From 9de555450931ca264628c7b4528a01adc4779439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ctibor=20Bran=C4=8D=C3=ADk?= Date: Wed, 23 Mar 2016 20:36:47 +0100 Subject: Add template for the site to repo. --- lib/tpl/nowawes/script.js | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 lib/tpl/nowawes/script.js (limited to 'lib/tpl/nowawes/script.js') diff --git a/lib/tpl/nowawes/script.js b/lib/tpl/nowawes/script.js new file mode 100644 index 000000000..d80a97850 --- /dev/null +++ b/lib/tpl/nowawes/script.js @@ -0,0 +1,127 @@ +/** + * javascript functionality for the arctic template + * copies the mothod for dokuwikis TOC functionality + * in order to keep the template XHTML valid + */ + +/** + * Adds the toggle switch to the TOC + */ +function addSbLeftTocToggle() { + if(!document.getElementById) return; + var header = jQuery('#sb__left__toc__header'); + if(!header.length) return; + + var obj = document.createElement('span'); + obj.id = 'sb__left__toc__toggle'; + obj.innerHTML = ''; + obj.className = 'toc_close'; + obj.style.cursor = 'pointer'; + + //prependChild(header,obj); + jQuery( header ).prepend( obj ); + //obj.parentNode.onclick = toggleSbLeftToc; + jQuery( obj.parentNode ).bind( 'click', toggleSbLeftToc ); + try { + obj.parentNode.style.cursor = 'pointer'; + obj.parentNode.style.cursor = 'hand'; + }catch(e){} +} + +/** + * This toggles the visibility of the Table of Contents + */ +function toggleSbLeftToc() { + var toc = jQuery('#sb__left__toc__inside'); + var obj = jQuery('#sb__left__toc__toggle'); + if( toc.css( 'display' ) == 'none' ) { + toc.css( 'display', 'block' ); + obj.innerHTML = ''; + obj.className = 'toc_close'; + } else { + toc.css( 'display', 'none' ); + toc.style.display = 'none'; + obj.innerHTML = '+'; + obj.className = 'toc_open'; + } +} + +/** + * Adds the toggle switch to the TOC + */ +function addSbRightTocToggle() { + if(!document.getElementById) return; + var header = jQuery('#sb__right__toc__header'); + if(!header.length) return; + + var obj = document.createElement('span'); + obj.id = 'sb__right__toc__toggle'; + obj.innerHTML = ''; + obj.className = 'toc_close'; + obj.style.cursor = 'pointer'; + + //prependChild(header,obj); + jQuery( header ).prepend( obj ); + + //obj.parentNode.onclick = toggleSbRightToc; + jQuery( obj.parentNode ).bind( 'click', toggleSbRightToc ); + try { + obj.parentNode.style.cursor = 'pointer'; + obj.parentNode.style.cursor = 'hand'; + }catch(e){} +} + +/** + * This toggles the visibility of the Table of Contents + */ +function toggleSbRightToc() { + var toc = jQuery('#sb__right__toc__inside'); + var obj = jQuery('#sb__right__toc__toggle'); + + if( toc.css( 'display' ) == 'none' ) { + toc.css( 'display', 'block' ); + obj.innerHTML = ''; + obj.className = 'toc_close'; + } else { + toc.css( 'display', 'none' ); + obj.innerHTML = '+'; + obj.className = 'toc_open'; + } +} + +var left_dw_index = jQuery('#left__index__tree').dw_tree({deferInit: true, + load_data: function (show_sublist, $clicky) { + jQuery.post( + DOKU_BASE + 'lib/exe/ajax.php', + $clicky[0].search.substr(1) + '&call=index', + show_sublist, 'html' + ); + } +}); +var right_dw_index = jQuery('#right__index__tree').dw_tree({deferInit: true, + load_data: function (show_sublist, $clicky) { + jQuery.post( + DOKU_BASE + 'lib/exe/ajax.php', + $clicky[0].search.substr(1) + '&call=index', + show_sublist, 'html' + ); + } +}); + +jQuery(function(){ +// from lib/scripts/index.js + var $tree = jQuery('#left__index__tree'); + left_dw_index.$obj = $tree; + left_dw_index.init(); + + var $tree = jQuery('#right__index__tree'); + right_dw_index.$obj = $tree; + right_dw_index.init(); + +// add TOC events + jQuery(addSbLeftTocToggle); + jQuery(addSbRightTocToggle); + +}); + +// vim:ts=4:sw=4:et:enc=utf-8: -- cgit v1.2.3