зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1106932 - allow opening the loop panel from the menu, focus the panel immediately, r=mikedeboer
--HG-- extra : commitid : 7ByUIsFCPW extra : rebase_source : 9674d909a65ea73483424f0d903b578a7c2dcab9
This commit is contained in:
Родитель
6778068f21
Коммит
11f3927ffd
|
@ -60,13 +60,13 @@ var LoopUI;
|
|||
*/
|
||||
promiseDocumentVisible(aDocument) {
|
||||
if (!aDocument.hidden) {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve(aDocument);
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
aDocument.addEventListener("visibilitychange", function onVisibilityChanged() {
|
||||
aDocument.removeEventListener("visibilitychange", onVisibilityChanged);
|
||||
resolve();
|
||||
resolve(aDocument);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -81,6 +81,15 @@ var LoopUI;
|
|||
* @return {Promise}
|
||||
*/
|
||||
togglePanel: function(event, tabId = null) {
|
||||
if (!this.panel) {
|
||||
// We're on the hidden window! What fun!
|
||||
let obs = win => {
|
||||
Services.obs.removeObserver(obs, "browser-delayed-startup-finished");
|
||||
win.LoopUI.togglePanel(event, tabId);
|
||||
};
|
||||
Services.obs.addObserver(obs, "browser-delayed-startup-finished", false);
|
||||
return OpenBrowserWindow();
|
||||
}
|
||||
if (this.panel.state == "open") {
|
||||
return new Promise(resolve => {
|
||||
this.panel.hidePopup();
|
||||
|
@ -88,7 +97,12 @@ var LoopUI;
|
|||
});
|
||||
}
|
||||
|
||||
return this.openCallPanel(event, tabId);
|
||||
return this.openCallPanel(event, tabId).then(doc => {
|
||||
let fm = Services.focus;
|
||||
fm.moveFocus(doc.defaultView, null, fm.MOVEFOCUS_FIRST, fm.FLAG_NOSCROLL);
|
||||
}).catch(err => {
|
||||
Cu.reportError(x);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -130,14 +144,14 @@ var LoopUI;
|
|||
|
||||
let documentDOMLoaded = () => {
|
||||
iframe.removeEventListener("DOMContentLoaded", documentDOMLoaded, true);
|
||||
this.injectLoopAPI(iframe.contentWindow);
|
||||
iframe.contentWindow.addEventListener("loopPanelInitialized", function loopPanelInitialized() {
|
||||
this.injectLoopAPI(iframe.contentWindow);
|
||||
iframe.contentWindow.addEventListener("loopPanelInitialized", function loopPanelInitialized() {
|
||||
iframe.contentWindow.removeEventListener("loopPanelInitialized",
|
||||
loopPanelInitialized);
|
||||
loopPanelInitialized);
|
||||
showTab();
|
||||
});
|
||||
};
|
||||
iframe.addEventListener("DOMContentLoaded", documentDOMLoaded, true);
|
||||
});
|
||||
};
|
||||
iframe.addEventListener("DOMContentLoaded", documentDOMLoaded, true);
|
||||
};
|
||||
|
||||
// Used to clear the temporary "login" state from the button.
|
||||
|
@ -153,7 +167,9 @@ var LoopUI;
|
|||
return;
|
||||
}
|
||||
|
||||
this.PanelFrame.showPopup(window, event ? event.target : this.toolbarButton.node,
|
||||
let anchor = event ? event.target : this.toolbarButton.anchor;
|
||||
|
||||
this.PanelFrame.showPopup(window, anchor,
|
||||
"loop", null, "about:looppanel",
|
||||
// Loop wants a fixed size for the panel. This also stops it dynamically resizing.
|
||||
{ width: 330, height: 410 },
|
||||
|
|
|
@ -507,6 +507,12 @@
|
|||
label="&webapps.label;"
|
||||
accesskey="&webapps.accesskey;"
|
||||
oncommand="BrowserOpenApps();"/>
|
||||
|
||||
<menuitem id="menu_openLoop"
|
||||
label="&loopMenuItem.label;"
|
||||
accesskey = "&loopMenuItem.accesskey;"
|
||||
oncommand="LoopUI.togglePanel();"/>
|
||||
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
<!-- only one of sync-setup, sync-syncnowitem or sync-reauthitem will be showing at once -->
|
||||
<menuitem id="sync-setup"
|
||||
|
|
|
@ -229,6 +229,8 @@ 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">
|
||||
|
|
Загрузка…
Ссылка в новой задаче