forked from maccman/holla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidebar.js
More file actions
53 lines (41 loc) · 1.15 KB
/
Copy pathsidebar.js
File metadata and controls
53 lines (41 loc) · 1.15 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
(function($){
window.Sidebar = Spine.Controller.create({
events: {
"click [data-name]": "click"
},
elements: {
"#channels": "channels"
},
proxied: ["change", "render"],
template: function(item){
return $("#channelsTemplate").tmpl(item);
},
init: function(){
Channel.bind("refresh change", this.render);
this.App.bind("change", this.change);
},
render: function(){
var items = Channel.all();
this.channels.html(this.template(items));
// Select first channel
if ( !this.current )
this.$("[data-name=channels]:first").click();
},
change: function(type, item){
this.App.trigger("change:" + type, item);
this.deactivate();
var elements = this.$("[data-name=" + type + "]");
this.current = (item && elements.forItem(item)) || elements;
this.current.addClass("current");
},
click: function(e){
var element = $(e.target);
var type = element.attr("data-name");
var item = element.item();
this.App.trigger("change", type, item);
},
deactivate: function(){
this.$("[data-name]").removeClass("current");
}
});
})(jQuery);