Merge branch 'ResidentBiscuit-rb_ui_work' into development
[KiwiIRC.git] / client / src / models / panellist.js
1 _kiwi.model.PanelList = Backbone.Collection.extend({
2 model: _kiwi.model.Panel,
3
4 comparator: function (chan) {
5 return chan.get('name');
6 },
7 initialize: function (elements, network) {
8 var that = this;
9
10 // If this PanelList is associated with a network/connection
11 if (network) {
12 this.network = network;
13 }
14
15 this.view = new _kiwi.view.Tabs({model: this});
16
17 // Holds the active panel
18 this.active = null;
19
20 // Keep a tab on the active panel
21 this.bind('active', function (active_panel) {
22 this.active = active_panel;
23 }, this);
24
25 this.bind('add', function(panel) {
26 panel.set('panel_list', this);
27 });
28 },
29
30
31
32 getByCid: function (cid) {
33 if (typeof name !== 'string') return;
34
35 return this.find(function (c) {
36 return cid === c.cid;
37 });
38 },
39
40
41
42 getByName: function (name) {
43 if (typeof name !== 'string') return;
44
45 return this.find(function (c) {
46 return name.toLowerCase() === c.get('name').toLowerCase();
47 });
48 }
49 });