diff options
author | Andreas Gohr <andi@splitbrain.org> | 2011-08-21 14:33:07 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2011-08-21 14:33:07 +0200 |
commit | ba72dce1b47b01a626df51666b84593d8cbc1050 (patch) | |
tree | 11a8a5a40c90e454b5b2b9b424a978bd0f32e71e /lib/scripts/page.js | |
parent | bedfa6abf0ea09be1ea44de0c014d83bd57a7412 (diff) | |
download | rpg-ba72dce1b47b01a626df51666b84593d8cbc1050.tar.gz rpg-ba72dce1b47b01a626df51666b84593d8cbc1050.tar.bz2 |
fixed TOC-Bug and moved TOC behaviour to page.js FS#2314
Diffstat (limited to 'lib/scripts/page.js')
-rw-r--r-- | lib/scripts/page.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/scripts/page.js b/lib/scripts/page.js index 05c5ece20..f3d35609d 100644 --- a/lib/scripts/page.js +++ b/lib/scripts/page.js @@ -10,6 +10,7 @@ dw_page = { init: function(){ dw_page.sectionHighlight(); jQuery('a.fn_top').mouseover(dw_page.footnoteDisplay); + dw_page.initTocToggle(); }, /** @@ -93,7 +94,38 @@ dw_page = { // now put the content into the wrapper $fndiv.html(content); $fndiv.show(); + }, + + /** + * Adds the toggle switch to the TOC + */ + initTocToggle: function() { + var $header = jQuery('#toc__header'); + if(!$header.length) return; + var $toc = jQuery('#toc__inside'); + + var setClicky = function(){ + if($toc.css('display') == 'none'){ + $clicky.html('<span>+</span>'); + $clicky[0].className = 'toc_open'; + }else{ + $clicky.html('<span>−</span>'); + $clicky[0].className = 'toc_close'; + } + }; + + var $clicky = jQuery(document.createElement('span')) + .attr('id','toc__toggle') + $header.css('cursor','pointer') + .click(function(){ + $toc.slideToggle(200,setClicky); + }) + .prepend($clicky); + + setClicky(); } + + }; jQuery(dw_page.init); |