diff options
author | sembrestels <sembrestels@riseup.net> | 2011-10-13 15:23:11 +0200 |
---|---|---|
committer | sembrestels <sembrestels@riseup.net> | 2011-10-13 15:23:11 +0200 |
commit | 74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf (patch) | |
tree | 834c120d692be288f261bcae169eedd3d6b31d74 /vendors/dokuwiki/lib/plugins/indexmenu/script.js | |
parent | f8be8643f0faadb2c0ce87d553b7b9d569af5afd (diff) | |
download | elgg-74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf.tar.gz elgg-74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf.tar.bz2 |
Rename lib/dokuwiki to vendors/dokuwiki
Diffstat (limited to 'vendors/dokuwiki/lib/plugins/indexmenu/script.js')
-rw-r--r-- | vendors/dokuwiki/lib/plugins/indexmenu/script.js | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/vendors/dokuwiki/lib/plugins/indexmenu/script.js b/vendors/dokuwiki/lib/plugins/indexmenu/script.js new file mode 100644 index 000000000..411f0fde5 --- /dev/null +++ b/vendors/dokuwiki/lib/plugins/indexmenu/script.js @@ -0,0 +1,152 @@ +/* Queue of loaded script files */ +var indexmenu_jsqueue = []; +/* Queue of loaded css files */ +var indexmenu_cssqueue = []; +/* Queue of nojs trees */ +var indexmenu_nojsqueue = []; + +function indexmenu_findExt(path){ + var ext = "gif"; + var cext = path.lastIndexOf("."); + if ( cext > -1){ + cext++; + cext = path.substring(cext, path.length).toLowerCase(); + if ((cext == "png") || (cext == "jpg")) {ext = cext;} + } + return ext; +} + +function indexmenu_createTocMenu(get,picker,btn) { + var toc_picker = DOKUid(picker); + if (!toc_picker) { + toc_picker=indexmenu_createPicker(picker); + toc_picker.className='dokuwiki indexmenu_toc'; + toc_picker.innerHTML='<a href="#"><img src="'+DOKU_BASE+'lib/plugins/indexmenu/images/close.gif" class="indexmenu_close" /></a><div />'; + addEvent(toc_picker.firstChild, 'click',function (event) {event.stopPropagation();return indexmenu_showPicker(picker)}); + } else { + toc_picker.style.display = 'none'; + } + indexmenu_ajaxmenu(get,toc_picker,DOKUid(btn),toc_picker.childNodes[1]); +} + +function indexmenu_ajaxmenu(get,picker,btn,container,oncomplete) { + var indx_list; + if (container) { + indx_list = container; + } else { + indx_list = picker; + } + if (!indexmenu_showPicker(picker,btn)) return; + // We use SACK to do the AJAX requests + var ajax = new sack(DOKU_BASE+'lib/plugins/indexmenu/ajax.php'); + ajax.encodeURIString=false; + ajax.onLoading = function () { + indx_list.innerHTML='<div class="tocheader">Loading .....</div>'; + }; + + // define callback + ajax.onCompletion = function(){ + var data = this.response; + indx_list.innerHTML=""; + if (isFunction(oncomplete)) { + oncomplete(data,indx_list); + } else { + indx_list.innerHTML=data; + } + }; + + ajax.runAJAX(encodeURI(get)); +} + +function indexmenu_createPicker(id,cl) { + var indx_list = document.createElement('div'); + indx_list.className = cl || 'picker'; + indx_list.id=id; + indx_list.style.position = 'absolute'; + indx_list.style.display = 'none'; + var body = document.getElementsByTagName('body')[0]; + body.appendChild(indx_list); + return indx_list; +} + +function indexmenu_showPicker(pickerid,btn){ + var x = 3, y = 3, picker = DOKUid(pickerid); + if(picker.style.display == 'none'){ + x += findPosX(btn); + y += findPosY(btn); + if (picker.id != 'picker_plugin_indexmenu') { + x += btn.offsetWidth-3; + } else { + y += btn.offsetHeight; + } + picker.style.display = 'block'; + picker.style.left = x+'px'; + picker.style.top = y+'px'; + return true; + }else{ + picker.style.display = 'none'; + return false; + } +} + +function indexmenu_loadtoolbar(){ + var toolbar = DOKUid('tool__bar'); + if(!toolbar) return; + indexmenu_loadJs(DOKU_BASE+'lib/plugins/indexmenu/edit.js'); +} + +function indexmenu_loadJs(f){ + var basef = f.replace(/^.*[\/\\]/g, ''); + if (indexmenu_notinarray(indexmenu_jsqueue,basef)) { + var oLink = document.createElement("script"); + oLink.src = f; + oLink.type = "text/javascript"; + oLink.charset="utf-8"; + indexmenu_jsqueue.push(basef); + document.getElementsByTagName("head")[0].appendChild(oLink); + } +} + +function indexmenu_checkcontextm(n,obj,e){ + var k=0; + e=e||event; + if ((e.which == 3 || e.button == 2) || (window.opera && e.which == 1 && e.ctrlKey)) { + obj.contextmenu (n,e); + indexmenu_stopevt(e); + } +} + +function indexmenu_stopevt(e) { + if (!window.indexmenu_contextmenu) { + return true; + } + e=e||event; + e.preventdefault? e.preventdefault() : e.returnValue = false; + return false; +} + +function indexmenu_notinarray(array,val) { + for (var i = 0; i < array.length; i++) { + if (array[i] == val) { + return false; + } + } + return true; +} + +function indexmenu_mouseposition(obj,e) { +/*http://www.quirksmode.org/js/events_properties.html*/ + if (!e) e = window.event; + if (e.pageX || e.pageY) { + X = e.pageX; + Y = e.pageY; + } + else if (e.clientX || e.clientY) { + X = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + Y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } + obj.style.left=X-5+'px'; + obj.style.top=Y-5+'px'; +} + +addInitEvent(indexmenu_loadtoolbar); |