diff options
-rw-r--r-- | finder_menu.js | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/finder_menu.js b/finder_menu.js index f05ae18..ce8e6a9 100644 --- a/finder_menu.js +++ b/finder_menu.js @@ -86,24 +86,26 @@ function ul2finder() cssjs('add',this,openClass);
cssjs('add',this.parentNode.getElementsByTagName('ul')[0],showClass);
- // unset window.finderNode for all other nodes that aren't children
+ // unset window.finderNode for all other nodes that aren't children or parent
children = this.parentNode.childNodes;
refs = document.getElementById('finder').getElementsByTagName('a');
for (var i=0;i<refs.length;i++) {
found = false;
- if (refs[i] != this) {
- // search at children
+ if (refs[i] == this) {
+ found = true;
+ } else if (isparent(refs[i].parentNode, this)) {
+ found = true;
+ } else {
for(var j=0;j<children.lenght;j++) {
if (refs[i] == children[j]) {
found = true;
break;
}
}
- // TODO: search at parent
- if (!found) {
- window.finderOpened[refs[i].id] = false;
- refs[i].innerHTML = window.finderOpened[refs[i].id];
- }
+ }
+ if (!found) {
+ window.finderOpened[refs[i].id] = false;
+ refs[i].innerHTML = window.finderOpened[refs[i].id];
}
}
} else {
@@ -113,7 +115,6 @@ function ul2finder() cssjs('add',this,parentClass);
cssjs('remove',this,openClass);
children = this.parentNode.getElementsByTagName('ul');
- // TODO: check and fix
for(var j=0;j<children.lenght;j++) {
cssjs('remove',children[j],showClass);
children[j].innerHTML = window.finderOpened[refs[i].id];
@@ -125,6 +126,19 @@ function ul2finder() return false;
}
}
+ function isparent(par, child) {
+ if (par.hasChildNodes()) {
+ children = par.childNodes;
+ for (var i=0;i<children.length;i++) {
+ if (children[i] == child) {
+ return true;
+ } else if (isparent(children[i], child)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
/*
* cssjs
* written by Christian Heilmann (http://icant.co.uk)
|