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() {
|
_onNavigationSelect() {
|
||||||
for (let child of this.content.children) {
|
for (let child of this.content.children) {
|
||||||
if (child !== this.helpContainer) {
|
if (child !== this.helpContainer) {
|
||||||
|
|
|
@ -253,10 +253,10 @@
|
||||||
<hbox id="zotero-prefpane-advanced-open-buttons" align="center">
|
<hbox id="zotero-prefpane-advanced-open-buttons" align="center">
|
||||||
<button id="config-editor"
|
<button id="config-editor"
|
||||||
label="&zotero.preferences.configEditor;"
|
label="&zotero.preferences.configEditor;"
|
||||||
oncommand="Zotero_Preferences.openInViewer('about:config')"/>
|
oncommand="Zotero.openInViewer('about:config')"/>
|
||||||
<button id="memory-info"
|
<button id="memory-info"
|
||||||
label="Memory Info"
|
label="Memory Info"
|
||||||
oncommand="Zotero_Preferences.openInViewer('about:memory')"
|
oncommand="Zotero.openInViewer('about:memory')"
|
||||||
hidden="true"/>
|
hidden="true"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
|
@ -61,10 +61,10 @@
|
||||||
<hbox>
|
<hbox>
|
||||||
<button id="openCSLEdit"
|
<button id="openCSLEdit"
|
||||||
label="&zotero.preferences.styleEditor;"
|
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"
|
<button id="openCSLPreview"
|
||||||
label="&zotero.preferences.stylePreview;"
|
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>
|
</hbox>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
|
@ -52,6 +52,7 @@ window.addEventListener("load", /*async */function () {
|
||||||
//browser.docShellIsActive = false;
|
//browser.docShellIsActive = false;
|
||||||
|
|
||||||
// Load URI passed in as nsISupports .data via openWindow()
|
// Load URI passed in as nsISupports .data via openWindow()
|
||||||
|
window.viewerOriginalURI = window.arguments[0];
|
||||||
loadURI(window.arguments[0]);
|
loadURI(window.arguments[0]);
|
||||||
}, false);
|
}, 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
|
* @param {Function} [onLoad] - Function to run once URI is loaded; passed the loaded document
|
||||||
*/
|
*/
|
||||||
this.openInViewer = function (uri, onLoad) {
|
this.openInViewer = function (uri, onLoad) {
|
||||||
var wm = Services.wm;
|
var viewerWins = Services.wm.getEnumerator("zotero:basicViewer");
|
||||||
var win = wm.getMostRecentWindow("zotero:basicViewer");
|
for (let existingWin of viewerWins) {
|
||||||
if (win) {
|
if (existingWin.viewerOriginalURI === uri) {
|
||||||
win.loadURI(uri);
|
existingWin.focus();
|
||||||
} else {
|
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;
|
|
||||||
win = ww.openWindow(null, "chrome://zotero/content/standalone/basicViewer.xhtml",
|
|
||||||
"basicViewer", "chrome,dialog=yes,resizable,centerscreen,menubar,scrollbars", arg);
|
|
||||||
}
|
}
|
||||||
|
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) {
|
if (onLoad) {
|
||||||
let browser
|
let browser;
|
||||||
let func = function () {
|
let func = function () {
|
||||||
win.removeEventListener("load", func);
|
win.removeEventListener("load", func);
|
||||||
// <browser> is created in basicViewer.js in a window load event, so we have to
|
// <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