aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2009-10-01 18:03:12 -0300
committerSilvio <s1lv10@uol.com.br>2009-10-01 18:03:12 -0300
commit27a9ddaec51e367fb3271940431e352c30e71603 (patch)
treeed64e2c67140b58eac18eb8078695bec1a0aa77a
parentf5fa8fbf4bb5b7c848cbc209e90592d0056ad579 (diff)
downloadfinder_menu-27a9ddaec51e367fb3271940431e352c30e71603.tar.gz
finder_menu-27a9ddaec51e367fb3271940431e352c30e71603.tar.bz2
Initial code to hide the menu (7)
-rw-r--r--finder_menu.js39
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);
}