www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 7b6611399022ce26177145eafe42789348a03030
parent b4e5819a823a9404c94018804e0e56b09df3b29c
Author: Simon Kornblith <simon@simonster.com>
Date:   Sat, 12 Feb 2011 21:09:41 +0000

put "View PDF" at top of locate menu


Diffstat:
Mchrome/content/zotero/locateMenu.js | 62+++++++++++++++++++++++++++++++-------------------------------
1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/chrome/content/zotero/locateMenu.js b/chrome/content/zotero/locateMenu.js @@ -230,6 +230,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 * * Should appear only when an item or an attachment has a URL @@ -278,37 +309,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 * * Should appear only when the item is a PDF, or a linked or attached file or web attachment is