put "View PDF" at top of locate menu
This commit is contained in:
parent
b4e5819a82
commit
7b66113990
1 changed files with 31 additions and 31 deletions
|
@ -229,6 +229,37 @@ var Zotero_LocateMenu = new function() {
|
|||
|
||||
var ViewOptions = {};
|
||||
|
||||
/**
|
||||
* "View PDF" option
|
||||
*
|
||||
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
|
||||
* a PDF
|
||||
*/
|
||||
ViewOptions.pdf = new function() {
|
||||
this.icon = "chrome://zotero/skin/treeitem-attachment-pdf.png";
|
||||
this._mimeTypes = ["application/pdf"];
|
||||
this.canHandleItem = function(item) !!_getFirstAttachmentWithMIMEType(item, this._mimeTypes);
|
||||
|
||||
this.handleItems = function(items, event) {
|
||||
for each(var item in items) {
|
||||
var attachment = _getFirstAttachmentWithMIMEType(item, this._mimeTypes);
|
||||
if(attachment) {
|
||||
ZoteroPane.viewAttachment(attachment.id, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _getFirstAttachmentWithMIMEType(item, mimeTypes) {
|
||||
var attachments = (item.isAttachment() ? [item] : Zotero.Items.get(item.getBestAttachments()));
|
||||
for each(var attachment in attachments) {
|
||||
if(mimeTypes.indexOf(attachment.attachmentMIMEType) !== -1
|
||||
&& item.linkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) return attachment;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* "View Online" option
|
||||
*
|
||||
|
@ -277,37 +308,6 @@ var Zotero_LocateMenu = new function() {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* "View PDF" option
|
||||
*
|
||||
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
|
||||
* a PDF
|
||||
*/
|
||||
ViewOptions.pdf = new function() {
|
||||
this.icon = "chrome://zotero/skin/treeitem-attachment-pdf.png";
|
||||
this._mimeTypes = ["application/pdf"];
|
||||
this.canHandleItem = function(item) !!_getFirstAttachmentWithMIMEType(item, this._mimeTypes);
|
||||
|
||||
this.handleItems = function(items, event) {
|
||||
for each(var item in items) {
|
||||
var attachment = _getFirstAttachmentWithMIMEType(item, this._mimeTypes);
|
||||
if(attachment) {
|
||||
ZoteroPane.viewAttachment(attachment.id, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _getFirstAttachmentWithMIMEType(item, mimeTypes) {
|
||||
var attachments = (item.isAttachment() ? [item] : Zotero.Items.get(item.getBestAttachments()));
|
||||
for each(var attachment in attachments) {
|
||||
if(mimeTypes.indexOf(attachment.attachmentMIMEType) !== -1
|
||||
&& item.linkMode != Zotero.Attachments.LINK_MODE_LINKED_URL) return attachment;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* "View Snapshot" option
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue