From 8fcd04535b4df0fbd72f287199aee1b531958f91 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 27 Apr 2013 19:01:58 +0100 Subject: [PATCH] model_networkpanellist extracted to its own file --- client/assets/dev/build.js | 1 + client/assets/dev/index.html.tmpl | 6 +- client/assets/dev/model_networkpanellist.js | 62 ++++++++++++++++++++ client/assets/dev/model_panellist.js | 65 --------------------- 4 files changed, 65 insertions(+), 69 deletions(-) create mode 100644 client/assets/dev/model_networkpanellist.js diff --git a/client/assets/dev/build.js b/client/assets/dev/build.js index 723db16..8adba49 100644 --- a/client/assets/dev/build.js +++ b/client/assets/dev/build.js @@ -37,6 +37,7 @@ var src = concat([ __dirname + '/model_memberlist.js', __dirname + '/model_panel.js', __dirname + '/model_panellist.js', + __dirname + '/model_networkpanellist.js', __dirname + '/model_query.js', __dirname + '/model_channel.js', __dirname + '/model_server.js', diff --git a/client/assets/dev/index.html.tmpl b/client/assets/dev/index.html.tmpl index bff13ff..40cd32e 100644 --- a/client/assets/dev/index.html.tmpl +++ b/client/assets/dev/index.html.tmpl @@ -23,10 +23,7 @@ -
- - -
+
@@ -278,6 +275,7 @@ ], [ 'dev/model_panellist.js', + 'dev/model_networkpanellist.js', 'dev/model_panel.js', 'dev/model_member.js', 'dev/model_memberlist.js' diff --git a/client/assets/dev/model_networkpanellist.js b/client/assets/dev/model_networkpanellist.js new file mode 100644 index 0000000..96785c3 --- /dev/null +++ b/client/assets/dev/model_networkpanellist.js @@ -0,0 +1,62 @@ +_kiwi.model.NetworkPanelList = Backbone.Collection.extend({ + model: _kiwi.model.Network, + + initialize: function() { + this.view = new _kiwi.view.NetworkTabs({model: this}); + + this.on('add', this.onNetworkAdd, this); + this.on('remove', this.onNetworkRemove, this); + + // Current active connection / panel + this.active_connection = undefined; + this.active_panel = undefined; + + // TODO: Remove this - legacy + this.active = undefined; + }, + + getByConnectionId: function(id) { + return this.find(function(connection){ + return connection.get('connection_id') == id; + }); + }, + + panels: function() { + var panels = []; + + this.each(function(network) { + panels = panels.concat(network.panels.models); + }); + + return panels; + }, + + + onNetworkAdd: function(network) { + network.panels.on('active', this.onPanelActive, this); + + // if it's our first connection, set it active + if (this.models.length === 1) { + this.active_connection = network; + this.active_panel = network.panels.server; + + // TODO: Remove this - legacy + this.active = this.active_panel; + } + }, + + onNetworkRemove: function(network) { + network.panels.off('active', this.onPanelActive, this); + }, + + onPanelActive: function(panel) { + var connection = this.getByConnectionId(panel.tab.data('connection_id')); + this.trigger('active', panel, connection); + + this.active_connection = connection; + this.active_panel = panel; + + // TODO: Remove this - legacy + this.active = panel; + } +}); \ No newline at end of file diff --git a/client/assets/dev/model_panellist.js b/client/assets/dev/model_panellist.js index 39d1a1a..b1050fd 100644 --- a/client/assets/dev/model_panellist.js +++ b/client/assets/dev/model_panellist.js @@ -37,68 +37,3 @@ _kiwi.model.PanelList = Backbone.Collection.extend({ }); } }); - - - -_kiwi.model.NetworkPanelList = Backbone.Collection.extend({ - model: _kiwi.model.Network, - - initialize: function() { - this.view = new _kiwi.view.NetworkTabs({model: this}); - - this.on('add', this.onNetworkAdd, this); - this.on('remove', this.onNetworkRemove, this); - - // Current active connection / panel - this.active_connection = undefined; - this.active_panel = undefined; - - // TODO: Remove this - legacy - this.active = undefined; - }, - - getByConnectionId: function(id) { - return this.find(function(connection){ - return connection.get('connection_id') == id; - }); - }, - - panels: function() { - var panels = []; - - this.each(function(network) { - panels = panels.concat(network.panels.models); - }); - - return panels; - }, - - - onNetworkAdd: function(network) { - network.panels.on('active', this.onPanelActive, this); - - // if it's our first connection, set it active - if (this.models.length === 1) { - this.active_connection = network; - this.active_panel = network.panels.server; - - // TODO: Remove this - legacy - this.active = this.active_panel; - } - }, - - onNetworkRemove: function(network) { - network.panels.off('active', this.onPanelActive, this); - }, - - onPanelActive: function(panel) { - var connection = this.getByConnectionId(panel.tab.data('connection_id')); - this.trigger('active', panel, connection); - - this.active_connection = connection; - this.active_panel = panel; - - // TODO: Remove this - legacy - this.active = panel; - } -}); \ No newline at end of file -- 2.25.1