More hacks for pdf.js

This commit is contained in:
Simon Kornblith 2012-02-15 02:43:08 -05:00
parent 9b76f4b5b8
commit 645bbf92b8
2 changed files with 23 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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 {