pdfjs-dist 2.0.943 → 2.1.266
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/bower.json +1 -1
- package/build/pdf.js +15329 -11095
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +12497 -4184
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +3438 -1209
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +335 -109
- package/lib/core/arithmetic_decoder.js +274 -244
- package/lib/core/bidi.js +64 -5
- package/lib/core/ccitt.js +172 -17
- package/lib/core/ccitt_stream.js +14 -5
- package/lib/core/cff_parser.js +304 -28
- package/lib/core/charsets.js +4 -3
- package/lib/core/chunked_stream.js +379 -149
- package/lib/core/cmap.js +210 -40
- package/lib/core/colorspace.js +332 -187
- package/lib/core/crypto.js +289 -44
- package/lib/core/document.js +508 -249
- package/lib/core/encodings.js +18 -9
- package/lib/core/evaluator.js +657 -119
- package/lib/core/font_renderer.js +217 -34
- package/lib/core/fonts.js +632 -41
- package/lib/core/function.js +252 -26
- package/lib/core/glyphlist.js +2 -1
- package/lib/core/image.js +124 -27
- package/lib/core/jbig2.js +425 -65
- package/lib/core/jbig2_stream.js +18 -7
- package/lib/core/jpeg_stream.js +24 -8
- package/lib/core/jpg.js +208 -16
- package/lib/core/jpx.js +395 -5
- package/lib/core/jpx_stream.js +17 -5
- package/lib/core/metrics.js +3 -3
- package/lib/core/murmurhash3.js +23 -5
- package/lib/core/obj.js +625 -132
- package/lib/core/operator_list.js +104 -3
- package/lib/core/parser.js +262 -25
- package/lib/core/pattern.js +144 -12
- package/lib/core/pdf_manager.js +104 -70
- package/lib/core/primitives.js +74 -21
- package/lib/core/ps_parser.js +133 -44
- package/lib/core/standard_fonts.js +9 -9
- package/lib/core/stream.js +283 -31
- package/lib/core/type1_parser.js +138 -6
- package/lib/core/unicode.js +28 -1
- package/lib/core/worker.js +192 -57
- package/lib/display/annotation_layer.js +303 -123
- package/lib/display/api.js +1073 -574
- package/lib/display/api_compatibility.js +4 -1
- package/lib/display/canvas.js +314 -18
- package/lib/display/content_disposition.js +70 -23
- package/lib/display/dom_utils.js +112 -59
- package/lib/display/fetch_stream.js +95 -50
- package/lib/display/font_loader.js +250 -132
- package/lib/display/metadata.js +37 -15
- package/lib/display/network.js +123 -34
- package/lib/display/network_utils.js +23 -10
- package/lib/display/node_stream.js +162 -65
- package/lib/display/pattern_helper.js +57 -6
- package/lib/display/svg.js +194 -18
- package/lib/display/text_layer.js +128 -14
- package/lib/display/transport_stream.js +83 -27
- package/lib/display/webgl.js +63 -17
- package/lib/display/worker_options.js +4 -3
- package/lib/display/xml_parser.js +162 -52
- package/lib/examples/node/domstubs.js +56 -3
- package/lib/pdf.js +15 -2
- package/lib/pdf.worker.js +4 -2
- package/lib/shared/compatibility.js +129 -26
- package/lib/shared/global_scope.js +1 -1
- package/lib/shared/is_node.js +3 -3
- package/lib/shared/message_handler.js +103 -45
- package/lib/shared/streams_polyfill.js +20 -16
- package/lib/shared/url_polyfill.js +8 -2
- package/lib/shared/util.js +246 -84
- package/lib/test/unit/annotation_spec.js +99 -73
- package/lib/test/unit/api_spec.js +347 -113
- package/lib/test/unit/bidi_spec.js +6 -6
- package/lib/test/unit/cff_parser_spec.js +17 -5
- package/lib/test/unit/clitests_helper.js +7 -8
- package/lib/test/unit/cmap_spec.js +79 -25
- package/lib/test/unit/colorspace_spec.js +65 -18
- package/lib/test/unit/crypto_spec.js +16 -4
- package/lib/test/unit/custom_spec.js +40 -52
- package/lib/test/unit/display_svg_spec.js +32 -16
- package/lib/test/unit/document_spec.js +2 -2
- package/lib/test/unit/dom_utils_spec.js +8 -8
- package/lib/test/unit/encodings_spec.js +24 -44
- package/lib/test/unit/evaluator_spec.js +15 -8
- package/lib/test/unit/function_spec.js +16 -4
- package/lib/test/unit/jasmine-boot.js +29 -16
- package/lib/test/unit/message_handler_spec.js +19 -6
- package/lib/test/unit/metadata_spec.js +64 -11
- package/lib/test/unit/murmurhash3_spec.js +2 -2
- package/lib/test/unit/network_spec.js +19 -4
- package/lib/test/unit/network_utils_spec.js +6 -4
- package/lib/test/unit/node_stream_spec.js +50 -26
- package/lib/test/unit/parser_spec.js +13 -29
- package/lib/test/unit/pdf_find_controller_spec.js +144 -32
- package/lib/test/unit/pdf_find_utils_spec.js +10 -9
- package/lib/test/unit/pdf_history_spec.js +20 -8
- package/lib/test/unit/primitives_spec.js +23 -3
- package/lib/test/unit/stream_spec.js +8 -3
- package/lib/test/unit/test_utils.js +89 -26
- package/lib/test/unit/testreporter.js +19 -1
- package/lib/test/unit/type1_parser_spec.js +7 -5
- package/lib/test/unit/ui_utils_spec.js +162 -38
- package/lib/test/unit/unicode_spec.js +13 -10
- package/lib/test/unit/util_spec.js +89 -9
- package/lib/web/annotation_layer_builder.js +38 -21
- package/lib/web/app.js +610 -245
- package/lib/web/app_options.js +54 -34
- package/lib/web/base_viewer.js +359 -162
- package/lib/web/chromecom.js +159 -80
- package/lib/web/debugger.js +161 -17
- package/lib/web/download_manager.js +29 -11
- package/lib/web/firefox_print_service.js +16 -8
- package/lib/web/firefoxcom.js +127 -91
- package/lib/web/genericcom.js +50 -31
- package/lib/web/genericl10n.js +46 -34
- package/lib/web/grab_to_pan.js +25 -3
- package/lib/web/interfaces.js +108 -61
- package/lib/web/overlay_manager.js +67 -45
- package/lib/web/password_prompt.js +20 -12
- package/lib/web/pdf_attachment_viewer.js +37 -17
- package/lib/web/pdf_cursor_tools.js +38 -15
- package/lib/web/pdf_document_properties.js +65 -24
- package/lib/web/pdf_find_bar.js +48 -20
- package/lib/web/pdf_find_controller.js +290 -89
- package/lib/web/pdf_find_utils.js +19 -3
- package/lib/web/pdf_history.js +186 -49
- package/lib/web/pdf_link_service.js +127 -52
- package/lib/web/pdf_outline_viewer.js +71 -21
- package/lib/web/pdf_page_view.js +188 -63
- package/lib/web/pdf_presentation_mode.js +98 -33
- package/lib/web/pdf_print_service.js +54 -10
- package/lib/web/pdf_rendering_queue.js +26 -4
- package/lib/web/pdf_sidebar.js +116 -62
- package/lib/web/pdf_sidebar_resizer.js +41 -15
- package/lib/web/pdf_single_page_viewer.js +65 -68
- package/lib/web/pdf_thumbnail_view.js +102 -31
- package/lib/web/pdf_thumbnail_viewer.js +62 -22
- package/lib/web/pdf_viewer.component.js +111 -31
- package/lib/web/pdf_viewer.js +80 -60
- package/lib/web/preferences.js +61 -39
- package/lib/web/secondary_toolbar.js +101 -82
- package/lib/web/text_layer_builder.js +124 -69
- package/lib/web/toolbar.js +67 -27
- package/lib/web/ui_utils.js +284 -128
- package/lib/web/view_history.js +75 -51
- package/lib/web/viewer_compatibility.js +2 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +1 -1
- package/web/pdf_viewer.js +2200 -973
- package/web/pdf_viewer.js.map +1 -1
- package/lib/web/dom_events.js +0 -140
package/lib/web/preferences.js
CHANGED
@@ -24,29 +24,32 @@
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.BasePreferences =
|
27
|
+
exports.BasePreferences = void 0;
|
28
28
|
|
29
|
-
var _regenerator = require("babel
|
29
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
31
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
34
32
|
|
35
|
-
|
33
|
+
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); } }
|
36
34
|
|
37
|
-
function
|
35
|
+
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); }); }; }
|
38
36
|
|
39
|
-
function
|
37
|
+
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); }
|
40
38
|
|
41
39
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
42
40
|
|
41
|
+
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); } }
|
42
|
+
|
43
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
44
|
+
|
43
45
|
var defaultPreferences = null;
|
46
|
+
|
44
47
|
function getDefaultPreferences() {
|
45
48
|
if (!defaultPreferences) {
|
46
49
|
defaultPreferences = Promise.resolve({
|
47
|
-
"
|
50
|
+
"viewOnLoad": 0,
|
48
51
|
"defaultZoomValue": "",
|
49
|
-
"sidebarViewOnLoad":
|
52
|
+
"sidebarViewOnLoad": -1,
|
50
53
|
"cursorToolOnLoad": 0,
|
51
54
|
"enableWebGL": false,
|
52
55
|
"eventBusDispatchToDOM": false,
|
@@ -61,16 +64,19 @@ function getDefaultPreferences() {
|
|
61
64
|
"renderer": "canvas",
|
62
65
|
"renderInteractiveForms": false,
|
63
66
|
"enablePrintAutoRotate": false,
|
64
|
-
"disablePageMode": false,
|
65
67
|
"disablePageLabels": false,
|
66
|
-
"
|
67
|
-
"
|
68
|
+
"historyUpdateUrl": false,
|
69
|
+
"scrollModeOnLoad": -1,
|
70
|
+
"spreadModeOnLoad": -1
|
68
71
|
});
|
69
72
|
}
|
73
|
+
|
70
74
|
return defaultPreferences;
|
71
75
|
}
|
72
76
|
|
73
|
-
var BasePreferences =
|
77
|
+
var BasePreferences =
|
78
|
+
/*#__PURE__*/
|
79
|
+
function () {
|
74
80
|
function BasePreferences() {
|
75
81
|
var _this = this;
|
76
82
|
|
@@ -79,6 +85,7 @@ var BasePreferences = function () {
|
|
79
85
|
if (this.constructor === BasePreferences) {
|
80
86
|
throw new Error('Cannot initialize BasePreferences.');
|
81
87
|
}
|
88
|
+
|
82
89
|
this.prefs = null;
|
83
90
|
this._initializedPromise = getDefaultPreferences().then(function (defaults) {
|
84
91
|
Object.defineProperty(_this, 'defaults', {
|
@@ -93,12 +100,15 @@ var BasePreferences = function () {
|
|
93
100
|
if (!prefs) {
|
94
101
|
return;
|
95
102
|
}
|
103
|
+
|
96
104
|
for (var name in prefs) {
|
97
105
|
var defaultValue = _this.defaults[name],
|
98
106
|
prefValue = prefs[name];
|
99
|
-
|
107
|
+
|
108
|
+
if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
|
100
109
|
continue;
|
101
110
|
}
|
111
|
+
|
102
112
|
_this.prefs[name] = prefValue;
|
103
113
|
}
|
104
114
|
});
|
@@ -107,8 +117,10 @@ var BasePreferences = function () {
|
|
107
117
|
_createClass(BasePreferences, [{
|
108
118
|
key: "_writeToStorage",
|
109
119
|
value: function () {
|
110
|
-
var
|
111
|
-
|
120
|
+
var _writeToStorage2 = _asyncToGenerator(
|
121
|
+
/*#__PURE__*/
|
122
|
+
_regenerator.default.mark(function _callee(prefObj) {
|
123
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
112
124
|
while (1) {
|
113
125
|
switch (_context.prev = _context.next) {
|
114
126
|
case 0:
|
@@ -123,7 +135,7 @@ var BasePreferences = function () {
|
|
123
135
|
}));
|
124
136
|
|
125
137
|
function _writeToStorage(_x) {
|
126
|
-
return
|
138
|
+
return _writeToStorage2.apply(this, arguments);
|
127
139
|
}
|
128
140
|
|
129
141
|
return _writeToStorage;
|
@@ -131,8 +143,10 @@ var BasePreferences = function () {
|
|
131
143
|
}, {
|
132
144
|
key: "_readFromStorage",
|
133
145
|
value: function () {
|
134
|
-
var
|
135
|
-
|
146
|
+
var _readFromStorage2 = _asyncToGenerator(
|
147
|
+
/*#__PURE__*/
|
148
|
+
_regenerator.default.mark(function _callee2(prefObj) {
|
149
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
136
150
|
while (1) {
|
137
151
|
switch (_context2.prev = _context2.next) {
|
138
152
|
case 0:
|
@@ -147,7 +161,7 @@ var BasePreferences = function () {
|
|
147
161
|
}));
|
148
162
|
|
149
163
|
function _readFromStorage(_x2) {
|
150
|
-
return
|
164
|
+
return _readFromStorage2.apply(this, arguments);
|
151
165
|
}
|
152
166
|
|
153
167
|
return _readFromStorage;
|
@@ -155,8 +169,10 @@ var BasePreferences = function () {
|
|
155
169
|
}, {
|
156
170
|
key: "reset",
|
157
171
|
value: function () {
|
158
|
-
var
|
159
|
-
|
172
|
+
var _reset = _asyncToGenerator(
|
173
|
+
/*#__PURE__*/
|
174
|
+
_regenerator.default.mark(function _callee3() {
|
175
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
160
176
|
while (1) {
|
161
177
|
switch (_context3.prev = _context3.next) {
|
162
178
|
case 0:
|
@@ -176,7 +192,7 @@ var BasePreferences = function () {
|
|
176
192
|
}));
|
177
193
|
|
178
194
|
function reset() {
|
179
|
-
return
|
195
|
+
return _reset.apply(this, arguments);
|
180
196
|
}
|
181
197
|
|
182
198
|
return reset;
|
@@ -184,9 +200,11 @@ var BasePreferences = function () {
|
|
184
200
|
}, {
|
185
201
|
key: "set",
|
186
202
|
value: function () {
|
187
|
-
var
|
203
|
+
var _set = _asyncToGenerator(
|
204
|
+
/*#__PURE__*/
|
205
|
+
_regenerator.default.mark(function _callee4(name, value) {
|
188
206
|
var defaultValue, valueType, defaultType;
|
189
|
-
return
|
207
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
190
208
|
while (1) {
|
191
209
|
switch (_context4.prev = _context4.next) {
|
192
210
|
case 0:
|
@@ -201,7 +219,7 @@ var BasePreferences = function () {
|
|
201
219
|
break;
|
202
220
|
}
|
203
221
|
|
204
|
-
throw new Error("Set preference: \""
|
222
|
+
throw new Error("Set preference: \"".concat(name, "\" is undefined."));
|
205
223
|
|
206
224
|
case 7:
|
207
225
|
if (!(value === undefined)) {
|
@@ -212,8 +230,8 @@ var BasePreferences = function () {
|
|
212
230
|
throw new Error('Set preference: no value is specified.');
|
213
231
|
|
214
232
|
case 9:
|
215
|
-
valueType =
|
216
|
-
defaultType =
|
233
|
+
valueType = _typeof(value);
|
234
|
+
defaultType = _typeof(defaultValue);
|
217
235
|
|
218
236
|
if (!(valueType !== defaultType)) {
|
219
237
|
_context4.next = 19;
|
@@ -230,7 +248,7 @@ var BasePreferences = function () {
|
|
230
248
|
break;
|
231
249
|
|
232
250
|
case 16:
|
233
|
-
throw new Error("Set preference: \""
|
251
|
+
throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
|
234
252
|
|
235
253
|
case 17:
|
236
254
|
_context4.next = 21;
|
@@ -242,7 +260,7 @@ var BasePreferences = function () {
|
|
242
260
|
break;
|
243
261
|
}
|
244
262
|
|
245
|
-
throw new Error("Set preference: \""
|
263
|
+
throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
|
246
264
|
|
247
265
|
case 21:
|
248
266
|
this.prefs[name] = value;
|
@@ -257,7 +275,7 @@ var BasePreferences = function () {
|
|
257
275
|
}));
|
258
276
|
|
259
277
|
function set(_x3, _x4) {
|
260
|
-
return
|
278
|
+
return _set.apply(this, arguments);
|
261
279
|
}
|
262
280
|
|
263
281
|
return set;
|
@@ -265,9 +283,11 @@ var BasePreferences = function () {
|
|
265
283
|
}, {
|
266
284
|
key: "get",
|
267
285
|
value: function () {
|
268
|
-
var
|
286
|
+
var _get = _asyncToGenerator(
|
287
|
+
/*#__PURE__*/
|
288
|
+
_regenerator.default.mark(function _callee5(name) {
|
269
289
|
var defaultValue, prefValue;
|
270
|
-
return
|
290
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
271
291
|
while (1) {
|
272
292
|
switch (_context5.prev = _context5.next) {
|
273
293
|
case 0:
|
@@ -282,7 +302,7 @@ var BasePreferences = function () {
|
|
282
302
|
break;
|
283
303
|
}
|
284
304
|
|
285
|
-
throw new Error("Get preference: \""
|
305
|
+
throw new Error("Get preference: \"".concat(name, "\" is undefined."));
|
286
306
|
|
287
307
|
case 7:
|
288
308
|
prefValue = this.prefs[name];
|
@@ -306,7 +326,7 @@ var BasePreferences = function () {
|
|
306
326
|
}));
|
307
327
|
|
308
328
|
function get(_x5) {
|
309
|
-
return
|
329
|
+
return _get.apply(this, arguments);
|
310
330
|
}
|
311
331
|
|
312
332
|
return get;
|
@@ -314,8 +334,10 @@ var BasePreferences = function () {
|
|
314
334
|
}, {
|
315
335
|
key: "getAll",
|
316
336
|
value: function () {
|
317
|
-
var
|
318
|
-
|
337
|
+
var _getAll = _asyncToGenerator(
|
338
|
+
/*#__PURE__*/
|
339
|
+
_regenerator.default.mark(function _callee6() {
|
340
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
319
341
|
while (1) {
|
320
342
|
switch (_context6.prev = _context6.next) {
|
321
343
|
case 0:
|
@@ -334,7 +356,7 @@ var BasePreferences = function () {
|
|
334
356
|
}));
|
335
357
|
|
336
358
|
function getAll() {
|
337
|
-
return
|
359
|
+
return _getAll.apply(this, arguments);
|
338
360
|
}
|
339
361
|
|
340
362
|
return getAll;
|
@@ -19,26 +19,28 @@
|
|
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.SecondaryToolbar =
|
27
|
+
exports.SecondaryToolbar = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _ui_utils = require("./ui_utils");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _pdf_cursor_tools = require("./pdf_cursor_tools");
|
32
32
|
|
33
|
-
var
|
33
|
+
var _pdf_single_page_viewer = require("./pdf_single_page_viewer");
|
34
34
|
|
35
|
-
|
35
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
36
36
|
|
37
|
-
var
|
37
|
+
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); } }
|
38
38
|
|
39
|
-
function
|
39
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
40
40
|
|
41
|
-
var SecondaryToolbar =
|
41
|
+
var SecondaryToolbar =
|
42
|
+
/*#__PURE__*/
|
43
|
+
function () {
|
42
44
|
function SecondaryToolbar(options, mainContainer, eventBus) {
|
43
45
|
var _this = this;
|
44
46
|
|
@@ -86,42 +88,58 @@ var SecondaryToolbar = function () {
|
|
86
88
|
}, {
|
87
89
|
element: options.cursorSelectToolButton,
|
88
90
|
eventName: 'switchcursortool',
|
89
|
-
eventDetails: {
|
91
|
+
eventDetails: {
|
92
|
+
tool: _pdf_cursor_tools.CursorTool.SELECT
|
93
|
+
},
|
90
94
|
close: true
|
91
95
|
}, {
|
92
96
|
element: options.cursorHandToolButton,
|
93
97
|
eventName: 'switchcursortool',
|
94
|
-
eventDetails: {
|
98
|
+
eventDetails: {
|
99
|
+
tool: _pdf_cursor_tools.CursorTool.HAND
|
100
|
+
},
|
95
101
|
close: true
|
96
102
|
}, {
|
97
103
|
element: options.scrollVerticalButton,
|
98
104
|
eventName: 'switchscrollmode',
|
99
|
-
eventDetails: {
|
105
|
+
eventDetails: {
|
106
|
+
mode: _ui_utils.ScrollMode.VERTICAL
|
107
|
+
},
|
100
108
|
close: true
|
101
109
|
}, {
|
102
110
|
element: options.scrollHorizontalButton,
|
103
111
|
eventName: 'switchscrollmode',
|
104
|
-
eventDetails: {
|
112
|
+
eventDetails: {
|
113
|
+
mode: _ui_utils.ScrollMode.HORIZONTAL
|
114
|
+
},
|
105
115
|
close: true
|
106
116
|
}, {
|
107
117
|
element: options.scrollWrappedButton,
|
108
118
|
eventName: 'switchscrollmode',
|
109
|
-
eventDetails: {
|
119
|
+
eventDetails: {
|
120
|
+
mode: _ui_utils.ScrollMode.WRAPPED
|
121
|
+
},
|
110
122
|
close: true
|
111
123
|
}, {
|
112
124
|
element: options.spreadNoneButton,
|
113
125
|
eventName: 'switchspreadmode',
|
114
|
-
eventDetails: {
|
126
|
+
eventDetails: {
|
127
|
+
mode: _ui_utils.SpreadMode.NONE
|
128
|
+
},
|
115
129
|
close: true
|
116
130
|
}, {
|
117
131
|
element: options.spreadOddButton,
|
118
132
|
eventName: 'switchspreadmode',
|
119
|
-
eventDetails: {
|
133
|
+
eventDetails: {
|
134
|
+
mode: _ui_utils.SpreadMode.ODD
|
135
|
+
},
|
120
136
|
close: true
|
121
137
|
}, {
|
122
138
|
element: options.spreadEvenButton,
|
123
139
|
eventName: 'switchspreadmode',
|
124
|
-
eventDetails: {
|
140
|
+
eventDetails: {
|
141
|
+
mode: _ui_utils.SpreadMode.EVEN
|
142
|
+
},
|
125
143
|
close: true
|
126
144
|
}, {
|
127
145
|
element: options.documentPropertiesButton,
|
@@ -140,10 +158,15 @@ var SecondaryToolbar = function () {
|
|
140
158
|
this.containerHeight = null;
|
141
159
|
this.previousContainerHeight = null;
|
142
160
|
this.reset();
|
161
|
+
|
143
162
|
this._bindClickListeners();
|
163
|
+
|
144
164
|
this._bindCursorToolsListener(options);
|
165
|
+
|
145
166
|
this._bindScrollModeListener(options);
|
167
|
+
|
146
168
|
this._bindSpreadModeListener(options);
|
169
|
+
|
147
170
|
this.eventBus.on('resize', this._setMaxHeight.bind(this));
|
148
171
|
this.eventBus.on('baseviewerinit', function (evt) {
|
149
172
|
if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
|
@@ -155,27 +178,33 @@ var SecondaryToolbar = function () {
|
|
155
178
|
}
|
156
179
|
|
157
180
|
_createClass(SecondaryToolbar, [{
|
158
|
-
key:
|
181
|
+
key: "setPageNumber",
|
159
182
|
value: function setPageNumber(pageNumber) {
|
160
183
|
this.pageNumber = pageNumber;
|
184
|
+
|
161
185
|
this._updateUIState();
|
162
186
|
}
|
163
187
|
}, {
|
164
|
-
key:
|
188
|
+
key: "setPagesCount",
|
165
189
|
value: function setPagesCount(pagesCount) {
|
166
190
|
this.pagesCount = pagesCount;
|
191
|
+
|
167
192
|
this._updateUIState();
|
168
193
|
}
|
169
194
|
}, {
|
170
|
-
key:
|
195
|
+
key: "reset",
|
171
196
|
value: function reset() {
|
172
197
|
this.pageNumber = 0;
|
173
198
|
this.pagesCount = 0;
|
199
|
+
|
174
200
|
this._updateUIState();
|
175
|
-
|
201
|
+
|
202
|
+
this.eventBus.dispatch('secondarytoolbarreset', {
|
203
|
+
source: this
|
204
|
+
});
|
176
205
|
}
|
177
206
|
}, {
|
178
|
-
key:
|
207
|
+
key: "_updateUIState",
|
179
208
|
value: function _updateUIState() {
|
180
209
|
this.items.firstPage.disabled = this.pageNumber <= 1;
|
181
210
|
this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
|
@@ -183,27 +212,31 @@ var SecondaryToolbar = function () {
|
|
183
212
|
this.items.pageRotateCcw.disabled = this.pagesCount === 0;
|
184
213
|
}
|
185
214
|
}, {
|
186
|
-
key:
|
215
|
+
key: "_bindClickListeners",
|
187
216
|
value: function _bindClickListeners() {
|
188
217
|
var _this2 = this;
|
189
218
|
|
190
219
|
this.toggleButton.addEventListener('click', this.toggle.bind(this));
|
191
220
|
|
192
221
|
var _loop = function _loop(button) {
|
193
|
-
var
|
194
|
-
element =
|
195
|
-
eventName =
|
196
|
-
close =
|
197
|
-
eventDetails =
|
198
|
-
|
222
|
+
var _this2$buttons$button = _this2.buttons[button],
|
223
|
+
element = _this2$buttons$button.element,
|
224
|
+
eventName = _this2$buttons$button.eventName,
|
225
|
+
close = _this2$buttons$button.close,
|
226
|
+
eventDetails = _this2$buttons$button.eventDetails;
|
199
227
|
element.addEventListener('click', function (evt) {
|
200
228
|
if (eventName !== null) {
|
201
|
-
var details = {
|
229
|
+
var details = {
|
230
|
+
source: _this2
|
231
|
+
};
|
232
|
+
|
202
233
|
for (var property in eventDetails) {
|
203
234
|
details[property] = eventDetails[property];
|
204
235
|
}
|
236
|
+
|
205
237
|
_this2.eventBus.dispatch(eventName, details);
|
206
238
|
}
|
239
|
+
|
207
240
|
if (close) {
|
208
241
|
_this2.close();
|
209
242
|
}
|
@@ -215,104 +248,87 @@ var SecondaryToolbar = function () {
|
|
215
248
|
}
|
216
249
|
}
|
217
250
|
}, {
|
218
|
-
key:
|
251
|
+
key: "_bindCursorToolsListener",
|
219
252
|
value: function _bindCursorToolsListener(buttons) {
|
220
|
-
this.eventBus.on('cursortoolchanged', function (
|
221
|
-
|
222
|
-
buttons.
|
223
|
-
|
224
|
-
case _pdf_cursor_tools.CursorTool.SELECT:
|
225
|
-
buttons.cursorSelectToolButton.classList.add('toggled');
|
226
|
-
break;
|
227
|
-
case _pdf_cursor_tools.CursorTool.HAND:
|
228
|
-
buttons.cursorHandToolButton.classList.add('toggled');
|
229
|
-
break;
|
230
|
-
}
|
253
|
+
this.eventBus.on('cursortoolchanged', function (_ref) {
|
254
|
+
var tool = _ref.tool;
|
255
|
+
buttons.cursorSelectToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.SELECT);
|
256
|
+
buttons.cursorHandToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.HAND);
|
231
257
|
});
|
232
258
|
}
|
233
259
|
}, {
|
234
|
-
key:
|
260
|
+
key: "_bindScrollModeListener",
|
235
261
|
value: function _bindScrollModeListener(buttons) {
|
236
262
|
var _this3 = this;
|
237
263
|
|
238
|
-
function scrollModeChanged(
|
239
|
-
|
240
|
-
buttons.
|
241
|
-
buttons.
|
242
|
-
|
243
|
-
|
244
|
-
buttons.scrollVerticalButton.classList.add('toggled');
|
245
|
-
break;
|
246
|
-
case _base_viewer.ScrollMode.HORIZONTAL:
|
247
|
-
buttons.scrollHorizontalButton.classList.add('toggled');
|
248
|
-
break;
|
249
|
-
case _base_viewer.ScrollMode.WRAPPED:
|
250
|
-
buttons.scrollWrappedButton.classList.add('toggled');
|
251
|
-
break;
|
252
|
-
}
|
253
|
-
var isScrollModeHorizontal = evt.mode === _base_viewer.ScrollMode.HORIZONTAL;
|
264
|
+
function scrollModeChanged(_ref2) {
|
265
|
+
var mode = _ref2.mode;
|
266
|
+
buttons.scrollVerticalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.VERTICAL);
|
267
|
+
buttons.scrollHorizontalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.HORIZONTAL);
|
268
|
+
buttons.scrollWrappedButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.WRAPPED);
|
269
|
+
var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
|
254
270
|
buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
|
255
271
|
buttons.spreadOddButton.disabled = isScrollModeHorizontal;
|
256
272
|
buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
|
257
273
|
}
|
274
|
+
|
258
275
|
this.eventBus.on('scrollmodechanged', scrollModeChanged);
|
259
276
|
this.eventBus.on('secondarytoolbarreset', function (evt) {
|
260
277
|
if (evt.source === _this3) {
|
261
|
-
scrollModeChanged({
|
278
|
+
scrollModeChanged({
|
279
|
+
mode: _ui_utils.ScrollMode.VERTICAL
|
280
|
+
});
|
262
281
|
}
|
263
282
|
});
|
264
283
|
}
|
265
284
|
}, {
|
266
|
-
key:
|
285
|
+
key: "_bindSpreadModeListener",
|
267
286
|
value: function _bindSpreadModeListener(buttons) {
|
268
287
|
var _this4 = this;
|
269
288
|
|
270
|
-
function spreadModeChanged(
|
271
|
-
|
272
|
-
buttons.
|
273
|
-
buttons.
|
274
|
-
|
275
|
-
case _base_viewer.SpreadMode.NONE:
|
276
|
-
buttons.spreadNoneButton.classList.add('toggled');
|
277
|
-
break;
|
278
|
-
case _base_viewer.SpreadMode.ODD:
|
279
|
-
buttons.spreadOddButton.classList.add('toggled');
|
280
|
-
break;
|
281
|
-
case _base_viewer.SpreadMode.EVEN:
|
282
|
-
buttons.spreadEvenButton.classList.add('toggled');
|
283
|
-
break;
|
284
|
-
}
|
289
|
+
function spreadModeChanged(_ref3) {
|
290
|
+
var mode = _ref3.mode;
|
291
|
+
buttons.spreadNoneButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.NONE);
|
292
|
+
buttons.spreadOddButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.ODD);
|
293
|
+
buttons.spreadEvenButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.EVEN);
|
285
294
|
}
|
295
|
+
|
286
296
|
this.eventBus.on('spreadmodechanged', spreadModeChanged);
|
287
297
|
this.eventBus.on('secondarytoolbarreset', function (evt) {
|
288
298
|
if (evt.source === _this4) {
|
289
|
-
spreadModeChanged({
|
299
|
+
spreadModeChanged({
|
300
|
+
mode: _ui_utils.SpreadMode.NONE
|
301
|
+
});
|
290
302
|
}
|
291
303
|
});
|
292
304
|
}
|
293
305
|
}, {
|
294
|
-
key:
|
306
|
+
key: "open",
|
295
307
|
value: function open() {
|
296
308
|
if (this.opened) {
|
297
309
|
return;
|
298
310
|
}
|
311
|
+
|
299
312
|
this.opened = true;
|
313
|
+
|
300
314
|
this._setMaxHeight();
|
315
|
+
|
301
316
|
this.toggleButton.classList.add('toggled');
|
302
317
|
this.toolbar.classList.remove('hidden');
|
303
318
|
}
|
304
319
|
}, {
|
305
|
-
key:
|
320
|
+
key: "close",
|
306
321
|
value: function close() {
|
307
322
|
if (!this.opened) {
|
308
323
|
return;
|
309
324
|
}
|
325
|
+
|
310
326
|
this.opened = false;
|
311
327
|
this.toolbar.classList.add('hidden');
|
312
328
|
this.toggleButton.classList.remove('toggled');
|
313
329
|
}
|
314
330
|
}, {
|
315
|
-
key:
|
331
|
+
key: "toggle",
|
316
332
|
value: function toggle() {
|
317
333
|
if (this.opened) {
|
318
334
|
this.close();
|
@@ -321,20 +337,23 @@ var SecondaryToolbar = function () {
|
|
321
337
|
}
|
322
338
|
}
|
323
339
|
}, {
|
324
|
-
key:
|
340
|
+
key: "_setMaxHeight",
|
325
341
|
value: function _setMaxHeight() {
|
326
342
|
if (!this.opened) {
|
327
343
|
return;
|
328
344
|
}
|
345
|
+
|
329
346
|
this.containerHeight = this.mainContainer.clientHeight;
|
347
|
+
|
330
348
|
if (this.containerHeight === this.previousContainerHeight) {
|
331
349
|
return;
|
332
350
|
}
|
351
|
+
|
333
352
|
this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
|
334
353
|
this.previousContainerHeight = this.containerHeight;
|
335
354
|
}
|
336
355
|
}, {
|
337
|
-
key:
|
356
|
+
key: "isOpen",
|
338
357
|
get: function get() {
|
339
358
|
return this.opened;
|
340
359
|
}
|