1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | (function webpackUniversalModuleDefinition(root, factory) {
|
24 | if(typeof exports === 'object' && typeof module === 'object')
|
25 | module.exports = factory();
|
26 | else if(typeof define === 'function' && define.amd)
|
27 | define("pdfjs-dist/web/pdf_viewer", [], factory);
|
28 | else if(typeof exports === 'object')
|
29 | exports["pdfjs-dist/web/pdf_viewer"] = factory();
|
30 | else
|
31 | root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
|
32 | })(typeof self !== 'undefined' ? self : this, function() {
|
33 | return (function(modules) {
|
34 |
|
35 | var installedModules = {};
|
36 |
|
37 |
|
38 | function __w_pdfjs_require__(moduleId) {
|
39 |
|
40 |
|
41 | if(installedModules[moduleId]) {
|
42 | return installedModules[moduleId].exports;
|
43 | }
|
44 |
|
45 | var module = installedModules[moduleId] = {
|
46 | i: moduleId,
|
47 | l: false,
|
48 | exports: {}
|
49 | };
|
50 |
|
51 |
|
52 | modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
|
53 |
|
54 |
|
55 | module.l = true;
|
56 |
|
57 |
|
58 | return module.exports;
|
59 | }
|
60 |
|
61 |
|
62 |
|
63 | __w_pdfjs_require__.m = modules;
|
64 |
|
65 |
|
66 | __w_pdfjs_require__.c = installedModules;
|
67 |
|
68 |
|
69 | __w_pdfjs_require__.d = function(exports, name, getter) {
|
70 | if(!__w_pdfjs_require__.o(exports, name)) {
|
71 | Object.defineProperty(exports, name, {
|
72 | configurable: false,
|
73 | enumerable: true,
|
74 | get: getter
|
75 | /******/ });
|
76 | /******/ }
|
77 | /******/ };
|
78 | /******/
|
79 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
80 | /******/ __w_pdfjs_require__.n = function(module) {
|
81 | var getter = module && module.__esModule ?
|
82 | function getDefault() { return module['default']; } :
|
83 | function getModuleExports() { return module; };
|
84 | __w_pdfjs_require__.d(getter, 'a', getter);
|
85 | return getter;
|
86 | };
|
87 |
|
88 |
|
89 | __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
90 |
|
91 |
|
92 | __w_pdfjs_require__.p = "";
|
93 |
|
94 |
|
95 | return __w_pdfjs_require__(__w_pdfjs_require__.s = 9);
|
96 | })
|
97 |
|
98 | ([
|
99 |
|
100 | (function(module, exports, __w_pdfjs_require__) {
|
101 |
|
102 | "use strict";
|
103 |
|
104 |
|
105 | Object.defineProperty(exports, "__esModule", {
|
106 | value: true
|
107 | });
|
108 | exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isFileSchema = exports.isPortraitOrientation = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
|
109 |
|
110 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
111 |
|
112 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
113 |
|
114 | var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
115 |
|
116 | var _pdfjsLib = __w_pdfjs_require__(1);
|
117 |
|
118 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
119 |
|
120 | var CSS_UNITS = 96.0 / 72.0;
|
121 | var DEFAULT_SCALE_VALUE = 'auto';
|
122 | var DEFAULT_SCALE = 1.0;
|
123 | var MIN_SCALE = 0.10;
|
124 | var MAX_SCALE = 10.0;
|
125 | var UNKNOWN_SCALE = 0;
|
126 | var MAX_AUTO_SCALE = 1.25;
|
127 | var SCROLLBAR_PADDING = 40;
|
128 | var VERTICAL_PADDING = 5;
|
129 | var PresentationModeState = {
|
130 | UNKNOWN: 0,
|
131 | NORMAL: 1,
|
132 | CHANGING: 2,
|
133 | FULLSCREEN: 3
|
134 | };
|
135 | var RendererType = {
|
136 | CANVAS: 'canvas',
|
137 | SVG: 'svg'
|
138 | };
|
139 | var TextLayerMode = {
|
140 | DISABLE: 0,
|
141 | ENABLE: 1,
|
142 | ENABLE_ENHANCE: 2
|
143 | };
|
144 | function formatL10nValue(text, args) {
|
145 | if (!args) {
|
146 | return text;
|
147 | }
|
148 | return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
|
149 | return name in args ? args[name] : '{{' + name + '}}';
|
150 | });
|
151 | }
|
152 | var NullL10n = {
|
153 | getLanguage: function getLanguage() {
|
154 | return Promise.resolve('en-us');
|
155 | },
|
156 | getDirection: function getDirection() {
|
157 | return Promise.resolve('ltr');
|
158 | },
|
159 | get: function get(property, args, fallback) {
|
160 | return Promise.resolve(formatL10nValue(fallback, args));
|
161 | },
|
162 | translate: function translate(element) {
|
163 | return Promise.resolve();
|
164 | }
|
165 | };
|
166 | function getOutputScale(ctx) {
|
167 | var devicePixelRatio = window.devicePixelRatio || 1;
|
168 | var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
169 | var pixelRatio = devicePixelRatio / backingStoreRatio;
|
170 | return {
|
171 | sx: pixelRatio,
|
172 | sy: pixelRatio,
|
173 | scaled: pixelRatio !== 1
|
174 | };
|
175 | }
|
176 | function scrollIntoView(element, spot) {
|
177 | var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
178 |
|
179 | var parent = element.offsetParent;
|
180 | if (!parent) {
|
181 | console.error('offsetParent is not set -- cannot scroll');
|
182 | return;
|
183 | }
|
184 | var offsetY = element.offsetTop + element.clientTop;
|
185 | var offsetX = element.offsetLeft + element.clientLeft;
|
186 | while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
|
187 | if (parent.dataset._scaleY) {
|
188 | offsetY /= parent.dataset._scaleY;
|
189 | offsetX /= parent.dataset._scaleX;
|
190 | }
|
191 | offsetY += parent.offsetTop;
|
192 | offsetX += parent.offsetLeft;
|
193 | parent = parent.offsetParent;
|
194 | if (!parent) {
|
195 | return;
|
196 | }
|
197 | }
|
198 | if (spot) {
|
199 | if (spot.top !== undefined) {
|
200 | offsetY += spot.top;
|
201 | }
|
202 | if (spot.left !== undefined) {
|
203 | offsetX += spot.left;
|
204 | parent.scrollLeft = offsetX;
|
205 | }
|
206 | }
|
207 | parent.scrollTop = offsetY;
|
208 | }
|
209 | function watchScroll(viewAreaElement, callback) {
|
210 | var debounceScroll = function debounceScroll(evt) {
|
211 | if (rAF) {
|
212 | return;
|
213 | }
|
214 | rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
|
215 | rAF = null;
|
216 | var currentY = viewAreaElement.scrollTop;
|
217 | var lastY = state.lastY;
|
218 | if (currentY !== lastY) {
|
219 | state.down = currentY > lastY;
|
220 | }
|
221 | state.lastY = currentY;
|
222 | callback(state);
|
223 | });
|
224 | };
|
225 | var state = {
|
226 | down: true,
|
227 | lastY: viewAreaElement.scrollTop,
|
228 | _eventHandler: debounceScroll
|
229 | };
|
230 | var rAF = null;
|
231 | viewAreaElement.addEventListener('scroll', debounceScroll, true);
|
232 | return state;
|
233 | }
|
234 | function parseQueryString(query) {
|
235 | var parts = query.split('&');
|
236 | var params = Object.create(null);
|
237 | for (var i = 0, ii = parts.length; i < ii; ++i) {
|
238 | var param = parts[i].split('=');
|
239 | var key = param[0].toLowerCase();
|
240 | var value = param.length > 1 ? param[1] : null;
|
241 | params[decodeURIComponent(key)] = decodeURIComponent(value);
|
242 | }
|
243 | return params;
|
244 | }
|
245 | function binarySearchFirstItem(items, condition) {
|
246 | var minIndex = 0;
|
247 | var maxIndex = items.length - 1;
|
248 | if (items.length === 0 || !condition(items[maxIndex])) {
|
249 | return items.length;
|
250 | }
|
251 | if (condition(items[minIndex])) {
|
252 | return minIndex;
|
253 | }
|
254 | while (minIndex < maxIndex) {
|
255 | var currentIndex = minIndex + maxIndex >> 1;
|
256 | var currentItem = items[currentIndex];
|
257 | if (condition(currentItem)) {
|
258 | maxIndex = currentIndex;
|
259 | } else {
|
260 | minIndex = currentIndex + 1;
|
261 | }
|
262 | }
|
263 | return minIndex;
|
264 | }
|
265 | function approximateFraction(x) {
|
266 | if (Math.floor(x) === x) {
|
267 | return [x, 1];
|
268 | }
|
269 | var xinv = 1 / x;
|
270 | var limit = 8;
|
271 | if (xinv > limit) {
|
272 | return [1, limit];
|
273 | } else if (Math.floor(xinv) === xinv) {
|
274 | return [1, xinv];
|
275 | }
|
276 | var x_ = x > 1 ? xinv : x;
|
277 | var a = 0,
|
278 | b = 1,
|
279 | c = 1,
|
280 | d = 1;
|
281 | while (true) {
|
282 | var p = a + c,
|
283 | q = b + d;
|
284 | if (q > limit) {
|
285 | break;
|
286 | }
|
287 | if (x_ <= p / q) {
|
288 | c = p;
|
289 | d = q;
|
290 | } else {
|
291 | a = p;
|
292 | b = q;
|
293 | }
|
294 | }
|
295 | var result = void 0;
|
296 | if (x_ - a / b < c / d - x_) {
|
297 | result = x_ === x ? [a, b] : [b, a];
|
298 | } else {
|
299 | result = x_ === x ? [c, d] : [d, c];
|
300 | }
|
301 | return result;
|
302 | }
|
303 | function roundToDivide(x, div) {
|
304 | var r = x % div;
|
305 | return r === 0 ? x : Math.round(x - r + div);
|
306 | }
|
307 | function getPageSizeInches(_ref) {
|
308 | var view = _ref.view,
|
309 | userUnit = _ref.userUnit,
|
310 | rotate = _ref.rotate;
|
311 |
|
312 | var _view = _slicedToArray(view, 4),
|
313 | x1 = _view[0],
|
314 | y1 = _view[1],
|
315 | x2 = _view[2],
|
316 | y2 = _view[3];
|
317 |
|
318 | var changeOrientation = rotate % 180 !== 0;
|
319 | var width = (x2 - x1) / 72 * userUnit;
|
320 | var height = (y2 - y1) / 72 * userUnit;
|
321 | return {
|
322 | width: changeOrientation ? height : width,
|
323 | height: changeOrientation ? width : height
|
324 | };
|
325 | }
|
326 | function getVisibleElements(scrollEl, views) {
|
327 | var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
328 |
|
329 | var top = scrollEl.scrollTop,
|
330 | bottom = top + scrollEl.clientHeight;
|
331 | var left = scrollEl.scrollLeft,
|
332 | right = left + scrollEl.clientWidth;
|
333 | function isElementBottomBelowViewTop(view) {
|
334 | var element = view.div;
|
335 | var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
|
336 | return elementBottom > top;
|
337 | }
|
338 | var visible = [],
|
339 | view = void 0,
|
340 | element = void 0;
|
341 | var currentHeight = void 0,
|
342 | viewHeight = void 0,
|
343 | hiddenHeight = void 0,
|
344 | percentHeight = void 0;
|
345 | var currentWidth = void 0,
|
346 | viewWidth = void 0;
|
347 | var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
|
348 | for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
|
349 | view = views[i];
|
350 | element = view.div;
|
351 | currentHeight = element.offsetTop + element.clientTop;
|
352 | viewHeight = element.clientHeight;
|
353 | if (currentHeight > bottom) {
|
354 | break;
|
355 | }
|
356 | currentWidth = element.offsetLeft + element.clientLeft;
|
357 | viewWidth = element.clientWidth;
|
358 | if (currentWidth + viewWidth < left || currentWidth > right) {
|
359 | continue;
|
360 | }
|
361 | hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
|
362 | percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
|
363 | visible.push({
|
364 | id: view.id,
|
365 | x: currentWidth,
|
366 | y: currentHeight,
|
367 | view: view,
|
368 | percent: percentHeight
|
369 | });
|
370 | }
|
371 | var first = visible[0];
|
372 | var last = visible[visible.length - 1];
|
373 | if (sortByVisibility) {
|
374 | visible.sort(function (a, b) {
|
375 | var pc = a.percent - b.percent;
|
376 | if (Math.abs(pc) > 0.001) {
|
377 | return -pc;
|
378 | }
|
379 | return a.id - b.id;
|
380 | });
|
381 | }
|
382 | return {
|
383 | first: first,
|
384 | last: last,
|
385 | views: visible
|
386 | };
|
387 | }
|
388 | function noContextMenuHandler(evt) {
|
389 | evt.preventDefault();
|
390 | }
|
391 | function isFileSchema(url) {
|
392 | var i = 0,
|
393 | ii = url.length;
|
394 | while (i < ii && url[i].trim() === '') {
|
395 | i++;
|
396 | }
|
397 | return url.substr(i, 7).toLowerCase() === 'file://';
|
398 | }
|
399 | function isDataSchema(url) {
|
400 | var i = 0,
|
401 | ii = url.length;
|
402 | while (i < ii && url[i].trim() === '') {
|
403 | i++;
|
404 | }
|
405 | return url.substr(i, 5).toLowerCase() === 'data:';
|
406 | }
|
407 | function getPDFFileNameFromURL(url) {
|
408 | var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
|
409 |
|
410 | if (isDataSchema(url)) {
|
411 | console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
|
412 | return defaultFilename;
|
413 | }
|
414 | var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
415 | var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
416 | var splitURI = reURI.exec(url);
|
417 | var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
|
418 | if (suggestedFilename) {
|
419 | suggestedFilename = suggestedFilename[0];
|
420 | if (suggestedFilename.includes('%')) {
|
421 | try {
|
422 | suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
|
423 | } catch (ex) {}
|
424 | }
|
425 | }
|
426 | return suggestedFilename || defaultFilename;
|
427 | }
|
428 | function normalizeWheelEventDelta(evt) {
|
429 | var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
430 | var angle = Math.atan2(evt.deltaY, evt.deltaX);
|
431 | if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
|
432 | delta = -delta;
|
433 | }
|
434 | var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
|
435 | var MOUSE_DOM_DELTA_LINE_MODE = 1;
|
436 | var MOUSE_PIXELS_PER_LINE = 30;
|
437 | var MOUSE_LINES_PER_PAGE = 30;
|
438 | if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
|
439 | delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
|
440 | } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
|
441 | delta /= MOUSE_LINES_PER_PAGE;
|
442 | }
|
443 | return delta;
|
444 | }
|
445 | function isValidRotation(angle) {
|
446 | return Number.isInteger(angle) && angle % 90 === 0;
|
447 | }
|
448 | function isPortraitOrientation(size) {
|
449 | return size.width <= size.height;
|
450 | }
|
451 | function cloneObj(obj) {
|
452 | var result = Object.create(null);
|
453 | for (var i in obj) {
|
454 | if (Object.prototype.hasOwnProperty.call(obj, i)) {
|
455 | result[i] = obj[i];
|
456 | }
|
457 | }
|
458 | return result;
|
459 | }
|
460 | var WaitOnType = {
|
461 | EVENT: 'event',
|
462 | TIMEOUT: 'timeout'
|
463 | };
|
464 | function waitOnEventOrTimeout(_ref2) {
|
465 | var target = _ref2.target,
|
466 | name = _ref2.name,
|
467 | _ref2$delay = _ref2.delay,
|
468 | delay = _ref2$delay === undefined ? 0 : _ref2$delay;
|
469 |
|
470 | if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
|
471 | return Promise.reject(new Error('waitOnEventOrTimeout - invalid parameters.'));
|
472 | }
|
473 | var capability = (0, _pdfjsLib.createPromiseCapability)();
|
474 | function handler(type) {
|
475 | if (target instanceof EventBus) {
|
476 | target.off(name, eventHandler);
|
477 | } else {
|
478 | target.removeEventListener(name, eventHandler);
|
479 | }
|
480 | if (timeout) {
|
481 | clearTimeout(timeout);
|
482 | }
|
483 | capability.resolve(type);
|
484 | }
|
485 | var eventHandler = handler.bind(null, WaitOnType.EVENT);
|
486 | if (target instanceof EventBus) {
|
487 | target.on(name, eventHandler);
|
488 | } else {
|
489 | target.addEventListener(name, eventHandler);
|
490 | }
|
491 | var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
|
492 | var timeout = setTimeout(timeoutHandler, delay);
|
493 | return capability.promise;
|
494 | }
|
495 | var animationStarted = new Promise(function (resolve) {
|
496 | window.requestAnimationFrame(resolve);
|
497 | });
|
498 |
|
499 | var EventBus = function () {
|
500 | function EventBus() {
|
501 | _classCallCheck(this, EventBus);
|
502 |
|
503 | this._listeners = Object.create(null);
|
504 | }
|
505 |
|
506 | _createClass(EventBus, [{
|
507 | key: 'on',
|
508 | value: function on(eventName, listener) {
|
509 | var eventListeners = this._listeners[eventName];
|
510 | if (!eventListeners) {
|
511 | eventListeners = [];
|
512 | this._listeners[eventName] = eventListeners;
|
513 | }
|
514 | eventListeners.push(listener);
|
515 | }
|
516 | }, {
|
517 | key: 'off',
|
518 | value: function off(eventName, listener) {
|
519 | var eventListeners = this._listeners[eventName];
|
520 | var i = void 0;
|
521 | if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
|
522 | return;
|
523 | }
|
524 | eventListeners.splice(i, 1);
|
525 | }
|
526 | }, {
|
527 | key: 'dispatch',
|
528 | value: function dispatch(eventName) {
|
529 | var eventListeners = this._listeners[eventName];
|
530 | if (!eventListeners || eventListeners.length === 0) {
|
531 | return;
|
532 | }
|
533 | var args = Array.prototype.slice.call(arguments, 1);
|
534 | eventListeners.slice(0).forEach(function (listener) {
|
535 | listener.apply(null, args);
|
536 | });
|
537 | }
|
538 | }]);
|
539 |
|
540 | return EventBus;
|
541 | }();
|
542 |
|
543 | function clamp(v, min, max) {
|
544 | return Math.min(Math.max(v, min), max);
|
545 | }
|
546 |
|
547 | var ProgressBar = function () {
|
548 | function ProgressBar(id) {
|
549 | var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
550 | height = _ref3.height,
|
551 | width = _ref3.width,
|
552 | units = _ref3.units;
|
553 |
|
554 | _classCallCheck(this, ProgressBar);
|
555 |
|
556 | this.visible = true;
|
557 | this.div = document.querySelector(id + ' .progress');
|
558 | this.bar = this.div.parentNode;
|
559 | this.height = height || 100;
|
560 | this.width = width || 100;
|
561 | this.units = units || '%';
|
562 | this.div.style.height = this.height + this.units;
|
563 | this.percent = 0;
|
564 | }
|
565 |
|
566 | _createClass(ProgressBar, [{
|
567 | key: '_updateBar',
|
568 | value: function _updateBar() {
|
569 | if (this._indeterminate) {
|
570 | this.div.classList.add('indeterminate');
|
571 | this.div.style.width = this.width + this.units;
|
572 | return;
|
573 | }
|
574 | this.div.classList.remove('indeterminate');
|
575 | var progressSize = this.width * this._percent / 100;
|
576 | this.div.style.width = progressSize + this.units;
|
577 | }
|
578 | }, {
|
579 | key: 'setWidth',
|
580 | value: function setWidth(viewer) {
|
581 | if (!viewer) {
|
582 | return;
|
583 | }
|
584 | var container = viewer.parentNode;
|
585 | var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
586 | if (scrollbarWidth > 0) {
|
587 | this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
|
588 | }
|
589 | }
|
590 | }, {
|
591 | key: 'hide',
|
592 | value: function hide() {
|
593 | if (!this.visible) {
|
594 | return;
|
595 | }
|
596 | this.visible = false;
|
597 | this.bar.classList.add('hidden');
|
598 | document.body.classList.remove('loadingInProgress');
|
599 | }
|
600 | }, {
|
601 | key: 'show',
|
602 | value: function show() {
|
603 | if (this.visible) {
|
604 | return;
|
605 | }
|
606 | this.visible = true;
|
607 | document.body.classList.add('loadingInProgress');
|
608 | this.bar.classList.remove('hidden');
|
609 | }
|
610 | }, {
|
611 | key: 'percent',
|
612 | get: function get() {
|
613 | return this._percent;
|
614 | },
|
615 | set: function set(val) {
|
616 | this._indeterminate = isNaN(val);
|
617 | this._percent = clamp(val, 0, 100);
|
618 | this._updateBar();
|
619 | }
|
620 | }]);
|
621 |
|
622 | return ProgressBar;
|
623 | }();
|
624 |
|
625 | exports.CSS_UNITS = CSS_UNITS;
|
626 | exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
627 | exports.DEFAULT_SCALE = DEFAULT_SCALE;
|
628 | exports.MIN_SCALE = MIN_SCALE;
|
629 | exports.MAX_SCALE = MAX_SCALE;
|
630 | exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
|
631 | exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
|
632 | exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
633 | exports.VERTICAL_PADDING = VERTICAL_PADDING;
|
634 | exports.isValidRotation = isValidRotation;
|
635 | exports.isPortraitOrientation = isPortraitOrientation;
|
636 | exports.isFileSchema = isFileSchema;
|
637 | exports.cloneObj = cloneObj;
|
638 | exports.PresentationModeState = PresentationModeState;
|
639 | exports.RendererType = RendererType;
|
640 | exports.TextLayerMode = TextLayerMode;
|
641 | exports.NullL10n = NullL10n;
|
642 | exports.EventBus = EventBus;
|
643 | exports.ProgressBar = ProgressBar;
|
644 | exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
645 | exports.noContextMenuHandler = noContextMenuHandler;
|
646 | exports.parseQueryString = parseQueryString;
|
647 | exports.getVisibleElements = getVisibleElements;
|
648 | exports.roundToDivide = roundToDivide;
|
649 | exports.getPageSizeInches = getPageSizeInches;
|
650 | exports.approximateFraction = approximateFraction;
|
651 | exports.getOutputScale = getOutputScale;
|
652 | exports.scrollIntoView = scrollIntoView;
|
653 | exports.watchScroll = watchScroll;
|
654 | exports.binarySearchFirstItem = binarySearchFirstItem;
|
655 | exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
656 | exports.animationStarted = animationStarted;
|
657 | exports.WaitOnType = WaitOnType;
|
658 | exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
|
659 |
|
660 | }),
|
661 |
|
662 | (function(module, exports, __w_pdfjs_require__) {
|
663 |
|
664 | "use strict";
|
665 |
|
666 |
|
667 | var pdfjsLib = void 0;
|
668 | if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
|
669 | pdfjsLib = window['pdfjs-dist/build/pdf'];
|
670 | } else {
|
671 | pdfjsLib = require('../build/pdf.js');
|
672 | }
|
673 | module.exports = pdfjsLib;
|
674 |
|
675 | }),
|
676 |
|
677 | (function(module, exports, __w_pdfjs_require__) {
|
678 |
|
679 | "use strict";
|
680 |
|
681 |
|
682 | Object.defineProperty(exports, "__esModule", {
|
683 | value: true
|
684 | });
|
685 | exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
|
686 |
|
687 | var _ui_utils = __w_pdfjs_require__(0);
|
688 |
|
689 | function attachDOMEventsToEventBus(eventBus) {
|
690 | eventBus.on('documentload', function () {
|
691 | var event = document.createEvent('CustomEvent');
|
692 | event.initCustomEvent('documentload', true, true, {});
|
693 | window.dispatchEvent(event);
|
694 | });
|
695 | eventBus.on('pagerendered', function (evt) {
|
696 | var event = document.createEvent('CustomEvent');
|
697 | event.initCustomEvent('pagerendered', true, true, {
|
698 | pageNumber: evt.pageNumber,
|
699 | cssTransform: evt.cssTransform
|
700 | });
|
701 | evt.source.div.dispatchEvent(event);
|
702 | });
|
703 | eventBus.on('textlayerrendered', function (evt) {
|
704 | var event = document.createEvent('CustomEvent');
|
705 | event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
|
706 | evt.source.textLayerDiv.dispatchEvent(event);
|
707 | });
|
708 | eventBus.on('pagechange', function (evt) {
|
709 | var event = document.createEvent('UIEvents');
|
710 | event.initUIEvent('pagechange', true, true, window, 0);
|
711 | event.pageNumber = evt.pageNumber;
|
712 | evt.source.container.dispatchEvent(event);
|
713 | });
|
714 | eventBus.on('pagesinit', function (evt) {
|
715 | var event = document.createEvent('CustomEvent');
|
716 | event.initCustomEvent('pagesinit', true, true, null);
|
717 | evt.source.container.dispatchEvent(event);
|
718 | });
|
719 | eventBus.on('pagesloaded', function (evt) {
|
720 | var event = document.createEvent('CustomEvent');
|
721 | event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
|
722 | evt.source.container.dispatchEvent(event);
|
723 | });
|
724 | eventBus.on('scalechange', function (evt) {
|
725 | var event = document.createEvent('UIEvents');
|
726 | event.initUIEvent('scalechange', true, true, window, 0);
|
727 | event.scale = evt.scale;
|
728 | event.presetValue = evt.presetValue;
|
729 | evt.source.container.dispatchEvent(event);
|
730 | });
|
731 | eventBus.on('updateviewarea', function (evt) {
|
732 | var event = document.createEvent('UIEvents');
|
733 | event.initUIEvent('updateviewarea', true, true, window, 0);
|
734 | event.location = evt.location;
|
735 | evt.source.container.dispatchEvent(event);
|
736 | });
|
737 | eventBus.on('find', function (evt) {
|
738 | if (evt.source === window) {
|
739 | return;
|
740 | }
|
741 | var event = document.createEvent('CustomEvent');
|
742 | event.initCustomEvent('find' + evt.type, true, true, {
|
743 | query: evt.query,
|
744 | phraseSearch: evt.phraseSearch,
|
745 | caseSensitive: evt.caseSensitive,
|
746 | highlightAll: evt.highlightAll,
|
747 | findPrevious: evt.findPrevious
|
748 | });
|
749 | window.dispatchEvent(event);
|
750 | });
|
751 | eventBus.on('attachmentsloaded', function (evt) {
|
752 | var event = document.createEvent('CustomEvent');
|
753 | event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
|
754 | evt.source.container.dispatchEvent(event);
|
755 | });
|
756 | eventBus.on('sidebarviewchanged', function (evt) {
|
757 | var event = document.createEvent('CustomEvent');
|
758 | event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
|
759 | evt.source.outerContainer.dispatchEvent(event);
|
760 | });
|
761 | eventBus.on('pagemode', function (evt) {
|
762 | var event = document.createEvent('CustomEvent');
|
763 | event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
|
764 | evt.source.pdfViewer.container.dispatchEvent(event);
|
765 | });
|
766 | eventBus.on('namedaction', function (evt) {
|
767 | var event = document.createEvent('CustomEvent');
|
768 | event.initCustomEvent('namedaction', true, true, { action: evt.action });
|
769 | evt.source.pdfViewer.container.dispatchEvent(event);
|
770 | });
|
771 | eventBus.on('presentationmodechanged', function (evt) {
|
772 | var event = document.createEvent('CustomEvent');
|
773 | event.initCustomEvent('presentationmodechanged', true, true, {
|
774 | active: evt.active,
|
775 | switchInProgress: evt.switchInProgress
|
776 | });
|
777 | window.dispatchEvent(event);
|
778 | });
|
779 | eventBus.on('outlineloaded', function (evt) {
|
780 | var event = document.createEvent('CustomEvent');
|
781 | event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
|
782 | evt.source.container.dispatchEvent(event);
|
783 | });
|
784 | }
|
785 | var globalEventBus = null;
|
786 | function getGlobalEventBus() {
|
787 | if (globalEventBus) {
|
788 | return globalEventBus;
|
789 | }
|
790 | globalEventBus = new _ui_utils.EventBus();
|
791 | attachDOMEventsToEventBus(globalEventBus);
|
792 | return globalEventBus;
|
793 | }
|
794 | exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
|
795 | exports.getGlobalEventBus = getGlobalEventBus;
|
796 |
|
797 | }),
|
798 |
|
799 | (function(module, exports, __w_pdfjs_require__) {
|
800 |
|
801 | "use strict";
|
802 |
|
803 |
|
804 | Object.defineProperty(exports, "__esModule", {
|
805 | value: true
|
806 | });
|
807 | exports.SimpleLinkService = exports.PDFLinkService = undefined;
|
808 |
|
809 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
810 |
|
811 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
812 |
|
813 | var _dom_events = __w_pdfjs_require__(2);
|
814 |
|
815 | var _ui_utils = __w_pdfjs_require__(0);
|
816 |
|
817 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
818 |
|
819 | var PDFLinkService = function () {
|
820 | function PDFLinkService() {
|
821 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
822 | eventBus = _ref.eventBus,
|
823 | _ref$externalLinkTarg = _ref.externalLinkTarget,
|
824 | externalLinkTarget = _ref$externalLinkTarg === undefined ? null : _ref$externalLinkTarg,
|
825 | _ref$externalLinkRel = _ref.externalLinkRel,
|
826 | externalLinkRel = _ref$externalLinkRel === undefined ? null : _ref$externalLinkRel;
|
827 |
|
828 | _classCallCheck(this, PDFLinkService);
|
829 |
|
830 | this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
|
831 | this.externalLinkTarget = externalLinkTarget;
|
832 | this.externalLinkRel = externalLinkRel;
|
833 | this.baseUrl = null;
|
834 | this.pdfDocument = null;
|
835 | this.pdfViewer = null;
|
836 | this.pdfHistory = null;
|
837 | this._pagesRefCache = null;
|
838 | }
|
839 |
|
840 | _createClass(PDFLinkService, [{
|
841 | key: 'setDocument',
|
842 | value: function setDocument(pdfDocument, baseUrl) {
|
843 | this.baseUrl = baseUrl;
|
844 | this.pdfDocument = pdfDocument;
|
845 | this._pagesRefCache = Object.create(null);
|
846 | }
|
847 | }, {
|
848 | key: 'setViewer',
|
849 | value: function setViewer(pdfViewer) {
|
850 | this.pdfViewer = pdfViewer;
|
851 | }
|
852 | }, {
|
853 | key: 'setHistory',
|
854 | value: function setHistory(pdfHistory) {
|
855 | this.pdfHistory = pdfHistory;
|
856 | }
|
857 | }, {
|
858 | key: 'navigateTo',
|
859 | value: function navigateTo(dest) {
|
860 | var _this = this;
|
861 |
|
862 | var goToDestination = function goToDestination(_ref2) {
|
863 | var namedDest = _ref2.namedDest,
|
864 | explicitDest = _ref2.explicitDest;
|
865 |
|
866 | var destRef = explicitDest[0],
|
867 | pageNumber = void 0;
|
868 | if (destRef instanceof Object) {
|
869 | pageNumber = _this._cachedPageNumber(destRef);
|
870 | if (pageNumber === null) {
|
871 | _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
|
872 | _this.cachePageRef(pageIndex + 1, destRef);
|
873 | goToDestination({
|
874 | namedDest: namedDest,
|
875 | explicitDest: explicitDest
|
876 | });
|
877 | }).catch(function () {
|
878 | console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
|
879 | });
|
880 | return;
|
881 | }
|
882 | } else if (Number.isInteger(destRef)) {
|
883 | pageNumber = destRef + 1;
|
884 | } else {
|
885 | console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
|
886 | return;
|
887 | }
|
888 | if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
|
889 | console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
|
890 | return;
|
891 | }
|
892 | if (_this.pdfHistory) {
|
893 | _this.pdfHistory.pushCurrentPosition();
|
894 | _this.pdfHistory.push({
|
895 | namedDest: namedDest,
|
896 | explicitDest: explicitDest,
|
897 | pageNumber: pageNumber
|
898 | });
|
899 | }
|
900 | _this.pdfViewer.scrollPageIntoView({
|
901 | pageNumber: pageNumber,
|
902 | destArray: explicitDest
|
903 | });
|
904 | };
|
905 | new Promise(function (resolve, reject) {
|
906 | if (typeof dest === 'string') {
|
907 | _this.pdfDocument.getDestination(dest).then(function (destArray) {
|
908 | resolve({
|
909 | namedDest: dest,
|
910 | explicitDest: destArray
|
911 | });
|
912 | });
|
913 | return;
|
914 | }
|
915 | resolve({
|
916 | namedDest: '',
|
917 | explicitDest: dest
|
918 | });
|
919 | }).then(function (data) {
|
920 | if (!(data.explicitDest instanceof Array)) {
|
921 | console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
|
922 | return;
|
923 | }
|
924 | goToDestination(data);
|
925 | });
|
926 | }
|
927 | }, {
|
928 | key: 'getDestinationHash',
|
929 | value: function getDestinationHash(dest) {
|
930 | if (typeof dest === 'string') {
|
931 | return this.getAnchorUrl('#' + escape(dest));
|
932 | }
|
933 | if (dest instanceof Array) {
|
934 | var str = JSON.stringify(dest);
|
935 | return this.getAnchorUrl('#' + escape(str));
|
936 | }
|
937 | return this.getAnchorUrl('');
|
938 | }
|
939 | }, {
|
940 | key: 'getAnchorUrl',
|
941 | value: function getAnchorUrl(anchor) {
|
942 | return (this.baseUrl || '') + anchor;
|
943 | }
|
944 | }, {
|
945 | key: 'setHash',
|
946 | value: function setHash(hash) {
|
947 | var pageNumber = void 0,
|
948 | dest = void 0;
|
949 | if (hash.includes('=')) {
|
950 | var params = (0, _ui_utils.parseQueryString)(hash);
|
951 | if ('search' in params) {
|
952 | this.eventBus.dispatch('findfromurlhash', {
|
953 | source: this,
|
954 | query: params['search'].replace(/"/g, ''),
|
955 | phraseSearch: params['phrase'] === 'true'
|
956 | });
|
957 | }
|
958 | if ('nameddest' in params) {
|
959 | this.navigateTo(params.nameddest);
|
960 | return;
|
961 | }
|
962 | if ('page' in params) {
|
963 | pageNumber = params.page | 0 || 1;
|
964 | }
|
965 | if ('zoom' in params) {
|
966 | var zoomArgs = params.zoom.split(',');
|
967 | var zoomArg = zoomArgs[0];
|
968 | var zoomArgNumber = parseFloat(zoomArg);
|
969 | if (!zoomArg.includes('Fit')) {
|
970 | dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
|
971 | } else {
|
972 | if (zoomArg === 'Fit' || zoomArg === 'FitB') {
|
973 | dest = [null, { name: zoomArg }];
|
974 | } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
|
975 | dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
|
976 | } else if (zoomArg === 'FitR') {
|
977 | if (zoomArgs.length !== 5) {
|
978 | console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
|
979 | } else {
|
980 | dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
|
981 | }
|
982 | } else {
|
983 | console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
|
984 | }
|
985 | }
|
986 | }
|
987 | if (dest) {
|
988 | this.pdfViewer.scrollPageIntoView({
|
989 | pageNumber: pageNumber || this.page,
|
990 | destArray: dest,
|
991 | allowNegativeOffset: true
|
992 | });
|
993 | } else if (pageNumber) {
|
994 | this.page = pageNumber;
|
995 | }
|
996 | if ('pagemode' in params) {
|
997 | this.eventBus.dispatch('pagemode', {
|
998 | source: this,
|
999 | mode: params.pagemode
|
1000 | });
|
1001 | }
|
1002 | } else {
|
1003 | dest = unescape(hash);
|
1004 | try {
|
1005 | dest = JSON.parse(dest);
|
1006 | if (!(dest instanceof Array)) {
|
1007 | dest = dest.toString();
|
1008 | }
|
1009 | } catch (ex) {}
|
1010 | if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
|
1011 | this.navigateTo(dest);
|
1012 | return;
|
1013 | }
|
1014 | console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
|
1015 | }
|
1016 | }
|
1017 | }, {
|
1018 | key: 'executeNamedAction',
|
1019 | value: function executeNamedAction(action) {
|
1020 | switch (action) {
|
1021 | case 'GoBack':
|
1022 | if (this.pdfHistory) {
|
1023 | this.pdfHistory.back();
|
1024 | }
|
1025 | break;
|
1026 | case 'GoForward':
|
1027 | if (this.pdfHistory) {
|
1028 | this.pdfHistory.forward();
|
1029 | }
|
1030 | break;
|
1031 | case 'NextPage':
|
1032 | if (this.page < this.pagesCount) {
|
1033 | this.page++;
|
1034 | }
|
1035 | break;
|
1036 | case 'PrevPage':
|
1037 | if (this.page > 1) {
|
1038 | this.page--;
|
1039 | }
|
1040 | break;
|
1041 | case 'LastPage':
|
1042 | this.page = this.pagesCount;
|
1043 | break;
|
1044 | case 'FirstPage':
|
1045 | this.page = 1;
|
1046 | break;
|
1047 | default:
|
1048 | break;
|
1049 | }
|
1050 | this.eventBus.dispatch('namedaction', {
|
1051 | source: this,
|
1052 | action: action
|
1053 | });
|
1054 | }
|
1055 | }, {
|
1056 | key: 'onFileAttachmentAnnotation',
|
1057 | value: function onFileAttachmentAnnotation(_ref3) {
|
1058 | var id = _ref3.id,
|
1059 | filename = _ref3.filename,
|
1060 | content = _ref3.content;
|
1061 |
|
1062 | this.eventBus.dispatch('fileattachmentannotation', {
|
1063 | source: this,
|
1064 | id: id,
|
1065 | filename: filename,
|
1066 | content: content
|
1067 | });
|
1068 | }
|
1069 | }, {
|
1070 | key: 'cachePageRef',
|
1071 | value: function cachePageRef(pageNum, pageRef) {
|
1072 | if (!pageRef) {
|
1073 | return;
|
1074 | }
|
1075 | var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
|
1076 | this._pagesRefCache[refStr] = pageNum;
|
1077 | }
|
1078 | }, {
|
1079 | key: '_cachedPageNumber',
|
1080 | value: function _cachedPageNumber(pageRef) {
|
1081 | var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
|
1082 | return this._pagesRefCache && this._pagesRefCache[refStr] || null;
|
1083 | }
|
1084 | }, {
|
1085 | key: 'pagesCount',
|
1086 | get: function get() {
|
1087 | return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
1088 | }
|
1089 | }, {
|
1090 | key: 'page',
|
1091 | get: function get() {
|
1092 | return this.pdfViewer.currentPageNumber;
|
1093 | },
|
1094 | set: function set(value) {
|
1095 | this.pdfViewer.currentPageNumber = value;
|
1096 | }
|
1097 | }, {
|
1098 | key: 'rotation',
|
1099 | get: function get() {
|
1100 | return this.pdfViewer.pagesRotation;
|
1101 | },
|
1102 | set: function set(value) {
|
1103 | this.pdfViewer.pagesRotation = value;
|
1104 | }
|
1105 | }]);
|
1106 |
|
1107 | return PDFLinkService;
|
1108 | }();
|
1109 |
|
1110 | function isValidExplicitDestination(dest) {
|
1111 | if (!(dest instanceof Array)) {
|
1112 | return false;
|
1113 | }
|
1114 | var destLength = dest.length,
|
1115 | allowNull = true;
|
1116 | if (destLength < 2) {
|
1117 | return false;
|
1118 | }
|
1119 | var page = dest[0];
|
1120 | if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
|
1121 | return false;
|
1122 | }
|
1123 | var zoom = dest[1];
|
1124 | if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
|
1125 | return false;
|
1126 | }
|
1127 | switch (zoom.name) {
|
1128 | case 'XYZ':
|
1129 | if (destLength !== 5) {
|
1130 | return false;
|
1131 | }
|
1132 | break;
|
1133 | case 'Fit':
|
1134 | case 'FitB':
|
1135 | return destLength === 2;
|
1136 | case 'FitH':
|
1137 | case 'FitBH':
|
1138 | case 'FitV':
|
1139 | case 'FitBV':
|
1140 | if (destLength !== 3) {
|
1141 | return false;
|
1142 | }
|
1143 | break;
|
1144 | case 'FitR':
|
1145 | if (destLength !== 6) {
|
1146 | return false;
|
1147 | }
|
1148 | allowNull = false;
|
1149 | break;
|
1150 | default:
|
1151 | return false;
|
1152 | }
|
1153 | for (var i = 2; i < destLength; i++) {
|
1154 | var param = dest[i];
|
1155 | if (!(typeof param === 'number' || allowNull && param === null)) {
|
1156 | return false;
|
1157 | }
|
1158 | }
|
1159 | return true;
|
1160 | }
|
1161 |
|
1162 | var SimpleLinkService = function () {
|
1163 | function SimpleLinkService() {
|
1164 | _classCallCheck(this, SimpleLinkService);
|
1165 |
|
1166 | this.externalLinkTarget = null;
|
1167 | this.externalLinkRel = null;
|
1168 | }
|
1169 |
|
1170 | _createClass(SimpleLinkService, [{
|
1171 | key: 'navigateTo',
|
1172 | value: function navigateTo(dest) {}
|
1173 | }, {
|
1174 | key: 'getDestinationHash',
|
1175 | value: function getDestinationHash(dest) {
|
1176 | return '#';
|
1177 | }
|
1178 | }, {
|
1179 | key: 'getAnchorUrl',
|
1180 | value: function getAnchorUrl(hash) {
|
1181 | return '#';
|
1182 | }
|
1183 | }, {
|
1184 | key: 'setHash',
|
1185 | value: function setHash(hash) {}
|
1186 | }, {
|
1187 | key: 'executeNamedAction',
|
1188 | value: function executeNamedAction(action) {}
|
1189 | }, {
|
1190 | key: 'onFileAttachmentAnnotation',
|
1191 | value: function onFileAttachmentAnnotation(_ref4) {
|
1192 | var id = _ref4.id,
|
1193 | filename = _ref4.filename,
|
1194 | content = _ref4.content;
|
1195 | }
|
1196 | }, {
|
1197 | key: 'cachePageRef',
|
1198 | value: function cachePageRef(pageNum, pageRef) {}
|
1199 | }, {
|
1200 | key: 'page',
|
1201 | get: function get() {
|
1202 | return 0;
|
1203 | },
|
1204 | set: function set(value) {}
|
1205 | }, {
|
1206 | key: 'rotation',
|
1207 | get: function get() {
|
1208 | return 0;
|
1209 | },
|
1210 | set: function set(value) {}
|
1211 | }]);
|
1212 |
|
1213 | return SimpleLinkService;
|
1214 | }();
|
1215 |
|
1216 | exports.PDFLinkService = PDFLinkService;
|
1217 | exports.SimpleLinkService = SimpleLinkService;
|
1218 |
|
1219 | }),
|
1220 |
|
1221 | (function(module, exports, __w_pdfjs_require__) {
|
1222 |
|
1223 | "use strict";
|
1224 |
|
1225 |
|
1226 | Object.defineProperty(exports, "__esModule", {
|
1227 | value: true
|
1228 | });
|
1229 | exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
|
1230 |
|
1231 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
1232 |
|
1233 | var _pdfjsLib = __w_pdfjs_require__(1);
|
1234 |
|
1235 | var _ui_utils = __w_pdfjs_require__(0);
|
1236 |
|
1237 | var _pdf_link_service = __w_pdfjs_require__(3);
|
1238 |
|
1239 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1240 |
|
1241 | var AnnotationLayerBuilder = function () {
|
1242 | function AnnotationLayerBuilder(_ref) {
|
1243 | var pageDiv = _ref.pageDiv,
|
1244 | pdfPage = _ref.pdfPage,
|
1245 | linkService = _ref.linkService,
|
1246 | downloadManager = _ref.downloadManager,
|
1247 | _ref$imageResourcesPa = _ref.imageResourcesPath,
|
1248 | imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa,
|
1249 | _ref$renderInteractiv = _ref.renderInteractiveForms,
|
1250 | renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
|
1251 | _ref$l10n = _ref.l10n,
|
1252 | l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
|
1253 |
|
1254 | _classCallCheck(this, AnnotationLayerBuilder);
|
1255 |
|
1256 | this.pageDiv = pageDiv;
|
1257 | this.pdfPage = pdfPage;
|
1258 | this.linkService = linkService;
|
1259 | this.downloadManager = downloadManager;
|
1260 | this.imageResourcesPath = imageResourcesPath;
|
1261 | this.renderInteractiveForms = renderInteractiveForms;
|
1262 | this.l10n = l10n;
|
1263 | this.div = null;
|
1264 | this._cancelled = false;
|
1265 | }
|
1266 |
|
1267 | _createClass(AnnotationLayerBuilder, [{
|
1268 | key: 'render',
|
1269 | value: function render(viewport) {
|
1270 | var _this = this;
|
1271 |
|
1272 | var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
|
1273 |
|
1274 | this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
|
1275 | if (_this._cancelled) {
|
1276 | return;
|
1277 | }
|
1278 | var parameters = {
|
1279 | viewport: viewport.clone({ dontFlip: true }),
|
1280 | div: _this.div,
|
1281 | annotations: annotations,
|
1282 | page: _this.pdfPage,
|
1283 | imageResourcesPath: _this.imageResourcesPath,
|
1284 | renderInteractiveForms: _this.renderInteractiveForms,
|
1285 | linkService: _this.linkService,
|
1286 | downloadManager: _this.downloadManager
|
1287 | };
|
1288 | if (_this.div) {
|
1289 | _pdfjsLib.AnnotationLayer.update(parameters);
|
1290 | } else {
|
1291 | if (annotations.length === 0) {
|
1292 | return;
|
1293 | }
|
1294 | _this.div = document.createElement('div');
|
1295 | _this.div.className = 'annotationLayer';
|
1296 | _this.pageDiv.appendChild(_this.div);
|
1297 | parameters.div = _this.div;
|
1298 | _pdfjsLib.AnnotationLayer.render(parameters);
|
1299 | _this.l10n.translate(_this.div);
|
1300 | }
|
1301 | });
|
1302 | }
|
1303 | }, {
|
1304 | key: 'cancel',
|
1305 | value: function cancel() {
|
1306 | this._cancelled = true;
|
1307 | }
|
1308 | }, {
|
1309 | key: 'hide',
|
1310 | value: function hide() {
|
1311 | if (!this.div) {
|
1312 | return;
|
1313 | }
|
1314 | this.div.setAttribute('hidden', 'true');
|
1315 | }
|
1316 | }]);
|
1317 |
|
1318 | return AnnotationLayerBuilder;
|
1319 | }();
|
1320 |
|
1321 | var DefaultAnnotationLayerFactory = function () {
|
1322 | function DefaultAnnotationLayerFactory() {
|
1323 | _classCallCheck(this, DefaultAnnotationLayerFactory);
|
1324 | }
|
1325 |
|
1326 | _createClass(DefaultAnnotationLayerFactory, [{
|
1327 | key: 'createAnnotationLayerBuilder',
|
1328 | value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
|
1329 | var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
1330 | var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
1331 | var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
|
1332 |
|
1333 | return new AnnotationLayerBuilder({
|
1334 | pageDiv: pageDiv,
|
1335 | pdfPage: pdfPage,
|
1336 | imageResourcesPath: imageResourcesPath,
|
1337 | renderInteractiveForms: renderInteractiveForms,
|
1338 | linkService: new _pdf_link_service.SimpleLinkService(),
|
1339 | l10n: l10n
|
1340 | });
|
1341 | }
|
1342 | }]);
|
1343 |
|
1344 | return DefaultAnnotationLayerFactory;
|
1345 | }();
|
1346 |
|
1347 | exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
|
1348 | exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
|
1349 |
|
1350 | }),
|
1351 |
|
1352 | (function(module, exports, __w_pdfjs_require__) {
|
1353 |
|
1354 | "use strict";
|
1355 |
|
1356 |
|
1357 | Object.defineProperty(exports, "__esModule", {
|
1358 | value: true
|
1359 | });
|
1360 | exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
|
1361 |
|
1362 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
1363 |
|
1364 | var _dom_events = __w_pdfjs_require__(2);
|
1365 |
|
1366 | var _pdfjsLib = __w_pdfjs_require__(1);
|
1367 |
|
1368 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1369 |
|
1370 | var EXPAND_DIVS_TIMEOUT = 300;
|
1371 |
|
1372 | var TextLayerBuilder = function () {
|
1373 | function TextLayerBuilder(_ref) {
|
1374 | var textLayerDiv = _ref.textLayerDiv,
|
1375 | eventBus = _ref.eventBus,
|
1376 | pageIndex = _ref.pageIndex,
|
1377 | viewport = _ref.viewport,
|
1378 | _ref$findController = _ref.findController,
|
1379 | findController = _ref$findController === undefined ? null : _ref$findController,
|
1380 | _ref$enhanceTextSelec = _ref.enhanceTextSelection,
|
1381 | enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
|
1382 |
|
1383 | _classCallCheck(this, TextLayerBuilder);
|
1384 |
|
1385 | this.textLayerDiv = textLayerDiv;
|
1386 | this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
|
1387 | this.textContent = null;
|
1388 | this.textContentItemsStr = [];
|
1389 | this.textContentStream = null;
|
1390 | this.renderingDone = false;
|
1391 | this.pageIdx = pageIndex;
|
1392 | this.pageNumber = this.pageIdx + 1;
|
1393 | this.matches = [];
|
1394 | this.viewport = viewport;
|
1395 | this.textDivs = [];
|
1396 | this.findController = findController;
|
1397 | this.textLayerRenderTask = null;
|
1398 | this.enhanceTextSelection = enhanceTextSelection;
|
1399 | this._bindMouse();
|
1400 | }
|
1401 |
|
1402 | _createClass(TextLayerBuilder, [{
|
1403 | key: '_finishRendering',
|
1404 | value: function _finishRendering() {
|
1405 | this.renderingDone = true;
|
1406 | if (!this.enhanceTextSelection) {
|
1407 | var endOfContent = document.createElement('div');
|
1408 | endOfContent.className = 'endOfContent';
|
1409 | this.textLayerDiv.appendChild(endOfContent);
|
1410 | }
|
1411 | this.eventBus.dispatch('textlayerrendered', {
|
1412 | source: this,
|
1413 | pageNumber: this.pageNumber,
|
1414 | numTextDivs: this.textDivs.length
|
1415 | });
|
1416 | }
|
1417 | }, {
|
1418 | key: 'render',
|
1419 | value: function render() {
|
1420 | var _this = this;
|
1421 |
|
1422 | var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
1423 |
|
1424 | if (!(this.textContent || this.textContentStream) || this.renderingDone) {
|
1425 | return;
|
1426 | }
|
1427 | this.cancel();
|
1428 | this.textDivs = [];
|
1429 | var textLayerFrag = document.createDocumentFragment();
|
1430 | this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
|
1431 | textContent: this.textContent,
|
1432 | textContentStream: this.textContentStream,
|
1433 | container: textLayerFrag,
|
1434 | viewport: this.viewport,
|
1435 | textDivs: this.textDivs,
|
1436 | textContentItemsStr: this.textContentItemsStr,
|
1437 | timeout: timeout,
|
1438 | enhanceTextSelection: this.enhanceTextSelection
|
1439 | });
|
1440 | this.textLayerRenderTask.promise.then(function () {
|
1441 | _this.textLayerDiv.appendChild(textLayerFrag);
|
1442 | _this._finishRendering();
|
1443 | _this.updateMatches();
|
1444 | }, function (reason) {});
|
1445 | }
|
1446 | }, {
|
1447 | key: 'cancel',
|
1448 | value: function cancel() {
|
1449 | if (this.textLayerRenderTask) {
|
1450 | this.textLayerRenderTask.cancel();
|
1451 | this.textLayerRenderTask = null;
|
1452 | }
|
1453 | }
|
1454 | }, {
|
1455 | key: 'setTextContentStream',
|
1456 | value: function setTextContentStream(readableStream) {
|
1457 | this.cancel();
|
1458 | this.textContentStream = readableStream;
|
1459 | }
|
1460 | }, {
|
1461 | key: 'setTextContent',
|
1462 | value: function setTextContent(textContent) {
|
1463 | this.cancel();
|
1464 | this.textContent = textContent;
|
1465 | }
|
1466 | }, {
|
1467 | key: 'convertMatches',
|
1468 | value: function convertMatches(matches, matchesLength) {
|
1469 | var i = 0;
|
1470 | var iIndex = 0;
|
1471 | var textContentItemsStr = this.textContentItemsStr;
|
1472 | var end = textContentItemsStr.length - 1;
|
1473 | var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
|
1474 | var ret = [];
|
1475 | if (!matches) {
|
1476 | return ret;
|
1477 | }
|
1478 | for (var m = 0, len = matches.length; m < len; m++) {
|
1479 | var matchIdx = matches[m];
|
1480 | while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
|
1481 | iIndex += textContentItemsStr[i].length;
|
1482 | i++;
|
1483 | }
|
1484 | if (i === textContentItemsStr.length) {
|
1485 | console.error('Could not find a matching mapping');
|
1486 | }
|
1487 | var match = {
|
1488 | begin: {
|
1489 | divIdx: i,
|
1490 | offset: matchIdx - iIndex
|
1491 | }
|
1492 | };
|
1493 | if (matchesLength) {
|
1494 | matchIdx += matchesLength[m];
|
1495 | } else {
|
1496 | matchIdx += queryLen;
|
1497 | }
|
1498 | while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
|
1499 | iIndex += textContentItemsStr[i].length;
|
1500 | i++;
|
1501 | }
|
1502 | match.end = {
|
1503 | divIdx: i,
|
1504 | offset: matchIdx - iIndex
|
1505 | };
|
1506 | ret.push(match);
|
1507 | }
|
1508 | return ret;
|
1509 | }
|
1510 | }, {
|
1511 | key: 'renderMatches',
|
1512 | value: function renderMatches(matches) {
|
1513 | if (matches.length === 0) {
|
1514 | return;
|
1515 | }
|
1516 | var textContentItemsStr = this.textContentItemsStr;
|
1517 | var textDivs = this.textDivs;
|
1518 | var prevEnd = null;
|
1519 | var pageIdx = this.pageIdx;
|
1520 | var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
|
1521 | var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
|
1522 | var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
|
1523 | var infinity = {
|
1524 | divIdx: -1,
|
1525 | offset: undefined
|
1526 | };
|
1527 | function beginText(begin, className) {
|
1528 | var divIdx = begin.divIdx;
|
1529 | textDivs[divIdx].textContent = '';
|
1530 | appendTextToDiv(divIdx, 0, begin.offset, className);
|
1531 | }
|
1532 | function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
|
1533 | var div = textDivs[divIdx];
|
1534 | var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
|
1535 | var node = document.createTextNode(content);
|
1536 | if (className) {
|
1537 | var span = document.createElement('span');
|
1538 | span.className = className;
|
1539 | span.appendChild(node);
|
1540 | div.appendChild(span);
|
1541 | return;
|
1542 | }
|
1543 | div.appendChild(node);
|
1544 | }
|
1545 | var i0 = selectedMatchIdx,
|
1546 | i1 = i0 + 1;
|
1547 | if (highlightAll) {
|
1548 | i0 = 0;
|
1549 | i1 = matches.length;
|
1550 | } else if (!isSelectedPage) {
|
1551 | return;
|
1552 | }
|
1553 | for (var i = i0; i < i1; i++) {
|
1554 | var match = matches[i];
|
1555 | var begin = match.begin;
|
1556 | var end = match.end;
|
1557 | var isSelected = isSelectedPage && i === selectedMatchIdx;
|
1558 | var highlightSuffix = isSelected ? ' selected' : '';
|
1559 | if (this.findController) {
|
1560 | this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
|
1561 | }
|
1562 | if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
|
1563 | if (prevEnd !== null) {
|
1564 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
|
1565 | }
|
1566 | beginText(begin);
|
1567 | } else {
|
1568 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
|
1569 | }
|
1570 | if (begin.divIdx === end.divIdx) {
|
1571 | appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
|
1572 | } else {
|
1573 | appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
|
1574 | for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
|
1575 | textDivs[n0].className = 'highlight middle' + highlightSuffix;
|
1576 | }
|
1577 | beginText(end, 'highlight end' + highlightSuffix);
|
1578 | }
|
1579 | prevEnd = end;
|
1580 | }
|
1581 | if (prevEnd) {
|
1582 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
|
1583 | }
|
1584 | }
|
1585 | }, {
|
1586 | key: 'updateMatches',
|
1587 | value: function updateMatches() {
|
1588 | if (!this.renderingDone) {
|
1589 | return;
|
1590 | }
|
1591 | var matches = this.matches;
|
1592 | var textDivs = this.textDivs;
|
1593 | var textContentItemsStr = this.textContentItemsStr;
|
1594 | var clearedUntilDivIdx = -1;
|
1595 | for (var i = 0, len = matches.length; i < len; i++) {
|
1596 | var match = matches[i];
|
1597 | var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
|
1598 | for (var n = begin, end = match.end.divIdx; n <= end; n++) {
|
1599 | var div = textDivs[n];
|
1600 | div.textContent = textContentItemsStr[n];
|
1601 | div.className = '';
|
1602 | }
|
1603 | clearedUntilDivIdx = match.end.divIdx + 1;
|
1604 | }
|
1605 | if (this.findController === null || !this.findController.active) {
|
1606 | return;
|
1607 | }
|
1608 | var pageMatches = void 0,
|
1609 | pageMatchesLength = void 0;
|
1610 | if (this.findController !== null) {
|
1611 | pageMatches = this.findController.pageMatches[this.pageIdx] || null;
|
1612 | pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
|
1613 | }
|
1614 | this.matches = this.convertMatches(pageMatches, pageMatchesLength);
|
1615 | this.renderMatches(this.matches);
|
1616 | }
|
1617 | }, {
|
1618 | key: '_bindMouse',
|
1619 | value: function _bindMouse() {
|
1620 | var _this2 = this;
|
1621 |
|
1622 | var div = this.textLayerDiv;
|
1623 | var expandDivsTimer = null;
|
1624 | div.addEventListener('mousedown', function (evt) {
|
1625 | if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
|
1626 | _this2.textLayerRenderTask.expandTextDivs(true);
|
1627 | if (expandDivsTimer) {
|
1628 | clearTimeout(expandDivsTimer);
|
1629 | expandDivsTimer = null;
|
1630 | }
|
1631 | return;
|
1632 | }
|
1633 | var end = div.querySelector('.endOfContent');
|
1634 | if (!end) {
|
1635 | return;
|
1636 | }
|
1637 | var adjustTop = evt.target !== div;
|
1638 | adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
|
1639 | if (adjustTop) {
|
1640 | var divBounds = div.getBoundingClientRect();
|
1641 | var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
|
1642 | end.style.top = (r * 100).toFixed(2) + '%';
|
1643 | }
|
1644 | end.classList.add('active');
|
1645 | });
|
1646 | div.addEventListener('mouseup', function () {
|
1647 | if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
|
1648 | expandDivsTimer = setTimeout(function () {
|
1649 | if (_this2.textLayerRenderTask) {
|
1650 | _this2.textLayerRenderTask.expandTextDivs(false);
|
1651 | }
|
1652 | expandDivsTimer = null;
|
1653 | }, EXPAND_DIVS_TIMEOUT);
|
1654 | return;
|
1655 | }
|
1656 | var end = div.querySelector('.endOfContent');
|
1657 | if (!end) {
|
1658 | return;
|
1659 | }
|
1660 | end.style.top = '';
|
1661 | end.classList.remove('active');
|
1662 | });
|
1663 | }
|
1664 | }]);
|
1665 |
|
1666 | return TextLayerBuilder;
|
1667 | }();
|
1668 |
|
1669 | var DefaultTextLayerFactory = function () {
|
1670 | function DefaultTextLayerFactory() {
|
1671 | _classCallCheck(this, DefaultTextLayerFactory);
|
1672 | }
|
1673 |
|
1674 | _createClass(DefaultTextLayerFactory, [{
|
1675 | key: 'createTextLayerBuilder',
|
1676 | value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
|
1677 | var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
1678 |
|
1679 | return new TextLayerBuilder({
|
1680 | textLayerDiv: textLayerDiv,
|
1681 | pageIndex: pageIndex,
|
1682 | viewport: viewport,
|
1683 | enhanceTextSelection: enhanceTextSelection
|
1684 | });
|
1685 | }
|
1686 | }]);
|
1687 |
|
1688 | return DefaultTextLayerFactory;
|
1689 | }();
|
1690 |
|
1691 | exports.TextLayerBuilder = TextLayerBuilder;
|
1692 | exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
|
1693 |
|
1694 | }),
|
1695 |
|
1696 | (function(module, exports, __w_pdfjs_require__) {
|
1697 |
|
1698 | "use strict";
|
1699 |
|
1700 |
|
1701 | Object.defineProperty(exports, "__esModule", {
|
1702 | value: true
|
1703 | });
|
1704 | exports.PDFPageView = undefined;
|
1705 |
|
1706 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
1707 |
|
1708 | var _ui_utils = __w_pdfjs_require__(0);
|
1709 |
|
1710 | var _pdfjsLib = __w_pdfjs_require__(1);
|
1711 |
|
1712 | var _dom_events = __w_pdfjs_require__(2);
|
1713 |
|
1714 | var _pdf_rendering_queue = __w_pdfjs_require__(7);
|
1715 |
|
1716 | var _viewer_compatibility = __w_pdfjs_require__(15);
|
1717 |
|
1718 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1719 |
|
1720 | var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
|
1721 |
|
1722 | var PDFPageView = function () {
|
1723 | function PDFPageView(options) {
|
1724 | _classCallCheck(this, PDFPageView);
|
1725 |
|
1726 | var container = options.container;
|
1727 | var defaultViewport = options.defaultViewport;
|
1728 | this.id = options.id;
|
1729 | this.renderingId = 'page' + this.id;
|
1730 | this.pdfPage = null;
|
1731 | this.pageLabel = null;
|
1732 | this.rotation = 0;
|
1733 | this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
|
1734 | this.viewport = defaultViewport;
|
1735 | this.pdfPageRotate = defaultViewport.rotation;
|
1736 | this.hasRestrictedScaling = false;
|
1737 | this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
|
1738 | this.imageResourcesPath = options.imageResourcesPath || '';
|
1739 | this.renderInteractiveForms = options.renderInteractiveForms || false;
|
1740 | this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
1741 | this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
|
1742 | this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
|
1743 | this.renderingQueue = options.renderingQueue;
|
1744 | this.textLayerFactory = options.textLayerFactory;
|
1745 | this.annotationLayerFactory = options.annotationLayerFactory;
|
1746 | this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
|
1747 | this.enableWebGL = options.enableWebGL || false;
|
1748 | this.l10n = options.l10n || _ui_utils.NullL10n;
|
1749 | this.paintTask = null;
|
1750 | this.paintedViewportMap = new WeakMap();
|
1751 | this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
|
1752 | this.resume = null;
|
1753 | this.error = null;
|
1754 | this.onBeforeDraw = null;
|
1755 | this.onAfterDraw = null;
|
1756 | this.annotationLayer = null;
|
1757 | this.textLayer = null;
|
1758 | this.zoomLayer = null;
|
1759 | var div = document.createElement('div');
|
1760 | div.className = 'page';
|
1761 | div.style.width = Math.floor(this.viewport.width) + 'px';
|
1762 | div.style.height = Math.floor(this.viewport.height) + 'px';
|
1763 | div.setAttribute('data-page-number', this.id);
|
1764 | this.div = div;
|
1765 | container.appendChild(div);
|
1766 | }
|
1767 |
|
1768 | _createClass(PDFPageView, [{
|
1769 | key: 'setPdfPage',
|
1770 | value: function setPdfPage(pdfPage) {
|
1771 | this.pdfPage = pdfPage;
|
1772 | this.pdfPageRotate = pdfPage.rotate;
|
1773 | var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
1774 | this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
|
1775 | this.stats = pdfPage.stats;
|
1776 | this.reset();
|
1777 | }
|
1778 | }, {
|
1779 | key: 'destroy',
|
1780 | value: function destroy() {
|
1781 | this.reset();
|
1782 | if (this.pdfPage) {
|
1783 | this.pdfPage.cleanup();
|
1784 | }
|
1785 | }
|
1786 | }, {
|
1787 | key: '_resetZoomLayer',
|
1788 | value: function _resetZoomLayer() {
|
1789 | var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1790 |
|
1791 | if (!this.zoomLayer) {
|
1792 | return;
|
1793 | }
|
1794 | var zoomLayerCanvas = this.zoomLayer.firstChild;
|
1795 | this.paintedViewportMap.delete(zoomLayerCanvas);
|
1796 | zoomLayerCanvas.width = 0;
|
1797 | zoomLayerCanvas.height = 0;
|
1798 | if (removeFromDOM) {
|
1799 | this.zoomLayer.remove();
|
1800 | }
|
1801 | this.zoomLayer = null;
|
1802 | }
|
1803 | }, {
|
1804 | key: 'reset',
|
1805 | value: function reset() {
|
1806 | var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1807 | var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1808 |
|
1809 | this.cancelRendering(keepAnnotations);
|
1810 | var div = this.div;
|
1811 | div.style.width = Math.floor(this.viewport.width) + 'px';
|
1812 | div.style.height = Math.floor(this.viewport.height) + 'px';
|
1813 | var childNodes = div.childNodes;
|
1814 | var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
|
1815 | var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
|
1816 | for (var i = childNodes.length - 1; i >= 0; i--) {
|
1817 | var node = childNodes[i];
|
1818 | if (currentZoomLayerNode === node || currentAnnotationNode === node) {
|
1819 | continue;
|
1820 | }
|
1821 | div.removeChild(node);
|
1822 | }
|
1823 | div.removeAttribute('data-loaded');
|
1824 | if (currentAnnotationNode) {
|
1825 | this.annotationLayer.hide();
|
1826 | } else if (this.annotationLayer) {
|
1827 | this.annotationLayer.cancel();
|
1828 | this.annotationLayer = null;
|
1829 | }
|
1830 | if (!currentZoomLayerNode) {
|
1831 | if (this.canvas) {
|
1832 | this.paintedViewportMap.delete(this.canvas);
|
1833 | this.canvas.width = 0;
|
1834 | this.canvas.height = 0;
|
1835 | delete this.canvas;
|
1836 | }
|
1837 | this._resetZoomLayer();
|
1838 | }
|
1839 | if (this.svg) {
|
1840 | this.paintedViewportMap.delete(this.svg);
|
1841 | delete this.svg;
|
1842 | }
|
1843 | this.loadingIconDiv = document.createElement('div');
|
1844 | this.loadingIconDiv.className = 'loadingIcon';
|
1845 | div.appendChild(this.loadingIconDiv);
|
1846 | }
|
1847 | }, {
|
1848 | key: 'update',
|
1849 | value: function update(scale, rotation) {
|
1850 | this.scale = scale || this.scale;
|
1851 | if (typeof rotation !== 'undefined') {
|
1852 | this.rotation = rotation;
|
1853 | }
|
1854 | var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
1855 | this.viewport = this.viewport.clone({
|
1856 | scale: this.scale * _ui_utils.CSS_UNITS,
|
1857 | rotation: totalRotation
|
1858 | });
|
1859 | if (this.svg) {
|
1860 | this.cssTransform(this.svg, true);
|
1861 | this.eventBus.dispatch('pagerendered', {
|
1862 | source: this,
|
1863 | pageNumber: this.id,
|
1864 | cssTransform: true
|
1865 | });
|
1866 | return;
|
1867 | }
|
1868 | var isScalingRestricted = false;
|
1869 | if (this.canvas && this.maxCanvasPixels > 0) {
|
1870 | var outputScale = this.outputScale;
|
1871 | if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
|
1872 | isScalingRestricted = true;
|
1873 | }
|
1874 | }
|
1875 | if (this.canvas) {
|
1876 | if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
|
1877 | this.cssTransform(this.canvas, true);
|
1878 | this.eventBus.dispatch('pagerendered', {
|
1879 | source: this,
|
1880 | pageNumber: this.id,
|
1881 | cssTransform: true
|
1882 | });
|
1883 | return;
|
1884 | }
|
1885 | if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
|
1886 | this.zoomLayer = this.canvas.parentNode;
|
1887 | this.zoomLayer.style.position = 'absolute';
|
1888 | }
|
1889 | }
|
1890 | if (this.zoomLayer) {
|
1891 | this.cssTransform(this.zoomLayer.firstChild);
|
1892 | }
|
1893 | this.reset(true, true);
|
1894 | }
|
1895 | }, {
|
1896 | key: 'cancelRendering',
|
1897 | value: function cancelRendering() {
|
1898 | var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1899 |
|
1900 | if (this.paintTask) {
|
1901 | this.paintTask.cancel();
|
1902 | this.paintTask = null;
|
1903 | }
|
1904 | this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
|
1905 | this.resume = null;
|
1906 | if (this.textLayer) {
|
1907 | this.textLayer.cancel();
|
1908 | this.textLayer = null;
|
1909 | }
|
1910 | if (!keepAnnotations && this.annotationLayer) {
|
1911 | this.annotationLayer.cancel();
|
1912 | this.annotationLayer = null;
|
1913 | }
|
1914 | }
|
1915 | }, {
|
1916 | key: 'cssTransform',
|
1917 | value: function cssTransform(target) {
|
1918 | var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1919 |
|
1920 | var width = this.viewport.width;
|
1921 | var height = this.viewport.height;
|
1922 | var div = this.div;
|
1923 | target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
|
1924 | target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
|
1925 | var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
|
1926 | var absRotation = Math.abs(relativeRotation);
|
1927 | var scaleX = 1,
|
1928 | scaleY = 1;
|
1929 | if (absRotation === 90 || absRotation === 270) {
|
1930 | scaleX = height / width;
|
1931 | scaleY = width / height;
|
1932 | }
|
1933 | var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
|
1934 | target.style.transform = cssTransform;
|
1935 | if (this.textLayer) {
|
1936 | var textLayerViewport = this.textLayer.viewport;
|
1937 | var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
|
1938 | var textAbsRotation = Math.abs(textRelativeRotation);
|
1939 | var scale = width / textLayerViewport.width;
|
1940 | if (textAbsRotation === 90 || textAbsRotation === 270) {
|
1941 | scale = width / textLayerViewport.height;
|
1942 | }
|
1943 | var textLayerDiv = this.textLayer.textLayerDiv;
|
1944 | var transX = void 0,
|
1945 | transY = void 0;
|
1946 | switch (textAbsRotation) {
|
1947 | case 0:
|
1948 | transX = transY = 0;
|
1949 | break;
|
1950 | case 90:
|
1951 | transX = 0;
|
1952 | transY = '-' + textLayerDiv.style.height;
|
1953 | break;
|
1954 | case 180:
|
1955 | transX = '-' + textLayerDiv.style.width;
|
1956 | transY = '-' + textLayerDiv.style.height;
|
1957 | break;
|
1958 | case 270:
|
1959 | transX = '-' + textLayerDiv.style.width;
|
1960 | transY = 0;
|
1961 | break;
|
1962 | default:
|
1963 | console.error('Bad rotation value.');
|
1964 | break;
|
1965 | }
|
1966 | textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
|
1967 | textLayerDiv.style.transformOrigin = '0% 0%';
|
1968 | }
|
1969 | if (redrawAnnotations && this.annotationLayer) {
|
1970 | this.annotationLayer.render(this.viewport, 'display');
|
1971 | }
|
1972 | }
|
1973 | }, {
|
1974 | key: 'getPagePoint',
|
1975 | value: function getPagePoint(x, y) {
|
1976 | return this.viewport.convertToPdfPoint(x, y);
|
1977 | }
|
1978 | }, {
|
1979 | key: 'draw',
|
1980 | value: function draw() {
|
1981 | var _this = this;
|
1982 |
|
1983 | if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
|
1984 | console.error('Must be in new state before drawing');
|
1985 | this.reset();
|
1986 | }
|
1987 | if (!this.pdfPage) {
|
1988 | this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
1989 | return Promise.reject(new Error('Page is not loaded'));
|
1990 | }
|
1991 | this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
|
1992 | var pdfPage = this.pdfPage;
|
1993 | var div = this.div;
|
1994 | var canvasWrapper = document.createElement('div');
|
1995 | canvasWrapper.style.width = div.style.width;
|
1996 | canvasWrapper.style.height = div.style.height;
|
1997 | canvasWrapper.classList.add('canvasWrapper');
|
1998 | if (this.annotationLayer && this.annotationLayer.div) {
|
1999 | div.insertBefore(canvasWrapper, this.annotationLayer.div);
|
2000 | } else {
|
2001 | div.appendChild(canvasWrapper);
|
2002 | }
|
2003 | var textLayer = null;
|
2004 | if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
|
2005 | var textLayerDiv = document.createElement('div');
|
2006 | textLayerDiv.className = 'textLayer';
|
2007 | textLayerDiv.style.width = canvasWrapper.style.width;
|
2008 | textLayerDiv.style.height = canvasWrapper.style.height;
|
2009 | if (this.annotationLayer && this.annotationLayer.div) {
|
2010 | div.insertBefore(textLayerDiv, this.annotationLayer.div);
|
2011 | } else {
|
2012 | div.appendChild(textLayerDiv);
|
2013 | }
|
2014 | textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
|
2015 | }
|
2016 | this.textLayer = textLayer;
|
2017 | var renderContinueCallback = null;
|
2018 | if (this.renderingQueue) {
|
2019 | renderContinueCallback = function renderContinueCallback(cont) {
|
2020 | if (!_this.renderingQueue.isHighestPriority(_this)) {
|
2021 | _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
|
2022 | _this.resume = function () {
|
2023 | _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
|
2024 | cont();
|
2025 | };
|
2026 | return;
|
2027 | }
|
2028 | cont();
|
2029 | };
|
2030 | }
|
2031 | var finishPaintTask = function finishPaintTask(error) {
|
2032 | if (paintTask === _this.paintTask) {
|
2033 | _this.paintTask = null;
|
2034 | }
|
2035 | if (error instanceof _pdfjsLib.RenderingCancelledException) {
|
2036 | _this.error = null;
|
2037 | return Promise.resolve(undefined);
|
2038 | }
|
2039 | _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
2040 | if (_this.loadingIconDiv) {
|
2041 | div.removeChild(_this.loadingIconDiv);
|
2042 | delete _this.loadingIconDiv;
|
2043 | }
|
2044 | _this._resetZoomLayer(true);
|
2045 | _this.error = error;
|
2046 | _this.stats = pdfPage.stats;
|
2047 | if (_this.onAfterDraw) {
|
2048 | _this.onAfterDraw();
|
2049 | }
|
2050 | _this.eventBus.dispatch('pagerendered', {
|
2051 | source: _this,
|
2052 | pageNumber: _this.id,
|
2053 | cssTransform: false
|
2054 | });
|
2055 | if (error) {
|
2056 | return Promise.reject(error);
|
2057 | }
|
2058 | return Promise.resolve(undefined);
|
2059 | };
|
2060 | var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
|
2061 | paintTask.onRenderContinue = renderContinueCallback;
|
2062 | this.paintTask = paintTask;
|
2063 | var resultPromise = paintTask.promise.then(function () {
|
2064 | return finishPaintTask(null).then(function () {
|
2065 | if (textLayer) {
|
2066 | var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
|
2067 | textLayer.setTextContentStream(readableStream);
|
2068 | textLayer.render();
|
2069 | }
|
2070 | });
|
2071 | }, function (reason) {
|
2072 | return finishPaintTask(reason);
|
2073 | });
|
2074 | if (this.annotationLayerFactory) {
|
2075 | if (!this.annotationLayer) {
|
2076 | this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
|
2077 | }
|
2078 | this.annotationLayer.render(this.viewport, 'display');
|
2079 | }
|
2080 | div.setAttribute('data-loaded', true);
|
2081 | if (this.onBeforeDraw) {
|
2082 | this.onBeforeDraw();
|
2083 | }
|
2084 | return resultPromise;
|
2085 | }
|
2086 | }, {
|
2087 | key: 'paintOnCanvas',
|
2088 | value: function paintOnCanvas(canvasWrapper) {
|
2089 | var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
|
2090 | var result = {
|
2091 | promise: renderCapability.promise,
|
2092 | onRenderContinue: function onRenderContinue(cont) {
|
2093 | cont();
|
2094 | },
|
2095 | cancel: function cancel() {
|
2096 | renderTask.cancel();
|
2097 | }
|
2098 | };
|
2099 | var viewport = this.viewport;
|
2100 | var canvas = document.createElement('canvas');
|
2101 | canvas.id = this.renderingId;
|
2102 | canvas.setAttribute('hidden', 'hidden');
|
2103 | var isCanvasHidden = true;
|
2104 | var showCanvas = function showCanvas() {
|
2105 | if (isCanvasHidden) {
|
2106 | canvas.removeAttribute('hidden');
|
2107 | isCanvasHidden = false;
|
2108 | }
|
2109 | };
|
2110 | canvasWrapper.appendChild(canvas);
|
2111 | this.canvas = canvas;
|
2112 | canvas.mozOpaque = true;
|
2113 | var ctx = canvas.getContext('2d', { alpha: false });
|
2114 | var outputScale = (0, _ui_utils.getOutputScale)(ctx);
|
2115 | this.outputScale = outputScale;
|
2116 | if (this.useOnlyCssZoom) {
|
2117 | var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
|
2118 | outputScale.sx *= actualSizeViewport.width / viewport.width;
|
2119 | outputScale.sy *= actualSizeViewport.height / viewport.height;
|
2120 | outputScale.scaled = true;
|
2121 | }
|
2122 | if (this.maxCanvasPixels > 0) {
|
2123 | var pixelsInViewport = viewport.width * viewport.height;
|
2124 | var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
|
2125 | if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
|
2126 | outputScale.sx = maxScale;
|
2127 | outputScale.sy = maxScale;
|
2128 | outputScale.scaled = true;
|
2129 | this.hasRestrictedScaling = true;
|
2130 | } else {
|
2131 | this.hasRestrictedScaling = false;
|
2132 | }
|
2133 | }
|
2134 | var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
|
2135 | var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
|
2136 | canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
|
2137 | canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
|
2138 | canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
|
2139 | canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
|
2140 | this.paintedViewportMap.set(canvas, viewport);
|
2141 | var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
|
2142 | var renderContext = {
|
2143 | canvasContext: ctx,
|
2144 | transform: transform,
|
2145 | viewport: this.viewport,
|
2146 | enableWebGL: this.enableWebGL,
|
2147 | renderInteractiveForms: this.renderInteractiveForms
|
2148 | };
|
2149 | var renderTask = this.pdfPage.render(renderContext);
|
2150 | renderTask.onContinue = function (cont) {
|
2151 | showCanvas();
|
2152 | if (result.onRenderContinue) {
|
2153 | result.onRenderContinue(cont);
|
2154 | } else {
|
2155 | cont();
|
2156 | }
|
2157 | };
|
2158 | renderTask.promise.then(function () {
|
2159 | showCanvas();
|
2160 | renderCapability.resolve(undefined);
|
2161 | }, function (error) {
|
2162 | showCanvas();
|
2163 | renderCapability.reject(error);
|
2164 | });
|
2165 | return result;
|
2166 | }
|
2167 | }, {
|
2168 | key: 'paintOnSvg',
|
2169 | value: function paintOnSvg(wrapper) {
|
2170 | var _this2 = this;
|
2171 |
|
2172 | var cancelled = false;
|
2173 | var ensureNotCancelled = function ensureNotCancelled() {
|
2174 | if (cancelled) {
|
2175 | throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
|
2176 | }
|
2177 | };
|
2178 | var pdfPage = this.pdfPage;
|
2179 | var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
|
2180 | var promise = pdfPage.getOperatorList().then(function (opList) {
|
2181 | ensureNotCancelled();
|
2182 | var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
|
2183 | return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
|
2184 | ensureNotCancelled();
|
2185 | _this2.svg = svg;
|
2186 | _this2.paintedViewportMap.set(svg, actualSizeViewport);
|
2187 | svg.style.width = wrapper.style.width;
|
2188 | svg.style.height = wrapper.style.height;
|
2189 | _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
2190 | wrapper.appendChild(svg);
|
2191 | });
|
2192 | });
|
2193 | return {
|
2194 | promise: promise,
|
2195 | onRenderContinue: function onRenderContinue(cont) {
|
2196 | cont();
|
2197 | },
|
2198 | cancel: function cancel() {
|
2199 | cancelled = true;
|
2200 | }
|
2201 | };
|
2202 | }
|
2203 | }, {
|
2204 | key: 'setPageLabel',
|
2205 | value: function setPageLabel(label) {
|
2206 | this.pageLabel = typeof label === 'string' ? label : null;
|
2207 | if (this.pageLabel !== null) {
|
2208 | this.div.setAttribute('data-page-label', this.pageLabel);
|
2209 | } else {
|
2210 | this.div.removeAttribute('data-page-label');
|
2211 | }
|
2212 | }
|
2213 | }, {
|
2214 | key: 'width',
|
2215 | get: function get() {
|
2216 | return this.viewport.width;
|
2217 | }
|
2218 | }, {
|
2219 | key: 'height',
|
2220 | get: function get() {
|
2221 | return this.viewport.height;
|
2222 | }
|
2223 | }]);
|
2224 |
|
2225 | return PDFPageView;
|
2226 | }();
|
2227 |
|
2228 | exports.PDFPageView = PDFPageView;
|
2229 |
|
2230 | }),
|
2231 |
|
2232 | (function(module, exports, __w_pdfjs_require__) {
|
2233 |
|
2234 | "use strict";
|
2235 |
|
2236 |
|
2237 | Object.defineProperty(exports, "__esModule", {
|
2238 | value: true
|
2239 | });
|
2240 |
|
2241 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
2242 |
|
2243 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2244 |
|
2245 | var CLEANUP_TIMEOUT = 30000;
|
2246 | var RenderingStates = {
|
2247 | INITIAL: 0,
|
2248 | RUNNING: 1,
|
2249 | PAUSED: 2,
|
2250 | FINISHED: 3
|
2251 | };
|
2252 |
|
2253 | var PDFRenderingQueue = function () {
|
2254 | function PDFRenderingQueue() {
|
2255 | _classCallCheck(this, PDFRenderingQueue);
|
2256 |
|
2257 | this.pdfViewer = null;
|
2258 | this.pdfThumbnailViewer = null;
|
2259 | this.onIdle = null;
|
2260 | this.highestPriorityPage = null;
|
2261 | this.idleTimeout = null;
|
2262 | this.printing = false;
|
2263 | this.isThumbnailViewEnabled = false;
|
2264 | }
|
2265 |
|
2266 | _createClass(PDFRenderingQueue, [{
|
2267 | key: "setViewer",
|
2268 | value: function setViewer(pdfViewer) {
|
2269 | this.pdfViewer = pdfViewer;
|
2270 | }
|
2271 | }, {
|
2272 | key: "setThumbnailViewer",
|
2273 | value: function setThumbnailViewer(pdfThumbnailViewer) {
|
2274 | this.pdfThumbnailViewer = pdfThumbnailViewer;
|
2275 | }
|
2276 | }, {
|
2277 | key: "isHighestPriority",
|
2278 | value: function isHighestPriority(view) {
|
2279 | return this.highestPriorityPage === view.renderingId;
|
2280 | }
|
2281 | }, {
|
2282 | key: "renderHighestPriority",
|
2283 | value: function renderHighestPriority(currentlyVisiblePages) {
|
2284 | if (this.idleTimeout) {
|
2285 | clearTimeout(this.idleTimeout);
|
2286 | this.idleTimeout = null;
|
2287 | }
|
2288 | if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
|
2289 | return;
|
2290 | }
|
2291 | if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
|
2292 | if (this.pdfThumbnailViewer.forceRendering()) {
|
2293 | return;
|
2294 | }
|
2295 | }
|
2296 | if (this.printing) {
|
2297 | return;
|
2298 | }
|
2299 | if (this.onIdle) {
|
2300 | this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
|
2301 | }
|
2302 | }
|
2303 | }, {
|
2304 | key: "getHighestPriority",
|
2305 | value: function getHighestPriority(visible, views, scrolledDown) {
|
2306 | var visibleViews = visible.views;
|
2307 | var numVisible = visibleViews.length;
|
2308 | if (numVisible === 0) {
|
2309 | return false;
|
2310 | }
|
2311 | for (var i = 0; i < numVisible; ++i) {
|
2312 | var view = visibleViews[i].view;
|
2313 | if (!this.isViewFinished(view)) {
|
2314 | return view;
|
2315 | }
|
2316 | }
|
2317 | if (scrolledDown) {
|
2318 | var nextPageIndex = visible.last.id;
|
2319 | if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
|
2320 | return views[nextPageIndex];
|
2321 | }
|
2322 | } else {
|
2323 | var previousPageIndex = visible.first.id - 2;
|
2324 | if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
|
2325 | return views[previousPageIndex];
|
2326 | }
|
2327 | }
|
2328 | return null;
|
2329 | }
|
2330 | }, {
|
2331 | key: "isViewFinished",
|
2332 | value: function isViewFinished(view) {
|
2333 | return view.renderingState === RenderingStates.FINISHED;
|
2334 | }
|
2335 | }, {
|
2336 | key: "renderView",
|
2337 | value: function renderView(view) {
|
2338 | var _this = this;
|
2339 |
|
2340 | switch (view.renderingState) {
|
2341 | case RenderingStates.FINISHED:
|
2342 | return false;
|
2343 | case RenderingStates.PAUSED:
|
2344 | this.highestPriorityPage = view.renderingId;
|
2345 | view.resume();
|
2346 | break;
|
2347 | case RenderingStates.RUNNING:
|
2348 | this.highestPriorityPage = view.renderingId;
|
2349 | break;
|
2350 | case RenderingStates.INITIAL:
|
2351 | this.highestPriorityPage = view.renderingId;
|
2352 | var continueRendering = function continueRendering() {
|
2353 | _this.renderHighestPriority();
|
2354 | };
|
2355 | view.draw().then(continueRendering, continueRendering);
|
2356 | break;
|
2357 | }
|
2358 | return true;
|
2359 | }
|
2360 | }]);
|
2361 |
|
2362 | return PDFRenderingQueue;
|
2363 | }();
|
2364 |
|
2365 | exports.RenderingStates = RenderingStates;
|
2366 | exports.PDFRenderingQueue = PDFRenderingQueue;
|
2367 |
|
2368 | }),
|
2369 |
|
2370 | (function(module, exports, __w_pdfjs_require__) {
|
2371 |
|
2372 | "use strict";
|
2373 |
|
2374 |
|
2375 | Object.defineProperty(exports, "__esModule", {
|
2376 | value: true
|
2377 | });
|
2378 | exports.BaseViewer = undefined;
|
2379 |
|
2380 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
2381 |
|
2382 | var _ui_utils = __w_pdfjs_require__(0);
|
2383 |
|
2384 | var _pdf_rendering_queue = __w_pdfjs_require__(7);
|
2385 |
|
2386 | var _annotation_layer_builder = __w_pdfjs_require__(4);
|
2387 |
|
2388 | var _pdfjsLib = __w_pdfjs_require__(1);
|
2389 |
|
2390 | var _dom_events = __w_pdfjs_require__(2);
|
2391 |
|
2392 | var _pdf_page_view = __w_pdfjs_require__(6);
|
2393 |
|
2394 | var _pdf_link_service = __w_pdfjs_require__(3);
|
2395 |
|
2396 | var _text_layer_builder = __w_pdfjs_require__(5);
|
2397 |
|
2398 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2399 |
|
2400 | var DEFAULT_CACHE_SIZE = 10;
|
2401 | function PDFPageViewBuffer(size) {
|
2402 | var data = [];
|
2403 | this.push = function (view) {
|
2404 | var i = data.indexOf(view);
|
2405 | if (i >= 0) {
|
2406 | data.splice(i, 1);
|
2407 | }
|
2408 | data.push(view);
|
2409 | if (data.length > size) {
|
2410 | data.shift().destroy();
|
2411 | }
|
2412 | };
|
2413 | this.resize = function (newSize) {
|
2414 | size = newSize;
|
2415 | while (data.length > size) {
|
2416 | data.shift().destroy();
|
2417 | }
|
2418 | };
|
2419 | }
|
2420 | function isSameScale(oldScale, newScale) {
|
2421 | if (newScale === oldScale) {
|
2422 | return true;
|
2423 | }
|
2424 | if (Math.abs(newScale - oldScale) < 1e-15) {
|
2425 | return true;
|
2426 | }
|
2427 | return false;
|
2428 | }
|
2429 |
|
2430 | var BaseViewer = function () {
|
2431 | function BaseViewer(options) {
|
2432 | _classCallCheck(this, BaseViewer);
|
2433 |
|
2434 | if (this.constructor === BaseViewer) {
|
2435 | throw new Error('Cannot initialize BaseViewer.');
|
2436 | }
|
2437 | this._name = this.constructor.name;
|
2438 | this.container = options.container;
|
2439 | this.viewer = options.viewer || options.container.firstElementChild;
|
2440 | this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
|
2441 | this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
|
2442 | this.downloadManager = options.downloadManager || null;
|
2443 | this.removePageBorders = options.removePageBorders || false;
|
2444 | this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
|
2445 | this.enhanceTextSelection = options.enhanceTextSelection || false;
|
2446 | this.imageResourcesPath = options.imageResourcesPath || '';
|
2447 | this.renderInteractiveForms = options.renderInteractiveForms || false;
|
2448 | this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
2449 | this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
|
2450 | this.enableWebGL = options.enableWebGL || false;
|
2451 | this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
2452 | this.maxCanvasPixels = options.maxCanvasPixels;
|
2453 | this.l10n = options.l10n || _ui_utils.NullL10n;
|
2454 | this.defaultRenderingQueue = !options.renderingQueue;
|
2455 | if (this.defaultRenderingQueue) {
|
2456 | this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
|
2457 | this.renderingQueue.setViewer(this);
|
2458 | } else {
|
2459 | this.renderingQueue = options.renderingQueue;
|
2460 | }
|
2461 | this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
|
2462 | this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
|
2463 | this._resetView();
|
2464 | if (this.removePageBorders) {
|
2465 | this.viewer.classList.add('removePageBorders');
|
2466 | }
|
2467 | }
|
2468 |
|
2469 | _createClass(BaseViewer, [{
|
2470 | key: 'getPageView',
|
2471 | value: function getPageView(index) {
|
2472 | return this._pages[index];
|
2473 | }
|
2474 | }, {
|
2475 | key: '_setCurrentPageNumber',
|
2476 | value: function _setCurrentPageNumber(val) {
|
2477 | var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2478 |
|
2479 | if (this._currentPageNumber === val) {
|
2480 | if (resetCurrentPageView) {
|
2481 | this._resetCurrentPageView();
|
2482 | }
|
2483 | return;
|
2484 | }
|
2485 | if (!(0 < val && val <= this.pagesCount)) {
|
2486 | console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
|
2487 | return;
|
2488 | }
|
2489 | var arg = {
|
2490 | source: this,
|
2491 | pageNumber: val,
|
2492 | pageLabel: this._pageLabels && this._pageLabels[val - 1]
|
2493 | };
|
2494 | this._currentPageNumber = val;
|
2495 | this.eventBus.dispatch('pagechanging', arg);
|
2496 | this.eventBus.dispatch('pagechange', arg);
|
2497 | if (resetCurrentPageView) {
|
2498 | this._resetCurrentPageView();
|
2499 | }
|
2500 | }
|
2501 | }, {
|
2502 | key: 'setDocument',
|
2503 | value: function setDocument(pdfDocument) {
|
2504 | var _this = this;
|
2505 |
|
2506 | if (this.pdfDocument) {
|
2507 | this._cancelRendering();
|
2508 | this._resetView();
|
2509 | }
|
2510 | this.pdfDocument = pdfDocument;
|
2511 | if (!pdfDocument) {
|
2512 | return;
|
2513 | }
|
2514 | var pagesCount = pdfDocument.numPages;
|
2515 | var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
|
2516 | this.pagesPromise = pagesCapability.promise;
|
2517 | pagesCapability.promise.then(function () {
|
2518 | _this._pageViewsReady = true;
|
2519 | _this.eventBus.dispatch('pagesloaded', {
|
2520 | source: _this,
|
2521 | pagesCount: pagesCount
|
2522 | });
|
2523 | });
|
2524 | var isOnePageRenderedResolved = false;
|
2525 | var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
|
2526 | this.onePageRendered = onePageRenderedCapability.promise;
|
2527 | var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
|
2528 | pageView.onBeforeDraw = function () {
|
2529 | _this._buffer.push(pageView);
|
2530 | };
|
2531 | pageView.onAfterDraw = function () {
|
2532 | if (!isOnePageRenderedResolved) {
|
2533 | isOnePageRenderedResolved = true;
|
2534 | onePageRenderedCapability.resolve();
|
2535 | }
|
2536 | };
|
2537 | };
|
2538 | var firstPagePromise = pdfDocument.getPage(1);
|
2539 | this.firstPagePromise = firstPagePromise;
|
2540 | firstPagePromise.then(function (pdfPage) {
|
2541 | var scale = _this.currentScale;
|
2542 | var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
|
2543 | for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
2544 | var textLayerFactory = null;
|
2545 | if (_this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
|
2546 | textLayerFactory = _this;
|
2547 | }
|
2548 | var pageView = new _pdf_page_view.PDFPageView({
|
2549 | container: _this._setDocumentViewerElement,
|
2550 | eventBus: _this.eventBus,
|
2551 | id: pageNum,
|
2552 | scale: scale,
|
2553 | defaultViewport: viewport.clone(),
|
2554 | renderingQueue: _this.renderingQueue,
|
2555 | textLayerFactory: textLayerFactory,
|
2556 | textLayerMode: _this.textLayerMode,
|
2557 | annotationLayerFactory: _this,
|
2558 | imageResourcesPath: _this.imageResourcesPath,
|
2559 | renderInteractiveForms: _this.renderInteractiveForms,
|
2560 | renderer: _this.renderer,
|
2561 | enableWebGL: _this.enableWebGL,
|
2562 | useOnlyCssZoom: _this.useOnlyCssZoom,
|
2563 | maxCanvasPixels: _this.maxCanvasPixels,
|
2564 | l10n: _this.l10n
|
2565 | });
|
2566 | bindOnAfterAndBeforeDraw(pageView);
|
2567 | _this._pages.push(pageView);
|
2568 | }
|
2569 | onePageRenderedCapability.promise.then(function () {
|
2570 | if (pdfDocument.loadingParams['disableAutoFetch']) {
|
2571 | pagesCapability.resolve();
|
2572 | return;
|
2573 | }
|
2574 | var getPagesLeft = pagesCount;
|
2575 |
|
2576 | var _loop = function _loop(_pageNum) {
|
2577 | pdfDocument.getPage(_pageNum).then(function (pdfPage) {
|
2578 | var pageView = _this._pages[_pageNum - 1];
|
2579 | if (!pageView.pdfPage) {
|
2580 | pageView.setPdfPage(pdfPage);
|
2581 | }
|
2582 | _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
|
2583 | if (--getPagesLeft === 0) {
|
2584 | pagesCapability.resolve();
|
2585 | }
|
2586 | }, function (reason) {
|
2587 | console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
|
2588 | if (--getPagesLeft === 0) {
|
2589 | pagesCapability.resolve();
|
2590 | }
|
2591 | });
|
2592 | };
|
2593 |
|
2594 | for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
|
2595 | _loop(_pageNum);
|
2596 | }
|
2597 | });
|
2598 | _this.eventBus.dispatch('pagesinit', { source: _this });
|
2599 | if (_this.defaultRenderingQueue) {
|
2600 | _this.update();
|
2601 | }
|
2602 | if (_this.findController) {
|
2603 | _this.findController.resolveFirstPage();
|
2604 | }
|
2605 | }).catch(function (reason) {
|
2606 | console.error('Unable to initialize viewer', reason);
|
2607 | });
|
2608 | }
|
2609 | }, {
|
2610 | key: 'setPageLabels',
|
2611 | value: function setPageLabels(labels) {
|
2612 | if (!this.pdfDocument) {
|
2613 | return;
|
2614 | }
|
2615 | if (!labels) {
|
2616 | this._pageLabels = null;
|
2617 | } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
|
2618 | this._pageLabels = null;
|
2619 | console.error(this._name + '.setPageLabels: Invalid page labels.');
|
2620 | } else {
|
2621 | this._pageLabels = labels;
|
2622 | }
|
2623 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
2624 | var pageView = this._pages[i];
|
2625 | var label = this._pageLabels && this._pageLabels[i];
|
2626 | pageView.setPageLabel(label);
|
2627 | }
|
2628 | }
|
2629 | }, {
|
2630 | key: '_resetView',
|
2631 | value: function _resetView() {
|
2632 | this._pages = [];
|
2633 | this._currentPageNumber = 1;
|
2634 | this._currentScale = _ui_utils.UNKNOWN_SCALE;
|
2635 | this._currentScaleValue = null;
|
2636 | this._pageLabels = null;
|
2637 | this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
|
2638 | this._location = null;
|
2639 | this._pagesRotation = 0;
|
2640 | this._pagesRequests = [];
|
2641 | this._pageViewsReady = false;
|
2642 | this.viewer.textContent = '';
|
2643 | }
|
2644 | }, {
|
2645 | key: '_scrollUpdate',
|
2646 | value: function _scrollUpdate() {
|
2647 | if (this.pagesCount === 0) {
|
2648 | return;
|
2649 | }
|
2650 | this.update();
|
2651 | }
|
2652 | }, {
|
2653 | key: '_scrollIntoView',
|
2654 | value: function _scrollIntoView(_ref) {
|
2655 | var pageDiv = _ref.pageDiv,
|
2656 | _ref$pageSpot = _ref.pageSpot,
|
2657 | pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
|
2658 | _ref$pageNumber = _ref.pageNumber,
|
2659 | pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
|
2660 |
|
2661 | throw new Error('Not implemented: _scrollIntoView');
|
2662 | }
|
2663 | }, {
|
2664 | key: '_setScaleDispatchEvent',
|
2665 | value: function _setScaleDispatchEvent(newScale, newValue) {
|
2666 | var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2667 |
|
2668 | var arg = {
|
2669 | source: this,
|
2670 | scale: newScale,
|
2671 | presetValue: preset ? newValue : undefined
|
2672 | };
|
2673 | this.eventBus.dispatch('scalechanging', arg);
|
2674 | this.eventBus.dispatch('scalechange', arg);
|
2675 | }
|
2676 | }, {
|
2677 | key: '_setScaleUpdatePages',
|
2678 | value: function _setScaleUpdatePages(newScale, newValue) {
|
2679 | var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2680 | var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
2681 |
|
2682 | this._currentScaleValue = newValue.toString();
|
2683 | if (isSameScale(this._currentScale, newScale)) {
|
2684 | if (preset) {
|
2685 | this._setScaleDispatchEvent(newScale, newValue, true);
|
2686 | }
|
2687 | return;
|
2688 | }
|
2689 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
2690 | this._pages[i].update(newScale);
|
2691 | }
|
2692 | this._currentScale = newScale;
|
2693 | if (!noScroll) {
|
2694 | var page = this._currentPageNumber,
|
2695 | dest = void 0;
|
2696 | if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
2697 | page = this._location.pageNumber;
|
2698 | dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
|
2699 | }
|
2700 | this.scrollPageIntoView({
|
2701 | pageNumber: page,
|
2702 | destArray: dest,
|
2703 | allowNegativeOffset: true
|
2704 | });
|
2705 | }
|
2706 | this._setScaleDispatchEvent(newScale, newValue, preset);
|
2707 | if (this.defaultRenderingQueue) {
|
2708 | this.update();
|
2709 | }
|
2710 | }
|
2711 | }, {
|
2712 | key: '_setScale',
|
2713 | value: function _setScale(value) {
|
2714 | var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2715 |
|
2716 | var scale = parseFloat(value);
|
2717 | if (scale > 0) {
|
2718 | this._setScaleUpdatePages(scale, value, noScroll, false);
|
2719 | } else {
|
2720 | var currentPage = this._pages[this._currentPageNumber - 1];
|
2721 | if (!currentPage) {
|
2722 | return;
|
2723 | }
|
2724 | var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
|
2725 | var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
|
2726 | var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
|
2727 | var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
|
2728 | switch (value) {
|
2729 | case 'page-actual':
|
2730 | scale = 1;
|
2731 | break;
|
2732 | case 'page-width':
|
2733 | scale = pageWidthScale;
|
2734 | break;
|
2735 | case 'page-height':
|
2736 | scale = pageHeightScale;
|
2737 | break;
|
2738 | case 'page-fit':
|
2739 | scale = Math.min(pageWidthScale, pageHeightScale);
|
2740 | break;
|
2741 | case 'auto':
|
2742 | var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
|
2743 | scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
|
2744 | break;
|
2745 | default:
|
2746 | console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
|
2747 | return;
|
2748 | }
|
2749 | this._setScaleUpdatePages(scale, value, noScroll, true);
|
2750 | }
|
2751 | }
|
2752 | }, {
|
2753 | key: '_resetCurrentPageView',
|
2754 | value: function _resetCurrentPageView() {
|
2755 | if (this.isInPresentationMode) {
|
2756 | this._setScale(this._currentScaleValue, true);
|
2757 | }
|
2758 | var pageView = this._pages[this._currentPageNumber - 1];
|
2759 | this._scrollIntoView({ pageDiv: pageView.div });
|
2760 | }
|
2761 | }, {
|
2762 | key: 'scrollPageIntoView',
|
2763 | value: function scrollPageIntoView(params) {
|
2764 | if (!this.pdfDocument) {
|
2765 | return;
|
2766 | }
|
2767 | var pageNumber = params.pageNumber || 0;
|
2768 | var dest = params.destArray || null;
|
2769 | var allowNegativeOffset = params.allowNegativeOffset || false;
|
2770 | if (this.isInPresentationMode || !dest) {
|
2771 | this._setCurrentPageNumber(pageNumber, true);
|
2772 | return;
|
2773 | }
|
2774 | var pageView = this._pages[pageNumber - 1];
|
2775 | if (!pageView) {
|
2776 | console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
|
2777 | return;
|
2778 | }
|
2779 | var x = 0,
|
2780 | y = 0;
|
2781 | var width = 0,
|
2782 | height = 0,
|
2783 | widthScale = void 0,
|
2784 | heightScale = void 0;
|
2785 | var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
|
2786 | var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
|
2787 | var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
|
2788 | var scale = 0;
|
2789 | switch (dest[1].name) {
|
2790 | case 'XYZ':
|
2791 | x = dest[2];
|
2792 | y = dest[3];
|
2793 | scale = dest[4];
|
2794 | x = x !== null ? x : 0;
|
2795 | y = y !== null ? y : pageHeight;
|
2796 | break;
|
2797 | case 'Fit':
|
2798 | case 'FitB':
|
2799 | scale = 'page-fit';
|
2800 | break;
|
2801 | case 'FitH':
|
2802 | case 'FitBH':
|
2803 | y = dest[2];
|
2804 | scale = 'page-width';
|
2805 | if (y === null && this._location) {
|
2806 | x = this._location.left;
|
2807 | y = this._location.top;
|
2808 | }
|
2809 | break;
|
2810 | case 'FitV':
|
2811 | case 'FitBV':
|
2812 | x = dest[2];
|
2813 | width = pageWidth;
|
2814 | height = pageHeight;
|
2815 | scale = 'page-height';
|
2816 | break;
|
2817 | case 'FitR':
|
2818 | x = dest[2];
|
2819 | y = dest[3];
|
2820 | width = dest[4] - x;
|
2821 | height = dest[5] - y;
|
2822 | var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
|
2823 | var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
|
2824 | widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
|
2825 | heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
|
2826 | scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
|
2827 | break;
|
2828 | default:
|
2829 | console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
|
2830 | return;
|
2831 | }
|
2832 | if (scale && scale !== this._currentScale) {
|
2833 | this.currentScaleValue = scale;
|
2834 | } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
|
2835 | this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
2836 | }
|
2837 | if (scale === 'page-fit' && !dest[4]) {
|
2838 | this._scrollIntoView({
|
2839 | pageDiv: pageView.div,
|
2840 | pageNumber: pageNumber
|
2841 | });
|
2842 | return;
|
2843 | }
|
2844 | var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
|
2845 | var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
|
2846 | var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
|
2847 | if (!allowNegativeOffset) {
|
2848 | left = Math.max(left, 0);
|
2849 | top = Math.max(top, 0);
|
2850 | }
|
2851 | this._scrollIntoView({
|
2852 | pageDiv: pageView.div,
|
2853 | pageSpot: {
|
2854 | left: left,
|
2855 | top: top
|
2856 | },
|
2857 | pageNumber: pageNumber
|
2858 | });
|
2859 | }
|
2860 | }, {
|
2861 | key: '_resizeBuffer',
|
2862 | value: function _resizeBuffer(numVisiblePages) {
|
2863 | var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
|
2864 | this._buffer.resize(suggestedCacheSize);
|
2865 | }
|
2866 | }, {
|
2867 | key: '_updateLocation',
|
2868 | value: function _updateLocation(firstPage) {
|
2869 | var currentScale = this._currentScale;
|
2870 | var currentScaleValue = this._currentScaleValue;
|
2871 | var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
|
2872 | var pageNumber = firstPage.id;
|
2873 | var pdfOpenParams = '#page=' + pageNumber;
|
2874 | pdfOpenParams += '&zoom=' + normalizedScaleValue;
|
2875 | var currentPageView = this._pages[pageNumber - 1];
|
2876 | var container = this.container;
|
2877 | var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
|
2878 | var intLeft = Math.round(topLeft[0]);
|
2879 | var intTop = Math.round(topLeft[1]);
|
2880 | pdfOpenParams += ',' + intLeft + ',' + intTop;
|
2881 | this._location = {
|
2882 | pageNumber: pageNumber,
|
2883 | scale: normalizedScaleValue,
|
2884 | top: intTop,
|
2885 | left: intLeft,
|
2886 | rotation: this._pagesRotation,
|
2887 | pdfOpenParams: pdfOpenParams
|
2888 | };
|
2889 | }
|
2890 | }, {
|
2891 | key: 'update',
|
2892 | value: function update() {
|
2893 | throw new Error('Not implemented: update');
|
2894 | }
|
2895 | }, {
|
2896 | key: 'containsElement',
|
2897 | value: function containsElement(element) {
|
2898 | return this.container.contains(element);
|
2899 | }
|
2900 | }, {
|
2901 | key: 'focus',
|
2902 | value: function focus() {
|
2903 | this.container.focus();
|
2904 | }
|
2905 | }, {
|
2906 | key: '_getVisiblePages',
|
2907 | value: function _getVisiblePages() {
|
2908 | throw new Error('Not implemented: _getVisiblePages');
|
2909 | }
|
2910 | }, {
|
2911 | key: 'cleanup',
|
2912 | value: function cleanup() {
|
2913 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
2914 | if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
|
2915 | this._pages[i].reset();
|
2916 | }
|
2917 | }
|
2918 | }
|
2919 | }, {
|
2920 | key: '_cancelRendering',
|
2921 | value: function _cancelRendering() {
|
2922 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
2923 | if (this._pages[i]) {
|
2924 | this._pages[i].cancelRendering();
|
2925 | }
|
2926 | }
|
2927 | }
|
2928 | }, {
|
2929 | key: '_ensurePdfPageLoaded',
|
2930 | value: function _ensurePdfPageLoaded(pageView) {
|
2931 | var _this2 = this;
|
2932 |
|
2933 | if (pageView.pdfPage) {
|
2934 | return Promise.resolve(pageView.pdfPage);
|
2935 | }
|
2936 | var pageNumber = pageView.id;
|
2937 | if (this._pagesRequests[pageNumber]) {
|
2938 | return this._pagesRequests[pageNumber];
|
2939 | }
|
2940 | var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
|
2941 | if (!pageView.pdfPage) {
|
2942 | pageView.setPdfPage(pdfPage);
|
2943 | }
|
2944 | _this2._pagesRequests[pageNumber] = null;
|
2945 | return pdfPage;
|
2946 | }).catch(function (reason) {
|
2947 | console.error('Unable to get page for page view', reason);
|
2948 | _this2._pagesRequests[pageNumber] = null;
|
2949 | });
|
2950 | this._pagesRequests[pageNumber] = promise;
|
2951 | return promise;
|
2952 | }
|
2953 | }, {
|
2954 | key: 'forceRendering',
|
2955 | value: function forceRendering(currentlyVisiblePages) {
|
2956 | var _this3 = this;
|
2957 |
|
2958 | var visiblePages = currentlyVisiblePages || this._getVisiblePages();
|
2959 | var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
|
2960 | if (pageView) {
|
2961 | this._ensurePdfPageLoaded(pageView).then(function () {
|
2962 | _this3.renderingQueue.renderView(pageView);
|
2963 | });
|
2964 | return true;
|
2965 | }
|
2966 | return false;
|
2967 | }
|
2968 | }, {
|
2969 | key: 'getPageTextContent',
|
2970 | value: function getPageTextContent(pageIndex) {
|
2971 | return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
|
2972 | return page.getTextContent({ normalizeWhitespace: true });
|
2973 | });
|
2974 | }
|
2975 | }, {
|
2976 | key: 'createTextLayerBuilder',
|
2977 | value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
|
2978 | var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
2979 |
|
2980 | return new _text_layer_builder.TextLayerBuilder({
|
2981 | textLayerDiv: textLayerDiv,
|
2982 | eventBus: this.eventBus,
|
2983 | pageIndex: pageIndex,
|
2984 | viewport: viewport,
|
2985 | findController: this.isInPresentationMode ? null : this.findController,
|
2986 | enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
|
2987 | });
|
2988 | }
|
2989 | }, {
|
2990 | key: 'createAnnotationLayerBuilder',
|
2991 | value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
|
2992 | var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
2993 | var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
2994 | var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
|
2995 |
|
2996 | return new _annotation_layer_builder.AnnotationLayerBuilder({
|
2997 | pageDiv: pageDiv,
|
2998 | pdfPage: pdfPage,
|
2999 | imageResourcesPath: imageResourcesPath,
|
3000 | renderInteractiveForms: renderInteractiveForms,
|
3001 | linkService: this.linkService,
|
3002 | downloadManager: this.downloadManager,
|
3003 | l10n: l10n
|
3004 | });
|
3005 | }
|
3006 | }, {
|
3007 | key: 'setFindController',
|
3008 | value: function setFindController(findController) {
|
3009 | this.findController = findController;
|
3010 | }
|
3011 | }, {
|
3012 | key: 'getPagesOverview',
|
3013 | value: function getPagesOverview() {
|
3014 | var pagesOverview = this._pages.map(function (pageView) {
|
3015 | var viewport = pageView.pdfPage.getViewport(1);
|
3016 | return {
|
3017 | width: viewport.width,
|
3018 | height: viewport.height,
|
3019 | rotation: viewport.rotation
|
3020 | };
|
3021 | });
|
3022 | if (!this.enablePrintAutoRotate) {
|
3023 | return pagesOverview;
|
3024 | }
|
3025 | var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
|
3026 | return pagesOverview.map(function (size) {
|
3027 | if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
|
3028 | return size;
|
3029 | }
|
3030 | return {
|
3031 | width: size.height,
|
3032 | height: size.width,
|
3033 | rotation: (size.rotation + 90) % 360
|
3034 | };
|
3035 | });
|
3036 | }
|
3037 | }, {
|
3038 | key: 'pagesCount',
|
3039 | get: function get() {
|
3040 | return this._pages.length;
|
3041 | }
|
3042 | }, {
|
3043 | key: 'pageViewsReady',
|
3044 | get: function get() {
|
3045 | return this._pageViewsReady;
|
3046 | }
|
3047 | }, {
|
3048 | key: 'currentPageNumber',
|
3049 | get: function get() {
|
3050 | return this._currentPageNumber;
|
3051 | },
|
3052 | set: function set(val) {
|
3053 | if (!Number.isInteger(val)) {
|
3054 | throw new Error('Invalid page number.');
|
3055 | }
|
3056 | if (!this.pdfDocument) {
|
3057 | return;
|
3058 | }
|
3059 | this._setCurrentPageNumber(val, true);
|
3060 | }
|
3061 | }, {
|
3062 | key: 'currentPageLabel',
|
3063 | get: function get() {
|
3064 | return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
|
3065 | },
|
3066 | set: function set(val) {
|
3067 | var pageNumber = val | 0;
|
3068 | if (this._pageLabels) {
|
3069 | var i = this._pageLabels.indexOf(val);
|
3070 | if (i >= 0) {
|
3071 | pageNumber = i + 1;
|
3072 | }
|
3073 | }
|
3074 | this.currentPageNumber = pageNumber;
|
3075 | }
|
3076 | }, {
|
3077 | key: 'currentScale',
|
3078 | get: function get() {
|
3079 | return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
|
3080 | },
|
3081 | set: function set(val) {
|
3082 | if (isNaN(val)) {
|
3083 | throw new Error('Invalid numeric scale');
|
3084 | }
|
3085 | if (!this.pdfDocument) {
|
3086 | return;
|
3087 | }
|
3088 | this._setScale(val, false);
|
3089 | }
|
3090 | }, {
|
3091 | key: 'currentScaleValue',
|
3092 | get: function get() {
|
3093 | return this._currentScaleValue;
|
3094 | },
|
3095 | set: function set(val) {
|
3096 | if (!this.pdfDocument) {
|
3097 | return;
|
3098 | }
|
3099 | this._setScale(val, false);
|
3100 | }
|
3101 | }, {
|
3102 | key: 'pagesRotation',
|
3103 | get: function get() {
|
3104 | return this._pagesRotation;
|
3105 | },
|
3106 | set: function set(rotation) {
|
3107 | if (!(0, _ui_utils.isValidRotation)(rotation)) {
|
3108 | throw new Error('Invalid pages rotation angle.');
|
3109 | }
|
3110 | if (!this.pdfDocument) {
|
3111 | return;
|
3112 | }
|
3113 | if (this._pagesRotation === rotation) {
|
3114 | return;
|
3115 | }
|
3116 | this._pagesRotation = rotation;
|
3117 | var pageNumber = this._currentPageNumber;
|
3118 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
3119 | var pageView = this._pages[i];
|
3120 | pageView.update(pageView.scale, rotation);
|
3121 | }
|
3122 | if (this._currentScaleValue) {
|
3123 | this._setScale(this._currentScaleValue, true);
|
3124 | }
|
3125 | this.eventBus.dispatch('rotationchanging', {
|
3126 | source: this,
|
3127 | pagesRotation: rotation,
|
3128 | pageNumber: pageNumber
|
3129 | });
|
3130 | if (this.defaultRenderingQueue) {
|
3131 | this.update();
|
3132 | }
|
3133 | }
|
3134 | }, {
|
3135 | key: '_setDocumentViewerElement',
|
3136 | get: function get() {
|
3137 | throw new Error('Not implemented: _setDocumentViewerElement');
|
3138 | }
|
3139 | }, {
|
3140 | key: 'isInPresentationMode',
|
3141 | get: function get() {
|
3142 | return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
|
3143 | }
|
3144 | }, {
|
3145 | key: 'isChangingPresentationMode',
|
3146 | get: function get() {
|
3147 | return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
|
3148 | }
|
3149 | }, {
|
3150 | key: 'isHorizontalScrollbarEnabled',
|
3151 | get: function get() {
|
3152 | return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
|
3153 | }
|
3154 | }, {
|
3155 | key: 'hasEqualPageSizes',
|
3156 | get: function get() {
|
3157 | var firstPageView = this._pages[0];
|
3158 | for (var i = 1, ii = this._pages.length; i < ii; ++i) {
|
3159 | var pageView = this._pages[i];
|
3160 | if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
|
3161 | return false;
|
3162 | }
|
3163 | }
|
3164 | return true;
|
3165 | }
|
3166 | }]);
|
3167 |
|
3168 | return BaseViewer;
|
3169 | }();
|
3170 |
|
3171 | exports.BaseViewer = BaseViewer;
|
3172 |
|
3173 | }),
|
3174 |
|
3175 | (function(module, exports, __w_pdfjs_require__) {
|
3176 |
|
3177 | "use strict";
|
3178 |
|
3179 |
|
3180 | Object.defineProperty(exports, "__esModule", {
|
3181 | value: true
|
3182 | });
|
3183 | exports.NullL10n = exports.GenericL10n = exports.ProgressBar = exports.DownloadManager = exports.EventBus = exports.PDFFindController = exports.PDFHistory = exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = exports.DefaultTextLayerFactory = exports.TextLayerBuilder = exports.SimpleLinkService = exports.PDFLinkService = exports.PDFPageView = exports.PDFSinglePageViewer = exports.PDFViewer = undefined;
|
3184 |
|
3185 | var _annotation_layer_builder = __w_pdfjs_require__(4);
|
3186 |
|
3187 | var _text_layer_builder = __w_pdfjs_require__(5);
|
3188 |
|
3189 | var _ui_utils = __w_pdfjs_require__(0);
|
3190 |
|
3191 | var _pdf_link_service = __w_pdfjs_require__(3);
|
3192 |
|
3193 | var _download_manager = __w_pdfjs_require__(10);
|
3194 |
|
3195 | var _genericl10n = __w_pdfjs_require__(11);
|
3196 |
|
3197 | var _pdf_find_controller = __w_pdfjs_require__(13);
|
3198 |
|
3199 | var _pdf_history = __w_pdfjs_require__(14);
|
3200 |
|
3201 | var _pdf_page_view = __w_pdfjs_require__(6);
|
3202 |
|
3203 | var _pdf_single_page_viewer = __w_pdfjs_require__(16);
|
3204 |
|
3205 | var _pdf_viewer = __w_pdfjs_require__(17);
|
3206 |
|
3207 | var pdfjsVersion = '2.0.489';
|
3208 | var pdfjsBuild = '7d7bc80e';
|
3209 | exports.PDFViewer = _pdf_viewer.PDFViewer;
|
3210 | exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
|
3211 | exports.PDFPageView = _pdf_page_view.PDFPageView;
|
3212 | exports.PDFLinkService = _pdf_link_service.PDFLinkService;
|
3213 | exports.SimpleLinkService = _pdf_link_service.SimpleLinkService;
|
3214 | exports.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
|
3215 | exports.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
|
3216 | exports.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
|
3217 | exports.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
|
3218 | exports.PDFHistory = _pdf_history.PDFHistory;
|
3219 | exports.PDFFindController = _pdf_find_controller.PDFFindController;
|
3220 | exports.EventBus = _ui_utils.EventBus;
|
3221 | exports.DownloadManager = _download_manager.DownloadManager;
|
3222 | exports.ProgressBar = _ui_utils.ProgressBar;
|
3223 | exports.GenericL10n = _genericl10n.GenericL10n;
|
3224 | exports.NullL10n = _ui_utils.NullL10n;
|
3225 |
|
3226 | }),
|
3227 |
|
3228 | (function(module, exports, __w_pdfjs_require__) {
|
3229 |
|
3230 | "use strict";
|
3231 |
|
3232 |
|
3233 | Object.defineProperty(exports, "__esModule", {
|
3234 | value: true
|
3235 | });
|
3236 | exports.DownloadManager = undefined;
|
3237 |
|
3238 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
3239 |
|
3240 | var _pdfjsLib = __w_pdfjs_require__(1);
|
3241 |
|
3242 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3243 |
|
3244 | ;
|
3245 | var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
|
3246 | function _download(blobUrl, filename) {
|
3247 | var a = document.createElement('a');
|
3248 | if (!a.click) {
|
3249 | throw new Error('DownloadManager: "a.click()" is not supported.');
|
3250 | }
|
3251 | a.href = blobUrl;
|
3252 | a.target = '_parent';
|
3253 | if ('download' in a) {
|
3254 | a.download = filename;
|
3255 | }
|
3256 | (document.body || document.documentElement).appendChild(a);
|
3257 | a.click();
|
3258 | a.remove();
|
3259 | }
|
3260 |
|
3261 | var DownloadManager = function () {
|
3262 | function DownloadManager(_ref) {
|
3263 | var _ref$disableCreateObj = _ref.disableCreateObjectURL,
|
3264 | disableCreateObjectURL = _ref$disableCreateObj === undefined ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
|
3265 |
|
3266 | _classCallCheck(this, DownloadManager);
|
3267 |
|
3268 | this.disableCreateObjectURL = disableCreateObjectURL;
|
3269 | }
|
3270 |
|
3271 | _createClass(DownloadManager, [{
|
3272 | key: 'downloadUrl',
|
3273 | value: function downloadUrl(url, filename) {
|
3274 | if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
|
3275 | return;
|
3276 | }
|
3277 | _download(url + '#pdfjs.action=download', filename);
|
3278 | }
|
3279 | }, {
|
3280 | key: 'downloadData',
|
3281 | value: function downloadData(data, filename, contentType) {
|
3282 | if (navigator.msSaveBlob) {
|
3283 | return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
|
3284 | }
|
3285 | var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
|
3286 | _download(blobUrl, filename);
|
3287 | }
|
3288 | }, {
|
3289 | key: 'download',
|
3290 | value: function download(blob, url, filename) {
|
3291 | if (navigator.msSaveBlob) {
|
3292 | if (!navigator.msSaveBlob(blob, filename)) {
|
3293 | this.downloadUrl(url, filename);
|
3294 | }
|
3295 | return;
|
3296 | }
|
3297 | if (this.disableCreateObjectURL) {
|
3298 | this.downloadUrl(url, filename);
|
3299 | return;
|
3300 | }
|
3301 | var blobUrl = URL.createObjectURL(blob);
|
3302 | _download(blobUrl, filename);
|
3303 | }
|
3304 | }]);
|
3305 |
|
3306 | return DownloadManager;
|
3307 | }();
|
3308 |
|
3309 | exports.DownloadManager = DownloadManager;
|
3310 |
|
3311 | }),
|
3312 |
|
3313 | (function(module, exports, __w_pdfjs_require__) {
|
3314 |
|
3315 | "use strict";
|
3316 |
|
3317 |
|
3318 | Object.defineProperty(exports, "__esModule", {
|
3319 | value: true
|
3320 | });
|
3321 | exports.GenericL10n = undefined;
|
3322 |
|
3323 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
3324 |
|
3325 | __w_pdfjs_require__(12);
|
3326 |
|
3327 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3328 |
|
3329 | var webL10n = document.webL10n;
|
3330 |
|
3331 | var GenericL10n = function () {
|
3332 | function GenericL10n(lang) {
|
3333 | _classCallCheck(this, GenericL10n);
|
3334 |
|
3335 | this._lang = lang;
|
3336 | this._ready = new Promise(function (resolve, reject) {
|
3337 | webL10n.setLanguage(lang, function () {
|
3338 | resolve(webL10n);
|
3339 | });
|
3340 | });
|
3341 | }
|
3342 |
|
3343 | _createClass(GenericL10n, [{
|
3344 | key: 'getLanguage',
|
3345 | value: function getLanguage() {
|
3346 | return this._ready.then(function (l10n) {
|
3347 | return l10n.getLanguage();
|
3348 | });
|
3349 | }
|
3350 | }, {
|
3351 | key: 'getDirection',
|
3352 | value: function getDirection() {
|
3353 | return this._ready.then(function (l10n) {
|
3354 | return l10n.getDirection();
|
3355 | });
|
3356 | }
|
3357 | }, {
|
3358 | key: 'get',
|
3359 | value: function get(property, args, fallback) {
|
3360 | return this._ready.then(function (l10n) {
|
3361 | return l10n.get(property, args, fallback);
|
3362 | });
|
3363 | }
|
3364 | }, {
|
3365 | key: 'translate',
|
3366 | value: function translate(element) {
|
3367 | return this._ready.then(function (l10n) {
|
3368 | return l10n.translate(element);
|
3369 | });
|
3370 | }
|
3371 | }]);
|
3372 |
|
3373 | return GenericL10n;
|
3374 | }();
|
3375 |
|
3376 | exports.GenericL10n = GenericL10n;
|
3377 |
|
3378 | }),
|
3379 |
|
3380 | (function(module, exports, __w_pdfjs_require__) {
|
3381 |
|
3382 | "use strict";
|
3383 |
|
3384 |
|
3385 | document.webL10n = function (window, document, undefined) {
|
3386 | var gL10nData = {};
|
3387 | var gTextData = '';
|
3388 | var gTextProp = 'textContent';
|
3389 | var gLanguage = '';
|
3390 | var gMacros = {};
|
3391 | var gReadyState = 'loading';
|
3392 | var gAsyncResourceLoading = true;
|
3393 | function getL10nResourceLinks() {
|
3394 | return document.querySelectorAll('link[type="application/l10n"]');
|
3395 | }
|
3396 | function getL10nDictionary() {
|
3397 | var script = document.querySelector('script[type="application/l10n"]');
|
3398 | return script ? JSON.parse(script.innerHTML) : null;
|
3399 | }
|
3400 | function getTranslatableChildren(element) {
|
3401 | return element ? element.querySelectorAll('*[data-l10n-id]') : [];
|
3402 | }
|
3403 | function getL10nAttributes(element) {
|
3404 | if (!element) return {};
|
3405 | var l10nId = element.getAttribute('data-l10n-id');
|
3406 | var l10nArgs = element.getAttribute('data-l10n-args');
|
3407 | var args = {};
|
3408 | if (l10nArgs) {
|
3409 | try {
|
3410 | args = JSON.parse(l10nArgs);
|
3411 | } catch (e) {
|
3412 | console.warn('could not parse arguments for #' + l10nId);
|
3413 | }
|
3414 | }
|
3415 | return {
|
3416 | id: l10nId,
|
3417 | args: args
|
3418 | };
|
3419 | }
|
3420 | function fireL10nReadyEvent(lang) {
|
3421 | var evtObject = document.createEvent('Event');
|
3422 | evtObject.initEvent('localized', true, false);
|
3423 | evtObject.language = lang;
|
3424 | document.dispatchEvent(evtObject);
|
3425 | }
|
3426 | function xhrLoadText(url, onSuccess, onFailure) {
|
3427 | onSuccess = onSuccess || function _onSuccess(data) {};
|
3428 | onFailure = onFailure || function _onFailure() {};
|
3429 | var xhr = new XMLHttpRequest();
|
3430 | xhr.open('GET', url, gAsyncResourceLoading);
|
3431 | if (xhr.overrideMimeType) {
|
3432 | xhr.overrideMimeType('text/plain; charset=utf-8');
|
3433 | }
|
3434 | xhr.onreadystatechange = function () {
|
3435 | if (xhr.readyState == 4) {
|
3436 | if (xhr.status == 200 || xhr.status === 0) {
|
3437 | onSuccess(xhr.responseText);
|
3438 | } else {
|
3439 | onFailure();
|
3440 | }
|
3441 | }
|
3442 | };
|
3443 | xhr.onerror = onFailure;
|
3444 | xhr.ontimeout = onFailure;
|
3445 | try {
|
3446 | xhr.send(null);
|
3447 | } catch (e) {
|
3448 | onFailure();
|
3449 | }
|
3450 | }
|
3451 | function parseResource(href, lang, successCallback, failureCallback) {
|
3452 | var baseURL = href.replace(/[^\/]*$/, '') || './';
|
3453 | function evalString(text) {
|
3454 | if (text.lastIndexOf('\\') < 0) return text;
|
3455 | return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
|
3456 | }
|
3457 | function parseProperties(text, parsedPropertiesCallback) {
|
3458 | var dictionary = {};
|
3459 | var reBlank = /^\s*|\s*$/;
|
3460 | var reComment = /^\s*#|^\s*$/;
|
3461 | var reSection = /^\s*\[(.*)\]\s*$/;
|
3462 | var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
|
3463 | var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
|
3464 | function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
|
3465 | var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
|
3466 | var currentLang = '*';
|
3467 | var genericLang = lang.split('-', 1)[0];
|
3468 | var skipLang = false;
|
3469 | var match = '';
|
3470 | function nextEntry() {
|
3471 | while (true) {
|
3472 | if (!entries.length) {
|
3473 | parsedRawLinesCallback();
|
3474 | return;
|
3475 | }
|
3476 | var line = entries.shift();
|
3477 | if (reComment.test(line)) continue;
|
3478 | if (extendedSyntax) {
|
3479 | match = reSection.exec(line);
|
3480 | if (match) {
|
3481 | currentLang = match[1].toLowerCase();
|
3482 | skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
|
3483 | continue;
|
3484 | } else if (skipLang) {
|
3485 | continue;
|
3486 | }
|
3487 | match = reImport.exec(line);
|
3488 | if (match) {
|
3489 | loadImport(baseURL + match[1], nextEntry);
|
3490 | return;
|
3491 | }
|
3492 | }
|
3493 | var tmp = line.match(reSplit);
|
3494 | if (tmp && tmp.length == 3) {
|
3495 | dictionary[tmp[1]] = evalString(tmp[2]);
|
3496 | }
|
3497 | }
|
3498 | }
|
3499 | nextEntry();
|
3500 | }
|
3501 | function loadImport(url, callback) {
|
3502 | xhrLoadText(url, function (content) {
|
3503 | parseRawLines(content, false, callback);
|
3504 | }, function () {
|
3505 | console.warn(url + ' not found.');
|
3506 | callback();
|
3507 | });
|
3508 | }
|
3509 | parseRawLines(text, true, function () {
|
3510 | parsedPropertiesCallback(dictionary);
|
3511 | });
|
3512 | }
|
3513 | xhrLoadText(href, function (response) {
|
3514 | gTextData += response;
|
3515 | parseProperties(response, function (data) {
|
3516 | for (var key in data) {
|
3517 | var id,
|
3518 | prop,
|
3519 | index = key.lastIndexOf('.');
|
3520 | if (index > 0) {
|
3521 | id = key.substring(0, index);
|
3522 | prop = key.substr(index + 1);
|
3523 | } else {
|
3524 | id = key;
|
3525 | prop = gTextProp;
|
3526 | }
|
3527 | if (!gL10nData[id]) {
|
3528 | gL10nData[id] = {};
|
3529 | }
|
3530 | gL10nData[id][prop] = data[key];
|
3531 | }
|
3532 | if (successCallback) {
|
3533 | successCallback();
|
3534 | }
|
3535 | });
|
3536 | }, failureCallback);
|
3537 | }
|
3538 | function loadLocale(lang, callback) {
|
3539 | if (lang) {
|
3540 | lang = lang.toLowerCase();
|
3541 | }
|
3542 | callback = callback || function _callback() {};
|
3543 | clear();
|
3544 | gLanguage = lang;
|
3545 | var langLinks = getL10nResourceLinks();
|
3546 | var langCount = langLinks.length;
|
3547 | if (langCount === 0) {
|
3548 | var dict = getL10nDictionary();
|
3549 | if (dict && dict.locales && dict.default_locale) {
|
3550 | console.log('using the embedded JSON directory, early way out');
|
3551 | gL10nData = dict.locales[lang];
|
3552 | if (!gL10nData) {
|
3553 | var defaultLocale = dict.default_locale.toLowerCase();
|
3554 | for (var anyCaseLang in dict.locales) {
|
3555 | anyCaseLang = anyCaseLang.toLowerCase();
|
3556 | if (anyCaseLang === lang) {
|
3557 | gL10nData = dict.locales[lang];
|
3558 | break;
|
3559 | } else if (anyCaseLang === defaultLocale) {
|
3560 | gL10nData = dict.locales[defaultLocale];
|
3561 | }
|
3562 | }
|
3563 | }
|
3564 | callback();
|
3565 | } else {
|
3566 | console.log('no resource to load, early way out');
|
3567 | }
|
3568 | fireL10nReadyEvent(lang);
|
3569 | gReadyState = 'complete';
|
3570 | return;
|
3571 | }
|
3572 | var onResourceLoaded = null;
|
3573 | var gResourceCount = 0;
|
3574 | onResourceLoaded = function onResourceLoaded() {
|
3575 | gResourceCount++;
|
3576 | if (gResourceCount >= langCount) {
|
3577 | callback();
|
3578 | fireL10nReadyEvent(lang);
|
3579 | gReadyState = 'complete';
|
3580 | }
|
3581 | };
|
3582 | function L10nResourceLink(link) {
|
3583 | var href = link.href;
|
3584 | this.load = function (lang, callback) {
|
3585 | parseResource(href, lang, callback, function () {
|
3586 | console.warn(href + ' not found.');
|
3587 | console.warn('"' + lang + '" resource not found');
|
3588 | gLanguage = '';
|
3589 | callback();
|
3590 | });
|
3591 | };
|
3592 | }
|
3593 | for (var i = 0; i < langCount; i++) {
|
3594 | var resource = new L10nResourceLink(langLinks[i]);
|
3595 | resource.load(lang, onResourceLoaded);
|
3596 | }
|
3597 | }
|
3598 | function clear() {
|
3599 | gL10nData = {};
|
3600 | gTextData = '';
|
3601 | gLanguage = '';
|
3602 | }
|
3603 | function getPluralRules(lang) {
|
3604 | var locales2rules = {
|
3605 | 'af': 3,
|
3606 | 'ak': 4,
|
3607 | 'am': 4,
|
3608 | 'ar': 1,
|
3609 | 'asa': 3,
|
3610 | 'az': 0,
|
3611 | 'be': 11,
|
3612 | 'bem': 3,
|
3613 | 'bez': 3,
|
3614 | 'bg': 3,
|
3615 | 'bh': 4,
|
3616 | 'bm': 0,
|
3617 | 'bn': 3,
|
3618 | 'bo': 0,
|
3619 | 'br': 20,
|
3620 | 'brx': 3,
|
3621 | 'bs': 11,
|
3622 | 'ca': 3,
|
3623 | 'cgg': 3,
|
3624 | 'chr': 3,
|
3625 | 'cs': 12,
|
3626 | 'cy': 17,
|
3627 | 'da': 3,
|
3628 | 'de': 3,
|
3629 | 'dv': 3,
|
3630 | 'dz': 0,
|
3631 | 'ee': 3,
|
3632 | 'el': 3,
|
3633 | 'en': 3,
|
3634 | 'eo': 3,
|
3635 | 'es': 3,
|
3636 | 'et': 3,
|
3637 | 'eu': 3,
|
3638 | 'fa': 0,
|
3639 | 'ff': 5,
|
3640 | 'fi': 3,
|
3641 | 'fil': 4,
|
3642 | 'fo': 3,
|
3643 | 'fr': 5,
|
3644 | 'fur': 3,
|
3645 | 'fy': 3,
|
3646 | 'ga': 8,
|
3647 | 'gd': 24,
|
3648 | 'gl': 3,
|
3649 | 'gsw': 3,
|
3650 | 'gu': 3,
|
3651 | 'guw': 4,
|
3652 | 'gv': 23,
|
3653 | 'ha': 3,
|
3654 | 'haw': 3,
|
3655 | 'he': 2,
|
3656 | 'hi': 4,
|
3657 | 'hr': 11,
|
3658 | 'hu': 0,
|
3659 | 'id': 0,
|
3660 | 'ig': 0,
|
3661 | 'ii': 0,
|
3662 | 'is': 3,
|
3663 | 'it': 3,
|
3664 | 'iu': 7,
|
3665 | 'ja': 0,
|
3666 | 'jmc': 3,
|
3667 | 'jv': 0,
|
3668 | 'ka': 0,
|
3669 | 'kab': 5,
|
3670 | 'kaj': 3,
|
3671 | 'kcg': 3,
|
3672 | 'kde': 0,
|
3673 | 'kea': 0,
|
3674 | 'kk': 3,
|
3675 | 'kl': 3,
|
3676 | 'km': 0,
|
3677 | 'kn': 0,
|
3678 | 'ko': 0,
|
3679 | 'ksb': 3,
|
3680 | 'ksh': 21,
|
3681 | 'ku': 3,
|
3682 | 'kw': 7,
|
3683 | 'lag': 18,
|
3684 | 'lb': 3,
|
3685 | 'lg': 3,
|
3686 | 'ln': 4,
|
3687 | 'lo': 0,
|
3688 | 'lt': 10,
|
3689 | 'lv': 6,
|
3690 | 'mas': 3,
|
3691 | 'mg': 4,
|
3692 | 'mk': 16,
|
3693 | 'ml': 3,
|
3694 | 'mn': 3,
|
3695 | 'mo': 9,
|
3696 | 'mr': 3,
|
3697 | 'ms': 0,
|
3698 | 'mt': 15,
|
3699 | 'my': 0,
|
3700 | 'nah': 3,
|
3701 | 'naq': 7,
|
3702 | 'nb': 3,
|
3703 | 'nd': 3,
|
3704 | 'ne': 3,
|
3705 | 'nl': 3,
|
3706 | 'nn': 3,
|
3707 | 'no': 3,
|
3708 | 'nr': 3,
|
3709 | 'nso': 4,
|
3710 | 'ny': 3,
|
3711 | 'nyn': 3,
|
3712 | 'om': 3,
|
3713 | 'or': 3,
|
3714 | 'pa': 3,
|
3715 | 'pap': 3,
|
3716 | 'pl': 13,
|
3717 | 'ps': 3,
|
3718 | 'pt': 3,
|
3719 | 'rm': 3,
|
3720 | 'ro': 9,
|
3721 | 'rof': 3,
|
3722 | 'ru': 11,
|
3723 | 'rwk': 3,
|
3724 | 'sah': 0,
|
3725 | 'saq': 3,
|
3726 | 'se': 7,
|
3727 | 'seh': 3,
|
3728 | 'ses': 0,
|
3729 | 'sg': 0,
|
3730 | 'sh': 11,
|
3731 | 'shi': 19,
|
3732 | 'sk': 12,
|
3733 | 'sl': 14,
|
3734 | 'sma': 7,
|
3735 | 'smi': 7,
|
3736 | 'smj': 7,
|
3737 | 'smn': 7,
|
3738 | 'sms': 7,
|
3739 | 'sn': 3,
|
3740 | 'so': 3,
|
3741 | 'sq': 3,
|
3742 | 'sr': 11,
|
3743 | 'ss': 3,
|
3744 | 'ssy': 3,
|
3745 | 'st': 3,
|
3746 | 'sv': 3,
|
3747 | 'sw': 3,
|
3748 | 'syr': 3,
|
3749 | 'ta': 3,
|
3750 | 'te': 3,
|
3751 | 'teo': 3,
|
3752 | 'th': 0,
|
3753 | 'ti': 4,
|
3754 | 'tig': 3,
|
3755 | 'tk': 3,
|
3756 | 'tl': 4,
|
3757 | 'tn': 3,
|
3758 | 'to': 0,
|
3759 | 'tr': 0,
|
3760 | 'ts': 3,
|
3761 | 'tzm': 22,
|
3762 | 'uk': 11,
|
3763 | 'ur': 3,
|
3764 | 've': 3,
|
3765 | 'vi': 0,
|
3766 | 'vun': 3,
|
3767 | 'wa': 4,
|
3768 | 'wae': 3,
|
3769 | 'wo': 0,
|
3770 | 'xh': 3,
|
3771 | 'xog': 3,
|
3772 | 'yo': 0,
|
3773 | 'zh': 0,
|
3774 | 'zu': 3
|
3775 | };
|
3776 | function isIn(n, list) {
|
3777 | return list.indexOf(n) !== -1;
|
3778 | }
|
3779 | function isBetween(n, start, end) {
|
3780 | return start <= n && n <= end;
|
3781 | }
|
3782 | var pluralRules = {
|
3783 | '0': function _(n) {
|
3784 | return 'other';
|
3785 | },
|
3786 | '1': function _(n) {
|
3787 | if (isBetween(n % 100, 3, 10)) return 'few';
|
3788 | if (n === 0) return 'zero';
|
3789 | if (isBetween(n % 100, 11, 99)) return 'many';
|
3790 | if (n == 2) return 'two';
|
3791 | if (n == 1) return 'one';
|
3792 | return 'other';
|
3793 | },
|
3794 | '2': function _(n) {
|
3795 | if (n !== 0 && n % 10 === 0) return 'many';
|
3796 | if (n == 2) return 'two';
|
3797 | if (n == 1) return 'one';
|
3798 | return 'other';
|
3799 | },
|
3800 | '3': function _(n) {
|
3801 | if (n == 1) return 'one';
|
3802 | return 'other';
|
3803 | },
|
3804 | '4': function _(n) {
|
3805 | if (isBetween(n, 0, 1)) return 'one';
|
3806 | return 'other';
|
3807 | },
|
3808 | '5': function _(n) {
|
3809 | if (isBetween(n, 0, 2) && n != 2) return 'one';
|
3810 | return 'other';
|
3811 | },
|
3812 | '6': function _(n) {
|
3813 | if (n === 0) return 'zero';
|
3814 | if (n % 10 == 1 && n % 100 != 11) return 'one';
|
3815 | return 'other';
|
3816 | },
|
3817 | '7': function _(n) {
|
3818 | if (n == 2) return 'two';
|
3819 | if (n == 1) return 'one';
|
3820 | return 'other';
|
3821 | },
|
3822 | '8': function _(n) {
|
3823 | if (isBetween(n, 3, 6)) return 'few';
|
3824 | if (isBetween(n, 7, 10)) return 'many';
|
3825 | if (n == 2) return 'two';
|
3826 | if (n == 1) return 'one';
|
3827 | return 'other';
|
3828 | },
|
3829 | '9': function _(n) {
|
3830 | if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
|
3831 | if (n == 1) return 'one';
|
3832 | return 'other';
|
3833 | },
|
3834 | '10': function _(n) {
|
3835 | if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
|
3836 | if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
|
3837 | return 'other';
|
3838 | },
|
3839 | '11': function _(n) {
|
3840 | if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
|
3841 | if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
|
3842 | if (n % 10 == 1 && n % 100 != 11) return 'one';
|
3843 | return 'other';
|
3844 | },
|
3845 | '12': function _(n) {
|
3846 | if (isBetween(n, 2, 4)) return 'few';
|
3847 | if (n == 1) return 'one';
|
3848 | return 'other';
|
3849 | },
|
3850 | '13': function _(n) {
|
3851 | if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
|
3852 | if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
|
3853 | if (n == 1) return 'one';
|
3854 | return 'other';
|
3855 | },
|
3856 | '14': function _(n) {
|
3857 | if (isBetween(n % 100, 3, 4)) return 'few';
|
3858 | if (n % 100 == 2) return 'two';
|
3859 | if (n % 100 == 1) return 'one';
|
3860 | return 'other';
|
3861 | },
|
3862 | '15': function _(n) {
|
3863 | if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
|
3864 | if (isBetween(n % 100, 11, 19)) return 'many';
|
3865 | if (n == 1) return 'one';
|
3866 | return 'other';
|
3867 | },
|
3868 | '16': function _(n) {
|
3869 | if (n % 10 == 1 && n != 11) return 'one';
|
3870 | return 'other';
|
3871 | },
|
3872 | '17': function _(n) {
|
3873 | if (n == 3) return 'few';
|
3874 | if (n === 0) return 'zero';
|
3875 | if (n == 6) return 'many';
|
3876 | if (n == 2) return 'two';
|
3877 | if (n == 1) return 'one';
|
3878 | return 'other';
|
3879 | },
|
3880 | '18': function _(n) {
|
3881 | if (n === 0) return 'zero';
|
3882 | if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
|
3883 | return 'other';
|
3884 | },
|
3885 | '19': function _(n) {
|
3886 | if (isBetween(n, 2, 10)) return 'few';
|
3887 | if (isBetween(n, 0, 1)) return 'one';
|
3888 | return 'other';
|
3889 | },
|
3890 | '20': function _(n) {
|
3891 | if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
|
3892 | if (n % 1000000 === 0 && n !== 0) return 'many';
|
3893 | if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
|
3894 | if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
|
3895 | return 'other';
|
3896 | },
|
3897 | '21': function _(n) {
|
3898 | if (n === 0) return 'zero';
|
3899 | if (n == 1) return 'one';
|
3900 | return 'other';
|
3901 | },
|
3902 | '22': function _(n) {
|
3903 | if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
|
3904 | return 'other';
|
3905 | },
|
3906 | '23': function _(n) {
|
3907 | if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
|
3908 | return 'other';
|
3909 | },
|
3910 | '24': function _(n) {
|
3911 | if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
|
3912 | if (isIn(n, [2, 12])) return 'two';
|
3913 | if (isIn(n, [1, 11])) return 'one';
|
3914 | return 'other';
|
3915 | }
|
3916 | };
|
3917 | var index = locales2rules[lang.replace(/-.*$/, '')];
|
3918 | if (!(index in pluralRules)) {
|
3919 | console.warn('plural form unknown for [' + lang + ']');
|
3920 | return function () {
|
3921 | return 'other';
|
3922 | };
|
3923 | }
|
3924 | return pluralRules[index];
|
3925 | }
|
3926 | gMacros.plural = function (str, param, key, prop) {
|
3927 | var n = parseFloat(param);
|
3928 | if (isNaN(n)) return str;
|
3929 | if (prop != gTextProp) return str;
|
3930 | if (!gMacros._pluralRules) {
|
3931 | gMacros._pluralRules = getPluralRules(gLanguage);
|
3932 | }
|
3933 | var index = '[' + gMacros._pluralRules(n) + ']';
|
3934 | if (n === 0 && key + '[zero]' in gL10nData) {
|
3935 | str = gL10nData[key + '[zero]'][prop];
|
3936 | } else if (n == 1 && key + '[one]' in gL10nData) {
|
3937 | str = gL10nData[key + '[one]'][prop];
|
3938 | } else if (n == 2 && key + '[two]' in gL10nData) {
|
3939 | str = gL10nData[key + '[two]'][prop];
|
3940 | } else if (key + index in gL10nData) {
|
3941 | str = gL10nData[key + index][prop];
|
3942 | } else if (key + '[other]' in gL10nData) {
|
3943 | str = gL10nData[key + '[other]'][prop];
|
3944 | }
|
3945 | return str;
|
3946 | };
|
3947 | function getL10nData(key, args, fallback) {
|
3948 | var data = gL10nData[key];
|
3949 | if (!data) {
|
3950 | console.warn('#' + key + ' is undefined.');
|
3951 | if (!fallback) {
|
3952 | return null;
|
3953 | }
|
3954 | data = fallback;
|
3955 | }
|
3956 | var rv = {};
|
3957 | for (var prop in data) {
|
3958 | var str = data[prop];
|
3959 | str = substIndexes(str, args, key, prop);
|
3960 | str = substArguments(str, args, key);
|
3961 | rv[prop] = str;
|
3962 | }
|
3963 | return rv;
|
3964 | }
|
3965 | function substIndexes(str, args, key, prop) {
|
3966 | var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
|
3967 | var reMatch = reIndex.exec(str);
|
3968 | if (!reMatch || !reMatch.length) return str;
|
3969 | var macroName = reMatch[1];
|
3970 | var paramName = reMatch[2];
|
3971 | var param;
|
3972 | if (args && paramName in args) {
|
3973 | param = args[paramName];
|
3974 | } else if (paramName in gL10nData) {
|
3975 | param = gL10nData[paramName];
|
3976 | }
|
3977 | if (macroName in gMacros) {
|
3978 | var macro = gMacros[macroName];
|
3979 | str = macro(str, param, key, prop);
|
3980 | }
|
3981 | return str;
|
3982 | }
|
3983 | function substArguments(str, args, key) {
|
3984 | var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
|
3985 | return str.replace(reArgs, function (matched_text, arg) {
|
3986 | if (args && arg in args) {
|
3987 | return args[arg];
|
3988 | }
|
3989 | if (arg in gL10nData) {
|
3990 | return gL10nData[arg];
|
3991 | }
|
3992 | console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
|
3993 | return matched_text;
|
3994 | });
|
3995 | }
|
3996 | function translateElement(element) {
|
3997 | var l10n = getL10nAttributes(element);
|
3998 | if (!l10n.id) return;
|
3999 | var data = getL10nData(l10n.id, l10n.args);
|
4000 | if (!data) {
|
4001 | console.warn('#' + l10n.id + ' is undefined.');
|
4002 | return;
|
4003 | }
|
4004 | if (data[gTextProp]) {
|
4005 | if (getChildElementCount(element) === 0) {
|
4006 | element[gTextProp] = data[gTextProp];
|
4007 | } else {
|
4008 | var children = element.childNodes;
|
4009 | var found = false;
|
4010 | for (var i = 0, l = children.length; i < l; i++) {
|
4011 | if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
|
4012 | if (found) {
|
4013 | children[i].nodeValue = '';
|
4014 | } else {
|
4015 | children[i].nodeValue = data[gTextProp];
|
4016 | found = true;
|
4017 | }
|
4018 | }
|
4019 | }
|
4020 | if (!found) {
|
4021 | var textNode = document.createTextNode(data[gTextProp]);
|
4022 | element.insertBefore(textNode, element.firstChild);
|
4023 | }
|
4024 | }
|
4025 | delete data[gTextProp];
|
4026 | }
|
4027 | for (var k in data) {
|
4028 | element[k] = data[k];
|
4029 | }
|
4030 | }
|
4031 | function getChildElementCount(element) {
|
4032 | if (element.children) {
|
4033 | return element.children.length;
|
4034 | }
|
4035 | if (typeof element.childElementCount !== 'undefined') {
|
4036 | return element.childElementCount;
|
4037 | }
|
4038 | var count = 0;
|
4039 | for (var i = 0; i < element.childNodes.length; i++) {
|
4040 | count += element.nodeType === 1 ? 1 : 0;
|
4041 | }
|
4042 | return count;
|
4043 | }
|
4044 | function translateFragment(element) {
|
4045 | element = element || document.documentElement;
|
4046 | var children = getTranslatableChildren(element);
|
4047 | var elementCount = children.length;
|
4048 | for (var i = 0; i < elementCount; i++) {
|
4049 | translateElement(children[i]);
|
4050 | }
|
4051 | translateElement(element);
|
4052 | }
|
4053 | return {
|
4054 | get: function get(key, args, fallbackString) {
|
4055 | var index = key.lastIndexOf('.');
|
4056 | var prop = gTextProp;
|
4057 | if (index > 0) {
|
4058 | prop = key.substr(index + 1);
|
4059 | key = key.substring(0, index);
|
4060 | }
|
4061 | var fallback;
|
4062 | if (fallbackString) {
|
4063 | fallback = {};
|
4064 | fallback[prop] = fallbackString;
|
4065 | }
|
4066 | var data = getL10nData(key, args, fallback);
|
4067 | if (data && prop in data) {
|
4068 | return data[prop];
|
4069 | }
|
4070 | return '{{' + key + '}}';
|
4071 | },
|
4072 | getData: function getData() {
|
4073 | return gL10nData;
|
4074 | },
|
4075 | getText: function getText() {
|
4076 | return gTextData;
|
4077 | },
|
4078 | getLanguage: function getLanguage() {
|
4079 | return gLanguage;
|
4080 | },
|
4081 | setLanguage: function setLanguage(lang, callback) {
|
4082 | loadLocale(lang, function () {
|
4083 | if (callback) callback();
|
4084 | });
|
4085 | },
|
4086 | getDirection: function getDirection() {
|
4087 | var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
|
4088 | var shortCode = gLanguage.split('-', 1)[0];
|
4089 | return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
|
4090 | },
|
4091 | translate: translateFragment,
|
4092 | getReadyState: function getReadyState() {
|
4093 | return gReadyState;
|
4094 | },
|
4095 | ready: function ready(callback) {
|
4096 | if (!callback) {
|
4097 | return;
|
4098 | } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
|
4099 | window.setTimeout(function () {
|
4100 | callback();
|
4101 | });
|
4102 | } else if (document.addEventListener) {
|
4103 | document.addEventListener('localized', function once() {
|
4104 | document.removeEventListener('localized', once);
|
4105 | callback();
|
4106 | });
|
4107 | }
|
4108 | }
|
4109 | };
|
4110 | }(window, document);
|
4111 |
|
4112 | }),
|
4113 |
|
4114 | (function(module, exports, __w_pdfjs_require__) {
|
4115 |
|
4116 | "use strict";
|
4117 |
|
4118 |
|
4119 | Object.defineProperty(exports, "__esModule", {
|
4120 | value: true
|
4121 | });
|
4122 | exports.PDFFindController = exports.FindState = undefined;
|
4123 |
|
4124 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
4125 |
|
4126 | var _pdfjsLib = __w_pdfjs_require__(1);
|
4127 |
|
4128 | var _ui_utils = __w_pdfjs_require__(0);
|
4129 |
|
4130 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4131 |
|
4132 | var FindState = {
|
4133 | FOUND: 0,
|
4134 | NOT_FOUND: 1,
|
4135 | WRAPPED: 2,
|
4136 | PENDING: 3
|
4137 | };
|
4138 | var FIND_SCROLL_OFFSET_TOP = -50;
|
4139 | var FIND_SCROLL_OFFSET_LEFT = -400;
|
4140 | var FIND_TIMEOUT = 250;
|
4141 | var CHARACTERS_TO_NORMALIZE = {
|
4142 | '\u2018': '\'',
|
4143 | '\u2019': '\'',
|
4144 | '\u201A': '\'',
|
4145 | '\u201B': '\'',
|
4146 | '\u201C': '"',
|
4147 | '\u201D': '"',
|
4148 | '\u201E': '"',
|
4149 | '\u201F': '"',
|
4150 | '\xBC': '1/4',
|
4151 | '\xBD': '1/2',
|
4152 | '\xBE': '3/4'
|
4153 | };
|
4154 |
|
4155 | var PDFFindController = function () {
|
4156 | function PDFFindController(_ref) {
|
4157 | var pdfViewer = _ref.pdfViewer;
|
4158 |
|
4159 | _classCallCheck(this, PDFFindController);
|
4160 |
|
4161 | this.pdfViewer = pdfViewer;
|
4162 | this.onUpdateResultsCount = null;
|
4163 | this.onUpdateState = null;
|
4164 | this.reset();
|
4165 | var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
|
4166 | this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
|
4167 | }
|
4168 |
|
4169 | _createClass(PDFFindController, [{
|
4170 | key: 'reset',
|
4171 | value: function reset() {
|
4172 | var _this = this;
|
4173 |
|
4174 | this.startedTextExtraction = false;
|
4175 | this.extractTextPromises = [];
|
4176 | this.pendingFindMatches = Object.create(null);
|
4177 | this.active = false;
|
4178 | this.pageContents = [];
|
4179 | this.pageMatches = [];
|
4180 | this.pageMatchesLength = null;
|
4181 | this.matchCount = 0;
|
4182 | this.selected = {
|
4183 | pageIdx: -1,
|
4184 | matchIdx: -1
|
4185 | };
|
4186 | this.offset = {
|
4187 | pageIdx: null,
|
4188 | matchIdx: null
|
4189 | };
|
4190 | this.pagesToSearch = null;
|
4191 | this.resumePageIdx = null;
|
4192 | this.state = null;
|
4193 | this.dirtyMatch = false;
|
4194 | this.findTimeout = null;
|
4195 | this._firstPagePromise = new Promise(function (resolve) {
|
4196 | _this.resolveFirstPage = resolve;
|
4197 | });
|
4198 | }
|
4199 | }, {
|
4200 | key: 'executeCommand',
|
4201 | value: function executeCommand(cmd, state) {
|
4202 | var _this2 = this;
|
4203 |
|
4204 | if (this.state === null || cmd !== 'findagain') {
|
4205 | this.dirtyMatch = true;
|
4206 | }
|
4207 | this.state = state;
|
4208 | this._updateUIState(FindState.PENDING);
|
4209 | this._firstPagePromise.then(function () {
|
4210 | _this2._extractText();
|
4211 | clearTimeout(_this2.findTimeout);
|
4212 | if (cmd === 'find') {
|
4213 | _this2.findTimeout = setTimeout(_this2._nextMatch.bind(_this2), FIND_TIMEOUT);
|
4214 | } else {
|
4215 | _this2._nextMatch();
|
4216 | }
|
4217 | });
|
4218 | }
|
4219 | }, {
|
4220 | key: 'updateMatchPosition',
|
4221 | value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
|
4222 | if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
|
4223 | var spot = {
|
4224 | top: FIND_SCROLL_OFFSET_TOP,
|
4225 | left: FIND_SCROLL_OFFSET_LEFT
|
4226 | };
|
4227 | (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
|
4228 | }
|
4229 | }
|
4230 | }, {
|
4231 | key: '_normalize',
|
4232 | value: function _normalize(text) {
|
4233 | return text.replace(this.normalizationRegex, function (ch) {
|
4234 | return CHARACTERS_TO_NORMALIZE[ch];
|
4235 | });
|
4236 | }
|
4237 | }, {
|
4238 | key: '_prepareMatches',
|
4239 | value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
|
4240 | function isSubTerm(matchesWithLength, currentIndex) {
|
4241 | var currentElem = matchesWithLength[currentIndex];
|
4242 | var nextElem = matchesWithLength[currentIndex + 1];
|
4243 | if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
|
4244 | currentElem.skipped = true;
|
4245 | return true;
|
4246 | }
|
4247 | for (var i = currentIndex - 1; i >= 0; i--) {
|
4248 | var prevElem = matchesWithLength[i];
|
4249 | if (prevElem.skipped) {
|
4250 | continue;
|
4251 | }
|
4252 | if (prevElem.match + prevElem.matchLength < currentElem.match) {
|
4253 | break;
|
4254 | }
|
4255 | if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
|
4256 | currentElem.skipped = true;
|
4257 | return true;
|
4258 | }
|
4259 | }
|
4260 | return false;
|
4261 | }
|
4262 | matchesWithLength.sort(function (a, b) {
|
4263 | return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
|
4264 | });
|
4265 | for (var i = 0, len = matchesWithLength.length; i < len; i++) {
|
4266 | if (isSubTerm(matchesWithLength, i)) {
|
4267 | continue;
|
4268 | }
|
4269 | matches.push(matchesWithLength[i].match);
|
4270 | matchesLength.push(matchesWithLength[i].matchLength);
|
4271 | }
|
4272 | }
|
4273 | }, {
|
4274 | key: '_calculatePhraseMatch',
|
4275 | value: function _calculatePhraseMatch(query, pageIndex, pageContent) {
|
4276 | var matches = [];
|
4277 | var queryLen = query.length;
|
4278 | var matchIdx = -queryLen;
|
4279 | while (true) {
|
4280 | matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
|
4281 | if (matchIdx === -1) {
|
4282 | break;
|
4283 | }
|
4284 | matches.push(matchIdx);
|
4285 | }
|
4286 | this.pageMatches[pageIndex] = matches;
|
4287 | }
|
4288 | }, {
|
4289 | key: '_calculateWordMatch',
|
4290 | value: function _calculateWordMatch(query, pageIndex, pageContent) {
|
4291 | var matchesWithLength = [];
|
4292 | var queryArray = query.match(/\S+/g);
|
4293 | for (var i = 0, len = queryArray.length; i < len; i++) {
|
4294 | var subquery = queryArray[i];
|
4295 | var subqueryLen = subquery.length;
|
4296 | var matchIdx = -subqueryLen;
|
4297 | while (true) {
|
4298 | matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
|
4299 | if (matchIdx === -1) {
|
4300 | break;
|
4301 | }
|
4302 | matchesWithLength.push({
|
4303 | match: matchIdx,
|
4304 | matchLength: subqueryLen,
|
4305 | skipped: false
|
4306 | });
|
4307 | }
|
4308 | }
|
4309 | if (!this.pageMatchesLength) {
|
4310 | this.pageMatchesLength = [];
|
4311 | }
|
4312 | this.pageMatchesLength[pageIndex] = [];
|
4313 | this.pageMatches[pageIndex] = [];
|
4314 | this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
|
4315 | }
|
4316 | }, {
|
4317 | key: '_calculateMatch',
|
4318 | value: function _calculateMatch(pageIndex) {
|
4319 | var pageContent = this._normalize(this.pageContents[pageIndex]);
|
4320 | var query = this._normalize(this.state.query);
|
4321 | var caseSensitive = this.state.caseSensitive;
|
4322 | var phraseSearch = this.state.phraseSearch;
|
4323 | var queryLen = query.length;
|
4324 | if (queryLen === 0) {
|
4325 | return;
|
4326 | }
|
4327 | if (!caseSensitive) {
|
4328 | pageContent = pageContent.toLowerCase();
|
4329 | query = query.toLowerCase();
|
4330 | }
|
4331 | if (phraseSearch) {
|
4332 | this._calculatePhraseMatch(query, pageIndex, pageContent);
|
4333 | } else {
|
4334 | this._calculateWordMatch(query, pageIndex, pageContent);
|
4335 | }
|
4336 | this._updatePage(pageIndex);
|
4337 | if (this.resumePageIdx === pageIndex) {
|
4338 | this.resumePageIdx = null;
|
4339 | this._nextPageMatch();
|
4340 | }
|
4341 | if (this.pageMatches[pageIndex].length > 0) {
|
4342 | this.matchCount += this.pageMatches[pageIndex].length;
|
4343 | this._updateUIResultsCount();
|
4344 | }
|
4345 | }
|
4346 | }, {
|
4347 | key: '_extractText',
|
4348 | value: function _extractText() {
|
4349 | var _this3 = this;
|
4350 |
|
4351 | if (this.startedTextExtraction) {
|
4352 | return;
|
4353 | }
|
4354 | this.startedTextExtraction = true;
|
4355 | this.pageContents.length = 0;
|
4356 | var promise = Promise.resolve();
|
4357 |
|
4358 | var _loop = function _loop(i, ii) {
|
4359 | var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
|
4360 | _this3.extractTextPromises[i] = extractTextCapability.promise;
|
4361 | promise = promise.then(function () {
|
4362 | return _this3.pdfViewer.getPageTextContent(i).then(function (textContent) {
|
4363 | var textItems = textContent.items;
|
4364 | var strBuf = [];
|
4365 | for (var j = 0, jj = textItems.length; j < jj; j++) {
|
4366 | strBuf.push(textItems[j].str);
|
4367 | }
|
4368 | _this3.pageContents[i] = strBuf.join('');
|
4369 | extractTextCapability.resolve(i);
|
4370 | }, function (reason) {
|
4371 | console.error('Unable to get page ' + (i + 1) + ' text content', reason);
|
4372 | _this3.pageContents[i] = '';
|
4373 | extractTextCapability.resolve(i);
|
4374 | });
|
4375 | });
|
4376 | };
|
4377 |
|
4378 | for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
|
4379 | _loop(i, ii);
|
4380 | }
|
4381 | }
|
4382 | }, {
|
4383 | key: '_updatePage',
|
4384 | value: function _updatePage(index) {
|
4385 | if (this.selected.pageIdx === index) {
|
4386 | this.pdfViewer.currentPageNumber = index + 1;
|
4387 | }
|
4388 | var page = this.pdfViewer.getPageView(index);
|
4389 | if (page.textLayer) {
|
4390 | page.textLayer.updateMatches();
|
4391 | }
|
4392 | }
|
4393 | }, {
|
4394 | key: '_nextMatch',
|
4395 | value: function _nextMatch() {
|
4396 | var _this4 = this;
|
4397 |
|
4398 | var previous = this.state.findPrevious;
|
4399 | var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
|
4400 | var numPages = this.pdfViewer.pagesCount;
|
4401 | this.active = true;
|
4402 | if (this.dirtyMatch) {
|
4403 | this.dirtyMatch = false;
|
4404 | this.selected.pageIdx = this.selected.matchIdx = -1;
|
4405 | this.offset.pageIdx = currentPageIndex;
|
4406 | this.offset.matchIdx = null;
|
4407 | this.hadMatch = false;
|
4408 | this.resumePageIdx = null;
|
4409 | this.pageMatches = [];
|
4410 | this.matchCount = 0;
|
4411 | this.pageMatchesLength = null;
|
4412 | for (var i = 0; i < numPages; i++) {
|
4413 | this._updatePage(i);
|
4414 | if (!(i in this.pendingFindMatches)) {
|
4415 | this.pendingFindMatches[i] = true;
|
4416 | this.extractTextPromises[i].then(function (pageIdx) {
|
4417 | delete _this4.pendingFindMatches[pageIdx];
|
4418 | _this4._calculateMatch(pageIdx);
|
4419 | });
|
4420 | }
|
4421 | }
|
4422 | }
|
4423 | if (this.state.query === '') {
|
4424 | this._updateUIState(FindState.FOUND);
|
4425 | return;
|
4426 | }
|
4427 | if (this.resumePageIdx) {
|
4428 | return;
|
4429 | }
|
4430 | var offset = this.offset;
|
4431 | this.pagesToSearch = numPages;
|
4432 | if (offset.matchIdx !== null) {
|
4433 | var numPageMatches = this.pageMatches[offset.pageIdx].length;
|
4434 | if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
|
4435 | this.hadMatch = true;
|
4436 | offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
|
4437 | this._updateMatch(true);
|
4438 | return;
|
4439 | }
|
4440 | this._advanceOffsetPage(previous);
|
4441 | }
|
4442 | this._nextPageMatch();
|
4443 | }
|
4444 | }, {
|
4445 | key: '_matchesReady',
|
4446 | value: function _matchesReady(matches) {
|
4447 | var offset = this.offset;
|
4448 | var numMatches = matches.length;
|
4449 | var previous = this.state.findPrevious;
|
4450 | if (numMatches) {
|
4451 | this.hadMatch = true;
|
4452 | offset.matchIdx = previous ? numMatches - 1 : 0;
|
4453 | this._updateMatch(true);
|
4454 | return true;
|
4455 | }
|
4456 | this._advanceOffsetPage(previous);
|
4457 | if (offset.wrapped) {
|
4458 | offset.matchIdx = null;
|
4459 | if (this.pagesToSearch < 0) {
|
4460 | this._updateMatch(false);
|
4461 | return true;
|
4462 | }
|
4463 | }
|
4464 | return false;
|
4465 | }
|
4466 | }, {
|
4467 | key: '_nextPageMatch',
|
4468 | value: function _nextPageMatch() {
|
4469 | if (this.resumePageIdx !== null) {
|
4470 | console.error('There can only be one pending page.');
|
4471 | }
|
4472 | var matches = null;
|
4473 | do {
|
4474 | var pageIdx = this.offset.pageIdx;
|
4475 | matches = this.pageMatches[pageIdx];
|
4476 | if (!matches) {
|
4477 | this.resumePageIdx = pageIdx;
|
4478 | break;
|
4479 | }
|
4480 | } while (!this._matchesReady(matches));
|
4481 | }
|
4482 | }, {
|
4483 | key: '_advanceOffsetPage',
|
4484 | value: function _advanceOffsetPage(previous) {
|
4485 | var offset = this.offset;
|
4486 | var numPages = this.extractTextPromises.length;
|
4487 | offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
|
4488 | offset.matchIdx = null;
|
4489 | this.pagesToSearch--;
|
4490 | if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
|
4491 | offset.pageIdx = previous ? numPages - 1 : 0;
|
4492 | offset.wrapped = true;
|
4493 | }
|
4494 | }
|
4495 | }, {
|
4496 | key: '_updateMatch',
|
4497 | value: function _updateMatch() {
|
4498 | var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
4499 |
|
4500 | var state = FindState.NOT_FOUND;
|
4501 | var wrapped = this.offset.wrapped;
|
4502 | this.offset.wrapped = false;
|
4503 | if (found) {
|
4504 | var previousPage = this.selected.pageIdx;
|
4505 | this.selected.pageIdx = this.offset.pageIdx;
|
4506 | this.selected.matchIdx = this.offset.matchIdx;
|
4507 | state = wrapped ? FindState.WRAPPED : FindState.FOUND;
|
4508 | if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
|
4509 | this._updatePage(previousPage);
|
4510 | }
|
4511 | }
|
4512 | this._updateUIState(state, this.state.findPrevious);
|
4513 | if (this.selected.pageIdx !== -1) {
|
4514 | this._updatePage(this.selected.pageIdx);
|
4515 | }
|
4516 | }
|
4517 | }, {
|
4518 | key: '_updateUIResultsCount',
|
4519 | value: function _updateUIResultsCount() {
|
4520 | if (this.onUpdateResultsCount) {
|
4521 | this.onUpdateResultsCount(this.matchCount);
|
4522 | }
|
4523 | }
|
4524 | }, {
|
4525 | key: '_updateUIState',
|
4526 | value: function _updateUIState(state, previous) {
|
4527 | if (this.onUpdateState) {
|
4528 | this.onUpdateState(state, previous, this.matchCount);
|
4529 | }
|
4530 | }
|
4531 | }]);
|
4532 |
|
4533 | return PDFFindController;
|
4534 | }();
|
4535 |
|
4536 | exports.FindState = FindState;
|
4537 | exports.PDFFindController = PDFFindController;
|
4538 |
|
4539 | }),
|
4540 |
|
4541 | (function(module, exports, __w_pdfjs_require__) {
|
4542 |
|
4543 | "use strict";
|
4544 |
|
4545 |
|
4546 | Object.defineProperty(exports, "__esModule", {
|
4547 | value: true
|
4548 | });
|
4549 | exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
|
4550 |
|
4551 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
4552 |
|
4553 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
4554 |
|
4555 | var _ui_utils = __w_pdfjs_require__(0);
|
4556 |
|
4557 | var _dom_events = __w_pdfjs_require__(2);
|
4558 |
|
4559 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4560 |
|
4561 | var HASH_CHANGE_TIMEOUT = 1000;
|
4562 | var POSITION_UPDATED_THRESHOLD = 50;
|
4563 | var UPDATE_VIEWAREA_TIMEOUT = 1000;
|
4564 | function getCurrentHash() {
|
4565 | return document.location.hash;
|
4566 | }
|
4567 | function parseCurrentHash(linkService) {
|
4568 | var hash = unescape(getCurrentHash()).substring(1);
|
4569 | var params = (0, _ui_utils.parseQueryString)(hash);
|
4570 | var page = params.page | 0;
|
4571 | if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
|
4572 | page = null;
|
4573 | }
|
4574 | return {
|
4575 | hash: hash,
|
4576 | page: page,
|
4577 | rotation: linkService.rotation
|
4578 | };
|
4579 | }
|
4580 |
|
4581 | var PDFHistory = function () {
|
4582 | function PDFHistory(_ref) {
|
4583 | var _this = this;
|
4584 |
|
4585 | var linkService = _ref.linkService,
|
4586 | eventBus = _ref.eventBus;
|
4587 |
|
4588 | _classCallCheck(this, PDFHistory);
|
4589 |
|
4590 | this.linkService = linkService;
|
4591 | this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
|
4592 | this.initialized = false;
|
4593 | this.initialBookmark = null;
|
4594 | this.initialRotation = null;
|
4595 | this._boundEvents = Object.create(null);
|
4596 | this._isViewerInPresentationMode = false;
|
4597 | this._isPagesLoaded = false;
|
4598 | this.eventBus.on('presentationmodechanged', function (evt) {
|
4599 | _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
|
4600 | });
|
4601 | this.eventBus.on('pagesloaded', function (evt) {
|
4602 | _this._isPagesLoaded = !!evt.pagesCount;
|
4603 | });
|
4604 | }
|
4605 |
|
4606 | _createClass(PDFHistory, [{
|
4607 | key: 'initialize',
|
4608 | value: function initialize(fingerprint) {
|
4609 | var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
4610 |
|
4611 | if (!fingerprint || typeof fingerprint !== 'string') {
|
4612 | console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
|
4613 | return;
|
4614 | }
|
4615 | var reInitialized = this.initialized && this.fingerprint !== fingerprint;
|
4616 | this.fingerprint = fingerprint;
|
4617 | if (!this.initialized) {
|
4618 | this._bindEvents();
|
4619 | }
|
4620 | var state = window.history.state;
|
4621 | this.initialized = true;
|
4622 | this.initialBookmark = null;
|
4623 | this.initialRotation = null;
|
4624 | this._popStateInProgress = false;
|
4625 | this._blockHashChange = 0;
|
4626 | this._currentHash = getCurrentHash();
|
4627 | this._numPositionUpdates = 0;
|
4628 | this._uid = this._maxUid = 0;
|
4629 | this._destination = null;
|
4630 | this._position = null;
|
4631 | if (!this._isValidState(state) || resetHistory) {
|
4632 | var _parseCurrentHash = parseCurrentHash(this.linkService),
|
4633 | hash = _parseCurrentHash.hash,
|
4634 | page = _parseCurrentHash.page,
|
4635 | rotation = _parseCurrentHash.rotation;
|
4636 |
|
4637 | if (!hash || reInitialized || resetHistory) {
|
4638 | this._pushOrReplaceState(null, true);
|
4639 | return;
|
4640 | }
|
4641 | this._pushOrReplaceState({
|
4642 | hash: hash,
|
4643 | page: page,
|
4644 | rotation: rotation
|
4645 | }, true);
|
4646 | return;
|
4647 | }
|
4648 | var destination = state.destination;
|
4649 | this._updateInternalState(destination, state.uid, true);
|
4650 | if (this._uid > this._maxUid) {
|
4651 | this._maxUid = this._uid;
|
4652 | }
|
4653 | if (destination.rotation !== undefined) {
|
4654 | this.initialRotation = destination.rotation;
|
4655 | }
|
4656 | if (destination.dest) {
|
4657 | this.initialBookmark = JSON.stringify(destination.dest);
|
4658 | this._destination.page = null;
|
4659 | } else if (destination.hash) {
|
4660 | this.initialBookmark = destination.hash;
|
4661 | } else if (destination.page) {
|
4662 | this.initialBookmark = 'page=' + destination.page;
|
4663 | }
|
4664 | }
|
4665 | }, {
|
4666 | key: 'push',
|
4667 | value: function push(_ref2) {
|
4668 | var _this2 = this;
|
4669 |
|
4670 | var namedDest = _ref2.namedDest,
|
4671 | explicitDest = _ref2.explicitDest,
|
4672 | pageNumber = _ref2.pageNumber;
|
4673 |
|
4674 | if (!this.initialized) {
|
4675 | return;
|
4676 | }
|
4677 | if (namedDest && typeof namedDest !== 'string' || !(explicitDest instanceof Array) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
|
4678 | console.error('PDFHistory.push: Invalid parameters.');
|
4679 | return;
|
4680 | }
|
4681 | var hash = namedDest || JSON.stringify(explicitDest);
|
4682 | if (!hash) {
|
4683 | return;
|
4684 | }
|
4685 | var forceReplace = false;
|
4686 | if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
|
4687 | if (this._destination.page) {
|
4688 | return;
|
4689 | }
|
4690 | forceReplace = true;
|
4691 | }
|
4692 | if (this._popStateInProgress && !forceReplace) {
|
4693 | return;
|
4694 | }
|
4695 | this._pushOrReplaceState({
|
4696 | dest: explicitDest,
|
4697 | hash: hash,
|
4698 | page: pageNumber,
|
4699 | rotation: this.linkService.rotation
|
4700 | }, forceReplace);
|
4701 | if (!this._popStateInProgress) {
|
4702 | this._popStateInProgress = true;
|
4703 | Promise.resolve().then(function () {
|
4704 | _this2._popStateInProgress = false;
|
4705 | });
|
4706 | }
|
4707 | }
|
4708 | }, {
|
4709 | key: 'pushCurrentPosition',
|
4710 | value: function pushCurrentPosition() {
|
4711 | if (!this.initialized || this._popStateInProgress) {
|
4712 | return;
|
4713 | }
|
4714 | this._tryPushCurrentPosition();
|
4715 | }
|
4716 | }, {
|
4717 | key: 'back',
|
4718 | value: function back() {
|
4719 | if (!this.initialized || this._popStateInProgress) {
|
4720 | return;
|
4721 | }
|
4722 | var state = window.history.state;
|
4723 | if (this._isValidState(state) && state.uid > 0) {
|
4724 | window.history.back();
|
4725 | }
|
4726 | }
|
4727 | }, {
|
4728 | key: 'forward',
|
4729 | value: function forward() {
|
4730 | if (!this.initialized || this._popStateInProgress) {
|
4731 | return;
|
4732 | }
|
4733 | var state = window.history.state;
|
4734 | if (this._isValidState(state) && state.uid < this._maxUid) {
|
4735 | window.history.forward();
|
4736 | }
|
4737 | }
|
4738 | }, {
|
4739 | key: '_pushOrReplaceState',
|
4740 | value: function _pushOrReplaceState(destination) {
|
4741 | var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
4742 |
|
4743 | var shouldReplace = forceReplace || !this._destination;
|
4744 | var newState = {
|
4745 | fingerprint: this.fingerprint,
|
4746 | uid: shouldReplace ? this._uid : this._uid + 1,
|
4747 | destination: destination
|
4748 | };
|
4749 | this._updateInternalState(destination, newState.uid);
|
4750 | if (shouldReplace) {
|
4751 | window.history.replaceState(newState, '');
|
4752 | } else {
|
4753 | this._maxUid = this._uid;
|
4754 | window.history.pushState(newState, '');
|
4755 | }
|
4756 | }
|
4757 | }, {
|
4758 | key: '_tryPushCurrentPosition',
|
4759 | value: function _tryPushCurrentPosition() {
|
4760 | var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
4761 |
|
4762 | if (!this._position) {
|
4763 | return;
|
4764 | }
|
4765 | var position = this._position;
|
4766 | if (temporary) {
|
4767 | position = (0, _ui_utils.cloneObj)(this._position);
|
4768 | position.temporary = true;
|
4769 | }
|
4770 | if (!this._destination) {
|
4771 | this._pushOrReplaceState(position);
|
4772 | return;
|
4773 | }
|
4774 | if (this._destination.temporary) {
|
4775 | this._pushOrReplaceState(position, true);
|
4776 | return;
|
4777 | }
|
4778 | if (this._destination.hash === position.hash) {
|
4779 | return;
|
4780 | }
|
4781 | if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
|
4782 | return;
|
4783 | }
|
4784 | var forceReplace = false;
|
4785 | if (this._destination.page === position.first || this._destination.page === position.page) {
|
4786 | if (this._destination.dest || !this._destination.first) {
|
4787 | return;
|
4788 | }
|
4789 | forceReplace = true;
|
4790 | }
|
4791 | this._pushOrReplaceState(position, forceReplace);
|
4792 | }
|
4793 | }, {
|
4794 | key: '_isValidState',
|
4795 | value: function _isValidState(state) {
|
4796 | if (!state) {
|
4797 | return false;
|
4798 | }
|
4799 | if (state.fingerprint !== this.fingerprint) {
|
4800 | return false;
|
4801 | }
|
4802 | if (!Number.isInteger(state.uid) || state.uid < 0) {
|
4803 | return false;
|
4804 | }
|
4805 | if (state.destination === null || _typeof(state.destination) !== 'object') {
|
4806 | return false;
|
4807 | }
|
4808 | return true;
|
4809 | }
|
4810 | }, {
|
4811 | key: '_updateInternalState',
|
4812 | value: function _updateInternalState(destination, uid) {
|
4813 | var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
4814 |
|
4815 | if (this._updateViewareaTimeout) {
|
4816 | clearTimeout(this._updateViewareaTimeout);
|
4817 | this._updateViewareaTimeout = null;
|
4818 | }
|
4819 | if (removeTemporary && destination && destination.temporary) {
|
4820 | delete destination.temporary;
|
4821 | }
|
4822 | this._destination = destination;
|
4823 | this._uid = uid;
|
4824 | this._numPositionUpdates = 0;
|
4825 | }
|
4826 | }, {
|
4827 | key: '_updateViewarea',
|
4828 | value: function _updateViewarea(_ref3) {
|
4829 | var _this3 = this;
|
4830 |
|
4831 | var location = _ref3.location;
|
4832 |
|
4833 | if (this._updateViewareaTimeout) {
|
4834 | clearTimeout(this._updateViewareaTimeout);
|
4835 | this._updateViewareaTimeout = null;
|
4836 | }
|
4837 | this._position = {
|
4838 | hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
|
4839 | page: this.linkService.page,
|
4840 | first: location.pageNumber,
|
4841 | rotation: location.rotation
|
4842 | };
|
4843 | if (this._popStateInProgress) {
|
4844 | return;
|
4845 | }
|
4846 | if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
|
4847 | this._numPositionUpdates++;
|
4848 | }
|
4849 | if (UPDATE_VIEWAREA_TIMEOUT > 0) {
|
4850 | this._updateViewareaTimeout = setTimeout(function () {
|
4851 | if (!_this3._popStateInProgress) {
|
4852 | _this3._tryPushCurrentPosition(true);
|
4853 | }
|
4854 | _this3._updateViewareaTimeout = null;
|
4855 | }, UPDATE_VIEWAREA_TIMEOUT);
|
4856 | }
|
4857 | }
|
4858 | }, {
|
4859 | key: '_popState',
|
4860 | value: function _popState(_ref4) {
|
4861 | var _this4 = this;
|
4862 |
|
4863 | var state = _ref4.state;
|
4864 |
|
4865 | var newHash = getCurrentHash(),
|
4866 | hashChanged = this._currentHash !== newHash;
|
4867 | this._currentHash = newHash;
|
4868 | if (!state || false) {
|
4869 | this._uid++;
|
4870 |
|
4871 | var _parseCurrentHash2 = parseCurrentHash(this.linkService),
|
4872 | hash = _parseCurrentHash2.hash,
|
4873 | page = _parseCurrentHash2.page,
|
4874 | rotation = _parseCurrentHash2.rotation;
|
4875 |
|
4876 | this._pushOrReplaceState({
|
4877 | hash: hash,
|
4878 | page: page,
|
4879 | rotation: rotation
|
4880 | }, true);
|
4881 | return;
|
4882 | }
|
4883 | if (!this._isValidState(state)) {
|
4884 | return;
|
4885 | }
|
4886 | this._popStateInProgress = true;
|
4887 | if (hashChanged) {
|
4888 | this._blockHashChange++;
|
4889 | (0, _ui_utils.waitOnEventOrTimeout)({
|
4890 | target: window,
|
4891 | name: 'hashchange',
|
4892 | delay: HASH_CHANGE_TIMEOUT
|
4893 | }).then(function () {
|
4894 | _this4._blockHashChange--;
|
4895 | });
|
4896 | }
|
4897 | var destination = state.destination;
|
4898 | this._updateInternalState(destination, state.uid, true);
|
4899 | if (this._uid > this._maxUid) {
|
4900 | this._maxUid = this._uid;
|
4901 | }
|
4902 | if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
|
4903 | this.linkService.rotation = destination.rotation;
|
4904 | }
|
4905 | if (destination.dest) {
|
4906 | this.linkService.navigateTo(destination.dest);
|
4907 | } else if (destination.hash) {
|
4908 | this.linkService.setHash(destination.hash);
|
4909 | } else if (destination.page) {
|
4910 | this.linkService.page = destination.page;
|
4911 | }
|
4912 | Promise.resolve().then(function () {
|
4913 | _this4._popStateInProgress = false;
|
4914 | });
|
4915 | }
|
4916 | }, {
|
4917 | key: '_bindEvents',
|
4918 | value: function _bindEvents() {
|
4919 | var _this5 = this;
|
4920 |
|
4921 | var _boundEvents = this._boundEvents,
|
4922 | eventBus = this.eventBus;
|
4923 |
|
4924 | _boundEvents.updateViewarea = this._updateViewarea.bind(this);
|
4925 | _boundEvents.popState = this._popState.bind(this);
|
4926 | _boundEvents.pageHide = function (evt) {
|
4927 | if (!_this5._destination || _this5._destination.temporary) {
|
4928 | _this5._tryPushCurrentPosition();
|
4929 | }
|
4930 | };
|
4931 | eventBus.on('updateviewarea', _boundEvents.updateViewarea);
|
4932 | window.addEventListener('popstate', _boundEvents.popState);
|
4933 | window.addEventListener('pagehide', _boundEvents.pageHide);
|
4934 | }
|
4935 | }, {
|
4936 | key: 'popStateInProgress',
|
4937 | get: function get() {
|
4938 | return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
|
4939 | }
|
4940 | }]);
|
4941 |
|
4942 | return PDFHistory;
|
4943 | }();
|
4944 |
|
4945 | function isDestHashesEqual(destHash, pushHash) {
|
4946 | if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
|
4947 | return false;
|
4948 | }
|
4949 | if (destHash === pushHash) {
|
4950 | return true;
|
4951 | }
|
4952 |
|
4953 | var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
|
4954 | nameddest = _parseQueryString.nameddest;
|
4955 |
|
4956 | if (nameddest === pushHash) {
|
4957 | return true;
|
4958 | }
|
4959 | return false;
|
4960 | }
|
4961 | function isDestArraysEqual(firstDest, secondDest) {
|
4962 | function isEntryEqual(first, second) {
|
4963 | if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
|
4964 | return false;
|
4965 | }
|
4966 | if (first instanceof Array || second instanceof Array) {
|
4967 | return false;
|
4968 | }
|
4969 | if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
|
4970 | if (Object.keys(first).length !== Object.keys(second).length) {
|
4971 | return false;
|
4972 | }
|
4973 | for (var key in first) {
|
4974 | if (!isEntryEqual(first[key], second[key])) {
|
4975 | return false;
|
4976 | }
|
4977 | }
|
4978 | return true;
|
4979 | }
|
4980 | return first === second || Number.isNaN(first) && Number.isNaN(second);
|
4981 | }
|
4982 | if (!(firstDest instanceof Array && secondDest instanceof Array)) {
|
4983 | return false;
|
4984 | }
|
4985 | if (firstDest.length !== secondDest.length) {
|
4986 | return false;
|
4987 | }
|
4988 | for (var i = 0, ii = firstDest.length; i < ii; i++) {
|
4989 | if (!isEntryEqual(firstDest[i], secondDest[i])) {
|
4990 | return false;
|
4991 | }
|
4992 | }
|
4993 | return true;
|
4994 | }
|
4995 | exports.PDFHistory = PDFHistory;
|
4996 | exports.isDestHashesEqual = isDestHashesEqual;
|
4997 | exports.isDestArraysEqual = isDestArraysEqual;
|
4998 |
|
4999 | }),
|
5000 |
|
5001 | (function(module, exports, __w_pdfjs_require__) {
|
5002 |
|
5003 | "use strict";
|
5004 |
|
5005 |
|
5006 | Object.defineProperty(exports, "__esModule", {
|
5007 | value: true
|
5008 | });
|
5009 | var compatibilityParams = Object.create(null);
|
5010 | {
|
5011 | var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
5012 | var isAndroid = /Android/.test(userAgent);
|
5013 | var isIE = /Trident/.test(userAgent);
|
5014 | var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
|
5015 | (function checkFullscreenSupport() {
|
5016 | if (isIE && window.parent !== window) {
|
5017 | compatibilityParams.disableFullscreen = true;
|
5018 | }
|
5019 | })();
|
5020 | (function checkCanvasSizeLimitation() {
|
5021 | if (isIOS || isAndroid) {
|
5022 | compatibilityParams.maxCanvasPixels = 5242880;
|
5023 | }
|
5024 | })();
|
5025 | }
|
5026 | var viewerCompatibilityParams = Object.freeze(compatibilityParams);
|
5027 | exports.viewerCompatibilityParams = viewerCompatibilityParams;
|
5028 |
|
5029 | }),
|
5030 |
|
5031 | (function(module, exports, __w_pdfjs_require__) {
|
5032 |
|
5033 | "use strict";
|
5034 |
|
5035 |
|
5036 | Object.defineProperty(exports, "__esModule", {
|
5037 | value: true
|
5038 | });
|
5039 | exports.PDFSinglePageViewer = undefined;
|
5040 |
|
5041 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
5042 |
|
5043 | var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
5044 |
|
5045 | var _base_viewer = __w_pdfjs_require__(8);
|
5046 |
|
5047 | var _ui_utils = __w_pdfjs_require__(0);
|
5048 |
|
5049 | var _pdfjsLib = __w_pdfjs_require__(1);
|
5050 |
|
5051 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5052 |
|
5053 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
5054 |
|
5055 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5056 |
|
5057 | var PDFSinglePageViewer = function (_BaseViewer) {
|
5058 | _inherits(PDFSinglePageViewer, _BaseViewer);
|
5059 |
|
5060 | function PDFSinglePageViewer(options) {
|
5061 | _classCallCheck(this, PDFSinglePageViewer);
|
5062 |
|
5063 | var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
|
5064 |
|
5065 | _this.eventBus.on('pagesinit', function (evt) {
|
5066 | _this._ensurePageViewVisible();
|
5067 | });
|
5068 | return _this;
|
5069 | }
|
5070 |
|
5071 | _createClass(PDFSinglePageViewer, [{
|
5072 | key: '_resetView',
|
5073 | value: function _resetView() {
|
5074 | _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
|
5075 | this._previousPageNumber = 1;
|
5076 | this._shadowViewer = document.createDocumentFragment();
|
5077 | }
|
5078 | }, {
|
5079 | key: '_ensurePageViewVisible',
|
5080 | value: function _ensurePageViewVisible() {
|
5081 | var pageView = this._pages[this._currentPageNumber - 1];
|
5082 | var previousPageView = this._pages[this._previousPageNumber - 1];
|
5083 | var viewerNodes = this.viewer.childNodes;
|
5084 | switch (viewerNodes.length) {
|
5085 | case 0:
|
5086 | this.viewer.appendChild(pageView.div);
|
5087 | break;
|
5088 | case 1:
|
5089 | if (viewerNodes[0] !== previousPageView.div) {
|
5090 | throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
|
5091 | }
|
5092 | if (pageView === previousPageView) {
|
5093 | break;
|
5094 | }
|
5095 | this._shadowViewer.appendChild(previousPageView.div);
|
5096 | this.viewer.appendChild(pageView.div);
|
5097 | this.container.scrollTop = 0;
|
5098 | break;
|
5099 | default:
|
5100 | throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
|
5101 | }
|
5102 | this._previousPageNumber = this._currentPageNumber;
|
5103 | }
|
5104 | }, {
|
5105 | key: '_scrollUpdate',
|
5106 | value: function _scrollUpdate() {
|
5107 | if (this._updateScrollDown) {
|
5108 | this._updateScrollDown();
|
5109 | }
|
5110 | _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
|
5111 | }
|
5112 | }, {
|
5113 | key: '_scrollIntoView',
|
5114 | value: function _scrollIntoView(_ref) {
|
5115 | var _this2 = this;
|
5116 |
|
5117 | var pageDiv = _ref.pageDiv,
|
5118 | _ref$pageSpot = _ref.pageSpot,
|
5119 | pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
|
5120 | _ref$pageNumber = _ref.pageNumber,
|
5121 | pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
|
5122 |
|
5123 | if (pageNumber) {
|
5124 | this._setCurrentPageNumber(pageNumber);
|
5125 | }
|
5126 | var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
|
5127 | var previousLocation = this._location;
|
5128 | this._ensurePageViewVisible();
|
5129 | (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
|
5130 | this._updateScrollDown = function () {
|
5131 | _this2.scroll.down = scrolledDown;
|
5132 | delete _this2._updateScrollDown;
|
5133 | };
|
5134 | setTimeout(function () {
|
5135 | if (_this2._location === previousLocation) {
|
5136 | if (_this2._updateScrollDown) {
|
5137 | _this2._updateScrollDown();
|
5138 | }
|
5139 | _this2.update();
|
5140 | }
|
5141 | }, 0);
|
5142 | }
|
5143 | }, {
|
5144 | key: '_getVisiblePages',
|
5145 | value: function _getVisiblePages() {
|
5146 | if (!this.pagesCount) {
|
5147 | return { views: [] };
|
5148 | }
|
5149 | var pageView = this._pages[this._currentPageNumber - 1];
|
5150 | var element = pageView.div;
|
5151 | var view = {
|
5152 | id: pageView.id,
|
5153 | x: element.offsetLeft + element.clientLeft,
|
5154 | y: element.offsetTop + element.clientTop,
|
5155 | view: pageView
|
5156 | };
|
5157 | return {
|
5158 | first: view,
|
5159 | last: view,
|
5160 | views: [view]
|
5161 | };
|
5162 | }
|
5163 | }, {
|
5164 | key: 'update',
|
5165 | value: function update() {
|
5166 | var visible = this._getVisiblePages();
|
5167 | var visiblePages = visible.views,
|
5168 | numVisiblePages = visiblePages.length;
|
5169 | if (numVisiblePages === 0) {
|
5170 | return;
|
5171 | }
|
5172 | this._resizeBuffer(numVisiblePages);
|
5173 | this.renderingQueue.renderHighestPriority(visible);
|
5174 | this._updateLocation(visible.first);
|
5175 | this.eventBus.dispatch('updateviewarea', {
|
5176 | source: this,
|
5177 | location: this._location
|
5178 | });
|
5179 | }
|
5180 | }, {
|
5181 | key: '_setDocumentViewerElement',
|
5182 | get: function get() {
|
5183 | return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
|
5184 | }
|
5185 | }]);
|
5186 |
|
5187 | return PDFSinglePageViewer;
|
5188 | }(_base_viewer.BaseViewer);
|
5189 |
|
5190 | exports.PDFSinglePageViewer = PDFSinglePageViewer;
|
5191 |
|
5192 | }),
|
5193 |
|
5194 | (function(module, exports, __w_pdfjs_require__) {
|
5195 |
|
5196 | "use strict";
|
5197 |
|
5198 |
|
5199 | Object.defineProperty(exports, "__esModule", {
|
5200 | value: true
|
5201 | });
|
5202 | exports.PDFViewer = undefined;
|
5203 |
|
5204 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
5205 |
|
5206 | var _ui_utils = __w_pdfjs_require__(0);
|
5207 |
|
5208 | var _base_viewer = __w_pdfjs_require__(8);
|
5209 |
|
5210 | var _pdfjsLib = __w_pdfjs_require__(1);
|
5211 |
|
5212 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5213 |
|
5214 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
5215 |
|
5216 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
5217 |
|
5218 | var PDFViewer = function (_BaseViewer) {
|
5219 | _inherits(PDFViewer, _BaseViewer);
|
5220 |
|
5221 | function PDFViewer() {
|
5222 | _classCallCheck(this, PDFViewer);
|
5223 |
|
5224 | return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
|
5225 | }
|
5226 |
|
5227 | _createClass(PDFViewer, [{
|
5228 | key: '_scrollIntoView',
|
5229 | value: function _scrollIntoView(_ref) {
|
5230 | var pageDiv = _ref.pageDiv,
|
5231 | _ref$pageSpot = _ref.pageSpot,
|
5232 | pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
|
5233 |
|
5234 | (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
|
5235 | }
|
5236 | }, {
|
5237 | key: '_getVisiblePages',
|
5238 | value: function _getVisiblePages() {
|
5239 | if (!this.isInPresentationMode) {
|
5240 | return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
|
5241 | }
|
5242 | var currentPage = this._pages[this._currentPageNumber - 1];
|
5243 | var visible = [{
|
5244 | id: currentPage.id,
|
5245 | view: currentPage
|
5246 | }];
|
5247 | return {
|
5248 | first: currentPage,
|
5249 | last: currentPage,
|
5250 | views: visible
|
5251 | };
|
5252 | }
|
5253 | }, {
|
5254 | key: 'update',
|
5255 | value: function update() {
|
5256 | var visible = this._getVisiblePages();
|
5257 | var visiblePages = visible.views,
|
5258 | numVisiblePages = visiblePages.length;
|
5259 | if (numVisiblePages === 0) {
|
5260 | return;
|
5261 | }
|
5262 | this._resizeBuffer(numVisiblePages);
|
5263 | this.renderingQueue.renderHighestPriority(visible);
|
5264 | var currentId = this._currentPageNumber;
|
5265 | var stillFullyVisible = false;
|
5266 | for (var i = 0; i < numVisiblePages; ++i) {
|
5267 | var page = visiblePages[i];
|
5268 | if (page.percent < 100) {
|
5269 | break;
|
5270 | }
|
5271 | if (page.id === currentId) {
|
5272 | stillFullyVisible = true;
|
5273 | break;
|
5274 | }
|
5275 | }
|
5276 | if (!stillFullyVisible) {
|
5277 | currentId = visiblePages[0].id;
|
5278 | }
|
5279 | if (!this.isInPresentationMode) {
|
5280 | this._setCurrentPageNumber(currentId);
|
5281 | }
|
5282 | this._updateLocation(visible.first);
|
5283 | this.eventBus.dispatch('updateviewarea', {
|
5284 | source: this,
|
5285 | location: this._location
|
5286 | });
|
5287 | }
|
5288 | }, {
|
5289 | key: '_setDocumentViewerElement',
|
5290 | get: function get() {
|
5291 | return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
|
5292 | }
|
5293 | }]);
|
5294 |
|
5295 | return PDFViewer;
|
5296 | }(_base_viewer.BaseViewer);
|
5297 |
|
5298 | exports.PDFViewer = PDFViewer;
|
5299 |
|
5300 | })
|
5301 | ]);
|
5302 | });
|
5303 |
|
\ | No newline at end of file |