Commit | Line | Data |
---|---|---|
eaaf73b0 D |
1 | _kiwi.model.PanelList = Backbone.Collection.extend({\r |
2 | model: _kiwi.model.Panel,\r | |
9df70c63 | 3 | \r |
9df70c63 | 4 | comparator: function (chan) {\r |
ce13508b | 5 | return chan.get('name');\r |
9df70c63 | 6 | },\r |
0e546dd4 | 7 | initialize: function (elements, network) {\r |
6d5faa6e | 8 | var that = this;\r |
fb321ba0 | 9 | \r |
c966123a D |
10 | // If this PanelList is associated with a network/connection\r |
11 | if (network) {\r | |
12 | this.network = network;\r | |
13 | }\r | |
fb321ba0 D |
14 | \r |
15 | this.view = new _kiwi.view.Tabs({model: this});\r | |
9df70c63 | 16 | \r |
85377d88 D |
17 | // Holds the active panel\r |
18 | this.active = null;\r | |
19 | \r | |
8b2a103d | 20 | // Keep a tab on the active panel\r |
9df70c63 D |
21 | this.bind('active', function (active_panel) {\r |
22 | this.active = active_panel;\r | |
23 | }, this);\r | |
6d5faa6e D |
24 | \r |
25 | this.bind('add', function(panel) {\r | |
26 | panel.set('panel_list', this);\r | |
27 | });\r | |
9df70c63 | 28 | },\r |
ce13508b D |
29 | \r |
30 | \r | |
31 | \r | |
e7d65587 D |
32 | getByCid: function (cid) {\r |
33 | if (typeof name !== 'string') return;\r | |
34 | \r | |
35 | return this.find(function (c) {\r | |
36 | return cid === c.cid;\r | |
37 | });\r | |
38 | },\r | |
39 | \r | |
40 | \r | |
41 | \r | |
9df70c63 D |
42 | getByName: function (name) {\r |
43 | if (typeof name !== 'string') return;\r | |
ce13508b | 44 | \r |
9df70c63 D |
45 | return this.find(function (c) {\r |
46 | return name.toLowerCase() === c.get('name').toLowerCase();\r | |
47 | });\r | |
48 | }\r | |
0e546dd4 | 49 | });\r |