From 7b6611399022ce26177145eafe42789348a03030 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 12 Feb 2011 21:09:41 +0000 Subject: [PATCH] put "View PDF" at top of locate menu --- chrome/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 index f6c6e0b5e5..ba7dbb6735 100644 --- a/chrome/content/zotero/locateMenu.js +++ b/chrome/content/zotero/locateMenu.js @@ -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 *