mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1229933: create the Loop menu item in the browser Tools menu dynamically from the extension and remove it from core browser code. r=Standard8
This commit is contained in:
parent
4ede1a6007
commit
ca1c606eff
@ -504,11 +504,6 @@
|
||||
accesskey="&webapps.accesskey;"
|
||||
oncommand="BrowserOpenApps();"/>
|
||||
|
||||
<menuitem id="menu_openLoop"
|
||||
label="&loopMenuItem.label;"
|
||||
accesskey = "&loopMenuItem.accesskey;"
|
||||
oncommand="LoopUI.togglePanel();"/>
|
||||
|
||||
<!-- only one of sync-setup, sync-syncnowitem or sync-reauthitem will be showing at once -->
|
||||
<menuitem id="sync-setup"
|
||||
label="&syncSignIn.label;"
|
||||
|
51
browser/extensions/loop/bootstrap.js
vendored
51
browser/extensions/loop/bootstrap.js
vendored
@ -35,6 +35,7 @@ var WindowListener = {
|
||||
let gBrowser = window.gBrowser;
|
||||
let xhrClass = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"];
|
||||
let FileReader = window.FileReader;
|
||||
let menuItem = null;
|
||||
|
||||
// the "exported" symbols
|
||||
var LoopUI = {
|
||||
@ -69,20 +70,6 @@ var WindowListener = {
|
||||
return browser;
|
||||
},
|
||||
|
||||
/**
|
||||
* @var {String|null} selectedTab Getter for the name of the currently selected
|
||||
* tab inside the Loop panel. Will be NULL if
|
||||
* the panel hasn't loaded yet.
|
||||
*/
|
||||
get selectedTab() {
|
||||
if (!this.browser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let selectedTab = this.browser.contentDocument.querySelector(".tab-view > .selected");
|
||||
return selectedTab && selectedTab.getAttribute("data-tab-name");
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Promise}
|
||||
*/
|
||||
@ -278,6 +265,8 @@ var WindowListener = {
|
||||
}
|
||||
});
|
||||
|
||||
this.addMenuItem();
|
||||
|
||||
// Don't do the rest if this is for the hidden window - we don't
|
||||
// have a toolbar there.
|
||||
if (window == Services.appShell.hiddenDOMWindow) {
|
||||
@ -294,6 +283,35 @@ var WindowListener = {
|
||||
this.updateToolbarState();
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a menu item to the browsers' Tools menu that open the Loop panel
|
||||
* when selected.
|
||||
*/
|
||||
addMenuItem: function() {
|
||||
let menu = document.getElementById("menu_ToolsPopup");
|
||||
if (!menu || menuItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
menuItem = document.createElementNS(kNSXUL, "menuitem");
|
||||
menuItem.setAttribute("id", "menu_openLoop");
|
||||
menuItem.setAttribute("label", this._getString("loopMenuItem_label"));
|
||||
menuItem.setAttribute("accesskey", this._getString("loopMenuItem_accesskey"));
|
||||
|
||||
menuItem.addEventListener("command", () => this.togglePanel());
|
||||
|
||||
menu.insertBefore(menuItem, document.getElementById("sync-setup"));
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the menu item from the browsers' Tools menu.
|
||||
*/
|
||||
removeMenuItem: function() {
|
||||
if (menuItem) {
|
||||
menuItem.parentNode.removeChild(menuItem);
|
||||
}
|
||||
},
|
||||
|
||||
// Implements nsIObserver
|
||||
observe: function(subject, topic, data) {
|
||||
if (topic != "loop-status-changed") {
|
||||
@ -674,7 +692,10 @@ var WindowListener = {
|
||||
|
||||
// Take any steps to remove UI or anything from the browser window
|
||||
// document.getElementById() etc. will work here
|
||||
// XXX Add in tear-down of the panel.
|
||||
if (window.LoopUI) {
|
||||
window.LoopUI.removeMenuItem();
|
||||
// XXX Add in tear-down of the panel.
|
||||
}
|
||||
},
|
||||
|
||||
// nsIWindowMediatorListener functions.
|
||||
|
@ -252,8 +252,6 @@ These should match what Safari and other Apple applications use on OS X Lion. --
|
||||
<!ENTITY addons.commandkey "A">
|
||||
<!ENTITY webapps.label "Apps">
|
||||
<!ENTITY webapps.accesskey "p">
|
||||
<!ENTITY loopMenuItem.label "Start a conversation…">
|
||||
<!ENTITY loopMenuItem.accesskey "t">
|
||||
|
||||
<!ENTITY webDeveloperMenu.label "Web Developer">
|
||||
<!ENTITY webDeveloperMenu.accesskey "W">
|
||||
|
@ -9,6 +9,12 @@
|
||||
clientShortname2=Firefox Hello
|
||||
clientSuperShortname=Hello
|
||||
|
||||
## LOCALIZATION_NOTE(loopMenuItem_label): Label of the menu item that is placed
|
||||
## inside the browser 'Tools' menu. Use the unicode ellipsis char, \u2026, or
|
||||
## use "..." if \u2026 doesn't suit traditions in your locale.
|
||||
loopMenuItem_label=Start a conversation…
|
||||
loopMenuItem_accesskey=t
|
||||
|
||||
## LOCALIZATION_NOTE(sign_in_again_title_line_one, sign_in_again_title_line_two2):
|
||||
## These are displayed together at the top of the panel when a user is needed to
|
||||
## sign-in again. The emphesis is on the first line to get the user to sign-in again,
|
||||
|
Loading…
Reference in New Issue
Block a user