aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--finder_menu.js41
1 files changed, 27 insertions, 14 deletions
diff --git a/finder_menu.js b/finder_menu.js
index 2aec3f7..17efa76 100644
--- a/finder_menu.js
+++ b/finder_menu.js
@@ -65,28 +65,18 @@ function ul2finder()
{
ref = uls[i].parentNode.getElementsByTagName('a')[0];
if (ref != this && !isparent(uls[i],parentUls[0])) {
- window.finderOpened[ref.id] = false;
- cssjs('add',uls[i],hideClass);
+ changelink('close', ref);
cssjs('remove',uls[i],showClass);
- cssjs('remove',ref,openClass);
- cssjs('add',ref,parentClass);
}
}
}
+ // open or close a given finder tab
if (window.finderOpened[this.id] == false) {
- window.finderOpened[this.id] = true;
- // change the current link from parent to open
- // and show the current nested list
- cssjs('remove',this,parentClass);
- cssjs('add',this,openClass);
+ changelink('open', this);
cssjs('add',parentUls[0],showClass);
} else {
- window.finderOpened[this.id] = false;
- // change the current link from open to parent
- // and hide the current nested list
- cssjs('add',this,parentClass);
- cssjs('remove',this,openClass);
+ changelink('close', this);
for(var u=0;u<parentUls.length;u++) {
cssjs('remove',parentUls[u],showClass);
}
@@ -98,6 +88,29 @@ function ul2finder()
}
/*
+ * changelink
+ * written by Silvio - s1lv10 at uol.com.br
+ * changes the state of a given finder link
+ */
+ function changelink(action, ref) {
+ var state = false;
+ switch (action) {
+ case 'open':
+ state = true;
+ classParent = 'remove';
+ classOpen = 'add';
+ break;
+ case 'close':
+ classParent = 'add';
+ classOpen = 'remove';
+ break;
+ }
+ window.finderOpened[ref.id] = state;
+ cssjs(classParent,ref,parentClass);
+ cssjs(classOpen,ref,openClass);
+ }
+
+ /*
* isparent
* written by Silvio - s1lv10 at uol.com.br
* checks if an element is parent of another via DOM