Merge pull request #86 from kohana/3.3/bug/travis-composer-no-interaction
[kohana-userguide.git] / media / guide / js / kodoc.js
blob1dab95d57e6ed9c9662618a524e3d00a0d668315
1 $(document).ready(function()
4 // Syntax highlighter
6         $('pre:not(.debug) code').each(function()
7         {
8                 $(this).addClass('brush: php, class-name: highlighted');
9         });
11         SyntaxHighlighter.config.tagName = 'code';
12         // Don't show the toolbar or line-numbers.
13         SyntaxHighlighter.defaults.gutter = false;
14         SyntaxHighlighter.all();
15         
16         // Any link that has the current page as its href should be class="current"
17         $('a[href="'+ window.location.pathname +'"]').addClass('current');
19         // Breadcrumbs magic
20         $('#kodoc-breadcrumb li.last').each(function()
21         {
22                 var $this = $(this);
23                 var $topics = $('#kodoc-topics li').has('a.current').slice(0, -1);
25                 $topics.each(function()
26                 {
27                         // Create a copy of the menu link
28                         var $crumb = $(this).children('a:first, span:not(.toggle):first').clone();
30                         // Insert the menu link into the breadcrumbs
31                         $('<li></li>').html($crumb).insertBefore($this);
32                 });
33         });
35 // Show source links
37         $('#kodoc-main .method-source').each(function()
38         {
39                 var self = $(this);
40                 var togg = $(' <a class="sourcecode-toggle">[show]</a>').appendTo($('h4', self));
41                 var code = self.find('pre').hide();
43                 togg.toggle(function()
44                 {
45                         togg.html('[hide]');
46                         code.stop(true, true).slideDown();
47                 },
48                 function()
49                 {
50                         togg.html('[show]');
51                         code.stop(true, true).slideUp();
52                 });
53         });
55         // "Link to this" link that appears when you hover over a header
56         $('#kodoc-body')
57                 .find('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]')
58                 .append(function(){
59                         var $this = $(this);
60                         return '<a href="#' + $this.attr('id') + '" class="permalink">link to this</a>';
61                 });
62 });