diff --git a/chrome/content/zotero/locateMenu.js b/chrome/content/zotero/locateMenu.js
index b1a6db557b..f4619d7149 100644
--- a/chrome/content/zotero/locateMenu.js
+++ b/chrome/content/zotero/locateMenu.js
@@ -122,11 +122,12 @@ var Zotero_LocateMenu = new function() {
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
var menuitem;
- if (optionObject.l10nKey) {
+ if (optionObject.l10nId) {
menuitem = _createMenuItem('', null, null); // Set by Fluent
- menuitem.setAttribute("data-l10n-id", optionObject.l10nKey);
- if (optionObject.l10nArgs) {
- menuitem.setAttribute("data-l10n-args", optionObject.l10nArgs);
+ menuitem.dataset.l10nId = optionObject.l10nId;
+ let l10nArgs = optionObject.l10nArgs;
+ if (l10nArgs) {
+ menuitem.dataset.l10nArgs = JSON.stringify(l10nArgs);
}
}
else {
@@ -395,7 +396,7 @@ var Zotero_LocateMenu = new function() {
// "in New Tab" when it's true) in toolbar Locate menu
this.hideInToolbar = alternateWindowBehavior;
- this.l10nKey = "item-menu-viewAttachment";
+ this.l10nId = "item-menu-viewAttachment";
Object.defineProperty(this, "l10nArgs", {
get: () => {
let openIn;
@@ -409,11 +410,11 @@ var Zotero_LocateMenu = new function() {
}
openIn = openInNewWindow ? "window" : "tab";
}
- return JSON.stringify({
+ return {
attachmentType: this._attachmentType,
numAttachments: this._numAttachments,
openIn,
- });
+ };
}
});
@@ -598,30 +599,24 @@ var Zotero_LocateMenu = new function() {
* file or web attachment
*/
ViewOptions.showFile = new function() {
- this.className = "zotero-menuitem-view-file";
- this.useExternalViewer = true;
+ this.className = "zotero-menuitem-show-file";
+ this.hideInToolbar = true;
+ this.l10nId = "menu-show-file";
+ this.l10nArgs = { count: 0 };
this.canHandleItem = function (item) {
- return _getBestFile(item).then(item => !!item);
- }
+ return ZoteroPane.canShowItemInFilesystem(item);
+ };
- this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
- for (let item of items) {
- var attachment = yield _getBestFile(item);
- if(attachment) {
- ZoteroPane_Local.showAttachmentInFilesystem(attachment.id);
- }
- }
- });
+ this.updateMenuItem = function (items) {
+ let count = items.filter(item => ZoteroPane.canShowItemInFilesystem(item))
+ .length;
+ this.l10nArgs = { count };
+ };
- var _getBestFile = Zotero.Promise.coroutine(function* (item) {
- if(item.isAttachment()) {
- if(item.attachmentLinkMode === Zotero.Attachments.LINK_MODE_LINKED_URL) return false;
- return item;
- } else {
- return yield item.getBestAttachment();
- }
- });
+ this.handleItems = async function (items) {
+ await ZoteroPane.showItemsInFilesystem(items);
+ };
};
/**
diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js
index 832a895551..5b2f7f569c 100644
--- a/chrome/content/zotero/standalone/standalone.js
+++ b/chrome/content/zotero/standalone/standalone.js
@@ -157,8 +157,9 @@ const ZoteroStandalone = new function() {
};
this.onFileMenuOpen = function () {
- // PDF annotation transfer ("Import Annotation"/"Store Annotations in File")
let reader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID);
+
+ // PDF annotation transfer ("Import Annotation"/"Store Annotations in File")
if (reader) {
let item = Zotero.Items.get(reader.itemID);
let library = Zotero.Libraries.get(item.libraryID);
@@ -175,14 +176,20 @@ const ZoteroStandalone = new function() {
}
}
+ let showFileMenuitem = document.getElementById('menu_showFile');
+ let numFiles = ZoteroPane.getSelectedItems()
+ .filter(item => ZoteroPane.canShowItemInFilesystem(item))
+ .length;
+ showFileMenuitem.disabled = !numFiles;
+ document.l10n.setArgs(showFileMenuitem, {
+ count: numFiles
+ });
+
// TEMP: Quick implementation
try {
let menuitem = document.getElementById('menu_export_files');
- let sep = menuitem.nextSibling;
-
- let zp = Zotero.getActiveZoteroPane();
- if (zp && !reader) {
- let numFiles = zp.getSelectedItems().reduce((num, item) => {
+ if (!reader) {
+ let numFiles = ZoteroPane.getSelectedItems().reduce((num, item) => {
if (item.isPDFAttachment()) {
return num + 1;
}
@@ -193,19 +200,16 @@ const ZoteroStandalone = new function() {
}, 0);
if (numFiles) {
menuitem.hidden = false;
- sep.hidden = false;
menuitem.label = Zotero.getString(
'pane.items.menu.exportPDF' + (numFiles == 1 ? '' : '.multiple')
);
}
else {
menuitem.hidden = true;
- sep.hidden = true;
}
}
else {
menuitem.hidden = true;
- sep.hidden = true;
}
}
catch (e) {
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
index 35577083b9..f338e5359e 100644
--- a/chrome/content/zotero/zoteroPane.js
+++ b/chrome/content/zotero/zoteroPane.js
@@ -4901,6 +4901,31 @@ var ZoteroPane = new function()
}
+ this.canShowItemInFilesystem = function (item) {
+ return (item.isRegularItem() && item.numFileAttachments()) || item.isFileAttachment();
+ };
+
+
+ this.showItemsInFilesystem = async function (items = this.getSelectedItems()) {
+ let attachments = (await Promise.all(
+ items.map((item) => {
+ if (item.isRegularItem()) {
+ return item.getBestAttachment();
+ }
+ else if (item.isFileAttachment()) {
+ return item;
+ }
+ else {
+ return null;
+ }
+ })
+ )).filter(Boolean);
+ for (let attachment of attachments) {
+ await this.showAttachmentInFilesystem(attachment.id);
+ }
+ };
+
+
this.showAttachmentInFilesystem = async function (itemID, noLocateOnMissing) {
var attachment = await Zotero.Items.getAsync(itemID)
if (attachment.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL) return;
diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml
index 4525b97696..a5246e1115 100644
--- a/chrome/content/zotero/zoteroPane.xhtml
+++ b/chrome/content/zotero/zoteroPane.xhtml
@@ -319,10 +319,13 @@
+
-
+