1/** 2 * javascript functionality for the arctic template 3 * copies the mothod for dokuwikis TOC functionality 4 * in order to keep the template XHTML valid 5 */ 6 7/** 8 * Adds the toggle switch to the TOC 9 */ 10function addSbTocToggle() { 11 if(!document.getElementById) return; 12 var header = $('sb__toc__header'); 13 if(!header) return; 14 15 var obj = document.createElement('span'); 16 obj.id = 'sb__toc__toggle'; 17 obj.innerHTML = '<span>−</span>'; 18 obj.className = 'toc_close'; 19 obj.style.cursor = 'pointer'; 20 21 prependChild(header,obj); 22 obj.parentNode.onclick = toggleSbToc; 23 try { 24 obj.parentNode.style.cursor = 'pointer'; 25 obj.parentNode.style.cursor = 'hand'; 26 }catch(e){} 27} 28 29/** 30 * This toggles the visibility of the Table of Contents 31 */ 32function toggleSbToc() { 33 var toc = $('sb__toc__inside'); 34 var obj = $('sb__toc__toggle'); 35 if(toc.style.display == 'none') { 36 toc.style.display = ''; 37 obj.innerHTML = '<span>−</span>'; 38 obj.className = 'toc_close'; 39 } else { 40 toc.style.display = 'none'; 41 obj.innerHTML = '<span>+</span>'; 42 obj.className = 'toc_open'; 43 } 44} 45 46// attach TOC event 47addInitEvent(addSbTocToggle); 48 49// attach the AJAX index to the sidebar index 50addInitEvent(function(){ 51 index.treeattach($('sb__index__tree')); 52}); 53