pdfjs-dist 2.0.487 → 2.1.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/bower.json +1 -1
- package/build/pdf.js +15564 -9476
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +46644 -36309
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11430 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +406 -131
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +376 -53
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +387 -149
- package/lib/core/cmap.js +310 -75
- package/lib/core/colorspace.js +874 -594
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +545 -260
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +725 -147
- package/lib/core/font_renderer.js +360 -91
- package/lib/core/fonts.js +791 -186
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +3 -2
- package/lib/core/image.js +168 -61
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +252 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +4 -4
- package/lib/core/murmurhash3.js +24 -6
- package/lib/core/obj.js +1137 -475
- package/lib/core/operator_list.js +108 -6
- package/lib/core/parser.js +321 -68
- package/lib/core/pattern.js +145 -13
- package/lib/core/pdf_manager.js +321 -133
- package/lib/core/primitives.js +75 -22
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +10 -10
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +31 -4
- package/lib/core/worker.js +210 -66
- package/lib/display/annotation_layer.js +361 -123
- package/lib/display/api.js +1454 -729
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +324 -29
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/dom_utils.js +226 -41
- package/lib/display/fetch_stream.js +208 -84
- package/lib/display/font_loader.js +465 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +216 -51
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +352 -169
- package/lib/display/pattern_helper.js +58 -7
- package/lib/display/svg.js +242 -29
- package/lib/display/text_layer.js +132 -18
- package/lib/display/transport_stream.js +171 -42
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +57 -4
- package/lib/pdf.js +21 -4
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +295 -650
- package/lib/test/unit/annotation_spec.js +629 -345
- package/lib/test/unit/api_spec.js +555 -253
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +40 -11
- package/lib/test/unit/clitests_helper.js +9 -7
- package/lib/test/unit/cmap_spec.js +80 -26
- package/lib/test/unit/colorspace_spec.js +99 -52
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +41 -53
- package/lib/test/unit/display_svg_spec.js +33 -17
- package/lib/test/unit/document_spec.js +3 -3
- package/lib/test/unit/dom_utils_spec.js +9 -9
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +34 -9
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +31 -18
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +20 -5
- package/lib/test/unit/network_utils_spec.js +41 -14
- package/lib/test/unit/node_stream_spec.js +51 -27
- package/lib/test/unit/parser_spec.js +35 -8
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +24 -4
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +90 -27
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +8 -6
- package/lib/test/unit/ui_utils_spec.js +452 -14
- package/lib/test/unit/unicode_spec.js +14 -11
- package/lib/test/unit/util_spec.js +131 -9
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1240 -582
- package/lib/web/app_options.js +71 -41
- package/lib/web/base_viewer.js +508 -179
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -13
- package/lib/web/firefox_print_service.js +17 -9
- package/lib/web/firefoxcom.js +283 -79
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +26 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +21 -13
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +80 -30
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +137 -76
- package/lib/web/pdf_outline_viewer.js +73 -22
- package/lib/web/pdf_page_view.js +196 -63
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +57 -11
- package/lib/web/pdf_rendering_queue.js +27 -5
- package/lib/web/pdf_sidebar.js +120 -67
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +103 -32
- package/lib/web/pdf_thumbnail_viewer.js +64 -24
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +275 -80
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +162 -65
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +58 -1
- package/web/pdf_viewer.js +6346 -3919
- package/web/pdf_viewer.js.map +1 -1
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
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 2018 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,32 +19,39 @@
|
|
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");
|
30
30
|
|
31
|
-
var
|
32
|
-
|
33
|
-
var _pdf_rendering_queue = require('./pdf_rendering_queue');
|
31
|
+
var _pdf_rendering_queue = require("./pdf_rendering_queue");
|
34
32
|
|
35
33
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
36
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
|
+
|
37
39
|
var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
|
38
40
|
var SidebarView = {
|
41
|
+
UNKNOWN: -1,
|
39
42
|
NONE: 0,
|
40
43
|
THUMBS: 1,
|
41
44
|
OUTLINE: 2,
|
42
|
-
ATTACHMENTS: 3
|
45
|
+
ATTACHMENTS: 3,
|
46
|
+
LAYERS: 4
|
43
47
|
};
|
48
|
+
exports.SidebarView = SidebarView;
|
44
49
|
|
45
|
-
var PDFSidebar =
|
46
|
-
|
47
|
-
|
50
|
+
var PDFSidebar =
|
51
|
+
/*#__PURE__*/
|
52
|
+
function () {
|
53
|
+
function PDFSidebar(options, eventBus) {
|
54
|
+
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
|
48
55
|
|
49
56
|
_classCallCheck(this, PDFSidebar);
|
50
57
|
|
@@ -54,10 +61,8 @@ var PDFSidebar = function () {
|
|
54
61
|
this.onToggled = null;
|
55
62
|
this.pdfViewer = options.pdfViewer;
|
56
63
|
this.pdfThumbnailViewer = options.pdfThumbnailViewer;
|
57
|
-
this.pdfOutlineViewer = options.pdfOutlineViewer;
|
58
64
|
this.outerContainer = options.outerContainer;
|
59
65
|
this.viewerContainer = options.viewerContainer;
|
60
|
-
this.eventBus = options.eventBus;
|
61
66
|
this.toggleButton = options.toggleButton;
|
62
67
|
this.thumbnailButton = options.thumbnailButton;
|
63
68
|
this.outlineButton = options.outlineButton;
|
@@ -66,133 +71,159 @@ var PDFSidebar = function () {
|
|
66
71
|
this.outlineView = options.outlineView;
|
67
72
|
this.attachmentsView = options.attachmentsView;
|
68
73
|
this.disableNotification = options.disableNotification || false;
|
74
|
+
this.eventBus = eventBus;
|
69
75
|
this.l10n = l10n;
|
76
|
+
|
70
77
|
this._addEventListeners();
|
71
78
|
}
|
72
79
|
|
73
80
|
_createClass(PDFSidebar, [{
|
74
|
-
key:
|
81
|
+
key: "reset",
|
75
82
|
value: function reset() {
|
76
83
|
this.isInitialViewSet = false;
|
84
|
+
|
77
85
|
this._hideUINotification(null);
|
86
|
+
|
78
87
|
this.switchView(SidebarView.THUMBS);
|
79
88
|
this.outlineButton.disabled = false;
|
80
89
|
this.attachmentsButton.disabled = false;
|
81
90
|
}
|
82
91
|
}, {
|
83
|
-
key:
|
92
|
+
key: "setInitialView",
|
84
93
|
value: function setInitialView() {
|
85
94
|
var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
|
86
95
|
|
87
96
|
if (this.isInitialViewSet) {
|
88
97
|
return;
|
89
98
|
}
|
99
|
+
|
90
100
|
this.isInitialViewSet = true;
|
91
|
-
|
101
|
+
|
102
|
+
if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
|
92
103
|
this._dispatchEvent();
|
104
|
+
|
93
105
|
return;
|
94
106
|
}
|
95
|
-
|
96
|
-
this.
|
97
|
-
if (isViewPreserved) {
|
107
|
+
|
108
|
+
if (!this._switchView(view, true)) {
|
98
109
|
this._dispatchEvent();
|
99
110
|
}
|
100
111
|
}
|
101
112
|
}, {
|
102
|
-
key:
|
113
|
+
key: "switchView",
|
103
114
|
value: function switchView(view) {
|
104
115
|
var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
105
116
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
117
|
+
this._switchView(view, forceOpen);
|
118
|
+
}
|
119
|
+
}, {
|
120
|
+
key: "_switchView",
|
121
|
+
value: function _switchView(view) {
|
122
|
+
var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
110
123
|
var isViewChanged = view !== this.active;
|
111
124
|
var shouldForceRendering = false;
|
125
|
+
|
112
126
|
switch (view) {
|
127
|
+
case SidebarView.NONE:
|
128
|
+
if (this.isOpen) {
|
129
|
+
this.close();
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
|
133
|
+
return false;
|
134
|
+
|
113
135
|
case SidebarView.THUMBS:
|
114
|
-
this.thumbnailButton.classList.add('toggled');
|
115
|
-
this.outlineButton.classList.remove('toggled');
|
116
|
-
this.attachmentsButton.classList.remove('toggled');
|
117
|
-
this.thumbnailView.classList.remove('hidden');
|
118
|
-
this.outlineView.classList.add('hidden');
|
119
|
-
this.attachmentsView.classList.add('hidden');
|
120
136
|
if (this.isOpen && isViewChanged) {
|
121
|
-
this._updateThumbnailViewer();
|
122
137
|
shouldForceRendering = true;
|
123
138
|
}
|
139
|
+
|
124
140
|
break;
|
141
|
+
|
125
142
|
case SidebarView.OUTLINE:
|
126
143
|
if (this.outlineButton.disabled) {
|
127
|
-
return;
|
144
|
+
return false;
|
128
145
|
}
|
129
|
-
|
130
|
-
this.outlineButton.classList.add('toggled');
|
131
|
-
this.attachmentsButton.classList.remove('toggled');
|
132
|
-
this.thumbnailView.classList.add('hidden');
|
133
|
-
this.outlineView.classList.remove('hidden');
|
134
|
-
this.attachmentsView.classList.add('hidden');
|
146
|
+
|
135
147
|
break;
|
148
|
+
|
136
149
|
case SidebarView.ATTACHMENTS:
|
137
150
|
if (this.attachmentsButton.disabled) {
|
138
|
-
return;
|
151
|
+
return false;
|
139
152
|
}
|
140
|
-
|
141
|
-
this.outlineButton.classList.remove('toggled');
|
142
|
-
this.attachmentsButton.classList.add('toggled');
|
143
|
-
this.thumbnailView.classList.add('hidden');
|
144
|
-
this.outlineView.classList.add('hidden');
|
145
|
-
this.attachmentsView.classList.remove('hidden');
|
153
|
+
|
146
154
|
break;
|
155
|
+
|
147
156
|
default:
|
148
|
-
console.error(
|
149
|
-
return;
|
157
|
+
console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
|
158
|
+
return false;
|
150
159
|
}
|
151
|
-
|
160
|
+
|
161
|
+
this.active = view;
|
162
|
+
this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
|
163
|
+
this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
|
164
|
+
this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
|
165
|
+
this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
|
166
|
+
this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
|
167
|
+
this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
|
168
|
+
|
152
169
|
if (forceOpen && !this.isOpen) {
|
153
170
|
this.open();
|
154
|
-
return;
|
171
|
+
return true;
|
155
172
|
}
|
173
|
+
|
156
174
|
if (shouldForceRendering) {
|
175
|
+
this._updateThumbnailViewer();
|
176
|
+
|
157
177
|
this._forceRendering();
|
158
178
|
}
|
179
|
+
|
159
180
|
if (isViewChanged) {
|
160
181
|
this._dispatchEvent();
|
161
182
|
}
|
183
|
+
|
162
184
|
this._hideUINotification(this.active);
|
185
|
+
|
186
|
+
return isViewChanged;
|
163
187
|
}
|
164
188
|
}, {
|
165
|
-
key:
|
189
|
+
key: "open",
|
166
190
|
value: function open() {
|
167
191
|
if (this.isOpen) {
|
168
192
|
return;
|
169
193
|
}
|
194
|
+
|
170
195
|
this.isOpen = true;
|
171
196
|
this.toggleButton.classList.add('toggled');
|
172
|
-
this.outerContainer.classList.add('sidebarMoving');
|
173
|
-
|
197
|
+
this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
|
198
|
+
|
174
199
|
if (this.active === SidebarView.THUMBS) {
|
175
200
|
this._updateThumbnailViewer();
|
176
201
|
}
|
202
|
+
|
177
203
|
this._forceRendering();
|
204
|
+
|
178
205
|
this._dispatchEvent();
|
206
|
+
|
179
207
|
this._hideUINotification(this.active);
|
180
208
|
}
|
181
209
|
}, {
|
182
|
-
key:
|
210
|
+
key: "close",
|
183
211
|
value: function close() {
|
184
212
|
if (!this.isOpen) {
|
185
213
|
return;
|
186
214
|
}
|
215
|
+
|
187
216
|
this.isOpen = false;
|
188
217
|
this.toggleButton.classList.remove('toggled');
|
189
218
|
this.outerContainer.classList.add('sidebarMoving');
|
190
219
|
this.outerContainer.classList.remove('sidebarOpen');
|
220
|
+
|
191
221
|
this._forceRendering();
|
222
|
+
|
192
223
|
this._dispatchEvent();
|
193
224
|
}
|
194
225
|
}, {
|
195
|
-
key:
|
226
|
+
key: "toggle",
|
196
227
|
value: function toggle() {
|
197
228
|
if (this.isOpen) {
|
198
229
|
this.close();
|
@@ -201,7 +232,7 @@ var PDFSidebar = function () {
|
|
201
232
|
}
|
202
233
|
}
|
203
234
|
}, {
|
204
|
-
key:
|
235
|
+
key: "_dispatchEvent",
|
205
236
|
value: function _dispatchEvent() {
|
206
237
|
this.eventBus.dispatch('sidebarviewchanged', {
|
207
238
|
source: this,
|
@@ -209,7 +240,7 @@ var PDFSidebar = function () {
|
|
209
240
|
});
|
210
241
|
}
|
211
242
|
}, {
|
212
|
-
key:
|
243
|
+
key: "_forceRendering",
|
213
244
|
value: function _forceRendering() {
|
214
245
|
if (this.onToggled) {
|
215
246
|
this.onToggled();
|
@@ -219,81 +250,96 @@ var PDFSidebar = function () {
|
|
219
250
|
}
|
220
251
|
}
|
221
252
|
}, {
|
222
|
-
key:
|
253
|
+
key: "_updateThumbnailViewer",
|
223
254
|
value: function _updateThumbnailViewer() {
|
224
255
|
var pdfViewer = this.pdfViewer,
|
225
256
|
pdfThumbnailViewer = this.pdfThumbnailViewer;
|
226
|
-
|
227
257
|
var pagesCount = pdfViewer.pagesCount;
|
258
|
+
|
228
259
|
for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
|
229
260
|
var pageView = pdfViewer.getPageView(pageIndex);
|
261
|
+
|
230
262
|
if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
|
231
263
|
var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
|
232
264
|
thumbnailView.setImage(pageView);
|
233
265
|
}
|
234
266
|
}
|
267
|
+
|
235
268
|
pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
|
236
269
|
}
|
237
270
|
}, {
|
238
|
-
key:
|
271
|
+
key: "_showUINotification",
|
239
272
|
value: function _showUINotification(view) {
|
240
273
|
var _this = this;
|
241
274
|
|
242
275
|
if (this.disableNotification) {
|
243
276
|
return;
|
244
277
|
}
|
278
|
+
|
245
279
|
this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
|
246
280
|
_this.toggleButton.title = msg;
|
247
281
|
});
|
282
|
+
|
248
283
|
if (!this.isOpen) {
|
249
284
|
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
|
250
285
|
} else if (view === this.active) {
|
251
286
|
return;
|
252
287
|
}
|
288
|
+
|
253
289
|
switch (view) {
|
254
290
|
case SidebarView.OUTLINE:
|
255
291
|
this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
|
256
292
|
break;
|
293
|
+
|
257
294
|
case SidebarView.ATTACHMENTS:
|
258
295
|
this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
|
259
296
|
break;
|
260
297
|
}
|
261
298
|
}
|
262
299
|
}, {
|
263
|
-
key:
|
300
|
+
key: "_hideUINotification",
|
264
301
|
value: function _hideUINotification(view) {
|
265
302
|
var _this2 = this;
|
266
303
|
|
267
304
|
if (this.disableNotification) {
|
268
305
|
return;
|
269
306
|
}
|
307
|
+
|
270
308
|
var removeNotification = function removeNotification(view) {
|
271
309
|
switch (view) {
|
272
310
|
case SidebarView.OUTLINE:
|
273
311
|
_this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
|
312
|
+
|
274
313
|
break;
|
314
|
+
|
275
315
|
case SidebarView.ATTACHMENTS:
|
276
316
|
_this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
|
317
|
+
|
277
318
|
break;
|
278
319
|
}
|
279
320
|
};
|
321
|
+
|
280
322
|
if (!this.isOpen && view !== null) {
|
281
323
|
return;
|
282
324
|
}
|
325
|
+
|
283
326
|
this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
|
327
|
+
|
284
328
|
if (view !== null) {
|
285
329
|
removeNotification(view);
|
286
330
|
return;
|
287
331
|
}
|
332
|
+
|
288
333
|
for (view in SidebarView) {
|
289
334
|
removeNotification(SidebarView[view]);
|
290
335
|
}
|
336
|
+
|
291
337
|
this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
|
292
338
|
_this2.toggleButton.title = msg;
|
293
339
|
});
|
294
340
|
}
|
295
341
|
}, {
|
296
|
-
key:
|
342
|
+
key: "_addEventListeners",
|
297
343
|
value: function _addEventListeners() {
|
298
344
|
var _this3 = this;
|
299
345
|
|
@@ -309,7 +355,9 @@ var PDFSidebar = function () {
|
|
309
355
|
_this3.switchView(SidebarView.OUTLINE);
|
310
356
|
});
|
311
357
|
this.outlineButton.addEventListener('dblclick', function () {
|
312
|
-
_this3.
|
358
|
+
_this3.eventBus.dispatch('toggleoutlinetree', {
|
359
|
+
source: _this3
|
360
|
+
});
|
313
361
|
});
|
314
362
|
this.attachmentsButton.addEventListener('click', function () {
|
315
363
|
_this3.switchView(SidebarView.ATTACHMENTS);
|
@@ -317,6 +365,7 @@ var PDFSidebar = function () {
|
|
317
365
|
this.eventBus.on('outlineloaded', function (evt) {
|
318
366
|
var outlineCount = evt.outlineCount;
|
319
367
|
_this3.outlineButton.disabled = !outlineCount;
|
368
|
+
|
320
369
|
if (outlineCount) {
|
321
370
|
_this3._showUINotification(SidebarView.OUTLINE);
|
322
371
|
} else if (_this3.active === SidebarView.OUTLINE) {
|
@@ -326,14 +375,19 @@ var PDFSidebar = function () {
|
|
326
375
|
this.eventBus.on('attachmentsloaded', function (evt) {
|
327
376
|
if (evt.attachmentsCount) {
|
328
377
|
_this3.attachmentsButton.disabled = false;
|
378
|
+
|
329
379
|
_this3._showUINotification(SidebarView.ATTACHMENTS);
|
380
|
+
|
330
381
|
return;
|
331
382
|
}
|
383
|
+
|
332
384
|
Promise.resolve().then(function () {
|
333
385
|
if (_this3.attachmentsView.hasChildNodes()) {
|
334
386
|
return;
|
335
387
|
}
|
388
|
+
|
336
389
|
_this3.attachmentsButton.disabled = true;
|
390
|
+
|
337
391
|
if (_this3.active === SidebarView.ATTACHMENTS) {
|
338
392
|
_this3.switchView(SidebarView.THUMBS);
|
339
393
|
}
|
@@ -346,22 +400,22 @@ var PDFSidebar = function () {
|
|
346
400
|
});
|
347
401
|
}
|
348
402
|
}, {
|
349
|
-
key:
|
403
|
+
key: "visibleView",
|
350
404
|
get: function get() {
|
351
405
|
return this.isOpen ? this.active : SidebarView.NONE;
|
352
406
|
}
|
353
407
|
}, {
|
354
|
-
key:
|
408
|
+
key: "isThumbnailViewVisible",
|
355
409
|
get: function get() {
|
356
410
|
return this.isOpen && this.active === SidebarView.THUMBS;
|
357
411
|
}
|
358
412
|
}, {
|
359
|
-
key:
|
413
|
+
key: "isOutlineViewVisible",
|
360
414
|
get: function get() {
|
361
415
|
return this.isOpen && this.active === SidebarView.OUTLINE;
|
362
416
|
}
|
363
417
|
}, {
|
364
|
-
key:
|
418
|
+
key: "isAttachmentsViewVisible",
|
365
419
|
get: function get() {
|
366
420
|
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
367
421
|
}
|
@@ -370,5 +424,4 @@ var PDFSidebar = function () {
|
|
370
424
|
return PDFSidebar;
|
371
425
|
}();
|
372
426
|
|
373
|
-
exports.SidebarView = SidebarView;
|
374
427
|
exports.PDFSidebar = PDFSidebar;
|
@@ -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 2018 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,24 +19,28 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFSidebarResizer =
|
27
|
+
exports.PDFSidebarResizer = void 0;
|
28
28
|
|
29
|
-
var
|
30
|
-
|
31
|
-
var _ui_utils = require('./ui_utils');
|
29
|
+
var _ui_utils = require("./ui_utils");
|
32
30
|
|
33
31
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
34
32
|
|
33
|
+
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); } }
|
34
|
+
|
35
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
36
|
+
|
35
37
|
var SIDEBAR_WIDTH_VAR = '--sidebar-width';
|
36
38
|
var SIDEBAR_MIN_WIDTH = 200;
|
37
39
|
var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
|
38
40
|
|
39
|
-
var PDFSidebarResizer =
|
41
|
+
var PDFSidebarResizer =
|
42
|
+
/*#__PURE__*/
|
43
|
+
function () {
|
40
44
|
function PDFSidebarResizer(options, eventBus) {
|
41
45
|
var _this = this;
|
42
46
|
|
@@ -55,66 +59,79 @@ var PDFSidebarResizer = function () {
|
|
55
59
|
this.resizer = options.resizer;
|
56
60
|
this.eventBus = eventBus;
|
57
61
|
this.l10n = l10n;
|
58
|
-
|
62
|
+
|
63
|
+
if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
|
59
64
|
console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
|
60
65
|
return;
|
61
66
|
}
|
67
|
+
|
62
68
|
this.enabled = true;
|
63
69
|
this.resizer.classList.remove('hidden');
|
64
70
|
this.l10n.getDirection().then(function (dir) {
|
65
71
|
_this.isRTL = dir === 'rtl';
|
66
72
|
});
|
73
|
+
|
67
74
|
this._addEventListeners();
|
68
75
|
}
|
69
76
|
|
70
77
|
_createClass(PDFSidebarResizer, [{
|
71
|
-
key:
|
78
|
+
key: "_updateWidth",
|
72
79
|
value: function _updateWidth() {
|
73
80
|
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
74
81
|
|
75
82
|
if (!this.enabled) {
|
76
83
|
return false;
|
77
84
|
}
|
85
|
+
|
78
86
|
var maxWidth = Math.floor(this.outerContainerWidth / 2);
|
87
|
+
|
79
88
|
if (width > maxWidth) {
|
80
89
|
width = maxWidth;
|
81
90
|
}
|
91
|
+
|
82
92
|
if (width < SIDEBAR_MIN_WIDTH) {
|
83
93
|
width = SIDEBAR_MIN_WIDTH;
|
84
94
|
}
|
95
|
+
|
85
96
|
if (width === this._width) {
|
86
97
|
return false;
|
87
98
|
}
|
99
|
+
|
88
100
|
this._width = width;
|
89
|
-
this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, width
|
101
|
+
this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
|
90
102
|
return true;
|
91
103
|
}
|
92
104
|
}, {
|
93
|
-
key:
|
105
|
+
key: "_mouseMove",
|
94
106
|
value: function _mouseMove(evt) {
|
95
107
|
var width = evt.clientX;
|
108
|
+
|
96
109
|
if (this.isRTL) {
|
97
110
|
width = this.outerContainerWidth - width;
|
98
111
|
}
|
112
|
+
|
99
113
|
this._updateWidth(width);
|
100
114
|
}
|
101
115
|
}, {
|
102
|
-
key:
|
116
|
+
key: "_mouseUp",
|
103
117
|
value: function _mouseUp(evt) {
|
104
118
|
this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
|
105
|
-
this.eventBus.dispatch('resize', {
|
119
|
+
this.eventBus.dispatch('resize', {
|
120
|
+
source: this
|
121
|
+
});
|
106
122
|
var _boundEvents = this._boundEvents;
|
107
123
|
window.removeEventListener('mousemove', _boundEvents.mouseMove);
|
108
124
|
window.removeEventListener('mouseup', _boundEvents.mouseUp);
|
109
125
|
}
|
110
126
|
}, {
|
111
|
-
key:
|
127
|
+
key: "_addEventListeners",
|
112
128
|
value: function _addEventListeners() {
|
113
129
|
var _this2 = this;
|
114
130
|
|
115
131
|
if (!this.enabled) {
|
116
132
|
return;
|
117
133
|
}
|
134
|
+
|
118
135
|
var _boundEvents = this._boundEvents;
|
119
136
|
_boundEvents.mouseMove = this._mouseMove.bind(this);
|
120
137
|
_boundEvents.mouseUp = this._mouseUp.bind(this);
|
@@ -122,7 +139,9 @@ var PDFSidebarResizer = function () {
|
|
122
139
|
if (evt.button !== 0) {
|
123
140
|
return;
|
124
141
|
}
|
142
|
+
|
125
143
|
_this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
|
144
|
+
|
126
145
|
window.addEventListener('mousemove', _boundEvents.mouseMove);
|
127
146
|
window.addEventListener('mouseup', _boundEvents.mouseUp);
|
128
147
|
});
|
@@ -132,14 +151,20 @@ var PDFSidebarResizer = function () {
|
|
132
151
|
this.eventBus.on('resize', function (evt) {
|
133
152
|
if (evt && evt.source === window) {
|
134
153
|
_this2._outerContainerWidth = null;
|
154
|
+
|
135
155
|
if (_this2._width) {
|
136
156
|
if (_this2.sidebarOpen) {
|
137
157
|
_this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
|
158
|
+
|
138
159
|
var updated = _this2._updateWidth(_this2._width);
|
160
|
+
|
139
161
|
Promise.resolve().then(function () {
|
140
162
|
_this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
|
163
|
+
|
141
164
|
if (updated) {
|
142
|
-
_this2.eventBus.dispatch('resize', {
|
165
|
+
_this2.eventBus.dispatch('resize', {
|
166
|
+
source: _this2
|
167
|
+
});
|
143
168
|
}
|
144
169
|
});
|
145
170
|
} else {
|
@@ -150,11 +175,12 @@ var PDFSidebarResizer = function () {
|
|
150
175
|
});
|
151
176
|
}
|
152
177
|
}, {
|
153
|
-
key:
|
178
|
+
key: "outerContainerWidth",
|
154
179
|
get: function get() {
|
155
180
|
if (!this._outerContainerWidth) {
|
156
181
|
this._outerContainerWidth = this.outerContainer.clientWidth;
|
157
182
|
}
|
183
|
+
|
158
184
|
return this._outerContainerWidth;
|
159
185
|
}
|
160
186
|
}]);
|