Merge branch 'development'
[KiwiIRC.git] / client / assets / dev / model_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 () {
8 this.view = new _kiwi.view.Tabs({"el": $('#tabs')[0], "model": this});
9
10 // Automatically create a server tab
11 this.add(new _kiwi.model.Server({'name': _kiwi.gateway.get('name')}));
12 this.server = this.getByName(_kiwi.gateway.get('name'));
13
14 // Holds the active panel
15 this.active = null;
16
17 // Keep a tab on the active panel
18 this.bind('active', function (active_panel) {
19 this.active = active_panel;
20 }, this);
21
22 },
23 getByName: function (name) {
24 if (typeof name !== 'string') return;
25 return this.find(function (c) {
26 return name.toLowerCase() === c.get('name').toLowerCase();
27 });
28 }
29 });