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

1510
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