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 addSbLeftTocToggle() { 11 if(!document.getElementById) return; 12 var header = $('sb__left__toc__header'); 13 if(!header) return; 14 15 var obj = document.createElement('span'); 16 obj.id = 'sb__left__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 = toggleSbLeftToc; 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 toggleSbLeftToc() { 33 var toc = $('sb__left__toc__inside'); 34 var obj = $('sb__left__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/** 47 * Adds the toggle switch to the TOC 48 */ 49function addSbRightTocToggle() { 50 if(!document.getElementById) return; 51 var header = $('sb__right__toc__header'); 52 if(!header) return; 53 54 var obj = document.createElement('span'); 55 obj.id = 'sb__right__toc__toggle'; 56 obj.innerHTML = '<span>−</span>'; 57 obj.className = 'toc_close'; 58 obj.style.cursor = 'pointer'; 59 60 prependChild(header,obj); 61 obj.parentNode.onclick = toggleSbRightToc; 62 try { 63 obj.parentNode.style.cursor = 'pointer'; 64 obj.parentNode.style.cursor = 'hand'; 65 }catch(e){} 66} 67 68/** 69 * This toggles the visibility of the Table of Contents 70 */ 71function toggleSbRightToc() { 72 var toc = $('sb__right__toc__inside'); 73 var obj = $('sb__right__toc__toggle'); 74 if(toc.style.display == 'none') { 75 toc.style.display = ''; 76 obj.innerHTML = '<span>−</span>'; 77 obj.className = 'toc_close'; 78 } else { 79 toc.style.display = 'none'; 80 obj.innerHTML = '<span>+</span>'; 81 obj.className = 'toc_open'; 82 } 83} 84 85// add TOC events 86addInitEvent(addSbLeftTocToggle); 87addInitEvent(addSbRightTocToggle); 88 89// add AJAX index events 90addInitEvent(function(){ 91 index.treeattach($('left__index__tree')); 92 index.treeattach($('right__index__tree')); 93}); 94 95// vim:ts=4:sw=4:et:enc=utf-8: 96