summaryrefslogtreecommitdiff
path: root/src/view/tab.js
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-11-13 17:41:57 +0200
committerLV-426 <lv-426@taproot.org.il>2014-11-13 17:41:57 +0200
commit76d1de512a58f023ae348ae8500100490fba9915 (patch)
tree87a3df058d3aaf1a3f2c408a784ffe63209cdaac /src/view/tab.js
parent4a303d5a7a7e1f8327bb18a2ef3e3093a30a50b6 (diff)
rename scripts/ -> src/
Diffstat (limited to 'src/view/tab.js')
-rw-r--r--src/view/tab.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/view/tab.js b/src/view/tab.js
new file mode 100644
index 00000000..97ba1351
--- /dev/null
+++ b/src/view/tab.js
@@ -0,0 +1,57 @@
+"use strict"
+
+define(['jquery'],
+function($) {
+
+function Tab(dict) {
+ var k,
+ selector = {},
+ name = [];
+
+ for (k in dict) {
+ if (dict.hasOwnProperty(k) == false) {
+ continue;
+ }
+ selector[k] = dict[k];
+ name.push(k);
+ }
+ this._selector = selector;
+ this._name = name;
+}
+
+Tab.prototype.show = function(shown_name) {
+ var i,
+ name,
+ element;
+
+ for (i = 0 ; i < this._name.length ; ++i) {
+ name = this._name[i];
+ element = $(this._selector[name]);
+ if (name === shown_name) {
+ element.fadeIn(300);
+ } else {
+ element.hide();
+ }
+ }
+}
+
+Tab.prototype.hide = function() {
+ var i;
+
+ for (i = 0 ; i < this._name.length ; ++i) {
+ $(this._selector[this._name[i]]).fadeOut(300);
+ }
+}
+
+Tab.prototype.get = function(name, sel) {
+ // selector concatenation
+ var e = $(this._selector[name] + ' ' + sel);
+
+ return e;
+}
+
+return {
+ Tab: Tab
+};
+
+});