1 _kiwi
.model
.NetworkPanelList
= Backbone
.Collection
.extend({
2 model
: _kiwi
.model
.Network
,
4 initialize: function() {
5 this.view
= new _kiwi
.view
.NetworkTabs({model
: this});
7 this.on('add', this.onNetworkAdd
, this);
8 this.on('remove', this.onNetworkRemove
, this);
10 // Current active connection / panel
11 this.active_connection
= undefined;
12 this.active_panel
= undefined;
14 // TODO: Remove this - legacy
15 this.active
= undefined;
18 getByConnectionId: function(id
) {
19 return this.find(function(connection
){
20 return connection
.get('connection_id') == id
;
27 this.each(function(network
) {
28 panels
= panels
.concat(network
.panels
.models
);
35 onNetworkAdd: function(network
) {
36 network
.panels
.on('active', this.onPanelActive
, this);
38 // if it's our first connection, set it active
39 if (this.models
.length
=== 1) {
40 this.active_connection
= network
;
41 this.active_panel
= network
.panels
.server
;
43 // TODO: Remove this - legacy
44 this.active
= this.active_panel
;
48 onNetworkRemove: function(network
) {
49 network
.panels
.off('active', this.onPanelActive
, this);
52 onPanelActive: function(panel
) {
53 var connection
= this.getByConnectionId(panel
.tab
.data('connection_id'));
54 this.trigger('active', panel
, connection
);
56 this.active_connection
= connection
;
57 this.active_panel
= panel
;
59 // TODO: Remove this - legacy