diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index 5e45327ec9..5be7f90a3a 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -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 // diff --git a/chrome/content/zotero/standalone/standalone.xul b/chrome/content/zotero/standalone/standalone.xul index fe9cfa5c5a..bf42f2e9ab 100644 --- a/chrome/content/zotero/standalone/standalone.xul +++ b/chrome/content/zotero/standalone/standalone.xul @@ -168,7 +168,7 @@ command="cmd_zotero_rtfScan"/> + oncommand="Zotero.openInViewer('chrome://mozapps/content/extensions/extensions.xul', ZoteroStandalone.updateAddonsPane)"/> diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 19f031af5a..f896833ccd 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -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 * diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index b0dad34349..1d4c944dd6 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -3195,7 +3195,7 @@ var ZoteroPane = new function() if(uri.match(/^https?/)) { this.launchURL(uri); } else { - ZoteroStandalone.openInViewer(uri); + Zotero.openInViewer(uri); } return; }