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.

Files changed (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3438 -1209
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
package/lib/web/app.js CHANGED
@@ -19,72 +19,82 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
27
+ exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
28
28
 
29
- var _regenerator = require('babel-runtime/regenerator');
29
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
30
 
31
- var _regenerator2 = _interopRequireDefault(_regenerator);
31
+ var _ui_utils = require("./ui_utils");
32
32
 
33
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
33
+ var _pdf = require("../pdf");
34
34
 
35
- var _ui_utils = require('./ui_utils');
35
+ var _pdf_cursor_tools = require("./pdf_cursor_tools");
36
36
 
37
- var _pdf = require('../pdf');
37
+ var _pdf_rendering_queue = require("./pdf_rendering_queue");
38
38
 
39
- var _pdf_cursor_tools = require('./pdf_cursor_tools');
39
+ var _pdf_sidebar = require("./pdf_sidebar");
40
40
 
41
- var _pdf_rendering_queue = require('./pdf_rendering_queue');
41
+ var _app_options = require("./app_options");
42
42
 
43
- var _pdf_sidebar = require('./pdf_sidebar');
43
+ var _overlay_manager = require("./overlay_manager");
44
44
 
45
- var _app_options = require('./app_options');
45
+ var _password_prompt = require("./password_prompt");
46
46
 
47
- var _dom_events = require('./dom_events');
47
+ var _pdf_attachment_viewer = require("./pdf_attachment_viewer");
48
48
 
49
- var _overlay_manager = require('./overlay_manager');
49
+ var _pdf_document_properties = require("./pdf_document_properties");
50
50
 
51
- var _password_prompt = require('./password_prompt');
51
+ var _pdf_find_bar = require("./pdf_find_bar");
52
52
 
53
- var _pdf_attachment_viewer = require('./pdf_attachment_viewer');
53
+ var _pdf_find_controller = require("./pdf_find_controller");
54
54
 
55
- var _pdf_document_properties = require('./pdf_document_properties');
55
+ var _pdf_history = require("./pdf_history");
56
56
 
57
- var _pdf_find_bar = require('./pdf_find_bar');
57
+ var _pdf_link_service = require("./pdf_link_service");
58
58
 
59
- var _pdf_find_controller = require('./pdf_find_controller');
59
+ var _pdf_outline_viewer = require("./pdf_outline_viewer");
60
60
 
61
- var _pdf_history = require('./pdf_history');
61
+ var _pdf_presentation_mode = require("./pdf_presentation_mode");
62
62
 
63
- var _pdf_link_service = require('./pdf_link_service');
63
+ var _pdf_sidebar_resizer = require("./pdf_sidebar_resizer");
64
64
 
65
- var _pdf_outline_viewer = require('./pdf_outline_viewer');
65
+ var _pdf_thumbnail_viewer = require("./pdf_thumbnail_viewer");
66
66
 
67
- var _pdf_presentation_mode = require('./pdf_presentation_mode');
67
+ var _pdf_viewer = require("./pdf_viewer");
68
68
 
69
- var _pdf_sidebar_resizer = require('./pdf_sidebar_resizer');
69
+ var _secondary_toolbar = require("./secondary_toolbar");
70
70
 
71
- var _pdf_thumbnail_viewer = require('./pdf_thumbnail_viewer');
71
+ var _toolbar = require("./toolbar");
72
72
 
73
- var _pdf_viewer = require('./pdf_viewer');
73
+ var _view_history = require("./view_history");
74
74
 
75
- var _secondary_toolbar = require('./secondary_toolbar');
75
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
76
76
 
77
- var _toolbar = require('./toolbar');
77
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
78
78
 
79
- var _view_history = require('./view_history');
79
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
80
80
 
81
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
81
+ 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; }
82
+
83
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
84
+
85
+ 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); } }
82
86
 
83
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
87
+ 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); }); }; }
84
88
 
85
89
  var DEFAULT_SCALE_DELTA = 1.1;
86
90
  var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
87
91
  var FORCE_PAGES_LOADED_TIMEOUT = 10000;
