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 | })(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, { enumerable: true, get: getter });
|
72 | }
|
73 | };
|
74 |
|
75 |
|
76 | __w_pdfjs_require__.r = function(exports) {
|
77 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
78 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
79 | }
|
80 | Object.defineProperty(exports, '__esModule', { value: true });
|
81 | };
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | __w_pdfjs_require__.t = function(value, mode) {
|
89 | if(mode & 1) value = __w_pdfjs_require__(value);
|
90 | if(mode & 8) return value;
|
91 | if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
92 | var ns = Object.create(null);
|
93 | __w_pdfjs_require__.r(ns);
|
94 | Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
95 | if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
96 | return ns;
|
97 | };
|
98 |
|
99 |
|
100 | __w_pdfjs_require__.n = function(module) {
|
101 | var getter = module && module.__esModule ?
|
102 | function getDefault() { return module['default']; } :
|
103 | function getModuleExports() { return module; };
|
104 | __w_pdfjs_require__.d(getter, 'a', getter);
|
105 | return getter;
|
106 | };
|
107 |
|
108 |
|
109 | __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
110 |
|
111 |
|
112 | __w_pdfjs_require__.p = "";
|
113 |
|
114 |
|
115 |
|
116 | return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
|
117 | })
|
118 |
|
119 | ([
|
120 |
|
121 | (function(module, exports, __w_pdfjs_require__) {
|
122 |
|
123 | "use strict";
|
124 |
|
125 |
|
126 | Object.defineProperty(exports, "__esModule", {
|
127 | value: true
|
128 | });
|
129 | Object.defineProperty(exports, "AnnotationLayerBuilder", {
|
130 | enumerable: true,
|
131 | get: function get() {
|
132 | return _annotation_layer_builder.AnnotationLayerBuilder;
|
133 | }
|
134 | });
|
135 | Object.defineProperty(exports, "DefaultAnnotationLayerFactory", {
|
136 | enumerable: true,
|
137 | get: function get() {
|
138 | return _annotation_layer_builder.DefaultAnnotationLayerFactory;
|
139 | }
|
140 | });
|
141 | Object.defineProperty(exports, "DefaultTextLayerFactory", {
|
142 | enumerable: true,
|
143 | get: function get() {
|
144 | return _text_layer_builder.DefaultTextLayerFactory;
|
145 | }
|
146 | });
|
147 | Object.defineProperty(exports, "TextLayerBuilder", {
|
148 | enumerable: true,
|
149 | get: function get() {
|
150 | return _text_layer_builder.TextLayerBuilder;
|
151 | }
|
152 | });
|
153 | Object.defineProperty(exports, "EventBus", {
|
154 | enumerable: true,
|
155 | get: function get() {
|
156 | return _ui_utils.EventBus;
|
157 | }
|
158 | });
|
159 | Object.defineProperty(exports, "NullL10n", {
|
160 | enumerable: true,
|
161 | get: function get() {
|
162 | return _ui_utils.NullL10n;
|
163 | }
|
164 | });
|
165 | Object.defineProperty(exports, "ProgressBar", {
|
166 | enumerable: true,
|
167 | get: function get() {
|
168 | return _ui_utils.ProgressBar;
|
169 | }
|
170 | });
|
171 | Object.defineProperty(exports, "PDFLinkService", {
|
172 | enumerable: true,
|
173 | get: function get() {
|
174 | return _pdf_link_service.PDFLinkService;
|
175 | }
|
176 | });
|
177 | Object.defineProperty(exports, "SimpleLinkService", {
|
178 | enumerable: true,
|
179 | get: function get() {
|
180 | return _pdf_link_service.SimpleLinkService;
|
181 | }
|
182 | });
|
183 | Object.defineProperty(exports, "DownloadManager", {
|
184 | enumerable: true,
|
185 | get: function get() {
|
186 | return _download_manager.DownloadManager;
|
187 | }
|
188 | });
|
189 | Object.defineProperty(exports, "GenericL10n", {
|
190 | enumerable: true,
|
191 | get: function get() {
|
192 | return _genericl10n.GenericL10n;
|
193 | }
|
194 | });
|
195 | Object.defineProperty(exports, "PDFFindController", {
|
196 | enumerable: true,
|
197 | get: function get() {
|
198 | return _pdf_find_controller.PDFFindController;
|
199 | }
|
200 | });
|
201 | Object.defineProperty(exports, "PDFHistory", {
|
202 | enumerable: true,
|
203 | get: function get() {
|
204 | return _pdf_history.PDFHistory;
|
205 | }
|
206 | });
|
207 | Object.defineProperty(exports, "PDFPageView", {
|
208 | enumerable: true,
|
209 | get: function get() {
|
210 | return _pdf_page_view.PDFPageView;
|
211 | }
|
212 | });
|
213 | Object.defineProperty(exports, "PDFSinglePageViewer", {
|
214 | enumerable: true,
|
215 | get: function get() {
|
216 | return _pdf_single_page_viewer.PDFSinglePageViewer;
|
217 | }
|
218 | });
|
219 | Object.defineProperty(exports, "PDFViewer", {
|
220 | enumerable: true,
|
221 | get: function get() {
|
222 | return _pdf_viewer.PDFViewer;
|
223 | }
|
224 | });
|
225 |
|
226 | var _annotation_layer_builder = __w_pdfjs_require__(1);
|
227 |
|
228 | var _text_layer_builder = __w_pdfjs_require__(8);
|
229 |
|
230 | var _ui_utils = __w_pdfjs_require__(3);
|
231 |
|
232 | var _pdf_link_service = __w_pdfjs_require__(7);
|
233 |
|
234 | var _download_manager = __w_pdfjs_require__(9);
|
235 |
|
236 | var _genericl10n = __w_pdfjs_require__(10);
|
237 |
|
238 | var _pdf_find_controller = __w_pdfjs_require__(12);
|
239 |
|
240 | var _pdf_history = __w_pdfjs_require__(14);
|
241 |
|
242 | var _pdf_page_view = __w_pdfjs_require__(15);
|
243 |
|
244 | var _pdf_single_page_viewer = __w_pdfjs_require__(18);
|
245 |
|
246 | var _pdf_viewer = __w_pdfjs_require__(20);
|
247 |
|
248 | var pdfjsVersion = '2.2.228';
|
249 | var pdfjsBuild = 'd7afb74a';
|
250 | (0, _ui_utils.getGlobalEventBus)(true);
|
251 |
|
252 | }),
|
253 |
|
254 | (function(module, exports, __w_pdfjs_require__) {
|
255 |
|
256 | "use strict";
|
257 |
|
258 |
|
259 | Object.defineProperty(exports, "__esModule", {
|
260 | value: true
|
261 | });
|
262 | exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
|
263 |
|
264 | var _pdfjsLib = __w_pdfjs_require__(2);
|
265 |
|
266 | var _ui_utils = __w_pdfjs_require__(3);
|
267 |
|
268 | var _pdf_link_service = __w_pdfjs_require__(7);
|
269 |
|
270 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
271 |
|
272 | 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); } }
|
273 |
|
274 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
275 |
|
276 | var AnnotationLayerBuilder =
|
277 |
|
278 | function () {
|
279 | function AnnotationLayerBuilder(_ref) {
|
280 | var pageDiv = _ref.pageDiv,
|
281 | pdfPage = _ref.pdfPage,
|
282 | linkService = _ref.linkService,
|
283 | downloadManager = _ref.downloadManager,
|
284 | _ref$imageResourcesPa = _ref.imageResourcesPath,
|
285 | imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
|
286 | _ref$renderInteractiv = _ref.renderInteractiveForms,
|
287 | renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
|
288 | _ref$l10n = _ref.l10n,
|
289 | l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
|
290 |
|
291 | _classCallCheck(this, AnnotationLayerBuilder);
|
292 |
|
293 | this.pageDiv = pageDiv;
|
294 | this.pdfPage = pdfPage;
|
295 | this.linkService = linkService;
|
296 | this.downloadManager = downloadManager;
|
297 | this.imageResourcesPath = imageResourcesPath;
|
298 | this.renderInteractiveForms = renderInteractiveForms;
|
299 | this.l10n = l10n;
|
300 | this.div = null;
|
301 | this._cancelled = false;
|
302 | }
|
303 |
|
304 | _createClass(AnnotationLayerBuilder, [{
|
305 | key: "render",
|
306 | value: function render(viewport) {
|
307 | var _this = this;
|
308 |
|
309 | var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
|
310 | this.pdfPage.getAnnotations({
|
311 | intent: intent
|
312 | }).then(function (annotations) {
|
313 | if (_this._cancelled) {
|
314 | return;
|
315 | }
|
316 |
|
317 | var parameters = {
|
318 | viewport: viewport.clone({
|
319 | dontFlip: true
|
320 | }),
|
321 | div: _this.div,
|
322 | annotations: annotations,
|
323 | page: _this.pdfPage,
|
324 | imageResourcesPath: _this.imageResourcesPath,
|
325 | renderInteractiveForms: _this.renderInteractiveForms,
|
326 | linkService: _this.linkService,
|
327 | downloadManager: _this.downloadManager
|
328 | };
|
329 |
|
330 | if (_this.div) {
|
331 | _pdfjsLib.AnnotationLayer.update(parameters);
|
332 | } else {
|
333 | if (annotations.length === 0) {
|
334 | return;
|
335 | }
|
336 |
|
337 | _this.div = document.createElement('div');
|
338 | _this.div.className = 'annotationLayer';
|
339 |
|
340 | _this.pageDiv.appendChild(_this.div);
|
341 |
|
342 | parameters.div = _this.div;
|
343 |
|
344 | _pdfjsLib.AnnotationLayer.render(parameters);
|
345 |
|
346 | _this.l10n.translate(_this.div);
|
347 | }
|
348 | });
|
349 | }
|
350 | }, {
|
351 | key: "cancel",
|
352 | value: function cancel() {
|
353 | this._cancelled = true;
|
354 | }
|
355 | }, {
|
356 | key: "hide",
|
357 | value: function hide() {
|
358 | if (!this.div) {
|
359 | return;
|
360 | }
|
361 |
|
362 | this.div.setAttribute('hidden', 'true');
|
363 | }
|
364 | }]);
|
365 |
|
366 | return AnnotationLayerBuilder;
|
367 | }();
|
368 |
|
369 | exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
|
370 |
|
371 | var DefaultAnnotationLayerFactory =
|
372 |
|
373 | function () {
|
374 | function DefaultAnnotationLayerFactory() {
|
375 | _classCallCheck(this, DefaultAnnotationLayerFactory);
|
376 | }
|
377 |
|
378 | _createClass(DefaultAnnotationLayerFactory, [{
|
379 | key: "createAnnotationLayerBuilder",
|
380 | value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
|
381 | var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
382 | var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
383 | var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
|
384 | return new AnnotationLayerBuilder({
|
385 | pageDiv: pageDiv,
|
386 | pdfPage: pdfPage,
|
387 | imageResourcesPath: imageResourcesPath,
|
388 | renderInteractiveForms: renderInteractiveForms,
|
389 | linkService: new _pdf_link_service.SimpleLinkService(),
|
390 | l10n: l10n
|
391 | });
|
392 | }
|
393 | }]);
|
394 |
|
395 | return DefaultAnnotationLayerFactory;
|
396 | }();
|
397 |
|
398 | exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
|
399 |
|
400 | }),
|
401 |
|
402 | (function(module, exports, __w_pdfjs_require__) {
|
403 |
|
404 | "use strict";
|
405 |
|
406 |
|
407 | var pdfjsLib;
|
408 |
|
409 | if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
|
410 | pdfjsLib = window['pdfjs-dist/build/pdf'];
|
411 | } else {
|
412 | pdfjsLib = require('../build/pdf.js');
|
413 | }
|
414 |
|
415 | module.exports = pdfjsLib;
|
416 |
|
417 | }),
|
418 |
|
419 | (function(module, exports, __w_pdfjs_require__) {
|
420 |
|
421 | "use strict";
|
422 |
|
423 |
|
424 | Object.defineProperty(exports, "__esModule", {
|
425 | value: true
|
426 | });
|
427 | exports.isValidRotation = isValidRotation;
|
428 | exports.isValidScrollMode = isValidScrollMode;
|
429 | exports.isValidSpreadMode = isValidSpreadMode;
|
430 | exports.isPortraitOrientation = isPortraitOrientation;
|
431 | exports.getGlobalEventBus = getGlobalEventBus;
|
432 | exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
433 | exports.noContextMenuHandler = noContextMenuHandler;
|
434 | exports.parseQueryString = parseQueryString;
|
435 | exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
|
436 | exports.getVisibleElements = getVisibleElements;
|
437 | exports.roundToDivide = roundToDivide;
|
438 | exports.getPageSizeInches = getPageSizeInches;
|
439 | exports.approximateFraction = approximateFraction;
|
440 | exports.getOutputScale = getOutputScale;
|
441 | exports.scrollIntoView = scrollIntoView;
|
442 | exports.watchScroll = watchScroll;
|
443 | exports.binarySearchFirstItem = binarySearchFirstItem;
|
444 | exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
445 | exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
|
446 | exports.moveToEndOfArray = moveToEndOfArray;
|
447 | exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = 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 = void 0;
|
448 |
|
449 | var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
|
450 |
|
451 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
452 |
|
453 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
454 |
|
455 | 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); } }
|
456 |
|
457 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
458 |
|
459 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
460 |
|
461 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
462 |
|
463 | function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
464 |
|
465 | function _iterableToArrayLimit(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"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
466 |
|
467 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
468 |
|
469 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
470 |
|
471 | function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
472 |
|
473 | var CSS_UNITS = 96.0 / 72.0;
|
474 | exports.CSS_UNITS = CSS_UNITS;
|
475 | var DEFAULT_SCALE_VALUE = 'auto';
|
476 | exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
477 | var DEFAULT_SCALE = 1.0;
|
478 | exports.DEFAULT_SCALE = DEFAULT_SCALE;
|
479 | var MIN_SCALE = 0.10;
|
480 | exports.MIN_SCALE = MIN_SCALE;
|
481 | var MAX_SCALE = 10.0;
|
482 | exports.MAX_SCALE = MAX_SCALE;
|
483 | var UNKNOWN_SCALE = 0;
|
484 | exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
|
485 | var MAX_AUTO_SCALE = 1.25;
|
486 | exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
|
487 | var SCROLLBAR_PADDING = 40;
|
488 | exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
489 | var VERTICAL_PADDING = 5;
|
490 | exports.VERTICAL_PADDING = VERTICAL_PADDING;
|
491 | var PresentationModeState = {
|
492 | UNKNOWN: 0,
|
493 | NORMAL: 1,
|
494 | CHANGING: 2,
|
495 | FULLSCREEN: 3
|
496 | };
|
497 | exports.PresentationModeState = PresentationModeState;
|
498 | var RendererType = {
|
499 | CANVAS: 'canvas',
|
500 | SVG: 'svg'
|
501 | };
|
502 | exports.RendererType = RendererType;
|
503 | var TextLayerMode = {
|
504 | DISABLE: 0,
|
505 | ENABLE: 1,
|
506 | ENABLE_ENHANCE: 2
|
507 | };
|
508 | exports.TextLayerMode = TextLayerMode;
|
509 | var ScrollMode = {
|
510 | UNKNOWN: -1,
|
511 | VERTICAL: 0,
|
512 | HORIZONTAL: 1,
|
513 | WRAPPED: 2
|
514 | };
|
515 | exports.ScrollMode = ScrollMode;
|
516 | var SpreadMode = {
|
517 | UNKNOWN: -1,
|
518 | NONE: 0,
|
519 | ODD: 1,
|
520 | EVEN: 2
|
521 | };
|
522 | exports.SpreadMode = SpreadMode;
|
523 |
|
524 | function formatL10nValue(text, args) {
|
525 | if (!args) {
|
526 | return text;
|
527 | }
|
528 |
|
529 | return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
|
530 | return name in args ? args[name] : '{{' + name + '}}';
|
531 | });
|
532 | }
|
533 |
|
534 | var NullL10n = {
|
535 | getLanguage: function () {
|
536 | var _getLanguage = _asyncToGenerator(
|
537 |
|
538 | _regenerator["default"].mark(function _callee() {
|
539 | return _regenerator["default"].wrap(function _callee$(_context) {
|
540 | while (1) {
|
541 | switch (_context.prev = _context.next) {
|
542 | case 0:
|
543 | return _context.abrupt("return", 'en-us');
|
544 |
|
545 | case 1:
|
546 | case "end":
|
547 | return _context.stop();
|
548 | }
|
549 | }
|
550 | }, _callee);
|
551 | }));
|
552 |
|
553 | function getLanguage() {
|
554 | return _getLanguage.apply(this, arguments);
|
555 | }
|
556 |
|
557 | return getLanguage;
|
558 | }(),
|
559 | getDirection: function () {
|
560 | var _getDirection = _asyncToGenerator(
|
561 |
|
562 | _regenerator["default"].mark(function _callee2() {
|
563 | return _regenerator["default"].wrap(function _callee2$(_context2) {
|
564 | while (1) {
|
565 | switch (_context2.prev = _context2.next) {
|
566 | case 0:
|
567 | return _context2.abrupt("return", 'ltr');
|
568 |
|
569 | case 1:
|
570 | case "end":
|
571 | return _context2.stop();
|
572 | }
|
573 | }
|
574 | }, _callee2);
|
575 | }));
|
576 |
|
577 | function getDirection() {
|
578 | return _getDirection.apply(this, arguments);
|
579 | }
|
580 |
|
581 | return getDirection;
|
582 | }(),
|
583 | get: function () {
|
584 | var _get = _asyncToGenerator(
|
585 |
|
586 | _regenerator["default"].mark(function _callee3(property, args, fallback) {
|
587 | return _regenerator["default"].wrap(function _callee3$(_context3) {
|
588 | while (1) {
|
589 | switch (_context3.prev = _context3.next) {
|
590 | case 0:
|
591 | return _context3.abrupt("return", formatL10nValue(fallback, args));
|
592 |
|
593 | case 1:
|
594 | case "end":
|
595 | return _context3.stop();
|
596 | }
|
597 | }
|
598 | }, _callee3);
|
599 | }));
|
600 |
|
601 | function get(_x, _x2, _x3) {
|
602 | return _get.apply(this, arguments);
|
603 | }
|
604 |
|
605 | return get;
|
606 | }(),
|
607 | translate: function () {
|
608 | var _translate = _asyncToGenerator(
|
609 |
|
610 | _regenerator["default"].mark(function _callee4(element) {
|
611 | return _regenerator["default"].wrap(function _callee4$(_context4) {
|
612 | while (1) {
|
613 | switch (_context4.prev = _context4.next) {
|
614 | case 0:
|
615 | case "end":
|
616 | return _context4.stop();
|
617 | }
|
618 | }
|
619 | }, _callee4);
|
620 | }));
|
621 |
|
622 | function translate(_x4) {
|
623 | return _translate.apply(this, arguments);
|
624 | }
|
625 |
|
626 | return translate;
|
627 | }()
|
628 | };
|
629 | exports.NullL10n = NullL10n;
|
630 |
|
631 | function getOutputScale(ctx) {
|
632 | var devicePixelRatio = window.devicePixelRatio || 1;
|
633 | var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
634 | var pixelRatio = devicePixelRatio / backingStoreRatio;
|
635 | return {
|
636 | sx: pixelRatio,
|
637 | sy: pixelRatio,
|
638 | scaled: pixelRatio !== 1
|
639 | };
|
640 | }
|
641 |
|
642 | function scrollIntoView(element, spot) {
|
643 | var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
644 | var parent = element.offsetParent;
|
645 |
|
646 | if (!parent) {
|
647 | console.error('offsetParent is not set -- cannot scroll');
|
648 | return;
|
649 | }
|
650 |
|
651 | var offsetY = element.offsetTop + element.clientTop;
|
652 | var offsetX = element.offsetLeft + element.clientLeft;
|
653 |
|
654 | while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
|
655 | if (parent.dataset._scaleY) {
|
656 | offsetY /= parent.dataset._scaleY;
|
657 | offsetX /= parent.dataset._scaleX;
|
658 | }
|
659 |
|
660 | offsetY += parent.offsetTop;
|
661 | offsetX += parent.offsetLeft;
|
662 | parent = parent.offsetParent;
|
663 |
|
664 | if (!parent) {
|
665 | return;
|
666 | }
|
667 | }
|
668 |
|
669 | if (spot) {
|
670 | if (spot.top !== undefined) {
|
671 | offsetY += spot.top;
|
672 | }
|
673 |
|
674 | if (spot.left !== undefined) {
|
675 | offsetX += spot.left;
|
676 | parent.scrollLeft = offsetX;
|
677 | }
|
678 | }
|
679 |
|
680 | parent.scrollTop = offsetY;
|
681 | }
|
682 |
|
683 | function watchScroll(viewAreaElement, callback) {
|
684 | var debounceScroll = function debounceScroll(evt) {
|
685 | if (rAF) {
|
686 | return;
|
687 | }
|
688 |
|
689 | rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
|
690 | rAF = null;
|
691 | var currentX = viewAreaElement.scrollLeft;
|
692 | var lastX = state.lastX;
|
693 |
|
694 | if (currentX !== lastX) {
|
695 | state.right = currentX > lastX;
|
696 | }
|
697 |
|
698 | state.lastX = currentX;
|
699 | var currentY = viewAreaElement.scrollTop;
|
700 | var lastY = state.lastY;
|
701 |
|
702 | if (currentY !== lastY) {
|
703 | state.down = currentY > lastY;
|
704 | }
|
705 |
|
706 | state.lastY = currentY;
|
707 | callback(state);
|
708 | });
|
709 | };
|
710 |
|
711 | var state = {
|
712 | right: true,
|
713 | down: true,
|
714 | lastX: viewAreaElement.scrollLeft,
|
715 | lastY: viewAreaElement.scrollTop,
|
716 | _eventHandler: debounceScroll
|
717 | };
|
718 | var rAF = null;
|
719 | viewAreaElement.addEventListener('scroll', debounceScroll, true);
|
720 | return state;
|
721 | }
|
722 |
|
723 | function parseQueryString(query) {
|
724 | var parts = query.split('&');
|
725 | var params = Object.create(null);
|
726 |
|
727 | for (var i = 0, ii = parts.length; i < ii; ++i) {
|
728 | var param = parts[i].split('=');
|
729 | var key = param[0].toLowerCase();
|
730 | var value = param.length > 1 ? param[1] : null;
|
731 | params[decodeURIComponent(key)] = decodeURIComponent(value);
|
732 | }
|
733 |
|
734 | return params;
|
735 | }
|
736 |
|
737 | function binarySearchFirstItem(items, condition) {
|
738 | var minIndex = 0;
|
739 | var maxIndex = items.length - 1;
|
740 |
|
741 | if (items.length === 0 || !condition(items[maxIndex])) {
|
742 | return items.length;
|
743 | }
|
744 |
|
745 | if (condition(items[minIndex])) {
|
746 | return minIndex;
|
747 | }
|
748 |
|
749 | while (minIndex < maxIndex) {
|
750 | var currentIndex = minIndex + maxIndex >> 1;
|
751 | var currentItem = items[currentIndex];
|
752 |
|
753 | if (condition(currentItem)) {
|
754 | maxIndex = currentIndex;
|
755 | } else {
|
756 | minIndex = currentIndex + 1;
|
757 | }
|
758 | }
|
759 |
|
760 | return minIndex;
|
761 | }
|
762 |
|
763 | function approximateFraction(x) {
|
764 | if (Math.floor(x) === x) {
|
765 | return [x, 1];
|
766 | }
|
767 |
|
768 | var xinv = 1 / x;
|
769 | var limit = 8;
|
770 |
|
771 | if (xinv > limit) {
|
772 | return [1, limit];
|
773 | } else if (Math.floor(xinv) === xinv) {
|
774 | return [1, xinv];
|
775 | }
|
776 |
|
777 | var x_ = x > 1 ? xinv : x;
|
778 | var a = 0,
|
779 | b = 1,
|
780 | c = 1,
|
781 | d = 1;
|
782 |
|
783 | while (true) {
|
784 | var p = a + c,
|
785 | q = b + d;
|
786 |
|
787 | if (q > limit) {
|
788 | break;
|
789 | }
|
790 |
|
791 | if (x_ <= p / q) {
|
792 | c = p;
|
793 | d = q;
|
794 | } else {
|
795 | a = p;
|
796 | b = q;
|
797 | }
|
798 | }
|
799 |
|
800 | var result;
|
801 |
|
802 | if (x_ - a / b < c / d - x_) {
|
803 | result = x_ === x ? [a, b] : [b, a];
|
804 | } else {
|
805 | result = x_ === x ? [c, d] : [d, c];
|
806 | }
|
807 |
|
808 | return result;
|
809 | }
|
810 |
|
811 | function roundToDivide(x, div) {
|
812 | var r = x % div;
|
813 | return r === 0 ? x : Math.round(x - r + div);
|
814 | }
|
815 |
|
816 | function getPageSizeInches(_ref) {
|
817 | var view = _ref.view,
|
818 | userUnit = _ref.userUnit,
|
819 | rotate = _ref.rotate;
|
820 |
|
821 | var _view = _slicedToArray(view, 4),
|
822 | x1 = _view[0],
|
823 | y1 = _view[1],
|
824 | x2 = _view[2],
|
825 | y2 = _view[3];
|
826 |
|
827 | var changeOrientation = rotate % 180 !== 0;
|
828 | var width = (x2 - x1) / 72 * userUnit;
|
829 | var height = (y2 - y1) / 72 * userUnit;
|
830 | return {
|
831 | width: changeOrientation ? height : width,
|
832 | height: changeOrientation ? width : height
|
833 | };
|
834 | }
|
835 |
|
836 | function backtrackBeforeAllVisibleElements(index, views, top) {
|
837 | if (index < 2) {
|
838 | return index;
|
839 | }
|
840 |
|
841 | var elt = views[index].div;
|
842 | var pageTop = elt.offsetTop + elt.clientTop;
|
843 |
|
844 | if (pageTop >= top) {
|
845 | elt = views[index - 1].div;
|
846 | pageTop = elt.offsetTop + elt.clientTop;
|
847 | }
|
848 |
|
849 | for (var i = index - 2; i >= 0; --i) {
|
850 | elt = views[i].div;
|
851 |
|
852 | if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
|
853 | break;
|
854 | }
|
855 |
|
856 | index = i;
|
857 | }
|
858 |
|
859 | return index;
|
860 | }
|
861 |
|
862 | function getVisibleElements(scrollEl, views) {
|
863 | var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
864 | var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
865 | var top = scrollEl.scrollTop,
|
866 | bottom = top + scrollEl.clientHeight;
|
867 | var left = scrollEl.scrollLeft,
|
868 | right = left + scrollEl.clientWidth;
|
869 |
|
870 | function isElementBottomAfterViewTop(view) {
|
871 | var element = view.div;
|
872 | var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
|
873 | return elementBottom > top;
|
874 | }
|
875 |
|
876 | function isElementRightAfterViewLeft(view) {
|
877 | var element = view.div;
|
878 | var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
|
879 | return elementRight > left;
|
880 | }
|
881 |
|
882 | var visible = [],
|
883 | numViews = views.length;
|
884 | var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
|
885 |
|
886 | if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
|
887 | firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
|
888 | }
|
889 |
|
890 | var lastEdge = horizontal ? right : -1;
|
891 |
|
892 | for (var i = firstVisibleElementInd; i < numViews; i++) {
|
893 | var view = views[i],
|
894 | element = view.div;
|
895 | var currentWidth = element.offsetLeft + element.clientLeft;
|
896 | var currentHeight = element.offsetTop + element.clientTop;
|
897 | var viewWidth = element.clientWidth,
|
898 | viewHeight = element.clientHeight;
|
899 | var viewRight = currentWidth + viewWidth;
|
900 | var viewBottom = currentHeight + viewHeight;
|
901 |
|
902 | if (lastEdge === -1) {
|
903 | if (viewBottom >= bottom) {
|
904 | lastEdge = viewBottom;
|
905 | }
|
906 | } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
|
907 | break;
|
908 | }
|
909 |
|
910 | if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
|
911 | continue;
|
912 | }
|
913 |
|
914 | var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
|
915 | var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
|
916 | var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
|
917 | visible.push({
|
918 | id: view.id,
|
919 | x: currentWidth,
|
920 | y: currentHeight,
|
921 | view: view,
|
922 | percent: percent
|
923 | });
|
924 | }
|
925 |
|
926 | var first = visible[0],
|
927 | last = visible[visible.length - 1];
|
928 |
|
929 | if (sortByVisibility) {
|
930 | visible.sort(function (a, b) {
|
931 | var pc = a.percent - b.percent;
|
932 |
|
933 | if (Math.abs(pc) > 0.001) {
|
934 | return -pc;
|
935 | }
|
936 |
|
937 | return a.id - b.id;
|
938 | });
|
939 | }
|
940 |
|
941 | return {
|
942 | first: first,
|
943 | last: last,
|
944 | views: visible
|
945 | };
|
946 | }
|
947 |
|
948 | function noContextMenuHandler(evt) {
|
949 | evt.preventDefault();
|
950 | }
|
951 |
|
952 | function isDataSchema(url) {
|
953 | var i = 0,
|
954 | ii = url.length;
|
955 |
|
956 | while (i < ii && url[i].trim() === '') {
|
957 | i++;
|
958 | }
|
959 |
|
960 | return url.substring(i, i + 5).toLowerCase() === 'data:';
|
961 | }
|
962 |
|
963 | function getPDFFileNameFromURL(url) {
|
964 | var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
|
965 |
|
966 | if (typeof url !== 'string') {
|
967 | return defaultFilename;
|
968 | }
|
969 |
|
970 | if (isDataSchema(url)) {
|
971 | console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
|
972 | return defaultFilename;
|
973 | }
|
974 |
|
975 | var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
976 | var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
977 | var splitURI = reURI.exec(url);
|
978 | var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
|
979 |
|
980 | if (suggestedFilename) {
|
981 | suggestedFilename = suggestedFilename[0];
|
982 |
|
983 | if (suggestedFilename.includes('%')) {
|
984 | try {
|
985 | suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
|
986 | } catch (ex) {}
|
987 | }
|
988 | }
|
989 |
|
990 | return suggestedFilename || defaultFilename;
|
991 | }
|
992 |
|
993 | function normalizeWheelEventDelta(evt) {
|
994 | var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
995 | var angle = Math.atan2(evt.deltaY, evt.deltaX);
|
996 |
|
997 | if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
|
998 | delta = -delta;
|
999 | }
|
1000 |
|
1001 | var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
|
1002 | var MOUSE_DOM_DELTA_LINE_MODE = 1;
|
1003 | var MOUSE_PIXELS_PER_LINE = 30;
|
1004 | var MOUSE_LINES_PER_PAGE = 30;
|
1005 |
|
1006 | if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
|
1007 | delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
|
1008 | } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
|
1009 | delta /= MOUSE_LINES_PER_PAGE;
|
1010 | }
|
1011 |
|
1012 | return delta;
|
1013 | }
|
1014 |
|
1015 | function isValidRotation(angle) {
|
1016 | return Number.isInteger(angle) && angle % 90 === 0;
|
1017 | }
|
1018 |
|
1019 | function isValidScrollMode(mode) {
|
1020 | return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
|
1021 | }
|
1022 |
|
1023 | function isValidSpreadMode(mode) {
|
1024 | return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
|
1025 | }
|
1026 |
|
1027 | function isPortraitOrientation(size) {
|
1028 | return size.width <= size.height;
|
1029 | }
|
1030 |
|
1031 | var WaitOnType = {
|
1032 | EVENT: 'event',
|
1033 | TIMEOUT: 'timeout'
|
1034 | };
|
1035 | exports.WaitOnType = WaitOnType;
|
1036 |
|
1037 | function waitOnEventOrTimeout(_ref2) {
|
1038 | var target = _ref2.target,
|
1039 | name = _ref2.name,
|
1040 | _ref2$delay = _ref2.delay,
|
1041 | delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
|
1042 | return new Promise(function (resolve, reject) {
|
1043 | if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
|
1044 | throw new Error('waitOnEventOrTimeout - invalid parameters.');
|
1045 | }
|
1046 |
|
1047 | function handler(type) {
|
1048 | if (target instanceof EventBus) {
|
1049 | target.off(name, eventHandler);
|
1050 | } else {
|
1051 | target.removeEventListener(name, eventHandler);
|
1052 | }
|
1053 |
|
1054 | if (timeout) {
|
1055 | clearTimeout(timeout);
|
1056 | }
|
1057 |
|
1058 | resolve(type);
|
1059 | }
|
1060 |
|
1061 | var eventHandler = handler.bind(null, WaitOnType.EVENT);
|
1062 |
|
1063 | if (target instanceof EventBus) {
|
1064 | target.on(name, eventHandler);
|
1065 | } else {
|
1066 | target.addEventListener(name, eventHandler);
|
1067 | }
|
1068 |
|
1069 | var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
|
1070 | var timeout = setTimeout(timeoutHandler, delay);
|
1071 | });
|
1072 | }
|
1073 |
|
1074 | var animationStarted = new Promise(function (resolve) {
|
1075 | window.requestAnimationFrame(resolve);
|
1076 | });
|
1077 | exports.animationStarted = animationStarted;
|
1078 |
|
1079 | var EventBus =
|
1080 |
|
1081 | function () {
|
1082 | function EventBus() {
|
1083 | var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1084 | _ref3$dispatchToDOM = _ref3.dispatchToDOM,
|
1085 | dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
|
1086 |
|
1087 | _classCallCheck(this, EventBus);
|
1088 |
|
1089 | this._listeners = Object.create(null);
|
1090 | this._dispatchToDOM = dispatchToDOM === true;
|
1091 | }
|
1092 |
|
1093 | _createClass(EventBus, [{
|
1094 | key: "on",
|
1095 | value: function on(eventName, listener) {
|
1096 | var eventListeners = this._listeners[eventName];
|
1097 |
|
1098 | if (!eventListeners) {
|
1099 | eventListeners = [];
|
1100 | this._listeners[eventName] = eventListeners;
|
1101 | }
|
1102 |
|
1103 | eventListeners.push(listener);
|
1104 | }
|
1105 | }, {
|
1106 | key: "off",
|
1107 | value: function off(eventName, listener) {
|
1108 | var eventListeners = this._listeners[eventName];
|
1109 | var i;
|
1110 |
|
1111 | if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
|
1112 | return;
|
1113 | }
|
1114 |
|
1115 | eventListeners.splice(i, 1);
|
1116 | }
|
1117 | }, {
|
1118 | key: "dispatch",
|
1119 | value: function dispatch(eventName) {
|
1120 | var eventListeners = this._listeners[eventName];
|
1121 |
|
1122 | if (!eventListeners || eventListeners.length === 0) {
|
1123 | if (this._dispatchToDOM) {
|
1124 | var _args5 = Array.prototype.slice.call(arguments, 1);
|
1125 |
|
1126 | this._dispatchDOMEvent(eventName, _args5);
|
1127 | }
|
1128 |
|
1129 | return;
|
1130 | }
|
1131 |
|
1132 | var args = Array.prototype.slice.call(arguments, 1);
|
1133 | eventListeners.slice(0).forEach(function (listener) {
|
1134 | listener.apply(null, args);
|
1135 | });
|
1136 |
|
1137 | if (this._dispatchToDOM) {
|
1138 | this._dispatchDOMEvent(eventName, args);
|
1139 | }
|
1140 | }
|
1141 | }, {
|
1142 | key: "_dispatchDOMEvent",
|
1143 | value: function _dispatchDOMEvent(eventName) {
|
1144 | var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
1145 | var details = Object.create(null);
|
1146 |
|
1147 | if (args && args.length > 0) {
|
1148 | var obj = args[0];
|
1149 |
|
1150 | for (var key in obj) {
|
1151 | var value = obj[key];
|
1152 |
|
1153 | if (key === 'source') {
|
1154 | if (value === window || value === document) {
|
1155 | return;
|
1156 | }
|
1157 |
|
1158 | continue;
|
1159 | }
|
1160 |
|
1161 | details[key] = value;
|
1162 | }
|
1163 | }
|
1164 |
|
1165 | var event = document.createEvent('CustomEvent');
|
1166 | event.initCustomEvent(eventName, true, true, details);
|
1167 | document.dispatchEvent(event);
|
1168 | }
|
1169 | }]);
|
1170 |
|
1171 | return EventBus;
|
1172 | }();
|
1173 |
|
1174 | exports.EventBus = EventBus;
|
1175 | var globalEventBus = null;
|
1176 |
|
1177 | function getGlobalEventBus() {
|
1178 | var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1179 |
|
1180 | if (!globalEventBus) {
|
1181 | globalEventBus = new EventBus({
|
1182 | dispatchToDOM: dispatchToDOM
|
1183 | });
|
1184 | }
|
1185 |
|
1186 | return globalEventBus;
|
1187 | }
|
1188 |
|
1189 | function clamp(v, min, max) {
|
1190 | return Math.min(Math.max(v, min), max);
|
1191 | }
|
1192 |
|
1193 | var ProgressBar =
|
1194 |
|
1195 | function () {
|
1196 | function ProgressBar(id) {
|
1197 | var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
1198 | height = _ref4.height,
|
1199 | width = _ref4.width,
|
1200 | units = _ref4.units;
|
1201 |
|
1202 | _classCallCheck(this, ProgressBar);
|
1203 |
|
1204 | this.visible = true;
|
1205 | this.div = document.querySelector(id + ' .progress');
|
1206 | this.bar = this.div.parentNode;
|
1207 | this.height = height || 100;
|
1208 | this.width = width || 100;
|
1209 | this.units = units || '%';
|
1210 | this.div.style.height = this.height + this.units;
|
1211 | this.percent = 0;
|
1212 | }
|
1213 |
|
1214 | _createClass(ProgressBar, [{
|
1215 | key: "_updateBar",
|
1216 | value: function _updateBar() {
|
1217 | if (this._indeterminate) {
|
1218 | this.div.classList.add('indeterminate');
|
1219 | this.div.style.width = this.width + this.units;
|
1220 | return;
|
1221 | }
|
1222 |
|
1223 | this.div.classList.remove('indeterminate');
|
1224 | var progressSize = this.width * this._percent / 100;
|
1225 | this.div.style.width = progressSize + this.units;
|
1226 | }
|
1227 | }, {
|
1228 | key: "setWidth",
|
1229 | value: function setWidth(viewer) {
|
1230 | if (!viewer) {
|
1231 | return;
|
1232 | }
|
1233 |
|
1234 | var container = viewer.parentNode;
|
1235 | var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
1236 |
|
1237 | if (scrollbarWidth > 0) {
|
1238 | this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
|
1239 | }
|
1240 | }
|
1241 | }, {
|
1242 | key: "hide",
|
1243 | value: function hide() {
|
1244 | if (!this.visible) {
|
1245 | return;
|
1246 | }
|
1247 |
|
1248 | this.visible = false;
|
1249 | this.bar.classList.add('hidden');
|
1250 | document.body.classList.remove('loadingInProgress');
|
1251 | }
|
1252 | }, {
|
1253 | key: "show",
|
1254 | value: function show() {
|
1255 | if (this.visible) {
|
1256 | return;
|
1257 | }
|
1258 |
|
1259 | this.visible = true;
|
1260 | document.body.classList.add('loadingInProgress');
|
1261 | this.bar.classList.remove('hidden');
|
1262 | }
|
1263 | }, {
|
1264 | key: "percent",
|
1265 | get: function get() {
|
1266 | return this._percent;
|
1267 | },
|
1268 | set: function set(val) {
|
1269 | this._indeterminate = isNaN(val);
|
1270 | this._percent = clamp(val, 0, 100);
|
1271 |
|
1272 | this._updateBar();
|
1273 | }
|
1274 | }]);
|
1275 |
|
1276 | return ProgressBar;
|
1277 | }();
|
1278 |
|
1279 | exports.ProgressBar = ProgressBar;
|
1280 |
|
1281 | function moveToEndOfArray(arr, condition) {
|
1282 | var moved = [],
|
1283 | len = arr.length;
|
1284 | var write = 0;
|
1285 |
|
1286 | for (var read = 0; read < len; ++read) {
|
1287 | if (condition(arr[read])) {
|
1288 | moved.push(arr[read]);
|
1289 | } else {
|
1290 | arr[write] = arr[read];
|
1291 | ++write;
|
1292 | }
|
1293 | }
|
1294 |
|
1295 | for (var _read = 0; write < len; ++_read, ++write) {
|
1296 | arr[write] = moved[_read];
|
1297 | }
|
1298 | }
|
1299 |
|
1300 | }),
|
1301 |
|
1302 | (function(module, exports, __w_pdfjs_require__) {
|
1303 |
|
1304 | "use strict";
|
1305 |
|
1306 |
|
1307 | module.exports = __w_pdfjs_require__(5);
|
1308 |
|
1309 | }),
|
1310 |
|
1311 | (function(module, exports, __w_pdfjs_require__) {
|
1312 |
|
1313 | "use strict";
|
1314 | (function(module) {
|
1315 |
|
1316 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
1317 |
|
1318 | var runtime = function (exports) {
|
1319 | "use strict";
|
1320 |
|
1321 | var Op = Object.prototype;
|
1322 | var hasOwn = Op.hasOwnProperty;
|
1323 | var undefined;
|
1324 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
1325 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
1326 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
1327 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
1328 |
|
1329 | function wrap(innerFn, outerFn, self, tryLocsList) {
|
1330 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
1331 | var generator = Object.create(protoGenerator.prototype);
|
1332 | var context = new Context(tryLocsList || []);
|
1333 | generator._invoke = makeInvokeMethod(innerFn, self, context);
|
1334 | return generator;
|
1335 | }
|
1336 |
|
1337 | exports.wrap = wrap;
|
1338 |
|
1339 | function tryCatch(fn, obj, arg) {
|
1340 | try {
|
1341 | return {
|
1342 | type: "normal",
|
1343 | arg: fn.call(obj, arg)
|
1344 | };
|
1345 | } catch (err) {
|
1346 | return {
|
1347 | type: "throw",
|
1348 | arg: err
|
1349 | };
|
1350 | }
|
1351 | }
|
1352 |
|
1353 | var GenStateSuspendedStart = "suspendedStart";
|
1354 | var GenStateSuspendedYield = "suspendedYield";
|
1355 | var GenStateExecuting = "executing";
|
1356 | var GenStateCompleted = "completed";
|
1357 | var ContinueSentinel = {};
|
1358 |
|
1359 | function Generator() {}
|
1360 |
|
1361 | function GeneratorFunction() {}
|
1362 |
|
1363 | function GeneratorFunctionPrototype() {}
|
1364 |
|
1365 | var IteratorPrototype = {};
|
1366 |
|
1367 | IteratorPrototype[iteratorSymbol] = function () {
|
1368 | return this;
|
1369 | };
|
1370 |
|
1371 | var getProto = Object.getPrototypeOf;
|
1372 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
1373 |
|
1374 | if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
1375 | IteratorPrototype = NativeIteratorPrototype;
|
1376 | }
|
1377 |
|
1378 | var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
1379 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
1380 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
1381 | GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
|
1382 |
|
1383 | function defineIteratorMethods(prototype) {
|
1384 | ["next", "throw", "return"].forEach(function (method) {
|
1385 | prototype[method] = function (arg) {
|
1386 | return this._invoke(method, arg);
|
1387 | };
|
1388 | });
|
1389 | }
|
1390 |
|
1391 | exports.isGeneratorFunction = function (genFun) {
|
1392 | var ctor = typeof genFun === "function" && genFun.constructor;
|
1393 | return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
1394 | };
|
1395 |
|
1396 | exports.mark = function (genFun) {
|
1397 | if (Object.setPrototypeOf) {
|
1398 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
1399 | } else {
|
1400 | genFun.__proto__ = GeneratorFunctionPrototype;
|
1401 |
|
1402 | if (!(toStringTagSymbol in genFun)) {
|
1403 | genFun[toStringTagSymbol] = "GeneratorFunction";
|
1404 | }
|
1405 | }
|
1406 |
|
1407 | genFun.prototype = Object.create(Gp);
|
1408 | return genFun;
|
1409 | };
|
1410 |
|
1411 | exports.awrap = function (arg) {
|
1412 | return {
|
1413 | __await: arg
|
1414 | };
|
1415 | };
|
1416 |
|
1417 | function AsyncIterator(generator) {
|
1418 | function invoke(method, arg, resolve, reject) {
|
1419 | var record = tryCatch(generator[method], generator, arg);
|
1420 |
|
1421 | if (record.type === "throw") {
|
1422 | reject(record.arg);
|
1423 | } else {
|
1424 | var result = record.arg;
|
1425 | var value = result.value;
|
1426 |
|
1427 | if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
|
1428 | return Promise.resolve(value.__await).then(function (value) {
|
1429 | invoke("next", value, resolve, reject);
|
1430 | }, function (err) {
|
1431 | invoke("throw", err, resolve, reject);
|
1432 | });
|
1433 | }
|
1434 |
|
1435 | return Promise.resolve(value).then(function (unwrapped) {
|
1436 | result.value = unwrapped;
|
1437 | resolve(result);
|
1438 | }, function (error) {
|
1439 | return invoke("throw", error, resolve, reject);
|
1440 | });
|
1441 | }
|
1442 | }
|
1443 |
|
1444 | var previousPromise;
|
1445 |
|
1446 | function enqueue(method, arg) {
|
1447 | function callInvokeWithMethodAndArg() {
|
1448 | return new Promise(function (resolve, reject) {
|
1449 | invoke(method, arg, resolve, reject);
|
1450 | });
|
1451 | }
|
1452 |
|
1453 | return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
1454 | }
|
1455 |
|
1456 | this._invoke = enqueue;
|
1457 | }
|
1458 |
|
1459 | defineIteratorMethods(AsyncIterator.prototype);
|
1460 |
|
1461 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
1462 | return this;
|
1463 | };
|
1464 |
|
1465 | exports.AsyncIterator = AsyncIterator;
|
1466 |
|
1467 | exports.async = function (innerFn, outerFn, self, tryLocsList) {
|
1468 | var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
|
1469 | return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
1470 | return result.done ? result.value : iter.next();
|
1471 | });
|
1472 | };
|
1473 |
|
1474 | function makeInvokeMethod(innerFn, self, context) {
|
1475 | var state = GenStateSuspendedStart;
|
1476 | return function invoke(method, arg) {
|
1477 | if (state === GenStateExecuting) {
|
1478 | throw new Error("Generator is already running");
|
1479 | }
|
1480 |
|
1481 | if (state === GenStateCompleted) {
|
1482 | if (method === "throw") {
|
1483 | throw arg;
|
1484 | }
|
1485 |
|
1486 | return doneResult();
|
1487 | }
|
1488 |
|
1489 | context.method = method;
|
1490 | context.arg = arg;
|
1491 |
|
1492 | while (true) {
|
1493 | var delegate = context.delegate;
|
1494 |
|
1495 | if (delegate) {
|
1496 | var delegateResult = maybeInvokeDelegate(delegate, context);
|
1497 |
|
1498 | if (delegateResult) {
|
1499 | if (delegateResult === ContinueSentinel) continue;
|
1500 | return delegateResult;
|
1501 | }
|
1502 | }
|
1503 |
|
1504 | if (context.method === "next") {
|
1505 | context.sent = context._sent = context.arg;
|
1506 | } else if (context.method === "throw") {
|
1507 | if (state === GenStateSuspendedStart) {
|
1508 | state = GenStateCompleted;
|
1509 | throw context.arg;
|
1510 | }
|
1511 |
|
1512 | context.dispatchException(context.arg);
|
1513 | } else if (context.method === "return") {
|
1514 | context.abrupt("return", context.arg);
|
1515 | }
|
1516 |
|
1517 | state = GenStateExecuting;
|
1518 | var record = tryCatch(innerFn, self, context);
|
1519 |
|
1520 | if (record.type === "normal") {
|
1521 | state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
1522 |
|
1523 | if (record.arg === ContinueSentinel) {
|
1524 | continue;
|
1525 | }
|
1526 |
|
1527 | return {
|
1528 | value: record.arg,
|
1529 | done: context.done
|
1530 | };
|
1531 | } else if (record.type === "throw") {
|
1532 | state = GenStateCompleted;
|
1533 | context.method = "throw";
|
1534 | context.arg = record.arg;
|
1535 | }
|
1536 | }
|
1537 | };
|
1538 | }
|
1539 |
|
1540 | function maybeInvokeDelegate(delegate, context) {
|
1541 | var method = delegate.iterator[context.method];
|
1542 |
|
1543 | if (method === undefined) {
|
1544 | context.delegate = null;
|
1545 |
|
1546 | if (context.method === "throw") {
|
1547 | if (delegate.iterator["return"]) {
|
1548 | context.method = "return";
|
1549 | context.arg = undefined;
|
1550 | maybeInvokeDelegate(delegate, context);
|
1551 |
|
1552 | if (context.method === "throw") {
|
1553 | return ContinueSentinel;
|
1554 | }
|
1555 | }
|
1556 |
|
1557 | context.method = "throw";
|
1558 | context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
1559 | }
|
1560 |
|
1561 | return ContinueSentinel;
|
1562 | }
|
1563 |
|
1564 | var record = tryCatch(method, delegate.iterator, context.arg);
|
1565 |
|
1566 | if (record.type === "throw") {
|
1567 | context.method = "throw";
|
1568 | context.arg = record.arg;
|
1569 | context.delegate = null;
|
1570 | return ContinueSentinel;
|
1571 | }
|
1572 |
|
1573 | var info = record.arg;
|
1574 |
|
1575 | if (!info) {
|
1576 | context.method = "throw";
|
1577 | context.arg = new TypeError("iterator result is not an object");
|
1578 | context.delegate = null;
|
1579 | return ContinueSentinel;
|
1580 | }
|
1581 |
|
1582 | if (info.done) {
|
1583 | context[delegate.resultName] = info.value;
|
1584 | context.next = delegate.nextLoc;
|
1585 |
|
1586 | if (context.method !== "return") {
|
1587 | context.method = "next";
|
1588 | context.arg = undefined;
|
1589 | }
|
1590 | } else {
|
1591 | return info;
|
1592 | }
|
1593 |
|
1594 | context.delegate = null;
|
1595 | return ContinueSentinel;
|
1596 | }
|
1597 |
|
1598 | defineIteratorMethods(Gp);
|
1599 | Gp[toStringTagSymbol] = "Generator";
|
1600 |
|
1601 | Gp[iteratorSymbol] = function () {
|
1602 | return this;
|
1603 | };
|
1604 |
|
1605 | Gp.toString = function () {
|
1606 | return "[object Generator]";
|
1607 | };
|
1608 |
|
1609 | function pushTryEntry(locs) {
|
1610 | var entry = {
|
1611 | tryLoc: locs[0]
|
1612 | };
|
1613 |
|
1614 | if (1 in locs) {
|
1615 | entry.catchLoc = locs[1];
|
1616 | }
|
1617 |
|
1618 | if (2 in locs) {
|
1619 | entry.finallyLoc = locs[2];
|
1620 | entry.afterLoc = locs[3];
|
1621 | }
|
1622 |
|
1623 | this.tryEntries.push(entry);
|
1624 | }
|
1625 |
|
1626 | function resetTryEntry(entry) {
|
1627 | var record = entry.completion || {};
|
1628 | record.type = "normal";
|
1629 | delete record.arg;
|
1630 | entry.completion = record;
|
1631 | }
|
1632 |
|
1633 | function Context(tryLocsList) {
|
1634 | this.tryEntries = [{
|
1635 | tryLoc: "root"
|
1636 | }];
|
1637 | tryLocsList.forEach(pushTryEntry, this);
|
1638 | this.reset(true);
|
1639 | }
|
1640 |
|
1641 | exports.keys = function (object) {
|
1642 | var keys = [];
|
1643 |
|
1644 | for (var key in object) {
|
1645 | keys.push(key);
|
1646 | }
|
1647 |
|
1648 | keys.reverse();
|
1649 | return function next() {
|
1650 | while (keys.length) {
|
1651 | var key = keys.pop();
|
1652 |
|
1653 | if (key in object) {
|
1654 | next.value = key;
|
1655 | next.done = false;
|
1656 | return next;
|
1657 | }
|
1658 | }
|
1659 |
|
1660 | next.done = true;
|
1661 | return next;
|
1662 | };
|
1663 | };
|
1664 |
|
1665 | function values(iterable) {
|
1666 | if (iterable) {
|
1667 | var iteratorMethod = iterable[iteratorSymbol];
|
1668 |
|
1669 | if (iteratorMethod) {
|
1670 | return iteratorMethod.call(iterable);
|
1671 | }
|
1672 |
|
1673 | if (typeof iterable.next === "function") {
|
1674 | return iterable;
|
1675 | }
|
1676 |
|
1677 | if (!isNaN(iterable.length)) {
|
1678 | var i = -1,
|
1679 | next = function next() {
|
1680 | while (++i < iterable.length) {
|
1681 | if (hasOwn.call(iterable, i)) {
|
1682 | next.value = iterable[i];
|
1683 | next.done = false;
|
1684 | return next;
|
1685 | }
|
1686 | }
|
1687 |
|
1688 | next.value = undefined;
|
1689 | next.done = true;
|
1690 | return next;
|
1691 | };
|
1692 |
|
1693 | return next.next = next;
|
1694 | }
|
1695 | }
|
1696 |
|
1697 | return {
|
1698 | next: doneResult
|
1699 | };
|
1700 | }
|
1701 |
|
1702 | exports.values = values;
|
1703 |
|
1704 | function doneResult() {
|
1705 | return {
|
1706 | value: undefined,
|
1707 | done: true
|
1708 | };
|
1709 | }
|
1710 |
|
1711 | Context.prototype = {
|
1712 | constructor: Context,
|
1713 | reset: function reset(skipTempReset) {
|
1714 | this.prev = 0;
|
1715 | this.next = 0;
|
1716 | this.sent = this._sent = undefined;
|
1717 | this.done = false;
|
1718 | this.delegate = null;
|
1719 | this.method = "next";
|
1720 | this.arg = undefined;
|
1721 | this.tryEntries.forEach(resetTryEntry);
|
1722 |
|
1723 | if (!skipTempReset) {
|
1724 | for (var name in this) {
|
1725 | if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
1726 | this[name] = undefined;
|
1727 | }
|
1728 | }
|
1729 | }
|
1730 | },
|
1731 | stop: function stop() {
|
1732 | this.done = true;
|
1733 | var rootEntry = this.tryEntries[0];
|
1734 | var rootRecord = rootEntry.completion;
|
1735 |
|
1736 | if (rootRecord.type === "throw") {
|
1737 | throw rootRecord.arg;
|
1738 | }
|
1739 |
|
1740 | return this.rval;
|
1741 | },
|
1742 | dispatchException: function dispatchException(exception) {
|
1743 | if (this.done) {
|
1744 | throw exception;
|
1745 | }
|
1746 |
|
1747 | var context = this;
|
1748 |
|
1749 | function handle(loc, caught) {
|
1750 | record.type = "throw";
|
1751 | record.arg = exception;
|
1752 | context.next = loc;
|
1753 |
|
1754 | if (caught) {
|
1755 | context.method = "next";
|
1756 | context.arg = undefined;
|
1757 | }
|
1758 |
|
1759 | return !!caught;
|
1760 | }
|
1761 |
|
1762 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1763 | var entry = this.tryEntries[i];
|
1764 | var record = entry.completion;
|
1765 |
|
1766 | if (entry.tryLoc === "root") {
|
1767 | return handle("end");
|
1768 | }
|
1769 |
|
1770 | if (entry.tryLoc <= this.prev) {
|
1771 | var hasCatch = hasOwn.call(entry, "catchLoc");
|
1772 | var hasFinally = hasOwn.call(entry, "finallyLoc");
|
1773 |
|
1774 | if (hasCatch && hasFinally) {
|
1775 | if (this.prev < entry.catchLoc) {
|
1776 | return handle(entry.catchLoc, true);
|
1777 | } else if (this.prev < entry.finallyLoc) {
|
1778 | return handle(entry.finallyLoc);
|
1779 | }
|
1780 | } else if (hasCatch) {
|
1781 | if (this.prev < entry.catchLoc) {
|
1782 | return handle(entry.catchLoc, true);
|
1783 | }
|
1784 | } else if (hasFinally) {
|
1785 | if (this.prev < entry.finallyLoc) {
|
1786 | return handle(entry.finallyLoc);
|
1787 | }
|
1788 | } else {
|
1789 | throw new Error("try statement without catch or finally");
|
1790 | }
|
1791 | }
|
1792 | }
|
1793 | },
|
1794 | abrupt: function abrupt(type, arg) {
|
1795 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1796 | var entry = this.tryEntries[i];
|
1797 |
|
1798 | if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
1799 | var finallyEntry = entry;
|
1800 | break;
|
1801 | }
|
1802 | }
|
1803 |
|
1804 | if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
1805 | finallyEntry = null;
|
1806 | }
|
1807 |
|
1808 | var record = finallyEntry ? finallyEntry.completion : {};
|
1809 | record.type = type;
|
1810 | record.arg = arg;
|
1811 |
|
1812 | if (finallyEntry) {
|
1813 | this.method = "next";
|
1814 | this.next = finallyEntry.finallyLoc;
|
1815 | return ContinueSentinel;
|
1816 | }
|
1817 |
|
1818 | return this.complete(record);
|
1819 | },
|
1820 | complete: function complete(record, afterLoc) {
|
1821 | if (record.type === "throw") {
|
1822 | throw record.arg;
|
1823 | }
|
1824 |
|
1825 | if (record.type === "break" || record.type === "continue") {
|
1826 | this.next = record.arg;
|
1827 | } else if (record.type === "return") {
|
1828 | this.rval = this.arg = record.arg;
|
1829 | this.method = "return";
|
1830 | this.next = "end";
|
1831 | } else if (record.type === "normal" && afterLoc) {
|
1832 | this.next = afterLoc;
|
1833 | }
|
1834 |
|
1835 | return ContinueSentinel;
|
1836 | },
|
1837 | finish: function finish(finallyLoc) {
|
1838 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1839 | var entry = this.tryEntries[i];
|
1840 |
|
1841 | if (entry.finallyLoc === finallyLoc) {
|
1842 | this.complete(entry.completion, entry.afterLoc);
|
1843 | resetTryEntry(entry);
|
1844 | return ContinueSentinel;
|
1845 | }
|
1846 | }
|
1847 | },
|
1848 | "catch": function _catch(tryLoc) {
|
1849 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1850 | var entry = this.tryEntries[i];
|
1851 |
|
1852 | if (entry.tryLoc === tryLoc) {
|
1853 | var record = entry.completion;
|
1854 |
|
1855 | if (record.type === "throw") {
|
1856 | var thrown = record.arg;
|
1857 | resetTryEntry(entry);
|
1858 | }
|
1859 |
|
1860 | return thrown;
|
1861 | }
|
1862 | }
|
1863 |
|
1864 | throw new Error("illegal catch attempt");
|
1865 | },
|
1866 | delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
1867 | this.delegate = {
|
1868 | iterator: values(iterable),
|
1869 | resultName: resultName,
|
1870 | nextLoc: nextLoc
|
1871 | };
|
1872 |
|
1873 | if (this.method === "next") {
|
1874 | this.arg = undefined;
|
1875 | }
|
1876 |
|
1877 | return ContinueSentinel;
|
1878 | }
|
1879 | };
|
1880 | return exports;
|
1881 | }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
|
1882 |
|
1883 | try {
|
1884 | regeneratorRuntime = runtime;
|
1885 | } catch (accidentalStrictMode) {
|
1886 | Function("r", "regeneratorRuntime = r")(runtime);
|
1887 | }
|
1888 | }.call(this, __w_pdfjs_require__(6)(module)))
|
1889 |
|
1890 | }),
|
1891 |
|
1892 | (function(module, exports, __w_pdfjs_require__) {
|
1893 |
|
1894 | "use strict";
|
1895 |
|
1896 |
|
1897 | module.exports = function (module) {
|
1898 | if (!module.webpackPolyfill) {
|
1899 | module.deprecate = function () {};
|
1900 |
|
1901 | module.paths = [];
|
1902 | if (!module.children) module.children = [];
|
1903 | Object.defineProperty(module, "loaded", {
|
1904 | enumerable: true,
|
1905 | get: function get() {
|
1906 | return module.l;
|
1907 | }
|
1908 | });
|
1909 | Object.defineProperty(module, "id", {
|
1910 | enumerable: true,
|
1911 | get: function get() {
|
1912 | return module.i;
|
1913 | }
|
1914 | });
|
1915 | module.webpackPolyfill = 1;
|
1916 | }
|
1917 |
|
1918 | return module;
|
1919 | };
|
1920 |
|
1921 | }),
|
1922 |
|
1923 | (function(module, exports, __w_pdfjs_require__) {
|
1924 |
|
1925 | "use strict";
|
1926 |
|
1927 |
|
1928 | Object.defineProperty(exports, "__esModule", {
|
1929 | value: true
|
1930 | });
|
1931 | exports.SimpleLinkService = exports.PDFLinkService = void 0;
|
1932 |
|
1933 | var _ui_utils = __w_pdfjs_require__(3);
|
1934 |
|
1935 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
1936 |
|
1937 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1938 |
|
1939 | 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); } }
|
1940 |
|
1941 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
1942 |
|
1943 | var PDFLinkService =
|
1944 |
|
1945 | function () {
|
1946 | function PDFLinkService() {
|
1947 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1948 | eventBus = _ref.eventBus,
|
1949 | _ref$externalLinkTarg = _ref.externalLinkTarget,
|
1950 | externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
|
1951 | _ref$externalLinkRel = _ref.externalLinkRel,
|
1952 | externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel;
|
1953 |
|
1954 | _classCallCheck(this, PDFLinkService);
|
1955 |
|
1956 | this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
|
1957 | this.externalLinkTarget = externalLinkTarget;
|
1958 | this.externalLinkRel = externalLinkRel;
|
1959 | this.baseUrl = null;
|
1960 | this.pdfDocument = null;
|
1961 | this.pdfViewer = null;
|
1962 | this.pdfHistory = null;
|
1963 | this._pagesRefCache = null;
|
1964 | }
|
1965 |
|
1966 | _createClass(PDFLinkService, [{
|
1967 | key: "setDocument",
|
1968 | value: function setDocument(pdfDocument) {
|
1969 | var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
1970 | this.baseUrl = baseUrl;
|
1971 | this.pdfDocument = pdfDocument;
|
1972 | this._pagesRefCache = Object.create(null);
|
1973 | }
|
1974 | }, {
|
1975 | key: "setViewer",
|
1976 | value: function setViewer(pdfViewer) {
|
1977 | this.pdfViewer = pdfViewer;
|
1978 | }
|
1979 | }, {
|
1980 | key: "setHistory",
|
1981 | value: function setHistory(pdfHistory) {
|
1982 | this.pdfHistory = pdfHistory;
|
1983 | }
|
1984 | }, {
|
1985 | key: "navigateTo",
|
1986 | value: function navigateTo(dest) {
|
1987 | var _this = this;
|
1988 |
|
1989 | var goToDestination = function goToDestination(_ref2) {
|
1990 | var namedDest = _ref2.namedDest,
|
1991 | explicitDest = _ref2.explicitDest;
|
1992 | var destRef = explicitDest[0],
|
1993 | pageNumber;
|
1994 |
|
1995 | if (destRef instanceof Object) {
|
1996 | pageNumber = _this._cachedPageNumber(destRef);
|
1997 |
|
1998 | if (pageNumber === null) {
|
1999 | _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
|
2000 | _this.cachePageRef(pageIndex + 1, destRef);
|
2001 |
|
2002 | goToDestination({
|
2003 | namedDest: namedDest,
|
2004 | explicitDest: explicitDest
|
2005 | });
|
2006 | })["catch"](function () {
|
2007 | console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
|
2008 | });
|
2009 |
|
2010 | return;
|
2011 | }
|
2012 | } else if (Number.isInteger(destRef)) {
|
2013 | pageNumber = destRef + 1;
|
2014 | } else {
|
2015 | console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
|
2016 | return;
|
2017 | }
|
2018 |
|
2019 | if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
|
2020 | console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
|
2021 | return;
|
2022 | }
|
2023 |
|
2024 | if (_this.pdfHistory) {
|
2025 | _this.pdfHistory.pushCurrentPosition();
|
2026 |
|
2027 | _this.pdfHistory.push({
|
2028 | namedDest: namedDest,
|
2029 | explicitDest: explicitDest,
|
2030 | pageNumber: pageNumber
|
2031 | });
|
2032 | }
|
2033 |
|
2034 | _this.pdfViewer.scrollPageIntoView({
|
2035 | pageNumber: pageNumber,
|
2036 | destArray: explicitDest
|
2037 | });
|
2038 | };
|
2039 |
|
2040 | new Promise(function (resolve, reject) {
|
2041 | if (typeof dest === 'string') {
|
2042 | _this.pdfDocument.getDestination(dest).then(function (destArray) {
|
2043 | resolve({
|
2044 | namedDest: dest,
|
2045 | explicitDest: destArray
|
2046 | });
|
2047 | });
|
2048 |
|
2049 | return;
|
2050 | }
|
2051 |
|
2052 | resolve({
|
2053 | namedDest: '',
|
2054 | explicitDest: dest
|
2055 | });
|
2056 | }).then(function (data) {
|
2057 | if (!Array.isArray(data.explicitDest)) {
|
2058 | console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
|
2059 | return;
|
2060 | }
|
2061 |
|
2062 | goToDestination(data);
|
2063 | });
|
2064 | }
|
2065 | }, {
|
2066 | key: "getDestinationHash",
|
2067 | value: function getDestinationHash(dest) {
|
2068 | if (typeof dest === 'string') {
|
2069 | return this.getAnchorUrl('#' + escape(dest));
|
2070 | }
|
2071 |
|
2072 | if (Array.isArray(dest)) {
|
2073 | var str = JSON.stringify(dest);
|
2074 | return this.getAnchorUrl('#' + escape(str));
|
2075 | }
|
2076 |
|
2077 | return this.getAnchorUrl('');
|
2078 | }
|
2079 | }, {
|
2080 | key: "getAnchorUrl",
|
2081 | value: function getAnchorUrl(anchor) {
|
2082 | return (this.baseUrl || '') + anchor;
|
2083 | }
|
2084 | }, {
|
2085 | key: "setHash",
|
2086 | value: function setHash(hash) {
|
2087 | var pageNumber, dest;
|
2088 |
|
2089 | if (hash.includes('=')) {
|
2090 | var params = (0, _ui_utils.parseQueryString)(hash);
|
2091 |
|
2092 | if ('search' in params) {
|
2093 | this.eventBus.dispatch('findfromurlhash', {
|
2094 | source: this,
|
2095 | query: params['search'].replace(/"/g, ''),
|
2096 | phraseSearch: params['phrase'] === 'true'
|
2097 | });
|
2098 | }
|
2099 |
|
2100 | if ('nameddest' in params) {
|
2101 | this.navigateTo(params.nameddest);
|
2102 | return;
|
2103 | }
|
2104 |
|
2105 | if ('page' in params) {
|
2106 | pageNumber = params.page | 0 || 1;
|
2107 | }
|
2108 |
|
2109 | if ('zoom' in params) {
|
2110 | var zoomArgs = params.zoom.split(',');
|
2111 | var zoomArg = zoomArgs[0];
|
2112 | var zoomArgNumber = parseFloat(zoomArg);
|
2113 |
|
2114 | if (!zoomArg.includes('Fit')) {
|
2115 | dest = [null, {
|
2116 | name: 'XYZ'
|
2117 | }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
|
2118 | } else {
|
2119 | if (zoomArg === 'Fit' || zoomArg === 'FitB') {
|
2120 | dest = [null, {
|
2121 | name: zoomArg
|
2122 | }];
|
2123 | } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
|
2124 | dest = [null, {
|
2125 | name: zoomArg
|
2126 | }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
|
2127 | } else if (zoomArg === 'FitR') {
|
2128 | if (zoomArgs.length !== 5) {
|
2129 | console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
|
2130 | } else {
|
2131 | dest = [null, {
|
2132 | name: zoomArg
|
2133 | }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
|
2134 | }
|
2135 | } else {
|
2136 | console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
|
2137 | }
|
2138 | }
|
2139 | }
|
2140 |
|
2141 | if (dest) {
|
2142 | this.pdfViewer.scrollPageIntoView({
|
2143 | pageNumber: pageNumber || this.page,
|
2144 | destArray: dest,
|
2145 | allowNegativeOffset: true
|
2146 | });
|
2147 | } else if (pageNumber) {
|
2148 | this.page = pageNumber;
|
2149 | }
|
2150 |
|
2151 | if ('pagemode' in params) {
|
2152 | this.eventBus.dispatch('pagemode', {
|
2153 | source: this,
|
2154 | mode: params.pagemode
|
2155 | });
|
2156 | }
|
2157 | } else {
|
2158 | dest = unescape(hash);
|
2159 |
|
2160 | try {
|
2161 | dest = JSON.parse(dest);
|
2162 |
|
2163 | if (!Array.isArray(dest)) {
|
2164 | dest = dest.toString();
|
2165 | }
|
2166 | } catch (ex) {}
|
2167 |
|
2168 | if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
|
2169 | this.navigateTo(dest);
|
2170 | return;
|
2171 | }
|
2172 |
|
2173 | console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
|
2174 | }
|
2175 | }
|
2176 | }, {
|
2177 | key: "executeNamedAction",
|
2178 | value: function executeNamedAction(action) {
|
2179 | switch (action) {
|
2180 | case 'GoBack':
|
2181 | if (this.pdfHistory) {
|
2182 | this.pdfHistory.back();
|
2183 | }
|
2184 |
|
2185 | break;
|
2186 |
|
2187 | case 'GoForward':
|
2188 | if (this.pdfHistory) {
|
2189 | this.pdfHistory.forward();
|
2190 | }
|
2191 |
|
2192 | break;
|
2193 |
|
2194 | case 'NextPage':
|
2195 | if (this.page < this.pagesCount) {
|
2196 | this.page++;
|
2197 | }
|
2198 |
|
2199 | break;
|
2200 |
|
2201 | case 'PrevPage':
|
2202 | if (this.page > 1) {
|
2203 | this.page--;
|
2204 | }
|
2205 |
|
2206 | break;
|
2207 |
|
2208 | case 'LastPage':
|
2209 | this.page = this.pagesCount;
|
2210 | break;
|
2211 |
|
2212 | case 'FirstPage':
|
2213 | this.page = 1;
|
2214 | break;
|
2215 |
|
2216 | default:
|
2217 | break;
|
2218 | }
|
2219 |
|
2220 | this.eventBus.dispatch('namedaction', {
|
2221 | source: this,
|
2222 | action: action
|
2223 | });
|
2224 | }
|
2225 | }, {
|
2226 | key: "cachePageRef",
|
2227 | value: function cachePageRef(pageNum, pageRef) {
|
2228 | if (!pageRef) {
|
2229 | return;
|
2230 | }
|
2231 |
|
2232 | var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
|
2233 | this._pagesRefCache[refStr] = pageNum;
|
2234 | }
|
2235 | }, {
|
2236 | key: "_cachedPageNumber",
|
2237 | value: function _cachedPageNumber(pageRef) {
|
2238 | var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
|
2239 | return this._pagesRefCache && this._pagesRefCache[refStr] || null;
|
2240 | }
|
2241 | }, {
|
2242 | key: "isPageVisible",
|
2243 | value: function isPageVisible(pageNumber) {
|
2244 | return this.pdfViewer.isPageVisible(pageNumber);
|
2245 | }
|
2246 | }, {
|
2247 | key: "pagesCount",
|
2248 | get: function get() {
|
2249 | return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
2250 | }
|
2251 | }, {
|
2252 | key: "page",
|
2253 | get: function get() {
|
2254 | return this.pdfViewer.currentPageNumber;
|
2255 | },
|
2256 | set: function set(value) {
|
2257 | this.pdfViewer.currentPageNumber = value;
|
2258 | }
|
2259 | }, {
|
2260 | key: "rotation",
|
2261 | get: function get() {
|
2262 | return this.pdfViewer.pagesRotation;
|
2263 | },
|
2264 | set: function set(value) {
|
2265 | this.pdfViewer.pagesRotation = value;
|
2266 | }
|
2267 | }]);
|
2268 |
|
2269 | return PDFLinkService;
|
2270 | }();
|
2271 |
|
2272 | exports.PDFLinkService = PDFLinkService;
|
2273 |
|
2274 | function isValidExplicitDestination(dest) {
|
2275 | if (!Array.isArray(dest)) {
|
2276 | return false;
|
2277 | }
|
2278 |
|
2279 | var destLength = dest.length,
|
2280 | allowNull = true;
|
2281 |
|
2282 | if (destLength < 2) {
|
2283 | return false;
|
2284 | }
|
2285 |
|
2286 | var page = dest[0];
|
2287 |
|
2288 | if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
|
2289 | return false;
|
2290 | }
|
2291 |
|
2292 | var zoom = dest[1];
|
2293 |
|
2294 | if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
|
2295 | return false;
|
2296 | }
|
2297 |
|
2298 | switch (zoom.name) {
|
2299 | case 'XYZ':
|
2300 | if (destLength !== 5) {
|
2301 | return false;
|
2302 | }
|
2303 |
|
2304 | break;
|
2305 |
|
2306 | case 'Fit':
|
2307 | case 'FitB':
|
2308 | return destLength === 2;
|
2309 |
|
2310 | case 'FitH':
|
2311 | case 'FitBH':
|
2312 | case 'FitV':
|
2313 | case 'FitBV':
|
2314 | if (destLength !== 3) {
|
2315 | return false;
|
2316 | }
|
2317 |
|
2318 | break;
|
2319 |
|
2320 | case 'FitR':
|
2321 | if (destLength !== 6) {
|
2322 | return false;
|
2323 | }
|
2324 |
|
2325 | allowNull = false;
|
2326 | break;
|
2327 |
|
2328 | default:
|
2329 | return false;
|
2330 | }
|
2331 |
|
2332 | for (var i = 2; i < destLength; i++) {
|
2333 | var param = dest[i];
|
2334 |
|
2335 | if (!(typeof param === 'number' || allowNull && param === null)) {
|
2336 | return false;
|
2337 | }
|
2338 | }
|
2339 |
|
2340 | return true;
|
2341 | }
|
2342 |
|
2343 | var SimpleLinkService =
|
2344 |
|
2345 | function () {
|
2346 | function SimpleLinkService() {
|
2347 | _classCallCheck(this, SimpleLinkService);
|
2348 |
|
2349 | this.externalLinkTarget = null;
|
2350 | this.externalLinkRel = null;
|
2351 | }
|
2352 |
|
2353 | _createClass(SimpleLinkService, [{
|
2354 | key: "navigateTo",
|
2355 | value: function navigateTo(dest) {}
|
2356 | }, {
|
2357 | key: "getDestinationHash",
|
2358 | value: function getDestinationHash(dest) {
|
2359 | return '#';
|
2360 | }
|
2361 | }, {
|
2362 | key: "getAnchorUrl",
|
2363 | value: function getAnchorUrl(hash) {
|
2364 | return '#';
|
2365 | }
|
2366 | }, {
|
2367 | key: "setHash",
|
2368 | value: function setHash(hash) {}
|
2369 | }, {
|
2370 | key: "executeNamedAction",
|
2371 | value: function executeNamedAction(action) {}
|
2372 | }, {
|
2373 | key: "cachePageRef",
|
2374 | value: function cachePageRef(pageNum, pageRef) {}
|
2375 | }, {
|
2376 | key: "isPageVisible",
|
2377 | value: function isPageVisible(pageNumber) {
|
2378 | return true;
|
2379 | }
|
2380 | }, {
|
2381 | key: "pagesCount",
|
2382 | get: function get() {
|
2383 | return 0;
|
2384 | }
|
2385 | }, {
|
2386 | key: "page",
|
2387 | get: function get() {
|
2388 | return 0;
|
2389 | },
|
2390 | set: function set(value) {}
|
2391 | }, {
|
2392 | key: "rotation",
|
2393 | get: function get() {
|
2394 | return 0;
|
2395 | },
|
2396 | set: function set(value) {}
|
2397 | }]);
|
2398 |
|
2399 | return SimpleLinkService;
|
2400 | }();
|
2401 |
|
2402 | exports.SimpleLinkService = SimpleLinkService;
|
2403 |
|
2404 | }),
|
2405 |
|
2406 | (function(module, exports, __w_pdfjs_require__) {
|
2407 |
|
2408 | "use strict";
|
2409 |
|
2410 |
|
2411 | Object.defineProperty(exports, "__esModule", {
|
2412 | value: true
|
2413 | });
|
2414 | exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
|
2415 |
|
2416 | var _ui_utils = __w_pdfjs_require__(3);
|
2417 |
|
2418 | var _pdfjsLib = __w_pdfjs_require__(2);
|
2419 |
|
2420 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2421 |
|
2422 | 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); } }
|
2423 |
|
2424 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
2425 |
|
2426 | var EXPAND_DIVS_TIMEOUT = 300;
|
2427 |
|
2428 | var TextLayerBuilder =
|
2429 |
|
2430 | function () {
|
2431 | function TextLayerBuilder(_ref) {
|
2432 | var textLayerDiv = _ref.textLayerDiv,
|
2433 | eventBus = _ref.eventBus,
|
2434 | pageIndex = _ref.pageIndex,
|
2435 | viewport = _ref.viewport,
|
2436 | _ref$findController = _ref.findController,
|
2437 | findController = _ref$findController === void 0 ? null : _ref$findController,
|
2438 | _ref$enhanceTextSelec = _ref.enhanceTextSelection,
|
2439 | enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
|
2440 |
|
2441 | _classCallCheck(this, TextLayerBuilder);
|
2442 |
|
2443 | this.textLayerDiv = textLayerDiv;
|
2444 | this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
|
2445 | this.textContent = null;
|
2446 | this.textContentItemsStr = [];
|
2447 | this.textContentStream = null;
|
2448 | this.renderingDone = false;
|
2449 | this.pageIdx = pageIndex;
|
2450 | this.pageNumber = this.pageIdx + 1;
|
2451 | this.matches = [];
|
2452 | this.viewport = viewport;
|
2453 | this.textDivs = [];
|
2454 | this.findController = findController;
|
2455 | this.textLayerRenderTask = null;
|
2456 | this.enhanceTextSelection = enhanceTextSelection;
|
2457 | this._onUpdateTextLayerMatches = null;
|
2458 |
|
2459 | this._bindMouse();
|
2460 | }
|
2461 |
|
2462 | _createClass(TextLayerBuilder, [{
|
2463 | key: "_finishRendering",
|
2464 | value: function _finishRendering() {
|
2465 | this.renderingDone = true;
|
2466 |
|
2467 | if (!this.enhanceTextSelection) {
|
2468 | var endOfContent = document.createElement('div');
|
2469 | endOfContent.className = 'endOfContent';
|
2470 | this.textLayerDiv.appendChild(endOfContent);
|
2471 | }
|
2472 |
|
2473 | this.eventBus.dispatch('textlayerrendered', {
|
2474 | source: this,
|
2475 | pageNumber: this.pageNumber,
|
2476 | numTextDivs: this.textDivs.length
|
2477 | });
|
2478 | }
|
2479 | }, {
|
2480 | key: "render",
|
2481 | value: function render() {
|
2482 | var _this = this;
|
2483 |
|
2484 | var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
2485 |
|
2486 | if (!(this.textContent || this.textContentStream) || this.renderingDone) {
|
2487 | return;
|
2488 | }
|
2489 |
|
2490 | this.cancel();
|
2491 | this.textDivs = [];
|
2492 | var textLayerFrag = document.createDocumentFragment();
|
2493 | this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
|
2494 | textContent: this.textContent,
|
2495 | textContentStream: this.textContentStream,
|
2496 | container: textLayerFrag,
|
2497 | viewport: this.viewport,
|
2498 | textDivs: this.textDivs,
|
2499 | textContentItemsStr: this.textContentItemsStr,
|
2500 | timeout: timeout,
|
2501 | enhanceTextSelection: this.enhanceTextSelection
|
2502 | });
|
2503 | this.textLayerRenderTask.promise.then(function () {
|
2504 | _this.textLayerDiv.appendChild(textLayerFrag);
|
2505 |
|
2506 | _this._finishRendering();
|
2507 |
|
2508 | _this._updateMatches();
|
2509 | }, function (reason) {});
|
2510 |
|
2511 | if (!this._onUpdateTextLayerMatches) {
|
2512 | this._onUpdateTextLayerMatches = function (evt) {
|
2513 | if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
|
2514 | _this._updateMatches();
|
2515 | }
|
2516 | };
|
2517 |
|
2518 | this.eventBus.on('updatetextlayermatches', this._onUpdateTextLayerMatches);
|
2519 | }
|
2520 | }
|
2521 | }, {
|
2522 | key: "cancel",
|
2523 | value: function cancel() {
|
2524 | if (this.textLayerRenderTask) {
|
2525 | this.textLayerRenderTask.cancel();
|
2526 | this.textLayerRenderTask = null;
|
2527 | }
|
2528 |
|
2529 | if (this._onUpdateTextLayerMatches) {
|
2530 | this.eventBus.off('updatetextlayermatches', this._onUpdateTextLayerMatches);
|
2531 | this._onUpdateTextLayerMatches = null;
|
2532 | }
|
2533 | }
|
2534 | }, {
|
2535 | key: "setTextContentStream",
|
2536 | value: function setTextContentStream(readableStream) {
|
2537 | this.cancel();
|
2538 | this.textContentStream = readableStream;
|
2539 | }
|
2540 | }, {
|
2541 | key: "setTextContent",
|
2542 | value: function setTextContent(textContent) {
|
2543 | this.cancel();
|
2544 | this.textContent = textContent;
|
2545 | }
|
2546 | }, {
|
2547 | key: "_convertMatches",
|
2548 | value: function _convertMatches(matches, matchesLength) {
|
2549 | if (!matches) {
|
2550 | return [];
|
2551 | }
|
2552 |
|
2553 | var findController = this.findController,
|
2554 | textContentItemsStr = this.textContentItemsStr;
|
2555 | var i = 0,
|
2556 | iIndex = 0;
|
2557 | var end = textContentItemsStr.length - 1;
|
2558 | var queryLen = findController.state.query.length;
|
2559 | var result = [];
|
2560 |
|
2561 | for (var m = 0, mm = matches.length; m < mm; m++) {
|
2562 | var matchIdx = matches[m];
|
2563 |
|
2564 | while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
|
2565 | iIndex += textContentItemsStr[i].length;
|
2566 | i++;
|
2567 | }
|
2568 |
|
2569 | if (i === textContentItemsStr.length) {
|
2570 | console.error('Could not find a matching mapping');
|
2571 | }
|
2572 |
|
2573 | var match = {
|
2574 | begin: {
|
2575 | divIdx: i,
|
2576 | offset: matchIdx - iIndex
|
2577 | }
|
2578 | };
|
2579 |
|
2580 | if (matchesLength) {
|
2581 | matchIdx += matchesLength[m];
|
2582 | } else {
|
2583 | matchIdx += queryLen;
|
2584 | }
|
2585 |
|
2586 | while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
|
2587 | iIndex += textContentItemsStr[i].length;
|
2588 | i++;
|
2589 | }
|
2590 |
|
2591 | match.end = {
|
2592 | divIdx: i,
|
2593 | offset: matchIdx - iIndex
|
2594 | };
|
2595 | result.push(match);
|
2596 | }
|
2597 |
|
2598 | return result;
|
2599 | }
|
2600 | }, {
|
2601 | key: "_renderMatches",
|
2602 | value: function _renderMatches(matches) {
|
2603 | if (matches.length === 0) {
|
2604 | return;
|
2605 | }
|
2606 |
|
2607 | var findController = this.findController,
|
2608 | pageIdx = this.pageIdx,
|
2609 | textContentItemsStr = this.textContentItemsStr,
|
2610 | textDivs = this.textDivs;
|
2611 | var isSelectedPage = pageIdx === findController.selected.pageIdx;
|
2612 | var selectedMatchIdx = findController.selected.matchIdx;
|
2613 | var highlightAll = findController.state.highlightAll;
|
2614 | var prevEnd = null;
|
2615 | var infinity = {
|
2616 | divIdx: -1,
|
2617 | offset: undefined
|
2618 | };
|
2619 |
|
2620 | function beginText(begin, className) {
|
2621 | var divIdx = begin.divIdx;
|
2622 | textDivs[divIdx].textContent = '';
|
2623 | appendTextToDiv(divIdx, 0, begin.offset, className);
|
2624 | }
|
2625 |
|
2626 | function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
|
2627 | var div = textDivs[divIdx];
|
2628 | var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
|
2629 | var node = document.createTextNode(content);
|
2630 |
|
2631 | if (className) {
|
2632 | var span = document.createElement('span');
|
2633 | span.className = className;
|
2634 | span.appendChild(node);
|
2635 | div.appendChild(span);
|
2636 | return;
|
2637 | }
|
2638 |
|
2639 | div.appendChild(node);
|
2640 | }
|
2641 |
|
2642 | var i0 = selectedMatchIdx,
|
2643 | i1 = i0 + 1;
|
2644 |
|
2645 | if (highlightAll) {
|
2646 | i0 = 0;
|
2647 | i1 = matches.length;
|
2648 | } else if (!isSelectedPage) {
|
2649 | return;
|
2650 | }
|
2651 |
|
2652 | for (var i = i0; i < i1; i++) {
|
2653 | var match = matches[i];
|
2654 | var begin = match.begin;
|
2655 | var end = match.end;
|
2656 | var isSelected = isSelectedPage && i === selectedMatchIdx;
|
2657 | var highlightSuffix = isSelected ? ' selected' : '';
|
2658 |
|
2659 | if (isSelected) {
|
2660 | findController.scrollMatchIntoView({
|
2661 | element: textDivs[begin.divIdx],
|
2662 | pageIndex: pageIdx,
|
2663 | matchIndex: selectedMatchIdx
|
2664 | });
|
2665 | }
|
2666 |
|
2667 | if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
|
2668 | if (prevEnd !== null) {
|
2669 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
|
2670 | }
|
2671 |
|
2672 | beginText(begin);
|
2673 | } else {
|
2674 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
|
2675 | }
|
2676 |
|
2677 | if (begin.divIdx === end.divIdx) {
|
2678 | appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
|
2679 | } else {
|
2680 | appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
|
2681 |
|
2682 | for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
|
2683 | textDivs[n0].className = 'highlight middle' + highlightSuffix;
|
2684 | }
|
2685 |
|
2686 | beginText(end, 'highlight end' + highlightSuffix);
|
2687 | }
|
2688 |
|
2689 | prevEnd = end;
|
2690 | }
|
2691 |
|
2692 | if (prevEnd) {
|
2693 | appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
|
2694 | }
|
2695 | }
|
2696 | }, {
|
2697 | key: "_updateMatches",
|
2698 | value: function _updateMatches() {
|
2699 | if (!this.renderingDone) {
|
2700 | return;
|
2701 | }
|
2702 |
|
2703 | var findController = this.findController,
|
2704 | matches = this.matches,
|
2705 | pageIdx = this.pageIdx,
|
2706 | textContentItemsStr = this.textContentItemsStr,
|
2707 | textDivs = this.textDivs;
|
2708 | var clearedUntilDivIdx = -1;
|
2709 |
|
2710 | for (var i = 0, ii = matches.length; i < ii; i++) {
|
2711 | var match = matches[i];
|
2712 | var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
|
2713 |
|
2714 | for (var n = begin, end = match.end.divIdx; n <= end; n++) {
|
2715 | var div = textDivs[n];
|
2716 | div.textContent = textContentItemsStr[n];
|
2717 | div.className = '';
|
2718 | }
|
2719 |
|
2720 | clearedUntilDivIdx = match.end.divIdx + 1;
|
2721 | }
|
2722 |
|
2723 | if (!findController || !findController.highlightMatches) {
|
2724 | return;
|
2725 | }
|
2726 |
|
2727 | var pageMatches = findController.pageMatches[pageIdx] || null;
|
2728 | var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
|
2729 | this.matches = this._convertMatches(pageMatches, pageMatchesLength);
|
2730 |
|
2731 | this._renderMatches(this.matches);
|
2732 | }
|
2733 | }, {
|
2734 | key: "_bindMouse",
|
2735 | value: function _bindMouse() {
|
2736 | var _this2 = this;
|
2737 |
|
2738 | var div = this.textLayerDiv;
|
2739 | var expandDivsTimer = null;
|
2740 | div.addEventListener('mousedown', function (evt) {
|
2741 | if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
|
2742 | _this2.textLayerRenderTask.expandTextDivs(true);
|
2743 |
|
2744 | if (expandDivsTimer) {
|
2745 | clearTimeout(expandDivsTimer);
|
2746 | expandDivsTimer = null;
|
2747 | }
|
2748 |
|
2749 | return;
|
2750 | }
|
2751 |
|
2752 | var end = div.querySelector('.endOfContent');
|
2753 |
|
2754 | if (!end) {
|
2755 | return;
|
2756 | }
|
2757 |
|
2758 | var adjustTop = evt.target !== div;
|
2759 | adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
|
2760 |
|
2761 | if (adjustTop) {
|
2762 | var divBounds = div.getBoundingClientRect();
|
2763 | var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
|
2764 | end.style.top = (r * 100).toFixed(2) + '%';
|
2765 | }
|
2766 |
|
2767 | end.classList.add('active');
|
2768 | });
|
2769 | div.addEventListener('mouseup', function () {
|
2770 | if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
|
2771 | expandDivsTimer = setTimeout(function () {
|
2772 | if (_this2.textLayerRenderTask) {
|
2773 | _this2.textLayerRenderTask.expandTextDivs(false);
|
2774 | }
|
2775 |
|
2776 | expandDivsTimer = null;
|
2777 | }, EXPAND_DIVS_TIMEOUT);
|
2778 | return;
|
2779 | }
|
2780 |
|
2781 | var end = div.querySelector('.endOfContent');
|
2782 |
|
2783 | if (!end) {
|
2784 | return;
|
2785 | }
|
2786 |
|
2787 | end.style.top = '';
|
2788 | end.classList.remove('active');
|
2789 | });
|
2790 | }
|
2791 | }]);
|
2792 |
|
2793 | return TextLayerBuilder;
|
2794 | }();
|
2795 |
|
2796 | exports.TextLayerBuilder = TextLayerBuilder;
|
2797 |
|
2798 | var DefaultTextLayerFactory =
|
2799 |
|
2800 | function () {
|
2801 | function DefaultTextLayerFactory() {
|
2802 | _classCallCheck(this, DefaultTextLayerFactory);
|
2803 | }
|
2804 |
|
2805 | _createClass(DefaultTextLayerFactory, [{
|
2806 | key: "createTextLayerBuilder",
|
2807 | value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
|
2808 | var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
2809 | return new TextLayerBuilder({
|
2810 | textLayerDiv: textLayerDiv,
|
2811 | pageIndex: pageIndex,
|
2812 | viewport: viewport,
|
2813 | enhanceTextSelection: enhanceTextSelection
|
2814 | });
|
2815 | }
|
2816 | }]);
|
2817 |
|
2818 | return DefaultTextLayerFactory;
|
2819 | }();
|
2820 |
|
2821 | exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
|
2822 |
|
2823 | }),
|
2824 |
|
2825 | (function(module, exports, __w_pdfjs_require__) {
|
2826 |
|
2827 | "use strict";
|
2828 |
|
2829 |
|
2830 | Object.defineProperty(exports, "__esModule", {
|
2831 | value: true
|
2832 | });
|
2833 | exports.DownloadManager = void 0;
|
2834 |
|
2835 | var _pdfjsLib = __w_pdfjs_require__(2);
|
2836 |
|
2837 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2838 |
|
2839 | 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); } }
|
2840 |
|
2841 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
2842 |
|
2843 | ;
|
2844 | var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
|
2845 |
|
2846 | function _download(blobUrl, filename) {
|
2847 | var a = document.createElement('a');
|
2848 |
|
2849 | if (!a.click) {
|
2850 | throw new Error('DownloadManager: "a.click()" is not supported.');
|
2851 | }
|
2852 |
|
2853 | a.href = blobUrl;
|
2854 | a.target = '_parent';
|
2855 |
|
2856 | if ('download' in a) {
|
2857 | a.download = filename;
|
2858 | }
|
2859 |
|
2860 | (document.body || document.documentElement).appendChild(a);
|
2861 | a.click();
|
2862 | a.remove();
|
2863 | }
|
2864 |
|
2865 | var DownloadManager =
|
2866 |
|
2867 | function () {
|
2868 | function DownloadManager(_ref) {
|
2869 | var _ref$disableCreateObj = _ref.disableCreateObjectURL,
|
2870 | disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
|
2871 |
|
2872 | _classCallCheck(this, DownloadManager);
|
2873 |
|
2874 | this.disableCreateObjectURL = disableCreateObjectURL;
|
2875 | }
|
2876 |
|
2877 | _createClass(DownloadManager, [{
|
2878 | key: "downloadUrl",
|
2879 | value: function downloadUrl(url, filename) {
|
2880 | if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
|
2881 | return;
|
2882 | }
|
2883 |
|
2884 | _download(url + '#pdfjs.action=download', filename);
|
2885 | }
|
2886 | }, {
|
2887 | key: "downloadData",
|
2888 | value: function downloadData(data, filename, contentType) {
|
2889 | if (navigator.msSaveBlob) {
|
2890 | navigator.msSaveBlob(new Blob([data], {
|
2891 | type: contentType
|
2892 | }), filename);
|
2893 | return;
|
2894 | }
|
2895 |
|
2896 | var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
|
2897 |
|
2898 | _download(blobUrl, filename);
|
2899 | }
|
2900 | }, {
|
2901 | key: "download",
|
2902 | value: function download(blob, url, filename) {
|
2903 | if (navigator.msSaveBlob) {
|
2904 | if (!navigator.msSaveBlob(blob, filename)) {
|
2905 | this.downloadUrl(url, filename);
|
2906 | }
|
2907 |
|
2908 | return;
|
2909 | }
|
2910 |
|
2911 | if (this.disableCreateObjectURL) {
|
2912 | this.downloadUrl(url, filename);
|
2913 | return;
|
2914 | }
|
2915 |
|
2916 | var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
|
2917 |
|
2918 | _download(blobUrl, filename);
|
2919 | }
|
2920 | }]);
|
2921 |
|
2922 | return DownloadManager;
|
2923 | }();
|
2924 |
|
2925 | exports.DownloadManager = DownloadManager;
|
2926 |
|
2927 | }),
|
2928 |
|
2929 | (function(module, exports, __w_pdfjs_require__) {
|
2930 |
|
2931 | "use strict";
|
2932 |
|
2933 |
|
2934 | Object.defineProperty(exports, "__esModule", {
|
2935 | value: true
|
2936 | });
|
2937 | exports.GenericL10n = void 0;
|
2938 |
|
2939 | var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
|
2940 |
|
2941 | __w_pdfjs_require__(11);
|
2942 |
|
2943 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
2944 |
|
2945 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
2946 |
|
2947 | function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
2948 |
|
2949 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2950 |
|
2951 | 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); } }
|
2952 |
|
2953 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
2954 |
|
2955 | var webL10n = document.webL10n;
|
2956 |
|
2957 | var GenericL10n =
|
2958 |
|
2959 | function () {
|
2960 | function GenericL10n(lang) {
|
2961 | _classCallCheck(this, GenericL10n);
|
2962 |
|
2963 | this._lang = lang;
|
2964 | this._ready = new Promise(function (resolve, reject) {
|
2965 | webL10n.setLanguage(lang, function () {
|
2966 | resolve(webL10n);
|
2967 | });
|
2968 | });
|
2969 | }
|
2970 |
|
2971 | _createClass(GenericL10n, [{
|
2972 | key: "getLanguage",
|
2973 | value: function () {
|
2974 | var _getLanguage = _asyncToGenerator(
|
2975 |
|
2976 | _regenerator["default"].mark(function _callee() {
|
2977 | var l10n;
|
2978 | return _regenerator["default"].wrap(function _callee$(_context) {
|
2979 | while (1) {
|
2980 | switch (_context.prev = _context.next) {
|
2981 | case 0:
|
2982 | _context.next = 2;
|
2983 | return this._ready;
|
2984 |
|
2985 | case 2:
|
2986 | l10n = _context.sent;
|
2987 | return _context.abrupt("return", l10n.getLanguage());
|
2988 |
|
2989 | case 4:
|
2990 | case "end":
|
2991 | return _context.stop();
|
2992 | }
|
2993 | }
|
2994 | }, _callee, this);
|
2995 | }));
|
2996 |
|
2997 | function getLanguage() {
|
2998 | return _getLanguage.apply(this, arguments);
|
2999 | }
|
3000 |
|
3001 | return getLanguage;
|
3002 | }()
|
3003 | }, {
|
3004 | key: "getDirection",
|
3005 | value: function () {
|
3006 | var _getDirection = _asyncToGenerator(
|
3007 |
|
3008 | _regenerator["default"].mark(function _callee2() {
|
3009 | var l10n;
|
3010 | return _regenerator["default"].wrap(function _callee2$(_context2) {
|
3011 | while (1) {
|
3012 | switch (_context2.prev = _context2.next) {
|
3013 | case 0:
|
3014 | _context2.next = 2;
|
3015 | return this._ready;
|
3016 |
|
3017 | case 2:
|
3018 | l10n = _context2.sent;
|
3019 | return _context2.abrupt("return", l10n.getDirection());
|
3020 |
|
3021 | case 4:
|
3022 | case "end":
|
3023 | return _context2.stop();
|
3024 | }
|
3025 | }
|
3026 | }, _callee2, this);
|
3027 | }));
|
3028 |
|
3029 | function getDirection() {
|
3030 | return _getDirection.apply(this, arguments);
|
3031 | }
|
3032 |
|
3033 | return getDirection;
|
3034 | }()
|
3035 | }, {
|
3036 | key: "get",
|
3037 | value: function () {
|
3038 | var _get = _asyncToGenerator(
|
3039 |
|
3040 | _regenerator["default"].mark(function _callee3(property, args, fallback) {
|
3041 | var l10n;
|
3042 | return _regenerator["default"].wrap(function _callee3$(_context3) {
|
3043 | while (1) {
|
3044 | switch (_context3.prev = _context3.next) {
|
3045 | case 0:
|
3046 | _context3.next = 2;
|
3047 | return this._ready;
|
3048 |
|
3049 | case 2:
|
3050 | l10n = _context3.sent;
|
3051 | return _context3.abrupt("return", l10n.get(property, args, fallback));
|
3052 |
|
3053 | case 4:
|
3054 | case "end":
|
3055 | return _context3.stop();
|
3056 | }
|
3057 | }
|
3058 | }, _callee3, this);
|
3059 | }));
|
3060 |
|
3061 | function get(_x, _x2, _x3) {
|
3062 | return _get.apply(this, arguments);
|
3063 | }
|
3064 |
|
3065 | return get;
|
3066 | }()
|
3067 | }, {
|
3068 | key: "translate",
|
3069 | value: function () {
|
3070 | var _translate = _asyncToGenerator(
|
3071 |
|
3072 | _regenerator["default"].mark(function _callee4(element) {
|
3073 | var l10n;
|
3074 | return _regenerator["default"].wrap(function _callee4$(_context4) {
|
3075 | while (1) {
|
3076 | switch (_context4.prev = _context4.next) {
|
3077 | case 0:
|
3078 | _context4.next = 2;
|
3079 | return this._ready;
|
3080 |
|
3081 | case 2:
|
3082 | l10n = _context4.sent;
|
3083 | return _context4.abrupt("return", l10n.translate(element));
|
3084 |
|
3085 | case 4:
|
3086 | case "end":
|
3087 | return _context4.stop();
|
3088 | }
|
3089 | }
|
3090 | }, _callee4, this);
|
3091 | }));
|
3092 |
|
3093 | function translate(_x4) {
|
3094 | return _translate.apply(this, arguments);
|
3095 | }
|
3096 |
|
3097 | return translate;
|
3098 | }()
|
3099 | }]);
|
3100 |
|
3101 | return GenericL10n;
|
3102 | }();
|
3103 |
|
3104 | exports.GenericL10n = GenericL10n;
|
3105 |
|
3106 | }),
|
3107 |
|
3108 | (function(module, exports, __w_pdfjs_require__) {
|
3109 |
|
3110 | "use strict";
|
3111 |
|
3112 |
|
3113 | document.webL10n = function (window, document, undefined) {
|
3114 | var gL10nData = {};
|
3115 | var gTextData = '';
|
3116 | var gTextProp = 'textContent';
|
3117 | var gLanguage = '';
|
3118 | var gMacros = {};
|
3119 | var gReadyState = 'loading';
|
3120 | var gAsyncResourceLoading = true;
|
3121 |
|
3122 | function getL10nResourceLinks() {
|
3123 | return document.querySelectorAll('link[type="application/l10n"]');
|
3124 | }
|
3125 |
|
3126 | function getL10nDictionary() {
|
3127 | var script = document.querySelector('script[type="application/l10n"]');
|
3128 | return script ? JSON.parse(script.innerHTML) : null;
|
3129 | }
|
3130 |
|
3131 | function getTranslatableChildren(element) {
|
3132 | return element ? element.querySelectorAll('*[data-l10n-id]') : [];
|
3133 | }
|
3134 |
|
3135 | function getL10nAttributes(element) {
|
3136 | if (!element) return {};
|
3137 | var l10nId = element.getAttribute('data-l10n-id');
|
3138 | var l10nArgs = element.getAttribute('data-l10n-args');
|
3139 | var args = {};
|
3140 |
|
3141 | if (l10nArgs) {
|
3142 | try {
|
3143 | args = JSON.parse(l10nArgs);
|
3144 | } catch (e) {
|
3145 | console.warn('could not parse arguments for #' + l10nId);
|
3146 | }
|
3147 | }
|
3148 |
|
3149 | return {
|
3150 | id: l10nId,
|
3151 | args: args
|
3152 | };
|
3153 | }
|
3154 |
|
3155 | function fireL10nReadyEvent(lang) {
|
3156 | var evtObject = document.createEvent('Event');
|
3157 | evtObject.initEvent('localized', true, false);
|
3158 | evtObject.language = lang;
|
3159 | document.dispatchEvent(evtObject);
|
3160 | }
|
3161 |
|
3162 | function xhrLoadText(url, onSuccess, onFailure) {
|
3163 | onSuccess = onSuccess || function _onSuccess(data) {};
|
3164 |
|
3165 | onFailure = onFailure || function _onFailure() {};
|
3166 |
|
3167 | var xhr = new XMLHttpRequest();
|
3168 | xhr.open('GET', url, gAsyncResourceLoading);
|
3169 |
|
3170 | if (xhr.overrideMimeType) {
|
3171 | xhr.overrideMimeType('text/plain; charset=utf-8');
|
3172 | }
|
3173 |
|
3174 | xhr.onreadystatechange = function () {
|
3175 | if (xhr.readyState == 4) {
|
3176 | if (xhr.status == 200 || xhr.status === 0) {
|
3177 | onSuccess(xhr.responseText);
|
3178 | } else {
|
3179 | onFailure();
|
3180 | }
|
3181 | }
|
3182 | };
|
3183 |
|
3184 | xhr.onerror = onFailure;
|
3185 | xhr.ontimeout = onFailure;
|
3186 |
|
3187 | try {
|
3188 | xhr.send(null);
|
3189 | } catch (e) {
|
3190 | onFailure();
|
3191 | }
|
3192 | }
|
3193 |
|
3194 | function parseResource(href, lang, successCallback, failureCallback) {
|
3195 | var baseURL = href.replace(/[^\/]*$/, '') || './';
|
3196 |
|
3197 | function evalString(text) {
|
3198 | if (text.lastIndexOf('\\') < 0) return text;
|
3199 | 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, "'");
|
3200 | }
|
3201 |
|
3202 | function parseProperties(text, parsedPropertiesCallback) {
|
3203 | var dictionary = {};
|
3204 | var reBlank = /^\s*|\s*$/;
|
3205 | var reComment = /^\s*#|^\s*$/;
|
3206 | var reSection = /^\s*\[(.*)\]\s*$/;
|
3207 | var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
|
3208 | var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
|
3209 |
|
3210 | function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
|
3211 | var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
|
3212 | var currentLang = '*';
|
3213 | var genericLang = lang.split('-', 1)[0];
|
3214 | var skipLang = false;
|
3215 | var match = '';
|
3216 |
|
3217 | function nextEntry() {
|
3218 | while (true) {
|
3219 | if (!entries.length) {
|
3220 | parsedRawLinesCallback();
|
3221 | return;
|
3222 | }
|
3223 |
|
3224 | var line = entries.shift();
|
3225 | if (reComment.test(line)) continue;
|
3226 |
|
3227 | if (extendedSyntax) {
|
3228 | match = reSection.exec(line);
|
3229 |
|
3230 | if (match) {
|
3231 | currentLang = match[1].toLowerCase();
|
3232 | skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
|
3233 | continue;
|
3234 | } else if (skipLang) {
|
3235 | continue;
|
3236 | }
|
3237 |
|
3238 | match = reImport.exec(line);
|
3239 |
|
3240 | if (match) {
|
3241 | loadImport(baseURL + match[1], nextEntry);
|
3242 | return;
|
3243 | }
|
3244 | }
|
3245 |
|
3246 | var tmp = line.match(reSplit);
|
3247 |
|
3248 | if (tmp && tmp.length == 3) {
|
3249 | dictionary[tmp[1]] = evalString(tmp[2]);
|
3250 | }
|
3251 | }
|
3252 | }
|
3253 |
|
3254 | nextEntry();
|
3255 | }
|
3256 |
|
3257 | function loadImport(url, callback) {
|
3258 | xhrLoadText(url, function (content) {
|
3259 | parseRawLines(content, false, callback);
|
3260 | }, function () {
|
3261 | console.warn(url + ' not found.');
|
3262 | callback();
|
3263 | });
|
3264 | }
|
3265 |
|
3266 | parseRawLines(text, true, function () {
|
3267 | parsedPropertiesCallback(dictionary);
|
3268 | });
|
3269 | }
|
3270 |
|
3271 | xhrLoadText(href, function (response) {
|
3272 | gTextData += response;
|
3273 | parseProperties(response, function (data) {
|
3274 | for (var key in data) {
|
3275 | var id,
|
3276 | prop,
|
3277 | index = key.lastIndexOf('.');
|
3278 |
|
3279 | if (index > 0) {
|
3280 | id = key.substring(0, index);
|
3281 | prop = key.substring(index + 1);
|
3282 | } else {
|
3283 | id = key;
|
3284 | prop = gTextProp;
|
3285 | }
|
3286 |
|
3287 | if (!gL10nData[id]) {
|
3288 | gL10nData[id] = {};
|
3289 | }
|
3290 |
|
3291 | gL10nData[id][prop] = data[key];
|
3292 | }
|
3293 |
|
3294 | if (successCallback) {
|
3295 | successCallback();
|
3296 | }
|
3297 | });
|
3298 | }, failureCallback);
|
3299 | }
|
3300 |
|
3301 | function loadLocale(lang, callback) {
|
3302 | if (lang) {
|
3303 | lang = lang.toLowerCase();
|
3304 | }
|
3305 |
|
3306 | callback = callback || function _callback() {};
|
3307 |
|
3308 | clear();
|
3309 | gLanguage = lang;
|
3310 | var langLinks = getL10nResourceLinks();
|
3311 | var langCount = langLinks.length;
|
3312 |
|
3313 | if (langCount === 0) {
|
3314 | var dict = getL10nDictionary();
|
3315 |
|
3316 | if (dict && dict.locales && dict.default_locale) {
|
3317 | console.log('using the embedded JSON directory, early way out');
|
3318 | gL10nData = dict.locales[lang];
|
3319 |
|
3320 | if (!gL10nData) {
|
3321 | var defaultLocale = dict.default_locale.toLowerCase();
|
3322 |
|
3323 | for (var anyCaseLang in dict.locales) {
|
3324 | anyCaseLang = anyCaseLang.toLowerCase();
|
3325 |
|
3326 | if (anyCaseLang === lang) {
|
3327 | gL10nData = dict.locales[lang];
|
3328 | break;
|
3329 | } else if (anyCaseLang === defaultLocale) {
|
3330 | gL10nData = dict.locales[defaultLocale];
|
3331 | }
|
3332 | }
|
3333 | }
|
3334 |
|
3335 | callback();
|
3336 | } else {
|
3337 | console.log('no resource to load, early way out');
|
3338 | }
|
3339 |
|
3340 | fireL10nReadyEvent(lang);
|
3341 | gReadyState = 'complete';
|
3342 | return;
|
3343 | }
|
3344 |
|
3345 | var onResourceLoaded = null;
|
3346 | var gResourceCount = 0;
|
3347 |
|
3348 | onResourceLoaded = function onResourceLoaded() {
|
3349 | gResourceCount++;
|
3350 |
|
3351 | if (gResourceCount >= langCount) {
|
3352 | callback();
|
3353 | fireL10nReadyEvent(lang);
|
3354 | gReadyState = 'complete';
|
3355 | }
|
3356 | };
|
3357 |
|
3358 | function L10nResourceLink(link) {
|
3359 | var href = link.href;
|
3360 |
|
3361 | this.load = function (lang, callback) {
|
3362 | parseResource(href, lang, callback, function () {
|
3363 | console.warn(href + ' not found.');
|
3364 | console.warn('"' + lang + '" resource not found');
|
3365 | gLanguage = '';
|
3366 | callback();
|
3367 | });
|
3368 | };
|
3369 | }
|
3370 |
|
3371 | for (var i = 0; i < langCount; i++) {
|
3372 | var resource = new L10nResourceLink(langLinks[i]);
|
3373 | resource.load(lang, onResourceLoaded);
|
3374 | }
|
3375 | }
|
3376 |
|
3377 | function clear() {
|
3378 | gL10nData = {};
|
3379 | gTextData = '';
|
3380 | gLanguage = '';
|
3381 | }
|
3382 |
|
3383 | function getPluralRules(lang) {
|
3384 | var locales2rules = {
|
3385 | 'af': 3,
|
3386 | 'ak': 4,
|
3387 | 'am': 4,
|
3388 | 'ar': 1,
|
3389 | 'asa': 3,
|
3390 | 'az': 0,
|
3391 | 'be': 11,
|
3392 | 'bem': 3,
|
3393 | 'bez': 3,
|
3394 | 'bg': 3,
|
3395 | 'bh': 4,
|
3396 | 'bm': 0,
|
3397 | 'bn': 3,
|
3398 | 'bo': 0,
|
3399 | 'br': 20,
|
3400 | 'brx': 3,
|
3401 | 'bs': 11,
|
3402 | 'ca': 3,
|
3403 | 'cgg': 3,
|
3404 | 'chr': 3,
|
3405 | 'cs': 12,
|
3406 | 'cy': 17,
|
3407 | 'da': 3,
|
3408 | 'de': 3,
|
3409 | 'dv': 3,
|
3410 | 'dz': 0,
|
3411 | 'ee': 3,
|
3412 | 'el': 3,
|
3413 | 'en': 3,
|
3414 | 'eo': 3,
|
3415 | 'es': 3,
|
3416 | 'et': 3,
|
3417 | 'eu': 3,
|
3418 | 'fa': 0,
|
3419 | 'ff': 5,
|
3420 | 'fi': 3,
|
3421 | 'fil': 4,
|
3422 | 'fo': 3,
|
3423 | 'fr': 5,
|
3424 | 'fur': 3,
|
3425 | 'fy': 3,
|
3426 | 'ga': 8,
|
3427 | 'gd': 24,
|
3428 | 'gl': 3,
|
3429 | 'gsw': 3,
|
3430 | 'gu': 3,
|
3431 | 'guw': 4,
|
3432 | 'gv': 23,
|
3433 | 'ha': 3,
|
3434 | 'haw': 3,
|
3435 | 'he': 2,
|
3436 | 'hi': 4,
|
3437 | 'hr': 11,
|
3438 | 'hu': 0,
|
3439 | 'id': 0,
|
3440 | 'ig': 0,
|
3441 | 'ii': 0,
|
3442 | 'is': 3,
|
3443 | 'it': 3,
|
3444 | 'iu': 7,
|
3445 | 'ja': 0,
|
3446 | 'jmc': 3,
|
3447 | 'jv': 0,
|
3448 | 'ka': 0,
|
3449 | 'kab': 5,
|
3450 | 'kaj': 3,
|
3451 | 'kcg': 3,
|
3452 | 'kde': 0,
|
3453 | 'kea': 0,
|
3454 | 'kk': 3,
|
3455 | 'kl': 3,
|
3456 | 'km': 0,
|
3457 | 'kn': 0,
|
3458 | 'ko': 0,
|
3459 | 'ksb': 3,
|
3460 | 'ksh': 21,
|
3461 | 'ku': 3,
|
3462 | 'kw': 7,
|
3463 | 'lag': 18,
|
3464 | 'lb': 3,
|
3465 | 'lg': 3,
|
3466 | 'ln': 4,
|
3467 | 'lo': 0,
|
3468 | 'lt': 10,
|
3469 | 'lv': 6,
|
3470 | 'mas': 3,
|
3471 | 'mg': 4,
|
3472 | 'mk': 16,
|
3473 | 'ml': 3,
|
3474 | 'mn': 3,
|
3475 | 'mo': 9,
|
3476 | 'mr': 3,
|
3477 | 'ms': 0,
|
3478 | 'mt': 15,
|
3479 | 'my': 0,
|
3480 | 'nah': 3,
|
3481 | 'naq': 7,
|
3482 | 'nb': 3,
|
3483 | 'nd': 3,
|
3484 | 'ne': 3,
|
3485 | 'nl': 3,
|
3486 | 'nn': 3,
|
3487 | 'no': 3,
|
3488 | 'nr': 3,
|
3489 | 'nso': 4,
|
3490 | 'ny': 3,
|
3491 | 'nyn': 3,
|
3492 | 'om': 3,
|
3493 | 'or': 3,
|
3494 | 'pa': 3,
|
3495 | 'pap': 3,
|
3496 | 'pl': 13,
|
3497 | 'ps': 3,
|
3498 | 'pt': 3,
|
3499 | 'rm': 3,
|
3500 | 'ro': 9,
|
3501 | 'rof': 3,
|
3502 | 'ru': 11,
|
3503 | 'rwk': 3,
|
3504 | 'sah': 0,
|
3505 | 'saq': 3,
|
3506 | 'se': 7,
|
3507 | 'seh': 3,
|
3508 | 'ses': 0,
|
3509 | 'sg': 0,
|
3510 | 'sh': 11,
|
3511 | 'shi': 19,
|
3512 | 'sk': 12,
|
3513 | 'sl': 14,
|
3514 | 'sma': 7,
|
3515 | 'smi': 7,
|
3516 | 'smj': 7,
|
3517 | 'smn': 7,
|
3518 | 'sms': 7,
|
3519 | 'sn': 3,
|
3520 | 'so': 3,
|
3521 | 'sq': 3,
|
3522 | 'sr': 11,
|
3523 | 'ss': 3,
|
3524 | 'ssy': 3,
|
3525 | 'st': 3,
|
3526 | 'sv': 3,
|
3527 | 'sw': 3,
|
3528 | 'syr': 3,
|
3529 | 'ta': 3,
|
3530 | 'te': 3,
|
3531 | 'teo': 3,
|
3532 | 'th': 0,
|
3533 | 'ti': 4,
|
3534 | 'tig': 3,
|
3535 | 'tk': 3,
|
3536 | 'tl': 4,
|
3537 | 'tn': 3,
|
3538 | 'to': 0,
|
3539 | 'tr': 0,
|
3540 | 'ts': 3,
|
3541 | 'tzm': 22,
|
3542 | 'uk': 11,
|
3543 | 'ur': 3,
|
3544 | 've': 3,
|
3545 | 'vi': 0,
|
3546 | 'vun': 3,
|
3547 | 'wa': 4,
|
3548 | 'wae': 3,
|
3549 | 'wo': 0,
|
3550 | 'xh': 3,
|
3551 | 'xog': 3,
|
3552 | 'yo': 0,
|
3553 | 'zh': 0,
|
3554 | 'zu': 3
|
3555 | };
|
3556 |
|
3557 | function isIn(n, list) {
|
3558 | return list.indexOf(n) !== -1;
|
3559 | }
|
3560 |
|
3561 | function isBetween(n, start, end) {
|
3562 | return start <= n && n <= end;
|
3563 | }
|
3564 |
|
3565 | var pluralRules = {
|
3566 | '0': function _(n) {
|
3567 | return 'other';
|
3568 | },
|
3569 | '1': function _(n) {
|
3570 | if (isBetween(n % 100, 3, 10)) return 'few';
|
3571 | if (n === 0) return 'zero';
|
3572 | if (isBetween(n % 100, 11, 99)) return 'many';
|
3573 | if (n == 2) return 'two';
|
3574 | if (n == 1) return 'one';
|
3575 | return 'other';
|
3576 | },
|
3577 | '2': function _(n) {
|
3578 | if (n !== 0 && n % 10 === 0) return 'many';
|
3579 | if (n == 2) return 'two';
|
3580 | if (n == 1) return 'one';
|
3581 | return 'other';
|
3582 | },
|
3583 | '3': function _(n) {
|
3584 | if (n == 1) return 'one';
|
3585 | return 'other';
|
3586 | },
|
3587 | '4': function _(n) {
|
3588 | if (isBetween(n, 0, 1)) return 'one';
|
3589 | return 'other';
|
3590 | },
|
3591 | '5': function _(n) {
|
3592 | if (isBetween(n, 0, 2) && n != 2) return 'one';
|
3593 | return 'other';
|
3594 | },
|
3595 | '6': function _(n) {
|
3596 | if (n === 0) return 'zero';
|
3597 | if (n % 10 == 1 && n % 100 != 11) return 'one';
|
3598 | return 'other';
|
3599 | },
|
3600 | '7': function _(n) {
|
3601 | if (n == 2) return 'two';
|
3602 | if (n == 1) return 'one';
|
3603 | return 'other';
|
3604 | },
|
3605 | '8': function _(n) {
|
3606 | if (isBetween(n, 3, 6)) return 'few';
|
3607 | if (isBetween(n, 7, 10)) return 'many';
|
3608 | if (n == 2) return 'two';
|
3609 | if (n == 1) return 'one';
|
3610 | return 'other';
|
3611 | },
|
3612 | '9': function _(n) {
|
3613 | if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
|
3614 | if (n == 1) return 'one';
|
3615 | return 'other';
|
3616 | },
|
3617 | '10': function _(n) {
|
3618 | if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
|
3619 | if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
|
3620 | return 'other';
|
3621 | },
|
3622 | '11': function _(n) {
|
3623 | if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
|
3624 | if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
|
3625 | if (n % 10 == 1 && n % 100 != 11) return 'one';
|
3626 | return 'other';
|
3627 | },
|
3628 | '12': function _(n) {
|
3629 | if (isBetween(n, 2, 4)) return 'few';
|
3630 | if (n == 1) return 'one';
|
3631 | return 'other';
|
3632 | },
|
3633 | '13': function _(n) {
|
3634 | if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
|
3635 | if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
|
3636 | if (n == 1) return 'one';
|
3637 | return 'other';
|
3638 | },
|
3639 | '14': function _(n) {
|
3640 | if (isBetween(n % 100, 3, 4)) return 'few';
|
3641 | if (n % 100 == 2) return 'two';
|
3642 | if (n % 100 == 1) return 'one';
|
3643 | return 'other';
|
3644 | },
|
3645 | '15': function _(n) {
|
3646 | if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
|
3647 | if (isBetween(n % 100, 11, 19)) return 'many';
|
3648 | if (n == 1) return 'one';
|
3649 | return 'other';
|
3650 | },
|
3651 | '16': function _(n) {
|
3652 | if (n % 10 == 1 && n != 11) return 'one';
|
3653 | return 'other';
|
3654 | },
|
3655 | '17': function _(n) {
|
3656 | if (n == 3) return 'few';
|
3657 | if (n === 0) return 'zero';
|
3658 | if (n == 6) return 'many';
|
3659 | if (n == 2) return 'two';
|
3660 | if (n == 1) return 'one';
|
3661 | return 'other';
|
3662 | },
|
3663 | '18': function _(n) {
|
3664 | if (n === 0) return 'zero';
|
3665 | if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
|
3666 | return 'other';
|
3667 | },
|
3668 | '19': function _(n) {
|
3669 | if (isBetween(n, 2, 10)) return 'few';
|
3670 | if (isBetween(n, 0, 1)) return 'one';
|
3671 | return 'other';
|
3672 | },
|
3673 | '20': function _(n) {
|
3674 | 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';
|
3675 | if (n % 1000000 === 0 && n !== 0) return 'many';
|
3676 | if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
|
3677 | if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
|
3678 | return 'other';
|
3679 | },
|
3680 | '21': function _(n) {
|
3681 | if (n === 0) return 'zero';
|
3682 | if (n == 1) return 'one';
|
3683 | return 'other';
|
3684 | },
|
3685 | '22': function _(n) {
|
3686 | if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
|
3687 | return 'other';
|
3688 | },
|
3689 | '23': function _(n) {
|
3690 | if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
|
3691 | return 'other';
|
3692 | },
|
3693 | '24': function _(n) {
|
3694 | if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
|
3695 | if (isIn(n, [2, 12])) return 'two';
|
3696 | if (isIn(n, [1, 11])) return 'one';
|
3697 | return 'other';
|
3698 | }
|
3699 | };
|
3700 | var index = locales2rules[lang.replace(/-.*$/, '')];
|
3701 |
|
3702 | if (!(index in pluralRules)) {
|
3703 | console.warn('plural form unknown for [' + lang + ']');
|
3704 | return function () {
|
3705 | return 'other';
|
3706 | };
|
3707 | }
|
3708 |
|
3709 | return pluralRules[index];
|
3710 | }
|
3711 |
|
3712 | gMacros.plural = function (str, param, key, prop) {
|
3713 | var n = parseFloat(param);
|
3714 | if (isNaN(n)) return str;
|
3715 | if (prop != gTextProp) return str;
|
3716 |
|
3717 | if (!gMacros._pluralRules) {
|
3718 | gMacros._pluralRules = getPluralRules(gLanguage);
|
3719 | }
|
3720 |
|
3721 | var index = '[' + gMacros._pluralRules(n) + ']';
|
3722 |
|
3723 | if (n === 0 && key + '[zero]' in gL10nData) {
|
3724 | str = gL10nData[key + '[zero]'][prop];
|
3725 | } else if (n == 1 && key + '[one]' in gL10nData) {
|
3726 | str = gL10nData[key + '[one]'][prop];
|
3727 | } else if (n == 2 && key + '[two]' in gL10nData) {
|
3728 | str = gL10nData[key + '[two]'][prop];
|
3729 | } else if (key + index in gL10nData) {
|
3730 | str = gL10nData[key + index][prop];
|
3731 | } else if (key + '[other]' in gL10nData) {
|
3732 | str = gL10nData[key + '[other]'][prop];
|
3733 | }
|
3734 |
|
3735 | return str;
|
3736 | };
|
3737 |
|
3738 | function getL10nData(key, args, fallback) {
|
3739 | var data = gL10nData[key];
|
3740 |
|
3741 | if (!data) {
|
3742 | console.warn('#' + key + ' is undefined.');
|
3743 |
|
3744 | if (!fallback) {
|
3745 | return null;
|
3746 | }
|
3747 |
|
3748 | data = fallback;
|
3749 | }
|
3750 |
|
3751 | var rv = {};
|
3752 |
|
3753 | for (var prop in data) {
|
3754 | var str = data[prop];
|
3755 | str = substIndexes(str, args, key, prop);
|
3756 | str = substArguments(str, args, key);
|
3757 | rv[prop] = str;
|
3758 | }
|
3759 |
|
3760 | return rv;
|
3761 | }
|
3762 |
|
3763 | function substIndexes(str, args, key, prop) {
|
3764 | var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
|
3765 | var reMatch = reIndex.exec(str);
|
3766 | if (!reMatch || !reMatch.length) return str;
|
3767 | var macroName = reMatch[1];
|
3768 | var paramName = reMatch[2];
|
3769 | var param;
|
3770 |
|
3771 | if (args && paramName in args) {
|
3772 | param = args[paramName];
|
3773 | } else if (paramName in gL10nData) {
|
3774 | param = gL10nData[paramName];
|
3775 | }
|
3776 |
|
3777 | if (macroName in gMacros) {
|
3778 | var macro = gMacros[macroName];
|
3779 | str = macro(str, param, key, prop);
|
3780 | }
|
3781 |
|
3782 | return str;
|
3783 | }
|
3784 |
|
3785 | function substArguments(str, args, key) {
|
3786 | var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
|
3787 | return str.replace(reArgs, function (matched_text, arg) {
|
3788 | if (args && arg in args) {
|
3789 | return args[arg];
|
3790 | }
|
3791 |
|
3792 | if (arg in gL10nData) {
|
3793 | return gL10nData[arg];
|
3794 | }
|
3795 |
|
3796 | console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
|
3797 | return matched_text;
|
3798 | });
|
3799 | }
|
3800 |
|
3801 | function translateElement(element) {
|
3802 | var l10n = getL10nAttributes(element);
|
3803 | if (!l10n.id) return;
|
3804 | var data = getL10nData(l10n.id, l10n.args);
|
3805 |
|
3806 | if (!data) {
|
3807 | console.warn('#' + l10n.id + ' is undefined.');
|
3808 | return;
|
3809 | }
|
3810 |
|
3811 | if (data[gTextProp]) {
|
3812 | if (getChildElementCount(element) === 0) {
|
3813 | element[gTextProp] = data[gTextProp];
|
3814 | } else {
|
3815 | var children = element.childNodes;
|
3816 | var found = false;
|
3817 |
|
3818 | for (var i = 0, l = children.length; i < l; i++) {
|
3819 | if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
|
3820 | if (found) {
|
3821 | children[i].nodeValue = '';
|
3822 | } else {
|
3823 | children[i].nodeValue = data[gTextProp];
|
3824 | found = true;
|
3825 | }
|
3826 | }
|
3827 | }
|
3828 |
|
3829 | if (!found) {
|
3830 | var textNode = document.createTextNode(data[gTextProp]);
|
3831 | element.insertBefore(textNode, element.firstChild);
|
3832 | }
|
3833 | }
|
3834 |
|
3835 | delete data[gTextProp];
|
3836 | }
|
3837 |
|
3838 | for (var k in data) {
|
3839 | element[k] = data[k];
|
3840 | }
|
3841 | }
|
3842 |
|
3843 | function getChildElementCount(element) {
|
3844 | if (element.children) {
|
3845 | return element.children.length;
|
3846 | }
|
3847 |
|
3848 | if (typeof element.childElementCount !== 'undefined') {
|
3849 | return element.childElementCount;
|
3850 | }
|
3851 |
|
3852 | var count = 0;
|
3853 |
|
3854 | for (var i = 0; i < element.childNodes.length; i++) {
|
3855 | count += element.nodeType === 1 ? 1 : 0;
|
3856 | }
|
3857 |
|
3858 | return count;
|
3859 | }
|
3860 |
|
3861 | function translateFragment(element) {
|
3862 | element = element || document.documentElement;
|
3863 | var children = getTranslatableChildren(element);
|
3864 | var elementCount = children.length;
|
3865 |
|
3866 | for (var i = 0; i < elementCount; i++) {
|
3867 | translateElement(children[i]);
|
3868 | }
|
3869 |
|
3870 | translateElement(element);
|
3871 | }
|
3872 |
|
3873 | return {
|
3874 | get: function get(key, args, fallbackString) {
|
3875 | var index = key.lastIndexOf('.');
|
3876 | var prop = gTextProp;
|
3877 |
|
3878 | if (index > 0) {
|
3879 | prop = key.substring(index + 1);
|
3880 | key = key.substring(0, index);
|
3881 | }
|
3882 |
|
3883 | var fallback;
|
3884 |
|
3885 | if (fallbackString) {
|
3886 | fallback = {};
|
3887 | fallback[prop] = fallbackString;
|
3888 | }
|
3889 |
|
3890 | var data = getL10nData(key, args, fallback);
|
3891 |
|
3892 | if (data && prop in data) {
|
3893 | return data[prop];
|
3894 | }
|
3895 |
|
3896 | return '{{' + key + '}}';
|
3897 | },
|
3898 | getData: function getData() {
|
3899 | return gL10nData;
|
3900 | },
|
3901 | getText: function getText() {
|
3902 | return gTextData;
|
3903 | },
|
3904 | getLanguage: function getLanguage() {
|
3905 | return gLanguage;
|
3906 | },
|
3907 | setLanguage: function setLanguage(lang, callback) {
|
3908 | loadLocale(lang, function () {
|
3909 | if (callback) callback();
|
3910 | });
|
3911 | },
|
3912 | getDirection: function getDirection() {
|
3913 | var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
|
3914 | var shortCode = gLanguage.split('-', 1)[0];
|
3915 | return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
|
3916 | },
|
3917 | translate: translateFragment,
|
3918 | getReadyState: function getReadyState() {
|
3919 | return gReadyState;
|
3920 | },
|
3921 | ready: function ready(callback) {
|
3922 | if (!callback) {
|
3923 | return;
|
3924 | } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
|
3925 | window.setTimeout(function () {
|
3926 | callback();
|
3927 | });
|
3928 | } else if (document.addEventListener) {
|
3929 | document.addEventListener('localized', function once() {
|
3930 | document.removeEventListener('localized', once);
|
3931 | callback();
|
3932 | });
|
3933 | }
|
3934 | }
|
3935 | };
|
3936 | }(window, document);
|
3937 |
|
3938 | }),
|
3939 |
|
3940 | (function(module, exports, __w_pdfjs_require__) {
|
3941 |
|
3942 | "use strict";
|
3943 |
|
3944 |
|
3945 | Object.defineProperty(exports, "__esModule", {
|
3946 | value: true
|
3947 | });
|
3948 | exports.PDFFindController = exports.FindState = void 0;
|
3949 |
|
3950 | var _ui_utils = __w_pdfjs_require__(3);
|
3951 |
|
3952 | var _pdfjsLib = __w_pdfjs_require__(2);
|
3953 |
|
3954 | var _pdf_find_utils = __w_pdfjs_require__(13);
|
3955 |
|
3956 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3957 |
|
3958 | 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); } }
|
3959 |
|
3960 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
3961 |
|
3962 | var FindState = {
|
3963 | FOUND: 0,
|
3964 | NOT_FOUND: 1,
|
3965 | WRAPPED: 2,
|
3966 | PENDING: 3
|
3967 | };
|
3968 | exports.FindState = FindState;
|
3969 | var FIND_TIMEOUT = 250;
|
3970 | var MATCH_SCROLL_OFFSET_TOP = -50;
|
3971 | var MATCH_SCROLL_OFFSET_LEFT = -400;
|
3972 | var CHARACTERS_TO_NORMALIZE = {
|
3973 | "\u2018": '\'',
|
3974 | "\u2019": '\'',
|
3975 | "\u201A": '\'',
|
3976 | "\u201B": '\'',
|
3977 | "\u201C": '"',
|
3978 | "\u201D": '"',
|
3979 | "\u201E": '"',
|
3980 | "\u201F": '"',
|
3981 | "\xBC": '1/4',
|
3982 | "\xBD": '1/2',
|
3983 | "\xBE": '3/4'
|
3984 | };
|
3985 | var normalizationRegex = null;
|
3986 |
|
3987 | function normalize(text) {
|
3988 | if (!normalizationRegex) {
|
3989 | var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
|
3990 | normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
|
3991 | }
|
3992 |
|
3993 | return text.replace(normalizationRegex, function (ch) {
|
3994 | return CHARACTERS_TO_NORMALIZE[ch];
|
3995 | });
|
3996 | }
|
3997 |
|
3998 | var PDFFindController =
|
3999 |
|
4000 | function () {
|
4001 | function PDFFindController(_ref) {
|
4002 | var linkService = _ref.linkService,
|
4003 | _ref$eventBus = _ref.eventBus,
|
4004 | eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
|
4005 |
|
4006 | _classCallCheck(this, PDFFindController);
|
4007 |
|
4008 | this._linkService = linkService;
|
4009 | this._eventBus = eventBus;
|
4010 |
|
4011 | this._reset();
|
4012 |
|
4013 | eventBus.on('findbarclose', this._onFindBarClose.bind(this));
|
4014 | }
|
4015 |
|
4016 | _createClass(PDFFindController, [{
|
4017 | key: "setDocument",
|
4018 | value: function setDocument(pdfDocument) {
|
4019 | if (this._pdfDocument) {
|
4020 | this._reset();
|
4021 | }
|
4022 |
|
4023 | if (!pdfDocument) {
|
4024 | return;
|
4025 | }
|
4026 |
|
4027 | this._pdfDocument = pdfDocument;
|
4028 |
|
4029 | this._firstPageCapability.resolve();
|
4030 | }
|
4031 | }, {
|
4032 | key: "executeCommand",
|
4033 | value: function executeCommand(cmd, state) {
|
4034 | var _this = this;
|
4035 |
|
4036 | if (!state) {
|
4037 | return;
|
4038 | }
|
4039 |
|
4040 | var pdfDocument = this._pdfDocument;
|
4041 |
|
4042 | if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
|
4043 | this._dirtyMatch = true;
|
4044 | }
|
4045 |
|
4046 | this._state = state;
|
4047 |
|
4048 | if (cmd !== 'findhighlightallchange') {
|
4049 | this._updateUIState(FindState.PENDING);
|
4050 | }
|
4051 |
|
4052 | this._firstPageCapability.promise.then(function () {
|
4053 | if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
|
4054 | return;
|
4055 | }
|
4056 |
|
4057 | _this._extractText();
|
4058 |
|
4059 | var findbarClosed = !_this._highlightMatches;
|
4060 | var pendingTimeout = !!_this._findTimeout;
|
4061 |
|
4062 | if (_this._findTimeout) {
|
4063 | clearTimeout(_this._findTimeout);
|
4064 | _this._findTimeout = null;
|
4065 | }
|
4066 |
|
4067 | if (cmd === 'find') {
|
4068 | _this._findTimeout = setTimeout(function () {
|
4069 | _this._nextMatch();
|
4070 |
|
4071 | _this._findTimeout = null;
|
4072 | }, FIND_TIMEOUT);
|
4073 | } else if (_this._dirtyMatch) {
|
4074 | _this._nextMatch();
|
4075 | } else if (cmd === 'findagain') {
|
4076 | _this._nextMatch();
|
4077 |
|
4078 | if (findbarClosed && _this._state.highlightAll) {
|
4079 | _this._updateAllPages();
|
4080 | }
|
4081 | } else if (cmd === 'findhighlightallchange') {
|
4082 | if (pendingTimeout) {
|
4083 | _this._nextMatch();
|
4084 | } else {
|
4085 | _this._highlightMatches = true;
|
4086 | }
|
4087 |
|
4088 | _this._updateAllPages();
|
4089 | } else {
|
4090 | _this._nextMatch();
|
4091 | }
|
4092 | });
|
4093 | }
|
4094 | }, {
|
4095 | key: "scrollMatchIntoView",
|
4096 | value: function scrollMatchIntoView(_ref2) {
|
4097 | var _ref2$element = _ref2.element,
|
4098 | element = _ref2$element === void 0 ? null : _ref2$element,
|
4099 | _ref2$pageIndex = _ref2.pageIndex,
|
4100 | pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
|
4101 | _ref2$matchIndex = _ref2.matchIndex,
|
4102 | matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
|
4103 |
|
4104 | if (!this._scrollMatches || !element) {
|
4105 | return;
|
4106 | } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
|
4107 | return;
|
4108 | } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
|
4109 | return;
|
4110 | }
|
4111 |
|
4112 | this._scrollMatches = false;
|
4113 | var spot = {
|
4114 | top: MATCH_SCROLL_OFFSET_TOP,
|
4115 | left: MATCH_SCROLL_OFFSET_LEFT
|
4116 | };
|
4117 | (0, _ui_utils.scrollIntoView)(element, spot, true);
|
4118 | }
|
4119 | }, {
|
4120 | key: "_reset",
|
4121 | value: function _reset() {
|
4122 | this._highlightMatches = false;
|
4123 | this._scrollMatches = false;
|
4124 | this._pdfDocument = null;
|
4125 | this._pageMatches = [];
|
4126 | this._pageMatchesLength = [];
|
4127 | this._state = null;
|
4128 | this._selected = {
|
4129 | pageIdx: -1,
|
4130 | matchIdx: -1
|
4131 | };
|
4132 | this._offset = {
|
4133 | pageIdx: null,
|
4134 | matchIdx: null,
|
4135 | wrapped: false
|
4136 | };
|
4137 | this._extractTextPromises = [];
|
4138 | this._pageContents = [];
|
4139 | this._matchesCountTotal = 0;
|
4140 | this._pagesToSearch = null;
|
4141 | this._pendingFindMatches = Object.create(null);
|
4142 | this._resumePageIdx = null;
|
4143 | this._dirtyMatch = false;
|
4144 | clearTimeout(this._findTimeout);
|
4145 | this._findTimeout = null;
|
4146 | this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
|
4147 | }
|
4148 | }, {
|
4149 | key: "_shouldDirtyMatch",
|
4150 | value: function _shouldDirtyMatch(cmd, state) {
|
4151 | if (state.query !== this._state.query) {
|
4152 | return true;
|
4153 | }
|
4154 |
|
4155 | switch (cmd) {
|
4156 | case 'findagain':
|
4157 | var pageNumber = this._selected.pageIdx + 1;
|
4158 | var linkService = this._linkService;
|
4159 |
|
4160 | if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
|
4161 | return true;
|
4162 | }
|
4163 |
|
4164 | return false;
|
4165 |
|
4166 | case 'findhighlightallchange':
|
4167 | return false;
|
4168 | }
|
4169 |
|
4170 | return true;
|
4171 | }
|
4172 | }, {
|
4173 | key: "_prepareMatches",
|
4174 | value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
|
4175 | function isSubTerm(matchesWithLength, currentIndex) {
|
4176 | var currentElem = matchesWithLength[currentIndex];
|
4177 | var nextElem = matchesWithLength[currentIndex + 1];
|
4178 |
|
4179 | if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
|
4180 | currentElem.skipped = true;
|
4181 | return true;
|
4182 | }
|
4183 |
|
4184 | for (var i = currentIndex - 1; i >= 0; i--) {
|
4185 | var prevElem = matchesWithLength[i];
|
4186 |
|
4187 | if (prevElem.skipped) {
|
4188 | continue;
|
4189 | }
|
4190 |
|
4191 | if (prevElem.match + prevElem.matchLength < currentElem.match) {
|
4192 | break;
|
4193 | }
|
4194 |
|
4195 | if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
|
4196 | currentElem.skipped = true;
|
4197 | return true;
|
4198 | }
|
4199 | }
|
4200 |
|
4201 | return false;
|
4202 | }
|
4203 |
|
4204 | matchesWithLength.sort(function (a, b) {
|
4205 | return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
|
4206 | });
|
4207 |
|
4208 | for (var i = 0, len = matchesWithLength.length; i < len; i++) {
|
4209 | if (isSubTerm(matchesWithLength, i)) {
|
4210 | continue;
|
4211 | }
|
4212 |
|
4213 | matches.push(matchesWithLength[i].match);
|
4214 | matchesLength.push(matchesWithLength[i].matchLength);
|
4215 | }
|
4216 | }
|
4217 | }, {
|
4218 | key: "_isEntireWord",
|
4219 | value: function _isEntireWord(content, startIdx, length) {
|
4220 | if (startIdx > 0) {
|
4221 | var first = content.charCodeAt(startIdx);
|
4222 | var limit = content.charCodeAt(startIdx - 1);
|
4223 |
|
4224 | if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
|
4225 | return false;
|
4226 | }
|
4227 | }
|
4228 |
|
4229 | var endIdx = startIdx + length - 1;
|
4230 |
|
4231 | if (endIdx < content.length - 1) {
|
4232 | var last = content.charCodeAt(endIdx);
|
4233 |
|
4234 | var _limit = content.charCodeAt(endIdx + 1);
|
4235 |
|
4236 | if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
|
4237 | return false;
|
4238 | }
|
4239 | }
|
4240 |
|
4241 | return true;
|
4242 | }
|
4243 | }, {
|
4244 | key: "_calculatePhraseMatch",
|
4245 | value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
|
4246 | var matches = [];
|
4247 | var queryLen = query.length;
|
4248 | var matchIdx = -queryLen;
|
4249 |
|
4250 | while (true) {
|
4251 | matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
|
4252 |
|
4253 | if (matchIdx === -1) {
|
4254 | break;
|
4255 | }
|
4256 |
|
4257 | if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
|
4258 | continue;
|
4259 | }
|
4260 |
|
4261 | matches.push(matchIdx);
|
4262 | }
|
4263 |
|
4264 | this._pageMatches[pageIndex] = matches;
|
4265 | }
|
4266 | }, {
|
4267 | key: "_calculateWordMatch",
|
4268 | value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
|
4269 | var matchesWithLength = [];
|
4270 | var queryArray = query.match(/\S+/g);
|
4271 |
|
4272 | for (var i = 0, len = queryArray.length; i < len; i++) {
|
4273 | var subquery = queryArray[i];
|
4274 | var subqueryLen = subquery.length;
|
4275 | var matchIdx = -subqueryLen;
|
4276 |
|
4277 | while (true) {
|
4278 | matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
|
4279 |
|
4280 | if (matchIdx === -1) {
|
4281 | break;
|
4282 | }
|
4283 |
|
4284 | if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
|
4285 | continue;
|
4286 | }
|
4287 |
|
4288 | matchesWithLength.push({
|
4289 | match: matchIdx,
|
4290 | matchLength: subqueryLen,
|
4291 | skipped: false
|
4292 | });
|
4293 | }
|
4294 | }
|
4295 |
|
4296 | this._pageMatchesLength[pageIndex] = [];
|
4297 | this._pageMatches[pageIndex] = [];
|
4298 |
|
4299 | this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
|
4300 | }
|
4301 | }, {
|
4302 | key: "_calculateMatch",
|
4303 | value: function _calculateMatch(pageIndex) {
|
4304 | var pageContent = this._pageContents[pageIndex];
|
4305 | var query = this._query;
|
4306 | var _this$_state = this._state,
|
4307 | caseSensitive = _this$_state.caseSensitive,
|
4308 | entireWord = _this$_state.entireWord,
|
4309 | phraseSearch = _this$_state.phraseSearch;
|
4310 |
|
4311 | if (query.length === 0) {
|
4312 | return;
|
4313 | }
|
4314 |
|
4315 | if (!caseSensitive) {
|
4316 | pageContent = pageContent.toLowerCase();
|
4317 | query = query.toLowerCase();
|
4318 | }
|
4319 |
|
4320 | if (phraseSearch) {
|
4321 | this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
|
4322 | } else {
|
4323 | this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
|
4324 | }
|
4325 |
|
4326 | if (this._state.highlightAll) {
|
4327 | this._updatePage(pageIndex);
|
4328 | }
|
4329 |
|
4330 | if (this._resumePageIdx === pageIndex) {
|
4331 | this._resumePageIdx = null;
|
4332 |
|
4333 | this._nextPageMatch();
|
4334 | }
|
4335 |
|
4336 | var pageMatchesCount = this._pageMatches[pageIndex].length;
|
4337 |
|
4338 | if (pageMatchesCount > 0) {
|
4339 | this._matchesCountTotal += pageMatchesCount;
|
4340 |
|
4341 | this._updateUIResultsCount();
|
4342 | }
|
4343 | }
|
4344 | }, {
|
4345 | key: "_extractText",
|
4346 | value: function _extractText() {
|
4347 | var _this2 = this;
|
4348 |
|
4349 | if (this._extractTextPromises.length > 0) {
|
4350 | return;
|
4351 | }
|
4352 |
|
4353 | var promise = Promise.resolve();
|
4354 |
|
4355 | var _loop = function _loop(i, ii) {
|
4356 | var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
|
4357 | _this2._extractTextPromises[i] = extractTextCapability.promise;
|
4358 | promise = promise.then(function () {
|
4359 | return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
|
4360 | return pdfPage.getTextContent({
|
4361 | normalizeWhitespace: true
|
4362 | });
|
4363 | }).then(function (textContent) {
|
4364 | var textItems = textContent.items;
|
4365 | var strBuf = [];
|
4366 |
|
4367 | for (var j = 0, jj = textItems.length; j < jj; j++) {
|
4368 | strBuf.push(textItems[j].str);
|
4369 | }
|
4370 |
|
4371 | _this2._pageContents[i] = normalize(strBuf.join(''));
|
4372 | extractTextCapability.resolve(i);
|
4373 | }, function (reason) {
|
4374 | console.error("Unable to get text content for page ".concat(i + 1), reason);
|
4375 | _this2._pageContents[i] = '';
|
4376 | extractTextCapability.resolve(i);
|
4377 | });
|
4378 | });
|
4379 | };
|
4380 |
|
4381 | for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
|
4382 | _loop(i, ii);
|
4383 | }
|
4384 | }
|
4385 | }, {
|
4386 | key: "_updatePage",
|
4387 | value: function _updatePage(index) {
|
4388 | if (this._scrollMatches && this._selected.pageIdx === index) {
|
4389 | this._linkService.page = index + 1;
|
4390 | }
|
4391 |
|
4392 | this._eventBus.dispatch('updatetextlayermatches', {
|
4393 | source: this,
|
4394 | pageIndex: index
|
4395 | });
|
4396 | }
|
4397 | }, {
|
4398 | key: "_updateAllPages",
|
4399 | value: function _updateAllPages() {
|
4400 | this._eventBus.dispatch('updatetextlayermatches', {
|
4401 | source: this,
|
4402 | pageIndex: -1
|
4403 | });
|
4404 | }
|
4405 | }, {
|
4406 | key: "_nextMatch",
|
4407 | value: function _nextMatch() {
|
4408 | var _this3 = this;
|
4409 |
|
4410 | var previous = this._state.findPrevious;
|
4411 | var currentPageIndex = this._linkService.page - 1;
|
4412 | var numPages = this._linkService.pagesCount;
|
4413 | this._highlightMatches = true;
|
4414 |
|
4415 | if (this._dirtyMatch) {
|
4416 | this._dirtyMatch = false;
|
4417 | this._selected.pageIdx = this._selected.matchIdx = -1;
|
4418 | this._offset.pageIdx = currentPageIndex;
|
4419 | this._offset.matchIdx = null;
|
4420 | this._offset.wrapped = false;
|
4421 | this._resumePageIdx = null;
|
4422 | this._pageMatches.length = 0;
|
4423 | this._pageMatchesLength.length = 0;
|
4424 | this._matchesCountTotal = 0;
|
4425 |
|
4426 | this._updateAllPages();
|
4427 |
|
4428 | for (var i = 0; i < numPages; i++) {
|
4429 | if (this._pendingFindMatches[i] === true) {
|
4430 | continue;
|
4431 | }
|
4432 |
|
4433 | this._pendingFindMatches[i] = true;
|
4434 |
|
4435 | this._extractTextPromises[i].then(function (pageIdx) {
|
4436 | delete _this3._pendingFindMatches[pageIdx];
|
4437 |
|
4438 | _this3._calculateMatch(pageIdx);
|
4439 | });
|
4440 | }
|
4441 | }
|
4442 |
|
4443 | if (this._query === '') {
|
4444 | this._updateUIState(FindState.FOUND);
|
4445 |
|
4446 | return;
|
4447 | }
|
4448 |
|
4449 | if (this._resumePageIdx) {
|
4450 | return;
|
4451 | }
|
4452 |
|
4453 | var offset = this._offset;
|
4454 | this._pagesToSearch = numPages;
|
4455 |
|
4456 | if (offset.matchIdx !== null) {
|
4457 | var numPageMatches = this._pageMatches[offset.pageIdx].length;
|
4458 |
|
4459 | if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
|
4460 | offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
|
4461 |
|
4462 | this._updateMatch(true);
|
4463 |
|
4464 | return;
|
4465 | }
|
4466 |
|
4467 | this._advanceOffsetPage(previous);
|
4468 | }
|
4469 |
|
4470 | this._nextPageMatch();
|
4471 | }
|
4472 | }, {
|
4473 | key: "_matchesReady",
|
4474 | value: function _matchesReady(matches) {
|
4475 | var offset = this._offset;
|
4476 | var numMatches = matches.length;
|
4477 | var previous = this._state.findPrevious;
|
4478 |
|
4479 | if (numMatches) {
|
4480 | offset.matchIdx = previous ? numMatches - 1 : 0;
|
4481 |
|
4482 | this._updateMatch(true);
|
4483 |
|
4484 | return true;
|
4485 | }
|
4486 |
|
4487 | this._advanceOffsetPage(previous);
|
4488 |
|
4489 | if (offset.wrapped) {
|
4490 | offset.matchIdx = null;
|
4491 |
|
4492 | if (this._pagesToSearch < 0) {
|
4493 | this._updateMatch(false);
|
4494 |
|
4495 | return true;
|
4496 | }
|
4497 | }
|
4498 |
|
4499 | return false;
|
4500 | }
|
4501 | }, {
|
4502 | key: "_nextPageMatch",
|
4503 | value: function _nextPageMatch() {
|
4504 | if (this._resumePageIdx !== null) {
|
4505 | console.error('There can only be one pending page.');
|
4506 | }
|
4507 |
|
4508 | var matches = null;
|
4509 |
|
4510 | do {
|
4511 | var pageIdx = this._offset.pageIdx;
|
4512 | matches = this._pageMatches[pageIdx];
|
4513 |
|
4514 | if (!matches) {
|
4515 | this._resumePageIdx = pageIdx;
|
4516 | break;
|
4517 | }
|
4518 | } while (!this._matchesReady(matches));
|
4519 | }
|
4520 | }, {
|
4521 | key: "_advanceOffsetPage",
|
4522 | value: function _advanceOffsetPage(previous) {
|
4523 | var offset = this._offset;
|
4524 | var numPages = this._linkService.pagesCount;
|
4525 | offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
|
4526 | offset.matchIdx = null;
|
4527 | this._pagesToSearch--;
|
4528 |
|
4529 | if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
|
4530 | offset.pageIdx = previous ? numPages - 1 : 0;
|
4531 | offset.wrapped = true;
|
4532 | }
|
4533 | }
|
4534 | }, {
|
4535 | key: "_updateMatch",
|
4536 | value: function _updateMatch() {
|
4537 | var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
4538 | var state = FindState.NOT_FOUND;
|
4539 | var wrapped = this._offset.wrapped;
|
4540 | this._offset.wrapped = false;
|
4541 |
|
4542 | if (found) {
|
4543 | var previousPage = this._selected.pageIdx;
|
4544 | this._selected.pageIdx = this._offset.pageIdx;
|
4545 | this._selected.matchIdx = this._offset.matchIdx;
|
4546 | state = wrapped ? FindState.WRAPPED : FindState.FOUND;
|
4547 |
|
4548 | if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
|
4549 | this._updatePage(previousPage);
|
4550 | }
|
4551 | }
|
4552 |
|
4553 | this._updateUIState(state, this._state.findPrevious);
|
4554 |
|
4555 | if (this._selected.pageIdx !== -1) {
|
4556 | this._scrollMatches = true;
|
4557 |
|
4558 | this._updatePage(this._selected.pageIdx);
|
4559 | }
|
4560 | }
|
4561 | }, {
|
4562 | key: "_onFindBarClose",
|
4563 | value: function _onFindBarClose(evt) {
|
4564 | var _this4 = this;
|
4565 |
|
4566 | var pdfDocument = this._pdfDocument;
|
4567 |
|
4568 | this._firstPageCapability.promise.then(function () {
|
4569 | if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
|
4570 | return;
|
4571 | }
|
4572 |
|
4573 | if (_this4._findTimeout) {
|
4574 | clearTimeout(_this4._findTimeout);
|
4575 | _this4._findTimeout = null;
|
4576 | }
|
4577 |
|
4578 | if (_this4._resumePageIdx) {
|
4579 | _this4._resumePageIdx = null;
|
4580 | _this4._dirtyMatch = true;
|
4581 | }
|
4582 |
|
4583 | _this4._updateUIState(FindState.FOUND);
|
4584 |
|
4585 | _this4._highlightMatches = false;
|
4586 |
|
4587 | _this4._updateAllPages();
|
4588 | });
|
4589 | }
|
4590 | }, {
|
4591 | key: "_requestMatchesCount",
|
4592 | value: function _requestMatchesCount() {
|
4593 | var _this$_selected = this._selected,
|
4594 | pageIdx = _this$_selected.pageIdx,
|
4595 | matchIdx = _this$_selected.matchIdx;
|
4596 | var current = 0,
|
4597 | total = this._matchesCountTotal;
|
4598 |
|
4599 | if (matchIdx !== -1) {
|
4600 | for (var i = 0; i < pageIdx; i++) {
|
4601 | current += this._pageMatches[i] && this._pageMatches[i].length || 0;
|
4602 | }
|
4603 |
|
4604 | current += matchIdx + 1;
|
4605 | }
|
4606 |
|
4607 | if (current < 1 || current > total) {
|
4608 | current = total = 0;
|
4609 | }
|
4610 |
|
4611 | return {
|
4612 | current: current,
|
4613 | total: total
|
4614 | };
|
4615 | }
|
4616 | }, {
|
4617 | key: "_updateUIResultsCount",
|
4618 | value: function _updateUIResultsCount() {
|
4619 | this._eventBus.dispatch('updatefindmatchescount', {
|
4620 | source: this,
|
4621 | matchesCount: this._requestMatchesCount()
|
4622 | });
|
4623 | }
|
4624 | }, {
|
4625 | key: "_updateUIState",
|
4626 | value: function _updateUIState(state, previous) {
|
4627 | this._eventBus.dispatch('updatefindcontrolstate', {
|
4628 | source: this,
|
4629 | state: state,
|
4630 | previous: previous,
|
4631 | matchesCount: this._requestMatchesCount()
|
4632 | });
|
4633 | }
|
4634 | }, {
|
4635 | key: "highlightMatches",
|
4636 | get: function get() {
|
4637 | return this._highlightMatches;
|
4638 | }
|
4639 | }, {
|
4640 | key: "pageMatches",
|
4641 | get: function get() {
|
4642 | return this._pageMatches;
|
4643 | }
|
4644 | }, {
|
4645 | key: "pageMatchesLength",
|
4646 | get: function get() {
|
4647 | return this._pageMatchesLength;
|
4648 | }
|
4649 | }, {
|
4650 | key: "selected",
|
4651 | get: function get() {
|
4652 | return this._selected;
|
4653 | }
|
4654 | }, {
|
4655 | key: "state",
|
4656 | get: function get() {
|
4657 | return this._state;
|
4658 | }
|
4659 | }, {
|
4660 | key: "_query",
|
4661 | get: function get() {
|
4662 | if (this._state.query !== this._rawQuery) {
|
4663 | this._rawQuery = this._state.query;
|
4664 | this._normalizedQuery = normalize(this._state.query);
|
4665 | }
|
4666 |
|
4667 | return this._normalizedQuery;
|
4668 | }
|
4669 | }]);
|
4670 |
|
4671 | return PDFFindController;
|
4672 | }();
|
4673 |
|
4674 | exports.PDFFindController = PDFFindController;
|
4675 |
|
4676 | }),
|
4677 |
|
4678 | (function(module, exports, __w_pdfjs_require__) {
|
4679 |
|
4680 | "use strict";
|
4681 |
|
4682 |
|
4683 | Object.defineProperty(exports, "__esModule", {
|
4684 | value: true
|
4685 | });
|
4686 | exports.getCharacterType = getCharacterType;
|
4687 | exports.CharacterType = void 0;
|
4688 | var CharacterType = {
|
4689 | SPACE: 0,
|
4690 | ALPHA_LETTER: 1,
|
4691 | PUNCT: 2,
|
4692 | HAN_LETTER: 3,
|
4693 | KATAKANA_LETTER: 4,
|
4694 | HIRAGANA_LETTER: 5,
|
4695 | HALFWIDTH_KATAKANA_LETTER: 6,
|
4696 | THAI_LETTER: 7
|
4697 | };
|
4698 | exports.CharacterType = CharacterType;
|
4699 |
|
4700 | function isAlphabeticalScript(charCode) {
|
4701 | return charCode < 0x2E80;
|
4702 | }
|
4703 |
|
4704 | function isAscii(charCode) {
|
4705 | return (charCode & 0xFF80) === 0;
|
4706 | }
|
4707 |
|
4708 | function isAsciiAlpha(charCode) {
|
4709 | return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
|
4710 | }
|
4711 |
|
4712 | function isAsciiDigit(charCode) {
|
4713 | return charCode >= 0x30 && charCode <= 0x39;
|
4714 | }
|
4715 |
|
4716 | function isAsciiSpace(charCode) {
|
4717 | return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
|
4718 | }
|
4719 |
|
4720 | function isHan(charCode) {
|
4721 | return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
|
4722 | }
|
4723 |
|
4724 | function isKatakana(charCode) {
|
4725 | return charCode >= 0x30A0 && charCode <= 0x30FF;
|
4726 | }
|
4727 |
|
4728 | function isHiragana(charCode) {
|
4729 | return charCode >= 0x3040 && charCode <= 0x309F;
|
4730 | }
|
4731 |
|
4732 | function isHalfwidthKatakana(charCode) {
|
4733 | return charCode >= 0xFF60 && charCode <= 0xFF9F;
|
4734 | }
|
4735 |
|
4736 | function isThai(charCode) {
|
4737 | return (charCode & 0xFF80) === 0x0E00;
|
4738 | }
|
4739 |
|
4740 | function getCharacterType(charCode) {
|
4741 | if (isAlphabeticalScript(charCode)) {
|
4742 | if (isAscii(charCode)) {
|
4743 | if (isAsciiSpace(charCode)) {
|
4744 | return CharacterType.SPACE;
|
4745 | } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
|
4746 | return CharacterType.ALPHA_LETTER;
|
4747 | }
|
4748 |
|
4749 | return CharacterType.PUNCT;
|
4750 | } else if (isThai(charCode)) {
|
4751 | return CharacterType.THAI_LETTER;
|
4752 | } else if (charCode === 0xA0) {
|
4753 | return CharacterType.SPACE;
|
4754 | }
|
4755 |
|
4756 | return CharacterType.ALPHA_LETTER;
|
4757 | }
|
4758 |
|
4759 | if (isHan(charCode)) {
|
4760 | return CharacterType.HAN_LETTER;
|
4761 | } else if (isKatakana(charCode)) {
|
4762 | return CharacterType.KATAKANA_LETTER;
|
4763 | } else if (isHiragana(charCode)) {
|
4764 | return CharacterType.HIRAGANA_LETTER;
|
4765 | } else if (isHalfwidthKatakana(charCode)) {
|
4766 | return CharacterType.HALFWIDTH_KATAKANA_LETTER;
|
4767 | }
|
4768 |
|
4769 | return CharacterType.ALPHA_LETTER;
|
4770 | }
|
4771 |
|
4772 | }),
|
4773 |
|
4774 | (function(module, exports, __w_pdfjs_require__) {
|
4775 |
|
4776 | "use strict";
|
4777 |
|
4778 |
|
4779 | Object.defineProperty(exports, "__esModule", {
|
4780 | value: true
|
4781 | });
|
4782 | exports.isDestHashesEqual = isDestHashesEqual;
|
4783 | exports.isDestArraysEqual = isDestArraysEqual;
|
4784 | exports.PDFHistory = void 0;
|
4785 |
|
4786 | var _ui_utils = __w_pdfjs_require__(3);
|
4787 |
|
4788 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4789 |
|
4790 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
4791 |
|
4792 | function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
4793 |
|
4794 | function _iterableToArrayLimit(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"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
4795 |
|
4796 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
4797 |
|
4798 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4799 |
|
4800 | 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); } }
|
4801 |
|
4802 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
4803 |
|
4804 | var HASH_CHANGE_TIMEOUT = 1000;
|
4805 | var POSITION_UPDATED_THRESHOLD = 50;
|
4806 | var UPDATE_VIEWAREA_TIMEOUT = 1000;
|
4807 |
|
4808 | function getCurrentHash() {
|
4809 | return document.location.hash;
|
4810 | }
|
4811 |
|
4812 | function parseCurrentHash(linkService) {
|
4813 | var hash = unescape(getCurrentHash()).substring(1);
|
4814 | var params = (0, _ui_utils.parseQueryString)(hash);
|
4815 | var page = params.page | 0;
|
4816 |
|
4817 | if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
|
4818 | page = null;
|
4819 | }
|
4820 |
|
4821 | return {
|
4822 | hash: hash,
|
4823 | page: page,
|
4824 | rotation: linkService.rotation
|
4825 | };
|
4826 | }
|
4827 |
|
4828 | var PDFHistory =
|
4829 |
|
4830 | function () {
|
4831 | function PDFHistory(_ref) {
|
4832 | var _this = this;
|
4833 |
|
4834 | var linkService = _ref.linkService,
|
4835 | eventBus = _ref.eventBus;
|
4836 |
|
4837 | _classCallCheck(this, PDFHistory);
|
4838 |
|
4839 | this.linkService = linkService;
|
4840 | this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
|
4841 | this.initialized = false;
|
4842 | this.initialBookmark = null;
|
4843 | this.initialRotation = null;
|
4844 | this._boundEvents = Object.create(null);
|
4845 | this._isViewerInPresentationMode = false;
|
4846 | this._isPagesLoaded = false;
|
4847 | this.eventBus.on('presentationmodechanged', function (evt) {
|
4848 | _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
|
4849 | });
|
4850 | this.eventBus.on('pagesloaded', function (evt) {
|
4851 | _this._isPagesLoaded = !!evt.pagesCount;
|
4852 | });
|
4853 | }
|
4854 |
|
4855 | _createClass(PDFHistory, [{
|
4856 | key: "initialize",
|
4857 | value: function initialize(_ref2) {
|
4858 | var fingerprint = _ref2.fingerprint,
|
4859 | _ref2$resetHistory = _ref2.resetHistory,
|
4860 | resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
|
4861 | _ref2$updateUrl = _ref2.updateUrl,
|
4862 | updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
|
4863 |
|
4864 | if (!fingerprint || typeof fingerprint !== 'string') {
|
4865 | console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
|
4866 | return;
|
4867 | }
|
4868 |
|
4869 | var reInitialized = this.initialized && this.fingerprint !== fingerprint;
|
4870 | this.fingerprint = fingerprint;
|
4871 | this._updateUrl = updateUrl === true;
|
4872 |
|
4873 | if (!this.initialized) {
|
4874 | this._bindEvents();
|
4875 | }
|
4876 |
|
4877 | var state = window.history.state;
|
4878 | this.initialized = true;
|
4879 | this.initialBookmark = null;
|
4880 | this.initialRotation = null;
|
4881 | this._popStateInProgress = false;
|
4882 | this._blockHashChange = 0;
|
4883 | this._currentHash = getCurrentHash();
|
4884 | this._numPositionUpdates = 0;
|
4885 | this._uid = this._maxUid = 0;
|
4886 | this._destination = null;
|
4887 | this._position = null;
|
4888 |
|
4889 | if (!this._isValidState(state, true) || resetHistory) {
|
4890 | var _parseCurrentHash = parseCurrentHash(this.linkService),
|
4891 | hash = _parseCurrentHash.hash,
|
4892 | page = _parseCurrentHash.page,
|
4893 | rotation = _parseCurrentHash.rotation;
|
4894 |
|
4895 | if (!hash || reInitialized || resetHistory) {
|
4896 | this._pushOrReplaceState(null, true);
|
4897 |
|
4898 | return;
|
4899 | }
|
4900 |
|
4901 | this._pushOrReplaceState({
|
4902 | hash: hash,
|
4903 | page: page,
|
4904 | rotation: rotation
|
4905 | }, true);
|
4906 |
|
4907 | return;
|
4908 | }
|
4909 |
|
4910 | var destination = state.destination;
|
4911 |
|
4912 | this._updateInternalState(destination, state.uid, true);
|
4913 |
|
4914 | if (this._uid > this._maxUid) {
|
4915 | this._maxUid = this._uid;
|
4916 | }
|
4917 |
|
4918 | if (destination.rotation !== undefined) {
|
4919 | this.initialRotation = destination.rotation;
|
4920 | }
|
4921 |
|
4922 | if (destination.dest) {
|
4923 | this.initialBookmark = JSON.stringify(destination.dest);
|
4924 | this._destination.page = null;
|
4925 | } else if (destination.hash) {
|
4926 | this.initialBookmark = destination.hash;
|
4927 | } else if (destination.page) {
|
4928 | this.initialBookmark = "page=".concat(destination.page);
|
4929 | }
|
4930 | }
|
4931 | }, {
|
4932 | key: "push",
|
4933 | value: function push(_ref3) {
|
4934 | var _this2 = this;
|
4935 |
|
4936 | var _ref3$namedDest = _ref3.namedDest,
|
4937 | namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
|
4938 | explicitDest = _ref3.explicitDest,
|
4939 | pageNumber = _ref3.pageNumber;
|
4940 |
|
4941 | if (!this.initialized) {
|
4942 | return;
|
4943 | }
|
4944 |
|
4945 | if (namedDest && typeof namedDest !== 'string') {
|
4946 | console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
|
4947 | return;
|
4948 | } else if (!Array.isArray(explicitDest)) {
|
4949 | console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
|
4950 | return;
|
4951 | } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
|
4952 | if (pageNumber !== null || this._destination) {
|
4953 | console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
|
4954 | return;
|
4955 | }
|
4956 | }
|
4957 |
|
4958 | var hash = namedDest || JSON.stringify(explicitDest);
|
4959 |
|
4960 | if (!hash) {
|
4961 | return;
|
4962 | }
|
4963 |
|
4964 | var forceReplace = false;
|
4965 |
|
4966 | if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
|
4967 | if (this._destination.page) {
|
4968 | return;
|
4969 | }
|
4970 |
|
4971 | forceReplace = true;
|
4972 | }
|
4973 |
|
4974 | if (this._popStateInProgress && !forceReplace) {
|
4975 | return;
|
4976 | }
|
4977 |
|
4978 | this._pushOrReplaceState({
|
4979 | dest: explicitDest,
|
4980 | hash: hash,
|
4981 | page: pageNumber,
|
4982 | rotation: this.linkService.rotation
|
4983 | }, forceReplace);
|
4984 |
|
4985 | if (!this._popStateInProgress) {
|
4986 | this._popStateInProgress = true;
|
4987 | Promise.resolve().then(function () {
|
4988 | _this2._popStateInProgress = false;
|
4989 | });
|
4990 | }
|
4991 | }
|
4992 | }, {
|
4993 | key: "pushCurrentPosition",
|
4994 | value: function pushCurrentPosition() {
|
4995 | if (!this.initialized || this._popStateInProgress) {
|
4996 | return;
|
4997 | }
|
4998 |
|
4999 | this._tryPushCurrentPosition();
|
5000 | }
|
5001 | }, {
|
5002 | key: "back",
|
5003 | value: function back() {
|
5004 | if (!this.initialized || this._popStateInProgress) {
|
5005 | return;
|
5006 | }
|
5007 |
|
5008 | var state = window.history.state;
|
5009 |
|
5010 | if (this._isValidState(state) && state.uid > 0) {
|
5011 | window.history.back();
|
5012 | }
|
5013 | }
|
5014 | }, {
|
5015 | key: "forward",
|
5016 | value: function forward() {
|
5017 | if (!this.initialized || this._popStateInProgress) {
|
5018 | return;
|
5019 | }
|
5020 |
|
5021 | var state = window.history.state;
|
5022 |
|
5023 | if (this._isValidState(state) && state.uid < this._maxUid) {
|
5024 | window.history.forward();
|
5025 | }
|
5026 | }
|
5027 | }, {
|
5028 | key: "_pushOrReplaceState",
|
5029 | value: function _pushOrReplaceState(destination) {
|
5030 | var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5031 | var shouldReplace = forceReplace || !this._destination;
|
5032 | var newState = {
|
5033 | fingerprint: this.fingerprint,
|
5034 | uid: shouldReplace ? this._uid : this._uid + 1,
|
5035 | destination: destination
|
5036 | };
|
5037 |
|
5038 | this._updateInternalState(destination, newState.uid);
|
5039 |
|
5040 | var newUrl;
|
5041 |
|
5042 | if (this._updateUrl && destination && destination.hash) {
|
5043 | var baseUrl = document.location.href.split('#')[0];
|
5044 |
|
5045 | if (!baseUrl.startsWith('file://')) {
|
5046 | newUrl = "".concat(baseUrl, "#").concat(destination.hash);
|
5047 | }
|
5048 | }
|
5049 |
|
5050 | if (shouldReplace) {
|
5051 | if (newUrl) {
|
5052 | window.history.replaceState(newState, '', newUrl);
|
5053 | } else {
|
5054 | window.history.replaceState(newState, '');
|
5055 | }
|
5056 | } else {
|
5057 | this._maxUid = this._uid;
|
5058 |
|
5059 | if (newUrl) {
|
5060 | window.history.pushState(newState, '', newUrl);
|
5061 | } else {
|
5062 | window.history.pushState(newState, '');
|
5063 | }
|
5064 | }
|
5065 | }
|
5066 | }, {
|
5067 | key: "_tryPushCurrentPosition",
|
5068 | value: function _tryPushCurrentPosition() {
|
5069 | var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
5070 |
|
5071 | if (!this._position) {
|
5072 | return;
|
5073 | }
|
5074 |
|
5075 | var position = this._position;
|
5076 |
|
5077 | if (temporary) {
|
5078 | position = Object.assign(Object.create(null), this._position);
|
5079 | position.temporary = true;
|
5080 | }
|
5081 |
|
5082 | if (!this._destination) {
|
5083 | this._pushOrReplaceState(position);
|
5084 |
|
5085 | return;
|
5086 | }
|
5087 |
|
5088 | if (this._destination.temporary) {
|
5089 | this._pushOrReplaceState(position, true);
|
5090 |
|
5091 | return;
|
5092 | }
|
5093 |
|
5094 | if (this._destination.hash === position.hash) {
|
5095 | return;
|
5096 | }
|
5097 |
|
5098 | if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
|
5099 | return;
|
5100 | }
|
5101 |
|
5102 | var forceReplace = false;
|
5103 |
|
5104 | if (this._destination.page >= position.first && this._destination.page <= position.page) {
|
5105 | if (this._destination.dest || !this._destination.first) {
|
5106 | return;
|
5107 | }
|
5108 |
|
5109 | forceReplace = true;
|
5110 | }
|
5111 |
|
5112 | this._pushOrReplaceState(position, forceReplace);
|
5113 | }
|
5114 | }, {
|
5115 | key: "_isValidState",
|
5116 | value: function _isValidState(state) {
|
5117 | var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5118 |
|
5119 | if (!state) {
|
5120 | return false;
|
5121 | }
|
5122 |
|
5123 | if (state.fingerprint !== this.fingerprint) {
|
5124 | if (checkReload) {
|
5125 | if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
|
5126 | return false;
|
5127 | }
|
5128 |
|
5129 | var _performance$getEntri = performance.getEntriesByType('navigation'),
|
5130 | _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
|
5131 | perfEntry = _performance$getEntri2[0];
|
5132 |
|
5133 | if (!perfEntry || perfEntry.type !== 'reload') {
|
5134 | return false;
|
5135 | }
|
5136 | } else {
|
5137 | return false;
|
5138 | }
|
5139 | }
|
5140 |
|
5141 | if (!Number.isInteger(state.uid) || state.uid < 0) {
|
5142 | return false;
|
5143 | }
|
5144 |
|
5145 | if (state.destination === null || _typeof(state.destination) !== 'object') {
|
5146 | return false;
|
5147 | }
|
5148 |
|
5149 | return true;
|
5150 | }
|
5151 | }, {
|
5152 | key: "_updateInternalState",
|
5153 | value: function _updateInternalState(destination, uid) {
|
5154 | var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
5155 |
|
5156 | if (this._updateViewareaTimeout) {
|
5157 | clearTimeout(this._updateViewareaTimeout);
|
5158 | this._updateViewareaTimeout = null;
|
5159 | }
|
5160 |
|
5161 | if (removeTemporary && destination && destination.temporary) {
|
5162 | delete destination.temporary;
|
5163 | }
|
5164 |
|
5165 | this._destination = destination;
|
5166 | this._uid = uid;
|
5167 | this._numPositionUpdates = 0;
|
5168 | }
|
5169 | }, {
|
5170 | key: "_updateViewarea",
|
5171 | value: function _updateViewarea(_ref4) {
|
5172 | var _this3 = this;
|
5173 |
|
5174 | var location = _ref4.location;
|
5175 |
|
5176 | if (this._updateViewareaTimeout) {
|
5177 | clearTimeout(this._updateViewareaTimeout);
|
5178 | this._updateViewareaTimeout = null;
|
5179 | }
|
5180 |
|
5181 | this._position = {
|
5182 | hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
|
5183 | page: this.linkService.page,
|
5184 | first: location.pageNumber,
|
5185 | rotation: location.rotation
|
5186 | };
|
5187 |
|
5188 | if (this._popStateInProgress) {
|
5189 | return;
|
5190 | }
|
5191 |
|
5192 | if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
|
5193 | this._numPositionUpdates++;
|
5194 | }
|
5195 |
|
5196 | if (UPDATE_VIEWAREA_TIMEOUT > 0) {
|
5197 | this._updateViewareaTimeout = setTimeout(function () {
|
5198 | if (!_this3._popStateInProgress) {
|
5199 | _this3._tryPushCurrentPosition(true);
|
5200 | }
|
5201 |
|
5202 | _this3._updateViewareaTimeout = null;
|
5203 | }, UPDATE_VIEWAREA_TIMEOUT);
|
5204 | }
|
5205 | }
|
5206 | }, {
|
5207 | key: "_popState",
|
5208 | value: function _popState(_ref5) {
|
5209 | var _this4 = this;
|
5210 |
|
5211 | var state = _ref5.state;
|
5212 | var newHash = getCurrentHash(),
|
5213 | hashChanged = this._currentHash !== newHash;
|
5214 | this._currentHash = newHash;
|
5215 |
|
5216 | if (!state || false) {
|
5217 | this._uid++;
|
5218 |
|
5219 | var _parseCurrentHash2 = parseCurrentHash(this.linkService),
|
5220 | hash = _parseCurrentHash2.hash,
|
5221 | page = _parseCurrentHash2.page,
|
5222 | rotation = _parseCurrentHash2.rotation;
|
5223 |
|
5224 | this._pushOrReplaceState({
|
5225 | hash: hash,
|
5226 | page: page,
|
5227 | rotation: rotation
|
5228 | }, true);
|
5229 |
|
5230 | return;
|
5231 | }
|
5232 |
|
5233 | if (!this._isValidState(state)) {
|
5234 | return;
|
5235 | }
|
5236 |
|
5237 | this._popStateInProgress = true;
|
5238 |
|
5239 | if (hashChanged) {
|
5240 | this._blockHashChange++;
|
5241 | (0, _ui_utils.waitOnEventOrTimeout)({
|
5242 | target: window,
|
5243 | name: 'hashchange',
|
5244 | delay: HASH_CHANGE_TIMEOUT
|
5245 | }).then(function () {
|
5246 | _this4._blockHashChange--;
|
5247 | });
|
5248 | }
|
5249 |
|
5250 | var destination = state.destination;
|
5251 |
|
5252 | this._updateInternalState(destination, state.uid, true);
|
5253 |
|
5254 | if (this._uid > this._maxUid) {
|
5255 | this._maxUid = this._uid;
|
5256 | }
|
5257 |
|
5258 | if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
|
5259 | this.linkService.rotation = destination.rotation;
|
5260 | }
|
5261 |
|
5262 | if (destination.dest) {
|
5263 | this.linkService.navigateTo(destination.dest);
|
5264 | } else if (destination.hash) {
|
5265 | this.linkService.setHash(destination.hash);
|
5266 | } else if (destination.page) {
|
5267 | this.linkService.page = destination.page;
|
5268 | }
|
5269 |
|
5270 | Promise.resolve().then(function () {
|
5271 | _this4._popStateInProgress = false;
|
5272 | });
|
5273 | }
|
5274 | }, {
|
5275 | key: "_bindEvents",
|
5276 | value: function _bindEvents() {
|
5277 | var _this5 = this;
|
5278 |
|
5279 | var _boundEvents = this._boundEvents,
|
5280 | eventBus = this.eventBus;
|
5281 | _boundEvents.updateViewarea = this._updateViewarea.bind(this);
|
5282 | _boundEvents.popState = this._popState.bind(this);
|
5283 |
|
5284 | _boundEvents.pageHide = function (evt) {
|
5285 | if (!_this5._destination || _this5._destination.temporary) {
|
5286 | _this5._tryPushCurrentPosition();
|
5287 | }
|
5288 | };
|
5289 |
|
5290 | eventBus.on('updateviewarea', _boundEvents.updateViewarea);
|
5291 | window.addEventListener('popstate', _boundEvents.popState);
|
5292 | window.addEventListener('pagehide', _boundEvents.pageHide);
|
5293 | }
|
5294 | }, {
|
5295 | key: "popStateInProgress",
|
5296 | get: function get() {
|
5297 | return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
|
5298 | }
|
5299 | }]);
|
5300 |
|
5301 | return PDFHistory;
|
5302 | }();
|
5303 |
|
5304 | exports.PDFHistory = PDFHistory;
|
5305 |
|
5306 | function isDestHashesEqual(destHash, pushHash) {
|
5307 | if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
|
5308 | return false;
|
5309 | }
|
5310 |
|
5311 | if (destHash === pushHash) {
|
5312 | return true;
|
5313 | }
|
5314 |
|
5315 | var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
|
5316 | nameddest = _parseQueryString.nameddest;
|
5317 |
|
5318 | if (nameddest === pushHash) {
|
5319 | return true;
|
5320 | }
|
5321 |
|
5322 | return false;
|
5323 | }
|
5324 |
|
5325 | function isDestArraysEqual(firstDest, secondDest) {
|
5326 | function isEntryEqual(first, second) {
|
5327 | if (_typeof(first) !== _typeof(second)) {
|
5328 | return false;
|
5329 | }
|
5330 |
|
5331 | if (Array.isArray(first) || Array.isArray(second)) {
|
5332 | return false;
|
5333 | }
|
5334 |
|
5335 | if (first !== null && _typeof(first) === 'object' && second !== null) {
|
5336 | if (Object.keys(first).length !== Object.keys(second).length) {
|
5337 | return false;
|
5338 | }
|
5339 |
|
5340 | for (var key in first) {
|
5341 | if (!isEntryEqual(first[key], second[key])) {
|
5342 | return false;
|
5343 | }
|
5344 | }
|
5345 |
|
5346 | return true;
|
5347 | }
|
5348 |
|
5349 | return first === second || Number.isNaN(first) && Number.isNaN(second);
|
5350 | }
|
5351 |
|
5352 | if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
|
5353 | return false;
|
5354 | }
|
5355 |
|
5356 | if (firstDest.length !== secondDest.length) {
|
5357 | return false;
|
5358 | }
|
5359 |
|
5360 | for (var i = 0, ii = firstDest.length; i < ii; i++) {
|
5361 | if (!isEntryEqual(firstDest[i], secondDest[i])) {
|
5362 | return false;
|
5363 | }
|
5364 | }
|
5365 |
|
5366 | return true;
|
5367 | }
|
5368 |
|
5369 | }),
|
5370 |
|
5371 | (function(module, exports, __w_pdfjs_require__) {
|
5372 |
|
5373 | "use strict";
|
5374 |
|
5375 |
|
5376 | Object.defineProperty(exports, "__esModule", {
|
5377 | value: true
|
5378 | });
|
5379 | exports.PDFPageView = void 0;
|
5380 |
|
5381 | var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
|
5382 |
|
5383 | var _ui_utils = __w_pdfjs_require__(3);
|
5384 |
|
5385 | var _pdfjsLib = __w_pdfjs_require__(2);
|
5386 |
|
5387 | var _pdf_rendering_queue = __w_pdfjs_require__(16);
|
5388 |
|
5389 | var _viewer_compatibility = __w_pdfjs_require__(17);
|
5390 |
|
5391 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
5392 |
|
5393 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
5394 |
|
5395 | function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5396 |
|
5397 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5398 |
|
5399 | 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); } }
|
5400 |
|
5401 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
5402 |
|
5403 | var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
|
5404 |
|
5405 | var PDFPageView =
|
5406 |
|
5407 | function () {
|
5408 | function PDFPageView(options) {
|
5409 | _classCallCheck(this, PDFPageView);
|
5410 |
|
5411 | var container = options.container;
|
5412 | var defaultViewport = options.defaultViewport;
|
5413 | this.id = options.id;
|
5414 | this.renderingId = 'page' + this.id;
|
5415 | this.pdfPage = null;
|
5416 | this.pageLabel = null;
|
5417 | this.rotation = 0;
|
5418 | this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
|
5419 | this.viewport = defaultViewport;
|
5420 | this.pdfPageRotate = defaultViewport.rotation;
|
5421 | this.hasRestrictedScaling = false;
|
5422 | this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
|
5423 | this.imageResourcesPath = options.imageResourcesPath || '';
|
5424 | this.renderInteractiveForms = options.renderInteractiveForms || false;
|
5425 | this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
5426 | this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
|
5427 | this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
|
5428 | this.renderingQueue = options.renderingQueue;
|
5429 | this.textLayerFactory = options.textLayerFactory;
|
5430 | this.annotationLayerFactory = options.annotationLayerFactory;
|
5431 | this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
|
5432 | this.enableWebGL = options.enableWebGL || false;
|
5433 | this.l10n = options.l10n || _ui_utils.NullL10n;
|
5434 | this.paintTask = null;
|
5435 | this.paintedViewportMap = new WeakMap();
|
5436 | this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
|
5437 | this.resume = null;
|
5438 | this.error = null;
|
5439 | this.onBeforeDraw = null;
|
5440 | this.onAfterDraw = null;
|
5441 | this.annotationLayer = null;
|
5442 | this.textLayer = null;
|
5443 | this.zoomLayer = null;
|
5444 | var div = document.createElement('div');
|
5445 | div.className = 'page';
|
5446 | div.style.width = Math.floor(this.viewport.width) + 'px';
|
5447 | div.style.height = Math.floor(this.viewport.height) + 'px';
|
5448 | div.setAttribute('data-page-number', this.id);
|
5449 | this.div = div;
|
5450 | container.appendChild(div);
|
5451 | }
|
5452 |
|
5453 | _createClass(PDFPageView, [{
|
5454 | key: "setPdfPage",
|
5455 | value: function setPdfPage(pdfPage) {
|
5456 | this.pdfPage = pdfPage;
|
5457 | this.pdfPageRotate = pdfPage.rotate;
|
5458 | var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
5459 | this.viewport = pdfPage.getViewport({
|
5460 | scale: this.scale * _ui_utils.CSS_UNITS,
|
5461 | rotation: totalRotation
|
5462 | });
|
5463 | this.stats = pdfPage.stats;
|
5464 | this.reset();
|
5465 | }
|
5466 | }, {
|
5467 | key: "destroy",
|
5468 | value: function destroy() {
|
5469 | this.reset();
|
5470 |
|
5471 | if (this.pdfPage) {
|
5472 | this.pdfPage.cleanup();
|
5473 | }
|
5474 | }
|
5475 | }, {
|
5476 | key: "_resetZoomLayer",
|
5477 | value: function _resetZoomLayer() {
|
5478 | var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
5479 |
|
5480 | if (!this.zoomLayer) {
|
5481 | return;
|
5482 | }
|
5483 |
|
5484 | var zoomLayerCanvas = this.zoomLayer.firstChild;
|
5485 | this.paintedViewportMap["delete"](zoomLayerCanvas);
|
5486 | zoomLayerCanvas.width = 0;
|
5487 | zoomLayerCanvas.height = 0;
|
5488 |
|
5489 | if (removeFromDOM) {
|
5490 | this.zoomLayer.remove();
|
5491 | }
|
5492 |
|
5493 | this.zoomLayer = null;
|
5494 | }
|
5495 | }, {
|
5496 | key: "reset",
|
5497 | value: function reset() {
|
5498 | var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
5499 | var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5500 | this.cancelRendering(keepAnnotations);
|
5501 | this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
|
5502 | var div = this.div;
|
5503 | div.style.width = Math.floor(this.viewport.width) + 'px';
|
5504 | div.style.height = Math.floor(this.viewport.height) + 'px';
|
5505 | var childNodes = div.childNodes;
|
5506 | var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
|
5507 | var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
|
5508 |
|
5509 | for (var i = childNodes.length - 1; i >= 0; i--) {
|
5510 | var node = childNodes[i];
|
5511 |
|
5512 | if (currentZoomLayerNode === node || currentAnnotationNode === node) {
|
5513 | continue;
|
5514 | }
|
5515 |
|
5516 | div.removeChild(node);
|
5517 | }
|
5518 |
|
5519 | div.removeAttribute('data-loaded');
|
5520 |
|
5521 | if (currentAnnotationNode) {
|
5522 | this.annotationLayer.hide();
|
5523 | } else if (this.annotationLayer) {
|
5524 | this.annotationLayer.cancel();
|
5525 | this.annotationLayer = null;
|
5526 | }
|
5527 |
|
5528 | if (!currentZoomLayerNode) {
|
5529 | if (this.canvas) {
|
5530 | this.paintedViewportMap["delete"](this.canvas);
|
5531 | this.canvas.width = 0;
|
5532 | this.canvas.height = 0;
|
5533 | delete this.canvas;
|
5534 | }
|
5535 |
|
5536 | this._resetZoomLayer();
|
5537 | }
|
5538 |
|
5539 | if (this.svg) {
|
5540 | this.paintedViewportMap["delete"](this.svg);
|
5541 | delete this.svg;
|
5542 | }
|
5543 |
|
5544 | this.loadingIconDiv = document.createElement('div');
|
5545 | this.loadingIconDiv.className = 'loadingIcon';
|
5546 | div.appendChild(this.loadingIconDiv);
|
5547 | }
|
5548 | }, {
|
5549 | key: "update",
|
5550 | value: function update(scale, rotation) {
|
5551 | this.scale = scale || this.scale;
|
5552 |
|
5553 | if (typeof rotation !== 'undefined') {
|
5554 | this.rotation = rotation;
|
5555 | }
|
5556 |
|
5557 | var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
5558 | this.viewport = this.viewport.clone({
|
5559 | scale: this.scale * _ui_utils.CSS_UNITS,
|
5560 | rotation: totalRotation
|
5561 | });
|
5562 |
|
5563 | if (this.svg) {
|
5564 | this.cssTransform(this.svg, true);
|
5565 | this.eventBus.dispatch('pagerendered', {
|
5566 | source: this,
|
5567 | pageNumber: this.id,
|
5568 | cssTransform: true
|
5569 | });
|
5570 | return;
|
5571 | }
|
5572 |
|
5573 | var isScalingRestricted = false;
|
5574 |
|
5575 | if (this.canvas && this.maxCanvasPixels > 0) {
|
5576 | var outputScale = this.outputScale;
|
5577 |
|
5578 | if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
|
5579 | isScalingRestricted = true;
|
5580 | }
|
5581 | }
|
5582 |
|
5583 | if (this.canvas) {
|
5584 | if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
|
5585 | this.cssTransform(this.canvas, true);
|
5586 | this.eventBus.dispatch('pagerendered', {
|
5587 | source: this,
|
5588 | pageNumber: this.id,
|
5589 | cssTransform: true
|
5590 | });
|
5591 | return;
|
5592 | }
|
5593 |
|
5594 | if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
|
5595 | this.zoomLayer = this.canvas.parentNode;
|
5596 | this.zoomLayer.style.position = 'absolute';
|
5597 | }
|
5598 | }
|
5599 |
|
5600 | if (this.zoomLayer) {
|
5601 | this.cssTransform(this.zoomLayer.firstChild);
|
5602 | }
|
5603 |
|
5604 | this.reset(true, true);
|
5605 | }
|
5606 | }, {
|
5607 | key: "cancelRendering",
|
5608 | value: function cancelRendering() {
|
5609 | var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
5610 |
|
5611 | if (this.paintTask) {
|
5612 | this.paintTask.cancel();
|
5613 | this.paintTask = null;
|
5614 | }
|
5615 |
|
5616 | this.resume = null;
|
5617 |
|
5618 | if (this.textLayer) {
|
5619 | this.textLayer.cancel();
|
5620 | this.textLayer = null;
|
5621 | }
|
5622 |
|
5623 | if (!keepAnnotations && this.annotationLayer) {
|
5624 | this.annotationLayer.cancel();
|
5625 | this.annotationLayer = null;
|
5626 | }
|
5627 | }
|
5628 | }, {
|
5629 | key: "cssTransform",
|
5630 | value: function cssTransform(target) {
|
5631 | var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5632 | var width = this.viewport.width;
|
5633 | var height = this.viewport.height;
|
5634 | var div = this.div;
|
5635 | target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
|
5636 | target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
|
5637 | var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
|
5638 | var absRotation = Math.abs(relativeRotation);
|
5639 | var scaleX = 1,
|
5640 | scaleY = 1;
|
5641 |
|
5642 | if (absRotation === 90 || absRotation === 270) {
|
5643 | scaleX = height / width;
|
5644 | scaleY = width / height;
|
5645 | }
|
5646 |
|
5647 | var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
|
5648 | target.style.transform = cssTransform;
|
5649 |
|
5650 | if (this.textLayer) {
|
5651 | var textLayerViewport = this.textLayer.viewport;
|
5652 | var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
|
5653 | var textAbsRotation = Math.abs(textRelativeRotation);
|
5654 | var scale = width / textLayerViewport.width;
|
5655 |
|
5656 | if (textAbsRotation === 90 || textAbsRotation === 270) {
|
5657 | scale = width / textLayerViewport.height;
|
5658 | }
|
5659 |
|
5660 | var textLayerDiv = this.textLayer.textLayerDiv;
|
5661 | var transX, transY;
|
5662 |
|
5663 | switch (textAbsRotation) {
|
5664 | case 0:
|
5665 | transX = transY = 0;
|
5666 | break;
|
5667 |
|
5668 | case 90:
|
5669 | transX = 0;
|
5670 | transY = '-' + textLayerDiv.style.height;
|
5671 | break;
|
5672 |
|
5673 | case 180:
|
5674 | transX = '-' + textLayerDiv.style.width;
|
5675 | transY = '-' + textLayerDiv.style.height;
|
5676 | break;
|
5677 |
|
5678 | case 270:
|
5679 | transX = '-' + textLayerDiv.style.width;
|
5680 | transY = 0;
|
5681 | break;
|
5682 |
|
5683 | default:
|
5684 | console.error('Bad rotation value.');
|
5685 | break;
|
5686 | }
|
5687 |
|
5688 | textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
|
5689 | textLayerDiv.style.transformOrigin = '0% 0%';
|
5690 | }
|
5691 |
|
5692 | if (redrawAnnotations && this.annotationLayer) {
|
5693 | this.annotationLayer.render(this.viewport, 'display');
|
5694 | }
|
5695 | }
|
5696 | }, {
|
5697 | key: "getPagePoint",
|
5698 | value: function getPagePoint(x, y) {
|
5699 | return this.viewport.convertToPdfPoint(x, y);
|
5700 | }
|
5701 | }, {
|
5702 | key: "draw",
|
5703 | value: function draw() {
|
5704 | var _this = this;
|
5705 |
|
5706 | if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
|
5707 | console.error('Must be in new state before drawing');
|
5708 | this.reset();
|
5709 | }
|
5710 |
|
5711 | if (!this.pdfPage) {
|
5712 | this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
5713 | return Promise.reject(new Error('Page is not loaded'));
|
5714 | }
|
5715 |
|
5716 | this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
|
5717 | var pdfPage = this.pdfPage;
|
5718 | var div = this.div;
|
5719 | var canvasWrapper = document.createElement('div');
|
5720 | canvasWrapper.style.width = div.style.width;
|
5721 | canvasWrapper.style.height = div.style.height;
|
5722 | canvasWrapper.classList.add('canvasWrapper');
|
5723 |
|
5724 | if (this.annotationLayer && this.annotationLayer.div) {
|
5725 | div.insertBefore(canvasWrapper, this.annotationLayer.div);
|
5726 | } else {
|
5727 | div.appendChild(canvasWrapper);
|
5728 | }
|
5729 |
|
5730 | var textLayer = null;
|
5731 |
|
5732 | if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
|
5733 | var textLayerDiv = document.createElement('div');
|
5734 | textLayerDiv.className = 'textLayer';
|
5735 | textLayerDiv.style.width = canvasWrapper.style.width;
|
5736 | textLayerDiv.style.height = canvasWrapper.style.height;
|
5737 |
|
5738 | if (this.annotationLayer && this.annotationLayer.div) {
|
5739 | div.insertBefore(textLayerDiv, this.annotationLayer.div);
|
5740 | } else {
|
5741 | div.appendChild(textLayerDiv);
|
5742 | }
|
5743 |
|
5744 | textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
|
5745 | }
|
5746 |
|
5747 | this.textLayer = textLayer;
|
5748 | var renderContinueCallback = null;
|
5749 |
|
5750 | if (this.renderingQueue) {
|
5751 | renderContinueCallback = function renderContinueCallback(cont) {
|
5752 | if (!_this.renderingQueue.isHighestPriority(_this)) {
|
5753 | _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
|
5754 |
|
5755 | _this.resume = function () {
|
5756 | _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
|
5757 | cont();
|
5758 | };
|
5759 |
|
5760 | return;
|
5761 | }
|
5762 |
|
5763 | cont();
|
5764 | };
|
5765 | }
|
5766 |
|
5767 | var finishPaintTask =
|
5768 |
|
5769 | function () {
|
5770 | var _ref = _asyncToGenerator(
|
5771 |
|
5772 | _regenerator["default"].mark(function _callee(error) {
|
5773 | return _regenerator["default"].wrap(function _callee$(_context) {
|
5774 | while (1) {
|
5775 | switch (_context.prev = _context.next) {
|
5776 | case 0:
|
5777 | if (paintTask === _this.paintTask) {
|
5778 | _this.paintTask = null;
|
5779 | }
|
5780 |
|
5781 | if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
|
5782 | _context.next = 4;
|
5783 | break;
|
5784 | }
|
5785 |
|
5786 | _this.error = null;
|
5787 | return _context.abrupt("return");
|
5788 |
|
5789 | case 4:
|
5790 | _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
5791 |
|
5792 | if (_this.loadingIconDiv) {
|
5793 | div.removeChild(_this.loadingIconDiv);
|
5794 | delete _this.loadingIconDiv;
|
5795 | }
|
5796 |
|
5797 | _this._resetZoomLayer(true);
|
5798 |
|
5799 | _this.error = error;
|
5800 | _this.stats = pdfPage.stats;
|
5801 |
|
5802 | if (_this.onAfterDraw) {
|
5803 | _this.onAfterDraw();
|
5804 | }
|
5805 |
|
5806 | _this.eventBus.dispatch('pagerendered', {
|
5807 | source: _this,
|
5808 | pageNumber: _this.id,
|
5809 | cssTransform: false
|
5810 | });
|
5811 |
|
5812 | if (!error) {
|
5813 | _context.next = 13;
|
5814 | break;
|
5815 | }
|
5816 |
|
5817 | throw error;
|
5818 |
|
5819 | case 13:
|
5820 | case "end":
|
5821 | return _context.stop();
|
5822 | }
|
5823 | }
|
5824 | }, _callee);
|
5825 | }));
|
5826 |
|
5827 | return function finishPaintTask(_x) {
|
5828 | return _ref.apply(this, arguments);
|
5829 | };
|
5830 | }();
|
5831 |
|
5832 | var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
|
5833 | paintTask.onRenderContinue = renderContinueCallback;
|
5834 | this.paintTask = paintTask;
|
5835 | var resultPromise = paintTask.promise.then(function () {
|
5836 | return finishPaintTask(null).then(function () {
|
5837 | if (textLayer) {
|
5838 | var readableStream = pdfPage.streamTextContent({
|
5839 | normalizeWhitespace: true
|
5840 | });
|
5841 | textLayer.setTextContentStream(readableStream);
|
5842 | textLayer.render();
|
5843 | }
|
5844 | });
|
5845 | }, function (reason) {
|
5846 | return finishPaintTask(reason);
|
5847 | });
|
5848 |
|
5849 | if (this.annotationLayerFactory) {
|
5850 | if (!this.annotationLayer) {
|
5851 | this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
|
5852 | }
|
5853 |
|
5854 | this.annotationLayer.render(this.viewport, 'display');
|
5855 | }
|
5856 |
|
5857 | div.setAttribute('data-loaded', true);
|
5858 |
|
5859 | if (this.onBeforeDraw) {
|
5860 | this.onBeforeDraw();
|
5861 | }
|
5862 |
|
5863 | return resultPromise;
|
5864 | }
|
5865 | }, {
|
5866 | key: "paintOnCanvas",
|
5867 | value: function paintOnCanvas(canvasWrapper) {
|
5868 | var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
|
5869 | var result = {
|
5870 | promise: renderCapability.promise,
|
5871 | onRenderContinue: function onRenderContinue(cont) {
|
5872 | cont();
|
5873 | },
|
5874 | cancel: function cancel() {
|
5875 | renderTask.cancel();
|
5876 | }
|
5877 | };
|
5878 | var viewport = this.viewport;
|
5879 | var canvas = document.createElement('canvas');
|
5880 | canvas.id = this.renderingId;
|
5881 | canvas.setAttribute('hidden', 'hidden');
|
5882 | var isCanvasHidden = true;
|
5883 |
|
5884 | var showCanvas = function showCanvas() {
|
5885 | if (isCanvasHidden) {
|
5886 | canvas.removeAttribute('hidden');
|
5887 | isCanvasHidden = false;
|
5888 | }
|
5889 | };
|
5890 |
|
5891 | canvasWrapper.appendChild(canvas);
|
5892 | this.canvas = canvas;
|
5893 | canvas.mozOpaque = true;
|
5894 | var ctx = canvas.getContext('2d', {
|
5895 | alpha: false
|
5896 | });
|
5897 | var outputScale = (0, _ui_utils.getOutputScale)(ctx);
|
5898 | this.outputScale = outputScale;
|
5899 |
|
5900 | if (this.useOnlyCssZoom) {
|
5901 | var actualSizeViewport = viewport.clone({
|
5902 | scale: _ui_utils.CSS_UNITS
|
5903 | });
|
5904 | outputScale.sx *= actualSizeViewport.width / viewport.width;
|
5905 | outputScale.sy *= actualSizeViewport.height / viewport.height;
|
5906 | outputScale.scaled = true;
|
5907 | }
|
5908 |
|
5909 | if (this.maxCanvasPixels > 0) {
|
5910 | var pixelsInViewport = viewport.width * viewport.height;
|
5911 | var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
|
5912 |
|
5913 | if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
|
5914 | outputScale.sx = maxScale;
|
5915 | outputScale.sy = maxScale;
|
5916 | outputScale.scaled = true;
|
5917 | this.hasRestrictedScaling = true;
|
5918 | } else {
|
5919 | this.hasRestrictedScaling = false;
|
5920 | }
|
5921 | }
|
5922 |
|
5923 | var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
|
5924 | var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
|
5925 | canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
|
5926 | canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
|
5927 | canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
|
5928 | canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
|
5929 | this.paintedViewportMap.set(canvas, viewport);
|
5930 | var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
|
5931 | var renderContext = {
|
5932 | canvasContext: ctx,
|
5933 | transform: transform,
|
5934 | viewport: this.viewport,
|
5935 | enableWebGL: this.enableWebGL,
|
5936 | renderInteractiveForms: this.renderInteractiveForms
|
5937 | };
|
5938 | var renderTask = this.pdfPage.render(renderContext);
|
5939 |
|
5940 | renderTask.onContinue = function (cont) {
|
5941 | showCanvas();
|
5942 |
|
5943 | if (result.onRenderContinue) {
|
5944 | result.onRenderContinue(cont);
|
5945 | } else {
|
5946 | cont();
|
5947 | }
|
5948 | };
|
5949 |
|
5950 | renderTask.promise.then(function () {
|
5951 | showCanvas();
|
5952 | renderCapability.resolve(undefined);
|
5953 | }, function (error) {
|
5954 | showCanvas();
|
5955 | renderCapability.reject(error);
|
5956 | });
|
5957 | return result;
|
5958 | }
|
5959 | }, {
|
5960 | key: "paintOnSvg",
|
5961 | value: function paintOnSvg(wrapper) {
|
5962 | var _this2 = this;
|
5963 |
|
5964 | var cancelled = false;
|
5965 |
|
5966 | var ensureNotCancelled = function ensureNotCancelled() {
|
5967 | if (cancelled) {
|
5968 | throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
|
5969 | }
|
5970 | };
|
5971 |
|
5972 | var pdfPage = this.pdfPage;
|
5973 | var actualSizeViewport = this.viewport.clone({
|
5974 | scale: _ui_utils.CSS_UNITS
|
5975 | });
|
5976 | var promise = pdfPage.getOperatorList().then(function (opList) {
|
5977 | ensureNotCancelled();
|
5978 | var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
|
5979 | return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
|
5980 | ensureNotCancelled();
|
5981 | _this2.svg = svg;
|
5982 |
|
5983 | _this2.paintedViewportMap.set(svg, actualSizeViewport);
|
5984 |
|
5985 | svg.style.width = wrapper.style.width;
|
5986 | svg.style.height = wrapper.style.height;
|
5987 | _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
5988 | wrapper.appendChild(svg);
|
5989 | });
|
5990 | });
|
5991 | return {
|
5992 | promise: promise,
|
5993 | onRenderContinue: function onRenderContinue(cont) {
|
5994 | cont();
|
5995 | },
|
5996 | cancel: function cancel() {
|
5997 | cancelled = true;
|
5998 | }
|
5999 | };
|
6000 | }
|
6001 | }, {
|
6002 | key: "setPageLabel",
|
6003 | value: function setPageLabel(label) {
|
6004 | this.pageLabel = typeof label === 'string' ? label : null;
|
6005 |
|
6006 | if (this.pageLabel !== null) {
|
6007 | this.div.setAttribute('data-page-label', this.pageLabel);
|
6008 | } else {
|
6009 | this.div.removeAttribute('data-page-label');
|
6010 | }
|
6011 | }
|
6012 | }, {
|
6013 | key: "width",
|
6014 | get: function get() {
|
6015 | return this.viewport.width;
|
6016 | }
|
6017 | }, {
|
6018 | key: "height",
|
6019 | get: function get() {
|
6020 | return this.viewport.height;
|
6021 | }
|
6022 | }]);
|
6023 |
|
6024 | return PDFPageView;
|
6025 | }();
|
6026 |
|
6027 | exports.PDFPageView = PDFPageView;
|
6028 |
|
6029 | }),
|
6030 |
|
6031 | (function(module, exports, __w_pdfjs_require__) {
|
6032 |
|
6033 | "use strict";
|
6034 |
|
6035 |
|
6036 | Object.defineProperty(exports, "__esModule", {
|
6037 | value: true
|
6038 | });
|
6039 | exports.PDFRenderingQueue = exports.RenderingStates = void 0;
|
6040 |
|
6041 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6042 |
|
6043 | 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); } }
|
6044 |
|
6045 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
6046 |
|
6047 | var CLEANUP_TIMEOUT = 30000;
|
6048 | var RenderingStates = {
|
6049 | INITIAL: 0,
|
6050 | RUNNING: 1,
|
6051 | PAUSED: 2,
|
6052 | FINISHED: 3
|
6053 | };
|
6054 | exports.RenderingStates = RenderingStates;
|
6055 |
|
6056 | var PDFRenderingQueue =
|
6057 |
|
6058 | function () {
|
6059 | function PDFRenderingQueue() {
|
6060 | _classCallCheck(this, PDFRenderingQueue);
|
6061 |
|
6062 | this.pdfViewer = null;
|
6063 | this.pdfThumbnailViewer = null;
|
6064 | this.onIdle = null;
|
6065 | this.highestPriorityPage = null;
|
6066 | this.idleTimeout = null;
|
6067 | this.printing = false;
|
6068 | this.isThumbnailViewEnabled = false;
|
6069 | }
|
6070 |
|
6071 | _createClass(PDFRenderingQueue, [{
|
6072 | key: "setViewer",
|
6073 | value: function setViewer(pdfViewer) {
|
6074 | this.pdfViewer = pdfViewer;
|
6075 | }
|
6076 | }, {
|
6077 | key: "setThumbnailViewer",
|
6078 | value: function setThumbnailViewer(pdfThumbnailViewer) {
|
6079 | this.pdfThumbnailViewer = pdfThumbnailViewer;
|
6080 | }
|
6081 | }, {
|
6082 | key: "isHighestPriority",
|
6083 | value: function isHighestPriority(view) {
|
6084 | return this.highestPriorityPage === view.renderingId;
|
6085 | }
|
6086 | }, {
|
6087 | key: "renderHighestPriority",
|
6088 | value: function renderHighestPriority(currentlyVisiblePages) {
|
6089 | if (this.idleTimeout) {
|
6090 | clearTimeout(this.idleTimeout);
|
6091 | this.idleTimeout = null;
|
6092 | }
|
6093 |
|
6094 | if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
|
6095 | return;
|
6096 | }
|
6097 |
|
6098 | if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
|
6099 | if (this.pdfThumbnailViewer.forceRendering()) {
|
6100 | return;
|
6101 | }
|
6102 | }
|
6103 |
|
6104 | if (this.printing) {
|
6105 | return;
|
6106 | }
|
6107 |
|
6108 | if (this.onIdle) {
|
6109 | this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
|
6110 | }
|
6111 | }
|
6112 | }, {
|
6113 | key: "getHighestPriority",
|
6114 | value: function getHighestPriority(visible, views, scrolledDown) {
|
6115 | var visibleViews = visible.views;
|
6116 | var numVisible = visibleViews.length;
|
6117 |
|
6118 | if (numVisible === 0) {
|
6119 | return null;
|
6120 | }
|
6121 |
|
6122 | for (var i = 0; i < numVisible; ++i) {
|
6123 | var view = visibleViews[i].view;
|
6124 |
|
6125 | if (!this.isViewFinished(view)) {
|
6126 | return view;
|
6127 | }
|
6128 | }
|
6129 |
|
6130 | if (scrolledDown) {
|
6131 | var nextPageIndex = visible.last.id;
|
6132 |
|
6133 | if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
|
6134 | return views[nextPageIndex];
|
6135 | }
|
6136 | } else {
|
6137 | var previousPageIndex = visible.first.id - 2;
|
6138 |
|
6139 | if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
|
6140 | return views[previousPageIndex];
|
6141 | }
|
6142 | }
|
6143 |
|
6144 | return null;
|
6145 | }
|
6146 | }, {
|
6147 | key: "isViewFinished",
|
6148 | value: function isViewFinished(view) {
|
6149 | return view.renderingState === RenderingStates.FINISHED;
|
6150 | }
|
6151 | }, {
|
6152 | key: "renderView",
|
6153 | value: function renderView(view) {
|
6154 | var _this = this;
|
6155 |
|
6156 | switch (view.renderingState) {
|
6157 | case RenderingStates.FINISHED:
|
6158 | return false;
|
6159 |
|
6160 | case RenderingStates.PAUSED:
|
6161 | this.highestPriorityPage = view.renderingId;
|
6162 | view.resume();
|
6163 | break;
|
6164 |
|
6165 | case RenderingStates.RUNNING:
|
6166 | this.highestPriorityPage = view.renderingId;
|
6167 | break;
|
6168 |
|
6169 | case RenderingStates.INITIAL:
|
6170 | this.highestPriorityPage = view.renderingId;
|
6171 | view.draw()["finally"](function () {
|
6172 | _this.renderHighestPriority();
|
6173 | });
|
6174 | break;
|
6175 | }
|
6176 |
|
6177 | return true;
|
6178 | }
|
6179 | }]);
|
6180 |
|
6181 | return PDFRenderingQueue;
|
6182 | }();
|
6183 |
|
6184 | exports.PDFRenderingQueue = PDFRenderingQueue;
|
6185 |
|
6186 | }),
|
6187 |
|
6188 | (function(module, exports, __w_pdfjs_require__) {
|
6189 |
|
6190 | "use strict";
|
6191 |
|
6192 |
|
6193 | var compatibilityParams = Object.create(null);
|
6194 | {
|
6195 | var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
6196 | var isAndroid = /Android/.test(userAgent);
|
6197 | var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
|
6198 |
|
6199 | (function checkCanvasSizeLimitation() {
|
6200 | if (isIOS || isAndroid) {
|
6201 | compatibilityParams.maxCanvasPixels = 5242880;
|
6202 | }
|
6203 | })();
|
6204 | }
|
6205 | exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
|
6206 |
|
6207 | }),
|
6208 |
|
6209 | (function(module, exports, __w_pdfjs_require__) {
|
6210 |
|
6211 | "use strict";
|
6212 |
|
6213 |
|
6214 | Object.defineProperty(exports, "__esModule", {
|
6215 | value: true
|
6216 | });
|
6217 | exports.PDFSinglePageViewer = void 0;
|
6218 |
|
6219 | var _base_viewer = __w_pdfjs_require__(19);
|
6220 |
|
6221 | var _pdfjsLib = __w_pdfjs_require__(2);
|
6222 |
|
6223 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
6224 |
|
6225 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6226 |
|
6227 | 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); } }
|
6228 |
|
6229 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
6230 |
|
6231 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
6232 |
|
6233 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
6234 |
|
6235 | function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
6236 |
|
6237 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
6238 |
|
6239 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
6240 |
|
6241 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
6242 |
|
6243 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
6244 |
|
6245 | var PDFSinglePageViewer =
|
6246 |
|
6247 | function (_BaseViewer) {
|
6248 | _inherits(PDFSinglePageViewer, _BaseViewer);
|
6249 |
|
6250 | function PDFSinglePageViewer(options) {
|
6251 | var _this;
|
6252 |
|
6253 | _classCallCheck(this, PDFSinglePageViewer);
|
6254 |
|
6255 | _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
|
6256 |
|
6257 | _this.eventBus.on('pagesinit', function (evt) {
|
6258 | _this._ensurePageViewVisible();
|
6259 | });
|
6260 |
|
6261 | return _this;
|
6262 | }
|
6263 |
|
6264 | _createClass(PDFSinglePageViewer, [{
|
6265 | key: "_resetView",
|
6266 | value: function _resetView() {
|
6267 | _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
|
6268 |
|
6269 | this._previousPageNumber = 1;
|
6270 | this._shadowViewer = document.createDocumentFragment();
|
6271 | this._updateScrollDown = null;
|
6272 | }
|
6273 | }, {
|
6274 | key: "_ensurePageViewVisible",
|
6275 | value: function _ensurePageViewVisible() {
|
6276 | var pageView = this._pages[this._currentPageNumber - 1];
|
6277 | var previousPageView = this._pages[this._previousPageNumber - 1];
|
6278 | var viewerNodes = this.viewer.childNodes;
|
6279 |
|
6280 | switch (viewerNodes.length) {
|
6281 | case 0:
|
6282 | this.viewer.appendChild(pageView.div);
|
6283 | break;
|
6284 |
|
6285 | case 1:
|
6286 | if (viewerNodes[0] !== previousPageView.div) {
|
6287 | throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
|
6288 | }
|
6289 |
|
6290 | if (pageView === previousPageView) {
|
6291 | break;
|
6292 | }
|
6293 |
|
6294 | this._shadowViewer.appendChild(previousPageView.div);
|
6295 |
|
6296 | this.viewer.appendChild(pageView.div);
|
6297 | this.container.scrollTop = 0;
|
6298 | break;
|
6299 |
|
6300 | default:
|
6301 | throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
|
6302 | }
|
6303 |
|
6304 | this._previousPageNumber = this._currentPageNumber;
|
6305 | }
|
6306 | }, {
|
6307 | key: "_scrollUpdate",
|
6308 | value: function _scrollUpdate() {
|
6309 | if (this._updateScrollDown) {
|
6310 | this._updateScrollDown();
|
6311 | }
|
6312 |
|
6313 | _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
|
6314 | }
|
6315 | }, {
|
6316 | key: "_scrollIntoView",
|
6317 | value: function _scrollIntoView(_ref) {
|
6318 | var _this2 = this;
|
6319 |
|
6320 | var pageDiv = _ref.pageDiv,
|
6321 | _ref$pageSpot = _ref.pageSpot,
|
6322 | pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
|
6323 | _ref$pageNumber = _ref.pageNumber,
|
6324 | pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
|
6325 |
|
6326 | if (pageNumber) {
|
6327 | this._setCurrentPageNumber(pageNumber);
|
6328 | }
|
6329 |
|
6330 | var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
|
6331 |
|
6332 | this._ensurePageViewVisible();
|
6333 |
|
6334 | this.update();
|
6335 |
|
6336 | _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
|
6337 | pageDiv: pageDiv,
|
6338 | pageSpot: pageSpot,
|
6339 | pageNumber: pageNumber
|
6340 | });
|
6341 |
|
6342 | this._updateScrollDown = function () {
|
6343 | _this2.scroll.down = scrolledDown;
|
6344 | _this2._updateScrollDown = null;
|
6345 | };
|
6346 | }
|
6347 | }, {
|
6348 | key: "_getVisiblePages",
|
6349 | value: function _getVisiblePages() {
|
6350 | return this._getCurrentVisiblePage();
|
6351 | }
|
6352 | }, {
|
6353 | key: "_updateHelper",
|
6354 | value: function _updateHelper(visiblePages) {}
|
6355 | }, {
|
6356 | key: "_updateScrollMode",
|
6357 | value: function _updateScrollMode() {}
|
6358 | }, {
|
6359 | key: "_updateSpreadMode",
|
6360 | value: function _updateSpreadMode() {}
|
6361 | }, {
|
6362 | key: "_setDocumentViewerElement",
|
6363 | get: function get() {
|
6364 | return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
|
6365 | }
|
6366 | }, {
|
6367 | key: "_isScrollModeHorizontal",
|
6368 | get: function get() {
|
6369 | return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
|
6370 | }
|
6371 | }]);
|
6372 |
|
6373 | return PDFSinglePageViewer;
|
6374 | }(_base_viewer.BaseViewer);
|
6375 |
|
6376 | exports.PDFSinglePageViewer = PDFSinglePageViewer;
|
6377 |
|
6378 | }),
|
6379 |
|
6380 | (function(module, exports, __w_pdfjs_require__) {
|
6381 |
|
6382 | "use strict";
|
6383 |
|
6384 |
|
6385 | Object.defineProperty(exports, "__esModule", {
|
6386 | value: true
|
6387 | });
|
6388 | exports.BaseViewer = void 0;
|
6389 |
|
6390 | var _ui_utils = __w_pdfjs_require__(3);
|
6391 |
|
6392 | var _pdf_rendering_queue = __w_pdfjs_require__(16);
|
6393 |
|
6394 | var _annotation_layer_builder = __w_pdfjs_require__(1);
|
6395 |
|
6396 | var _pdfjsLib = __w_pdfjs_require__(2);
|
6397 |
|
6398 | var _pdf_page_view = __w_pdfjs_require__(15);
|
6399 |
|
6400 | var _pdf_link_service = __w_pdfjs_require__(7);
|
6401 |
|
6402 | var _text_layer_builder = __w_pdfjs_require__(8);
|
6403 |
|
6404 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6405 |
|
6406 | 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); } }
|
6407 |
|
6408 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
6409 |
|
6410 | var DEFAULT_CACHE_SIZE = 10;
|
6411 |
|
6412 | function PDFPageViewBuffer(size) {
|
6413 | var data = [];
|
6414 |
|
6415 | this.push = function (view) {
|
6416 | var i = data.indexOf(view);
|
6417 |
|
6418 | if (i >= 0) {
|
6419 | data.splice(i, 1);
|
6420 | }
|
6421 |
|
6422 | data.push(view);
|
6423 |
|
6424 | if (data.length > size) {
|
6425 | data.shift().destroy();
|
6426 | }
|
6427 | };
|
6428 |
|
6429 | this.resize = function (newSize, pagesToKeep) {
|
6430 | size = newSize;
|
6431 |
|
6432 | if (pagesToKeep) {
|
6433 | var pageIdsToKeep = new Set();
|
6434 |
|
6435 | for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
|
6436 | pageIdsToKeep.add(pagesToKeep[i].id);
|
6437 | }
|
6438 |
|
6439 | (0, _ui_utils.moveToEndOfArray)(data, function (page) {
|
6440 | return pageIdsToKeep.has(page.id);
|
6441 | });
|
6442 | }
|
6443 |
|
6444 | while (data.length > size) {
|
6445 | data.shift().destroy();
|
6446 | }
|
6447 | };
|
6448 | }
|
6449 |
|
6450 | function isSameScale(oldScale, newScale) {
|
6451 | if (newScale === oldScale) {
|
6452 | return true;
|
6453 | }
|
6454 |
|
6455 | if (Math.abs(newScale - oldScale) < 1e-15) {
|
6456 | return true;
|
6457 | }
|
6458 |
|
6459 | return false;
|
6460 | }
|
6461 |
|
6462 | var BaseViewer =
|
6463 |
|
6464 | function () {
|
6465 | function BaseViewer(options) {
|
6466 | var _this = this;
|
6467 |
|
6468 | _classCallCheck(this, BaseViewer);
|
6469 |
|
6470 | if (this.constructor === BaseViewer) {
|
6471 | throw new Error('Cannot initialize BaseViewer.');
|
6472 | }
|
6473 |
|
6474 | this._name = this.constructor.name;
|
6475 | this.container = options.container;
|
6476 | this.viewer = options.viewer || options.container.firstElementChild;
|
6477 | this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
|
6478 | this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
|
6479 | this.downloadManager = options.downloadManager || null;
|
6480 | this.findController = options.findController || null;
|
6481 | this.removePageBorders = options.removePageBorders || false;
|
6482 | this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
|
6483 | this.imageResourcesPath = options.imageResourcesPath || '';
|
6484 | this.renderInteractiveForms = options.renderInteractiveForms || false;
|
6485 | this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
6486 | this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
|
6487 | this.enableWebGL = options.enableWebGL || false;
|
6488 | this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
6489 | this.maxCanvasPixels = options.maxCanvasPixels;
|
6490 | this.l10n = options.l10n || _ui_utils.NullL10n;
|
6491 | this.defaultRenderingQueue = !options.renderingQueue;
|
6492 |
|
6493 | if (this.defaultRenderingQueue) {
|
6494 | this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
|
6495 | this.renderingQueue.setViewer(this);
|
6496 | } else {
|
6497 | this.renderingQueue = options.renderingQueue;
|
6498 | }
|
6499 |
|
6500 | this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
|
6501 | this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
|
6502 |
|
6503 | this._resetView();
|
6504 |
|
6505 | if (this.removePageBorders) {
|
6506 | this.viewer.classList.add('removePageBorders');
|
6507 | }
|
6508 |
|
6509 | Promise.resolve().then(function () {
|
6510 | _this.eventBus.dispatch('baseviewerinit', {
|
6511 | source: _this
|
6512 | });
|
6513 | });
|
6514 | }
|
6515 |
|
6516 | _createClass(BaseViewer, [{
|
6517 | key: "getPageView",
|
6518 | value: function getPageView(index) {
|
6519 | return this._pages[index];
|
6520 | }
|
6521 | }, {
|
6522 | key: "_setCurrentPageNumber",
|
6523 | value: function _setCurrentPageNumber(val) {
|
6524 | var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
6525 |
|
6526 | if (this._currentPageNumber === val) {
|
6527 | if (resetCurrentPageView) {
|
6528 | this._resetCurrentPageView();
|
6529 | }
|
6530 |
|
6531 | return true;
|
6532 | }
|
6533 |
|
6534 | if (!(0 < val && val <= this.pagesCount)) {
|
6535 | return false;
|
6536 | }
|
6537 |
|
6538 | this._currentPageNumber = val;
|
6539 | this.eventBus.dispatch('pagechanging', {
|
6540 | source: this,
|
6541 | pageNumber: val,
|
6542 | pageLabel: this._pageLabels && this._pageLabels[val - 1]
|
6543 | });
|
6544 |
|
6545 | if (resetCurrentPageView) {
|
6546 | this._resetCurrentPageView();
|
6547 | }
|
6548 |
|
6549 | return true;
|
6550 | }
|
6551 | }, {
|
6552 | key: "setDocument",
|
6553 | value: function setDocument(pdfDocument) {
|
6554 | var _this2 = this;
|
6555 |
|
6556 | if (this.pdfDocument) {
|
6557 | this._cancelRendering();
|
6558 |
|
6559 | this._resetView();
|
6560 |
|
6561 | if (this.findController) {
|
6562 | this.findController.setDocument(null);
|
6563 | }
|
6564 | }
|
6565 |
|
6566 | this.pdfDocument = pdfDocument;
|
6567 |
|
6568 | if (!pdfDocument) {
|
6569 | return;
|
6570 | }
|
6571 |
|
6572 | var pagesCount = pdfDocument.numPages;
|
6573 | var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
|
6574 | this.pagesPromise = pagesCapability.promise;
|
6575 | pagesCapability.promise.then(function () {
|
6576 | _this2._pageViewsReady = true;
|
6577 |
|
6578 | _this2.eventBus.dispatch('pagesloaded', {
|
6579 | source: _this2,
|
6580 | pagesCount: pagesCount
|
6581 | });
|
6582 | });
|
6583 | var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
|
6584 | this.onePageRendered = onePageRenderedCapability.promise;
|
6585 |
|
6586 | var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
|
6587 | pageView.onBeforeDraw = function () {
|
6588 | _this2._buffer.push(pageView);
|
6589 | };
|
6590 |
|
6591 | pageView.onAfterDraw = function () {
|
6592 | if (!onePageRenderedCapability.settled) {
|
6593 | onePageRenderedCapability.resolve();
|
6594 | }
|
6595 | };
|
6596 | };
|
6597 |
|
6598 | var firstPagePromise = pdfDocument.getPage(1);
|
6599 | this.firstPagePromise = firstPagePromise;
|
6600 | firstPagePromise.then(function (pdfPage) {
|
6601 | var scale = _this2.currentScale;
|
6602 | var viewport = pdfPage.getViewport({
|
6603 | scale: scale * _ui_utils.CSS_UNITS
|
6604 | });
|
6605 |
|
6606 | for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
6607 | var textLayerFactory = null;
|
6608 |
|
6609 | if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
|
6610 | textLayerFactory = _this2;
|
6611 | }
|
6612 |
|
6613 | var pageView = new _pdf_page_view.PDFPageView({
|
6614 | container: _this2._setDocumentViewerElement,
|
6615 | eventBus: _this2.eventBus,
|
6616 | id: pageNum,
|
6617 | scale: scale,
|
6618 | defaultViewport: viewport.clone(),
|
6619 | renderingQueue: _this2.renderingQueue,
|
6620 | textLayerFactory: textLayerFactory,
|
6621 | textLayerMode: _this2.textLayerMode,
|
6622 | annotationLayerFactory: _this2,
|
6623 | imageResourcesPath: _this2.imageResourcesPath,
|
6624 | renderInteractiveForms: _this2.renderInteractiveForms,
|
6625 | renderer: _this2.renderer,
|
6626 | enableWebGL: _this2.enableWebGL,
|
6627 | useOnlyCssZoom: _this2.useOnlyCssZoom,
|
6628 | maxCanvasPixels: _this2.maxCanvasPixels,
|
6629 | l10n: _this2.l10n
|
6630 | });
|
6631 | bindOnAfterAndBeforeDraw(pageView);
|
6632 |
|
6633 | _this2._pages.push(pageView);
|
6634 | }
|
6635 |
|
6636 | if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
|
6637 | _this2._updateSpreadMode();
|
6638 | }
|
6639 |
|
6640 | onePageRenderedCapability.promise.then(function () {
|
6641 | if (_this2.findController) {
|
6642 | _this2.findController.setDocument(pdfDocument);
|
6643 | }
|
6644 |
|
6645 | if (pdfDocument.loadingParams['disableAutoFetch']) {
|
6646 | pagesCapability.resolve();
|
6647 | return;
|
6648 | }
|
6649 |
|
6650 | var getPagesLeft = pagesCount;
|
6651 |
|
6652 | var _loop = function _loop(_pageNum) {
|
6653 | pdfDocument.getPage(_pageNum).then(function (pdfPage) {
|
6654 | var pageView = _this2._pages[_pageNum - 1];
|
6655 |
|
6656 | if (!pageView.pdfPage) {
|
6657 | pageView.setPdfPage(pdfPage);
|
6658 | }
|
6659 |
|
6660 | _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
|
6661 |
|
6662 | if (--getPagesLeft === 0) {
|
6663 | pagesCapability.resolve();
|
6664 | }
|
6665 | }, function (reason) {
|
6666 | console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
|
6667 |
|
6668 | if (--getPagesLeft === 0) {
|
6669 | pagesCapability.resolve();
|
6670 | }
|
6671 | });
|
6672 | };
|
6673 |
|
6674 | for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
|
6675 | _loop(_pageNum);
|
6676 | }
|
6677 | });
|
6678 |
|
6679 | _this2.eventBus.dispatch('pagesinit', {
|
6680 | source: _this2
|
6681 | });
|
6682 |
|
6683 | if (_this2.defaultRenderingQueue) {
|
6684 | _this2.update();
|
6685 | }
|
6686 | })["catch"](function (reason) {
|
6687 | console.error('Unable to initialize viewer', reason);
|
6688 | });
|
6689 | }
|
6690 | }, {
|
6691 | key: "setPageLabels",
|
6692 | value: function setPageLabels(labels) {
|
6693 | if (!this.pdfDocument) {
|
6694 | return;
|
6695 | }
|
6696 |
|
6697 | if (!labels) {
|
6698 | this._pageLabels = null;
|
6699 | } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
|
6700 | this._pageLabels = null;
|
6701 | console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
|
6702 | } else {
|
6703 | this._pageLabels = labels;
|
6704 | }
|
6705 |
|
6706 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
6707 | var pageView = this._pages[i];
|
6708 | var label = this._pageLabels && this._pageLabels[i];
|
6709 | pageView.setPageLabel(label);
|
6710 | }
|
6711 | }
|
6712 | }, {
|
6713 | key: "_resetView",
|
6714 | value: function _resetView() {
|
6715 | this._pages = [];
|
6716 | this._currentPageNumber = 1;
|
6717 | this._currentScale = _ui_utils.UNKNOWN_SCALE;
|
6718 | this._currentScaleValue = null;
|
6719 | this._pageLabels = null;
|
6720 | this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
|
6721 | this._location = null;
|
6722 | this._pagesRotation = 0;
|
6723 | this._pagesRequests = [];
|
6724 | this._pageViewsReady = false;
|
6725 | this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
|
6726 | this._spreadMode = _ui_utils.SpreadMode.NONE;
|
6727 | this.viewer.textContent = '';
|
6728 |
|
6729 | this._updateScrollMode();
|
6730 | }
|
6731 | }, {
|
6732 | key: "_scrollUpdate",
|
6733 | value: function _scrollUpdate() {
|
6734 | if (this.pagesCount === 0) {
|
6735 | return;
|
6736 | }
|
6737 |
|
6738 | this.update();
|
6739 | }
|
6740 | }, {
|
6741 | key: "_scrollIntoView",
|
6742 | value: function _scrollIntoView(_ref) {
|
6743 | var pageDiv = _ref.pageDiv,
|
6744 | _ref$pageSpot = _ref.pageSpot,
|
6745 | pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
|
6746 | _ref$pageNumber = _ref.pageNumber,
|
6747 | pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
|
6748 | (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
|
6749 | }
|
6750 | }, {
|
6751 | key: "_setScaleUpdatePages",
|
6752 | value: function _setScaleUpdatePages(newScale, newValue) {
|
6753 | var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
6754 | var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
6755 | this._currentScaleValue = newValue.toString();
|
6756 |
|
6757 | if (isSameScale(this._currentScale, newScale)) {
|
6758 | if (preset) {
|
6759 | this.eventBus.dispatch('scalechanging', {
|
6760 | source: this,
|
6761 | scale: newScale,
|
6762 | presetValue: newValue
|
6763 | });
|
6764 | }
|
6765 |
|
6766 | return;
|
6767 | }
|
6768 |
|
6769 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
6770 | this._pages[i].update(newScale);
|
6771 | }
|
6772 |
|
6773 | this._currentScale = newScale;
|
6774 |
|
6775 | if (!noScroll) {
|
6776 | var page = this._currentPageNumber,
|
6777 | dest;
|
6778 |
|
6779 | if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
6780 | page = this._location.pageNumber;
|
6781 | dest = [null, {
|
6782 | name: 'XYZ'
|
6783 | }, this._location.left, this._location.top, null];
|
6784 | }
|
6785 |
|
6786 | this.scrollPageIntoView({
|
6787 | pageNumber: page,
|
6788 | destArray: dest,
|
6789 | allowNegativeOffset: true
|
6790 | });
|
6791 | }
|
6792 |
|
6793 | this.eventBus.dispatch('scalechanging', {
|
6794 | source: this,
|
6795 | scale: newScale,
|
6796 | presetValue: preset ? newValue : undefined
|
6797 | });
|
6798 |
|
6799 | if (this.defaultRenderingQueue) {
|
6800 | this.update();
|
6801 | }
|
6802 | }
|
6803 | }, {
|
6804 | key: "_setScale",
|
6805 | value: function _setScale(value) {
|
6806 | var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
6807 | var scale = parseFloat(value);
|
6808 |
|
6809 | if (scale > 0) {
|
6810 | this._setScaleUpdatePages(scale, value, noScroll, false);
|
6811 | } else {
|
6812 | var currentPage = this._pages[this._currentPageNumber - 1];
|
6813 |
|
6814 | if (!currentPage) {
|
6815 | return;
|
6816 | }
|
6817 |
|
6818 | var noPadding = this.isInPresentationMode || this.removePageBorders;
|
6819 | var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
|
6820 | var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
|
6821 |
|
6822 | if (!noPadding && this._isScrollModeHorizontal) {
|
6823 | var _ref2 = [vPadding, hPadding];
|
6824 | hPadding = _ref2[0];
|
6825 | vPadding = _ref2[1];
|
6826 | }
|
6827 |
|
6828 | var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
|
6829 | var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
|
6830 |
|
6831 | switch (value) {
|
6832 | case 'page-actual':
|
6833 | scale = 1;
|
6834 | break;
|
6835 |
|
6836 | case 'page-width':
|
6837 | scale = pageWidthScale;
|
6838 | break;
|
6839 |
|
6840 | case 'page-height':
|
6841 | scale = pageHeightScale;
|
6842 | break;
|
6843 |
|
6844 | case 'page-fit':
|
6845 | scale = Math.min(pageWidthScale, pageHeightScale);
|
6846 | break;
|
6847 |
|
6848 | case 'auto':
|
6849 | var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
|
6850 | scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
|
6851 | break;
|
6852 |
|
6853 | default:
|
6854 | console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
|
6855 | return;
|
6856 | }
|
6857 |
|
6858 | this._setScaleUpdatePages(scale, value, noScroll, true);
|
6859 | }
|
6860 | }
|
6861 | }, {
|
6862 | key: "_resetCurrentPageView",
|
6863 | value: function _resetCurrentPageView() {
|
6864 | if (this.isInPresentationMode) {
|
6865 | this._setScale(this._currentScaleValue, true);
|
6866 | }
|
6867 |
|
6868 | var pageView = this._pages[this._currentPageNumber - 1];
|
6869 |
|
6870 | this._scrollIntoView({
|
6871 | pageDiv: pageView.div
|
6872 | });
|
6873 | }
|
6874 | }, {
|
6875 | key: "scrollPageIntoView",
|
6876 | value: function scrollPageIntoView(_ref3) {
|
6877 | var pageNumber = _ref3.pageNumber,
|
6878 | _ref3$destArray = _ref3.destArray,
|
6879 | destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
|
6880 | _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
|
6881 | allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
|
6882 |
|
6883 | if (!this.pdfDocument) {
|
6884 | return;
|
6885 | }
|
6886 |
|
6887 | var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
|
6888 |
|
6889 | if (!pageView) {
|
6890 | console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
|
6891 | return;
|
6892 | }
|
6893 |
|
6894 | if (this.isInPresentationMode || !destArray) {
|
6895 | this._setCurrentPageNumber(pageNumber, true);
|
6896 |
|
6897 | return;
|
6898 | }
|
6899 |
|
6900 | var x = 0,
|
6901 | y = 0;
|
6902 | var width = 0,
|
6903 | height = 0,
|
6904 | widthScale,
|
6905 | heightScale;
|
6906 | var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
|
6907 | var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
|
6908 | var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
|
6909 | var scale = 0;
|
6910 |
|
6911 | switch (destArray[1].name) {
|
6912 | case 'XYZ':
|
6913 | x = destArray[2];
|
6914 | y = destArray[3];
|
6915 | scale = destArray[4];
|
6916 | x = x !== null ? x : 0;
|
6917 | y = y !== null ? y : pageHeight;
|
6918 | break;
|
6919 |
|
6920 | case 'Fit':
|
6921 | case 'FitB':
|
6922 | scale = 'page-fit';
|
6923 | break;
|
6924 |
|
6925 | case 'FitH':
|
6926 | case 'FitBH':
|
6927 | y = destArray[2];
|
6928 | scale = 'page-width';
|
6929 |
|
6930 | if (y === null && this._location) {
|
6931 | x = this._location.left;
|
6932 | y = this._location.top;
|
6933 | }
|
6934 |
|
6935 | break;
|
6936 |
|
6937 | case 'FitV':
|
6938 | case 'FitBV':
|
6939 | x = destArray[2];
|
6940 | width = pageWidth;
|
6941 | height = pageHeight;
|
6942 | scale = 'page-height';
|
6943 | break;
|
6944 |
|
6945 | case 'FitR':
|
6946 | x = destArray[2];
|
6947 | y = destArray[3];
|
6948 | width = destArray[4] - x;
|
6949 | height = destArray[5] - y;
|
6950 | var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
|
6951 | var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
|
6952 | widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
|
6953 | heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
|
6954 | scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
|
6955 | break;
|
6956 |
|
6957 | default:
|
6958 | console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
|
6959 | return;
|
6960 | }
|
6961 |
|
6962 | if (scale && scale !== this._currentScale) {
|
6963 | this.currentScaleValue = scale;
|
6964 | } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
|
6965 | this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
|
6966 | }
|
6967 |
|
6968 | if (scale === 'page-fit' && !destArray[4]) {
|
6969 | this._scrollIntoView({
|
6970 | pageDiv: pageView.div,
|
6971 | pageNumber: pageNumber
|
6972 | });
|
6973 |
|
6974 | return;
|
6975 | }
|
6976 |
|
6977 | var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
|
6978 | var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
|
6979 | var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
|
6980 |
|
6981 | if (!allowNegativeOffset) {
|
6982 | left = Math.max(left, 0);
|
6983 | top = Math.max(top, 0);
|
6984 | }
|
6985 |
|
6986 | this._scrollIntoView({
|
6987 | pageDiv: pageView.div,
|
6988 | pageSpot: {
|
6989 | left: left,
|
6990 | top: top
|
6991 | },
|
6992 | pageNumber: pageNumber
|
6993 | });
|
6994 | }
|
6995 | }, {
|
6996 | key: "_updateLocation",
|
6997 | value: function _updateLocation(firstPage) {
|
6998 | var currentScale = this._currentScale;
|
6999 | var currentScaleValue = this._currentScaleValue;
|
7000 | var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
|
7001 | var pageNumber = firstPage.id;
|
7002 | var pdfOpenParams = '#page=' + pageNumber;
|
7003 | pdfOpenParams += '&zoom=' + normalizedScaleValue;
|
7004 | var currentPageView = this._pages[pageNumber - 1];
|
7005 | var container = this.container;
|
7006 | var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
|
7007 | var intLeft = Math.round(topLeft[0]);
|
7008 | var intTop = Math.round(topLeft[1]);
|
7009 | pdfOpenParams += ',' + intLeft + ',' + intTop;
|
7010 | this._location = {
|
7011 | pageNumber: pageNumber,
|
7012 | scale: normalizedScaleValue,
|
7013 | top: intTop,
|
7014 | left: intLeft,
|
7015 | rotation: this._pagesRotation,
|
7016 | pdfOpenParams: pdfOpenParams
|
7017 | };
|
7018 | }
|
7019 | }, {
|
7020 | key: "_updateHelper",
|
7021 | value: function _updateHelper(visiblePages) {
|
7022 | throw new Error('Not implemented: _updateHelper');
|
7023 | }
|
7024 | }, {
|
7025 | key: "update",
|
7026 | value: function update() {
|
7027 | var visible = this._getVisiblePages();
|
7028 |
|
7029 | var visiblePages = visible.views,
|
7030 | numVisiblePages = visiblePages.length;
|
7031 |
|
7032 | if (numVisiblePages === 0) {
|
7033 | return;
|
7034 | }
|
7035 |
|
7036 | var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
|
7037 |
|
7038 | this._buffer.resize(newCacheSize, visiblePages);
|
7039 |
|
7040 | this.renderingQueue.renderHighestPriority(visible);
|
7041 |
|
7042 | this._updateHelper(visiblePages);
|
7043 |
|
7044 | this._updateLocation(visible.first);
|
7045 |
|
7046 | this.eventBus.dispatch('updateviewarea', {
|
7047 | source: this,
|
7048 | location: this._location
|
7049 | });
|
7050 | }
|
7051 | }, {
|
7052 | key: "containsElement",
|
7053 | value: function containsElement(element) {
|
7054 | return this.container.contains(element);
|
7055 | }
|
7056 | }, {
|
7057 | key: "focus",
|
7058 | value: function focus() {
|
7059 | this.container.focus();
|
7060 | }
|
7061 | }, {
|
7062 | key: "_getCurrentVisiblePage",
|
7063 | value: function _getCurrentVisiblePage() {
|
7064 | if (!this.pagesCount) {
|
7065 | return {
|
7066 | views: []
|
7067 | };
|
7068 | }
|
7069 |
|
7070 | var pageView = this._pages[this._currentPageNumber - 1];
|
7071 | var element = pageView.div;
|
7072 | var view = {
|
7073 | id: pageView.id,
|
7074 | x: element.offsetLeft + element.clientLeft,
|
7075 | y: element.offsetTop + element.clientTop,
|
7076 | view: pageView
|
7077 | };
|
7078 | return {
|
7079 | first: view,
|
7080 | last: view,
|
7081 | views: [view]
|
7082 | };
|
7083 | }
|
7084 | }, {
|
7085 | key: "_getVisiblePages",
|
7086 | value: function _getVisiblePages() {
|
7087 | return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
|
7088 | }
|
7089 | }, {
|
7090 | key: "isPageVisible",
|
7091 | value: function isPageVisible(pageNumber) {
|
7092 | if (!this.pdfDocument) {
|
7093 | return false;
|
7094 | }
|
7095 |
|
7096 | if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
|
7097 | console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
|
7098 | return false;
|
7099 | }
|
7100 |
|
7101 | return this._getVisiblePages().views.some(function (view) {
|
7102 | return view.id === pageNumber;
|
7103 | });
|
7104 | }
|
7105 | }, {
|
7106 | key: "cleanup",
|
7107 | value: function cleanup() {
|
7108 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
7109 | if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
|
7110 | this._pages[i].reset();
|
7111 | }
|
7112 | }
|
7113 | }
|
7114 | }, {
|
7115 | key: "_cancelRendering",
|
7116 | value: function _cancelRendering() {
|
7117 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
7118 | if (this._pages[i]) {
|
7119 | this._pages[i].cancelRendering();
|
7120 | }
|
7121 | }
|
7122 | }
|
7123 | }, {
|
7124 | key: "_ensurePdfPageLoaded",
|
7125 | value: function _ensurePdfPageLoaded(pageView) {
|
7126 | var _this3 = this;
|
7127 |
|
7128 | if (pageView.pdfPage) {
|
7129 | return Promise.resolve(pageView.pdfPage);
|
7130 | }
|
7131 |
|
7132 | var pageNumber = pageView.id;
|
7133 |
|
7134 | if (this._pagesRequests[pageNumber]) {
|
7135 | return this._pagesRequests[pageNumber];
|
7136 | }
|
7137 |
|
7138 | var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
|
7139 | if (!pageView.pdfPage) {
|
7140 | pageView.setPdfPage(pdfPage);
|
7141 | }
|
7142 |
|
7143 | _this3._pagesRequests[pageNumber] = null;
|
7144 | return pdfPage;
|
7145 | })["catch"](function (reason) {
|
7146 | console.error('Unable to get page for page view', reason);
|
7147 | _this3._pagesRequests[pageNumber] = null;
|
7148 | });
|
7149 | this._pagesRequests[pageNumber] = promise;
|
7150 | return promise;
|
7151 | }
|
7152 | }, {
|
7153 | key: "forceRendering",
|
7154 | value: function forceRendering(currentlyVisiblePages) {
|
7155 | var _this4 = this;
|
7156 |
|
7157 | var visiblePages = currentlyVisiblePages || this._getVisiblePages();
|
7158 |
|
7159 | var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
|
7160 | var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
|
7161 |
|
7162 | if (pageView) {
|
7163 | this._ensurePdfPageLoaded(pageView).then(function () {
|
7164 | _this4.renderingQueue.renderView(pageView);
|
7165 | });
|
7166 |
|
7167 | return true;
|
7168 | }
|
7169 |
|
7170 | return false;
|
7171 | }
|
7172 | }, {
|
7173 | key: "createTextLayerBuilder",
|
7174 | value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
|
7175 | var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
7176 | return new _text_layer_builder.TextLayerBuilder({
|
7177 | textLayerDiv: textLayerDiv,
|
7178 | eventBus: this.eventBus,
|
7179 | pageIndex: pageIndex,
|
7180 | viewport: viewport,
|
7181 | findController: this.isInPresentationMode ? null : this.findController,
|
7182 | enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
|
7183 | });
|
7184 | }
|
7185 | }, {
|
7186 | key: "createAnnotationLayerBuilder",
|
7187 | value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
|
7188 | var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
7189 | var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
7190 | var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
|
7191 | return new _annotation_layer_builder.AnnotationLayerBuilder({
|
7192 | pageDiv: pageDiv,
|
7193 | pdfPage: pdfPage,
|
7194 | imageResourcesPath: imageResourcesPath,
|
7195 | renderInteractiveForms: renderInteractiveForms,
|
7196 | linkService: this.linkService,
|
7197 | downloadManager: this.downloadManager,
|
7198 | l10n: l10n
|
7199 | });
|
7200 | }
|
7201 | }, {
|
7202 | key: "getPagesOverview",
|
7203 | value: function getPagesOverview() {
|
7204 | var pagesOverview = this._pages.map(function (pageView) {
|
7205 | var viewport = pageView.pdfPage.getViewport({
|
7206 | scale: 1
|
7207 | });
|
7208 | return {
|
7209 | width: viewport.width,
|
7210 | height: viewport.height,
|
7211 | rotation: viewport.rotation
|
7212 | };
|
7213 | });
|
7214 |
|
7215 | if (!this.enablePrintAutoRotate) {
|
7216 | return pagesOverview;
|
7217 | }
|
7218 |
|
7219 | var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
|
7220 | return pagesOverview.map(function (size) {
|
7221 | if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
|
7222 | return size;
|
7223 | }
|
7224 |
|
7225 | return {
|
7226 | width: size.height,
|
7227 | height: size.width,
|
7228 | rotation: (size.rotation + 90) % 360
|
7229 | };
|
7230 | });
|
7231 | }
|
7232 | }, {
|
7233 | key: "_updateScrollMode",
|
7234 | value: function _updateScrollMode() {
|
7235 | var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
7236 | var scrollMode = this._scrollMode,
|
7237 | viewer = this.viewer;
|
7238 | viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
|
7239 | viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
|
7240 |
|
7241 | if (!this.pdfDocument || !pageNumber) {
|
7242 | return;
|
7243 | }
|
7244 |
|
7245 | if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
|
7246 | this._setScale(this._currentScaleValue, true);
|
7247 | }
|
7248 |
|
7249 | this._setCurrentPageNumber(pageNumber, true);
|
7250 |
|
7251 | this.update();
|
7252 | }
|
7253 | }, {
|
7254 | key: "_updateSpreadMode",
|
7255 | value: function _updateSpreadMode() {
|
7256 | var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
7257 |
|
7258 | if (!this.pdfDocument) {
|
7259 | return;
|
7260 | }
|
7261 |
|
7262 | var viewer = this.viewer,
|
7263 | pages = this._pages;
|
7264 | viewer.textContent = '';
|
7265 |
|
7266 | if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
|
7267 | for (var i = 0, iMax = pages.length; i < iMax; ++i) {
|
7268 | viewer.appendChild(pages[i].div);
|
7269 | }
|
7270 | } else {
|
7271 | var parity = this._spreadMode - 1;
|
7272 | var spread = null;
|
7273 |
|
7274 | for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
|
7275 | if (spread === null) {
|
7276 | spread = document.createElement('div');
|
7277 | spread.className = 'spread';
|
7278 | viewer.appendChild(spread);
|
7279 | } else if (_i % 2 === parity) {
|
7280 | spread = spread.cloneNode(false);
|
7281 | viewer.appendChild(spread);
|
7282 | }
|
7283 |
|
7284 | spread.appendChild(pages[_i].div);
|
7285 | }
|
7286 | }
|
7287 |
|
7288 | if (!pageNumber) {
|
7289 | return;
|
7290 | }
|
7291 |
|
7292 | this._setCurrentPageNumber(pageNumber, true);
|
7293 |
|
7294 | this.update();
|
7295 | }
|
7296 | }, {
|
7297 | key: "pagesCount",
|
7298 | get: function get() {
|
7299 | return this._pages.length;
|
7300 | }
|
7301 | }, {
|
7302 | key: "pageViewsReady",
|
7303 | get: function get() {
|
7304 | return this._pageViewsReady;
|
7305 | }
|
7306 | }, {
|
7307 | key: "currentPageNumber",
|
7308 | get: function get() {
|
7309 | return this._currentPageNumber;
|
7310 | },
|
7311 | set: function set(val) {
|
7312 | if (!Number.isInteger(val)) {
|
7313 | throw new Error('Invalid page number.');
|
7314 | }
|
7315 |
|
7316 | if (!this.pdfDocument) {
|
7317 | return;
|
7318 | }
|
7319 |
|
7320 | if (!this._setCurrentPageNumber(val, true)) {
|
7321 | console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
|
7322 | }
|
7323 | }
|
7324 | }, {
|
7325 | key: "currentPageLabel",
|
7326 | get: function get() {
|
7327 | return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
|
7328 | },
|
7329 | set: function set(val) {
|
7330 | if (!this.pdfDocument) {
|
7331 | return;
|
7332 | }
|
7333 |
|
7334 | var page = val | 0;
|
7335 |
|
7336 | if (this._pageLabels) {
|
7337 | var i = this._pageLabels.indexOf(val);
|
7338 |
|
7339 | if (i >= 0) {
|
7340 | page = i + 1;
|
7341 | }
|
7342 | }
|
7343 |
|
7344 | if (!this._setCurrentPageNumber(page, true)) {
|
7345 | console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
|
7346 | }
|
7347 | }
|
7348 | }, {
|
7349 | key: "currentScale",
|
7350 | get: function get() {
|
7351 | return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
|
7352 | },
|
7353 | set: function set(val) {
|
7354 | if (isNaN(val)) {
|
7355 | throw new Error('Invalid numeric scale.');
|
7356 | }
|
7357 |
|
7358 | if (!this.pdfDocument) {
|
7359 | return;
|
7360 | }
|
7361 |
|
7362 | this._setScale(val, false);
|
7363 | }
|
7364 | }, {
|
7365 | key: "currentScaleValue",
|
7366 | get: function get() {
|
7367 | return this._currentScaleValue;
|
7368 | },
|
7369 | set: function set(val) {
|
7370 | if (!this.pdfDocument) {
|
7371 | return;
|
7372 | }
|
7373 |
|
7374 | this._setScale(val, false);
|
7375 | }
|
7376 | }, {
|
7377 | key: "pagesRotation",
|
7378 | get: function get() {
|
7379 | return this._pagesRotation;
|
7380 | },
|
7381 | set: function set(rotation) {
|
7382 | if (!(0, _ui_utils.isValidRotation)(rotation)) {
|
7383 | throw new Error('Invalid pages rotation angle.');
|
7384 | }
|
7385 |
|
7386 | if (!this.pdfDocument) {
|
7387 | return;
|
7388 | }
|
7389 |
|
7390 | if (this._pagesRotation === rotation) {
|
7391 | return;
|
7392 | }
|
7393 |
|
7394 | this._pagesRotation = rotation;
|
7395 | var pageNumber = this._currentPageNumber;
|
7396 |
|
7397 | for (var i = 0, ii = this._pages.length; i < ii; i++) {
|
7398 | var pageView = this._pages[i];
|
7399 | pageView.update(pageView.scale, rotation);
|
7400 | }
|
7401 |
|
7402 | if (this._currentScaleValue) {
|
7403 | this._setScale(this._currentScaleValue, true);
|
7404 | }
|
7405 |
|
7406 | this.eventBus.dispatch('rotationchanging', {
|
7407 | source: this,
|
7408 | pagesRotation: rotation,
|
7409 | pageNumber: pageNumber
|
7410 | });
|
7411 |
|
7412 | if (this.defaultRenderingQueue) {
|
7413 | this.update();
|
7414 | }
|
7415 | }
|
7416 | }, {
|
7417 | key: "_setDocumentViewerElement",
|
7418 | get: function get() {
|
7419 | throw new Error('Not implemented: _setDocumentViewerElement');
|
7420 | }
|
7421 | }, {
|
7422 | key: "_isScrollModeHorizontal",
|
7423 | get: function get() {
|
7424 | return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
|
7425 | }
|
7426 | }, {
|
7427 | key: "isInPresentationMode",
|
7428 | get: function get() {
|
7429 | return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
|
7430 | }
|
7431 | }, {
|
7432 | key: "isChangingPresentationMode",
|
7433 | get: function get() {
|
7434 | return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
|
7435 | }
|
7436 | }, {
|
7437 | key: "isHorizontalScrollbarEnabled",
|
7438 | get: function get() {
|
7439 | return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
|
7440 | }
|
7441 | }, {
|
7442 | key: "isVerticalScrollbarEnabled",
|
7443 | get: function get() {
|
7444 | return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
|
7445 | }
|
7446 | }, {
|
7447 | key: "hasEqualPageSizes",
|
7448 | get: function get() {
|
7449 | var firstPageView = this._pages[0];
|
7450 |
|
7451 | for (var i = 1, ii = this._pages.length; i < ii; ++i) {
|
7452 | var pageView = this._pages[i];
|
7453 |
|
7454 | if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
|
7455 | return false;
|
7456 | }
|
7457 | }
|
7458 |
|
7459 | return true;
|
7460 | }
|
7461 | }, {
|
7462 | key: "scrollMode",
|
7463 | get: function get() {
|
7464 | return this._scrollMode;
|
7465 | },
|
7466 | set: function set(mode) {
|
7467 | if (this._scrollMode === mode) {
|
7468 | return;
|
7469 | }
|
7470 |
|
7471 | if (!(0, _ui_utils.isValidScrollMode)(mode)) {
|
7472 | throw new Error("Invalid scroll mode: ".concat(mode));
|
7473 | }
|
7474 |
|
7475 | this._scrollMode = mode;
|
7476 | this.eventBus.dispatch('scrollmodechanged', {
|
7477 | source: this,
|
7478 | mode: mode
|
7479 | });
|
7480 |
|
7481 | this._updateScrollMode(this._currentPageNumber);
|
7482 | }
|
7483 | }, {
|
7484 | key: "spreadMode",
|
7485 | get: function get() {
|
7486 | return this._spreadMode;
|
7487 | },
|
7488 | set: function set(mode) {
|
7489 | if (this._spreadMode === mode) {
|
7490 | return;
|
7491 | }
|
7492 |
|
7493 | if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
|
7494 | throw new Error("Invalid spread mode: ".concat(mode));
|
7495 | }
|
7496 |
|
7497 | this._spreadMode = mode;
|
7498 | this.eventBus.dispatch('spreadmodechanged', {
|
7499 | source: this,
|
7500 | mode: mode
|
7501 | });
|
7502 |
|
7503 | this._updateSpreadMode(this._currentPageNumber);
|
7504 | }
|
7505 | }]);
|
7506 |
|
7507 | return BaseViewer;
|
7508 | }();
|
7509 |
|
7510 | exports.BaseViewer = BaseViewer;
|
7511 |
|
7512 | }),
|
7513 |
|
7514 | (function(module, exports, __w_pdfjs_require__) {
|
7515 |
|
7516 | "use strict";
|
7517 |
|
7518 |
|
7519 | Object.defineProperty(exports, "__esModule", {
|
7520 | value: true
|
7521 | });
|
7522 | exports.PDFViewer = void 0;
|
7523 |
|
7524 | var _base_viewer = __w_pdfjs_require__(19);
|
7525 |
|
7526 | var _pdfjsLib = __w_pdfjs_require__(2);
|
7527 |
|
7528 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
7529 |
|
7530 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
7531 |
|
7532 | 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); } }
|
7533 |
|
7534 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
7535 |
|
7536 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
7537 |
|
7538 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
7539 |
|
7540 | function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
7541 |
|
7542 | function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
7543 |
|
7544 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
7545 |
|
7546 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
7547 |
|
7548 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
7549 |
|
7550 | var PDFViewer =
|
7551 |
|
7552 | function (_BaseViewer) {
|
7553 | _inherits(PDFViewer, _BaseViewer);
|
7554 |
|
7555 | function PDFViewer() {
|
7556 | _classCallCheck(this, PDFViewer);
|
7557 |
|
7558 | return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
|
7559 | }
|
7560 |
|
7561 | _createClass(PDFViewer, [{
|
7562 | key: "_scrollIntoView",
|
7563 | value: function _scrollIntoView(_ref) {
|
7564 | var pageDiv = _ref.pageDiv,
|
7565 | _ref$pageSpot = _ref.pageSpot,
|
7566 | pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
|
7567 | _ref$pageNumber = _ref.pageNumber,
|
7568 | pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
|
7569 |
|
7570 | if (!pageSpot && !this.isInPresentationMode) {
|
7571 | var left = pageDiv.offsetLeft + pageDiv.clientLeft;
|
7572 | var right = left + pageDiv.clientWidth;
|
7573 | var _this$container = this.container,
|
7574 | scrollLeft = _this$container.scrollLeft,
|
7575 | clientWidth = _this$container.clientWidth;
|
7576 |
|
7577 | if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
|
7578 | pageSpot = {
|
7579 | left: 0,
|
7580 | top: 0
|
7581 | };
|
7582 | }
|
7583 | }
|
7584 |
|
7585 | _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
|
7586 | pageDiv: pageDiv,
|
7587 | pageSpot: pageSpot,
|
7588 | pageNumber: pageNumber
|
7589 | });
|
7590 | }
|
7591 | }, {
|
7592 | key: "_getVisiblePages",
|
7593 | value: function _getVisiblePages() {
|
7594 | if (this.isInPresentationMode) {
|
7595 | return this._getCurrentVisiblePage();
|
7596 | }
|
7597 |
|
7598 | return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
|
7599 | }
|
7600 | }, {
|
7601 | key: "_updateHelper",
|
7602 | value: function _updateHelper(visiblePages) {
|
7603 | if (this.isInPresentationMode) {
|
7604 | return;
|
7605 | }
|
7606 |
|
7607 | var currentId = this._currentPageNumber;
|
7608 | var stillFullyVisible = false;
|
7609 | var _iteratorNormalCompletion = true;
|
7610 | var _didIteratorError = false;
|
7611 | var _iteratorError = undefined;
|
7612 |
|
7613 | try {
|
7614 | for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
7615 | var page = _step.value;
|
7616 |
|
7617 | if (page.percent < 100) {
|
7618 | break;
|
7619 | }
|
7620 |
|
7621 | if (page.id === currentId) {
|
7622 | stillFullyVisible = true;
|
7623 | break;
|
7624 | }
|
7625 | }
|
7626 | } catch (err) {
|
7627 | _didIteratorError = true;
|
7628 | _iteratorError = err;
|
7629 | } finally {
|
7630 | try {
|
7631 | if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
7632 | _iterator["return"]();
|
7633 | }
|
7634 | } finally {
|
7635 | if (_didIteratorError) {
|
7636 | throw _iteratorError;
|
7637 | }
|
7638 | }
|
7639 | }
|
7640 |
|
7641 | if (!stillFullyVisible) {
|
7642 | currentId = visiblePages[0].id;
|
7643 | }
|
7644 |
|
7645 | this._setCurrentPageNumber(currentId);
|
7646 | }
|
7647 | }, {
|
7648 | key: "_setDocumentViewerElement",
|
7649 | get: function get() {
|
7650 | return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
|
7651 | }
|
7652 | }]);
|
7653 |
|
7654 | return PDFViewer;
|
7655 | }(_base_viewer.BaseViewer);
|
7656 |
|
7657 | exports.PDFViewer = PDFViewer;
|
7658 |
|
7659 | })
|
7660 | ]);
|
7661 | });
|
7662 |
|
\ | No newline at end of file |