pdfjs-dist 2.0.943 → 2.4.456
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
package/lib/web/ui_utils.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,277 +19,273 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
27
|
+
exports.isValidRotation = isValidRotation;
|
28
|
+
exports.isValidScrollMode = isValidScrollMode;
|
29
|
+
exports.isValidSpreadMode = isValidSpreadMode;
|
30
|
+
exports.isPortraitOrientation = isPortraitOrientation;
|
31
|
+
exports.getGlobalEventBus = getGlobalEventBus;
|
32
|
+
exports.clamp = clamp;
|
33
|
+
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
34
|
+
exports.noContextMenuHandler = noContextMenuHandler;
|
35
|
+
exports.parseQueryString = parseQueryString;
|
36
|
+
exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
|
37
|
+
exports.getVisibleElements = getVisibleElements;
|
38
|
+
exports.roundToDivide = roundToDivide;
|
39
|
+
exports.getPageSizeInches = getPageSizeInches;
|
40
|
+
exports.approximateFraction = approximateFraction;
|
41
|
+
exports.getOutputScale = getOutputScale;
|
42
|
+
exports.scrollIntoView = scrollIntoView;
|
43
|
+
exports.watchScroll = watchScroll;
|
44
|
+
exports.binarySearchFirstItem = binarySearchFirstItem;
|
45
|
+
exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
46
|
+
exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
|
47
|
+
exports.moveToEndOfArray = moveToEndOfArray;
|
48
|
+
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 = exports.AutoPrintRegExp = void 0;
|
49
|
+
const CSS_UNITS = 96.0 / 72.0;
|
50
|
+
exports.CSS_UNITS = CSS_UNITS;
|
51
|
+
const DEFAULT_SCALE_VALUE = "auto";
|
52
|
+
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
53
|
+
const DEFAULT_SCALE = 1.0;
|
54
|
+
exports.DEFAULT_SCALE = DEFAULT_SCALE;
|
55
|
+
const MIN_SCALE = 0.1;
|
56
|
+
exports.MIN_SCALE = MIN_SCALE;
|
57
|
+
const MAX_SCALE = 10.0;
|
58
|
+
exports.MAX_SCALE = MAX_SCALE;
|
59
|
+
const UNKNOWN_SCALE = 0;
|
60
|
+
exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
|
61
|
+
const MAX_AUTO_SCALE = 1.25;
|
62
|
+
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
|
63
|
+
const SCROLLBAR_PADDING = 40;
|
64
|
+
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
65
|
+
const VERTICAL_PADDING = 5;
|
66
|
+
exports.VERTICAL_PADDING = VERTICAL_PADDING;
|
67
|
+
const PresentationModeState = {
|
55
68
|
UNKNOWN: 0,
|
56
69
|
NORMAL: 1,
|
57
70
|
CHANGING: 2,
|
58
71
|
FULLSCREEN: 3
|
59
72
|
};
|
60
|
-
|
61
|
-
|
62
|
-
|
73
|
+
exports.PresentationModeState = PresentationModeState;
|
74
|
+
const RendererType = {
|
75
|
+
CANVAS: "canvas",
|
76
|
+
SVG: "svg"
|
63
77
|
};
|
64
|
-
|
78
|
+
exports.RendererType = RendererType;
|
79
|
+
const TextLayerMode = {
|
65
80
|
DISABLE: 0,
|
66
81
|
ENABLE: 1,
|
67
82
|
ENABLE_ENHANCE: 2
|
68
83
|
};
|
84
|
+
exports.TextLayerMode = TextLayerMode;
|
85
|
+
const ScrollMode = {
|
86
|
+
UNKNOWN: -1,
|
87
|
+
VERTICAL: 0,
|
88
|
+
HORIZONTAL: 1,
|
89
|
+
WRAPPED: 2
|
90
|
+
};
|
91
|
+
exports.ScrollMode = ScrollMode;
|
92
|
+
const SpreadMode = {
|
93
|
+
UNKNOWN: -1,
|
94
|
+
NONE: 0,
|
95
|
+
ODD: 1,
|
96
|
+
EVEN: 2
|
97
|
+
};
|
98
|
+
exports.SpreadMode = SpreadMode;
|
99
|
+
const AutoPrintRegExp = /\bprint\s*\(/;
|
100
|
+
exports.AutoPrintRegExp = AutoPrintRegExp;
|
101
|
+
|
69
102
|
function formatL10nValue(text, args) {
|
70
103
|
if (!args) {
|
71
104
|
return text;
|
72
105
|
}
|
73
|
-
|
74
|
-
|
106
|
+
|
107
|
+
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
|
108
|
+
return name in args ? args[name] : "{{" + name + "}}";
|
75
109
|
});
|
76
110
|
}
|
77
|
-
var NullL10n = {
|
78
|
-
getLanguage: function () {
|
79
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
80
|
-
return _regenerator2.default.wrap(function _callee$(_context) {
|
81
|
-
while (1) {
|
82
|
-
switch (_context.prev = _context.next) {
|
83
|
-
case 0:
|
84
|
-
return _context.abrupt('return', 'en-us');
|
85
|
-
|
86
|
-
case 1:
|
87
|
-
case 'end':
|
88
|
-
return _context.stop();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}, _callee, this);
|
92
|
-
}));
|
93
111
|
|
94
|
-
|
95
|
-
|
96
|
-
|
112
|
+
const NullL10n = {
|
113
|
+
async getLanguage() {
|
114
|
+
return "en-us";
|
115
|
+
},
|
97
116
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
|
102
|
-
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
103
|
-
while (1) {
|
104
|
-
switch (_context2.prev = _context2.next) {
|
105
|
-
case 0:
|
106
|
-
return _context2.abrupt('return', 'ltr');
|
107
|
-
|
108
|
-
case 1:
|
109
|
-
case 'end':
|
110
|
-
return _context2.stop();
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}, _callee2, this);
|
114
|
-
}));
|
117
|
+
async getDirection() {
|
118
|
+
return "ltr";
|
119
|
+
},
|
115
120
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
return getDirection;
|
121
|
-
}(),
|
122
|
-
get: function () {
|
123
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(property, args, fallback) {
|
124
|
-
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
125
|
-
while (1) {
|
126
|
-
switch (_context3.prev = _context3.next) {
|
127
|
-
case 0:
|
128
|
-
return _context3.abrupt('return', formatL10nValue(fallback, args));
|
129
|
-
|
130
|
-
case 1:
|
131
|
-
case 'end':
|
132
|
-
return _context3.stop();
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}, _callee3, this);
|
136
|
-
}));
|
137
|
-
|
138
|
-
function get(_x, _x2, _x3) {
|
139
|
-
return _ref3.apply(this, arguments);
|
140
|
-
}
|
141
|
-
|
142
|
-
return get;
|
143
|
-
}(),
|
144
|
-
translate: function () {
|
145
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) {
|
146
|
-
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
147
|
-
while (1) {
|
148
|
-
switch (_context4.prev = _context4.next) {
|
149
|
-
case 0:
|
150
|
-
case 'end':
|
151
|
-
return _context4.stop();
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}, _callee4, this);
|
155
|
-
}));
|
121
|
+
async get(property, args, fallback) {
|
122
|
+
return formatL10nValue(fallback, args);
|
123
|
+
},
|
156
124
|
|
157
|
-
|
158
|
-
return _ref4.apply(this, arguments);
|
159
|
-
}
|
125
|
+
async translate(element) {}
|
160
126
|
|
161
|
-
return translate;
|
162
|
-
}()
|
163
127
|
};
|
128
|
+
exports.NullL10n = NullL10n;
|
129
|
+
|
164
130
|
function getOutputScale(ctx) {
|
165
|
-
|
166
|
-
|
167
|
-
|
131
|
+
const devicePixelRatio = window.devicePixelRatio || 1;
|
132
|
+
const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
133
|
+
const pixelRatio = devicePixelRatio / backingStoreRatio;
|
168
134
|
return {
|
169
135
|
sx: pixelRatio,
|
170
136
|
sy: pixelRatio,
|
171
137
|
scaled: pixelRatio !== 1
|
172
138
|
};
|
173
139
|
}
|
174
|
-
function scrollIntoView(element, spot) {
|
175
|
-
var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
176
140
|
|
177
|
-
|
141
|
+
function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
|
142
|
+
let parent = element.offsetParent;
|
143
|
+
|
178
144
|
if (!parent) {
|
179
|
-
console.error(
|
145
|
+
console.error("offsetParent is not set -- cannot scroll");
|
180
146
|
return;
|
181
147
|
}
|
182
|
-
|
183
|
-
|
184
|
-
|
148
|
+
|
149
|
+
let offsetY = element.offsetTop + element.clientTop;
|
150
|
+
let offsetX = element.offsetLeft + element.clientLeft;
|
151
|
+
|
152
|
+
while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
|
185
153
|
if (parent.dataset._scaleY) {
|
186
154
|
offsetY /= parent.dataset._scaleY;
|
187
155
|
offsetX /= parent.dataset._scaleX;
|
188
156
|
}
|
157
|
+
|
189
158
|
offsetY += parent.offsetTop;
|
190
159
|
offsetX += parent.offsetLeft;
|
191
160
|
parent = parent.offsetParent;
|
161
|
+
|
192
162
|
if (!parent) {
|
193
163
|
return;
|
194
164
|
}
|
195
165
|
}
|
166
|
+
|
196
167
|
if (spot) {
|
197
168
|
if (spot.top !== undefined) {
|
198
169
|
offsetY += spot.top;
|
199
170
|
}
|
171
|
+
|
200
172
|
if (spot.left !== undefined) {
|
201
173
|
offsetX += spot.left;
|
202
174
|
parent.scrollLeft = offsetX;
|
203
175
|
}
|
204
176
|
}
|
177
|
+
|
205
178
|
parent.scrollTop = offsetY;
|
206
179
|
}
|
180
|
+
|
207
181
|
function watchScroll(viewAreaElement, callback) {
|
208
|
-
|
182
|
+
const debounceScroll = function (evt) {
|
209
183
|
if (rAF) {
|
210
184
|
return;
|
211
185
|
}
|
186
|
+
|
212
187
|
rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
|
213
188
|
rAF = null;
|
214
|
-
|
215
|
-
|
189
|
+
const currentX = viewAreaElement.scrollLeft;
|
190
|
+
const lastX = state.lastX;
|
191
|
+
|
216
192
|
if (currentX !== lastX) {
|
217
193
|
state.right = currentX > lastX;
|
218
194
|
}
|
195
|
+
|
219
196
|
state.lastX = currentX;
|
220
|
-
|
221
|
-
|
197
|
+
const currentY = viewAreaElement.scrollTop;
|
198
|
+
const lastY = state.lastY;
|
199
|
+
|
222
200
|
if (currentY !== lastY) {
|
223
201
|
state.down = currentY > lastY;
|
224
202
|
}
|
203
|
+
|
225
204
|
state.lastY = currentY;
|
226
205
|
callback(state);
|
227
206
|
});
|
228
207
|
};
|
229
|
-
|
208
|
+
|
209
|
+
const state = {
|
230
210
|
right: true,
|
231
211
|
down: true,
|
232
212
|
lastX: viewAreaElement.scrollLeft,
|
233
213
|
lastY: viewAreaElement.scrollTop,
|
234
214
|
_eventHandler: debounceScroll
|
235
215
|
};
|
236
|
-
|
237
|
-
viewAreaElement.addEventListener(
|
216
|
+
let rAF = null;
|
217
|
+
viewAreaElement.addEventListener("scroll", debounceScroll, true);
|
238
218
|
return state;
|
239
219
|
}
|
220
|
+
|
240
221
|
function parseQueryString(query) {
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
222
|
+
const parts = query.split("&");
|
223
|
+
const params = Object.create(null);
|
224
|
+
|
225
|
+
for (let i = 0, ii = parts.length; i < ii; ++i) {
|
226
|
+
const param = parts[i].split("=");
|
227
|
+
const key = param[0].toLowerCase();
|
228
|
+
const value = param.length > 1 ? param[1] : null;
|
247
229
|
params[decodeURIComponent(key)] = decodeURIComponent(value);
|
248
230
|
}
|
231
|
+
|
249
232
|
return params;
|
250
233
|
}
|
234
|
+
|
251
235
|
function binarySearchFirstItem(items, condition) {
|
252
|
-
|
253
|
-
|
236
|
+
let minIndex = 0;
|
237
|
+
let maxIndex = items.length - 1;
|
238
|
+
|
254
239
|
if (items.length === 0 || !condition(items[maxIndex])) {
|
255
240
|
return items.length;
|
256
241
|
}
|
242
|
+
|
257
243
|
if (condition(items[minIndex])) {
|
258
244
|
return minIndex;
|
259
245
|
}
|
246
|
+
|
260
247
|
while (minIndex < maxIndex) {
|
261
|
-
|
262
|
-
|
248
|
+
const currentIndex = minIndex + maxIndex >> 1;
|
249
|
+
const currentItem = items[currentIndex];
|
250
|
+
|
263
251
|
if (condition(currentItem)) {
|
264
252
|
maxIndex = currentIndex;
|
265
253
|
} else {
|
266
254
|
minIndex = currentIndex + 1;
|
267
255
|
}
|
268
256
|
}
|
257
|
+
|
269
258
|
return minIndex;
|
270
259
|
}
|
260
|
+
|
271
261
|
function approximateFraction(x) {
|
272
262
|
if (Math.floor(x) === x) {
|
273
263
|
return [x, 1];
|
274
264
|
}
|
275
|
-
|
276
|
-
|
265
|
+
|
266
|
+
const xinv = 1 / x;
|
267
|
+
const limit = 8;
|
268
|
+
|
277
269
|
if (xinv > limit) {
|
278
270
|
return [1, limit];
|
279
271
|
} else if (Math.floor(xinv) === xinv) {
|
280
272
|
return [1, xinv];
|
281
273
|
}
|
282
|
-
|
283
|
-
|
274
|
+
|
275
|
+
const x_ = x > 1 ? xinv : x;
|
276
|
+
let a = 0,
|
284
277
|
b = 1,
|
285
278
|
c = 1,
|
286
279
|
d = 1;
|
280
|
+
|
287
281
|
while (true) {
|
288
|
-
|
289
|
-
|
282
|
+
const p = a + c,
|
283
|
+
q = b + d;
|
284
|
+
|
290
285
|
if (q > limit) {
|
291
286
|
break;
|
292
287
|
}
|
288
|
+
|
293
289
|
if (x_ <= p / q) {
|
294
290
|
c = p;
|
295
291
|
d = q;
|
@@ -298,100 +294,102 @@ function approximateFraction(x) {
|
|
298
294
|
b = q;
|
299
295
|
}
|
300
296
|
}
|
301
|
-
|
297
|
+
|
298
|
+
let result;
|
299
|
+
|
302
300
|
if (x_ - a / b < c / d - x_) {
|
303
301
|
result = x_ === x ? [a, b] : [b, a];
|
304
302
|
} else {
|
305
303
|
result = x_ === x ? [c, d] : [d, c];
|
306
304
|
}
|
305
|
+
|
307
306
|
return result;
|
308
307
|
}
|
308
|
+
|
309
309
|
function roundToDivide(x, div) {
|
310
|
-
|
310
|
+
const r = x % div;
|
311
311
|
return r === 0 ? x : Math.round(x - r + div);
|
312
312
|
}
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
var changeOrientation = rotate % 180 !== 0;
|
325
|
-
var width = (x2 - x1) / 72 * userUnit;
|
326
|
-
var height = (y2 - y1) / 72 * userUnit;
|
313
|
+
|
314
|
+
function getPageSizeInches({
|
315
|
+
view,
|
316
|
+
userUnit,
|
317
|
+
rotate
|
318
|
+
}) {
|
319
|
+
const [x1, y1, x2, y2] = view;
|
320
|
+
const changeOrientation = rotate % 180 !== 0;
|
321
|
+
const width = (x2 - x1) / 72 * userUnit;
|
322
|
+
const height = (y2 - y1) / 72 * userUnit;
|
327
323
|
return {
|
328
324
|
width: changeOrientation ? height : width,
|
329
325
|
height: changeOrientation ? width : height
|
330
326
|
};
|
331
327
|
}
|
328
|
+
|
332
329
|
function backtrackBeforeAllVisibleElements(index, views, top) {
|
333
330
|
if (index < 2) {
|
334
331
|
return index;
|
335
332
|
}
|
336
|
-
|
337
|
-
|
333
|
+
|
334
|
+
let elt = views[index].div;
|
335
|
+
let pageTop = elt.offsetTop + elt.clientTop;
|
336
|
+
|
338
337
|
if (pageTop >= top) {
|
339
338
|
elt = views[index - 1].div;
|
340
339
|
pageTop = elt.offsetTop + elt.clientTop;
|
341
340
|
}
|
342
|
-
|
341
|
+
|
342
|
+
for (let i = index - 2; i >= 0; --i) {
|
343
343
|
elt = views[i].div;
|
344
|
+
|
344
345
|
if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
|
345
346
|
break;
|
346
347
|
}
|
348
|
+
|
347
349
|
index = i;
|
348
350
|
}
|
351
|
+
|
349
352
|
return index;
|
350
353
|
}
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
right = left + scrollEl.clientWidth;
|
354
|
+
|
355
|
+
function getVisibleElements(scrollEl, views, sortByVisibility = false, horizontal = false) {
|
356
|
+
const top = scrollEl.scrollTop,
|
357
|
+
bottom = top + scrollEl.clientHeight;
|
358
|
+
const left = scrollEl.scrollLeft,
|
359
|
+
right = left + scrollEl.clientWidth;
|
360
|
+
|
359
361
|
function isElementBottomAfterViewTop(view) {
|
360
|
-
|
361
|
-
|
362
|
+
const element = view.div;
|
363
|
+
const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
|
362
364
|
return elementBottom > top;
|
363
365
|
}
|
366
|
+
|
364
367
|
function isElementRightAfterViewLeft(view) {
|
365
|
-
|
366
|
-
|
368
|
+
const element = view.div;
|
369
|
+
const elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
|
367
370
|
return elementRight > left;
|
368
371
|
}
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
hiddenHeight = void 0;
|
376
|
-
var currentWidth = void 0,
|
377
|
-
viewWidth = void 0,
|
378
|
-
viewRight = void 0,
|
379
|
-
hiddenWidth = void 0;
|
380
|
-
var percentVisible = void 0;
|
381
|
-
var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
|
382
|
-
if (views.length > 0 && !horizontal) {
|
372
|
+
|
373
|
+
const visible = [],
|
374
|
+
numViews = views.length;
|
375
|
+
let firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
|
376
|
+
|
377
|
+
if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
|
383
378
|
firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
|
384
379
|
}
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
380
|
+
|
381
|
+
let lastEdge = horizontal ? right : -1;
|
382
|
+
|
383
|
+
for (let i = firstVisibleElementInd; i < numViews; i++) {
|
384
|
+
const view = views[i],
|
385
|
+
element = view.div;
|
386
|
+
const currentWidth = element.offsetLeft + element.clientLeft;
|
387
|
+
const currentHeight = element.offsetTop + element.clientTop;
|
388
|
+
const viewWidth = element.clientWidth,
|
389
|
+
viewHeight = element.clientHeight;
|
390
|
+
const viewRight = currentWidth + viewWidth;
|
391
|
+
const viewBottom = currentHeight + viewHeight;
|
392
|
+
|
395
393
|
if (lastEdge === -1) {
|
396
394
|
if (viewBottom >= bottom) {
|
397
395
|
lastEdge = viewBottom;
|
@@ -399,307 +397,397 @@ function getVisibleElements(scrollEl, views) {
|
|
399
397
|
} else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
|
400
398
|
break;
|
401
399
|
}
|
400
|
+
|
402
401
|
if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
|
403
402
|
continue;
|
404
403
|
}
|
405
|
-
|
406
|
-
|
407
|
-
|
404
|
+
|
405
|
+
const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
|
406
|
+
const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
|
407
|
+
const percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
|
408
408
|
visible.push({
|
409
409
|
id: view.id,
|
410
410
|
x: currentWidth,
|
411
411
|
y: currentHeight,
|
412
|
-
view
|
413
|
-
percent
|
412
|
+
view,
|
413
|
+
percent
|
414
414
|
});
|
415
415
|
}
|
416
|
-
|
417
|
-
|
416
|
+
|
417
|
+
const first = visible[0],
|
418
|
+
last = visible[visible.length - 1];
|
419
|
+
|
418
420
|
if (sortByVisibility) {
|
419
421
|
visible.sort(function (a, b) {
|
420
|
-
|
422
|
+
const pc = a.percent - b.percent;
|
423
|
+
|
421
424
|
if (Math.abs(pc) > 0.001) {
|
422
425
|
return -pc;
|
423
426
|
}
|
427
|
+
|
424
428
|
return a.id - b.id;
|
425
429
|
});
|
426
430
|
}
|
431
|
+
|
427
432
|
return {
|
428
|
-
first
|
429
|
-
last
|
433
|
+
first,
|
434
|
+
last,
|
430
435
|
views: visible
|
431
436
|
};
|
432
437
|
}
|
438
|
+
|
433
439
|
function noContextMenuHandler(evt) {
|
434
440
|
evt.preventDefault();
|
435
441
|
}
|
442
|
+
|
436
443
|
function isDataSchema(url) {
|
437
|
-
|
438
|
-
|
439
|
-
|
444
|
+
let i = 0;
|
445
|
+
const ii = url.length;
|
446
|
+
|
447
|
+
while (i < ii && url[i].trim() === "") {
|
440
448
|
i++;
|
441
449
|
}
|
442
|
-
|
450
|
+
|
451
|
+
return url.substring(i, i + 5).toLowerCase() === "data:";
|
443
452
|
}
|
444
|
-
function getPDFFileNameFromURL(url) {
|
445
|
-
var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
|
446
453
|
|
447
|
-
|
454
|
+
function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
|
455
|
+
if (typeof url !== "string") {
|
448
456
|
return defaultFilename;
|
449
457
|
}
|
458
|
+
|
450
459
|
if (isDataSchema(url)) {
|
451
|
-
console.warn(
|
460
|
+
console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
|
452
461
|
return defaultFilename;
|
453
462
|
}
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
463
|
+
|
464
|
+
const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
465
|
+
const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
466
|
+
const splitURI = reURI.exec(url);
|
467
|
+
let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
|
468
|
+
|
458
469
|
if (suggestedFilename) {
|
459
470
|
suggestedFilename = suggestedFilename[0];
|
460
|
-
|
471
|
+
|
472
|
+
if (suggestedFilename.includes("%")) {
|
461
473
|
try {
|
462
474
|
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
|
463
475
|
} catch (ex) {}
|
464
476
|
}
|
465
477
|
}
|
478
|
+
|
466
479
|
return suggestedFilename || defaultFilename;
|
467
480
|
}
|
481
|
+
|
468
482
|
function normalizeWheelEventDelta(evt) {
|
469
|
-
|
470
|
-
|
483
|
+
let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
484
|
+
const angle = Math.atan2(evt.deltaY, evt.deltaX);
|
485
|
+
|
471
486
|
if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
|
472
487
|
delta = -delta;
|
473
488
|
}
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
489
|
+
|
490
|
+
const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
|
491
|
+
const MOUSE_DOM_DELTA_LINE_MODE = 1;
|
492
|
+
const MOUSE_PIXELS_PER_LINE = 30;
|
493
|
+
const MOUSE_LINES_PER_PAGE = 30;
|
494
|
+
|
478
495
|
if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
|
479
496
|
delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
|
480
497
|
} else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
|
481
498
|
delta /= MOUSE_LINES_PER_PAGE;
|
482
499
|
}
|
500
|
+
|
483
501
|
return delta;
|
484
502
|
}
|
503
|
+
|
485
504
|
function isValidRotation(angle) {
|
486
505
|
return Number.isInteger(angle) && angle % 90 === 0;
|
487
506
|
}
|
507
|
+
|
508
|
+
function isValidScrollMode(mode) {
|
509
|
+
return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
|
510
|
+
}
|
511
|
+
|
512
|
+
function isValidSpreadMode(mode) {
|
513
|
+
return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
|
514
|
+
}
|
515
|
+
|
488
516
|
function isPortraitOrientation(size) {
|
489
517
|
return size.width <= size.height;
|
490
518
|
}
|
491
|
-
|
492
|
-
|
493
|
-
|
519
|
+
|
520
|
+
const WaitOnType = {
|
521
|
+
EVENT: "event",
|
522
|
+
TIMEOUT: "timeout"
|
494
523
|
};
|
495
|
-
|
496
|
-
var target = _ref6.target,
|
497
|
-
name = _ref6.name,
|
498
|
-
_ref6$delay = _ref6.delay,
|
499
|
-
delay = _ref6$delay === undefined ? 0 : _ref6$delay;
|
524
|
+
exports.WaitOnType = WaitOnType;
|
500
525
|
|
526
|
+
function waitOnEventOrTimeout({
|
527
|
+
target,
|
528
|
+
name,
|
529
|
+
delay = 0
|
530
|
+
}) {
|
501
531
|
return new Promise(function (resolve, reject) {
|
502
|
-
if (
|
503
|
-
throw new Error(
|
532
|
+
if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
|
533
|
+
throw new Error("waitOnEventOrTimeout - invalid parameters.");
|
504
534
|
}
|
535
|
+
|
505
536
|
function handler(type) {
|
506
537
|
if (target instanceof EventBus) {
|
507
|
-
target.
|
538
|
+
target._off(name, eventHandler);
|
508
539
|
} else {
|
509
540
|
target.removeEventListener(name, eventHandler);
|
510
541
|
}
|
542
|
+
|
511
543
|
if (timeout) {
|
512
544
|
clearTimeout(timeout);
|
513
545
|
}
|
546
|
+
|
514
547
|
resolve(type);
|
515
548
|
}
|
516
|
-
|
549
|
+
|
550
|
+
const eventHandler = handler.bind(null, WaitOnType.EVENT);
|
551
|
+
|
517
552
|
if (target instanceof EventBus) {
|
518
|
-
target.
|
553
|
+
target._on(name, eventHandler);
|
519
554
|
} else {
|
520
555
|
target.addEventListener(name, eventHandler);
|
521
556
|
}
|
522
|
-
|
523
|
-
|
557
|
+
|
558
|
+
const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
|
559
|
+
const timeout = setTimeout(timeoutHandler, delay);
|
524
560
|
});
|
525
561
|
}
|
526
|
-
|
527
|
-
|
528
|
-
setTimeout(resolve, 20);
|
529
|
-
return;
|
530
|
-
}
|
562
|
+
|
563
|
+
const animationStarted = new Promise(function (resolve) {
|
531
564
|
window.requestAnimationFrame(resolve);
|
532
565
|
});
|
566
|
+
exports.animationStarted = animationStarted;
|
567
|
+
|
568
|
+
function dispatchDOMEvent(eventName, args = null) {
|
569
|
+
const details = Object.create(null);
|
570
|
+
|
571
|
+
if (args && args.length > 0) {
|
572
|
+
const obj = args[0];
|
533
573
|
|
534
|
-
|
535
|
-
|
536
|
-
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
537
|
-
_ref7$dispatchToDOM = _ref7.dispatchToDOM,
|
538
|
-
dispatchToDOM = _ref7$dispatchToDOM === undefined ? false : _ref7$dispatchToDOM;
|
574
|
+
for (const key in obj) {
|
575
|
+
const value = obj[key];
|
539
576
|
|
540
|
-
|
577
|
+
if (key === "source") {
|
578
|
+
if (value === window || value === document) {
|
579
|
+
return;
|
580
|
+
}
|
581
|
+
|
582
|
+
continue;
|
583
|
+
}
|
584
|
+
|
585
|
+
details[key] = value;
|
586
|
+
}
|
587
|
+
}
|
588
|
+
|
589
|
+
const event = document.createEvent("CustomEvent");
|
590
|
+
event.initCustomEvent(eventName, true, true, details);
|
591
|
+
document.dispatchEvent(event);
|
592
|
+
}
|
541
593
|
|
594
|
+
class EventBus {
|
595
|
+
constructor({
|
596
|
+
dispatchToDOM = false
|
597
|
+
} = {}) {
|
542
598
|
this._listeners = Object.create(null);
|
543
599
|
this._dispatchToDOM = dispatchToDOM === true;
|
544
|
-
}
|
545
600
|
|
546
|
-
|
547
|
-
|
548
|
-
value: function on(eventName, listener) {
|
549
|
-
var eventListeners = this._listeners[eventName];
|
550
|
-
if (!eventListeners) {
|
551
|
-
eventListeners = [];
|
552
|
-
this._listeners[eventName] = eventListeners;
|
553
|
-
}
|
554
|
-
eventListeners.push(listener);
|
601
|
+
if (dispatchToDOM) {
|
602
|
+
console.error("The `eventBusDispatchToDOM` option/preference is deprecated, " + "add event listeners to the EventBus instance rather than the DOM.");
|
555
603
|
}
|
556
|
-
}
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
604
|
+
}
|
605
|
+
|
606
|
+
on(eventName, listener) {
|
607
|
+
this._on(eventName, listener, {
|
608
|
+
external: true
|
609
|
+
});
|
610
|
+
}
|
611
|
+
|
612
|
+
off(eventName, listener) {
|
613
|
+
this._off(eventName, listener, {
|
614
|
+
external: true
|
615
|
+
});
|
616
|
+
}
|
617
|
+
|
618
|
+
dispatch(eventName) {
|
619
|
+
const eventListeners = this._listeners[eventName];
|
620
|
+
|
621
|
+
if (!eventListeners || eventListeners.length === 0) {
|
622
|
+
if (this._dispatchToDOM) {
|
623
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
624
|
+
dispatchDOMEvent(eventName, args);
|
563
625
|
}
|
564
|
-
|
626
|
+
|
627
|
+
return;
|
565
628
|
}
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
629
|
+
|
630
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
631
|
+
let externalListeners;
|
632
|
+
eventListeners.slice(0).forEach(function ({
|
633
|
+
listener,
|
634
|
+
external
|
635
|
+
}) {
|
636
|
+
if (external) {
|
637
|
+
if (!externalListeners) {
|
638
|
+
externalListeners = [];
|
574
639
|
}
|
640
|
+
|
641
|
+
externalListeners.push(listener);
|
575
642
|
return;
|
576
643
|
}
|
577
|
-
|
578
|
-
|
644
|
+
|
645
|
+
listener.apply(null, args);
|
646
|
+
});
|
647
|
+
|
648
|
+
if (externalListeners) {
|
649
|
+
externalListeners.forEach(function (listener) {
|
579
650
|
listener.apply(null, args);
|
580
651
|
});
|
581
|
-
|
582
|
-
|
583
|
-
|
652
|
+
externalListeners = null;
|
653
|
+
}
|
654
|
+
|
655
|
+
if (this._dispatchToDOM) {
|
656
|
+
dispatchDOMEvent(eventName, args);
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
_on(eventName, listener, options = null) {
|
661
|
+
let eventListeners = this._listeners[eventName];
|
662
|
+
|
663
|
+
if (!eventListeners) {
|
664
|
+
this._listeners[eventName] = eventListeners = [];
|
665
|
+
}
|
666
|
+
|
667
|
+
eventListeners.push({
|
668
|
+
listener,
|
669
|
+
external: (options && options.external) === true
|
670
|
+
});
|
671
|
+
}
|
672
|
+
|
673
|
+
_off(eventName, listener, options = null) {
|
674
|
+
const eventListeners = this._listeners[eventName];
|
675
|
+
|
676
|
+
if (!eventListeners) {
|
677
|
+
return;
|
584
678
|
}
|
585
|
-
}, {
|
586
|
-
key: '_dispatchDOMEvent',
|
587
|
-
value: function _dispatchDOMEvent(eventName) {
|
588
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
589
679
|
|
590
|
-
|
680
|
+
for (let i = 0, ii = eventListeners.length; i < ii; i++) {
|
681
|
+
if (eventListeners[i].listener === listener) {
|
682
|
+
eventListeners.splice(i, 1);
|
591
683
|
return;
|
592
684
|
}
|
593
|
-
var details = Object.create(null);
|
594
|
-
if (args && args.length > 0) {
|
595
|
-
var obj = args[0];
|
596
|
-
for (var key in obj) {
|
597
|
-
var value = obj[key];
|
598
|
-
if (key === 'source') {
|
599
|
-
if (value === window || value === document) {
|
600
|
-
return;
|
601
|
-
}
|
602
|
-
continue;
|
603
|
-
}
|
604
|
-
details[key] = value;
|
605
|
-
}
|
606
|
-
}
|
607
|
-
var event = document.createEvent('CustomEvent');
|
608
|
-
event.initCustomEvent(eventName, true, true, details);
|
609
|
-
document.dispatchEvent(event);
|
610
685
|
}
|
611
|
-
}
|
686
|
+
}
|
612
687
|
|
613
|
-
|
614
|
-
|
688
|
+
}
|
689
|
+
|
690
|
+
exports.EventBus = EventBus;
|
691
|
+
let globalEventBus = null;
|
692
|
+
|
693
|
+
function getGlobalEventBus(dispatchToDOM = false) {
|
694
|
+
console.error("getGlobalEventBus is deprecated, use a manually created EventBus instance instead.");
|
695
|
+
|
696
|
+
if (!globalEventBus) {
|
697
|
+
globalEventBus = new EventBus({
|
698
|
+
dispatchToDOM
|
699
|
+
});
|
700
|
+
}
|
701
|
+
|
702
|
+
return globalEventBus;
|
703
|
+
}
|
615
704
|
|
616
705
|
function clamp(v, min, max) {
|
617
706
|
return Math.min(Math.max(v, min), max);
|
618
707
|
}
|
619
708
|
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
_classCallCheck(this, ProgressBar);
|
628
|
-
|
709
|
+
class ProgressBar {
|
710
|
+
constructor(id, {
|
711
|
+
height,
|
712
|
+
width,
|
713
|
+
units
|
714
|
+
} = {}) {
|
629
715
|
this.visible = true;
|
630
|
-
this.div = document.querySelector(id +
|
716
|
+
this.div = document.querySelector(id + " .progress");
|
631
717
|
this.bar = this.div.parentNode;
|
632
718
|
this.height = height || 100;
|
633
719
|
this.width = width || 100;
|
634
|
-
this.units = units ||
|
720
|
+
this.units = units || "%";
|
635
721
|
this.div.style.height = this.height + this.units;
|
636
722
|
this.percent = 0;
|
637
723
|
}
|
638
724
|
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
this.div.style.width = this.width + this.units;
|
645
|
-
return;
|
646
|
-
}
|
647
|
-
this.div.classList.remove('indeterminate');
|
648
|
-
var progressSize = this.width * this._percent / 100;
|
649
|
-
this.div.style.width = progressSize + this.units;
|
725
|
+
_updateBar() {
|
726
|
+
if (this._indeterminate) {
|
727
|
+
this.div.classList.add("indeterminate");
|
728
|
+
this.div.style.width = this.width + this.units;
|
729
|
+
return;
|
650
730
|
}
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
731
|
+
|
732
|
+
this.div.classList.remove("indeterminate");
|
733
|
+
const progressSize = this.width * this._percent / 100;
|
734
|
+
this.div.style.width = progressSize + this.units;
|
735
|
+
}
|
736
|
+
|
737
|
+
get percent() {
|
738
|
+
return this._percent;
|
739
|
+
}
|
740
|
+
|
741
|
+
set percent(val) {
|
742
|
+
this._indeterminate = isNaN(val);
|
743
|
+
this._percent = clamp(val, 0, 100);
|
744
|
+
|
745
|
+
this._updateBar();
|
746
|
+
}
|
747
|
+
|
748
|
+
setWidth(viewer) {
|
749
|
+
if (!viewer) {
|
750
|
+
return;
|
662
751
|
}
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
}
|
669
|
-
this.visible = false;
|
670
|
-
this.bar.classList.add('hidden');
|
671
|
-
document.body.classList.remove('loadingInProgress');
|
752
|
+
|
753
|
+
const container = viewer.parentNode;
|
754
|
+
const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
755
|
+
|
756
|
+
if (scrollbarWidth > 0) {
|
757
|
+
this.bar.style.width = `calc(100% - ${scrollbarWidth}px)`;
|
672
758
|
}
|
673
|
-
}
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
}
|
679
|
-
this.visible = true;
|
680
|
-
document.body.classList.add('loadingInProgress');
|
681
|
-
this.bar.classList.remove('hidden');
|
759
|
+
}
|
760
|
+
|
761
|
+
hide() {
|
762
|
+
if (!this.visible) {
|
763
|
+
return;
|
682
764
|
}
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
765
|
+
|
766
|
+
this.visible = false;
|
767
|
+
this.bar.classList.add("hidden");
|
768
|
+
document.body.classList.remove("loadingInProgress");
|
769
|
+
}
|
770
|
+
|
771
|
+
show() {
|
772
|
+
if (this.visible) {
|
773
|
+
return;
|
692
774
|
}
|
693
|
-
}]);
|
694
775
|
|
695
|
-
|
696
|
-
|
776
|
+
this.visible = true;
|
777
|
+
document.body.classList.add("loadingInProgress");
|
778
|
+
this.bar.classList.remove("hidden");
|
779
|
+
}
|
780
|
+
|
781
|
+
}
|
782
|
+
|
783
|
+
exports.ProgressBar = ProgressBar;
|
697
784
|
|
698
785
|
function moveToEndOfArray(arr, condition) {
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
786
|
+
const moved = [],
|
787
|
+
len = arr.length;
|
788
|
+
let write = 0;
|
789
|
+
|
790
|
+
for (let read = 0; read < len; ++read) {
|
703
791
|
if (condition(arr[read])) {
|
704
792
|
moved.push(arr[read]);
|
705
793
|
} else {
|
@@ -707,41 +795,8 @@ function moveToEndOfArray(arr, condition) {
|
|
707
795
|
++write;
|
708
796
|
}
|
709
797
|
}
|
710
|
-
|
711
|
-
|
798
|
+
|
799
|
+
for (let read = 0; write < len; ++read, ++write) {
|
800
|
+
arr[write] = moved[read];
|
712
801
|
}
|
713
|
-
}
|
714
|
-
exports.CSS_UNITS = CSS_UNITS;
|
715
|
-
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
|
716
|
-
exports.DEFAULT_SCALE = DEFAULT_SCALE;
|
717
|
-
exports.MIN_SCALE = MIN_SCALE;
|
718
|
-
exports.MAX_SCALE = MAX_SCALE;
|
719
|
-
exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
|
720
|
-
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
|
721
|
-
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
|
722
|
-
exports.VERTICAL_PADDING = VERTICAL_PADDING;
|
723
|
-
exports.isValidRotation = isValidRotation;
|
724
|
-
exports.isPortraitOrientation = isPortraitOrientation;
|
725
|
-
exports.PresentationModeState = PresentationModeState;
|
726
|
-
exports.RendererType = RendererType;
|
727
|
-
exports.TextLayerMode = TextLayerMode;
|
728
|
-
exports.NullL10n = NullL10n;
|
729
|
-
exports.EventBus = EventBus;
|
730
|
-
exports.ProgressBar = ProgressBar;
|
731
|
-
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
|
732
|
-
exports.noContextMenuHandler = noContextMenuHandler;
|
733
|
-
exports.parseQueryString = parseQueryString;
|
734
|
-
exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
|
735
|
-
exports.getVisibleElements = getVisibleElements;
|
736
|
-
exports.roundToDivide = roundToDivide;
|
737
|
-
exports.getPageSizeInches = getPageSizeInches;
|
738
|
-
exports.approximateFraction = approximateFraction;
|
739
|
-
exports.getOutputScale = getOutputScale;
|
740
|
-
exports.scrollIntoView = scrollIntoView;
|
741
|
-
exports.watchScroll = watchScroll;
|
742
|
-
exports.binarySearchFirstItem = binarySearchFirstItem;
|
743
|
-
exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
|
744
|
-
exports.animationStarted = animationStarted;
|
745
|
-
exports.WaitOnType = WaitOnType;
|
746
|
-
exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
|
747
|
-
exports.moveToEndOfArray = moveToEndOfArray;
|
802
|
+
}
|