92
+ var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
93
+ var ViewOnLoad = {
94
+ UNKNOWN: -1,
95
+ PREVIOUS: 0,
96
+ INITIAL: 1
97
+ };
88
98
  var DefaultExternalServices = {
89
99
  updateFindControlState: function updateFindControlState(data) {},
90
100
  updateFindMatchesCount: function updateFindMatchesCount(data) {},
@@ -100,7 +110,6 @@ var DefaultExternalServices = {
100
110
  createL10n: function createL10n(options) {
101
111
  throw new Error('Not implemented: createL10n');
102
112
  },
103
-
104
113
  supportsIntegratedFind: false,
105
114
  supportsDocumentFonts: true,
106
115
  supportsDocumentColors: true,
@@ -109,6 +118,7 @@ var DefaultExternalServices = {
109
118
  metaKey: true
110
119
  }
111
120
  };
121
+ exports.DefaultExternalServices = DefaultExternalServices;
112
122
  var PDFViewerApplication = {
113
123
  initialBookmark: document.location.hash.substring(1),
114
124
  initialized: false,
@@ -146,11 +156,13 @@ var PDFViewerApplication = {
146
156
  _boundEvents: {},
147
157
  contentDispositionFilename: null,
148
158
  initialize: function () {
149
- var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(appConfig) {
159
+ var _initialize = _asyncToGenerator(
160
+ /*#__PURE__*/
161
+ _regenerator.default.mark(function _callee(appConfig) {
150
162
  var _this = this;
151
163
 
152
164
  var appContainer;
153
- return _regenerator2.default.wrap(function _callee$(_context) {
165
+ return _regenerator.default.wrap(function _callee$(_context) {
154
166
  while (1) {
155
167
  switch (_context.prev = _context.next) {
156
168
  case 0:
@@ -171,6 +183,7 @@ var PDFViewerApplication = {
171
183
  if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdf.LinkTarget.NONE) {
172
184
  _app_options.AppOptions.set('externalLinkTarget', _pdf.LinkTarget.TOP);
173
185
  }
186
+
174
187
  _context.next = 11;
175
188
  return this._initializeViewerComponents();
176
189
 
@@ -178,14 +191,15 @@ var PDFViewerApplication = {
178
191
  this.bindEvents();
179
192
  this.bindWindowEvents();
180
193
  appContainer = appConfig.appContainer || document.documentElement;
181
-
182
194
  this.l10n.translate(appContainer).then(function () {
183
- _this.eventBus.dispatch('localized', { source: _this });
195
+ _this.eventBus.dispatch('localized', {
196
+ source: _this
197
+ });
184
198
  });
185
199
  this.initialized = true;
186
200
 
187
201
  case 16:
188
- case 'end':
202
+ case "end":
189
203
  return _context.stop();
190
204
  }
191
205
  }
@@ -193,78 +207,66 @@ var PDFViewerApplication = {
193
207
  }));
194
208
 
195
209
  function initialize(_x) {
196
- return _ref.apply(this, arguments);
210
+ return _initialize.apply(this, arguments);
197
211
  }
198
212
 
199
213
  return initialize;
200
214
  }(),
201
215
  _readPreferences: function () {
202
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
203
- var OVERRIDES, prefs, name;
204
- return _regenerator2.default.wrap(function _callee2$(_context2) {
216
+ var _readPreferences2 = _asyncToGenerator(
217
+ /*#__PURE__*/
218
+ _regenerator.default.mark(function _callee2() {
219
+ var prefs, name;
220
+ return _regenerator.default.wrap(function _callee2$(_context2) {
205
221
  while (1) {
206
222
  switch (_context2.prev = _context2.next) {
207
223
  case 0:
208
- OVERRIDES = {
209
- disableFontFace: true,
210
- disableRange: true,
211
- disableStream: true,
212
- textLayerMode: _ui_utils.TextLayerMode.DISABLE
213
- };
214
- _context2.prev = 1;
215
- _context2.next = 4;
216
- return this.preferences.getAll();
217
-
218
- case 4:
219
- prefs = _context2.sent;
220
- _context2.t0 = _regenerator2.default.keys(prefs);
221
-
222
- case 6:
223
- if ((_context2.t1 = _context2.t0()).done) {
224
- _context2.next = 13;
224
+ if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
225
+ _context2.next = 2;
225
226
  break;
226
227
  }
227
228
 
228
- name = _context2.t1.value;
229
+ return _context2.abrupt("return");
229
230
 
230
- if (!(name in OVERRIDES && _app_options.AppOptions.get(name) === OVERRIDES[name])) {
231
- _context2.next = 10;
232
- break;
233
- }
231
+ case 2:
232
+ _context2.prev = 2;
233
+ _context2.next = 5;
234
+ return this.preferences.getAll();
234
235
 
235
- return _context2.abrupt('continue', 6);
236
+ case 5:
237
+ prefs = _context2.sent;
236
238
 
237
- case 10:
238
- _app_options.AppOptions.set(name, prefs[name]);
239
- _context2.next = 6;
240
- break;
239
+ for (name in prefs) {
240
+ _app_options.AppOptions.set(name, prefs[name]);
241
+ }
241
242
 
242
- case 13:
243
- _context2.next = 17;
243
+ _context2.next = 11;
244
244
  break;
245
245
 
246
- case 15:
247
- _context2.prev = 15;
248
- _context2.t2 = _context2['catch'](1);
246
+ case 9:
247
+ _context2.prev = 9;
248
+ _context2.t0 = _context2["catch"](2);
249
249
 
250
- case 17:
251
- case 'end':
250
+ case 11:
251
+ case "end":
252
252
  return _context2.stop();
253
253
  }
254
254
  }
255
- }, _callee2, this, [[1, 15]]);
255
+ }, _callee2, this, [[2, 9]]);
256
256
  }));
257
257
 
258
258
  function _readPreferences() {
259
- return _ref2.apply(this, arguments);
259
+ return _readPreferences2.apply(this, arguments);
260
260
  }
261
261
 
262
262
  return _readPreferences;
263
263
  }(),
264
264
  _parseHashParameters: function () {
265
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
265
+ var _parseHashParameters2 = _asyncToGenerator(
266
+ /*#__PURE__*/
267
+ _regenerator.default.mark(function _callee3() {
266
268
  var waitOn, hash, hashParams, viewer, enabled;
267
- return _regenerator2.default.wrap(function _callee3$(_context3) {
269
+ return _regenerator.default.wrap(function _callee3$(_context3) {
268
270
  while (1) {
269
271
  switch (_context3.prev = _context3.next) {
270
272
  case 0:
@@ -273,7 +275,7 @@ var PDFViewerApplication = {
273
275
  break;
274
276
  }
275
277
 
276
- return _context3.abrupt('return');
278
+ return _context3.abrupt("return");
277
279
 
278
280
  case 2:
279
281
  waitOn = [];
@@ -283,27 +285,35 @@ var PDFViewerApplication = {
283
285
  if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
284
286
  waitOn.push(loadFakeWorker());
285
287
  }
288
+
286
289
  if ('disablerange' in hashParams) {
287
290
  _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
288
291
  }
292
+
289
293
  if ('disablestream' in hashParams) {
290
294
  _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
291
295
  }
296
+
292
297
  if ('disableautofetch' in hashParams) {
293
298
  _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
294
299
  }
300
+
295
301
  if ('disablefontface' in hashParams) {
296
302
  _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
297
303
  }
304
+
298
305
  if ('disablehistory' in hashParams) {
299
306
  _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
300
307
  }
308
+
301
309
  if ('webgl' in hashParams) {
302
310
  _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
303
311
  }
312
+
304
313
  if ('useonlycsszoom' in hashParams) {
305
314
  _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
306
315
  }
316
+
307
317
  if ('verbosity' in hashParams) {
308
318
  _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
309
319
  }
@@ -319,30 +329,32 @@ var PDFViewerApplication = {
319
329
 
320
330
  case 18:
321
331
  _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
322
- return _context3.abrupt('break', 23);
332
+
333
+ return _context3.abrupt("break", 23);
323
334
 
324
335
  case 20:
325
336
  viewer = this.appConfig.viewerContainer;
326
-
327
337
  viewer.classList.add('textLayer-' + hashParams['textlayer']);
328
- return _context3.abrupt('break', 23);
338
+ return _context3.abrupt("break", 23);
329
339
 
330
340
  case 23:
331
341
  if ('pdfbug' in hashParams) {
332
342
  _app_options.AppOptions.set('pdfBug', true);
333
- enabled = hashParams['pdfbug'].split(',');
334
343
 
344
+ enabled = hashParams['pdfbug'].split(',');
335
345
  waitOn.push(loadAndEnablePDFBug(enabled));
336
346
  }
347
+
337
348
  if ('locale' in hashParams) {
338
349
  _app_options.AppOptions.set('locale', hashParams['locale']);
339
350
  }
340
- return _context3.abrupt('return', Promise.all(waitOn).catch(function (reason) {
341
- console.error('_parseHashParameters: "' + reason.message + '".');
351
+
352
+ return _context3.abrupt("return", Promise.all(waitOn).catch(function (reason) {
353
+ console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
342
354
  }));
343
355
 
344
356
  case 26:
345
- case 'end':
357
+ case "end":
346
358
  return _context3.stop();
347
359
  }
348
360
  }
@@ -350,29 +362,32 @@ var PDFViewerApplication = {
350
362
  }));
351
363
 
352
364
  function _parseHashParameters() {
353
- return _ref3.apply(this, arguments);
365
+ return _parseHashParameters2.apply(this, arguments);
354
366
  }
355
367
 
356
368
  return _parseHashParameters;
357
369
  }(),
358
370
  _initializeL10n: function () {
359
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
371
+ var _initializeL10n2 = _asyncToGenerator(
372
+ /*#__PURE__*/
373
+ _regenerator.default.mark(function _callee4() {
360
374
  var dir;
361
- return _regenerator2.default.wrap(function _callee4$(_context4) {
375
+ return _regenerator.default.wrap(function _callee4$(_context4) {
362
376
  while (1) {
363
377
  switch (_context4.prev = _context4.next) {
364
378
  case 0:
365
- this.l10n = this.externalServices.createL10n({ locale: _app_options.AppOptions.get('locale') });
379
+ this.l10n = this.externalServices.createL10n({
380
+ locale: _app_options.AppOptions.get('locale')
381
+ });
366
382
  _context4.next = 3;
367
383
  return this.l10n.getDirection();
368
384
 
369
385
  case 3:
370
386
  dir = _context4.sent;
371
-
372
387
  document.getElementsByTagName('html')[0].dir = dir;
373
388
 
374
389
  case 5:
375
- case 'end':
390
+ case "end":
376
391
  return _context4.stop();
377
392
  }
378
393
  }
@@ -380,27 +395,26 @@ var PDFViewerApplication = {
380
395
  }));
381
396
 
382
397
  function _initializeL10n() {
383
- return _ref4.apply(this, arguments);
398
+ return _initializeL10n2.apply(this, arguments);
384
399
  }
385
400
 
386
401
  return _initializeL10n;
387
402
  }(),
388
403
  _initializeViewerComponents: function () {
389
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
404
+ var _initializeViewerComponents2 = _asyncToGenerator(
405
+ /*#__PURE__*/
406
+ _regenerator.default.mark(function _callee5() {
390
407
  var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig;
391
- return _regenerator2.default.wrap(function _callee5$(_context5) {
408
+ return _regenerator.default.wrap(function _callee5$(_context5) {
392
409
  while (1) {
393
410
  switch (_context5.prev = _context5.next) {
394
411
  case 0:
395
412
  appConfig = this.appConfig;
396
-
397
413
  this.overlayManager = new _overlay_manager.OverlayManager();
398
414
  dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
399
- eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM);
400
-
415
+ eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(dispatchToDOM);
401
416
  this.eventBus = eventBus;
402
417
  pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
403
-
404
418
  pdfRenderingQueue.onIdle = this.cleanup.bind(this);
405
419
  this.pdfRenderingQueue = pdfRenderingQueue;
406
420
  pdfLinkService = new _pdf_link_service.PDFLinkService({
@@ -408,20 +422,18 @@ var PDFViewerApplication = {
408
422
  externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
409
423
  externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
410
424
  });
411
-
412
425
  this.pdfLinkService = pdfLinkService;
413
- downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') });
414
-
426
+ downloadManager = this.externalServices.createDownloadManager({
427
+ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
428
+ });
415
429
  this.downloadManager = downloadManager;
416
430
  findController = new _pdf_find_controller.PDFFindController({
417
431
  linkService: pdfLinkService,
418
432
  eventBus: eventBus
419
433
  });
420
-
421
434
  this.findController = findController;
422
435
  container = appConfig.mainContainer;
423
436
  viewer = appConfig.viewerContainer;
424
-
425
437
  this.pdfViewer = new _pdf_viewer.PDFViewer({
426
438
  container: container,
427
439
  viewer: viewer,
@@ -443,7 +455,6 @@ var PDFViewerApplication = {
443
455
  pdfRenderingQueue.setViewer(this.pdfViewer);
444
456
  pdfLinkService.setViewer(this.pdfViewer);
445
457
  thumbnailContainer = appConfig.sidebar.thumbnailView;
446
-
447
458
  this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
448
459
  container: thumbnailContainer,
449
460
  renderingQueue: pdfRenderingQueue,
@@ -465,6 +476,7 @@ var PDFViewerApplication = {
465
476
  });
466
477
  this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
467
478
  this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
479
+
468
480
  if (this.supportsFullscreen) {
469
481
  this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
470
482
  container: container,
@@ -474,6 +486,7 @@ var PDFViewerApplication = {
474
486
  contextMenuItems: appConfig.fullscreen
475
487
  });
476
488
  }
489
+
477
490
  this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
478
491
  this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
479
492
  container: appConfig.sidebar.outlineView,
@@ -486,7 +499,6 @@ var PDFViewerApplication = {
486
499
  downloadManager: downloadManager
487
500
  });
488
501
  sidebarConfig = Object.create(appConfig.sidebar);
489
-
490
502
  sidebarConfig.pdfViewer = this.pdfViewer;
491
503
  sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
492
504
  this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n);
@@ -494,7 +506,7 @@ var PDFViewerApplication = {
494
506
  this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
495
507
 
496
508
  case 39:
497
- case 'end':
509
+ case "end":
498
510
  return _context5.stop();
499
511
  }
500
512
  }
@@ -502,7 +514,7 @@ var PDFViewerApplication = {
502
514
  }));
503
515
 
504
516
  function _initializeViewerComponents() {
505
- return _ref5.apply(this, arguments);
517
+ return _initializeViewerComponents2.apply(this, arguments);
506
518
  }
507
519
 
508
520
  return _initializeViewerComponents;
@@ -512,72 +524,89 @@ var PDFViewerApplication = {
512
524
  },
513
525
  zoomIn: function zoomIn(ticks) {
514
526
  var newScale = this.pdfViewer.currentScale;
527
+
515
528
  do {
516
529
  newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
517
530
  newScale = Math.ceil(newScale * 10) / 10;
518
531
  newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
519
532
  } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
533
+
520
534
  this.pdfViewer.currentScaleValue = newScale;
521
535
  },
522
536
  zoomOut: function zoomOut(ticks) {
523
537
  var newScale = this.pdfViewer.currentScale;
538
+
524
539
  do {
525
540
  newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
526
541
  newScale = Math.floor(newScale * 10) / 10;
527
542
  newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
528
543
  } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
544
+
529
545
  this.pdfViewer.currentScaleValue = newScale;
530
546
  },
531
547
 
532
548
  get pagesCount() {
533
549
  return this.pdfDocument ? this.pdfDocument.numPages : 0;
534
550
  },
551
+
535
552
  set page(val) {
536
553
  this.pdfViewer.currentPageNumber = val;
537
554
  },
555
+
538
556
  get page() {
539
557
  return this.pdfViewer.currentPageNumber;
540
558
  },
559
+
541
560
  get printing() {
542
561
  return !!this.printService;
543
562
  },
563
+
544
564
  get supportsPrinting() {
545
565
  return PDFPrintServiceFactory.instance.supportsPrinting;
546
566
  },
567
+
547
568
  get supportsFullscreen() {
548
- var support = void 0;
569
+ var support;
549
570
  var doc = document.documentElement;
550
571
  support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
572
+
551
573
  if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
552
574
  support = false;
553
575
  }
576
+
554
577
  return (0, _pdf.shadow)(this, 'supportsFullscreen', support);
555
578
  },
579
+
556
580
  get supportsIntegratedFind() {
557
581
  return this.externalServices.supportsIntegratedFind;
558
582
  },
583
+
559
584
  get supportsDocumentFonts() {
560
585
  return this.externalServices.supportsDocumentFonts;
561
586
  },
587
+
562
588
  get supportsDocumentColors() {
563
589
  return this.externalServices.supportsDocumentColors;
564
590
  },
591
+
565
592
  get loadingBar() {
566
593
  var bar = new _ui_utils.ProgressBar('#loadingBar');
567
594
  return (0, _pdf.shadow)(this, 'loadingBar', bar);
568
595
  },
596
+
569
597
  get supportedMouseWheelZoomModifierKeys() {
570
598
  return this.externalServices.supportedMouseWheelZoomModifierKeys;
571
599
  },
600
+
572
601
  initPassiveLoading: function initPassiveLoading() {
573
602
  throw new Error('Not implemented: initPassiveLoading');
574
603
  },
575
604
  setTitleUsingUrl: function setTitleUsingUrl() {
576
605
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
577
-
578
606
  this.url = url;
579
607
  this.baseUrl = url.split('#')[0];
580
608
  var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
609
+
581
610
  if (!title) {
582
611
  try {
583
612
  title = decodeURIComponent((0, _pdf.getFilenameFromUrl)(url)) || url;
@@ -585,23 +614,26 @@ var PDFViewerApplication = {
585
614
  title = url;
586
615
  }
587
616
  }
617
+
588
618
  this.setTitle(title);
589
619
  },
590
620
  setTitle: function setTitle(title) {
591
621
  if (this.isViewerEmbedded) {
592
622
  return;
593
623
  }
624
+
594
625
  document.title = title;
595
626
  },
596
627
  close: function () {
597
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
628
+ var _close = _asyncToGenerator(
629
+ /*#__PURE__*/
630
+ _regenerator.default.mark(function _callee6() {
598
631
  var errorWrapper, promise;
599
- return _regenerator2.default.wrap(function _callee6$(_context6) {
632
+ return _regenerator.default.wrap(function _callee6$(_context6) {
600
633
  while (1) {
601
634
  switch (_context6.prev = _context6.next) {
602
635
  case 0:
603
636
  errorWrapper = this.appConfig.errorWrapper.container;
604
-
605
637
  errorWrapper.setAttribute('hidden', 'true');
606
638
 
607
639
  if (this.pdfLoadingTask) {
@@ -609,12 +641,12 @@ var PDFViewerApplication = {
609
641
  break;
610
642
  }
611
643
 
612
- return _context6.abrupt('return');
644
+ return _context6.abrupt("return");
613
645
 
614
646
  case 4:
615
647
  promise = this.pdfLoadingTask.destroy();
616
-
617
648
  this.pdfLoadingTask = null;
649
+
618
650
  if (this.pdfDocument) {
619
651
  this.pdfDocument = null;
620
652
  this.pdfThumbnailViewer.setDocument(null);
@@ -622,6 +654,7 @@ var PDFViewerApplication = {
622
654
  this.pdfLinkService.setDocument(null);
623
655
  this.pdfDocumentProperties.setDocument(null);
624
656
  }
657
+
625
658
  this.store = null;
626
659
  this.isInitialViewSet = false;
627
660
  this.downloadComplete = false;
@@ -634,13 +667,15 @@ var PDFViewerApplication = {
634
667
  this.findBar.reset();
635
668
  this.toolbar.reset();
636
669
  this.secondaryToolbar.reset();
670
+
637
671
  if (typeof PDFBug !== 'undefined') {
638
672
  PDFBug.cleanup();
639
673
  }
640
- return _context6.abrupt('return', promise);
674
+
675
+ return _context6.abrupt("return", promise);
641
676
 
642
677
  case 21:
643
- case 'end':
678
+ case "end":
644
679
  return _context6.stop();
645
680
  }
646
681
  }
@@ -648,18 +683,20 @@ var PDFViewerApplication = {
648
683
  }));
649
684
 
650
685
  function close() {
651
- return _ref6.apply(this, arguments);
686
+ return _close.apply(this, arguments);
652
687
  }
653
688
 
654
689
  return close;
655
690
  }(),
656
691
  open: function () {
657
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee7(file, args) {
692
+ var _open = _asyncToGenerator(
693
+ /*#__PURE__*/
694
+ _regenerator.default.mark(function _callee7(file, args) {
658
695
  var _this2 = this;
659
696
 
660
697
  var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
661
698
 
662
- return _regenerator2.default.wrap(function _callee7$(_context7) {
699
+ return _regenerator.default.wrap(function _callee7$(_context7) {
663
700
  while (1) {
664
701
  switch (_context7.prev = _context7.next) {
665
702
  case 0:
@@ -677,6 +714,7 @@ var PDFViewerApplication = {
677
714
  for (key in workerParameters) {
678
715
  _pdf.GlobalWorkerOptions[key] = workerParameters[key];
679
716
  }
717
+
680
718
  parameters = Object.create(null);
681
719
 
682
720
  if (typeof file === 'string') {
@@ -688,41 +726,50 @@ var PDFViewerApplication = {
688
726
  this.setTitleUsingUrl(file.originalUrl);
689
727
  parameters.url = file.url;
690
728
  }
729
+
691
730
  apiParameters = _app_options.AppOptions.getAll('api');
692
731
 
693
732
  for (_key in apiParameters) {
694
733
  parameters[_key] = apiParameters[_key];
695
734
  }
735
+
696
736
  if (args) {
697
737
  for (prop in args) {
698
738
  if (prop === 'length') {
699
739
  this.pdfDocumentProperties.setFileSize(args[prop]);
700
740
  }
741
+
701
742
  parameters[prop] = args[prop];
702
743
  }
703
744
  }
704
- loadingTask = (0, _pdf.getDocument)(parameters);
705
745
 
746
+ loadingTask = (0, _pdf.getDocument)(parameters);
706
747
  this.pdfLoadingTask = loadingTask;
748
+
707
749
  loadingTask.onPassword = function (updateCallback, reason) {
708
750
  _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
751
+
709
752
  _this2.passwordPrompt.open();
710
753
  };
711
- loadingTask.onProgress = function (_ref8) {
712
- var loaded = _ref8.loaded,
713
- total = _ref8.total;
754
+
755
+ loadingTask.onProgress = function (_ref) {
756
+ var loaded = _ref.loaded,
757
+ total = _ref.total;
714
758
 
715
759
  _this2.progress(loaded / total);
716
760
  };
761
+
717
762
  loadingTask.onUnsupportedFeature = this.fallback.bind(this);
718
- return _context7.abrupt('return', loadingTask.promise.then(function (pdfDocument) {
763
+ return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
719
764
  _this2.load(pdfDocument);
720
765
  }, function (exception) {
721
766
  if (loadingTask !== _this2.pdfLoadingTask) {
722
767
  return;
723
768
  }
769
+
724
770
  var message = exception && exception.message;
725
- var loadingErrorMessage = void 0;
771
+ var loadingErrorMessage;
772
+
726
773
  if (exception instanceof _pdf.InvalidPDFException) {
727
774
  loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
728
775
  } else if (exception instanceof _pdf.MissingPDFException) {
@@ -732,22 +779,26 @@ var PDFViewerApplication = {
732
779
  } else {
733
780
  loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
734
781
  }
782
+
735
783
  return loadingErrorMessage.then(function (msg) {
736
- _this2.error(msg, { message: message });
784
+ _this2.error(msg, {
785
+ message: message
786
+ });
787
+
737
788
  throw new Error(msg);
738
789
  });
739
790
  }));
740
791
 
741
792
  case 16:
742
- case 'end':
793
+ case "end":
743
794
  return _context7.stop();
744
795
  }
745
796
  }
746
797
  }, _callee7, this);
747
798
  }));
748
799
 
749
- function open(_x3, _x4) {
750
- return _ref7.apply(this, arguments);
800
+ function open(_x2, _x3) {
801
+ return _open.apply(this, arguments);
751
802
  }
752
803
 
753
804
  return open;
@@ -758,18 +809,24 @@ var PDFViewerApplication = {
758
809
  function downloadByUrl() {
759
810
  downloadManager.downloadUrl(url, filename);
760
811
  }
812
+
761
813
  var url = this.baseUrl;
762
814
  var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
763
815
  var downloadManager = this.downloadManager;
816
+
764
817
  downloadManager.onerror = function (err) {
765
- _this3.error('PDF failed to download: ' + err);
818
+ _this3.error("PDF failed to download: ".concat(err));
766
819
  };
820
+
767
821
  if (!this.pdfDocument || !this.downloadComplete) {
768
822
  downloadByUrl();
769
823
  return;
770
824
  }
825
+
771
826
  this.pdfDocument.getData().then(function (data) {
772
- var blob = new Blob([data], { type: 'application/pdf' });
827
+ var blob = new Blob([data], {
828
+ type: 'application/pdf'
829
+ });
773
830
  downloadManager.download(blob, url, filename);
774
831
  }).catch(downloadByUrl);
775
832
  },
@@ -779,42 +836,59 @@ var PDFViewerApplication = {
779
836
  version: _pdf.version || '?',
780
837
  build: _pdf.build || '?'
781
838
  }, 'PDF.js v{{version}} (build: {{build}})')];
839
+
782
840
  if (moreInfo) {
783
- moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}'));
841
+ moreInfoText.push(this.l10n.get('error_message', {
842
+ message: moreInfo.message
843
+ }, 'Message: {{message}}'));
844
+
784
845
  if (moreInfo.stack) {
785
- moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}'));
846
+ moreInfoText.push(this.l10n.get('error_stack', {
847
+ stack: moreInfo.stack
848
+ }, 'Stack: {{stack}}'));
786
849
  } else {
787
850
  if (moreInfo.filename) {
788
- moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}'));
851
+ moreInfoText.push(this.l10n.get('error_file', {
852
+ file: moreInfo.filename
853
+ }, 'File: {{file}}'));
789
854
  }
855
+
790
856
  if (moreInfo.lineNumber) {
791
- moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}'));
857
+ moreInfoText.push(this.l10n.get('error_line', {
858
+ line: moreInfo.lineNumber
859
+ }, 'Line: {{line}}'));
792
860
  }
793
861
  }
794
862
  }
863
+
795
864
  var errorWrapperConfig = this.appConfig.errorWrapper;
796
865
  var errorWrapper = errorWrapperConfig.container;
797
866
  errorWrapper.removeAttribute('hidden');
798
867
  var errorMessage = errorWrapperConfig.errorMessage;
799
868
  errorMessage.textContent = message;
800
869
  var closeButton = errorWrapperConfig.closeButton;
870
+
801
871
  closeButton.onclick = function () {
802
872
  errorWrapper.setAttribute('hidden', 'true');
803
873
  };
874
+
804
875
  var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
805
876
  var moreInfoButton = errorWrapperConfig.moreInfoButton;
806
877
  var lessInfoButton = errorWrapperConfig.lessInfoButton;
878
+
807
879
  moreInfoButton.onclick = function () {
808
880
  errorMoreInfo.removeAttribute('hidden');
809
881
  moreInfoButton.setAttribute('hidden', 'true');
810
882
  lessInfoButton.removeAttribute('hidden');
811
883
  errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
812
884
  };
885
+
813
886
  lessInfoButton.onclick = function () {
814
887
  errorMoreInfo.setAttribute('hidden', 'true');
815
888
  moreInfoButton.removeAttribute('hidden');
816
889
  lessInfoButton.setAttribute('hidden', 'true');
817
890
  };
891
+
818
892
  moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
819
893
  lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
820
894
  closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
@@ -830,18 +904,23 @@ var PDFViewerApplication = {
830
904
  if (this.downloadComplete) {
831
905
  return;
832
906
  }
907
+
833
908
  var percent = Math.round(level * 100);
909
+
834
910
  if (percent > this.loadingBar.percent || isNaN(percent)) {
835
911
  this.loadingBar.percent = percent;
836
912
  var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
913
+
837
914
  if (disableAutoFetch && percent) {
838
915
  if (this.disableAutoFetchLoadingBarTimeout) {
839
916
  clearTimeout(this.disableAutoFetchLoadingBarTimeout);
840
917
  this.disableAutoFetchLoadingBarTimeout = null;
841
918
  }
919
+
842
920
  this.loadingBar.show();
843
921
  this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
844
922
  _this4.loadingBar.hide();
923
+
845
924
  _this4.disableAutoFetchLoadingBarTimeout = null;
846
925
  }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
847
926
  }
@@ -853,17 +932,21 @@ var PDFViewerApplication = {
853
932
  this.pdfDocument = pdfDocument;
854
933
  pdfDocument.getDownloadInfo().then(function () {
855
934
  _this5.downloadComplete = true;
935
+
856
936
  _this5.loadingBar.hide();
937
+
857
938
  firstPagePromise.then(function () {
858
- _this5.eventBus.dispatch('documentloaded', { source: _this5 });
859
- _this5.eventBus.dispatch('documentload', { source: _this5 });
939
+ _this5.eventBus.dispatch('documentloaded', {
940
+ source: _this5
941
+ });
860
942
  });
861
943
  });
862
944
  var pageModePromise = pdfDocument.getPageMode().catch(function () {});
945
+ var openActionDestPromise = pdfDocument.getOpenActionDestination().catch(function () {});
863
946
  this.toolbar.setPagesCount(pdfDocument.numPages, false);
864
947
  this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
865
948
  var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
866
- var baseDocumentUrl = void 0;
949
+ var baseDocumentUrl;
867
950
  baseDocumentUrl = null;
868
951
  this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
869
952
  this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
@@ -876,102 +959,123 @@ var PDFViewerApplication = {
876
959
  pdfThumbnailViewer.setDocument(pdfDocument);
877
960
  firstPagePromise.then(function (pdfPage) {
878
961
  _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
879
- if (!_app_options.AppOptions.get('disableHistory') && !_this5.isViewerEmbedded) {
880
- var resetHistory = !_app_options.AppOptions.get('showPreviousViewOnLoad');
881
- _this5.pdfHistory.initialize(pdfDocument.fingerprint, resetHistory);
882
- if (_this5.pdfHistory.initialBookmark) {
883
- _this5.initialBookmark = _this5.pdfHistory.initialBookmark;
884
- _this5.initialRotation = _this5.pdfHistory.initialRotation;
885
- }
886
- }
962
+
887
963
  var storePromise = store.getMultiple({
888
964
  page: null,
889
965
  zoom: _ui_utils.DEFAULT_SCALE_VALUE,
890
966
  scrollLeft: '0',
891
967
  scrollTop: '0',
892
968
  rotation: null,
893
- sidebarView: _pdf_sidebar.SidebarView.NONE,
894
- scrollMode: null,
895
- spreadMode: null
969
+ sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
970
+ scrollMode: _ui_utils.ScrollMode.UNKNOWN,
971
+ spreadMode: _ui_utils.SpreadMode.UNKNOWN
896
972
  }).catch(function () {});
897
- Promise.all([storePromise, pageModePromise]).then(function () {
898
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee8(_ref9) {
899
- var _ref11 = _slicedToArray(_ref9, 2),
900
- _ref11$ = _ref11[0],
901
- values = _ref11$ === undefined ? {} : _ref11$,
902
- pageMode = _ref11[1];
903
-
904
- var initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
905
- return _regenerator2.default.wrap(function _callee8$(_context8) {
973
+ Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(
974
+ /*#__PURE__*/
975
+ function () {
976
+ var _ref3 = _asyncToGenerator(
977
+ /*#__PURE__*/
978
+ _regenerator.default.mark(function _callee8(_ref2) {
979
+ var _ref4, _ref4$, values, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
980
+
981
+ return _regenerator.default.wrap(function _callee8$(_context8) {
906
982
  while (1) {
907
983
  switch (_context8.prev = _context8.next) {
908
984
  case 0:
985
+ _ref4 = _slicedToArray(_ref2, 3), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageMode = _ref4[1], openActionDest = _ref4[2];
986
+ viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
987
+
988
+ _this5._initializePdfHistory({
989
+ fingerprint: pdfDocument.fingerprint,
990
+ viewOnLoad: viewOnLoad,
991
+ initialDest: openActionDest
992
+ });
993
+
909
994
  initialBookmark = _this5.initialBookmark;
910
995
  zoom = _app_options.AppOptions.get('defaultZoomValue');
911
- hash = zoom ? 'zoom=' + zoom : null;
996
+ hash = zoom ? "zoom=".concat(zoom) : null;
912
997
  rotation = null;
913
998
  sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
914
999
  scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
915
1000
  spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
916
1001
 
917
- if (values.page && _app_options.AppOptions.get('showPreviousViewOnLoad')) {
918
- hash = 'page=' + values.page + '&zoom=' + (zoom || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
1002
+ if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
1003
+ hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
919
1004
  rotation = parseInt(values.rotation, 10);
920
- sidebarView = sidebarView || values.sidebarView | 0;
921
- scrollMode = scrollMode || values.scrollMode | 0;
922
- spreadMode = spreadMode || values.spreadMode | 0;
1005
+
1006
+ if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
1007
+ sidebarView = values.sidebarView | 0;
1008
+ }
1009
+
1010
+ if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
1011
+ scrollMode = values.scrollMode | 0;
1012
+ }
1013
+
1014
+ if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
1015
+ spreadMode = values.spreadMode | 0;
1016
+ }
923
1017
  }
924
- if (pageMode && !_app_options.AppOptions.get('disablePageMode')) {
925
- sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
1018
+
1019
+ if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
1020
+ sidebarView = apiPageModeToSidebarView(pageMode);
926
1021
  }
1022
+
927
1023
  _this5.setInitialView(hash, {
928
1024
  rotation: rotation,
929
1025
  sidebarView: sidebarView,
930
1026
  scrollMode: scrollMode,
931
1027
  spreadMode: spreadMode
932
1028
  });
933
- _this5.eventBus.dispatch('documentinit', { source: _this5 });
1029
+
1030
+ _this5.eventBus.dispatch('documentinit', {
1031
+ source: _this5
1032
+ });
1033
+
934
1034
  if (!_this5.isViewerEmbedded) {
935
1035
  pdfViewer.focus();
936
1036
  }
937
- _context8.next = 14;
1037
+
1038
+ _context8.next = 17;
938
1039
  return Promise.race([pagesPromise, new Promise(function (resolve) {
939
1040
  setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
940
1041
  })]);
941
1042
 
942
- case 14:
1043
+ case 17:
943
1044
  if (!(!initialBookmark && !hash)) {
944
- _context8.next = 16;
1045
+ _context8.next = 19;
945
1046
  break;
946
1047
  }
947
1048
 
948
- return _context8.abrupt('return');
1049
+ return _context8.abrupt("return");
949
1050
 
950
- case 16:
1051
+ case 19:
951
1052
  if (!pdfViewer.hasEqualPageSizes) {
952
- _context8.next = 18;
1053
+ _context8.next = 21;
953
1054
  break;
954
1055
  }
955
1056
 
956
- return _context8.abrupt('return');
1057
+ return _context8.abrupt("return");
957
1058
 
958
- case 18:
1059
+ case 21:
959
1060
  _this5.initialBookmark = initialBookmark;
960
1061
  pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
1062
+
961
1063
  _this5.setInitialView(hash);
962
1064
 
963
- case 21:
964
- case 'end':
1065
+ case 24:
1066
+ case "end":
965
1067
  return _context8.stop();
966
1068
  }
967
1069
  }
968
- }, _callee8, _this5);
1070
+ }, _callee8, this);
969
1071
  }));
970
1072
 
971
- return function (_x5) {
972
- return _ref10.apply(this, arguments);
1073
+ return function (_x4) {
1074
+ return _ref3.apply(this, arguments);
973
1075
  };
974
- }()).then(function () {
1076
+ }()).catch(function () {
1077
+ _this5.setInitialView();
1078
+ }).then(function () {
975
1079
  pdfViewer.update();
976
1080
  });
977
1081
  });
@@ -979,42 +1083,56 @@ var PDFViewerApplication = {
979
1083
  if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
980
1084
  return;
981
1085
  }
1086
+
982
1087
  var i = 0,
983
1088
  numLabels = labels.length;
1089
+
984
1090
  if (numLabels !== _this5.pagesCount) {
985
1091
  console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
986
1092
  return;
987
1093
  }
1094
+
988
1095
  while (i < numLabels && labels[i] === (i + 1).toString()) {
989
1096
  i++;
990
1097
  }
1098
+
991
1099
  if (i === numLabels) {
992
1100
  return;
993
1101
  }
1102
+
994
1103
  pdfViewer.setPageLabels(labels);
995
1104
  pdfThumbnailViewer.setPageLabels(labels);
1105
+
996
1106
  _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
1107
+
997
1108
  _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
998
1109
  });
999
1110
  pagesPromise.then(function () {
1000
1111
  if (!_this5.supportsPrinting) {
1001
1112
  return;
1002
1113
  }
1114
+
1003
1115
  pdfDocument.getJavaScript().then(function (javaScript) {
1004
1116
  if (!javaScript) {
1005
1117
  return;
1006
1118
  }
1119
+
1007
1120
  javaScript.some(function (js) {
1008
1121
  if (!js) {
1009
1122
  return false;
1010
1123
  }
1124
+
1011
1125
  console.warn('Warning: JavaScript is not supported');
1126
+
1012
1127
  _this5.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript);
1128
+
1013
1129
  return true;
1014
1130
  });
1015
1131
  var regex = /\bprint\s*\(/;
1132
+
1016
1133
  for (var i = 0, ii = javaScript.length; i < ii; i++) {
1017
1134
  var js = javaScript[i];
1135
+
1018
1136
  if (js && regex.test(js)) {
1019
1137
  setTimeout(function () {
1020
1138
  window.print();
@@ -1026,67 +1144,109 @@ var PDFViewerApplication = {
1026
1144
  });
1027
1145
  Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
1028
1146
  pdfDocument.getOutline().then(function (outline) {
1029
- _this5.pdfOutlineViewer.render({ outline: outline });
1147
+ _this5.pdfOutlineViewer.render({
1148
+ outline: outline
1149
+ });
1030
1150
  });
1031
1151
  pdfDocument.getAttachments().then(function (attachments) {
1032
- _this5.pdfAttachmentViewer.render({ attachments: attachments });
1152
+ _this5.pdfAttachmentViewer.render({
1153
+ attachments: attachments
1154
+ });
1033
1155
  });
1034
1156
  });
1035
- pdfDocument.getMetadata().then(function (_ref12) {
1036
- var info = _ref12.info,
1037
- metadata = _ref12.metadata,
1038
- contentDispositionFilename = _ref12.contentDispositionFilename;
1039
-
1157
+ pdfDocument.getMetadata().then(function (_ref5) {
1158
+ var info = _ref5.info,
1159
+ metadata = _ref5.metadata,
1160
+ contentDispositionFilename = _ref5.contentDispositionFilename;
1040
1161
  _this5.documentInfo = info;
1041
1162
  _this5.metadata = metadata;
1042
1163
  _this5.contentDispositionFilename = contentDispositionFilename;
1043
1164
  console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdf.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
1044
- var pdfTitle = void 0;
1165
+ var pdfTitle;
1166
+
1045
1167
  if (metadata && metadata.has('dc:title')) {
1046
1168
  var title = metadata.get('dc:title');
1169
+
1047
1170
  if (title !== 'Untitled') {
1048
1171
  pdfTitle = title;
1049
1172
  }
1050
1173
  }
1174
+
1051
1175
  if (!pdfTitle && info && info['Title']) {
1052
1176
  pdfTitle = info['Title'];
1053
1177
  }
1178
+
1054
1179
  if (pdfTitle) {
1055
- _this5.setTitle(pdfTitle + ' - ' + (contentDispositionFilename || document.title));
1180
+ _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
1056
1181
  } else if (contentDispositionFilename) {
1057
1182
  _this5.setTitle(contentDispositionFilename);
1058
1183
  }
1184
+
1059
1185
  if (info.IsAcroFormPresent) {
1060
1186
  console.warn('Warning: AcroForm/XFA is not supported');
1187
+
1061
1188
  _this5.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
1062
1189
  }
1063
1190
  });
1064
1191
  },
1192
+ _initializePdfHistory: function _initializePdfHistory(_ref6) {
1193
+ var fingerprint = _ref6.fingerprint,
1194
+ viewOnLoad = _ref6.viewOnLoad,
1195
+ _ref6$initialDest = _ref6.initialDest,
1196
+ initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
1197
+
1198
+ if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
1199
+ return;
1200
+ }
1201
+
1202
+ this.pdfHistory.initialize({
1203
+ fingerprint: fingerprint,
1204
+ resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
1205
+ updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
1206
+ });
1207
+
1208
+ if (this.pdfHistory.initialBookmark) {
1209
+ this.initialBookmark = this.pdfHistory.initialBookmark;
1210
+ this.initialRotation = this.pdfHistory.initialRotation;
1211
+ }
1212
+
1213
+ if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
1214
+ this.initialBookmark = JSON.stringify(initialDest);
1215
+ this.pdfHistory.push({
1216
+ explicitDest: initialDest,
1217
+ pageNumber: null
1218
+ });
1219
+ }
1220
+ },
1065
1221
  setInitialView: function setInitialView(storedHash) {
1066
1222
  var _this6 = this;
1067
1223
 
1068
- var _ref13 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1069
- rotation = _ref13.rotation,
1070
- sidebarView = _ref13.sidebarView,
1071
- scrollMode = _ref13.scrollMode,
1072
- spreadMode = _ref13.spreadMode;
1224
+ var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1225
+ rotation = _ref7.rotation,
1226
+ sidebarView = _ref7.sidebarView,
1227
+ scrollMode = _ref7.scrollMode,
1228
+ spreadMode = _ref7.spreadMode;
1073
1229
 
1074
1230
  var setRotation = function setRotation(angle) {
1075
1231
  if ((0, _ui_utils.isValidRotation)(angle)) {
1076
1232
  _this6.pdfViewer.pagesRotation = angle;
1077
1233
  }
1078
1234
  };
1235
+
1079
1236
  var setViewerModes = function setViewerModes(scroll, spread) {
1080
- if (Number.isInteger(scroll)) {
1237
+ if ((0, _ui_utils.isValidScrollMode)(scroll)) {
1081
1238
  _this6.pdfViewer.scrollMode = scroll;
1082
1239
  }
1083
- if (Number.isInteger(spread)) {
1240
+
1241
+ if ((0, _ui_utils.isValidSpreadMode)(spread)) {
1084
1242
  _this6.pdfViewer.spreadMode = spread;
1085
1243
  }
1086
1244
  };
1087
- setViewerModes(scrollMode, spreadMode);
1245
+
1088
1246
  this.isInitialViewSet = true;
1089
1247
  this.pdfSidebar.setInitialView(sidebarView);
1248
+ setViewerModes(scrollMode, spreadMode);
1249
+
1090
1250
  if (this.initialBookmark) {
1091
1251
  setRotation(this.initialRotation);
1092
1252
  delete this.initialRotation;
@@ -1096,8 +1256,10 @@ var PDFViewerApplication = {
1096
1256
  setRotation(rotation);
1097
1257
  this.pdfLinkService.setHash(storedHash);
1098
1258
  }
1259
+
1099
1260
  this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
1100
1261
  this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
1262
+
1101
1263
  if (!this.pdfViewer.currentScaleValue) {
1102
1264
  this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
1103
1265
  }
@@ -1106,8 +1268,10 @@ var PDFViewerApplication = {
1106
1268
  if (!this.pdfDocument) {
1107
1269
  return;
1108
1270
  }
1271
+
1109
1272
  this.pdfViewer.cleanup();
1110
1273
  this.pdfThumbnailViewer.cleanup();
1274
+
1111
1275
  if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
1112
1276
  this.pdfDocument.cleanup();
1113
1277
  }
@@ -1123,18 +1287,21 @@ var PDFViewerApplication = {
1123
1287
  if (this.printService) {
1124
1288
  return;
1125
1289
  }
1290
+
1126
1291
  if (!this.supportsPrinting) {
1127
1292
  this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
1128
1293
  _this7.error(printMessage);
1129
1294
  });
1130
1295
  return;
1131
1296
  }
1297
+
1132
1298
  if (!this.pdfViewer.pageViewsReady) {
1133
1299
  this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
1134
1300
  window.alert(notReadyMessage);
1135
1301
  });
1136
1302
  return;
1137
1303
  }
1304
+
1138
1305
  var pagesOverview = this.pdfViewer.getPagesOverview();
1139
1306
  var printContainer = this.appConfig.printContainer;
1140
1307
  var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
@@ -1142,18 +1309,19 @@ var PDFViewerApplication = {
1142
1309
  this.forceRendering();
1143
1310
  printService.layout();
1144
1311
  },
1145
-
1146
1312
  afterPrint: function pdfViewSetupAfterPrint() {
1147
1313
  if (this.printService) {
1148
1314
  this.printService.destroy();
1149
1315
  this.printService = null;
1150
1316
  }
1317
+
1151
1318
  this.forceRendering();
1152
1319
  },
1153
1320
  rotatePages: function rotatePages(delta) {
1154
1321
  if (!this.pdfDocument) {
1155
1322
  return;
1156
1323
  }
1324
+
1157
1325
  var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
1158
1326
  this.pdfViewer.pagesRotation = newRotation;
1159
1327
  },
@@ -1161,12 +1329,12 @@ var PDFViewerApplication = {
1161
1329
  if (!this.pdfPresentationMode) {
1162
1330
  return;
1163
1331
  }
1332
+
1164
1333
  this.pdfPresentationMode.request();
1165
1334
  },
1166
1335
  bindEvents: function bindEvents() {
1167
1336
  var eventBus = this.eventBus,
1168
1337
  _boundEvents = this._boundEvents;
1169
-
1170
1338
  _boundEvents.beforePrint = this.beforePrint.bind(this);
1171
1339
  _boundEvents.afterPrint = this.afterPrint.bind(this);
1172
1340
  eventBus.on('resize', webViewerResize);
@@ -1213,20 +1381,31 @@ var PDFViewerApplication = {
1213
1381
  _boundEvents = this._boundEvents;
1214
1382
 
1215
1383
  _boundEvents.windowResize = function () {
1216
- eventBus.dispatch('resize', { source: window });
1384
+ eventBus.dispatch('resize', {
1385
+ source: window
1386
+ });
1217
1387
  };
1388
+
1218
1389
  _boundEvents.windowHashChange = function () {
1219
1390
  eventBus.dispatch('hashchange', {
1220
1391
  source: window,
1221
1392
  hash: document.location.hash.substring(1)
1222
1393
  });
1223
1394
  };
1395
+
1224
1396
  _boundEvents.windowBeforePrint = function () {
1225
- eventBus.dispatch('beforeprint', { source: window });
1397
+ eventBus.dispatch('beforeprint', {
1398
+ source: window
1399
+ });
1226
1400
  };
1401
+
1227
1402
  _boundEvents.windowAfterPrint = function () {
1228
- eventBus.dispatch('afterprint', { source: window });
1403
+ eventBus.dispatch('afterprint', {
1404
+ source: window
1405
+ });
1229
1406
  };
1407
+
1408
+ window.addEventListener('visibilitychange', webViewerVisibilityChange);
1230
1409
  window.addEventListener('wheel', webViewerWheel);
1231
1410
  window.addEventListener('click', webViewerClick);
1232
1411
  window.addEventListener('keydown', webViewerKeyDown);
@@ -1238,7 +1417,6 @@ var PDFViewerApplication = {
1238
1417
  unbindEvents: function unbindEvents() {
1239
1418
  var eventBus = this.eventBus,
1240
1419
  _boundEvents = this._boundEvents;
1241
-
1242
1420
  eventBus.off('resize', webViewerResize);
1243
1421
  eventBus.off('hashchange', webViewerHashchange);
1244
1422
  eventBus.off('beforeprint', _boundEvents.beforePrint);
@@ -1282,7 +1460,7 @@ var PDFViewerApplication = {
1282
1460
  },
1283
1461
  unbindWindowEvents: function unbindWindowEvents() {
1284
1462
  var _boundEvents = this._boundEvents;
1285
-
1463
+ window.removeEventListener('visibilitychange', webViewerVisibilityChange);
1286
1464
  window.removeEventListener('wheel', webViewerWheel);
1287
1465
  window.removeEventListener('click', webViewerClick);
1288
1466
  window.removeEventListener('keydown', webViewerKeyDown);
@@ -1296,22 +1474,26 @@ var PDFViewerApplication = {
1296
1474
  _boundEvents.windowAfterPrint = null;
1297
1475
  }
1298
1476
  };
1299
- var validateFileURL = void 0;
1477
+ exports.PDFViewerApplication = PDFViewerApplication;
1478
+ var validateFileURL;
1300
1479
  {
1301
1480
  var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
1481
+
1302
1482
  validateFileURL = function validateFileURL(file) {
1303
1483
  if (file === undefined) {
1304
1484
  return;
1305
1485
  }
1486
+
1306
1487
  try {
1307
1488
  var viewerOrigin = new _pdf.URL(window.location.href).origin || 'null';
1489
+
1308
1490
  if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
1309
1491
  return;
1310
1492
  }
1311
1493
 
1312
- var _ref14 = new _pdf.URL(file, window.location.href),
1313
- origin = _ref14.origin,
1314
- protocol = _ref14.protocol;
1494
+ var _ref8 = new _pdf.URL(file, window.location.href),
1495
+ origin = _ref8.origin,
1496
+ protocol = _ref8.protocol;
1315
1497
 
1316
1498
  if (origin !== viewerOrigin && protocol !== 'blob:') {
1317
1499
  throw new Error('file origin does not match viewer\'s');
@@ -1319,18 +1501,23 @@ var validateFileURL = void 0;
1319
1501
  } catch (ex) {
1320
1502
  var message = ex && ex.message;
1321
1503
  PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
1322
- PDFViewerApplication.error(loadingErrorMessage, { message: message });
1504
+ PDFViewerApplication.error(loadingErrorMessage, {
1505
+ message: message
1506
+ });
1323
1507
  });
1324
1508
  throw ex;
1325
1509
  }
1326
1510
  };
1327
1511
  }
1512
+
1328
1513
  function loadFakeWorker() {
1329
1514
  if (!_pdf.GlobalWorkerOptions.workerSrc) {
1330
1515
  _pdf.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
1331
1516
  }
1517
+
1332
1518
  return (0, _pdf.loadScript)(_pdf.PDFWorker.getWorkerSrc());
1333
1519
  }
1520
+
1334
1521
  function loadAndEnablePDFBug(enabledTabs) {
1335
1522
  var appConfig = PDFViewerApplication.appConfig;
1336
1523
  return (0, _pdf.loadScript)(appConfig.debuggerScriptPath).then(function () {
@@ -1341,9 +1528,10 @@ function loadAndEnablePDFBug(enabledTabs) {
1341
1528
  }, appConfig.mainContainer);
1342
1529
  });
1343
1530
  }
1531
+
1344
1532
  function webViewerInitialized() {
1345
1533
  var appConfig = PDFViewerApplication.appConfig;
1346
- var file = void 0;
1534
+ var file;
1347
1535
  var queryString = document.location.search.substring(1);
1348
1536
  var params = (0, _ui_utils.parseQueryString)(queryString);
1349
1537
  file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
@@ -1354,17 +1542,21 @@ function webViewerInitialized() {
1354
1542
  fileInput.setAttribute('type', 'file');
1355
1543
  fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
1356
1544
  document.body.appendChild(fileInput);
1545
+
1357
1546
  if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
1358
1547
  appConfig.toolbar.openFile.setAttribute('hidden', 'true');
1359
1548
  appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
1360
1549
  } else {
1361
1550
  fileInput.value = null;
1362
1551
  }
1552
+
1363
1553
  fileInput.addEventListener('change', function (evt) {
1364
1554
  var files = evt.target.files;
1555
+
1365
1556
  if (!files || files.length === 0) {
1366
1557
  return;
1367
1558
  }
1559
+
1368
1560
  PDFViewerApplication.eventBus.dispatch('fileinputchange', {
1369
1561
  source: this,
1370
1562
  fileInput: evt.target
@@ -1377,33 +1569,42 @@ function webViewerInitialized() {
1377
1569
  appConfig.mainContainer.addEventListener('drop', function (evt) {
1378
1570
  evt.preventDefault();
1379
1571
  var files = evt.dataTransfer.files;
1572
+
1380
1573
  if (!files || files.length === 0) {
1381
1574
  return;
1382
1575
  }
1576
+
1383
1577
  PDFViewerApplication.eventBus.dispatch('fileinputchange', {
1384
1578
  source: this,
1385
1579
  fileInput: evt.dataTransfer
1386
1580
  });
1387
1581
  });
1582
+
1388
1583
  if (!PDFViewerApplication.supportsPrinting) {
1389
1584
  appConfig.toolbar.print.classList.add('hidden');
1390
1585
  appConfig.secondaryToolbar.printButton.classList.add('hidden');
1391
1586
  }
1587
+
1392
1588
  if (!PDFViewerApplication.supportsFullscreen) {
1393
1589
  appConfig.toolbar.presentationModeButton.classList.add('hidden');
1394
1590
  appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
1395
1591
  }
1592
+
1396
1593
  if (PDFViewerApplication.supportsIntegratedFind) {
1397
1594
  appConfig.toolbar.viewFind.classList.add('hidden');
1398
1595
  }
1596
+
1399
1597
  appConfig.mainContainer.addEventListener('transitionend', function (evt) {
1400
1598
  if (evt.target === this) {
1401
- PDFViewerApplication.eventBus.dispatch('resize', { source: this });
1599
+ PDFViewerApplication.eventBus.dispatch('resize', {
1600
+ source: this
1601
+ });
1402
1602
  }
1403
1603
  }, true);
1404
1604
  appConfig.sidebar.toggleButton.addEventListener('click', function () {
1405
1605
  PDFViewerApplication.pdfSidebar.toggle();
1406
1606
  });
1607
+
1407
1608
  try {
1408
1609
  webViewerOpenFileViaURL(file);
1409
1610
  } catch (reason) {
@@ -1412,105 +1613,127 @@ function webViewerInitialized() {
1412
1613
  });
1413
1614
  }
1414
1615
  }
1415
- var webViewerOpenFileViaURL = void 0;
1616
+
1617
+ var webViewerOpenFileViaURL;
1416
1618
  {
1417
1619
  webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
1418
1620
  if (file && file.lastIndexOf('file:', 0) === 0) {
1419
1621
  PDFViewerApplication.setTitleUsingUrl(file);
1420
1622
  var xhr = new XMLHttpRequest();
1623
+
1421
1624
  xhr.onload = function () {
1422
1625
  PDFViewerApplication.open(new Uint8Array(xhr.response));
1423
1626
  };
1424
- try {
1425
- xhr.open('GET', file);
1426
- xhr.responseType = 'arraybuffer';
1427
- xhr.send();
1428
- } catch (ex) {
1429
- throw ex;
1430
- }
1627
+
1628
+ xhr.open('GET', file);
1629
+ xhr.responseType = 'arraybuffer';
1630
+ xhr.send();
1431
1631
  return;
1432
1632
  }
1633
+
1433
1634
  if (file) {
1434
1635
  PDFViewerApplication.open(file);
1435
1636
  }
1436
1637
  };
1437
1638
  }
1639
+
1438
1640
  function webViewerPageRendered(evt) {
1439
1641
  var pageNumber = evt.pageNumber;
1440
1642
  var pageIndex = pageNumber - 1;
1441
1643
  var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
1644
+
1442
1645
  if (pageNumber === PDFViewerApplication.page) {
1443
1646
  PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
1444
1647
  }
1648
+
1445
1649
  if (!pageView) {
1446
1650
  return;
1447
1651
  }
1652
+
1448
1653
  if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
1449
1654
  var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
1450
1655
  thumbnailView.setImage(pageView);
1451
1656
  }
1657
+
1452
1658
  if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
1453
1659
  Stats.add(pageNumber, pageView.stats);
1454
1660
  }
1661
+
1455
1662
  if (pageView.error) {
1456
1663
  PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
1457
1664
  PDFViewerApplication.error(msg, pageView.error);
1458
1665
  });
1459
1666
  }
1460
1667
  }
1668
+
1461
1669
  function webViewerTextLayerRendered(evt) {}
1670
+
1462
1671
  function webViewerPageMode(evt) {
1463
1672
  var mode = evt.mode,
1464
- view = void 0;
1673
+ view;
1674
+
1465
1675
  switch (mode) {
1466
1676
  case 'thumbs':
1467
1677
  view = _pdf_sidebar.SidebarView.THUMBS;
1468
1678
  break;
1679
+
1469
1680
  case 'bookmarks':
1470
1681
  case 'outline':
1471
1682
  view = _pdf_sidebar.SidebarView.OUTLINE;
1472
1683
  break;
1684
+
1473
1685
  case 'attachments':
1474
1686
  view = _pdf_sidebar.SidebarView.ATTACHMENTS;
1475
1687
  break;
1688
+
1476
1689
  case 'none':
1477
1690
  view = _pdf_sidebar.SidebarView.NONE;
1478
1691
  break;
1692
+
1479
1693
  default:
1480
1694
  console.error('Invalid "pagemode" hash parameter: ' + mode);
1481
1695
  return;
1482
1696
  }
1697
+
1483
1698
  PDFViewerApplication.pdfSidebar.switchView(view, true);
1484
1699
  }
1700
+
1485
1701
  function webViewerNamedAction(evt) {
1486
1702
  var action = evt.action;
1703
+
1487
1704
  switch (action) {
1488
1705
  case 'GoToPage':
1489
1706
  PDFViewerApplication.appConfig.toolbar.pageNumber.select();
1490
1707
  break;
1708
+
1491
1709
  case 'Find':
1492
1710
  if (!PDFViewerApplication.supportsIntegratedFind) {
1493
1711
  PDFViewerApplication.findBar.toggle();
1494
1712
  }
1713
+
1495
1714
  break;
1496
1715
  }
1497
1716
  }
1717
+
1498
1718
  function webViewerPresentationModeChanged(evt) {
1499
1719
  var active = evt.active,
1500
1720
  switchInProgress = evt.switchInProgress;
1501
-
1502
1721
  PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
1503
1722
  }
1723
+
1504
1724
  function webViewerSidebarViewChanged(evt) {
1505
1725
  PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
1506
1726
  var store = PDFViewerApplication.store;
1727
+
1507
1728
  if (store && PDFViewerApplication.isInitialViewSet) {
1508
1729
  store.set('sidebarView', evt.view).catch(function () {});
1509
1730
  }
1510
1731
  }
1732
+
1511
1733
  function webViewerUpdateViewarea(evt) {
1512
1734
  var location = evt.location,
1513
1735
  store = PDFViewerApplication.store;
1736
+
1514
1737
  if (store && PDFViewerApplication.isInitialViewSet) {
1515
1738
  store.setMultiple({
1516
1739
  'page': location.pageNumber,
@@ -1520,6 +1743,7 @@ function webViewerUpdateViewarea(evt) {
1520
1743
  'rotation': location.rotation
1521
1744
  }).catch(function () {});
1522
1745
  }
1746
+
1523
1747
  var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
1524
1748
  PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
1525
1749
  PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
@@ -1527,18 +1751,23 @@ function webViewerUpdateViewarea(evt) {
1527
1751
  var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
1528
1752
  PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
1529
1753
  }
1754
+
1530
1755
  function webViewerScrollModeChanged(evt) {
1531
1756
  var store = PDFViewerApplication.store;
1757
+
1532
1758
  if (store && PDFViewerApplication.isInitialViewSet) {
1533
1759
  store.set('scrollMode', evt.mode).catch(function () {});
1534
1760
  }
1535
1761
  }
1762
+
1536
1763
  function webViewerSpreadModeChanged(evt) {
1537
1764
  var store = PDFViewerApplication.store;
1765
+
1538
1766
  if (store && PDFViewerApplication.isInitialViewSet) {
1539
1767
  store.set('spreadMode', evt.mode).catch(function () {});
1540
1768
  }
1541
1769
  }
1770
+
1542
1771
  function webViewerResize() {
1543
1772
  var pdfDocument = PDFViewerApplication.pdfDocument,
1544
1773
  pdfViewer = PDFViewerApplication.pdfViewer;
@@ -1546,48 +1775,62 @@ function webViewerResize() {
1546
1775
  if (!pdfDocument) {
1547
1776
  return;
1548
1777
  }
1778
+
1549
1779
  var currentScaleValue = pdfViewer.currentScaleValue;
1780
+
1550
1781
  if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
1551
1782
  pdfViewer.currentScaleValue = currentScaleValue;
1552
1783
  }
1784
+
1553
1785
  pdfViewer.update();
1554
1786
  }
1787
+
1555
1788
  function webViewerHashchange(evt) {
1556
1789
  var hash = evt.hash;
1790
+
1557
1791
  if (!hash) {
1558
1792
  return;
1559
1793
  }
1794
+
1560
1795
  if (!PDFViewerApplication.isInitialViewSet) {
1561
1796
  PDFViewerApplication.initialBookmark = hash;
1562
1797
  } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
1563
1798
  PDFViewerApplication.pdfLinkService.setHash(hash);
1564
1799
  }
1565
1800
  }
1566
- var webViewerFileInputChange = void 0;
1801
+
1802
+ var webViewerFileInputChange;
1567
1803
  {
1568
1804
  webViewerFileInputChange = function webViewerFileInputChange(evt) {
1569
1805
  if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
1570
1806
  return;
1571
1807
  }
1808
+
1572
1809
  var file = evt.fileInput.files[0];
1810
+
1573
1811
  if (_pdf.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
1574
- var _url = _pdf.URL.createObjectURL(file);
1812
+ var url = _pdf.URL.createObjectURL(file);
1813
+
1575
1814
  if (file.name) {
1576
- _url = {
1577
- url: _url,
1815
+ url = {
1816
+ url: url,
1578
1817
  originalUrl: file.name
1579
1818
  };
1580
1819
  }
1581
- PDFViewerApplication.open(_url);
1820
+
1821
+ PDFViewerApplication.open(url);
1582
1822
  } else {
1583
1823
  PDFViewerApplication.setTitleUsingUrl(file.name);
1584
1824
  var fileReader = new FileReader();
1825
+
1585
1826
  fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
1586
1827
  var buffer = evt.target.result;
1587
1828
  PDFViewerApplication.open(new Uint8Array(buffer));
1588
1829
  };
1830
+
1589
1831
  fileReader.readAsArrayBuffer(file);
1590
1832
  }
1833
+
1591
1834
  var appConfig = PDFViewerApplication.appConfig;
1592
1835
  appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
1593
1836
  appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
@@ -1595,66 +1838,88 @@ var webViewerFileInputChange = void 0;
1595
1838
  appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
1596
1839
  };
1597
1840
  }
1841
+
1598
1842
  function webViewerPresentationMode() {
1599
1843
  PDFViewerApplication.requestPresentationMode();
1600
1844
  }
1845
+
1601
1846
  function webViewerOpenFile() {
1602
1847
  var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
1603
1848
  document.getElementById(openFileInputName).click();
1604
1849
  }
1850
+
1605
1851
  function webViewerPrint() {
1606
1852
  window.print();
1607
1853
  }
1854
+
1608
1855
  function webViewerDownload() {
1609
1856
  PDFViewerApplication.download();
1610
1857
  }
1858
+
1611
1859
  function webViewerFirstPage() {
1612
1860
  if (PDFViewerApplication.pdfDocument) {
1613
1861
  PDFViewerApplication.page = 1;
1614
1862
  }
1615
1863
  }
1864
+
1616
1865
  function webViewerLastPage() {
1617
1866
  if (PDFViewerApplication.pdfDocument) {
1618
1867
  PDFViewerApplication.page = PDFViewerApplication.pagesCount;
1619
1868
  }
1620
1869
  }
1870
+
1621
1871
  function webViewerNextPage() {
1622
1872
  PDFViewerApplication.page++;
1623
1873
  }
1874
+
1624
1875
  function webViewerPreviousPage() {
1625
1876
  PDFViewerApplication.page--;
1626
1877
  }
1878
+
1627
1879
  function webViewerZoomIn() {
1628
1880
  PDFViewerApplication.zoomIn();
1629
1881
  }
1882
+
1630
1883
  function webViewerZoomOut() {
1631
1884
  PDFViewerApplication.zoomOut();
1632
1885
  }
1886
+
1633
1887
  function webViewerPageNumberChanged(evt) {
1634
1888
  var pdfViewer = PDFViewerApplication.pdfViewer;
1635
- pdfViewer.currentPageLabel = evt.value;
1889
+
1890
+ if (evt.value !== '') {
1891
+ pdfViewer.currentPageLabel = evt.value;
1892
+ }
1893
+
1636
1894
  if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
1637
1895
  PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
1638
1896
  }
1639
1897
  }
1898
+
1640
1899
  function webViewerScaleChanged(evt) {
1641
1900
  PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
1642
1901
  }
1902
+
1643
1903
  function webViewerRotateCw() {
1644
1904
  PDFViewerApplication.rotatePages(90);
1645
1905
  }
1906
+
1646
1907
  function webViewerRotateCcw() {
1647
1908
  PDFViewerApplication.rotatePages(-90);
1648
1909
  }
1910
+
1649
1911
  function webViewerSwitchScrollMode(evt) {
1650
1912
  PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
1651
1913
  }
1914
+
1652
1915
  function webViewerSwitchSpreadMode(evt) {
1653
1916
  PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
1654
1917
  }
1918
+
1655
1919
  function webViewerDocumentProperties() {
1656
1920
  PDFViewerApplication.pdfDocumentProperties.open();
1657
1921
  }
1922
+
1658
1923
  function webViewerFind(evt) {
1659
1924
  PDFViewerApplication.findController.executeCommand('find' + evt.type, {
1660
1925
  query: evt.query,
@@ -1665,6 +1930,7 @@ function webViewerFind(evt) {
1665
1930
  findPrevious: evt.findPrevious
1666
1931
  });
1667
1932
  }
1933
+
1668
1934
  function webViewerFindFromUrlHash(evt) {
1669
1935
  PDFViewerApplication.findController.executeCommand('find', {
1670
1936
  query: evt.query,
@@ -1675,8 +1941,9 @@ function webViewerFindFromUrlHash(evt) {
1675
1941
  findPrevious: false
1676
1942
  });
1677
1943
  }
1678
- function webViewerUpdateFindMatchesCount(_ref15) {
1679
- var matchesCount = _ref15.matchesCount;
1944
+
1945
+ function webViewerUpdateFindMatchesCount(_ref9) {
1946
+ var matchesCount = _ref9.matchesCount;
1680
1947
 
1681
1948
  if (PDFViewerApplication.supportsIntegratedFind) {
1682
1949
  PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
@@ -1684,10 +1951,11 @@ function webViewerUpdateFindMatchesCount(_ref15) {
1684
1951
  PDFViewerApplication.findBar.updateResultsCount(matchesCount);
1685
1952
  }
1686
1953
  }
1687
- function webViewerUpdateFindControlState(_ref16) {
1688
- var state = _ref16.state,
1689
- previous = _ref16.previous,
1690
- matchesCount = _ref16.matchesCount;
1954
+
1955
+ function webViewerUpdateFindControlState(_ref10) {
1956
+ var state = _ref10.state,
1957
+ previous = _ref10.previous,
1958
+ matchesCount = _ref10.matchesCount;
1691
1959
 
1692
1960
  if (PDFViewerApplication.supportsIntegratedFind) {
1693
1961
  PDFViewerApplication.externalServices.updateFindControlState({
@@ -1699,55 +1967,87 @@ function webViewerUpdateFindControlState(_ref16) {
1699
1967
  PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
1700
1968
  }
1701
1969
  }
1970
+
1702
1971
  function webViewerScaleChanging(evt) {
1703
1972
  PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
1704
1973
  PDFViewerApplication.pdfViewer.update();
1705
1974
  }
1975
+
1706
1976
  function webViewerRotationChanging(evt) {
1707
1977
  PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
1708
1978
  PDFViewerApplication.forceRendering();
1709
1979
  PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
1710
1980
  }
1981
+
1711
1982
  function webViewerPageChanging(evt) {
1712
1983
  var page = evt.pageNumber;
1713
1984
  PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
1714
1985
  PDFViewerApplication.secondaryToolbar.setPageNumber(page);
1986
+
1715
1987
  if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
1716
1988
  PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
1717
1989
  }
1990
+
1718
1991
  if (typeof Stats !== 'undefined' && Stats.enabled) {
1719
1992
  var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
1993
+
1720
1994
  if (pageView && pageView.stats) {
1721
1995
  Stats.add(page, pageView.stats);
1722
1996
  }
1723
1997
  }
1724
1998
  }
1725
- var zoomDisabled = false,
1726
- zoomDisabledTimeout = void 0;
1999
+
2000
+ function webViewerVisibilityChange(evt) {
2001
+ if (document.visibilityState === 'visible') {
2002
+ setZoomDisabledTimeout();
2003
+ }
2004
+ }
2005
+
2006
+ var zoomDisabledTimeout = null;
2007
+
2008
+ function setZoomDisabledTimeout() {
2009
+ if (zoomDisabledTimeout) {
2010
+ clearTimeout(zoomDisabledTimeout);
2011
+ }
2012
+
2013
+ zoomDisabledTimeout = setTimeout(function () {
2014
+ zoomDisabledTimeout = null;
2015
+ }, WHEEL_ZOOM_DISABLED_TIMEOUT);
2016
+ }
2017
+
1727
2018
  function webViewerWheel(evt) {
1728
2019
  var pdfViewer = PDFViewerApplication.pdfViewer;
2020
+
1729
2021
  if (pdfViewer.isInPresentationMode) {
1730
2022
  return;
1731
2023
  }
2024
+
1732
2025
  if (evt.ctrlKey || evt.metaKey) {
1733
2026
  var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
2027
+
1734
2028
  if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
1735
2029
  return;
1736
2030
  }
2031
+
1737
2032
  evt.preventDefault();
1738
- if (zoomDisabled) {
2033
+
2034
+ if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
1739
2035
  return;
1740
2036
  }
2037
+
1741
2038
  var previousScale = pdfViewer.currentScale;
1742
2039
  var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
1743
2040
  var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
1744
2041
  var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
2042
+
1745
2043
  if (ticks < 0) {
1746
2044
  PDFViewerApplication.zoomOut(-ticks);
1747
2045
  } else {
1748
2046
  PDFViewerApplication.zoomIn(ticks);
1749
2047
  }
2048
+
1750
2049
  var currentScale = pdfViewer.currentScale;
2050
+
1751
2051
  if (previousScale !== currentScale) {
1752
2052
  var scaleCorrectionFactor = currentScale / previousScale - 1;
1753
2053
  var rect = pdfViewer.container.getBoundingClientRect();
@@ -1757,31 +2057,33 @@ function webViewerWheel(evt) {
1757
2057
  pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
1758
2058
  }
1759
2059
  } else {
1760
- zoomDisabled = true;
1761
- clearTimeout(zoomDisabledTimeout);
1762
- zoomDisabledTimeout = setTimeout(function () {
1763
- zoomDisabled = false;
1764
- }, 1000);
2060
+ setZoomDisabledTimeout();
1765
2061
  }
1766
2062
  }
2063
+
1767
2064
  function webViewerClick(evt) {
1768
2065
  if (!PDFViewerApplication.secondaryToolbar.isOpen) {
1769
2066
  return;
1770
2067
  }
2068
+
1771
2069
  var appConfig = PDFViewerApplication.appConfig;
2070
+
1772
2071
  if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
1773
2072
  PDFViewerApplication.secondaryToolbar.close();
1774
2073
  }
1775
2074
  }
2075
+
1776
2076
  function webViewerKeyDown(evt) {
1777
2077
  if (PDFViewerApplication.overlayManager.active) {
1778
2078
  return;
1779
2079
  }
2080
+
1780
2081
  var handled = false,
1781
2082
  ensureViewerFocused = false;
1782
2083
  var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
1783
2084
  var pdfViewer = PDFViewerApplication.pdfViewer;
1784
2085
  var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
2086
+
1785
2087
  if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
1786
2088
  switch (evt.keyCode) {
1787
2089
  case 70:
@@ -1789,10 +2091,13 @@ function webViewerKeyDown(evt) {
1789
2091
  PDFViewerApplication.findBar.open();
1790
2092
  handled = true;
1791
2093
  }
2094
+
1792
2095
  break;
2096
+
1793
2097
  case 71:
1794
2098
  if (!PDFViewerApplication.supportsIntegratedFind) {
1795
2099
  var findState = PDFViewerApplication.findController.state;
2100
+
1796
2101
  if (findState) {
1797
2102
  PDFViewerApplication.findController.executeCommand('findagain', {
1798
2103
  query: findState.query,
@@ -1803,9 +2108,12 @@ function webViewerKeyDown(evt) {
1803
2108
  findPrevious: cmd === 5 || cmd === 12
1804
2109
  });
1805
2110
  }
2111
+
1806
2112
  handled = true;
1807
2113
  }
2114
+
1808
2115
  break;
2116
+
1809
2117
  case 61:
1810
2118
  case 107:
1811
2119
  case 187:
@@ -1813,16 +2121,20 @@ function webViewerKeyDown(evt) {
1813
2121
  if (!isViewerInPresentationMode) {
1814
2122
  PDFViewerApplication.zoomIn();
1815
2123
  }
2124
+
1816
2125
  handled = true;
1817
2126
  break;
2127
+
1818
2128
  case 173:
1819
2129
  case 109:
1820
2130
  case 189:
1821
2131
  if (!isViewerInPresentationMode) {
1822
2132
  PDFViewerApplication.zoomOut();
1823
2133
  }
2134
+
1824
2135
  handled = true;
1825
2136
  break;
2137
+
1826
2138
  case 48:
1827
2139
  case 96:
1828
2140
  if (!isViewerInPresentationMode) {
@@ -1831,23 +2143,29 @@ function webViewerKeyDown(evt) {
1831
2143
  });
1832
2144
  handled = false;
1833
2145
  }
2146
+
1834
2147
  break;
2148
+
1835
2149
  case 38:
1836
2150
  if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
1837
2151
  PDFViewerApplication.page = 1;
1838
2152
  handled = true;
1839
2153
  ensureViewerFocused = true;
1840
2154
  }
2155
+
1841
2156
  break;
2157
+
1842
2158
  case 40:
1843
2159
  if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
1844
2160
  PDFViewerApplication.page = PDFViewerApplication.pagesCount;
1845
2161
  handled = true;
1846
2162
  ensureViewerFocused = true;
1847
2163
  }
2164
+
1848
2165
  break;
1849
2166
  }
1850
2167
  }
2168
+
1851
2169
  if (cmd === 1 || cmd === 8) {
1852
2170
  switch (evt.keyCode) {
1853
2171
  case 83:
@@ -1856,113 +2174,147 @@ function webViewerKeyDown(evt) {
1856
2174
  break;
1857
2175
  }
1858
2176
  }
2177
+
1859
2178
  if (cmd === 3 || cmd === 10) {
1860
2179
  switch (evt.keyCode) {
1861
2180
  case 80:
1862
2181
  PDFViewerApplication.requestPresentationMode();
1863
2182
  handled = true;
1864
2183
  break;
2184
+
1865
2185
  case 71:
1866
2186
  PDFViewerApplication.appConfig.toolbar.pageNumber.select();
1867
2187
  handled = true;
1868
2188
  break;
1869
2189
  }
1870
2190
  }
2191
+
1871
2192
  if (handled) {
1872
2193
  if (ensureViewerFocused && !isViewerInPresentationMode) {
1873
2194
  pdfViewer.focus();
1874
2195
  }
2196
+
1875
2197
  evt.preventDefault();
1876
2198
  return;
1877
2199
  }
2200
+
1878
2201
  var curElement = document.activeElement || document.querySelector(':focus');
1879
2202
  var curElementTagName = curElement && curElement.tagName.toUpperCase();
2203
+
1880
2204
  if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
1881
2205
  if (evt.keyCode !== 27) {
1882
2206
  return;
1883
2207
  }
1884
2208
  }
2209
+
1885
2210
  if (cmd === 0) {
1886
2211
  var turnPage = 0,
1887
2212
  turnOnlyIfPageFit = false;
2213
+
1888
2214
  switch (evt.keyCode) {
1889
2215
  case 38:
1890
2216
  case 33:
1891
2217
  if (pdfViewer.isVerticalScrollbarEnabled) {
1892
2218
  turnOnlyIfPageFit = true;
1893
2219
  }
2220
+
1894
2221
  turnPage = -1;
1895
2222
  break;
2223
+
1896
2224
  case 8:
1897
2225
  if (!isViewerInPresentationMode) {
1898
2226
  turnOnlyIfPageFit = true;
1899
2227
  }
2228
+
1900
2229
  turnPage = -1;
1901
2230
  break;
2231
+
1902
2232
  case 37:
1903
2233
  if (pdfViewer.isHorizontalScrollbarEnabled) {
1904
2234
  turnOnlyIfPageFit = true;
1905
2235
  }
2236
+
1906
2237
  case 75:
1907
2238
  case 80:
1908
2239
  turnPage = -1;
1909
2240
  break;
2241
+
1910
2242
  case 27:
1911
2243
  if (PDFViewerApplication.secondaryToolbar.isOpen) {
1912
2244
  PDFViewerApplication.secondaryToolbar.close();
1913
2245
  handled = true;
1914
2246
  }
2247
+
1915
2248
  if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
1916
2249
  PDFViewerApplication.findBar.close();
1917
2250
  handled = true;
1918
2251
  }
2252
+
1919
2253
  break;
2254
+
1920
2255
  case 40:
1921
2256
  case 34:
1922
2257
  if (pdfViewer.isVerticalScrollbarEnabled) {
1923
2258
  turnOnlyIfPageFit = true;
1924
2259
  }
2260
+
1925
2261
  turnPage = 1;
1926
2262
  break;
2263
+
1927
2264
  case 13:
1928
2265
  case 32:
1929
2266
  if (!isViewerInPresentationMode) {
1930
2267
  turnOnlyIfPageFit = true;
1931
2268
  }
2269
+
1932
2270
  turnPage = 1;
1933
2271
  break;
2272
+
1934
2273
  case 39:
1935
2274
  if (pdfViewer.isHorizontalScrollbarEnabled) {
1936
2275
  turnOnlyIfPageFit = true;
1937
2276
  }
2277
+
1938
2278
  case 74:
1939
2279
  case 78:
1940
2280
  turnPage = 1;
1941
2281
  break;
2282
+
1942
2283
  case 36:
1943
2284
  if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
1944
2285
  PDFViewerApplication.page = 1;
1945
2286
  handled = true;
1946
2287
  ensureViewerFocused = true;
1947
2288
  }
2289
+
1948
2290
  break;
2291
+
1949
2292
  case 35:
1950
2293
  if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
1951
2294
  PDFViewerApplication.page = PDFViewerApplication.pagesCount;
1952
2295
  handled = true;
1953
2296
  ensureViewerFocused = true;
1954
2297
  }
2298
+
1955
2299
  break;
2300
+
1956
2301
  case 83:
1957
2302
  PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
1958
2303
  break;
2304
+
1959
2305
  case 72:
1960
2306
  PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
1961
2307
  break;
2308
+
1962
2309
  case 82:
1963
2310
  PDFViewerApplication.rotatePages(90);
1964
2311
  break;
2312
+
2313
+ case 115:
2314
+ PDFViewerApplication.pdfSidebar.toggle();
2315
+ break;
1965
2316
  }
2317
+
1966
2318
  if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
1967
2319
  if (turnPage > 0) {
1968
2320
  if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
@@ -1973,9 +2325,11 @@ function webViewerKeyDown(evt) {
1973
2325
  PDFViewerApplication.page--;
1974
2326
  }
1975
2327
  }
2328
+
1976
2329
  handled = true;
1977
2330
  }
1978
2331
  }
2332
+
1979
2333
  if (cmd === 4) {
1980
2334
  switch (evt.keyCode) {
1981
2335
  case 13:
@@ -1983,42 +2337,55 @@ function webViewerKeyDown(evt) {
1983
2337
  if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
1984
2338
  break;
1985
2339
  }
2340
+
1986
2341
  if (PDFViewerApplication.page > 1) {
1987
2342
  PDFViewerApplication.page--;
1988
2343
  }
2344
+
1989
2345
  handled = true;
1990
2346
  break;
2347
+
1991
2348
  case 82:
1992
2349
  PDFViewerApplication.rotatePages(-90);
1993
2350
  break;
1994
2351
  }
1995
2352
  }
2353
+
1996
2354
  if (!handled && !isViewerInPresentationMode) {
1997
2355
  if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
1998
2356
  ensureViewerFocused = true;
1999
2357
  }
2000
2358
  }
2359
+
2001
2360
  if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
2002
2361
  pdfViewer.focus();
2003
2362
  }
2363
+
2004
2364
  if (handled) {
2005
2365
  evt.preventDefault();
2006
2366
  }
2007
2367
  }
2368
+
2008
2369
  function apiPageModeToSidebarView(mode) {
2009
2370
  switch (mode) {
2010
2371
  case 'UseNone':
2011
2372
  return _pdf_sidebar.SidebarView.NONE;
2373
+
2012
2374
  case 'UseThumbs':
2013
2375
  return _pdf_sidebar.SidebarView.THUMBS;
2376
+
2014
2377
  case 'UseOutlines':
2015
2378
  return _pdf_sidebar.SidebarView.OUTLINE;
2379
+
2016
2380
  case 'UseAttachments':
2017
2381
  return _pdf_sidebar.SidebarView.ATTACHMENTS;
2382
+
2018
2383
  case 'UseOC':
2019
2384
  }
2385
+
2020
2386
  return _pdf_sidebar.SidebarView.NONE;
2021
2387
  }
2388
+
2022
2389
  var PDFPrintServiceFactory = {
2023
2390
  instance: {
2024
2391
  supportsPrinting: false,
@@ -2027,6 +2394,4 @@ var PDFPrintServiceFactory = {
2027
2394
  }
2028
2395
  }
2029
2396
  };
2030
- exports.PDFViewerApplication = PDFViewerApplication;
2031
- exports.DefaultExternalServices = DefaultExternalServices;
2032
2397
  exports.PDFPrintServiceFactory = PDFPrintServiceFactory;