aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2009-10-03 19:08:10 -0300
committerSilvio <s1lv10@uol.com.br>2009-10-03 19:08:10 -0300
commitecd0a5c422114eb2d2482e471ff98890ac70da68 (patch)
treeb1a27ebb85223e32e220081cc74cb51f86d383d6
parentf8a4e7d146d572e0e4eb049f062fb9279c567351 (diff)
downloadfinder_menu-ecd0a5c422114eb2d2482e471ff98890ac70da68.tar.gz
finder_menu-ecd0a5c422114eb2d2482e471ff98890ac70da68.tar.bz2
Code cleanup and new function changelink()
-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