pdfjs-dist 2.0.943 → 2.4.456
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
package/lib/web/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.
|
@@ -19,355 +19,379 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFSidebar = exports.SidebarView =
|
27
|
+
exports.PDFSidebar = exports.SidebarView = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _ui_utils = require("./ui_utils.js");
|
30
30
|
|
31
|
-
var
|
31
|
+
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
|
38
|
-
var SidebarView = {
|
33
|
+
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
34
|
+
const SidebarView = {
|
35
|
+
UNKNOWN: -1,
|
39
36
|
NONE: 0,
|
40
37
|
THUMBS: 1,
|
41
38
|
OUTLINE: 2,
|
42
|
-
ATTACHMENTS: 3
|
39
|
+
ATTACHMENTS: 3,
|
40
|
+
LAYERS: 4
|
43
41
|
};
|
42
|
+
exports.SidebarView = SidebarView;
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
class PDFSidebar {
|
45
|
+
constructor({
|
46
|
+
elements,
|
47
|
+
pdfViewer,
|
48
|
+
pdfThumbnailViewer,
|
49
|
+
eventBus,
|
50
|
+
l10n = _ui_utils.NullL10n,
|
51
|
+
disableNotification = false
|
52
|
+
}) {
|
51
53
|
this.isOpen = false;
|
52
54
|
this.active = SidebarView.THUMBS;
|
53
55
|
this.isInitialViewSet = false;
|
54
56
|
this.onToggled = null;
|
55
|
-
this.pdfViewer =
|
56
|
-
this.pdfThumbnailViewer =
|
57
|
-
this.outerContainer =
|
58
|
-
this.viewerContainer =
|
59
|
-
this.toggleButton =
|
60
|
-
this.thumbnailButton =
|
61
|
-
this.outlineButton =
|
62
|
-
this.attachmentsButton =
|
63
|
-
this.thumbnailView =
|
64
|
-
this.outlineView =
|
65
|
-
this.attachmentsView =
|
66
|
-
this.disableNotification = options.disableNotification || false;
|
57
|
+
this.pdfViewer = pdfViewer;
|
58
|
+
this.pdfThumbnailViewer = pdfThumbnailViewer;
|
59
|
+
this.outerContainer = elements.outerContainer;
|
60
|
+
this.viewerContainer = elements.viewerContainer;
|
61
|
+
this.toggleButton = elements.toggleButton;
|
62
|
+
this.thumbnailButton = elements.thumbnailButton;
|
63
|
+
this.outlineButton = elements.outlineButton;
|
64
|
+
this.attachmentsButton = elements.attachmentsButton;
|
65
|
+
this.thumbnailView = elements.thumbnailView;
|
66
|
+
this.outlineView = elements.outlineView;
|
67
|
+
this.attachmentsView = elements.attachmentsView;
|
67
68
|
this.eventBus = eventBus;
|
68
69
|
this.l10n = l10n;
|
70
|
+
this._disableNotification = disableNotification;
|
71
|
+
|
69
72
|
this._addEventListeners();
|
70
73
|
}
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
value: function reset() {
|
75
|
-
this.isInitialViewSet = false;
|
76
|
-
this._hideUINotification(null);
|
77
|
-
this.switchView(SidebarView.THUMBS);
|
78
|
-
this.outlineButton.disabled = false;
|
79
|
-
this.attachmentsButton.disabled = false;
|
80
|
-
}
|
81
|
-
}, {
|
82
|
-
key: 'setInitialView',
|
83
|
-
value: function setInitialView() {
|
84
|
-
var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
|
75
|
+
reset() {
|
76
|
+
this.isInitialViewSet = false;
|
85
77
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
78
|
+
this._hideUINotification(null);
|
79
|
+
|
80
|
+
this.switchView(SidebarView.THUMBS);
|
81
|
+
this.outlineButton.disabled = false;
|
82
|
+
this.attachmentsButton.disabled = false;
|
83
|
+
}
|
84
|
+
|
85
|
+
get visibleView() {
|
86
|
+
return this.isOpen ? this.active : SidebarView.NONE;
|
87
|
+
}
|
88
|
+
|
89
|
+
get isThumbnailViewVisible() {
|
90
|
+
return this.isOpen && this.active === SidebarView.THUMBS;
|
91
|
+
}
|
92
|
+
|
93
|
+
get isOutlineViewVisible() {
|
94
|
+
return this.isOpen && this.active === SidebarView.OUTLINE;
|
95
|
+
}
|
96
|
+
|
97
|
+
get isAttachmentsViewVisible() {
|
98
|
+
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
99
|
+
}
|
100
|
+
|
101
|
+
setInitialView(view = SidebarView.NONE) {
|
102
|
+
if (this.isInitialViewSet) {
|
103
|
+
return;
|
99
104
|
}
|
100
|
-
}, {
|
101
|
-
key: 'switchView',
|
102
|
-
value: function switchView(view) {
|
103
|
-
var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
switch (view) {
|
112
|
-
case SidebarView.THUMBS:
|
113
|
-
this.thumbnailButton.classList.add('toggled');
|
114
|
-
this.outlineButton.classList.remove('toggled');
|
115
|
-
this.attachmentsButton.classList.remove('toggled');
|
116
|
-
this.thumbnailView.classList.remove('hidden');
|
117
|
-
this.outlineView.classList.add('hidden');
|
118
|
-
this.attachmentsView.classList.add('hidden');
|
119
|
-
if (this.isOpen && isViewChanged) {
|
120
|
-
this._updateThumbnailViewer();
|
121
|
-
shouldForceRendering = true;
|
122
|
-
}
|
123
|
-
break;
|
124
|
-
case SidebarView.OUTLINE:
|
125
|
-
if (this.outlineButton.disabled) {
|
126
|
-
return;
|
127
|
-
}
|
128
|
-
this.thumbnailButton.classList.remove('toggled');
|
129
|
-
this.outlineButton.classList.add('toggled');
|
130
|
-
this.attachmentsButton.classList.remove('toggled');
|
131
|
-
this.thumbnailView.classList.add('hidden');
|
132
|
-
this.outlineView.classList.remove('hidden');
|
133
|
-
this.attachmentsView.classList.add('hidden');
|
134
|
-
break;
|
135
|
-
case SidebarView.ATTACHMENTS:
|
136
|
-
if (this.attachmentsButton.disabled) {
|
137
|
-
return;
|
138
|
-
}
|
139
|
-
this.thumbnailButton.classList.remove('toggled');
|
140
|
-
this.outlineButton.classList.remove('toggled');
|
141
|
-
this.attachmentsButton.classList.add('toggled');
|
142
|
-
this.thumbnailView.classList.add('hidden');
|
143
|
-
this.outlineView.classList.add('hidden');
|
144
|
-
this.attachmentsView.classList.remove('hidden');
|
145
|
-
break;
|
146
|
-
default:
|
147
|
-
console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
|
148
|
-
return;
|
149
|
-
}
|
150
|
-
this.active = view | 0;
|
151
|
-
if (forceOpen && !this.isOpen) {
|
152
|
-
this.open();
|
153
|
-
return;
|
154
|
-
}
|
155
|
-
if (shouldForceRendering) {
|
156
|
-
this._forceRendering();
|
157
|
-
}
|
158
|
-
if (isViewChanged) {
|
159
|
-
this._dispatchEvent();
|
160
|
-
}
|
161
|
-
this._hideUINotification(this.active);
|
106
|
+
this.isInitialViewSet = true;
|
107
|
+
|
108
|
+
if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
|
109
|
+
this._dispatchEvent();
|
110
|
+
|
111
|
+
return;
|
162
112
|
}
|
163
|
-
|
164
|
-
|
165
|
-
value: function open() {
|
166
|
-
if (this.isOpen) {
|
167
|
-
return;
|
168
|
-
}
|
169
|
-
this.isOpen = true;
|
170
|
-
this.toggleButton.classList.add('toggled');
|
171
|
-
this.outerContainer.classList.add('sidebarMoving');
|
172
|
-
this.outerContainer.classList.add('sidebarOpen');
|
173
|
-
if (this.active === SidebarView.THUMBS) {
|
174
|
-
this._updateThumbnailViewer();
|
175
|
-
}
|
176
|
-
this._forceRendering();
|
113
|
+
|
114
|
+
if (!this._switchView(view, true)) {
|
177
115
|
this._dispatchEvent();
|
178
|
-
this._hideUINotification(this.active);
|
179
116
|
}
|
180
|
-
}
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
117
|
+
}
|
118
|
+
|
119
|
+
switchView(view, forceOpen = false) {
|
120
|
+
this._switchView(view, forceOpen);
|
121
|
+
}
|
122
|
+
|
123
|
+
_switchView(view, forceOpen = false) {
|
124
|
+
const isViewChanged = view !== this.active;
|
125
|
+
let shouldForceRendering = false;
|
126
|
+
|
127
|
+
switch (view) {
|
128
|
+
case SidebarView.NONE:
|
129
|
+
if (this.isOpen) {
|
130
|
+
this.close();
|
131
|
+
return true;
|
132
|
+
}
|
133
|
+
|
134
|
+
return false;
|
135
|
+
|
136
|
+
case SidebarView.THUMBS:
|
137
|
+
if (this.isOpen && isViewChanged) {
|
138
|
+
shouldForceRendering = true;
|
139
|
+
}
|
140
|
+
|
141
|
+
break;
|
142
|
+
|
143
|
+
case SidebarView.OUTLINE:
|
144
|
+
if (this.outlineButton.disabled) {
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
|
148
|
+
break;
|
149
|
+
|
150
|
+
case SidebarView.ATTACHMENTS:
|
151
|
+
if (this.attachmentsButton.disabled) {
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
|
155
|
+
break;
|
156
|
+
|
157
|
+
default:
|
158
|
+
console.error(`PDFSidebar._switchView: "${view}" is not a valid view.`);
|
159
|
+
return false;
|
160
|
+
}
|
161
|
+
|
162
|
+
this.active = view;
|
163
|
+
this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
|
164
|
+
this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
|
165
|
+
this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
|
166
|
+
this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
|
167
|
+
this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
|
168
|
+
this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
|
169
|
+
|
170
|
+
if (forceOpen && !this.isOpen) {
|
171
|
+
this.open();
|
172
|
+
return true;
|
173
|
+
}
|
174
|
+
|
175
|
+
if (shouldForceRendering) {
|
176
|
+
this._updateThumbnailViewer();
|
177
|
+
|
190
178
|
this._forceRendering();
|
179
|
+
}
|
180
|
+
|
181
|
+
if (isViewChanged) {
|
191
182
|
this._dispatchEvent();
|
192
183
|
}
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
184
|
+
|
185
|
+
this._hideUINotification(this.active);
|
186
|
+
|
187
|
+
return isViewChanged;
|
188
|
+
}
|
189
|
+
|
190
|
+
open() {
|
191
|
+
if (this.isOpen) {
|
192
|
+
return;
|
201
193
|
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
194
|
+
|
195
|
+
this.isOpen = true;
|
196
|
+
this.toggleButton.classList.add("toggled");
|
197
|
+
this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
|
198
|
+
|
199
|
+
if (this.active === SidebarView.THUMBS) {
|
200
|
+
this._updateThumbnailViewer();
|
209
201
|
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
202
|
+
|
203
|
+
this._forceRendering();
|
204
|
+
|
205
|
+
this._dispatchEvent();
|
206
|
+
|
207
|
+
this._hideUINotification(this.active);
|
208
|
+
}
|
209
|
+
|
210
|
+
close() {
|
211
|
+
if (!this.isOpen) {
|
212
|
+
return;
|
219
213
|
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
214
|
+
|
215
|
+
this.isOpen = false;
|
216
|
+
this.toggleButton.classList.remove("toggled");
|
217
|
+
this.outerContainer.classList.add("sidebarMoving");
|
218
|
+
this.outerContainer.classList.remove("sidebarOpen");
|
219
|
+
|
220
|
+
this._forceRendering();
|
221
|
+
|
222
|
+
this._dispatchEvent();
|
223
|
+
}
|
224
|
+
|
225
|
+
toggle() {
|
226
|
+
if (this.isOpen) {
|
227
|
+
this.close();
|
228
|
+
} else {
|
229
|
+
this.open();
|
235
230
|
}
|
236
|
-
}
|
237
|
-
key: '_showUINotification',
|
238
|
-
value: function _showUINotification(view) {
|
239
|
-
var _this = this;
|
231
|
+
}
|
240
232
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
this.
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
233
|
+
_dispatchEvent() {
|
234
|
+
this.eventBus.dispatch("sidebarviewchanged", {
|
235
|
+
source: this,
|
236
|
+
view: this.visibleView
|
237
|
+
});
|
238
|
+
}
|
239
|
+
|
240
|
+
_forceRendering() {
|
241
|
+
if (this.onToggled) {
|
242
|
+
this.onToggled();
|
243
|
+
} else {
|
244
|
+
this.pdfViewer.forceRendering();
|
245
|
+
this.pdfThumbnailViewer.forceRendering();
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
_updateThumbnailViewer() {
|
250
|
+
const {
|
251
|
+
pdfViewer,
|
252
|
+
pdfThumbnailViewer
|
253
|
+
} = this;
|
254
|
+
const pagesCount = pdfViewer.pagesCount;
|
255
|
+
|
256
|
+
for (let pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
|
257
|
+
const pageView = pdfViewer.getPageView(pageIndex);
|
258
|
+
|
259
|
+
if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
|
260
|
+
const thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
|
261
|
+
thumbnailView.setImage(pageView);
|
251
262
|
}
|
252
|
-
|
263
|
+
}
|
264
|
+
|
265
|
+
pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
|
266
|
+
}
|
267
|
+
|
268
|
+
_showUINotification(view) {
|
269
|
+
if (this._disableNotification) {
|
270
|
+
return;
|
271
|
+
}
|
272
|
+
|
273
|
+
this.l10n.get("toggle_sidebar_notification.title", null, "Toggle Sidebar (document contains outline/attachments)").then(msg => {
|
274
|
+
this.toggleButton.title = msg;
|
275
|
+
});
|
276
|
+
|
277
|
+
if (!this.isOpen) {
|
278
|
+
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
|
279
|
+
} else if (view === this.active) {
|
280
|
+
return;
|
281
|
+
}
|
282
|
+
|
283
|
+
switch (view) {
|
284
|
+
case SidebarView.OUTLINE:
|
285
|
+
this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
|
286
|
+
break;
|
287
|
+
|
288
|
+
case SidebarView.ATTACHMENTS:
|
289
|
+
this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
|
290
|
+
break;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
_hideUINotification(view) {
|
295
|
+
if (this._disableNotification) {
|
296
|
+
return;
|
297
|
+
}
|
298
|
+
|
299
|
+
const removeNotification = sidebarView => {
|
300
|
+
switch (sidebarView) {
|
253
301
|
case SidebarView.OUTLINE:
|
254
|
-
this.outlineButton.classList.
|
302
|
+
this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
|
255
303
|
break;
|
304
|
+
|
256
305
|
case SidebarView.ATTACHMENTS:
|
257
|
-
this.attachmentsButton.classList.
|
306
|
+
this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
|
258
307
|
break;
|
259
308
|
}
|
309
|
+
};
|
310
|
+
|
311
|
+
if (!this.isOpen && view !== null) {
|
312
|
+
return;
|
260
313
|
}
|
261
|
-
}, {
|
262
|
-
key: '_hideUINotification',
|
263
|
-
value: function _hideUINotification(view) {
|
264
|
-
var _this2 = this;
|
265
314
|
|
266
|
-
|
267
|
-
|
315
|
+
this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
|
316
|
+
|
317
|
+
if (view !== null) {
|
318
|
+
removeNotification(view);
|
319
|
+
return;
|
320
|
+
}
|
321
|
+
|
322
|
+
for (view in SidebarView) {
|
323
|
+
removeNotification(SidebarView[view]);
|
324
|
+
}
|
325
|
+
|
326
|
+
this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(msg => {
|
327
|
+
this.toggleButton.title = msg;
|
328
|
+
});
|
329
|
+
}
|
330
|
+
|
331
|
+
_addEventListeners() {
|
332
|
+
this.viewerContainer.addEventListener("transitionend", evt => {
|
333
|
+
if (evt.target === this.viewerContainer) {
|
334
|
+
this.outerContainer.classList.remove("sidebarMoving");
|
268
335
|
}
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
336
|
+
});
|
337
|
+
this.toggleButton.addEventListener("click", () => {
|
338
|
+
this.toggle();
|
339
|
+
});
|
340
|
+
this.thumbnailButton.addEventListener("click", () => {
|
341
|
+
this.switchView(SidebarView.THUMBS);
|
342
|
+
});
|
343
|
+
this.outlineButton.addEventListener("click", () => {
|
344
|
+
this.switchView(SidebarView.OUTLINE);
|
345
|
+
});
|
346
|
+
this.outlineButton.addEventListener("dblclick", () => {
|
347
|
+
this.eventBus.dispatch("toggleoutlinetree", {
|
348
|
+
source: this
|
349
|
+
});
|
350
|
+
});
|
351
|
+
this.attachmentsButton.addEventListener("click", () => {
|
352
|
+
this.switchView(SidebarView.ATTACHMENTS);
|
353
|
+
});
|
354
|
+
|
355
|
+
this.eventBus._on("outlineloaded", evt => {
|
356
|
+
const outlineCount = evt.outlineCount;
|
357
|
+
this.outlineButton.disabled = !outlineCount;
|
358
|
+
|
359
|
+
if (outlineCount) {
|
360
|
+
this._showUINotification(SidebarView.OUTLINE);
|
361
|
+
} else if (this.active === SidebarView.OUTLINE) {
|
362
|
+
this.switchView(SidebarView.THUMBS);
|
281
363
|
}
|
282
|
-
|
283
|
-
|
284
|
-
|
364
|
+
});
|
365
|
+
|
366
|
+
this.eventBus._on("attachmentsloaded", evt => {
|
367
|
+
if (evt.attachmentsCount) {
|
368
|
+
this.attachmentsButton.disabled = false;
|
369
|
+
|
370
|
+
this._showUINotification(SidebarView.ATTACHMENTS);
|
371
|
+
|
285
372
|
return;
|
286
373
|
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
|
291
|
-
_this2.toggleButton.title = msg;
|
292
|
-
});
|
293
|
-
}
|
294
|
-
}, {
|
295
|
-
key: '_addEventListeners',
|
296
|
-
value: function _addEventListeners() {
|
297
|
-
var _this3 = this;
|
298
|
-
|
299
|
-
this.viewerContainer.addEventListener('transitionend', function (evt) {
|
300
|
-
if (evt.target === _this3.viewerContainer) {
|
301
|
-
_this3.outerContainer.classList.remove('sidebarMoving');
|
302
|
-
}
|
303
|
-
});
|
304
|
-
this.thumbnailButton.addEventListener('click', function () {
|
305
|
-
_this3.switchView(SidebarView.THUMBS);
|
306
|
-
});
|
307
|
-
this.outlineButton.addEventListener('click', function () {
|
308
|
-
_this3.switchView(SidebarView.OUTLINE);
|
309
|
-
});
|
310
|
-
this.outlineButton.addEventListener('dblclick', function () {
|
311
|
-
_this3.eventBus.dispatch('toggleoutlinetree', { source: _this3 });
|
312
|
-
});
|
313
|
-
this.attachmentsButton.addEventListener('click', function () {
|
314
|
-
_this3.switchView(SidebarView.ATTACHMENTS);
|
315
|
-
});
|
316
|
-
this.eventBus.on('outlineloaded', function (evt) {
|
317
|
-
var outlineCount = evt.outlineCount;
|
318
|
-
_this3.outlineButton.disabled = !outlineCount;
|
319
|
-
if (outlineCount) {
|
320
|
-
_this3._showUINotification(SidebarView.OUTLINE);
|
321
|
-
} else if (_this3.active === SidebarView.OUTLINE) {
|
322
|
-
_this3.switchView(SidebarView.THUMBS);
|
323
|
-
}
|
324
|
-
});
|
325
|
-
this.eventBus.on('attachmentsloaded', function (evt) {
|
326
|
-
if (evt.attachmentsCount) {
|
327
|
-
_this3.attachmentsButton.disabled = false;
|
328
|
-
_this3._showUINotification(SidebarView.ATTACHMENTS);
|
374
|
+
|
375
|
+
Promise.resolve().then(() => {
|
376
|
+
if (this.attachmentsView.hasChildNodes()) {
|
329
377
|
return;
|
330
378
|
}
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
if (_this3.active === SidebarView.ATTACHMENTS) {
|
337
|
-
_this3.switchView(SidebarView.THUMBS);
|
338
|
-
}
|
339
|
-
});
|
340
|
-
});
|
341
|
-
this.eventBus.on('presentationmodechanged', function (evt) {
|
342
|
-
if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
|
343
|
-
_this3._updateThumbnailViewer();
|
379
|
+
|
380
|
+
this.attachmentsButton.disabled = true;
|
381
|
+
|
382
|
+
if (this.active === SidebarView.ATTACHMENTS) {
|
383
|
+
this.switchView(SidebarView.THUMBS);
|
344
384
|
}
|
345
385
|
});
|
346
|
-
}
|
347
|
-
}, {
|
348
|
-
key: 'visibleView',
|
349
|
-
get: function get() {
|
350
|
-
return this.isOpen ? this.active : SidebarView.NONE;
|
351
|
-
}
|
352
|
-
}, {
|
353
|
-
key: 'isThumbnailViewVisible',
|
354
|
-
get: function get() {
|
355
|
-
return this.isOpen && this.active === SidebarView.THUMBS;
|
356
|
-
}
|
357
|
-
}, {
|
358
|
-
key: 'isOutlineViewVisible',
|
359
|
-
get: function get() {
|
360
|
-
return this.isOpen && this.active === SidebarView.OUTLINE;
|
361
|
-
}
|
362
|
-
}, {
|
363
|
-
key: 'isAttachmentsViewVisible',
|
364
|
-
get: function get() {
|
365
|
-
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
366
|
-
}
|
367
|
-
}]);
|
386
|
+
});
|
368
387
|
|
369
|
-
|
370
|
-
|
388
|
+
this.eventBus._on("presentationmodechanged", evt => {
|
389
|
+
if (!evt.active && !evt.switchInProgress && this.isThumbnailViewVisible) {
|
390
|
+
this._updateThumbnailViewer();
|
391
|
+
}
|
392
|
+
});
|
393
|
+
}
|
394
|
+
|
395
|
+
}
|
371
396
|
|
372
|
-
exports.SidebarView = SidebarView;
|
373
397
|
exports.PDFSidebar = PDFSidebar;
|