Don't close the window with the last group tab, if the last child of the group is closed. (#537)
This behaviour can be disabled (and get the old behaviour) by setting the preference "extensions.treestyletab.autoRemoveNeedlessGroupTab.lastTab" to "true".
This commit is contained in:
parent
f476b50001
commit
63a72c9e62
@ -625,6 +625,18 @@ pref("extensions.treestyletab.createSubtree.underParent", true);
|
||||
*/
|
||||
pref("extensions.treestyletab.pinnedTab.faviconized", true);
|
||||
|
||||
/**
|
||||
* Behaviour when the last child tab of the last group tab is closed.
|
||||
* By default TST closes needless group tabs when they have no child anymore.
|
||||
* However, if it is the last tab of an window or a group, then TST closes
|
||||
* the window (or enters to the tab groups view).
|
||||
* By changing these preferences, you can allow/disallow to close the window
|
||||
* (or enter to the groups view).
|
||||
* true: allow to close the last group tab automatically.
|
||||
* false: disallow to close the last group tab automatically.
|
||||
*/
|
||||
pref("extensions.treestyletab.autoRemoveNeedlessGroupTab.lastTab", false);
|
||||
|
||||
/**
|
||||
* Compatibility hack flags for other addons. They can be disabled by each
|
||||
* addon, when the addon become working with TST without dirty hacks.
|
||||
|
@ -1310,6 +1310,16 @@ var TreeStyleTabBase = {
|
||||
return Array.slice(b.mTabContainer.querySelectorAll('tab:not([hidden="true"])'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all hidden tabs in background groups as an array.
|
||||
*/
|
||||
getHiddenTabs : function TSTBase_getHiddenTabs(aTabBrowserChild)
|
||||
{
|
||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
||||
this.assertBeforeDestruction(b && b.mTabContainer);
|
||||
return Array.slice(b.mTabContainer.querySelectorAll('tab[hidden="true"]'));
|
||||
},
|
||||
|
||||
getAllTabsArray : function TSTBase_getAllTabsArray(aTabBrowserChild) /* for backward compatibility */
|
||||
{
|
||||
return this.getAllTabs(aTabBrowserChild);
|
||||
|
@ -3105,7 +3105,8 @@ TreeStyleTabBrowser.prototype = {
|
||||
var shouldCloseParentTab = (
|
||||
parent &&
|
||||
this.isGroupTab(parent) &&
|
||||
this.getDescendantTabs(parent).length == 1
|
||||
this.getDescendantTabs(parent).length == 1 &&
|
||||
this._canCloseLastGroupTab(parent)
|
||||
);
|
||||
if (shouldCloseParentTab)
|
||||
tabs.push(parent);
|
||||
@ -3113,6 +3114,14 @@ TreeStyleTabBrowser.prototype = {
|
||||
return tabs;
|
||||
},
|
||||
|
||||
_canCloseLastGroupTab : function TSTBrowser_canCloseLastGroupTab(aGroupTab)
|
||||
{
|
||||
return (
|
||||
utils.getTreePref('autoRemoveNeedlessGroupTab.lastTab') ||
|
||||
this.getSiblingTabs(aGroupTab).length > 0
|
||||
);
|
||||
},
|
||||
|
||||
_reserveCloseRelatedTabs : function TSTBrowser_reserveCloseRelatedTabs(aTabs)
|
||||
{
|
||||
if (!aTabs.length)
|
||||
@ -5092,7 +5101,8 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
if (this.isGroupTab(parentTab) && !this.hasChildTabs(parentTab)) {
|
||||
this.window.setTimeout(function(aTabBrowser) {
|
||||
if (parentTab.parentNode)
|
||||
if (parentTab.parentNode &&
|
||||
aTabBrowser.treeStyleTab._canCloseLastGroupTab(parentTab))
|
||||
aTabBrowser.removeTab(parentTab, { animate : true });
|
||||
parentTab = null;
|
||||
}, 0, this.getTabBrowserFromChild(parentTab));
|
||||
|
Loading…
Reference in New Issue
Block a user