diff --git a/chrome/content/zotero/locateMenu.js b/chrome/content/zotero/locateMenu.js
index 7927f4d28d..ef58d41123 100644
--- a/chrome/content/zotero/locateMenu.js
+++ b/chrome/content/zotero/locateMenu.js
@@ -123,17 +123,17 @@ var Zotero_LocateMenu = new function() {
});
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
- var menuitem = _createMenuItem(Zotero.getString("locate."+optionName+".label"),
+ var menuitem = _createMenuItem(optionObject.label || Zotero.getString(`locate.${optionName}.label`),
null, null);
- if(showIcons) {
+ if (showIcons) {
menuitem.setAttribute("class", "menuitem-iconic");
- menuitem.style.listStyleImage = "url('"+optionObject.icon+"')";
+ menuitem.style.listStyleImage = `url('${optionObject.icon}')`;
}
menuitem.setAttribute("zotero-locate", "true");
- menuitem.addEventListener("command", function(event) {
+ menuitem.addEventListener("command", function (event) {
optionObject.handleItems(selectedItems, event);
- }, false)
+ }, false);
return menuitem;
}
@@ -344,16 +344,30 @@ var Zotero_LocateMenu = new function() {
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
* a PDF
*/
- function ViewPDF(inNewWindow) {
+ function ViewPDF(alternateWindowBehavior) {
this.icon = "chrome://zotero/skin/treeitem-attachment-pdf.png";
this._mimeTypes = ["application/pdf"];
- // Don't show "Open PDF in New Window" in toolbar Locate menu
- this.hideInToolbar = inNewWindow;
+ // Don't show alternate-behavior option ("in New Window" when openReaderInNewWindow is false,
+ // "in New Tab" when it's true) in toolbar Locate menu
+ this.hideInToolbar = alternateWindowBehavior;
+
+ Object.defineProperty(this, 'label', {
+ get() {
+ if (alternateWindowBehavior) {
+ return Zotero.getString(Zotero.Prefs.get('openReaderInNewWindow')
+ ? 'locate.pdfNewTab.label'
+ : 'locate.pdfNewWindow.label');
+ }
+ else {
+ return Zotero.getString('locate.pdf.label');
+ }
+ }
+ });
this.canHandleItem = async function (item) {
- // Don't show "Open PDF in New Window" when using an external PDF viewer
- if (inNewWindow && Zotero.Prefs.get("fileHandler.pdf")) {
+ // Don't show alternate-behavior option when using an external PDF viewer
+ if (alternateWindowBehavior && Zotero.Prefs.get("fileHandler.pdf")) {
return false;
}
return _getFirstAttachmentWithMIMEType(item, this._mimeTypes).then((item) => !!item);
@@ -367,7 +381,7 @@ var Zotero_LocateMenu = new function() {
}
ZoteroPane_Local.viewAttachment(attachments, event, false,
- { forceOpenPDFInWindow: inNewWindow });
+ { forceAlternateWindowBehavior: alternateWindowBehavior });
});
var _getFirstAttachmentWithMIMEType = Zotero.Promise.coroutine(function* (item, mimeTypes) {
@@ -384,7 +398,7 @@ var Zotero_LocateMenu = new function() {
}
ViewOptions.pdf = new ViewPDF(false);
- ViewOptions.pdfNewWindow = new ViewPDF(true);
+ ViewOptions.pdfAlternateWindowBehavior = new ViewPDF(true);
/**
* "View Online" option
diff --git a/chrome/content/zotero/preferences/preferences_general.js b/chrome/content/zotero/preferences/preferences_general.js
index f4740b4396..63b554bca0 100644
--- a/chrome/content/zotero/preferences/preferences_general.js
+++ b/chrome/content/zotero/preferences/preferences_general.js
@@ -170,11 +170,13 @@ Zotero_Preferences.General = {
var handler = Zotero.Prefs.get('fileHandler.pdf');
var menulist = document.getElementById('fileHandler-pdf');
var customMenuItem = document.getElementById('fileHandler-custom');
+ var inNewWindowCheckbox = document.getElementById('open-reader-in-new-window');
// System default
if (handler == 'system') {
customMenuItem.hidden = true;
menulist.selectedIndex = 1;
+ inNewWindowCheckbox.disabled = true;
}
// Custom handler
else if (handler) {
@@ -201,6 +203,7 @@ Zotero_Preferences.General = {
}
customMenuItem.hidden = false;
menulist.selectedIndex = 2;
+ inNewWindowCheckbox.disabled = true;
// There's almost certainly a better way to do this...
// but why doesn't the icon just behave by default?
@@ -211,6 +214,7 @@ Zotero_Preferences.General = {
let menuitem = document.getElementById('fileHandler-internal');
menulist.selectedIndex = 0;
customMenuItem.hidden = true;
+ inNewWindowCheckbox.disabled = false;
}
},
diff --git a/chrome/content/zotero/preferences/preferences_general.xhtml b/chrome/content/zotero/preferences/preferences_general.xhtml
index 4f5909628d..4730d197f9 100644
--- a/chrome/content/zotero/preferences/preferences_general.xhtml
+++ b/chrome/content/zotero/preferences/preferences_general.xhtml
@@ -55,20 +55,26 @@
oncommand="Zotero_Preferences.General.updateAutoRenameFilesUI()" native="true"/>
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
index cca8dd6b03..e389e1685c 100644
--- a/chrome/content/zotero/zoteroPane.js
+++ b/chrome/content/zotero/zoteroPane.js
@@ -4446,13 +4446,17 @@ var ZoteroPane = new function()
let pdfHandler = Zotero.Prefs.get("fileHandler.pdf");
// Zotero PDF reader
if (!pdfHandler) {
+ let openInWindow = Zotero.Prefs.get('openReaderInNewWindow');
+ let useAlternateWindowBehavior = event?.shiftKey || extraData?.forceAlternateWindowBehavior;
+ if (useAlternateWindowBehavior) {
+ openInWindow = !openInWindow;
+ }
await Zotero.Reader.open(
itemID,
extraData && extraData.location,
{
- openInWindow: (event && event.shiftKey)
- || (extraData && extraData.forceOpenPDFInWindow),
- allowDuplicate: event && event.shiftKey
+ openInWindow,
+ allowDuplicate: openInWindow
}
);
return;
diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd
index 747b8bb78c..ef54d8348e 100644
--- a/chrome/locale/en-US/zotero/preferences.dtd
+++ b/chrome/locale/en-US/zotero/preferences.dtd
@@ -19,6 +19,7 @@
+
diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties
index 1dac709550..cab1679fa4 100644
--- a/chrome/locale/en-US/zotero/zotero.properties
+++ b/chrome/locale/en-US/zotero/zotero.properties
@@ -1220,6 +1220,7 @@ createParent.prompt = Enter a DOI, ISBN, PMID, arXiv ID, or ADS Bibcode to i
locate.online.label = View Online
locate.pdf.label = Open PDF
locate.pdfNewWindow.label = Open PDF in New Window
+locate.pdfNewTab.label = Open PDF in New Tab
locate.snapshot.label = View Snapshot
locate.file.label = View File
locate.externalViewer.label = Open in External Viewer
diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js
index 95bc34b408..35e9f844a9 100644
--- a/defaults/preferences/zotero.js
+++ b/defaults/preferences/zotero.js
@@ -184,8 +184,8 @@ pref("extensions.zotero.purge.tags", false);
// Zotero pane persistent data
pref("extensions.zotero.pane.persist", "");
-// Custom file handlers
pref("extensions.zotero.fileHandler.pdf", "");
+pref("extensions.zotero.openReaderInNewWindow", false);
// File/URL opening executable if launch() fails
pref("extensions.zotero.fallbackLauncher.unix", "/usr/bin/xdg-open");