kodoc.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. $(document).ready(function()
  2. {
  3. // Syntax highlighter
  4. $('pre:not(.debug) code').each(function()
  5. {
  6. $(this).addClass('brush: php, class-name: highlighted');
  7. });
  8. SyntaxHighlighter.config.tagName = 'code';
  9. // Don't show the toolbar or line-numbers.
  10. SyntaxHighlighter.defaults.gutter = false;
  11. SyntaxHighlighter.all();
  12. // Any link that has the current page as its href should be class="current"
  13. $('a[href="'+ window.location.pathname +'"]').addClass('current');
  14. // Breadcrumbs magic
  15. $('#kodoc-breadcrumb li.last').each(function()
  16. {
  17. var $this = $(this);
  18. var $topics = $('#kodoc-topics li').has('a.current').slice(0, -1);
  19. $topics.each(function()
  20. {
  21. // Create a copy of the menu link
  22. var $crumb = $(this).children('a:first, span:not(.toggle):first').clone();
  23. // Insert the menu link into the breadcrumbs
  24. $('<li></li>').html($crumb).insertBefore($this);
  25. });
  26. });
  27. // Collapsing menus
  28. $('#kodoc-topics li:has(li)').each(function()
  29. {
  30. var $this = $(this);
  31. var toggle = $('<span class="toggle"></span>');
  32. var menu = $this.find('>ul,>ol');
  33. toggle.click(function()
  34. {
  35. if (menu.is(':visible'))
  36. {
  37. menu.stop(true, true).slideUp('fast');
  38. toggle.html('+');
  39. }
  40. else
  41. {
  42. menu.stop(true, true).slideDown('fast');
  43. toggle.html('&ndash;');
  44. }
  45. });
  46. $this.find('>span').click(function()
  47. {
  48. // Menu without a link
  49. toggle.click();
  50. });
  51. if ( ! $this.is(':has(a.current)'))
  52. {
  53. menu.hide();
  54. }
  55. toggle.html(menu.is(':visible') ? '&ndash;' : '+').prependTo($this);
  56. });
  57. // Show source links
  58. $('#kodoc-main .method-source').each(function()
  59. {
  60. var self = $(this);
  61. var togg = $(' <a class="sourcecode-toggle">[show]</a>').appendTo($('h4', self));
  62. var code = self.find('pre').hide();
  63. togg.toggle(function()
  64. {
  65. togg.html('[hide]');
  66. code.stop(true, true).slideDown();
  67. },
  68. function()
  69. {
  70. togg.html('[show]');
  71. code.stop(true, true).slideUp();
  72. });
  73. });
  74. // "Link to this" link that appears when you hover over a header
  75. $('#kodoc-body')
  76. .find('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]')
  77. .append(function(){
  78. var $this = $(this);
  79. return '<a href="#' + $this.attr('id') + '" class="permalink">link to this</a>';
  80. });
  81. });