Skip to content
Snippets Groups Projects
Commit c00de546 authored by michael's avatar michael
Browse files

Fixed doubleclick-behaviour of links, fixes FS#1389

There is a new open-attribute of listitems that represents the state that should be achieved or the current state. This makes it possible that clicks that occur when the opening of the listitem has already been triggered close it again and the listitem won't be reopened when the ajax-call is finished.

darcs-hash:20081012141018-074e0-f9be8bbe89083df761d71f665b409bc95e450bf3.gz
parent 83434a91
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,16 @@ index = {
// attach action to make the link clickable by AJAX
addEvent(elem,'click',function(e){ return index.toggle(e,this); });
// get the listitem the elem belongs to
var listitem = elem.parentNode;
while (listitem.tagName != 'LI') {
listitem = listitem.parentNode;
}
//when there are uls under this listitem mark this listitem as opened
if (listitem.getElementsByTagName('ul').length) {
listitem.open = true;
}
}
},
......@@ -40,17 +50,22 @@ index = {
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(sublists.length && listitem.className=='open'){
sublists[0].style.display='none';
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.className=='closed'){
if(sublists.length && listitem.open){
sublists[0].style.display='';
listitem.className='open';
e.preventDefault();
......@@ -68,17 +83,24 @@ index = {
ul.className = 'idx';
timeout = window.setTimeout(function(){
// show the throbber as needed
ul.innerHTML = '<li><img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="loading..." title="loading..." /></li>';
listitem.appendChild(ul);
listitem.className='open';
if (listitem.open) {
ul.innerHTML = '<li><img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="loading..." title="loading..." /></li>';
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') {
listitem.appendChild(ul);
if (!listitem.open) {
ul.style.display='none';
}
listitem.appendChild(ul);
if (listitem.open) {
listitem.className='open';
}
}
};
ajax.runAJAX(clicky.search.substr(1)+'&call=index');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment