|
@@ -25,10 +25,9 @@ if (typeof PDFJS === 'undefined') {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Checking if the typed arrays are supported
|
|
// Checking if the typed arrays are supported
|
|
|
-// Support: iOS<6.0 (subarray), IE<10, Android<4.0
|
|
|
|
|
(function checkTypedArrayCompatibility() {
|
|
(function checkTypedArrayCompatibility() {
|
|
|
if (typeof Uint8Array !== 'undefined') {
|
|
if (typeof Uint8Array !== 'undefined') {
|
|
|
- // Support: iOS<6.0
|
|
|
|
|
|
|
+ // some mobile versions do not support subarray (e.g. safari 5 / iOS)
|
|
|
if (typeof Uint8Array.prototype.subarray === 'undefined') {
|
|
if (typeof Uint8Array.prototype.subarray === 'undefined') {
|
|
|
Uint8Array.prototype.subarray = function subarray(start, end) {
|
|
Uint8Array.prototype.subarray = function subarray(start, end) {
|
|
|
return new Uint8Array(this.slice(start, end));
|
|
return new Uint8Array(this.slice(start, end));
|
|
@@ -38,10 +37,10 @@ if (typeof PDFJS === 'undefined') {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Support: Android<4.1
|
|
|
|
|
- if (typeof Float64Array === 'undefined') {
|
|
|
|
|
|
|
+ // some mobile version might not support Float64Array
|
|
|
|
|
+ if (typeof Float64Array === 'undefined')
|
|
|
window.Float64Array = Float32Array;
|
|
window.Float64Array = Float32Array;
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -50,26 +49,23 @@ if (typeof PDFJS === 'undefined') {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function setArrayOffset(array, offset) {
|
|
function setArrayOffset(array, offset) {
|
|
|
- if (arguments.length < 2) {
|
|
|
|
|
|
|
+ if (arguments.length < 2)
|
|
|
offset = 0;
|
|
offset = 0;
|
|
|
- }
|
|
|
|
|
- for (var i = 0, n = array.length; i < n; ++i, ++offset) {
|
|
|
|
|
|
|
+ for (var i = 0, n = array.length; i < n; ++i, ++offset)
|
|
|
this[offset] = array[i] & 0xFF;
|
|
this[offset] = array[i] & 0xFF;
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function TypedArray(arg1) {
|
|
function TypedArray(arg1) {
|
|
|
- var result, i, n;
|
|
|
|
|
|
|
+ var result;
|
|
|
if (typeof arg1 === 'number') {
|
|
if (typeof arg1 === 'number') {
|
|
|
result = [];
|
|
result = [];
|
|
|
- for (i = 0; i < arg1; ++i) {
|
|
|
|
|
|
|
+ for (var i = 0; i < arg1; ++i)
|
|
|
result[i] = 0;
|
|
result[i] = 0;
|
|
|
- }
|
|
|
|
|
} else if ('slice' in arg1) {
|
|
} else if ('slice' in arg1) {
|
|
|
result = arg1.slice(0);
|
|
result = arg1.slice(0);
|
|
|
} else {
|
|
} else {
|
|
|
result = [];
|
|
result = [];
|
|
|
- for (i = 0, n = arg1.length; i < n; ++i) {
|
|
|
|
|
|
|
+ for (var i = 0, n = arg1.length; i < n; ++i) {
|
|
|
result[i] = arg1[i];
|
|
result[i] = arg1[i];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -79,14 +75,13 @@ if (typeof PDFJS === 'undefined') {
|
|
|
result.byteLength = result.length;
|
|
result.byteLength = result.length;
|
|
|
result.set = setArrayOffset;
|
|
result.set = setArrayOffset;
|
|
|
|
|
|
|
|
- if (typeof arg1 === 'object' && arg1.buffer) {
|
|
|
|
|
|
|
+ if (typeof arg1 === 'object' && arg1.buffer)
|
|
|
result.buffer = arg1.buffer;
|
|
result.buffer = arg1.buffer;
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
window.Uint8Array = TypedArray;
|
|
window.Uint8Array = TypedArray;
|
|
|
- window.Int8Array = TypedArray;
|
|
|
|
|
|
|
|
|
|
// we don't need support for set, byteLength for 32-bit array
|
|
// we don't need support for set, byteLength for 32-bit array
|
|
|
// so we can use the TypedArray as well
|
|
// so we can use the TypedArray as well
|
|
@@ -98,15 +93,25 @@ if (typeof PDFJS === 'undefined') {
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// URL = URL || webkitURL
|
|
// URL = URL || webkitURL
|
|
|
-// Support: Safari<7, Android 4.2+
|
|
|
|
|
(function normalizeURLObject() {
|
|
(function normalizeURLObject() {
|
|
|
if (!window.URL) {
|
|
if (!window.URL) {
|
|
|
window.URL = window.webkitURL;
|
|
window.URL = window.webkitURL;
|
|
|
}
|
|
}
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
-// Object.defineProperty()?
|
|
|
|
|
-// Support: Android<4.0, Safari<5.1
|
|
|
|
|
|
|
+// Object.create() ?
|
|
|
|
|
+(function checkObjectCreateCompatibility() {
|
|
|
|
|
+ if (typeof Object.create !== 'undefined')
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ Object.create = function objectCreate(proto) {
|
|
|
|
|
+ function Constructor() {}
|
|
|
|
|
+ Constructor.prototype = proto;
|
|
|
|
|
+ return new Constructor();
|
|
|
|
|
+ };
|
|
|
|
|
+})();
|
|
|
|
|
+
|
|
|
|
|
+// Object.defineProperty() ?
|
|
|
(function checkObjectDefinePropertyCompatibility() {
|
|
(function checkObjectDefinePropertyCompatibility() {
|
|
|
if (typeof Object.defineProperty !== 'undefined') {
|
|
if (typeof Object.defineProperty !== 'undefined') {
|
|
|
var definePropertyPossible = true;
|
|
var definePropertyPossible = true;
|
|
@@ -122,19 +127,15 @@ if (typeof PDFJS === 'undefined') {
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
definePropertyPossible = false;
|
|
definePropertyPossible = false;
|
|
|
}
|
|
}
|
|
|
- if (definePropertyPossible) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (definePropertyPossible) return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Object.defineProperty = function objectDefineProperty(obj, name, def) {
|
|
Object.defineProperty = function objectDefineProperty(obj, name, def) {
|
|
|
delete obj[name];
|
|
delete obj[name];
|
|
|
- if ('get' in def) {
|
|
|
|
|
|
|
+ if ('get' in def)
|
|
|
obj.__defineGetter__(name, def['get']);
|
|
obj.__defineGetter__(name, def['get']);
|
|
|
- }
|
|
|
|
|
- if ('set' in def) {
|
|
|
|
|
|
|
+ if ('set' in def)
|
|
|
obj.__defineSetter__(name, def['set']);
|
|
obj.__defineSetter__(name, def['set']);
|
|
|
- }
|
|
|
|
|
if ('value' in def) {
|
|
if ('value' in def) {
|
|
|
obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
|
|
obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
|
|
|
this.__defineGetter__(name, function objectDefinePropertyGetter() {
|
|
this.__defineGetter__(name, function objectDefinePropertyGetter() {
|
|
@@ -147,35 +148,76 @@ if (typeof PDFJS === 'undefined') {
|
|
|
};
|
|
};
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
|
|
+// Object.keys() ?
|
|
|
|
|
+(function checkObjectKeysCompatibility() {
|
|
|
|
|
+ if (typeof Object.keys !== 'undefined')
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
-// No XMLHttpRequest#response?
|
|
|
|
|
-// Support: IE<11, Android <4.0
|
|
|
|
|
|
|
+ Object.keys = function objectKeys(obj) {
|
|
|
|
|
+ var result = [];
|
|
|
|
|
+ for (var i in obj) {
|
|
|
|
|
+ if (obj.hasOwnProperty(i))
|
|
|
|
|
+ result.push(i);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ };
|
|
|
|
|
+})();
|
|
|
|
|
+
|
|
|
|
|
+// No readAsArrayBuffer ?
|
|
|
|
|
+(function checkFileReaderReadAsArrayBuffer() {
|
|
|
|
|
+ if (typeof FileReader === 'undefined')
|
|
|
|
|
+ return; // FileReader is not implemented
|
|
|
|
|
+ var frPrototype = FileReader.prototype;
|
|
|
|
|
+ // Older versions of Firefox might not have readAsArrayBuffer
|
|
|
|
|
+ if ('readAsArrayBuffer' in frPrototype)
|
|
|
|
|
+ return; // readAsArrayBuffer is implemented
|
|
|
|
|
+ Object.defineProperty(frPrototype, 'readAsArrayBuffer', {
|
|
|
|
|
+ value: function fileReaderReadAsArrayBuffer(blob) {
|
|
|
|
|
+ var fileReader = new FileReader();
|
|
|
|
|
+ var originalReader = this;
|
|
|
|
|
+ fileReader.onload = function fileReaderOnload(evt) {
|
|
|
|
|
+ var data = evt.target.result;
|
|
|
|
|
+ var buffer = new ArrayBuffer(data.length);
|
|
|
|
|
+ var uint8Array = new Uint8Array(buffer);
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0, ii = data.length; i < ii; i++)
|
|
|
|
|
+ uint8Array[i] = data.charCodeAt(i);
|
|
|
|
|
+
|
|
|
|
|
+ Object.defineProperty(originalReader, 'result', {
|
|
|
|
|
+ value: buffer,
|
|
|
|
|
+ enumerable: true,
|
|
|
|
|
+ writable: false,
|
|
|
|
|
+ configurable: true
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ var event = document.createEvent('HTMLEvents');
|
|
|
|
|
+ event.initEvent('load', false, false);
|
|
|
|
|
+ originalReader.dispatchEvent(event);
|
|
|
|
|
+ };
|
|
|
|
|
+ fileReader.readAsBinaryString(blob);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+})();
|
|
|
|
|
+
|
|
|
|
|
+// No XMLHttpRequest.response ?
|
|
|
(function checkXMLHttpRequestResponseCompatibility() {
|
|
(function checkXMLHttpRequestResponseCompatibility() {
|
|
|
var xhrPrototype = XMLHttpRequest.prototype;
|
|
var xhrPrototype = XMLHttpRequest.prototype;
|
|
|
- var xhr = new XMLHttpRequest();
|
|
|
|
|
- if (!('overrideMimeType' in xhr)) {
|
|
|
|
|
|
|
+ if (!('overrideMimeType' in xhrPrototype)) {
|
|
|
// IE10 might have response, but not overrideMimeType
|
|
// IE10 might have response, but not overrideMimeType
|
|
|
- // Support: IE10
|
|
|
|
|
Object.defineProperty(xhrPrototype, 'overrideMimeType', {
|
|
Object.defineProperty(xhrPrototype, 'overrideMimeType', {
|
|
|
value: function xmlHttpRequestOverrideMimeType(mimeType) {}
|
|
value: function xmlHttpRequestOverrideMimeType(mimeType) {}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- if ('responseType' in xhr) {
|
|
|
|
|
|
|
+ if ('response' in xhrPrototype ||
|
|
|
|
|
+ 'mozResponseArrayBuffer' in xhrPrototype ||
|
|
|
|
|
+ 'mozResponse' in xhrPrototype ||
|
|
|
|
|
+ 'responseArrayBuffer' in xhrPrototype)
|
|
|
return;
|
|
return;
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // The worker will be using XHR, so we can save time and disable worker.
|
|
|
|
|
- PDFJS.disableWorker = true;
|
|
|
|
|
-
|
|
|
|
|
- // Support: IE9
|
|
|
|
|
|
|
+ // 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());
|
|
|
|
|
- } else {
|
|
|
|
|
- return this.responseText;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return new Uint8Array(new VBArray(this.responseBody).toArray());
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
return;
|
|
return;
|
|
@@ -186,7 +228,7 @@ if (typeof PDFJS === 'undefined') {
|
|
|
// will be only called to set "arraybuffer"
|
|
// will be only called to set "arraybuffer"
|
|
|
this.overrideMimeType('text/plain; charset=x-user-defined');
|
|
this.overrideMimeType('text/plain; charset=x-user-defined');
|
|
|
}
|
|
}
|
|
|
- if (typeof xhr.overrideMimeType === 'function') {
|
|
|
|
|
|
|
+ if (typeof xhrPrototype.overrideMimeType === 'function') {
|
|
|
Object.defineProperty(xhrPrototype, 'responseType',
|
|
Object.defineProperty(xhrPrototype, 'responseType',
|
|
|
{ set: responseTypeSetter });
|
|
{ set: responseTypeSetter });
|
|
|
}
|
|
}
|
|
@@ -194,20 +236,17 @@ if (typeof PDFJS === 'undefined') {
|
|
|
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);
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
|
|
|
|
+ for (i = 0; i < n; ++i)
|
|
|
result[i] = text.charCodeAt(i) & 0xFF;
|
|
result[i] = text.charCodeAt(i) & 0xFF;
|
|
|
- }
|
|
|
|
|
- return result.buffer;
|
|
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter });
|
|
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter });
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// window.btoa (base64 encode function) ?
|
|
// window.btoa (base64 encode function) ?
|
|
|
-// Support: IE<10
|
|
|
|
|
(function checkWindowBtoaCompatibility() {
|
|
(function checkWindowBtoaCompatibility() {
|
|
|
- if ('btoa' in window) {
|
|
|
|
|
|
|
+ if ('btoa' in window)
|
|
|
return;
|
|
return;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
var digits =
|
|
var digits =
|
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -229,21 +268,17 @@ if (typeof PDFJS === 'undefined') {
|
|
|
};
|
|
};
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
-// window.atob (base64 encode function)?
|
|
|
|
|
-// Support: IE<10
|
|
|
|
|
|
|
+// window.atob (base64 encode function) ?
|
|
|
(function checkWindowAtobCompatibility() {
|
|
(function checkWindowAtobCompatibility() {
|
|
|
- if ('atob' in window) {
|
|
|
|
|
|
|
+ if ('atob' in window)
|
|
|
return;
|
|
return;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// https://github.com/davidchambers/Base64.js
|
|
// https://github.com/davidchambers/Base64.js
|
|
|
var digits =
|
|
var digits =
|
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
|
window.atob = function (input) {
|
|
window.atob = function (input) {
|
|
|
input = input.replace(/=+$/, '');
|
|
input = input.replace(/=+$/, '');
|
|
|
- if (input.length % 4 === 1) {
|
|
|
|
|
- throw new Error('bad atob input');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (input.length % 4 == 1) throw new Error('bad atob input');
|
|
|
for (
|
|
for (
|
|
|
// initialize result and counters
|
|
// initialize result and counters
|
|
|
var bc = 0, bs, buffer, idx = 0, output = '';
|
|
var bc = 0, bs, buffer, idx = 0, output = '';
|
|
@@ -263,17 +298,15 @@ if (typeof PDFJS === 'undefined') {
|
|
|
};
|
|
};
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
-// Function.prototype.bind?
|
|
|
|
|
-// Support: Android<4.0, iOS<6.0
|
|
|
|
|
|
|
+// Function.prototype.bind ?
|
|
|
(function checkFunctionPrototypeBindCompatibility() {
|
|
(function checkFunctionPrototypeBindCompatibility() {
|
|
|
- if (typeof Function.prototype.bind !== 'undefined') {
|
|
|
|
|
|
|
+ if (typeof Function.prototype.bind !== 'undefined')
|
|
|
return;
|
|
return;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
Function.prototype.bind = function functionPrototypeBind(obj) {
|
|
Function.prototype.bind = function functionPrototypeBind(obj) {
|
|
|
var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
|
|
var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
|
|
|
var bound = function functionPrototypeBindBound() {
|
|
var bound = function functionPrototypeBindBound() {
|
|
|
- var args = headArgs.concat(Array.prototype.slice.call(arguments));
|
|
|
|
|
|
|
+ var args = Array.prototype.concat.apply(headArgs, arguments);
|
|
|
return fn.apply(obj, args);
|
|
return fn.apply(obj, args);
|
|
|
};
|
|
};
|
|
|
return bound;
|
|
return bound;
|
|
@@ -281,29 +314,23 @@ if (typeof PDFJS === 'undefined') {
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// HTMLElement dataset property
|
|
// HTMLElement dataset property
|
|
|
-// Support: IE<11, Safari<5.1, Android<4.0
|
|
|
|
|
(function checkDatasetProperty() {
|
|
(function checkDatasetProperty() {
|
|
|
var div = document.createElement('div');
|
|
var div = document.createElement('div');
|
|
|
- if ('dataset' in div) {
|
|
|
|
|
|
|
+ if ('dataset' in div)
|
|
|
return; // dataset property exists
|
|
return; // dataset property exists
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(HTMLElement.prototype, 'dataset', {
|
|
Object.defineProperty(HTMLElement.prototype, 'dataset', {
|
|
|
get: function() {
|
|
get: function() {
|
|
|
- if (this._dataset) {
|
|
|
|
|
|
|
+ if (this._dataset)
|
|
|
return this._dataset;
|
|
return this._dataset;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
- function(all, ch) {
|
|
|
|
|
- return ch.toUpperCase();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ function(all, ch) { return ch.toUpperCase(); });
|
|
|
dataset[key] = attribute.value;
|
|
dataset[key] = attribute.value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -319,26 +346,20 @@ if (typeof PDFJS === 'undefined') {
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// HTMLElement classList property
|
|
// HTMLElement classList property
|
|
|
-// Support: IE<10, Android<4.0, iOS<5.0
|
|
|
|
|
(function checkClassListProperty() {
|
|
(function checkClassListProperty() {
|
|
|
var div = document.createElement('div');
|
|
var div = document.createElement('div');
|
|
|
- if ('classList' in div) {
|
|
|
|
|
|
|
+ if ('classList' in div)
|
|
|
return; // classList property exists
|
|
return; // classList property exists
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
function changeList(element, itemName, add, remove) {
|
|
function changeList(element, itemName, add, remove) {
|
|
|
var s = element.className || '';
|
|
var s = element.className || '';
|
|
|
var list = s.split(/\s+/g);
|
|
var list = s.split(/\s+/g);
|
|
|
- if (list[0] === '') {
|
|
|
|
|
- list.shift();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (list[0] === '') list.shift();
|
|
|
var index = list.indexOf(itemName);
|
|
var index = list.indexOf(itemName);
|
|
|
- if (index < 0 && add) {
|
|
|
|
|
|
|
+ if (index < 0 && add)
|
|
|
list.push(itemName);
|
|
list.push(itemName);
|
|
|
- }
|
|
|
|
|
- if (index >= 0 && remove) {
|
|
|
|
|
|
|
+ if (index >= 0 && remove)
|
|
|
list.splice(index, 1);
|
|
list.splice(index, 1);
|
|
|
- }
|
|
|
|
|
element.className = list.join(' ');
|
|
element.className = list.join(' ');
|
|
|
return (index >= 0);
|
|
return (index >= 0);
|
|
|
}
|
|
}
|
|
@@ -360,9 +381,8 @@ if (typeof PDFJS === 'undefined') {
|
|
|
|
|
|
|
|
Object.defineProperty(HTMLElement.prototype, 'classList', {
|
|
Object.defineProperty(HTMLElement.prototype, 'classList', {
|
|
|
get: function() {
|
|
get: function() {
|
|
|
- if (this._classList) {
|
|
|
|
|
|
|
+ if (this._classList)
|
|
|
return this._classList;
|
|
return this._classList;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
var classList = Object.create(classListPrototype, {
|
|
var classList = Object.create(classListPrototype, {
|
|
|
element: {
|
|
element: {
|
|
@@ -383,9 +403,6 @@ if (typeof PDFJS === 'undefined') {
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// Check console compatibility
|
|
// Check console compatibility
|
|
|
-// In older IE versions the console object is not available
|
|
|
|
|
-// unless console is open.
|
|
|
|
|
-// Support: IE<10
|
|
|
|
|
(function checkConsoleCompatibility() {
|
|
(function checkConsoleCompatibility() {
|
|
|
if (!('console' in window)) {
|
|
if (!('console' in window)) {
|
|
|
window.console = {
|
|
window.console = {
|
|
@@ -408,7 +425,6 @@ if (typeof PDFJS === 'undefined') {
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// Check onclick compatibility in Opera
|
|
// Check onclick compatibility in Opera
|
|
|
-// Support: Opera<15
|
|
|
|
|
(function checkOnClickCompatibility() {
|
|
(function checkOnClickCompatibility() {
|
|
|
// workaround for reported Opera bug DSK-354448:
|
|
// workaround for reported Opera bug DSK-354448:
|
|
|
// onclick fires on disabled buttons with opaque content
|
|
// onclick fires on disabled buttons with opaque content
|
|
@@ -420,44 +436,30 @@ 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);
|
|
|
}
|
|
}
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
-// Checks if possible to use URL.createObjectURL()
|
|
|
|
|
-// Support: IE
|
|
|
|
|
-(function checkOnBlobSupport() {
|
|
|
|
|
- // sometimes IE loosing the data created with createObjectURL(), see #3977
|
|
|
|
|
- if (navigator.userAgent.indexOf('Trident') >= 0) {
|
|
|
|
|
- PDFJS.disableCreateObjectURL = true;
|
|
|
|
|
- }
|
|
|
|
|
-})();
|
|
|
|
|
-
|
|
|
|
|
// Checks if navigator.language is supported
|
|
// Checks if navigator.language is supported
|
|
|
(function checkNavigatorLanguage() {
|
|
(function checkNavigatorLanguage() {
|
|
|
- if ('language' in navigator &&
|
|
|
|
|
- /^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) {
|
|
|
|
|
|
|
+ if ('language' in navigator)
|
|
|
return;
|
|
return;
|
|
|
- }
|
|
|
|
|
- function formatLocale(locale) {
|
|
|
|
|
- var split = locale.split(/[-_]/);
|
|
|
|
|
- split[0] = split[0].toLowerCase();
|
|
|
|
|
- if (split.length > 1) {
|
|
|
|
|
- split[1] = split[1].toUpperCase();
|
|
|
|
|
- }
|
|
|
|
|
- return split.join('-');
|
|
|
|
|
- }
|
|
|
|
|
- var language = navigator.language || navigator.userLanguage || 'en-US';
|
|
|
|
|
- PDFJS.locale = formatLocale(language);
|
|
|
|
|
|
|
+ Object.defineProperty(navigator, 'language', {
|
|
|
|
|
+ get: function navigatorLanguage() {
|
|
|
|
|
+ var language = navigator.userLanguage || 'en-US';
|
|
|
|
|
+ return language.substring(0, 2).toLowerCase() +
|
|
|
|
|
+ language.substring(2).toUpperCase();
|
|
|
|
|
+ },
|
|
|
|
|
+ enumerable: true
|
|
|
|
|
+ });
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
(function checkRangeRequests() {
|
|
(function checkRangeRequests() {
|
|
|
// Safari has issues with cached range requests see:
|
|
// Safari has issues with cached range requests see:
|
|
|
// https://github.com/mozilla/pdf.js/issues/3260
|
|
// https://github.com/mozilla/pdf.js/issues/3260
|
|
|
// Last tested with version 6.0.4.
|
|
// Last tested with version 6.0.4.
|
|
|
- // Support: Safari 6.0+
|
|
|
|
|
var isSafari = Object.prototype.toString.call(
|
|
var isSafari = Object.prototype.toString.call(
|
|
|
window.HTMLElement).indexOf('Constructor') > 0;
|
|
window.HTMLElement).indexOf('Constructor') > 0;
|
|
|
|
|
|
|
@@ -465,7 +467,6 @@ if (typeof PDFJS === 'undefined') {
|
|
|
// https://github.com/mozilla/pdf.js/issues/3381.
|
|
// https://github.com/mozilla/pdf.js/issues/3381.
|
|
|
// Make sure that we only match webkit-based Android browsers,
|
|
// Make sure that we only match webkit-based Android browsers,
|
|
|
// since Firefox/Fennec works as expected.
|
|
// since Firefox/Fennec works as expected.
|
|
|
- // Support: Android<3.0
|
|
|
|
|
var regex = /Android\s[0-2][^\d]/;
|
|
var regex = /Android\s[0-2][^\d]/;
|
|
|
var isOldAndroid = regex.test(navigator.userAgent);
|
|
var isOldAndroid = regex.test(navigator.userAgent);
|
|
|
|
|
|
|
@@ -475,89 +476,8 @@ if (typeof PDFJS === 'undefined') {
|
|
|
})();
|
|
})();
|
|
|
|
|
|
|
|
// Check if the browser supports manipulation of the history.
|
|
// Check if the browser supports manipulation of the history.
|
|
|
-// Support: IE<10, Android<4.2
|
|
|
|
|
(function checkHistoryManipulation() {
|
|
(function checkHistoryManipulation() {
|
|
|
- // Android 2.x has so buggy pushState support that it was removed in
|
|
|
|
|
- // Android 3.0 and restored as late as in Android 4.2.
|
|
|
|
|
- // Support: Android 2.x
|
|
|
|
|
- if (!history.pushState || navigator.userAgent.indexOf('Android 2.') >= 0) {
|
|
|
|
|
|
|
+ if (!window.history.pushState) {
|
|
|
PDFJS.disableHistory = true;
|
|
PDFJS.disableHistory = true;
|
|
|
}
|
|
}
|
|
|
})();
|
|
})();
|
|
|
-
|
|
|
|
|
-// 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) {
|
|
|
|
|
- if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
|
|
|
|
|
- window.CanvasPixelArray.prototype.set = function(arr) {
|
|
|
|
|
- for (var i = 0, ii = this.length; i < ii; i++) {
|
|
|
|
|
- this[i] = arr[i];
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- } 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, versionMatch;
|
|
|
|
|
- if (navigator.userAgent.indexOf('Chrom') >= 0) {
|
|
|
|
|
- versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
|
|
|
|
|
- // Chrome < 21 lacks the set function.
|
|
|
|
|
- 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.
|
|
|
|
|
- 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) {
|
|
|
|
|
- var contextPrototype = window.CanvasRenderingContext2D.prototype;
|
|
|
|
|
- contextPrototype._createImageData = contextPrototype.createImageData;
|
|
|
|
|
- contextPrototype.createImageData = function(w, h) {
|
|
|
|
|
- var imageData = this._createImageData(w, h);
|
|
|
|
|
- imageData.data.set = function(arr) {
|
|
|
|
|
- for (var i = 0, ii = this.length; i < ii; i++) {
|
|
|
|
|
- this[i] = arr[i];
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- return imageData;
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-})();
|
|
|
|
|
-
|
|
|
|
|
-// Support: IE<10, Android<4.0, iOS
|
|
|
|
|
-(function checkRequestAnimationFrame() {
|
|
|
|
|
- function fakeRequestAnimationFrame(callback) {
|
|
|
|
|
- window.setTimeout(callback, 20);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
|
|
|
|
|
- if (isIOS) {
|
|
|
|
|
- // requestAnimationFrame on iOS is broken, replacing with fake one.
|
|
|
|
|
- window.requestAnimationFrame = fakeRequestAnimationFrame;
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if ('requestAnimationFrame' in window) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- window.requestAnimationFrame =
|
|
|
|
|
- window.mozRequestAnimationFrame ||
|
|
|
|
|
- window.webkitRequestAnimationFrame ||
|
|
|
|
|
- fakeRequestAnimationFrame;
|
|
|
|
|
-})();
|
|
|
|
|
-
|
|
|
|
|
-(function checkCanvasSizeLimitation() {
|
|
|
|
|
- var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
|
|
|
|
|
- var isAndroid = /Android/g.test(navigator.userAgent);
|
|
|
|
|
- if (isIOS || isAndroid) {
|
|
|
|
|
- // 5MP
|
|
|
|
|
- PDFJS.maxCanvasPixels = 5242880;
|
|
|
|
|
- }
|
|
|
|
|
-})();
|
|
|