diff options
| author | Alon Levy <alon@pobox.com> | 2014-11-11 15:57:42 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-11-11 19:48:22 +0200 |
| commit | 06101d59dc1d67f0bb4194425b46f153f8a97c7e (patch) | |
| tree | c374b6f06be0d4d8392630082bda8821916b6007 /scripts/view/tab.js | |
| parent | 73ef7c098053592db020bc3691180c49e5f45cf6 (diff) | |
put .info into a tab
not using jquery tab since I just want an abstraction for 'show just
one' which is simpler, no labels.
Diffstat (limited to 'scripts/view/tab.js')
| -rw-r--r-- | scripts/view/tab.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/view/tab.js b/scripts/view/tab.js new file mode 100644 index 00000000..97ba1351 --- /dev/null +++ b/scripts/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 +}; + +}); |
