From 74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf Mon Sep 17 00:00:00 2001 From: sembrestels Date: Thu, 13 Oct 2011 15:23:11 +0200 Subject: Rename lib/dokuwiki to vendors/dokuwiki --- vendors/dokuwiki/lib/scripts/index.js | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 vendors/dokuwiki/lib/scripts/index.js (limited to 'vendors/dokuwiki/lib/scripts/index.js') diff --git a/vendors/dokuwiki/lib/scripts/index.js b/vendors/dokuwiki/lib/scripts/index.js new file mode 100644 index 000000000..16b00c0ab --- /dev/null +++ b/vendors/dokuwiki/lib/scripts/index.js @@ -0,0 +1,116 @@ +/** + * Javascript for index view + * + * @author Andreas Gohr + */ + +var index = { + + /** + * Delay in ms before showing the throbber. + * Used to skip the throbber for fast AJAX calls. + */ + throbber_delay: 500, + + /** + * Attach event handlers to all "folders" below the given element + * + * @author Andreas Gohr + */ + treeattach: function(obj){ + if(!obj) return; + + var items = getElementsByClass('idx_dir',obj,'a'); + for(var i=0; i + * @author Ben Coburn + */ + toggle: function(e,clicky){ + var listitem = clicky.parentNode.parentNode; + + listitem.open = !listitem.open; + // listitem.open represents now the action to be done + + // if already open, close by removing the sublist + var sublists = listitem.getElementsByTagName('ul'); + if(!listitem.open){ + if (sublists.length) { + sublists[0].style.display='none'; + } + listitem.className='closed'; + e.preventDefault(); + return false; + } + + // just show if already loaded + if(sublists.length && listitem.open){ + sublists[0].style.display=''; + listitem.className='open'; + e.preventDefault(); + return false; + } + + // prepare an AJAX call to fetch the subtree + var ajax = new sack(DOKU_BASE + 'lib/exe/ajax.php'); + ajax.AjaxFailedAlert = ''; + ajax.encodeURIString = false; + if(ajax.failed) return true; + + //prepare the new ul + var ul = document.createElement('ul'); + ul.className = 'idx'; + timeout = window.setTimeout(function(){ + // show the throbber as needed + if (listitem.open) { + ul.innerHTML = '
  • loading...
  • '; + listitem.appendChild(ul); + listitem.className='open'; + } + }, this.throbber_delay); + ajax.elementObj = ul; + ajax.afterCompletion = function(){ + window.clearTimeout(timeout); + index.treeattach(ul); + if (listitem.className!='open') { + if (!listitem.open) { + ul.style.display='none'; + } + listitem.appendChild(ul); + if (listitem.open) { + listitem.className='open'; + } + } + }; + ajax.runAJAX(clicky.search.substr(1)+'&call=index'); + e.preventDefault(); + return false; + } +}; + + +addInitEvent(function(){ + if (DOKUid('index__tree')) + index.treeattach(DOKUid('index__tree')); +}); -- cgit v1.2.3