Browse Source

Updated to PDF.js 1.0.907

pull/156/merge
Simon Eisenmann 11 years ago
parent
commit
f3509bc215
  1. 61
      static/js/libs/pdf/compatibility.js
  2. 1514
      static/js/libs/pdf/pdf.js
  3. 10600
      static/js/libs/pdf/pdf.worker.js

61
static/js/libs/pdf/compatibility.js

@ -167,26 +167,40 @@ if (typeof PDFJS === 'undefined') {
// The worker will be using XHR, so we can save time and disable worker. // The worker will be using XHR, so we can save time and disable worker.
PDFJS.disableWorker = true; PDFJS.disableWorker = true;
Object.defineProperty(xhrPrototype, 'responseType', {
get: function xmlHttpRequestGetResponseType() {
return this._responseType || 'text';
},
set: function xmlHttpRequestSetResponseType(value) {
if (value === 'text' || value === 'arraybuffer') {
this._responseType = value;
if (value === 'arraybuffer' &&
typeof this.overrideMimeType === 'function') {
this.overrideMimeType('text/plain; charset=x-user-defined');
}
}
}
});
// Support: IE9 // Support: IE9
if (typeof VBArray !== 'undefined') { if (typeof VBArray !== 'undefined') {
Object.defineProperty(xhrPrototype, 'response', { Object.defineProperty(xhrPrototype, 'response', {
get: function xmlHttpRequestResponseGet() { get: function xmlHttpRequestResponseGet() {
if (this.responseType === 'arraybuffer') {
return new Uint8Array(new VBArray(this.responseBody).toArray()); return new Uint8Array(new VBArray(this.responseBody).toArray());
} else {
return this.responseText;
}
} }
}); });
return; return;
} }
// other browsers Object.defineProperty(xhrPrototype, 'response', {
function responseTypeSetter() { get: function xmlHttpRequestResponseGet() {
// will be only called to set "arraybuffer" if (this.responseType !== 'arraybuffer') {
this.overrideMimeType('text/plain; charset=x-user-defined'); return this.responseText;
}
if (typeof xhr.overrideMimeType === 'function') {
Object.defineProperty(xhrPrototype, 'responseType',
{ set: responseTypeSetter });
} }
function responseGetter() {
var text = this.responseText; var text = this.responseText;
var i, n = text.length; var i, n = text.length;
var result = new Uint8Array(n); var result = new Uint8Array(n);
@ -195,7 +209,7 @@ if (typeof PDFJS === 'undefined') {
} }
return result.buffer; return result.buffer;
} }
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter }); });
})(); })();
// window.btoa (base64 encode function) ? // window.btoa (base64 encode function) ?
@ -237,7 +251,7 @@ if (typeof PDFJS === 'undefined') {
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
window.atob = function (input) { window.atob = function (input) {
input = input.replace(/=+$/, ''); input = input.replace(/=+$/, '');
if (input.length % 4 == 1) { if (input.length % 4 === 1) {
throw new Error('bad atob input'); throw new Error('bad atob input');
} }
for ( for (
@ -293,7 +307,7 @@ if (typeof PDFJS === 'undefined') {
var dataset = {}; var dataset = {};
for (var j = 0, jj = this.attributes.length; j < jj; j++) { for (var j = 0, jj = this.attributes.length; j < jj; j++) {
var attribute = this.attributes[j]; var attribute = this.attributes[j];
if (attribute.name.substring(0, 5) != 'data-') { if (attribute.name.substring(0, 5) !== 'data-') {
continue; continue;
} }
var key = attribute.name.substring(5).replace(/\-([a-z])/g, var key = attribute.name.substring(5).replace(/\-([a-z])/g,
@ -416,7 +430,7 @@ if (typeof PDFJS === 'undefined') {
function isDisabled(node) { function isDisabled(node) {
return node.disabled || (node.parentNode && isDisabled(node.parentNode)); return node.disabled || (node.parentNode && isDisabled(node.parentNode));
} }
if (navigator.userAgent.indexOf('Opera') != -1) { if (navigator.userAgent.indexOf('Opera') !== -1) {
// use browser detection since we cannot feature-check this bug // use browser detection since we cannot feature-check this bug
document.addEventListener('click', ignoreIfTargetDisabled, true); document.addEventListener('click', ignoreIfTargetDisabled, true);
} }
@ -467,6 +481,7 @@ if (typeof PDFJS === 'undefined') {
if (isSafari || isOldAndroid) { if (isSafari || isOldAndroid) {
PDFJS.disableRange = true; PDFJS.disableRange = true;
PDFJS.disableStream = true;
} }
})(); })();
@ -481,7 +496,7 @@ if (typeof PDFJS === 'undefined') {
} }
})(); })();
// Support: IE<11, Chrome<21, Android<4.4 // Support: IE<11, Chrome<21, Android<4.4, Safari<6
(function checkSetPresenceInImageData() { (function checkSetPresenceInImageData() {
// IE < 11 will use window.CanvasPixelArray which lacks set function. // IE < 11 will use window.CanvasPixelArray which lacks set function.
if (window.CanvasPixelArray) { if (window.CanvasPixelArray) {
@ -495,21 +510,21 @@ if (typeof PDFJS === 'undefined') {
} else { } else {
// Old Chrome and Android use an inaccessible CanvasPixelArray prototype. // Old Chrome and Android use an inaccessible CanvasPixelArray prototype.
// Because we cannot feature detect it, we rely on user agent parsing. // Because we cannot feature detect it, we rely on user agent parsing.
var polyfill = false; var polyfill = false, versionMatch;
if (navigator.userAgent.indexOf('Chrom') >= 0) { if (navigator.userAgent.indexOf('Chrom') >= 0) {
var versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
if (versionMatch && parseInt(versionMatch[2]) < 21) {
// Chrome < 21 lacks the set function. // Chrome < 21 lacks the set function.
polyfill = true; polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
}
} else if (navigator.userAgent.indexOf('Android') >= 0) { } else if (navigator.userAgent.indexOf('Android') >= 0) {
// Android < 4.4 lacks the set function. // Android < 4.4 lacks the set function.
// Android >= 4.4 will contain Chrome in the user agent, // Android >= 4.4 will contain Chrome in the user agent,
// thus pass the Chrome check above and not reach this block. // thus pass the Chrome check above and not reach this block.
var isOldAndroid = /Android\s[0-4][^\d]/g.test(navigator.userAgent); polyfill = /Android\s[0-4][^\d]/g.test(navigator.userAgent);
if (isOldAndroid) { } else if (navigator.userAgent.indexOf('Safari') >= 0) {
polyfill = true; versionMatch = navigator.userAgent.
} match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
// Safari < 6 lacks the set function.
polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
} }
if (polyfill) { if (polyfill) {

1514
static/js/libs/pdf/pdf.js

File diff suppressed because it is too large Load Diff

10600
static/js/libs/pdf/pdf.worker.js vendored

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save