Unify window opening from menu items

This commit is contained in:
Dan Stillman 2019-08-27 19:37:39 -04:00
parent b08bd6849e
commit 8a95ce34d8

View file

@ -713,30 +713,43 @@ ZoteroStandalone.DebugOutput = {
function toJavaScriptConsole() { function toJavaScriptConsole() {
toOpenWindowByType("global:console", "chrome://global/content/console.xul"); openWindowByType('chrome://global/content/console.xul', 'global:console');
} }
function openRunJSWindow() { function openRunJSWindow() {
window.open('chrome://zotero/content/runJS.html', 'run-js', 'width=900,height=700,resizable'); openWindowByType(
'chrome://zotero/content/runJS.html',
'zotero:run-js',
'chrome,width=900,height=700,resizable,centerscreen'
);
} }
function openStyleEditor() { function openStyleEditor() {
window.open('chrome://zotero/content/tools/csledit.xul', 'style-editor', 'width=950,height=700,resizable'); openWindowByType(
'chrome://zotero/content/tools/csledit.xul',
'zotero:style-editor',
'chrome,width=950,height=700,resizable'
);
} }
function openScaffold() { function openScaffold() {
window.open('chrome://scaffold/content/scaffold.xul', 'scaffold', 'chrome,resizable'); openWindowByType(
'chrome://scaffold/content/scaffold.xul',
'zotero:scaffold',
'chrome,resizable'
);
} }
function toOpenWindowByType(inType, uri, features) function openWindowByType(uri, type, features) {
{ var win = Services.wm.getMostRecentWindow(type);
var topWindow = Services.wm.getMostRecentWindow(inType);
if (topWindow) { if (win) {
topWindow.focus(); win.focus();
} else if(features) { }
else if (features) {
window.open(uri, "_blank", features); window.open(uri, "_blank", features);
} else { }
else {
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
} }
} }