From 1797120df8302e0e5427311a88f3953d56dcfaaa Mon Sep 17 00:00:00 2001 From: Paul Shahid Date: Thu, 6 Feb 2014 00:20:23 -0500 Subject: [PATCH] Adding panel_access to the application model for tracking tab history --- client/src/applets/chanlist.js | 1 + client/src/models/application.js | 2 ++ client/src/models/panel.js | 14 ++++++++++++-- client/src/views/networktabs.js | 3 ++- client/src/views/tabs.js | 11 ++++++++++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/client/src/applets/chanlist.js b/client/src/applets/chanlist.js index 2e909c0..f685969 100644 --- a/client/src/applets/chanlist.js +++ b/client/src/applets/chanlist.js @@ -110,6 +110,7 @@ dispose: function () { + console.log("Dispose oooooo"); this.view.channels = null; this.view.unbind(); this.view.$el.html(''); diff --git a/client/src/models/application.js b/client/src/models/application.js index ebf8edb..eb6b807 100644 --- a/client/src/models/application.js +++ b/client/src/models/application.js @@ -128,6 +128,8 @@ _kiwi.model.Application = function () { this.resize_handle = new _kiwi.view.ResizeHandler({el: this.view.$el.find('.memberlists_resize_handle')[0]}); + this.panel_access = new Array(); + // Rejigg the UI sizes this.view.doLayout(); }; diff --git a/client/src/models/panel.js b/client/src/models/panel.js index 943658e..7141557 100644 --- a/client/src/models/panel.js +++ b/client/src/models/panel.js @@ -9,6 +9,7 @@ _kiwi.model.Panel = Backbone.Model.extend({ }, closePanel: function () { + console.log("Closing panel"); if (this.view) { this.view.unbind(); this.view.remove(); @@ -27,9 +28,18 @@ _kiwi.model.Panel = Backbone.Model.extend({ this.unbind(); this.destroy(); - // If closing the active panel, switch to the server panel + // If closing the active panel, switch to the last-accessed panel if (this === _kiwi.app.panels().active) { - _kiwi.app.connections.active_connection.panels.server.view.show(); + _kiwi.app.panel_access.shift(); + + var modelsList = _kiwi.app.connections.active_connection.panels.models; + //Since it always has at least one tab, just go to the 0th element + for (var i=0; i < modelsList.length;i++) { + if (modelsList[i].cid === _kiwi.app.panel_access[0]) { + console.log("Yap"); + modelsList[i].view.show(); + } + } } }, diff --git a/client/src/views/networktabs.js b/client/src/views/networktabs.js index 1e75692..00e6d31 100644 --- a/client/src/views/networktabs.js +++ b/client/src/views/networktabs.js @@ -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 diff --git a/client/src/views/tabs.js b/client/src/views/tabs.js index 74b5a95..7b9cce8 100644 --- a/client/src/views/tabs.js +++ b/client/src/views/tabs.js @@ -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(''); } + + 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) { -- 2.25.1