diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js
index 9a5e95be28..2eb9fa29a8 100644
--- a/chrome/content/zotero/preferences/preferences.js
+++ b/chrome/content/zotero/preferences/preferences.js
@@ -124,22 +124,6 @@ var Zotero_Preferences = {
}
},
- /**
- * Opens a URI in the basic viewer
- */
- openInViewer: function (uri) {
- 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 {
- window.openDialog("chrome://zotero/content/standalone/basicViewer.xhtml",
- "basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri);
- }
- },
-
_onNavigationSelect() {
for (let child of this.content.children) {
if (child !== this.helpContainer) {
diff --git a/chrome/content/zotero/preferences/preferences_advanced.xhtml b/chrome/content/zotero/preferences/preferences_advanced.xhtml
index 7c48815986..e54779b4df 100644
--- a/chrome/content/zotero/preferences/preferences_advanced.xhtml
+++ b/chrome/content/zotero/preferences/preferences_advanced.xhtml
@@ -253,10 +253,10 @@
+ oncommand="Zotero.openInViewer('about:config')"/>
diff --git a/chrome/content/zotero/preferences/preferences_cite.xhtml b/chrome/content/zotero/preferences/preferences_cite.xhtml
index ee26073f25..9be73bdaa7 100644
--- a/chrome/content/zotero/preferences/preferences_cite.xhtml
+++ b/chrome/content/zotero/preferences/preferences_cite.xhtml
@@ -61,10 +61,10 @@
+ oncommand="Zotero.openInViewer('chrome://zotero/content/tools/csledit.xhtml', true)"/>
+ oncommand="Zotero.openInViewer('chrome://zotero/content/tools/cslpreview.xhtml', true)"/>
diff --git a/chrome/content/zotero/standalone/basicViewer.js b/chrome/content/zotero/standalone/basicViewer.js
index 5b408bd766..1e701d3008 100644
--- a/chrome/content/zotero/standalone/basicViewer.js
+++ b/chrome/content/zotero/standalone/basicViewer.js
@@ -52,6 +52,7 @@ window.addEventListener("load", /*async */function () {
//browser.docShellIsActive = false;
// Load URI passed in as nsISupports .data via openWindow()
+ window.viewerOriginalURI = window.arguments[0];
loadURI(window.arguments[0]);
}, false);
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
index dd2ee06a52..b523fb9a99 100644
--- a/chrome/content/zotero/xpcom/zotero.js
+++ b/chrome/content/zotero/xpcom/zotero.js
@@ -1090,21 +1090,22 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
* @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 ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
- .getService(Components.interfaces.nsIWindowWatcher);
- let arg = Components.classes["@mozilla.org/supports-string;1"]
- .createInstance(Components.interfaces.nsISupportsString);
- arg.data = uri;
- win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xhtml",
- "basicViewer", "chrome,dialog=yes,resizable,centerscreen,menubar,scrollbars", arg);
+ var viewerWins = Services.wm.getEnumerator("zotero:basicViewer");
+ for (let existingWin of viewerWins) {
+ if (existingWin.viewerOriginalURI === uri) {
+ existingWin.focus();
+ return;
+ }
}
+ let ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
+ .getService(Components.interfaces.nsIWindowWatcher);
+ let arg = Components.classes["@mozilla.org/supports-string;1"]
+ .createInstance(Components.interfaces.nsISupportsString);
+ arg.data = uri;
+ let win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xhtml",
+ null, "chrome,dialog=yes,resizable,centerscreen,menubar,scrollbars", arg);
if (onLoad) {
- let browser
+ let browser;
let func = function () {
win.removeEventListener("load", func);
// is created in basicViewer.js in a window load event, so we have to