diff options
author | Matthias Schulte <post@lupo49.de> | 2011-07-17 12:18:37 +0200 |
---|---|---|
committer | Matthias Schulte <post@lupo49.de> | 2011-07-17 12:18:37 +0200 |
commit | 8e5a3957cd8de15f48dc27e9c07dfe4033fd6997 (patch) | |
tree | e819b734e24a3fb1a40da50383dfbaf34ba3b1d6 /lib/scripts/behaviour.js | |
parent | 3f3f8d1d768a4996d5a2fcc0ce8715e455ce7cad (diff) | |
parent | 1e542e417725bb148253929fac9146832d978e45 (diff) | |
download | rpg-8e5a3957cd8de15f48dc27e9c07dfe4033fd6997.tar.gz rpg-8e5a3957cd8de15f48dc27e9c07dfe4033fd6997.tar.bz2 |
Merge remote branch 'upstream/master'
Diffstat (limited to 'lib/scripts/behaviour.js')
-rw-r--r-- | lib/scripts/behaviour.js | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index 62c20eb0f..dd7676432 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -8,7 +8,6 @@ * automatically whenever a certain object is in the DOM or a certain CSS * class was found */ - var dw_behaviour = { init: function(){ @@ -18,15 +17,16 @@ var dw_behaviour = { dw_behaviour.removeHighlightOnClick(); dw_behaviour.quickSelect(); dw_behaviour.checkWindowsShares(); + dw_behaviour.initTocToggle(); }, /** * Looks for an element with the ID scroll__here at scrolls to it */ scrollToMarker: function(){ - var obj = jQuery('#scroll__here'); - if(obj.length) { - obj[0].scrollIntoView(); + var $obj = jQuery('#scroll__here'); + if($obj.length) { + $obj[0].scrollIntoView(); } }, @@ -90,8 +90,56 @@ var dw_behaviour = { jQuery('a.windows').live('click', function(){ alert(LANG.nosmblinks); }); + }, + + /** + * Adds the toggle switch to the TOC + */ + initTocToggle: function() { + var $header = jQuery('#toc__header'); + if(!$header.length) return; + var $toc = jQuery('#toc__inside'); + + var $clicky = jQuery(document.createElement('span')) + .attr('id','toc__toggle') + .css('cursor','pointer') + .click(function(){ + $toc.slideToggle(); + setClicky(); + }); + $header.prepend($clicky); + + 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'; + } + }; + + setClicky(); } }; +jQuery.fn.dw_hide = function(fn) { + return this.slideUp('fast', fn); +}; + +jQuery.fn.dw_show = function() { + return this.slideDown('fast'); +}; + +jQuery.fn.dw_toggle = function(bool) { + return this.each(function() { + var $this = jQuery(this); + if (typeof bool === 'undefined') { + bool = $this.is(':hidden'); + } + $this[bool ? "dw_show" : "dw_hide" ](); + }); +}; + jQuery(dw_behaviour.init); |