forked from rmurphey/srchr
-
Notifications
You must be signed in to change notification settings - Fork 13
/
tabs.js
40 lines (30 loc) · 827 Bytes
/
tabs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
steal.plugins('jquery/controller')
.css('tabs')
.then(function(){
$.Controller.extend("Srchr.Tabs",{
// initialize code
init : function(el){
// activate the first tab
this.activate( $(el).children("li:first") )
// hide other tabs
var tab = this.tab;
this.element.addClass('ui-helper-clearfix').children("li:gt(0)").each(function(){
tab($(this)).hide()
})
},
// helper function finds the tab for a given li
tab : function(li){
return $(li.find("a").attr("href"))
},
// on an li click, activates new tab
"li click" : function(el, ev){
ev.preventDefault();
this.activate(el)
},
//hides old activate tab, shows new one
activate : function(el){
this.tab(this.find('.active').removeClass('active')).hide()
this.tab(el.addClass('active')).show().trigger("show");
}
})
})