Making use of panels.getByCid and fixing trailing whitespace
authorPaul Shahid <pshahid90@gmail.com>
Wed, 26 Mar 2014 02:06:22 +0000 (22:06 -0400)
committerPaul Shahid <pshahid90@gmail.com>
Wed, 26 Mar 2014 02:06:22 +0000 (22:06 -0400)
client/src/models/application.js
client/src/views/networktabs.js
client/src/views/tabs.js

index 05dd48251b020c7a9ecc4707c55098ab25b67582..ebf8edbcec3f4fe380a9e285ee196a3b4e9b3681 100644 (file)
@@ -127,7 +127,7 @@ _kiwi.model.Application = function () {
             this.message = new _kiwi.view.StatusMessage({el: this.view.$el.find('.status_message')[0]});\r
 \r
             this.resize_handle = new _kiwi.view.ResizeHandler({el: this.view.$el.find('.memberlists_resize_handle')[0]});\r
-            \r
+\r
             // Rejigg the UI sizes\r
             this.view.doLayout();\r
         };\r
index 6af6a4642ce8302f737987b63811f0800323ebfe..1e756920d0bf2883decaefd807732c5538a8e7aa 100644 (file)
@@ -18,7 +18,7 @@ _kiwi.view.NetworkTabs = Backbone.View.extend({
 
     networkRemoved: function(network) {
         network.panels.view.remove();
-        
+
         _kiwi.app.view.doLayout();
     }
 });
\ No newline at end of file
index 25f5cc653ad466229bca143fbcb1615f1e4718cb..527592e9139ba16f2ddcd492d4dcd6783e8a3d06 100644 (file)
@@ -88,21 +88,20 @@ _kiwi.view.Tabs = Backbone.View.extend({
         _kiwi.app.view.doLayout();
     },
     panelRemoved: function (panel) {
-        var that = this;
+        var connection = _kiwi.app.connections.active_connection;
 
         panel.tab.remove();
 
-        var connection = _kiwi.app.connections.active_connection;
-
         // If closing the active panel, switch to the last-accessed panel
         if (this.panel_access[0] === _kiwi.app.panels().active.cid) {
             this.panel_access.shift();
 
-            _.forEach(connection.panels.models, function(model) {
-                if (model.cid === that.panel_access[0]) {
-                    model.view.show();
-                }
-            });
+            //Get the last-accessed panel model now that we removed the closed one
+            var model = connection.panels.getByCid(this.panel_access[0]);
+
+            if (model) {
+                model.view.show();
+            }
         }
 
         delete panel.tab;
@@ -111,6 +110,8 @@ _kiwi.view.Tabs = Backbone.View.extend({
     },
 
     panelActive: function (panel, previously_active_panel) {
+        var panel_index = this.panel_access.indexOf(panel.cid);
+
         // Remove any existing tabs or part images
         _kiwi.app.view.$el.find('.panellist .part').remove();
         _kiwi.app.view.$el.find('.panellist .active').removeClass('active');
@@ -122,7 +123,6 @@ _kiwi.view.Tabs = Backbone.View.extend({
             panel.tab.append('<span class="part icon-nonexistant"></span>');
         }
 
-        var panel_index = this.panel_access.indexOf(panel.cid);
         if (panel_index > -1) {
             this.panel_access.splice(panel_index, 1);
         }