diff options
Diffstat (limited to '')
-rw-r--r-- | browser/components/customizableui/CustomizableWidgets.sys.mjs | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/browser/components/customizableui/CustomizableWidgets.sys.mjs b/browser/components/customizableui/CustomizableWidgets.sys.mjs index 1f37af7963..09b57be4c9 100644 --- a/browser/components/customizableui/CustomizableWidgets.sys.mjs +++ b/browser/components/customizableui/CustomizableWidgets.sys.mjs @@ -99,6 +99,21 @@ export const CustomizableWidgets = [ case "unload": this.onWindowUnload(event); break; + case "command": { + let { target } = event; + let { PanelUI, PlacesCommandHook } = target.ownerGlobal; + if (target.id == "appMenuRecentlyClosedTabs") { + PanelUI.showSubView(this.recentlyClosedTabsPanel, target); + } else if (target.id == "appMenuRecentlyClosedWindows") { + PanelUI.showSubView(this.recentlyClosedWindowsPanel, target); + } else if (target.id == "appMenuSearchHistory") { + PlacesCommandHook.searchHistory(); + } else if (target.id == "PanelUI-historyMore") { + PlacesCommandHook.showPlacesOrganizer("History"); + lazy.CustomizableUI.hidePanelForNode(target); + } + break; + } default: throw new Error(`Unsupported event for '${this.id}'`); } @@ -153,6 +168,7 @@ export const CustomizableWidgets = [ // When the popup is hidden (thus the panelmultiview node as well), make // sure to stop listening to PlacesDatabase updates. panelview.panelMultiView.addEventListener("PanelMultiViewHidden", this); + panelview.addEventListener("command", this); window.addEventListener("unload", this); }, onViewHiding() { @@ -172,6 +188,10 @@ export const CustomizableWidgets = [ document, this.recentlyClosedWindowsPanel ).removeEventListener("ViewShowing", this); + lazy.PanelMultiView.getViewNode( + document, + this.viewId + ).removeEventListener("command", this); } panelMultiView.removeEventListener("PanelMultiViewHidden", this); }, @@ -260,7 +280,7 @@ export const CustomizableWidgets = [ tooltiptext: "sidebar-button.tooltiptext2", onCommand(aEvent) { let win = aEvent.target.ownerGlobal; - win.SidebarUI.toggle(); + win.SidebarController.toggle(); }, onCreated(aNode) { // Add an observer so the button is checked while the sidebar is open @@ -419,7 +439,7 @@ export const CustomizableWidgets = [ id: "characterencoding-button", l10nId: "repair-text-encoding-button", onCommand(aEvent) { - aEvent.view.BrowserForceEncodingDetection(); + aEvent.view.BrowserCommands.forceEncodingDetection(); }, }, { @@ -464,10 +484,52 @@ if (Services.prefs.getBoolPref("identity.fxaccounts.enabled")) { lazy.PanelMultiView.getViewNode(doc, "PanelUI-remotetabs-deck"), lazy.PanelMultiView.getViewNode(doc, "PanelUI-remotetabs-tabslist") ); + panelview.addEventListener("command", this); + let syncNowButton = lazy.PanelMultiView.getViewNode( + aEvent.target.ownerDocument, + "PanelUI-remotetabs-syncnow" + ); + syncNowButton.addEventListener("mouseover", this); }, onViewHiding(aEvent) { - aEvent.target.syncedTabsPanelList.destroy(); - aEvent.target.syncedTabsPanelList = null; + let panelview = aEvent.target; + panelview.syncedTabsPanelList.destroy(); + panelview.syncedTabsPanelList = null; + panelview.removeEventListener("command", this); + let syncNowButton = lazy.PanelMultiView.getViewNode( + aEvent.target.ownerDocument, + "PanelUI-remotetabs-syncnow" + ); + syncNowButton.removeEventListener("mouseover", this); + }, + handleEvent(aEvent) { + let button = aEvent.target; + let { gSync } = button.ownerGlobal; + switch (aEvent.type) { + case "mouseover": + gSync.refreshSyncButtonsTooltip(); + break; + case "command": { + switch (button.id) { + case "PanelUI-remotetabs-syncnow": + gSync.doSync(); + break; + case "PanelUI-remotetabs-view-managedevices": + gSync.openDevicesManagementPage("syncedtabs-menupanel"); + break; + case "PanelUI-remotetabs-tabsdisabledpane-button": + case "PanelUI-remotetabs-setupsync-button": + case "PanelUI-remotetabs-syncdisabled-button": + case "PanelUI-remotetabs-reauthsync-button": + case "PanelUI-remotetabs-unverified-button": + gSync.openPrefs("synced-tabs"); + break; + case "PanelUI-remotetabs-connect-device-button": + gSync.openConnectAnotherDevice("synced-tabs"); + break; + } + } + } }, }); } |