Add "Open PDF in New Window" to context menu (#2490)
Also: * Remove Locate tooltips
This commit is contained in:
parent
a5fc8b859c
commit
38f5551ee5
4 changed files with 33 additions and 22 deletions
|
@ -423,7 +423,7 @@
|
||||||
label.classList.add("pointer");
|
label.classList.add("pointer");
|
||||||
// TODO: make getFieldValue non-private and use below instead
|
// TODO: make getFieldValue non-private and use below instead
|
||||||
label.setAttribute("onclick", "Zotero.launchURL(this.nextSibling.firstChild ? this.nextSibling.firstChild.nodeValue : this.nextSibling.value)");
|
label.setAttribute("onclick", "Zotero.launchURL(this.nextSibling.firstChild ? this.nextSibling.firstChild.nodeValue : this.nextSibling.value)");
|
||||||
label.setAttribute("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
label.setAttribute("tooltiptext", Zotero.getString('pane.item.viewOnline.tooltip'));
|
||||||
}
|
}
|
||||||
else if (fieldName == 'DOI' && val && typeof val == 'string') {
|
else if (fieldName == 'DOI' && val && typeof val == 'string') {
|
||||||
// Pull out DOI, in case there's a prefix
|
// Pull out DOI, in case there's a prefix
|
||||||
|
@ -438,7 +438,7 @@
|
||||||
.replace(/"/g, '%22');
|
.replace(/"/g, '%22');
|
||||||
label.classList.add("pointer");
|
label.classList.add("pointer");
|
||||||
label.setAttribute("onclick", "ZoteroPane_Local.loadURI('" + doi + "', event)");
|
label.setAttribute("onclick", "ZoteroPane_Local.loadURI('" + doi + "', event)");
|
||||||
label.setAttribute("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
label.setAttribute("tooltiptext", Zotero.getString('pane.item.viewOnline.tooltip'));
|
||||||
valueElement.oncontextmenu = () => {
|
valueElement.oncontextmenu = () => {
|
||||||
this._id('zotero-doi-menu').openPopup(valueElement);
|
this._id('zotero-doi-menu').openPopup(valueElement);
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ var Zotero_LocateMenu = new function() {
|
||||||
var selectedItems = _getSelectedItems();
|
var selectedItems = _getSelectedItems();
|
||||||
|
|
||||||
if(selectedItems.length) {
|
if(selectedItems.length) {
|
||||||
_addViewOptions(locateMenu, selectedItems, true, true);
|
_addViewOptions(locateMenu, selectedItems, true, true, true);
|
||||||
|
|
||||||
var availableEngines = _getAvailableLocateEngines(selectedItems);
|
var availableEngines = _getAvailableLocateEngines(selectedItems);
|
||||||
// add engines that are available for selected items
|
// add engines that are available for selected items
|
||||||
|
@ -124,7 +124,7 @@ var Zotero_LocateMenu = new function() {
|
||||||
|
|
||||||
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
||||||
var menuitem = _createMenuItem(Zotero.getString("locate."+optionName+".label"),
|
var menuitem = _createMenuItem(Zotero.getString("locate."+optionName+".label"),
|
||||||
null, Zotero.getString("locate."+optionName+".tooltip"));
|
null, null);
|
||||||
if(showIcons) {
|
if(showIcons) {
|
||||||
menuitem.setAttribute("class", "menuitem-iconic");
|
menuitem.setAttribute("class", "menuitem-iconic");
|
||||||
menuitem.style.listStyleImage = "url('"+optionObject.icon+"')";
|
menuitem.style.listStyleImage = "url('"+optionObject.icon+"')";
|
||||||
|
@ -143,14 +143,17 @@ var Zotero_LocateMenu = new function() {
|
||||||
* @param {Zotero.Item[]} selectedItems The items to create view options based upon
|
* @param {Zotero.Item[]} selectedItems The items to create view options based upon
|
||||||
* @param {Boolean} showIcons Whether menu items should have associated icons
|
* @param {Boolean} showIcons Whether menu items should have associated icons
|
||||||
* @param {Boolean} addExtraOptions Whether to add options that start with "_" below the separator
|
* @param {Boolean} addExtraOptions Whether to add options that start with "_" below the separator
|
||||||
|
* @param {Boolean} isToolbarMenu Whether the menu being populated is displayed in the toolbar
|
||||||
|
* (and not the item tree context menu)
|
||||||
*/
|
*/
|
||||||
var _addViewOptions = Zotero.Promise.coroutine(function* (locateMenu, selectedItems, showIcons, addExtraOptions) {
|
var _addViewOptions = Zotero.Promise.coroutine(function* (locateMenu, selectedItems, showIcons, addExtraOptions, isToolbarMenu) {
|
||||||
var optionsToShow = {};
|
var optionsToShow = {};
|
||||||
|
|
||||||
// check which view options are available
|
// check which view options are available
|
||||||
for (let item of selectedItems) {
|
for (let item of selectedItems) {
|
||||||
for(var viewOption in ViewOptions) {
|
for(var viewOption in ViewOptions) {
|
||||||
if(!optionsToShow[viewOption]) {
|
if (!optionsToShow[viewOption]
|
||||||
|
&& (!isToolbarMenu || !ViewOptions[viewOption].hideInToolbar)) {
|
||||||
optionsToShow[viewOption] = yield ViewOptions[viewOption].canHandleItem(item);
|
optionsToShow[viewOption] = yield ViewOptions[viewOption].canHandleItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,16 +339,23 @@ var Zotero_LocateMenu = new function() {
|
||||||
var ViewOptions = {};
|
var ViewOptions = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "View PDF" option
|
* "Open PDF" option
|
||||||
*
|
*
|
||||||
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
|
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
|
||||||
* a PDF
|
* a PDF
|
||||||
*/
|
*/
|
||||||
ViewOptions.pdf = new function() {
|
function ViewPDF(inNewWindow) {
|
||||||
this.icon = "chrome://zotero/skin/treeitem-attachment-pdf.png";
|
this.icon = "chrome://zotero/skin/treeitem-attachment-pdf.png";
|
||||||
this._mimeTypes = ["application/pdf"];
|
this._mimeTypes = ["application/pdf"];
|
||||||
|
|
||||||
this.canHandleItem = function (item) {
|
// Don't show "Open PDF in New Window" in toolbar Locate menu
|
||||||
|
this.hideInToolbar = inNewWindow;
|
||||||
|
|
||||||
|
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")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return _getFirstAttachmentWithMIMEType(item, this._mimeTypes).then((item) => !!item);
|
return _getFirstAttachmentWithMIMEType(item, this._mimeTypes).then((item) => !!item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +366,8 @@ var Zotero_LocateMenu = new function() {
|
||||||
if(attachment) attachments.push(attachment.id);
|
if(attachment) attachments.push(attachment.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoteroPane_Local.viewAttachment(attachments, event);
|
ZoteroPane_Local.viewAttachment(attachments, event, false,
|
||||||
|
{ forceOpenPDFInWindow: inNewWindow });
|
||||||
});
|
});
|
||||||
|
|
||||||
var _getFirstAttachmentWithMIMEType = Zotero.Promise.coroutine(function* (item, mimeTypes) {
|
var _getFirstAttachmentWithMIMEType = Zotero.Promise.coroutine(function* (item, mimeTypes) {
|
||||||
|
@ -370,7 +381,10 @@ var Zotero_LocateMenu = new function() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
ViewOptions.pdf = new ViewPDF(false);
|
||||||
|
ViewOptions.pdfNewWindow = new ViewPDF(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "View Online" option
|
* "View Online" option
|
||||||
|
@ -441,7 +455,7 @@ var Zotero_LocateMenu = new function() {
|
||||||
* "View File" option
|
* "View File" option
|
||||||
*
|
*
|
||||||
* Should appear only when an item or a linked or attached file or web attachment does not
|
* Should appear only when an item or a linked or attached file or web attachment does not
|
||||||
* satisfy the conditions for "View PDF" or "View Snapshot"
|
* satisfy the conditions for "Open PDF" or "View Snapshot"
|
||||||
*/
|
*/
|
||||||
ViewOptions.file = new function() {
|
ViewOptions.file = new function() {
|
||||||
this.icon = "chrome://zotero/skin/treeitem-attachment-file.png";
|
this.icon = "chrome://zotero/skin/treeitem-attachment-file.png";
|
||||||
|
|
|
@ -4261,7 +4261,10 @@ var ZoteroPane = new function()
|
||||||
await Zotero.Reader.open(
|
await Zotero.Reader.open(
|
||||||
itemID,
|
itemID,
|
||||||
extraData && extraData.location,
|
extraData && extraData.location,
|
||||||
{ openInWindow: event && event.shiftKey }
|
{
|
||||||
|
openInWindow: (event && event.shiftKey)
|
||||||
|
|| (extraData && extraData.forceOpenPDFInWindow)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,6 +431,7 @@ pane.item.related.count.zero = %S related:
|
||||||
pane.item.related.count.singular = %S related:
|
pane.item.related.count.singular = %S related:
|
||||||
pane.item.related.count.plural = %S related:
|
pane.item.related.count.plural = %S related:
|
||||||
pane.item.parentItem = Parent Item:
|
pane.item.parentItem = Parent Item:
|
||||||
|
pane.item.viewOnline.tooltip = Go to this item online
|
||||||
|
|
||||||
pane.context.noParent = No parent item
|
pane.context.noParent = No parent item
|
||||||
pane.context.itemNotes = Item Notes
|
pane.context.itemNotes = Item Notes
|
||||||
|
@ -1208,21 +1209,14 @@ lookup.failureTooMany.description = Too many identifiers. Please enter one ident
|
||||||
createParent.prompt = Enter a DOI, ISBN, PMID, arXiv ID, or ADS Bibcode to identify this file
|
createParent.prompt = Enter a DOI, ISBN, PMID, arXiv ID, or ADS Bibcode to identify this file
|
||||||
|
|
||||||
locate.online.label = View Online
|
locate.online.label = View Online
|
||||||
locate.online.tooltip = Go to this item online
|
locate.pdf.label = Open PDF
|
||||||
locate.pdf.label = View PDF
|
locate.pdfNewWindow.label = Open PDF in New Window
|
||||||
locate.pdf.tooltip = Open PDF using the selected viewer
|
|
||||||
locate.snapshot.label = View Snapshot
|
locate.snapshot.label = View Snapshot
|
||||||
locate.snapshot.tooltip = View and annotate the snapshot for this item
|
|
||||||
locate.file.label = View File
|
locate.file.label = View File
|
||||||
locate.file.tooltip = Open file using the selected viewer
|
|
||||||
locate.externalViewer.label = Open in External Viewer
|
locate.externalViewer.label = Open in External Viewer
|
||||||
locate.externalViewer.tooltip = Open file in another application
|
|
||||||
locate.internalViewer.label = Open in Internal Viewer
|
locate.internalViewer.label = Open in Internal Viewer
|
||||||
locate.internalViewer.tooltip = Open file in this application
|
|
||||||
locate.showFile.label = Show File
|
locate.showFile.label = Show File
|
||||||
locate.showFile.tooltip = Open the directory in which this file resides
|
|
||||||
locate.libraryLookup.label = Library Lookup
|
locate.libraryLookup.label = Library Lookup
|
||||||
locate.libraryLookup.tooltip = Look up this item using the selected OpenURL resolver
|
|
||||||
locate.manageLocateEngines = Manage Lookup Engines…
|
locate.manageLocateEngines = Manage Lookup Engines…
|
||||||
locate.locateEngineDescription = Lookup engines help you find resources in your %S library on the web. Engines enabled in this list appear in the Locate drop-down in the toolbar.
|
locate.locateEngineDescription = Lookup engines help you find resources in your %S library on the web. Engines enabled in this list appear in the Locate drop-down in the toolbar.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue