pdfjs-dist 2.2.228 → 2.6.347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +1144 -927
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
package/lib/web/pdf_sidebar.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -26,18 +26,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.PDFSidebar = exports.SidebarView = void 0;
|
28
28
|
|
29
|
-
var _ui_utils = require("./ui_utils");
|
29
|
+
var _ui_utils = require("./ui_utils.js");
|
30
30
|
|
31
|
-
var _pdf_rendering_queue = require("./pdf_rendering_queue");
|
31
|
+
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
36
|
-
|
37
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
38
|
-
|
39
|
-
var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
|
40
|
-
var SidebarView = {
|
33
|
+
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
34
|
+
const SidebarView = {
|
41
35
|
UNKNOWN: -1,
|
42
36
|
NONE: 0,
|
43
37
|
THUMBS: 1,
|
@@ -47,21 +41,15 @@ var SidebarView = {
|
|
47
41
|
};
|
48
42
|
exports.SidebarView = SidebarView;
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
|
60
|
-
_ref$disableNotificat = _ref.disableNotification,
|
61
|
-
disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
|
62
|
-
|
63
|
-
_classCallCheck(this, PDFSidebar);
|
64
|
-
|
44
|
+
class PDFSidebar {
|
45
|
+
constructor({
|
46
|
+
elements,
|
47
|
+
pdfViewer,
|
48
|
+
pdfThumbnailViewer,
|
49
|
+
eventBus,
|
50
|
+
l10n = _ui_utils.NullL10n,
|
51
|
+
disableNotification = false
|
52
|
+
}) {
|
65
53
|
this.isOpen = false;
|
66
54
|
this.active = SidebarView.THUMBS;
|
67
55
|
this.isInitialViewSet = false;
|
@@ -74,9 +62,11 @@ function () {
|
|
74
62
|
this.thumbnailButton = elements.thumbnailButton;
|
75
63
|
this.outlineButton = elements.outlineButton;
|
76
64
|
this.attachmentsButton = elements.attachmentsButton;
|
65
|
+
this.layersButton = elements.layersButton;
|
77
66
|
this.thumbnailView = elements.thumbnailView;
|
78
67
|
this.outlineView = elements.outlineView;
|
79
68
|
this.attachmentsView = elements.attachmentsView;
|
69
|
+
this.layersView = elements.layersView;
|
80
70
|
this.eventBus = eventBus;
|
81
71
|
this.l10n = l10n;
|
82
72
|
this._disableNotification = disableNotification;
|
@@ -84,351 +74,345 @@ function () {
|
|
84
74
|
this._addEventListeners();
|
85
75
|
}
|
86
76
|
|
87
|
-
|
88
|
-
|
89
|
-
value: function reset() {
|
90
|
-
this.isInitialViewSet = false;
|
77
|
+
reset() {
|
78
|
+
this.isInitialViewSet = false;
|
91
79
|
|
92
|
-
|
80
|
+
this._hideUINotification(null);
|
93
81
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
}
|
99
|
-
key: "setInitialView",
|
100
|
-
value: function setInitialView() {
|
101
|
-
var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
|
82
|
+
this.switchView(SidebarView.THUMBS);
|
83
|
+
this.outlineButton.disabled = false;
|
84
|
+
this.attachmentsButton.disabled = false;
|
85
|
+
this.layersButton.disabled = false;
|
86
|
+
}
|
102
87
|
|
103
|
-
|
104
|
-
|
105
|
-
|
88
|
+
get visibleView() {
|
89
|
+
return this.isOpen ? this.active : SidebarView.NONE;
|
90
|
+
}
|
106
91
|
|
107
|
-
|
92
|
+
get isThumbnailViewVisible() {
|
93
|
+
return this.isOpen && this.active === SidebarView.THUMBS;
|
94
|
+
}
|
108
95
|
|
109
|
-
|
110
|
-
|
96
|
+
get isOutlineViewVisible() {
|
97
|
+
return this.isOpen && this.active === SidebarView.OUTLINE;
|
98
|
+
}
|
111
99
|
|
112
|
-
|
113
|
-
|
100
|
+
get isAttachmentsViewVisible() {
|
101
|
+
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
102
|
+
}
|
114
103
|
|
115
|
-
|
116
|
-
|
117
|
-
|
104
|
+
get isLayersViewVisible() {
|
105
|
+
return this.isOpen && this.active === SidebarView.LAYERS;
|
106
|
+
}
|
107
|
+
|
108
|
+
setInitialView(view = SidebarView.NONE) {
|
109
|
+
if (this.isInitialViewSet) {
|
110
|
+
return;
|
118
111
|
}
|
119
|
-
}, {
|
120
|
-
key: "switchView",
|
121
|
-
value: function switchView(view) {
|
122
|
-
var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
123
112
|
|
124
|
-
|
113
|
+
this.isInitialViewSet = true;
|
114
|
+
|
115
|
+
if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
|
116
|
+
this._dispatchEvent();
|
117
|
+
|
118
|
+
return;
|
125
119
|
}
|
126
|
-
}, {
|
127
|
-
key: "_switchView",
|
128
|
-
value: function _switchView(view) {
|
129
|
-
var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
130
|
-
var isViewChanged = view !== this.active;
|
131
|
-
var shouldForceRendering = false;
|
132
|
-
|
133
|
-
switch (view) {
|
134
|
-
case SidebarView.NONE:
|
135
|
-
if (this.isOpen) {
|
136
|
-
this.close();
|
137
|
-
return true;
|
138
|
-
}
|
139
120
|
|
140
|
-
|
121
|
+
if (!this._switchView(view, true)) {
|
122
|
+
this._dispatchEvent();
|
123
|
+
}
|
124
|
+
}
|
141
125
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
}
|
126
|
+
switchView(view, forceOpen = false) {
|
127
|
+
this._switchView(view, forceOpen);
|
128
|
+
}
|
146
129
|
|
147
|
-
|
130
|
+
_switchView(view, forceOpen = false) {
|
131
|
+
const isViewChanged = view !== this.active;
|
132
|
+
let shouldForceRendering = false;
|
148
133
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
134
|
+
switch (view) {
|
135
|
+
case SidebarView.NONE:
|
136
|
+
if (this.isOpen) {
|
137
|
+
this.close();
|
138
|
+
return true;
|
139
|
+
}
|
153
140
|
|
154
|
-
|
141
|
+
return false;
|
155
142
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
143
|
+
case SidebarView.THUMBS:
|
144
|
+
if (this.isOpen && isViewChanged) {
|
145
|
+
shouldForceRendering = true;
|
146
|
+
}
|
160
147
|
|
161
|
-
|
148
|
+
break;
|
162
149
|
|
163
|
-
|
164
|
-
|
150
|
+
case SidebarView.OUTLINE:
|
151
|
+
if (this.outlineButton.disabled) {
|
165
152
|
return false;
|
166
|
-
|
153
|
+
}
|
167
154
|
|
168
|
-
|
169
|
-
this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
|
170
|
-
this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
|
171
|
-
this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
|
172
|
-
this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
|
173
|
-
this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
|
174
|
-
this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
|
175
|
-
|
176
|
-
if (forceOpen && !this.isOpen) {
|
177
|
-
this.open();
|
178
|
-
return true;
|
179
|
-
}
|
155
|
+
break;
|
180
156
|
|
181
|
-
|
182
|
-
this.
|
157
|
+
case SidebarView.ATTACHMENTS:
|
158
|
+
if (this.attachmentsButton.disabled) {
|
159
|
+
return false;
|
160
|
+
}
|
183
161
|
|
184
|
-
|
185
|
-
}
|
162
|
+
break;
|
186
163
|
|
187
|
-
|
188
|
-
this.
|
189
|
-
|
164
|
+
case SidebarView.LAYERS:
|
165
|
+
if (this.layersButton.disabled) {
|
166
|
+
return false;
|
167
|
+
}
|
190
168
|
|
191
|
-
|
169
|
+
break;
|
192
170
|
|
193
|
-
|
171
|
+
default:
|
172
|
+
console.error(`PDFSidebar._switchView: "${view}" is not a valid view.`);
|
173
|
+
return false;
|
194
174
|
}
|
195
|
-
}, {
|
196
|
-
key: "open",
|
197
|
-
value: function open() {
|
198
|
-
if (this.isOpen) {
|
199
|
-
return;
|
200
|
-
}
|
201
175
|
|
202
|
-
|
203
|
-
|
204
|
-
|
176
|
+
this.active = view;
|
177
|
+
this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
|
178
|
+
this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
|
179
|
+
this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
|
180
|
+
this.layersButton.classList.toggle("toggled", view === SidebarView.LAYERS);
|
181
|
+
this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
|
182
|
+
this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
|
183
|
+
this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
|
184
|
+
this.layersView.classList.toggle("hidden", view !== SidebarView.LAYERS);
|
185
|
+
|
186
|
+
if (forceOpen && !this.isOpen) {
|
187
|
+
this.open();
|
188
|
+
return true;
|
189
|
+
}
|
205
190
|
|
206
|
-
|
207
|
-
|
208
|
-
}
|
191
|
+
if (shouldForceRendering) {
|
192
|
+
this._updateThumbnailViewer();
|
209
193
|
|
210
194
|
this._forceRendering();
|
195
|
+
}
|
211
196
|
|
197
|
+
if (isViewChanged) {
|
212
198
|
this._dispatchEvent();
|
199
|
+
}
|
213
200
|
|
214
|
-
|
201
|
+
this._hideUINotification(this.active);
|
202
|
+
|
203
|
+
return isViewChanged;
|
204
|
+
}
|
205
|
+
|
206
|
+
open() {
|
207
|
+
if (this.isOpen) {
|
208
|
+
return;
|
215
209
|
}
|
216
|
-
}, {
|
217
|
-
key: "close",
|
218
|
-
value: function close() {
|
219
|
-
if (!this.isOpen) {
|
220
|
-
return;
|
221
|
-
}
|
222
210
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
this.outerContainer.classList.remove('sidebarOpen');
|
211
|
+
this.isOpen = true;
|
212
|
+
this.toggleButton.classList.add("toggled");
|
213
|
+
this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
|
227
214
|
|
228
|
-
|
215
|
+
if (this.active === SidebarView.THUMBS) {
|
216
|
+
this._updateThumbnailViewer();
|
217
|
+
}
|
229
218
|
|
230
|
-
|
219
|
+
this._forceRendering();
|
220
|
+
|
221
|
+
this._dispatchEvent();
|
222
|
+
|
223
|
+
this._hideUINotification(this.active);
|
224
|
+
}
|
225
|
+
|
226
|
+
close() {
|
227
|
+
if (!this.isOpen) {
|
228
|
+
return;
|
231
229
|
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
230
|
+
|
231
|
+
this.isOpen = false;
|
232
|
+
this.toggleButton.classList.remove("toggled");
|
233
|
+
this.outerContainer.classList.add("sidebarMoving");
|
234
|
+
this.outerContainer.classList.remove("sidebarOpen");
|
235
|
+
|
236
|
+
this._forceRendering();
|
237
|
+
|
238
|
+
this._dispatchEvent();
|
239
|
+
}
|
240
|
+
|
241
|
+
toggle() {
|
242
|
+
if (this.isOpen) {
|
243
|
+
this.close();
|
244
|
+
} else {
|
245
|
+
this.open();
|
240
246
|
}
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
247
|
+
}
|
248
|
+
|
249
|
+
_dispatchEvent() {
|
250
|
+
this.eventBus.dispatch("sidebarviewchanged", {
|
251
|
+
source: this,
|
252
|
+
view: this.visibleView
|
253
|
+
});
|
254
|
+
}
|
255
|
+
|
256
|
+
_forceRendering() {
|
257
|
+
if (this.onToggled) {
|
258
|
+
this.onToggled();
|
259
|
+
} else {
|
260
|
+
this.pdfViewer.forceRendering();
|
261
|
+
this.pdfThumbnailViewer.forceRendering();
|
248
262
|
}
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
263
|
+
}
|
264
|
+
|
265
|
+
_updateThumbnailViewer() {
|
266
|
+
const {
|
267
|
+
pdfViewer,
|
268
|
+
pdfThumbnailViewer
|
269
|
+
} = this;
|
270
|
+
const pagesCount = pdfViewer.pagesCount;
|
271
|
+
|
272
|
+
for (let pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
|
273
|
+
const pageView = pdfViewer.getPageView(pageIndex);
|
274
|
+
|
275
|
+
if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
|
276
|
+
const thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
|
277
|
+
thumbnailView.setImage(pageView);
|
257
278
|
}
|
258
279
|
}
|
259
|
-
}, {
|
260
|
-
key: "_updateThumbnailViewer",
|
261
|
-
value: function _updateThumbnailViewer() {
|
262
|
-
var pdfViewer = this.pdfViewer,
|
263
|
-
pdfThumbnailViewer = this.pdfThumbnailViewer;
|
264
|
-
var pagesCount = pdfViewer.pagesCount;
|
265
|
-
|
266
|
-
for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
|
267
|
-
var pageView = pdfViewer.getPageView(pageIndex);
|
268
|
-
|
269
|
-
if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
|
270
|
-
var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
|
271
|
-
thumbnailView.setImage(pageView);
|
272
|
-
}
|
273
|
-
}
|
274
280
|
|
275
|
-
|
281
|
+
pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
|
282
|
+
}
|
283
|
+
|
284
|
+
_showUINotification(view) {
|
285
|
+
if (this._disableNotification) {
|
286
|
+
return;
|
276
287
|
}
|
277
|
-
}, {
|
278
|
-
key: "_showUINotification",
|
279
|
-
value: function _showUINotification(view) {
|
280
|
-
var _this = this;
|
281
288
|
|
282
|
-
|
283
|
-
|
284
|
-
|
289
|
+
this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(msg => {
|
290
|
+
this.toggleButton.title = msg;
|
291
|
+
});
|
285
292
|
|
286
|
-
|
287
|
-
|
288
|
-
|
293
|
+
if (!this.isOpen) {
|
294
|
+
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
|
295
|
+
} else if (view === this.active) {
|
296
|
+
return;
|
297
|
+
}
|
289
298
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
299
|
+
switch (view) {
|
300
|
+
case SidebarView.OUTLINE:
|
301
|
+
this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
|
302
|
+
break;
|
303
|
+
|
304
|
+
case SidebarView.ATTACHMENTS:
|
305
|
+
this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
|
306
|
+
break;
|
307
|
+
|
308
|
+
case SidebarView.LAYERS:
|
309
|
+
this.layersButton.classList.add(UI_NOTIFICATION_CLASS);
|
310
|
+
break;
|
311
|
+
}
|
312
|
+
}
|
295
313
|
|
296
|
-
|
314
|
+
_hideUINotification(view) {
|
315
|
+
if (this._disableNotification) {
|
316
|
+
return;
|
317
|
+
}
|
318
|
+
|
319
|
+
const removeNotification = sidebarView => {
|
320
|
+
switch (sidebarView) {
|
297
321
|
case SidebarView.OUTLINE:
|
298
|
-
this.outlineButton.classList.
|
322
|
+
this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
|
299
323
|
break;
|
300
324
|
|
301
325
|
case SidebarView.ATTACHMENTS:
|
302
|
-
this.attachmentsButton.classList.
|
326
|
+
this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
|
303
327
|
break;
|
304
|
-
}
|
305
|
-
}
|
306
|
-
}, {
|
307
|
-
key: "_hideUINotification",
|
308
|
-
value: function _hideUINotification(view) {
|
309
|
-
var _this2 = this;
|
310
328
|
|
311
|
-
|
312
|
-
|
329
|
+
case SidebarView.LAYERS:
|
330
|
+
this.layersButton.classList.remove(UI_NOTIFICATION_CLASS);
|
331
|
+
break;
|
313
332
|
}
|
333
|
+
};
|
314
334
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
_this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
|
319
|
-
|
320
|
-
break;
|
321
|
-
|
322
|
-
case SidebarView.ATTACHMENTS:
|
323
|
-
_this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
|
335
|
+
if (!this.isOpen && view !== null) {
|
336
|
+
return;
|
337
|
+
}
|
324
338
|
|
325
|
-
|
326
|
-
}
|
327
|
-
};
|
339
|
+
this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
|
328
340
|
|
329
|
-
|
330
|
-
|
331
|
-
|
341
|
+
if (view !== null) {
|
342
|
+
removeNotification(view);
|
343
|
+
return;
|
344
|
+
}
|
332
345
|
|
333
|
-
|
346
|
+
for (view in SidebarView) {
|
347
|
+
removeNotification(SidebarView[view]);
|
348
|
+
}
|
334
349
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
350
|
+
this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(msg => {
|
351
|
+
this.toggleButton.title = msg;
|
352
|
+
});
|
353
|
+
}
|
339
354
|
|
340
|
-
|
341
|
-
|
355
|
+
_addEventListeners() {
|
356
|
+
this.viewerContainer.addEventListener("transitionend", evt => {
|
357
|
+
if (evt.target === this.viewerContainer) {
|
358
|
+
this.outerContainer.classList.remove("sidebarMoving");
|
342
359
|
}
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
}
|
357
|
-
});
|
358
|
-
this.thumbnailButton.addEventListener('click', function () {
|
359
|
-
_this3.switchView(SidebarView.THUMBS);
|
360
|
-
});
|
361
|
-
this.outlineButton.addEventListener('click', function () {
|
362
|
-
_this3.switchView(SidebarView.OUTLINE);
|
363
|
-
});
|
364
|
-
this.outlineButton.addEventListener('dblclick', function () {
|
365
|
-
_this3.eventBus.dispatch('toggleoutlinetree', {
|
366
|
-
source: _this3
|
367
|
-
});
|
360
|
+
});
|
361
|
+
this.toggleButton.addEventListener("click", () => {
|
362
|
+
this.toggle();
|
363
|
+
});
|
364
|
+
this.thumbnailButton.addEventListener("click", () => {
|
365
|
+
this.switchView(SidebarView.THUMBS);
|
366
|
+
});
|
367
|
+
this.outlineButton.addEventListener("click", () => {
|
368
|
+
this.switchView(SidebarView.OUTLINE);
|
369
|
+
});
|
370
|
+
this.outlineButton.addEventListener("dblclick", () => {
|
371
|
+
this.eventBus.dispatch("toggleoutlinetree", {
|
372
|
+
source: this
|
368
373
|
});
|
369
|
-
|
370
|
-
|
374
|
+
});
|
375
|
+
this.attachmentsButton.addEventListener("click", () => {
|
376
|
+
this.switchView(SidebarView.ATTACHMENTS);
|
377
|
+
});
|
378
|
+
this.layersButton.addEventListener("click", () => {
|
379
|
+
this.switchView(SidebarView.LAYERS);
|
380
|
+
});
|
381
|
+
this.layersButton.addEventListener("dblclick", () => {
|
382
|
+
this.eventBus.dispatch("resetlayers", {
|
383
|
+
source: this
|
371
384
|
});
|
372
|
-
|
373
|
-
var outlineCount = evt.outlineCount;
|
374
|
-
_this3.outlineButton.disabled = !outlineCount;
|
375
|
-
|
376
|
-
if (outlineCount) {
|
377
|
-
_this3._showUINotification(SidebarView.OUTLINE);
|
378
|
-
} else if (_this3.active === SidebarView.OUTLINE) {
|
379
|
-
_this3.switchView(SidebarView.THUMBS);
|
380
|
-
}
|
381
|
-
});
|
382
|
-
this.eventBus.on('attachmentsloaded', function (evt) {
|
383
|
-
if (evt.attachmentsCount) {
|
384
|
-
_this3.attachmentsButton.disabled = false;
|
385
|
+
});
|
385
386
|
|
386
|
-
|
387
|
+
const onTreeLoaded = (count, button, view) => {
|
388
|
+
button.disabled = !count;
|
387
389
|
|
388
|
-
|
389
|
-
|
390
|
+
if (count) {
|
391
|
+
this._showUINotification(view);
|
392
|
+
} else if (this.active === view) {
|
393
|
+
this.switchView(SidebarView.THUMBS);
|
394
|
+
}
|
395
|
+
};
|
390
396
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
}
|
397
|
+
this.eventBus._on("outlineloaded", evt => {
|
398
|
+
onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE);
|
399
|
+
});
|
395
400
|
|
396
|
-
|
401
|
+
this.eventBus._on("attachmentsloaded", evt => {
|
402
|
+
onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS);
|
403
|
+
});
|
397
404
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
}
|
409
|
-
}, {
|
410
|
-
key: "visibleView",
|
411
|
-
get: function get() {
|
412
|
-
return this.isOpen ? this.active : SidebarView.NONE;
|
413
|
-
}
|
414
|
-
}, {
|
415
|
-
key: "isThumbnailViewVisible",
|
416
|
-
get: function get() {
|
417
|
-
return this.isOpen && this.active === SidebarView.THUMBS;
|
418
|
-
}
|
419
|
-
}, {
|
420
|
-
key: "isOutlineViewVisible",
|
421
|
-
get: function get() {
|
422
|
-
return this.isOpen && this.active === SidebarView.OUTLINE;
|
423
|
-
}
|
424
|
-
}, {
|
425
|
-
key: "isAttachmentsViewVisible",
|
426
|
-
get: function get() {
|
427
|
-
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
428
|
-
}
|
429
|
-
}]);
|
405
|
+
this.eventBus._on("layersloaded", evt => {
|
406
|
+
onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS);
|
407
|
+
});
|
408
|
+
|
409
|
+
this.eventBus._on("presentationmodechanged", evt => {
|
410
|
+
if (!evt.active && !evt.switchInProgress && this.isThumbnailViewVisible) {
|
411
|
+
this._updateThumbnailViewer();
|
412
|
+
}
|
413
|
+
});
|
414
|
+
}
|
430
415
|
|
431
|
-
|
432
|
-
}();
|
416
|
+
}
|
433
417
|
|
434
418
|
exports.PDFSidebar = PDFSidebar;
|