Bug 1473974 - Fix opening all tabs panel with cycle recent tabs r=dao

MozReview-Commit-ID: EGYJo8AAF2K
This commit is contained in:
Mark Striemer
2018-07-10 13:48:57 -05:00
parent 63df8acae1
commit fd7bcb67b4
3 changed files with 18 additions and 28 deletions

View File

@@ -18,11 +18,15 @@ var gTabsPanel = {
hiddenTabsView: "allTabsMenu-hiddenTabsView", hiddenTabsView: "allTabsMenu-hiddenTabsView",
}, },
_initialized: false, _initialized: false,
_initializedElements: false,
initElements() { initElements() {
if (this._initializedElements) return;
for (let [name, id] of Object.entries(this.kElements)) { for (let [name, id] of Object.entries(this.kElements)) {
this[name] = document.getElementById(id); this[name] = document.getElementById(id);
} }
this._initializedElements = true;
}, },
init() { init() {
@@ -124,9 +128,16 @@ var gTabsPanel = {
this._initialized = true; this._initialized = true;
}, },
get canOpen() {
this.initElements();
return isElementVisible(this.allTabsButton);
},
showAllTabsPanel() { showAllTabsPanel() {
this.init(); this.init();
PanelUI.showSubView(this.kElements.allTabsView, this.allTabsButton); if (this.canOpen) {
PanelUI.showSubView(this.kElements.allTabsView, this.allTabsButton);
}
}, },
hideAllTabsPanel() { hideAllTabsPanel() {
@@ -136,6 +147,9 @@ var gTabsPanel = {
showHiddenTabsPanel() { showHiddenTabsPanel() {
this.init(); this.init();
if (!this.canOpen) {
return;
}
this.allTabsView.addEventListener("ViewShown", (e) => { this.allTabsView.addEventListener("ViewShown", (e) => {
PanelUI.showSubView(this.kElements.hiddenTabsView, this.hiddenTabsButton); PanelUI.showSubView(this.kElements.hiddenTabsView, this.hiddenTabsButton);
}, {once: true}); }, {once: true});

View File

@@ -294,7 +294,7 @@ var ctrlTab = {
var showAllLabel = gNavigatorBundle.getString("ctrlTab.listAllTabs.label"); var showAllLabel = gNavigatorBundle.getString("ctrlTab.listAllTabs.label");
this.showAllButton._label.setAttribute("value", this.showAllButton._label.setAttribute("value",
PluralForm.get(this.tabCount, showAllLabel).replace("#1", this.tabCount)); PluralForm.get(this.tabCount, showAllLabel).replace("#1", this.tabCount));
this.showAllButton.hidden = !allTabs.canOpen; this.showAllButton.hidden = !gTabsPanel.canOpen;
}, },
updatePreview: function ctrlTab_updatePreview(aPreview, aTab) { updatePreview: function ctrlTab_updatePreview(aPreview, aTab) {
@@ -570,7 +570,7 @@ var ctrlTab = {
break; break;
case "popupshowing": case "popupshowing":
if (event.target.id == "menu_viewPopup") if (event.target.id == "menu_viewPopup")
document.getElementById("menu_showAllTabs").hidden = !allTabs.canOpen; document.getElementById("menu_showAllTabs").hidden = !gTabsPanel.canOpen;
break; break;
} }
}, },
@@ -628,27 +628,3 @@ var ctrlTab = {
key_showAllTabs.setAttribute("disabled", "true"); key_showAllTabs.setAttribute("disabled", "true");
} }
}; };
/**
* All Tabs menu
*/
var allTabs = {
get toolbarButton() {
return document.getElementById("alltabs-button");
},
get canOpen() {
return isElementVisible(this.toolbarButton);
},
open: function allTabs_open() {
if (this.canOpen) {
// Without setTimeout, the menupopup won't stay open when invoking
// "View > Show All Tabs" and the menu bar auto-hides.
setTimeout(() => {
this.toolbarButton.open = true;
}, 0);
}
}
};

View File

@@ -81,7 +81,7 @@
</command> </command>
<command id="Browser:NextTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);"/> <command id="Browser:NextTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);"/>
<command id="Browser:PrevTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);"/> <command id="Browser:PrevTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);"/>
<command id="Browser:ShowAllTabs" oncommand="allTabs.open();"/> <command id="Browser:ShowAllTabs" oncommand="gTabsPanel.showAllTabsPanel();"/>
<command id="cmd_fullZoomReduce" oncommand="FullZoom.reduce()"/> <command id="cmd_fullZoomReduce" oncommand="FullZoom.reduce()"/>
<command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/> <command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/>
<command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/> <command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/>