Move "Show File" out of Locate menu and into File menu (#4124)
This commit is contained in:
parent
e1f1003318
commit
c47617c809
7 changed files with 74 additions and 39 deletions
|
@ -122,11 +122,12 @@ var Zotero_LocateMenu = new function() {
|
||||||
|
|
||||||
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
||||||
var menuitem;
|
var menuitem;
|
||||||
if (optionObject.l10nKey) {
|
if (optionObject.l10nId) {
|
||||||
menuitem = _createMenuItem('', null, null); // Set by Fluent
|
menuitem = _createMenuItem('', null, null); // Set by Fluent
|
||||||
menuitem.setAttribute("data-l10n-id", optionObject.l10nKey);
|
menuitem.dataset.l10nId = optionObject.l10nId;
|
||||||
if (optionObject.l10nArgs) {
|
let l10nArgs = optionObject.l10nArgs;
|
||||||
menuitem.setAttribute("data-l10n-args", optionObject.l10nArgs);
|
if (l10nArgs) {
|
||||||
|
menuitem.dataset.l10nArgs = JSON.stringify(l10nArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -395,7 +396,7 @@ var Zotero_LocateMenu = new function() {
|
||||||
// "in New Tab" when it's true) in toolbar Locate menu
|
// "in New Tab" when it's true) in toolbar Locate menu
|
||||||
this.hideInToolbar = alternateWindowBehavior;
|
this.hideInToolbar = alternateWindowBehavior;
|
||||||
|
|
||||||
this.l10nKey = "item-menu-viewAttachment";
|
this.l10nId = "item-menu-viewAttachment";
|
||||||
Object.defineProperty(this, "l10nArgs", {
|
Object.defineProperty(this, "l10nArgs", {
|
||||||
get: () => {
|
get: () => {
|
||||||
let openIn;
|
let openIn;
|
||||||
|
@ -409,11 +410,11 @@ var Zotero_LocateMenu = new function() {
|
||||||
}
|
}
|
||||||
openIn = openInNewWindow ? "window" : "tab";
|
openIn = openInNewWindow ? "window" : "tab";
|
||||||
}
|
}
|
||||||
return JSON.stringify({
|
return {
|
||||||
attachmentType: this._attachmentType,
|
attachmentType: this._attachmentType,
|
||||||
numAttachments: this._numAttachments,
|
numAttachments: this._numAttachments,
|
||||||
openIn,
|
openIn,
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -598,30 +599,24 @@ var Zotero_LocateMenu = new function() {
|
||||||
* file or web attachment
|
* file or web attachment
|
||||||
*/
|
*/
|
||||||
ViewOptions.showFile = new function() {
|
ViewOptions.showFile = new function() {
|
||||||
this.className = "zotero-menuitem-view-file";
|
this.className = "zotero-menuitem-show-file";
|
||||||
this.useExternalViewer = true;
|
this.hideInToolbar = true;
|
||||||
|
this.l10nId = "menu-show-file";
|
||||||
|
this.l10nArgs = { count: 0 };
|
||||||
|
|
||||||
this.canHandleItem = function (item) {
|
this.canHandleItem = function (item) {
|
||||||
return _getBestFile(item).then(item => !!item);
|
return ZoteroPane.canShowItemInFilesystem(item);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
this.updateMenuItem = function (items) {
|
||||||
for (let item of items) {
|
let count = items.filter(item => ZoteroPane.canShowItemInFilesystem(item))
|
||||||
var attachment = yield _getBestFile(item);
|
.length;
|
||||||
if(attachment) {
|
this.l10nArgs = { count };
|
||||||
ZoteroPane_Local.showAttachmentInFilesystem(attachment.id);
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var _getBestFile = Zotero.Promise.coroutine(function* (item) {
|
this.handleItems = async function (items) {
|
||||||
if(item.isAttachment()) {
|
await ZoteroPane.showItemsInFilesystem(items);
|
||||||
if(item.attachmentLinkMode === Zotero.Attachments.LINK_MODE_LINKED_URL) return false;
|
};
|
||||||
return item;
|
|
||||||
} else {
|
|
||||||
return yield item.getBestAttachment();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -157,8 +157,9 @@ const ZoteroStandalone = new function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onFileMenuOpen = function () {
|
this.onFileMenuOpen = function () {
|
||||||
// PDF annotation transfer ("Import Annotation"/"Store Annotations in File")
|
|
||||||
let reader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID);
|
let reader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID);
|
||||||
|
|
||||||
|
// PDF annotation transfer ("Import Annotation"/"Store Annotations in File")
|
||||||
if (reader) {
|
if (reader) {
|
||||||
let item = Zotero.Items.get(reader.itemID);
|
let item = Zotero.Items.get(reader.itemID);
|
||||||
let library = Zotero.Libraries.get(item.libraryID);
|
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
|
// TEMP: Quick implementation
|
||||||
try {
|
try {
|
||||||
let menuitem = document.getElementById('menu_export_files');
|
let menuitem = document.getElementById('menu_export_files');
|
||||||
let sep = menuitem.nextSibling;
|
if (!reader) {
|
||||||
|
let numFiles = ZoteroPane.getSelectedItems().reduce((num, item) => {
|
||||||
let zp = Zotero.getActiveZoteroPane();
|
|
||||||
if (zp && !reader) {
|
|
||||||
let numFiles = zp.getSelectedItems().reduce((num, item) => {
|
|
||||||
if (item.isPDFAttachment()) {
|
if (item.isPDFAttachment()) {
|
||||||
return num + 1;
|
return num + 1;
|
||||||
}
|
}
|
||||||
|
@ -193,19 +200,16 @@ const ZoteroStandalone = new function() {
|
||||||
}, 0);
|
}, 0);
|
||||||
if (numFiles) {
|
if (numFiles) {
|
||||||
menuitem.hidden = false;
|
menuitem.hidden = false;
|
||||||
sep.hidden = false;
|
|
||||||
menuitem.label = Zotero.getString(
|
menuitem.label = Zotero.getString(
|
||||||
'pane.items.menu.exportPDF' + (numFiles == 1 ? '' : '.multiple')
|
'pane.items.menu.exportPDF' + (numFiles == 1 ? '' : '.multiple')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
menuitem.hidden = true;
|
menuitem.hidden = true;
|
||||||
sep.hidden = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
menuitem.hidden = true;
|
menuitem.hidden = true;
|
||||||
sep.hidden = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -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) {
|
this.showAttachmentInFilesystem = async function (itemID, noLocateOnMissing) {
|
||||||
var attachment = await Zotero.Items.getAsync(itemID)
|
var attachment = await Zotero.Items.getAsync(itemID)
|
||||||
if (attachment.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL) return;
|
if (attachment.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL) return;
|
||||||
|
|
|
@ -319,10 +319,13 @@
|
||||||
<menuitem id="menu_close_tab" class="menu-type-reader" label="&closeCmd.label;" key="key_close"
|
<menuitem id="menu_close_tab" class="menu-type-reader" label="&closeCmd.label;" key="key_close"
|
||||||
accesskey="&closeCmd.accesskey;" oncommand="Zotero_Tabs.close()"/>
|
accesskey="&closeCmd.accesskey;" oncommand="Zotero_Tabs.close()"/>
|
||||||
<menuseparator class="menu-type-library"/>
|
<menuseparator class="menu-type-library"/>
|
||||||
|
<menuitem data-l10n-id="menu-show-file" id="menu_showFile"
|
||||||
|
class="menu-type-library"
|
||||||
|
oncommand="ZoteroPane.showItemsInFilesystem()"/>
|
||||||
<menuitem id="menu_export_files" class="menu-type-library"
|
<menuitem id="menu_export_files" class="menu-type-library"
|
||||||
oncommand="ZoteroPane.exportSelectedFiles()"
|
oncommand="ZoteroPane.exportSelectedFiles()"
|
||||||
hidden="true"/>
|
hidden="true"/>
|
||||||
<menuseparator class="menu-type-library" hidden="true"/>
|
<menuseparator class="menu-type-library"/>
|
||||||
<menuitem id="menu_import" class="menu-type-library" label="&importCmd.label;"
|
<menuitem id="menu_import" class="menu-type-library" label="&importCmd.label;"
|
||||||
command="cmd_zotero_import" key="key_import"/>
|
command="cmd_zotero_import" key="key_import"/>
|
||||||
<menuitem id="menu_importFromClipboard" class="menu-type-library" label="&importFromClipboardCmd.label;"
|
<menuitem id="menu_importFromClipboard" class="menu-type-library" label="&importFromClipboardCmd.label;"
|
||||||
|
|
|
@ -10,6 +10,15 @@ general-add = Add
|
||||||
|
|
||||||
menu-print =
|
menu-print =
|
||||||
.label = { general-print }
|
.label = { general-print }
|
||||||
|
menu-show-file =
|
||||||
|
.label = { PLATFORM() ->
|
||||||
|
[macos] Show in Finder
|
||||||
|
*[other] { $count ->
|
||||||
|
[0] Show File
|
||||||
|
[one] Show File
|
||||||
|
*[other] Show Files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu-density =
|
menu-density =
|
||||||
.label = Density
|
.label = Density
|
||||||
|
|
|
@ -1231,7 +1231,6 @@ locate.snapshot.label = View Snapshot
|
||||||
locate.file.label = View File
|
locate.file.label = View File
|
||||||
locate.externalViewer.label = Open in External Viewer
|
locate.externalViewer.label = Open in External Viewer
|
||||||
locate.internalViewer.label = Open in Internal Viewer
|
locate.internalViewer.label = Open in Internal Viewer
|
||||||
locate.showFile.label = Show File
|
|
||||||
locate.libraryLookup.label = Library Lookup
|
locate.libraryLookup.label = Library Lookup
|
||||||
locate.libraryLookup.noResolver.title = No OpenURL Resolver
|
locate.libraryLookup.noResolver.title = No OpenURL Resolver
|
||||||
locate.libraryLookup.noResolver.text = You must choose an OpenURL resolver from the Advanced pane of the %S preferences.
|
locate.libraryLookup.noResolver.text = You must choose an OpenURL resolver from the Advanced pane of the %S preferences.
|
||||||
|
|
|
@ -22,7 +22,7 @@ $menu-icons: (
|
||||||
attach: "attachment",
|
attach: "attachment",
|
||||||
attachments-web-link: "link",
|
attachments-web-link: "link",
|
||||||
view-online: "globe",
|
view-online: "globe",
|
||||||
view-file: "folder-open",
|
show-file: "folder-open",
|
||||||
view-external: "page",
|
view-external: "page",
|
||||||
library-lookup: "library-lookup",
|
library-lookup: "library-lookup",
|
||||||
new-feed: "feed",
|
new-feed: "feed",
|
||||||
|
|
Loading…
Reference in a new issue