aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2009-10-02 11:46:24 -0300
committerSilvio <s1lv10@uol.com.br>2009-10-02 11:46:24 -0300
commit4474f82dfa5c4bd05b9263766d520b540b079521 (patch)
tree5b819a53c25d1da27d0bd0b1f633dc1790531918
parentc6ddba99048322f43ae1e8d12f611120964cf7a4 (diff)
downloadfinder_menu-4474f82dfa5c4bd05b9263766d520b540b079521.tar.gz
finder_menu-4474f82dfa5c4bd05b9263766d520b540b079521.tar.bz2
Searching on children and parent
-rw-r--r--finder_menu.js32
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)