Adding panel_access to the application model for tracking tab history
authorPaul Shahid <pshahid90@gmail.com>
Thu, 6 Feb 2014 05:20:23 +0000 (00:20 -0500)
committerPaul Shahid <pshahid90@gmail.com>
Thu, 6 Feb 2014 05:20:23 +0000 (00:20 -0500)
client/src/applets/chanlist.js
client/src/models/application.js
client/src/models/panel.js
client/src/views/networktabs.js
client/src/views/tabs.js

index 2e909c014fbe8ae2bf61e9bba6c238e0866dd631..f6859693b4eed18dc502e1965ba9f87a077aaa91 100644 (file)
 \r
 \r
         dispose: function () {\r
+            console.log("Dispose oooooo");\r
             this.view.channels = null;\r
             this.view.unbind();\r
             this.view.$el.html('');\r
index ebf8edbcec3f4fe380a9e285ee196a3b4e9b3681..eb6b8079f6247cf2e580dd4f65e9c5c1f5151ca2 100644 (file)
@@ -128,6 +128,8 @@ _kiwi.model.Application = function () {
 \r
             this.resize_handle = new _kiwi.view.ResizeHandler({el: this.view.$el.find('.memberlists_resize_handle')[0]});\r
 \r
+            this.panel_access = new Array();\r
+\r
             // Rejigg the UI sizes\r
             this.view.doLayout();\r
         };\r
index 943658e7acdd697225545673afe79fd90317d201..71415572739ac4b2348aa58f510a4f5df999a5c2 100644 (file)
@@ -9,6 +9,7 @@ _kiwi.model.Panel = Backbone.Model.extend({
     },\r
 \r
     closePanel: function () {\r
+        console.log("Closing panel");\r
         if (this.view) {\r
             this.view.unbind();\r
             this.view.remove();\r
@@ -27,9 +28,18 @@ _kiwi.model.Panel = Backbone.Model.extend({
         this.unbind();\r
         this.destroy();\r
 \r
-        // If closing the active panel, switch to the server panel\r
+        // If closing the active panel, switch to the last-accessed panel\r
         if (this === _kiwi.app.panels().active) {\r
-            _kiwi.app.connections.active_connection.panels.server.view.show();\r
+            _kiwi.app.panel_access.shift();\r
+\r
+            var modelsList = _kiwi.app.connections.active_connection.panels.models;\r
+            //Since it always has at least one tab, just go to the 0th element\r
+            for (var i=0; i < modelsList.length;i++) {\r
+                if (modelsList[i].cid === _kiwi.app.panel_access[0]) {\r
+                    console.log("Yap");\r
+                    modelsList[i].view.show();\r
+                }\r
+            }\r
         }\r
     },\r
 \r
index 1e756920d0bf2883decaefd807732c5538a8e7aa..00e6d31b27771fdeba98839cb1ec531be8c9f6cc 100644 (file)
@@ -18,7 +18,8 @@ _kiwi.view.NetworkTabs = Backbone.View.extend({
 
     networkRemoved: function(network) {
         network.panels.view.remove();
-
+        console.log("networkRemoved");
+        console.log(network);
         _kiwi.app.view.doLayout();
     }
 });
\ No newline at end of file
index 74b5a9584a258316bbe939fa8a67db40bbfb3adc..7b9cce8383a03e25d8e301b666fa42c095ce25f1 100644 (file)
@@ -85,7 +85,6 @@ _kiwi.view.Tabs = Backbone.View.extend({
     panelRemoved: function (panel) {
         panel.tab.remove();
         delete panel.tab;
-
         _kiwi.app.view.doLayout();
     },
 
@@ -100,6 +99,16 @@ _kiwi.view.Tabs = Backbone.View.extend({
         if (!panel.isServer()) {
             panel.tab.append('<span class="part icon-nonexistant"></span>');
         }
+
+        var panel_index = _kiwi.app.panel_access.indexOf(panel.cid);
+
+        if (panel_index > -1) {
+            _kiwi.app.panel_access.splice(panel_index, 1);
+        }
+
+        //Make this panel the most recently accessed
+        _kiwi.app.panel_access.unshift(panel.cid);
+
     },
 
     tabClick: function (e) {