1 _kiwi
.model
.PanelList
= Backbone
.Collection
.extend({
2 model
: _kiwi
.model
.Panel
,
4 comparator: function (chan
) {
5 return chan
.get('name');
7 initialize: function (elements
, network
) {
9 // The network this PanelList is associated with
10 this.network
= network
;
12 this.view
= new _kiwi
.view
.Tabs({model
: this});
14 // Holds the active panel
17 // Keep a tab on the active panel
18 this.bind('active', function (active_panel
) {
19 this.active
= active_panel
;
25 getByName: function (name
) {
26 if (typeof name
!== 'string') return;
28 return this.find(function (c
) {
29 return name
.toLowerCase() === c
.get('name').toLowerCase();
36 _kiwi
.model
.NetworkPanelList
= Backbone
.Collection
.extend({
37 model
: _kiwi
.model
.Network
,
39 initialize: function() {
40 this.view
= new _kiwi
.view
.NetworkTabs({model
: this});
42 this.on('add', this.onNetworkAdd
, this);
43 this.on('remove', this.onNetworkRemove
, this);
45 // Current active panel
46 this.active
= undefined;
47 this.active_connection
= undefined;
50 getByConnectionId: function(id
) {
51 return this.find(function(connection
){
52 return connection
.get('connection_id') == id
;
57 onNetworkAdd: function(network
) {
58 network
.panels
.on('active', this.onPanelActive
, this);
61 onNetworkRemove: function(network
) {
62 network
.panels
.off('active', this.onPanelActive
, this);
65 onPanelActive: function(panel
) {
66 var connection
= this.getByConnectionId(panel
.tab
.data('connection_id'));
67 this.trigger('active', panel
, connection
);
69 this.active_connection
= connection
;