From: Cory Chaplin Date: Wed, 16 Jul 2014 20:59:08 +0000 (+0200) Subject: Add tab fallback for removed panels that have not been expressly closed X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d1925bdf7d54096eeb4ace5b044b1ab347898365;p=KiwiIRC.git Add tab fallback for removed panels that have not been expressly closed --- diff --git a/client/src/views/application.js b/client/src/views/application.js index dd68619..624a081 100644 --- a/client/src/views/application.js +++ b/client/src/views/application.js @@ -390,5 +390,19 @@ _kiwi.view.Application = Backbone.View.extend({ } } }); + + this.model.panels.on('remove', function(panel) { + // If closing the active panel, switch to the last-accessed panel + if (panel_access[0] === panel.cid) { + panel_access.shift(); + + //Get the last-accessed panel model now that we removed the closed one + var model = _.find(_kiwi.app.panels('applets').concat(_kiwi.app.panels('connections')), {cid: panel_access[0]}); + + if (model) { + model.view.show(); + } + } + }); } }); diff --git a/client/src/views/tabs.js b/client/src/views/tabs.js index 0af7973..20881a2 100644 --- a/client/src/views/tabs.js +++ b/client/src/views/tabs.js @@ -87,9 +87,10 @@ _kiwi.view.Tabs = Backbone.View.extend({ var connection = _kiwi.app.connections.active_connection; panel.tab.remove(); - delete panel.tab; + _kiwi.app.panels.trigger('remove', this); + _kiwi.app.view.doLayout(); },