From 5b98f9e4c97b9ddcf9590d5092224d06865f32d9 Mon Sep 17 00:00:00 2001 From: Silvio Date: Thu, 1 Oct 2009 12:27:59 -0300 Subject: Initial code to hide the menu (3) --- finder_menu.js | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/finder_menu.js b/finder_menu.js index a03db53..7f08a94 100644 --- a/finder_menu.js +++ b/finder_menu.js @@ -59,30 +59,34 @@ function ul2finder() if(uls[i].getElementsByTagName('ul')[j] == this.parentNode.getElementsByTagName('ul')[0]) { - if (window.finderOpened[i] == false) { - window.finderOpened[i] = true; - found=true; - break; - } + found=true; + break; } } - // and hide all others - if(!found) - { - cssjs('add',uls[i],hideClass); - cssjs('remove',uls[i],showClass); - cssjs('remove',uls[i].parentNode.getElementsByTagName('a')[0],openClass); - cssjs('add',uls[i].parentNode.getElementsByTagName('a')[0],parentClass); - } else { - window.finderOpened[i] = false; - cssjs('remove',uls[i].parentNode.getElementsByTagName('a')[0],parentClass); - } - } - // change the current link from parent to open - cssjs('swap',this,parentClass,openClass) - // show the current nested list - cssjs('add',this.parentNode.getElementsByTagName('ul')[0],showClass) + // and hide all others + if(!found) + { + cssjs('add',uls[i],hideClass) + cssjs('remove',uls[i],showClass) + cssjs('remove',uls[i].parentNode.getElementsByTagName('a')[0],openClass) + cssjs('add',uls[i].parentNode.getElementsByTagName('a')[0],parentClass) + } + } + + if (window.finderOpened[i] == false) { + window.finderOpened[i] = true; + // change the current link from parent to open + cssjs('swap',this,parentClass,openClass); + // show the current nested list + cssjs('add',this.parentNode.getElementsByTagName('ul')[0],showClass); + } else { + window.finderOpened[i] = false; + // change the current link from open to parent + cssjs('swap',this,openClass,parentClass); + // hide the current nested list + cssjs('add',this.parentNode.getElementsByTagName('ul')[0],hideClass); + } // don't follow the real HREF of the link return false; -- cgit v1.2.3