Basic viewer: Open separate windows per URI (#3081)
This commit is contained in:
parent
8e6f33f045
commit
b33d3ec799
5 changed files with 19 additions and 33 deletions
|
@ -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) {
|
||||
|
|
|
@ -253,10 +253,10 @@
|
|||
<hbox id="zotero-prefpane-advanced-open-buttons" align="center">
|
||||
<button id="config-editor"
|
||||
label="&zotero.preferences.configEditor;"
|
||||
oncommand="Zotero_Preferences.openInViewer('about:config')"/>
|
||||
oncommand="Zotero.openInViewer('about:config')"/>
|
||||
<button id="memory-info"
|
||||
label="Memory Info"
|
||||
oncommand="Zotero_Preferences.openInViewer('about:memory')"
|
||||
oncommand="Zotero.openInViewer('about:memory')"
|
||||
hidden="true"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
|
|
@ -61,10 +61,10 @@
|
|||
<hbox>
|
||||
<button id="openCSLEdit"
|
||||
label="&zotero.preferences.styleEditor;"
|
||||
oncommand="Zotero_Preferences.openInViewer('chrome://zotero/content/tools/csledit.xhtml', true)"/>
|
||||
oncommand="Zotero.openInViewer('chrome://zotero/content/tools/csledit.xhtml', true)"/>
|
||||
<button id="openCSLPreview"
|
||||
label="&zotero.preferences.stylePreview;"
|
||||
oncommand="Zotero_Preferences.openInViewer('chrome://zotero/content/tools/cslpreview.xhtml', true)"/>
|
||||
oncommand="Zotero.openInViewer('chrome://zotero/content/tools/cslpreview.xhtml', true)"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</vbox>
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
// <browser> is created in basicViewer.js in a window load event, so we have to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue