commit 645bbf92b80a7a95c31253a5905ac731adf6a532 parent 9b76f4b5b8162fe9e309f204c563455f23f96d7c Author: Simon Kornblith <simon@simonster.com> Date: Wed, 15 Feb 2012 02:43:08 -0500 More hacks for pdf.js Diffstat:
| M | chrome/content/zotero/xpcom/attachments.js | | | 22 | ++++++++++++++++++++++ |
| M | chrome/content/zotero/zoteroPane.js | | | 2 | +- |
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js @@ -504,6 +504,10 @@ Zotero.Attachments = new function(){ var url = document.location.href; var title = forceTitle ? forceTitle : document.title; var mimeType = document.contentType; + if(Zotero.Attachments.isPDFJS(document)) { + mimeType = "application/pdf"; + } + var charsetID = Zotero.CharacterSets.getID(document.characterSet); if (!forceTitle) { @@ -1358,4 +1362,22 @@ Zotero.Attachments = new function(){ .getURLSpecFromFile(file); browser.loadURI(url); } + + /** + * Determines if a given document is an instance of PDFJS + * @return {Boolean} + */ + this.isPDFJS = function(doc) { + // pdf.js HACK + if(doc.contentType === "text/html") { + var win = doc.defaultView; + if(win) { + win = win.wrappedJSObject; + if(win && "PDFJS" in win && win.PDFJS.isFirefoxExtension) { + return true; + } + } + } + return false; + } } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -3082,7 +3082,7 @@ var ZoteroPane = new function() if (itemType == 'temporaryPDFHack') { itemType = null; var isPDF = false; - if (doc.title.indexOf('application/pdf') != -1) { + if (doc.title.indexOf('application/pdf') != -1 || Zotero.Attachments.isPDFJS(doc)) { isPDF = true; } else {