Move ZoteroStandalone.openInViewer() to Zotero.openInViewer()

This commit is contained in:
Dan Stillman 2016-12-30 00:56:04 -05:00
parent a076edc836
commit fb7f9698d3
4 changed files with 34 additions and 34 deletions

View file

@ -121,38 +121,6 @@ const ZoteroStandalone = new function() {
}
}
/**
* Opens a URL in the basic viewer, and optionally run a callback on load
*
* @param {String} uri
* @param {Function} [onLoad] - Function to run once URI is loaded; passed the loaded document
*/
this.openInViewer = function(uri, onLoad) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("zotero:basicViewer");
if(win) {
win.loadURI(uri);
} else {
win = window.openDialog("chrome://zotero/content/standalone/basicViewer.xul",
"basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri);
}
if (onLoad) {
let browser
let func = function () {
win.removeEventListener("load", func);
browser = win.document.documentElement.getElementsByTagName('browser')[0];
browser.addEventListener("pageshow", innerFunc);
};
let innerFunc = function () {
browser.removeEventListener("pageshow", innerFunc);
onLoad(browser.contentDocument);
};
win.addEventListener("load", func);
}
}
this.updateAddonsPane = function (doc) {
// Hide unsigned add-on verification warnings
//

View file

@ -168,7 +168,7 @@
command="cmd_zotero_rtfScan"/>
<menuseparator/>
<menuitem id="menu_addons" label="&addons.label;"
oncommand="ZoteroStandalone.openInViewer('chrome://mozapps/content/extensions/extensions.xul', ZoteroStandalone.updateAddonsPane)"/>
oncommand="Zotero.openInViewer('chrome://mozapps/content/extensions/extensions.xul', ZoteroStandalone.updateAddonsPane)"/>
<!--<menuitem label="Error Console" oncommand="toJavaScriptConsole()"/>-->
</menupopup>
</menu>

View file

@ -992,6 +992,38 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
}
/**
* Opens a URL in the basic viewer, and optionally run a callback on load
*
* @param {String} uri
* @param {Function} [onLoad] - Function to run once URI is loaded; passed the loaded document
*/
this.openInViewer = function (uri, onLoad) {
var wm = Services.wm;
var win = wm.getMostRecentWindow("zotero:basicViewer");
if (win) {
win.loadURI(uri);
} else {
let window = wm.getMostRecentWindow("navigator:browser");
win = window.openDialog("chrome://zotero/content/standalone/basicViewer.xul",
"basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri);
}
if (onLoad) {
let browser
let func = function () {
win.removeEventListener("load", func);
browser = win.document.documentElement.getElementsByTagName('browser')[0];
browser.addEventListener("pageshow", innerFunc);
};
let innerFunc = function () {
browser.removeEventListener("pageshow", innerFunc);
onLoad(browser.contentDocument);
};
win.addEventListener("load", func);
}
};
/*
* Debug logging function
*

View file

@ -3195,7 +3195,7 @@ var ZoteroPane = new function()
if(uri.match(/^https?/)) {
this.launchURL(uri);
} else {
ZoteroStandalone.openInViewer(uri);
Zotero.openInViewer(uri);
}
return;
}