diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-07-26 00:24:27 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-07-26 00:24:27 -0400 |
commit | 8dd07c0ddd99ae626a1ec8c06f75f27fed51269f (patch) | |
tree | 261d3c9911dabc58c1ac54e4e36b3dee24d2032b /public/ng/js/lib/tabs.js | |
parent | 0a739cf9ac901f54484c34bba8322418dedb09b0 (diff) |
New UI merge in progress
Diffstat (limited to 'public/ng/js/lib/tabs.js')
-rw-r--r-- | public/ng/js/lib/tabs.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/public/ng/js/lib/tabs.js b/public/ng/js/lib/tabs.js new file mode 100644 index 00000000..98216720 --- /dev/null +++ b/public/ng/js/lib/tabs.js @@ -0,0 +1,39 @@ +/** + * Created by fuxiaohei on 14-6-26. + */ + +function Tabs(selector) { + + function hide($nav) { + console.log("hide", $nav); + $nav.removeClass("js-tab-nav-show"); + $($nav.data("tab-target")).removeClass("js-tab-show").hide(); + } + + function show($nav) { + console.log("show", $nav); + $nav.addClass("js-tab-nav-show"); + $($nav.data("tab-target")).addClass("js-tab-show").show(); + } + + var $e = $(selector); + if ($e.length) { + // pre-assign init index + var $current = $e.find('.js-tab-nav-show'); + if ($current.length) { + $($current.data("tab-target")).addClass("js-tab-show"); + } + // bind nav click + $e.on("click", ".js-tab-nav", function () { + var $this = $(this); + // is showing, not change. + if ($this.hasClass("js-tab-nav-show")) { + return; + } + $current = $e.find(".js-tab-nav-show").eq(0); + hide($current); + show($this); + }); + console.log("init tabs @", selector) + } +}
\ No newline at end of file |