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