viewerjs-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +2 -0
- data/app/assets/AGPL-3.0.txt +661 -0
- data/app/assets/images/kogmbh.png +0 -0
- data/app/assets/images/nlnet.png +0 -0
- data/app/assets/images/texture.png +0 -0
- data/app/assets/images/toolbarButton-download.png +0 -0
- data/app/assets/images/toolbarButton-fullscreen.png +0 -0
- data/app/assets/images/toolbarButton-menuArrows.png +0 -0
- data/app/assets/images/toolbarButton-pageDown.png +0 -0
- data/app/assets/images/toolbarButton-pageUp.png +0 -0
- data/app/assets/images/toolbarButton-presentation.png +0 -0
- data/app/assets/images/toolbarButton-zoomIn.png +0 -0
- data/app/assets/images/toolbarButton-zoomOut.png +0 -0
- data/app/assets/javascripts/pdf.worker.js +39900 -0
- data/app/assets/javascripts/viewerjs/ODFViewerPlugin.js +219 -0
- data/app/assets/javascripts/viewerjs/PDFViewerPlugin.js.erb +348 -0
- data/app/assets/javascripts/viewerjs/PluginLoader.js +47 -0
- data/app/assets/javascripts/viewerjs/compatibility.js +491 -0
- data/app/assets/javascripts/viewerjs/pdf.js +7651 -0
- data/app/assets/javascripts/viewerjs/pdf_find_bar.js +175 -0
- data/app/assets/javascripts/viewerjs/pdf_find_controller.js +355 -0
- data/app/assets/javascripts/viewerjs/pdfjsversion.js +1 -0
- data/app/assets/javascripts/viewerjs/text_layer_builder.js +385 -0
- data/app/assets/javascripts/viewerjs/ui_utils.js +270 -0
- data/app/assets/javascripts/viewerjs/viewer.js +230 -0
- data/app/assets/javascripts/viewerjs/webodf.js +631 -0
- data/app/assets/javascripts/viewerjs_rails.js +22 -0
- data/app/assets/stylesheets/ODFViewerPlugin.css.scss +29 -0
- data/app/assets/stylesheets/PDFViewerPlugin.css.scss +36 -0
- data/app/assets/stylesheets/example.local.css.scss +27 -0
- data/app/assets/stylesheets/viewer.css.scss +816 -0
- data/app/assets/stylesheets/viewerjs_rails.css +15 -0
- data/lib/viewerjs/rails.rb +19 -0
- data/lib/viewerjs/rails/version.rb +5 -0
- data/lib/viewerjs/view_helpers.rb +75 -0
- data/viewerjs-rails.gemspec +23 -0
- metadata +113 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright (C) 2012 KO GmbH <copyright@kogmbh.com>
|
4
|
+
*
|
5
|
+
* @licstart
|
6
|
+
* The JavaScript code in this page is free software: you can redistribute it
|
7
|
+
* and/or modify it under the terms of the GNU Affero General Public License
|
8
|
+
* (GNU AGPL) as published by the Free Software Foundation, either version 3 of
|
9
|
+
* the License, or (at your option) any later version. The code is distributed
|
10
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
11
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details.
|
12
|
+
*
|
13
|
+
* You should have received a copy of the GNU Affero General Public License
|
14
|
+
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
*
|
16
|
+
* As additional permission under GNU AGPL version 3 section 7, you
|
17
|
+
* may distribute non-source (e.g., minimized or compacted) forms of
|
18
|
+
* that code without the copy of the GNU GPL normally required by
|
19
|
+
* section 4, provided you include this license notice and a URL
|
20
|
+
* through which recipients can access the Corresponding Source.
|
21
|
+
*
|
22
|
+
* As a special exception to the AGPL, any HTML file which merely makes function
|
23
|
+
* calls to this code, and for that purpose includes it by reference shall be
|
24
|
+
* deemed a separate work for copyright law purposes. In addition, the copyright
|
25
|
+
* holders of this code give you permission to combine this code with free
|
26
|
+
* software libraries that are released under the GNU LGPL. You may copy and
|
27
|
+
* distribute such a system following the terms of the GNU AGPL for this code
|
28
|
+
* and the LGPL for the libraries. If you modify this code, you may extend this
|
29
|
+
* exception to your version of the code, but you are not obligated to do so.
|
30
|
+
* If you do not wish to do so, delete this exception statement from your
|
31
|
+
* version.
|
32
|
+
*
|
33
|
+
* This license applies to this entire compilation.
|
34
|
+
* @licend
|
35
|
+
* @source: http://viewerjs.org/
|
36
|
+
* @source: http://github.com/kogmbh/ViewerJS
|
37
|
+
*/
|
38
|
+
|
39
|
+
/*global document, window, Viewer, ODFViewerPlugin, PDFViewerPlugin*/
|
40
|
+
|
41
|
+
var viewer;
|
42
|
+
function loadDocument(documentUrl) {
|
43
|
+
window.onload = function () {
|
44
|
+
console.log("Am i here!!!")
|
45
|
+
viewer = new Viewer(new PDFViewerPlugin());
|
46
|
+
};
|
47
|
+
}
|
@@ -0,0 +1,491 @@
|
|
1
|
+
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2
|
+
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
3
|
+
/* Copyright 2012 Mozilla Foundation
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
/* globals VBArray, PDFJS */
|
18
|
+
|
19
|
+
'use strict';
|
20
|
+
|
21
|
+
// Initializing PDFJS global object here, it case if we need to change/disable
|
22
|
+
// some PDF.js features, e.g. range requests
|
23
|
+
if (typeof PDFJS === 'undefined') {
|
24
|
+
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
25
|
+
}
|
26
|
+
|
27
|
+
// Checking if the typed arrays are supported
|
28
|
+
(function checkTypedArrayCompatibility() {
|
29
|
+
if (typeof Uint8Array !== 'undefined') {
|
30
|
+
// some mobile versions do not support subarray (e.g. safari 5 / iOS)
|
31
|
+
if (typeof Uint8Array.prototype.subarray === 'undefined') {
|
32
|
+
Uint8Array.prototype.subarray = function subarray(start, end) {
|
33
|
+
return new Uint8Array(this.slice(start, end));
|
34
|
+
};
|
35
|
+
Float32Array.prototype.subarray = function subarray(start, end) {
|
36
|
+
return new Float32Array(this.slice(start, end));
|
37
|
+
};
|
38
|
+
}
|
39
|
+
|
40
|
+
// some mobile version might not support Float64Array
|
41
|
+
if (typeof Float64Array === 'undefined')
|
42
|
+
window.Float64Array = Float32Array;
|
43
|
+
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
function subarray(start, end) {
|
48
|
+
return new TypedArray(this.slice(start, end));
|
49
|
+
}
|
50
|
+
|
51
|
+
function setArrayOffset(array, offset) {
|
52
|
+
if (arguments.length < 2)
|
53
|
+
offset = 0;
|
54
|
+
for (var i = 0, n = array.length; i < n; ++i, ++offset)
|
55
|
+
this[offset] = array[i] & 0xFF;
|
56
|
+
}
|
57
|
+
|
58
|
+
function TypedArray(arg1) {
|
59
|
+
var result;
|
60
|
+
if (typeof arg1 === 'number') {
|
61
|
+
result = [];
|
62
|
+
for (var i = 0; i < arg1; ++i)
|
63
|
+
result[i] = 0;
|
64
|
+
} else if ('slice' in arg1) {
|
65
|
+
result = arg1.slice(0);
|
66
|
+
} else {
|
67
|
+
result = [];
|
68
|
+
for (var i = 0, n = arg1.length; i < n; ++i) {
|
69
|
+
result[i] = arg1[i];
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
result.subarray = subarray;
|
74
|
+
result.buffer = result;
|
75
|
+
result.byteLength = result.length;
|
76
|
+
result.set = setArrayOffset;
|
77
|
+
|
78
|
+
if (typeof arg1 === 'object' && arg1.buffer)
|
79
|
+
result.buffer = arg1.buffer;
|
80
|
+
|
81
|
+
return result;
|
82
|
+
}
|
83
|
+
|
84
|
+
window.Uint8Array = TypedArray;
|
85
|
+
|
86
|
+
// we don't need support for set, byteLength for 32-bit array
|
87
|
+
// so we can use the TypedArray as well
|
88
|
+
window.Uint32Array = TypedArray;
|
89
|
+
window.Int32Array = TypedArray;
|
90
|
+
window.Uint16Array = TypedArray;
|
91
|
+
window.Float32Array = TypedArray;
|
92
|
+
window.Float64Array = TypedArray;
|
93
|
+
})();
|
94
|
+
|
95
|
+
// URL = URL || webkitURL
|
96
|
+
(function normalizeURLObject() {
|
97
|
+
if (!window.URL) {
|
98
|
+
window.URL = window.webkitURL;
|
99
|
+
}
|
100
|
+
})();
|
101
|
+
|
102
|
+
// Object.create() ?
|
103
|
+
(function checkObjectCreateCompatibility() {
|
104
|
+
if (typeof Object.create !== 'undefined')
|
105
|
+
return;
|
106
|
+
|
107
|
+
Object.create = function objectCreate(proto) {
|
108
|
+
function Constructor() {}
|
109
|
+
Constructor.prototype = proto;
|
110
|
+
return new Constructor();
|
111
|
+
};
|
112
|
+
})();
|
113
|
+
|
114
|
+
// Object.defineProperty() ?
|
115
|
+
(function checkObjectDefinePropertyCompatibility() {
|
116
|
+
if (typeof Object.defineProperty !== 'undefined') {
|
117
|
+
var definePropertyPossible = true;
|
118
|
+
try {
|
119
|
+
// some browsers (e.g. safari) cannot use defineProperty() on DOM objects
|
120
|
+
// and thus the native version is not sufficient
|
121
|
+
Object.defineProperty(new Image(), 'id', { value: 'test' });
|
122
|
+
// ... another test for android gb browser for non-DOM objects
|
123
|
+
var Test = function Test() {};
|
124
|
+
Test.prototype = { get id() { } };
|
125
|
+
Object.defineProperty(new Test(), 'id',
|
126
|
+
{ value: '', configurable: true, enumerable: true, writable: false });
|
127
|
+
} catch (e) {
|
128
|
+
definePropertyPossible = false;
|
129
|
+
}
|
130
|
+
if (definePropertyPossible) return;
|
131
|
+
}
|
132
|
+
|
133
|
+
Object.defineProperty = function objectDefineProperty(obj, name, def) {
|
134
|
+
delete obj[name];
|
135
|
+
if ('get' in def)
|
136
|
+
obj.__defineGetter__(name, def['get']);
|
137
|
+
if ('set' in def)
|
138
|
+
obj.__defineSetter__(name, def['set']);
|
139
|
+
if ('value' in def) {
|
140
|
+
obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
|
141
|
+
this.__defineGetter__(name, function objectDefinePropertyGetter() {
|
142
|
+
return value;
|
143
|
+
});
|
144
|
+
return value;
|
145
|
+
});
|
146
|
+
obj[name] = def.value;
|
147
|
+
}
|
148
|
+
};
|
149
|
+
})();
|
150
|
+
|
151
|
+
// Object.keys() ?
|
152
|
+
(function checkObjectKeysCompatibility() {
|
153
|
+
if (typeof Object.keys !== 'undefined')
|
154
|
+
return;
|
155
|
+
|
156
|
+
Object.keys = function objectKeys(obj) {
|
157
|
+
var result = [];
|
158
|
+
for (var i in obj) {
|
159
|
+
if (obj.hasOwnProperty(i))
|
160
|
+
result.push(i);
|
161
|
+
}
|
162
|
+
return result;
|
163
|
+
};
|
164
|
+
})();
|
165
|
+
|
166
|
+
// No readAsArrayBuffer ?
|
167
|
+
(function checkFileReaderReadAsArrayBuffer() {
|
168
|
+
if (typeof FileReader === 'undefined')
|
169
|
+
return; // FileReader is not implemented
|
170
|
+
var frPrototype = FileReader.prototype;
|
171
|
+
// Older versions of Firefox might not have readAsArrayBuffer
|
172
|
+
if ('readAsArrayBuffer' in frPrototype)
|
173
|
+
return; // readAsArrayBuffer is implemented
|
174
|
+
Object.defineProperty(frPrototype, 'readAsArrayBuffer', {
|
175
|
+
value: function fileReaderReadAsArrayBuffer(blob) {
|
176
|
+
var fileReader = new FileReader();
|
177
|
+
var originalReader = this;
|
178
|
+
fileReader.onload = function fileReaderOnload(evt) {
|
179
|
+
var data = evt.target.result;
|
180
|
+
var buffer = new ArrayBuffer(data.length);
|
181
|
+
var uint8Array = new Uint8Array(buffer);
|
182
|
+
|
183
|
+
for (var i = 0, ii = data.length; i < ii; i++)
|
184
|
+
uint8Array[i] = data.charCodeAt(i);
|
185
|
+
|
186
|
+
Object.defineProperty(originalReader, 'result', {
|
187
|
+
value: buffer,
|
188
|
+
enumerable: true,
|
189
|
+
writable: false,
|
190
|
+
configurable: true
|
191
|
+
});
|
192
|
+
|
193
|
+
var event = document.createEvent('HTMLEvents');
|
194
|
+
event.initEvent('load', false, false);
|
195
|
+
originalReader.dispatchEvent(event);
|
196
|
+
};
|
197
|
+
fileReader.readAsBinaryString(blob);
|
198
|
+
}
|
199
|
+
});
|
200
|
+
})();
|
201
|
+
|
202
|
+
// No XMLHttpRequest.response ?
|
203
|
+
(function checkXMLHttpRequestResponseCompatibility() {
|
204
|
+
var xhrPrototype = XMLHttpRequest.prototype;
|
205
|
+
if (!('overrideMimeType' in xhrPrototype)) {
|
206
|
+
// IE10 might have response, but not overrideMimeType
|
207
|
+
Object.defineProperty(xhrPrototype, 'overrideMimeType', {
|
208
|
+
value: function xmlHttpRequestOverrideMimeType(mimeType) {}
|
209
|
+
});
|
210
|
+
}
|
211
|
+
if ('response' in xhrPrototype ||
|
212
|
+
'mozResponseArrayBuffer' in xhrPrototype ||
|
213
|
+
'mozResponse' in xhrPrototype ||
|
214
|
+
'responseArrayBuffer' in xhrPrototype)
|
215
|
+
return;
|
216
|
+
// IE9 ?
|
217
|
+
if (typeof VBArray !== 'undefined') {
|
218
|
+
Object.defineProperty(xhrPrototype, 'response', {
|
219
|
+
get: function xmlHttpRequestResponseGet() {
|
220
|
+
return new Uint8Array(new VBArray(this.responseBody).toArray());
|
221
|
+
}
|
222
|
+
});
|
223
|
+
return;
|
224
|
+
}
|
225
|
+
|
226
|
+
// other browsers
|
227
|
+
function responseTypeSetter() {
|
228
|
+
// will be only called to set "arraybuffer"
|
229
|
+
this.overrideMimeType('text/plain; charset=x-user-defined');
|
230
|
+
}
|
231
|
+
if (typeof xhrPrototype.overrideMimeType === 'function') {
|
232
|
+
Object.defineProperty(xhrPrototype, 'responseType',
|
233
|
+
{ set: responseTypeSetter });
|
234
|
+
}
|
235
|
+
function responseGetter() {
|
236
|
+
var text = this.responseText;
|
237
|
+
var i, n = text.length;
|
238
|
+
var result = new Uint8Array(n);
|
239
|
+
for (i = 0; i < n; ++i)
|
240
|
+
result[i] = text.charCodeAt(i) & 0xFF;
|
241
|
+
return result;
|
242
|
+
}
|
243
|
+
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter });
|
244
|
+
})();
|
245
|
+
|
246
|
+
// window.btoa (base64 encode function) ?
|
247
|
+
(function checkWindowBtoaCompatibility() {
|
248
|
+
if ('btoa' in window)
|
249
|
+
return;
|
250
|
+
|
251
|
+
var digits =
|
252
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
253
|
+
|
254
|
+
window.btoa = function windowBtoa(chars) {
|
255
|
+
var buffer = '';
|
256
|
+
var i, n;
|
257
|
+
for (i = 0, n = chars.length; i < n; i += 3) {
|
258
|
+
var b1 = chars.charCodeAt(i) & 0xFF;
|
259
|
+
var b2 = chars.charCodeAt(i + 1) & 0xFF;
|
260
|
+
var b3 = chars.charCodeAt(i + 2) & 0xFF;
|
261
|
+
var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
|
262
|
+
var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
|
263
|
+
var d4 = i + 2 < n ? (b3 & 0x3F) : 64;
|
264
|
+
buffer += (digits.charAt(d1) + digits.charAt(d2) +
|
265
|
+
digits.charAt(d3) + digits.charAt(d4));
|
266
|
+
}
|
267
|
+
return buffer;
|
268
|
+
};
|
269
|
+
})();
|
270
|
+
|
271
|
+
// window.atob (base64 encode function) ?
|
272
|
+
(function checkWindowAtobCompatibility() {
|
273
|
+
if ('atob' in window)
|
274
|
+
return;
|
275
|
+
|
276
|
+
// https://github.com/davidchambers/Base64.js
|
277
|
+
var digits =
|
278
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
279
|
+
window.atob = function (input) {
|
280
|
+
input = input.replace(/=+$/, '');
|
281
|
+
if (input.length % 4 == 1) throw new Error('bad atob input');
|
282
|
+
for (
|
283
|
+
// initialize result and counters
|
284
|
+
var bc = 0, bs, buffer, idx = 0, output = '';
|
285
|
+
// get next character
|
286
|
+
buffer = input.charAt(idx++);
|
287
|
+
// character found in table?
|
288
|
+
// initialize bit storage and add its ascii value
|
289
|
+
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
290
|
+
// and if not first of each 4 characters,
|
291
|
+
// convert the first 8 bits to one ascii character
|
292
|
+
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
|
293
|
+
) {
|
294
|
+
// try to find character in table (0-63, not found => -1)
|
295
|
+
buffer = digits.indexOf(buffer);
|
296
|
+
}
|
297
|
+
return output;
|
298
|
+
};
|
299
|
+
})();
|
300
|
+
|
301
|
+
// Function.prototype.bind ?
|
302
|
+
(function checkFunctionPrototypeBindCompatibility() {
|
303
|
+
if (typeof Function.prototype.bind !== 'undefined')
|
304
|
+
return;
|
305
|
+
|
306
|
+
Function.prototype.bind = function functionPrototypeBind(obj) {
|
307
|
+
var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
|
308
|
+
var bound = function functionPrototypeBindBound() {
|
309
|
+
var args = Array.prototype.concat.apply(headArgs, arguments);
|
310
|
+
return fn.apply(obj, args);
|
311
|
+
};
|
312
|
+
return bound;
|
313
|
+
};
|
314
|
+
})();
|
315
|
+
|
316
|
+
// HTMLElement dataset property
|
317
|
+
(function checkDatasetProperty() {
|
318
|
+
var div = document.createElement('div');
|
319
|
+
if ('dataset' in div)
|
320
|
+
return; // dataset property exists
|
321
|
+
|
322
|
+
Object.defineProperty(HTMLElement.prototype, 'dataset', {
|
323
|
+
get: function() {
|
324
|
+
if (this._dataset)
|
325
|
+
return this._dataset;
|
326
|
+
|
327
|
+
var dataset = {};
|
328
|
+
for (var j = 0, jj = this.attributes.length; j < jj; j++) {
|
329
|
+
var attribute = this.attributes[j];
|
330
|
+
if (attribute.name.substring(0, 5) != 'data-')
|
331
|
+
continue;
|
332
|
+
var key = attribute.name.substring(5).replace(/\-([a-z])/g,
|
333
|
+
function(all, ch) { return ch.toUpperCase(); });
|
334
|
+
dataset[key] = attribute.value;
|
335
|
+
}
|
336
|
+
|
337
|
+
Object.defineProperty(this, '_dataset', {
|
338
|
+
value: dataset,
|
339
|
+
writable: false,
|
340
|
+
enumerable: false
|
341
|
+
});
|
342
|
+
return dataset;
|
343
|
+
},
|
344
|
+
enumerable: true
|
345
|
+
});
|
346
|
+
})();
|
347
|
+
|
348
|
+
// HTMLElement classList property
|
349
|
+
(function checkClassListProperty() {
|
350
|
+
var div = document.createElement('div');
|
351
|
+
if ('classList' in div)
|
352
|
+
return; // classList property exists
|
353
|
+
|
354
|
+
function changeList(element, itemName, add, remove) {
|
355
|
+
var s = element.className || '';
|
356
|
+
var list = s.split(/\s+/g);
|
357
|
+
if (list[0] === '') list.shift();
|
358
|
+
var index = list.indexOf(itemName);
|
359
|
+
if (index < 0 && add)
|
360
|
+
list.push(itemName);
|
361
|
+
if (index >= 0 && remove)
|
362
|
+
list.splice(index, 1);
|
363
|
+
element.className = list.join(' ');
|
364
|
+
return (index >= 0);
|
365
|
+
}
|
366
|
+
|
367
|
+
var classListPrototype = {
|
368
|
+
add: function(name) {
|
369
|
+
changeList(this.element, name, true, false);
|
370
|
+
},
|
371
|
+
contains: function(name) {
|
372
|
+
return changeList(this.element, name, false, false);
|
373
|
+
},
|
374
|
+
remove: function(name) {
|
375
|
+
changeList(this.element, name, false, true);
|
376
|
+
},
|
377
|
+
toggle: function(name) {
|
378
|
+
changeList(this.element, name, true, true);
|
379
|
+
}
|
380
|
+
};
|
381
|
+
|
382
|
+
Object.defineProperty(HTMLElement.prototype, 'classList', {
|
383
|
+
get: function() {
|
384
|
+
if (this._classList)
|
385
|
+
return this._classList;
|
386
|
+
|
387
|
+
var classList = Object.create(classListPrototype, {
|
388
|
+
element: {
|
389
|
+
value: this,
|
390
|
+
writable: false,
|
391
|
+
enumerable: true
|
392
|
+
}
|
393
|
+
});
|
394
|
+
Object.defineProperty(this, '_classList', {
|
395
|
+
value: classList,
|
396
|
+
writable: false,
|
397
|
+
enumerable: false
|
398
|
+
});
|
399
|
+
return classList;
|
400
|
+
},
|
401
|
+
enumerable: true
|
402
|
+
});
|
403
|
+
})();
|
404
|
+
|
405
|
+
// Check console compatibility
|
406
|
+
(function checkConsoleCompatibility() {
|
407
|
+
if (!('console' in window)) {
|
408
|
+
window.console = {
|
409
|
+
log: function() {},
|
410
|
+
error: function() {},
|
411
|
+
warn: function() {}
|
412
|
+
};
|
413
|
+
} else if (!('bind' in console.log)) {
|
414
|
+
// native functions in IE9 might not have bind
|
415
|
+
console.log = (function(fn) {
|
416
|
+
return function(msg) { return fn(msg); };
|
417
|
+
})(console.log);
|
418
|
+
console.error = (function(fn) {
|
419
|
+
return function(msg) { return fn(msg); };
|
420
|
+
})(console.error);
|
421
|
+
console.warn = (function(fn) {
|
422
|
+
return function(msg) { return fn(msg); };
|
423
|
+
})(console.warn);
|
424
|
+
}
|
425
|
+
})();
|
426
|
+
|
427
|
+
// Check onclick compatibility in Opera
|
428
|
+
(function checkOnClickCompatibility() {
|
429
|
+
// workaround for reported Opera bug DSK-354448:
|
430
|
+
// onclick fires on disabled buttons with opaque content
|
431
|
+
function ignoreIfTargetDisabled(event) {
|
432
|
+
if (isDisabled(event.target)) {
|
433
|
+
event.stopPropagation();
|
434
|
+
}
|
435
|
+
}
|
436
|
+
function isDisabled(node) {
|
437
|
+
return node.disabled || (node.parentNode && isDisabled(node.parentNode));
|
438
|
+
}
|
439
|
+
if (navigator.userAgent.indexOf('Opera') != -1) {
|
440
|
+
// use browser detection since we cannot feature-check this bug
|
441
|
+
document.addEventListener('click', ignoreIfTargetDisabled, true);
|
442
|
+
}
|
443
|
+
})();
|
444
|
+
|
445
|
+
// Checks if possible to use URL.createObjectURL()
|
446
|
+
(function checkOnBlobSupport() {
|
447
|
+
// sometimes IE loosing the data created with createObjectURL(), see #3977
|
448
|
+
if (navigator.userAgent.indexOf('Trident') >= 0) {
|
449
|
+
PDFJS.disableCreateObjectURL = true;
|
450
|
+
}
|
451
|
+
})();
|
452
|
+
|
453
|
+
// Checks if navigator.language is supported
|
454
|
+
(function checkNavigatorLanguage() {
|
455
|
+
if ('language' in navigator)
|
456
|
+
return;
|
457
|
+
Object.defineProperty(navigator, 'language', {
|
458
|
+
get: function navigatorLanguage() {
|
459
|
+
var language = navigator.userLanguage || 'en-US';
|
460
|
+
return language.substring(0, 2).toLowerCase() +
|
461
|
+
language.substring(2).toUpperCase();
|
462
|
+
},
|
463
|
+
enumerable: true
|
464
|
+
});
|
465
|
+
})();
|
466
|
+
|
467
|
+
(function checkRangeRequests() {
|
468
|
+
// Safari has issues with cached range requests see:
|
469
|
+
// https://github.com/mozilla/pdf.js/issues/3260
|
470
|
+
// Last tested with version 6.0.4.
|
471
|
+
var isSafari = Object.prototype.toString.call(
|
472
|
+
window.HTMLElement).indexOf('Constructor') > 0;
|
473
|
+
|
474
|
+
// Older versions of Android (pre 3.0) has issues with range requests, see:
|
475
|
+
// https://github.com/mozilla/pdf.js/issues/3381.
|
476
|
+
// Make sure that we only match webkit-based Android browsers,
|
477
|
+
// since Firefox/Fennec works as expected.
|
478
|
+
var regex = /Android\s[0-2][^\d]/;
|
479
|
+
var isOldAndroid = regex.test(navigator.userAgent);
|
480
|
+
|
481
|
+
if (isSafari || isOldAndroid) {
|
482
|
+
PDFJS.disableRange = true;
|
483
|
+
}
|
484
|
+
})();
|
485
|
+
|
486
|
+
// Check if the browser supports manipulation of the history.
|
487
|
+
(function checkHistoryManipulation() {
|
488
|
+
if (!window.history.pushState) {
|
489
|
+
PDFJS.disableHistory = true;
|
490
|
+
}
|
491
|
+
})();
|