diff options
-rw-r--r-- | finder_menu.js | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/finder_menu.js b/finder_menu.js index 376ddd5..e21f5d2 100644 --- a/finder_menu.js +++ b/finder_menu.js @@ -12,6 +12,7 @@ function ul2finder() var showClass='shown';
var hideClass='hidden';
var openClass='open';
+ window.finderOpened = [];
// check if our finder list exists, if not, stop all activities
finder=document.getElementById('finder');
@@ -44,8 +45,13 @@ function ul2finder() // otherwise apply the parent class
cssjs('add',newa,parentClass);
+ // setup the link
+ ref = lis[i].getElementsByTagName('a')[0];
+ ref.id = 'finder[' + i + ']';
+ window.finderOpened[ref.id] = false;
+
// if the user clicks on the link
- lis[i].getElementsByTagName('a')[0].onclick=function()
+ ref.onclick=function()
{
// loop through all lists inside finder
for(var i=0;i<uls.length;i++)
@@ -72,17 +78,34 @@ function ul2finder() }
}
- if (this.isOpened == false || this.isOpened == null) {
- this.isOpened = true;
+ if (window.finderOpened[this.id] == false) {
+ window.finderOpened[this.id] = true;
// change the current link from parent to open
- cssjs('swap',this,parentClass,openClass);
- // show the current nested list
+ // and show the current nested list
+ cssjs('remove',this,parentClass);
+ cssjs('add',this,openClass);
cssjs('add',this.parentNode.getElementsByTagName('ul')[0],showClass);
+ children = this.childNodes;
+ refs = document.getElementById('finder').getElementsByTagName('a');
+ for (var i=0;i<refs.length;i++) {
+ found = false;
+ if (refs[i] != this) {
+ for(var j=0;j<children.lenght;j++) {
+ if (refs[i] == children[j]) {
+ found = true;
+ }
+ }
+ if (!found) {
+ window.finderOpened[refs[i].id] = false;
+ }
+ }
+ }
} else {
- this.isOpened = false;
+ window.finderOpened[this.id] = false;
// change the current link from open to parent
- cssjs('swap',this,openClass,parentClass);
- // hide the current nested list
+ // and hide the current nested list
+ cssjs('add',this,parentClass);
+ cssjs('remove',this,openClass);
cssjs('remove',this.parentNode.getElementsByTagName('ul')[0],showClass);
}
|