@vaadin-component-factory/vcf-pdf-viewer 3.1.0 → 4.0.0
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.
- package/README.md +2 -1
- package/package.json +56 -52
- package/pdfjs/dist/display_utils.js +609 -714
- package/pdfjs/dist/fetch_stream.js +239 -293
- package/pdfjs/dist/l10n_utils.js +113 -122
- package/pdfjs/dist/message_handler.js +451 -524
- package/pdfjs/dist/network.js +441 -552
- package/pdfjs/dist/network_utils.js +262 -309
- package/pdfjs/dist/node_stream.js +383 -481
- package/pdfjs/dist/pdf.js +9883 -11687
- package/pdfjs/dist/pdf_link_service.js +440 -534
- package/pdfjs/dist/pdf_rendering_queue.js +134 -154
- package/pdfjs/dist/pdf_thumbnail_viewer.js +620 -738
- package/pdfjs/dist/pdf_viewer.js +2667 -3207
- package/pdfjs/dist/ui_utils.js +762 -881
- package/pdfjs/dist/util.js +867 -991
- package/pdfjs/dist/worker.js +51434 -60846
- package/src/vcf-pdf-viewer.js +999 -886
- package/theme/base/vcf-pdf-viewer-styles.js +144 -0
- package/theme/base/vcf-pdf-viewer-toolbar-icons-styles.js +39 -0
- package/theme/base/vcf-pdf-viewer.js +3 -0
- package/vcf-pdf-viewer.js +1 -1
- package/theme/lumo/vcf-pdf-viewer-styles.js +0 -153
- package/theme/lumo/vcf-pdf-viewer-toolbar-icons-styles.js +0 -35
- package/theme/lumo/vcf-pdf-viewer.js +0 -3
- package/theme/material/baseline-keyboard_arrow_down-24px.svg +0 -1
- package/theme/material/baseline-keyboard_arrow_up-24px.svg +0 -1
- package/theme/material/vcf-pdf-viewer-styles.js +0 -123
- package/theme/material/vcf-pdf-viewer.js +0 -2
package/pdfjs/dist/ui_utils.js
CHANGED
|
@@ -11,74 +11,77 @@
|
|
|
11
11
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const CSS_UNITS = 96.0 / 72.0;
|
|
17
|
+
const DEFAULT_SCALE_VALUE = "auto";
|
|
18
|
+
const DEFAULT_SCALE = 1.0;
|
|
19
|
+
const MIN_SCALE = 0.1;
|
|
20
|
+
const MAX_SCALE = 10.0;
|
|
21
|
+
const UNKNOWN_SCALE = 0;
|
|
22
|
+
const MAX_AUTO_SCALE = 1.25;
|
|
23
|
+
const SCROLLBAR_PADDING = 40;
|
|
24
|
+
const VERTICAL_PADDING = 5;
|
|
25
|
+
const LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
|
|
26
|
+
const PresentationModeState = {
|
|
27
|
+
UNKNOWN: 0,
|
|
28
|
+
NORMAL: 1,
|
|
29
|
+
CHANGING: 2,
|
|
30
|
+
FULLSCREEN: 3
|
|
31
|
+
};
|
|
32
|
+
const SidebarView = {
|
|
33
|
+
UNKNOWN: -1,
|
|
34
|
+
NONE: 0,
|
|
35
|
+
THUMBS: 1,
|
|
36
|
+
// Default value.
|
|
37
|
+
OUTLINE: 2,
|
|
38
|
+
ATTACHMENTS: 3,
|
|
39
|
+
LAYERS: 4
|
|
40
|
+
};
|
|
41
|
+
const RendererType = {
|
|
42
|
+
CANVAS: "canvas",
|
|
43
|
+
SVG: "svg"
|
|
44
|
+
};
|
|
45
|
+
const TextLayerMode = {
|
|
46
|
+
DISABLE: 0,
|
|
47
|
+
ENABLE: 1,
|
|
48
|
+
ENABLE_ENHANCE: 2
|
|
49
|
+
};
|
|
50
|
+
const ScrollMode = {
|
|
51
|
+
UNKNOWN: -1,
|
|
52
|
+
VERTICAL: 0,
|
|
53
|
+
// Default value.
|
|
54
|
+
HORIZONTAL: 1,
|
|
55
|
+
WRAPPED: 2
|
|
56
|
+
};
|
|
57
|
+
const SpreadMode = {
|
|
58
|
+
UNKNOWN: -1,
|
|
59
|
+
NONE: 0,
|
|
60
|
+
// Default value.
|
|
61
|
+
ODD: 1,
|
|
62
|
+
EVEN: 2
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Used by `PDFViewerApplication`, and by the API unit-tests.
|
|
66
|
+
const AutoPrintRegExp = /\bprint\s*\(/;
|
|
67
|
+
|
|
65
68
|
/**
|
|
66
69
|
* Returns scale factor for the canvas. It makes sense for the HiDPI displays.
|
|
67
70
|
* @returns {Object} The object with horizontal (sx) and vertical (sy)
|
|
68
71
|
* scales. The scaled property is set to false if scaling is
|
|
69
72
|
* not required, true otherwise.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
*/
|
|
74
|
+
function getOutputScale(ctx) {
|
|
75
|
+
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
76
|
+
const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
|
|
77
|
+
const pixelRatio = devicePixelRatio / backingStoreRatio;
|
|
78
|
+
return {
|
|
79
|
+
sx: pixelRatio,
|
|
80
|
+
sy: pixelRatio,
|
|
81
|
+
scaled: pixelRatio !== 1
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
82
85
|
/**
|
|
83
86
|
* Scrolls specified element into view of its parent.
|
|
84
87
|
* @param {Object} element - The element to be visible.
|
|
@@ -87,110 +90,92 @@ function getOutputScale(ctx) {
|
|
|
87
90
|
* @param {boolean} [scrollMatches] - When scrolling search results into view,
|
|
88
91
|
* ignore elements that either: Contains marked content identifiers,
|
|
89
92
|
* or have the CSS-rule `overflow: hidden;` set. The default value is `false`.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (spot.left !== undefined) {
|
|
123
|
-
offsetX += spot.left;
|
|
124
|
-
parent.scrollLeft = offsetX;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
parent.scrollTop = offsetY;
|
|
129
|
-
}
|
|
93
|
+
*/
|
|
94
|
+
function scrollIntoView(element, spot, scrollMatches = false) {
|
|
95
|
+
// Assuming offsetParent is available (it's not available when viewer is in
|
|
96
|
+
// hidden iframe or object). We have to scroll: if the offsetParent is not set
|
|
97
|
+
// producing the error. See also animationStarted.
|
|
98
|
+
let parent = element.offsetParent;
|
|
99
|
+
if (!parent) {
|
|
100
|
+
console.error("offsetParent is not set -- cannot scroll");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let offsetY = element.offsetTop + element.clientTop;
|
|
104
|
+
let offsetX = element.offsetLeft + element.clientLeft;
|
|
105
|
+
while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
|
|
106
|
+
offsetY += parent.offsetTop;
|
|
107
|
+
offsetX += parent.offsetLeft;
|
|
108
|
+
parent = parent.offsetParent;
|
|
109
|
+
if (!parent) {
|
|
110
|
+
return; // no need to scroll
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (spot) {
|
|
114
|
+
if (spot.top !== undefined) {
|
|
115
|
+
offsetY += spot.top;
|
|
116
|
+
}
|
|
117
|
+
if (spot.left !== undefined) {
|
|
118
|
+
offsetX += spot.left;
|
|
119
|
+
parent.scrollLeft = offsetX;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
parent.scrollTop = offsetY;
|
|
123
|
+
}
|
|
124
|
+
|
|
130
125
|
/**
|
|
131
126
|
* Helper function to start monitoring the scroll event and converting them into
|
|
132
127
|
* PDF.js friendly one: with scroll debounce and scroll direction.
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
lastY: viewAreaElement.scrollTop,
|
|
170
|
-
_eventHandler: debounceScroll
|
|
171
|
-
};
|
|
172
|
-
let rAF = null;
|
|
173
|
-
viewAreaElement.addEventListener("scroll", debounceScroll, true);
|
|
174
|
-
return state;
|
|
175
|
-
}
|
|
128
|
+
*/
|
|
129
|
+
function watchScroll(viewAreaElement, callback) {
|
|
130
|
+
const debounceScroll = function (evt) {
|
|
131
|
+
if (rAF) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// schedule an invocation of scroll for next animation frame.
|
|
135
|
+
rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
|
|
136
|
+
rAF = null;
|
|
137
|
+
const currentX = viewAreaElement.scrollLeft;
|
|
138
|
+
const lastX = state.lastX;
|
|
139
|
+
if (currentX !== lastX) {
|
|
140
|
+
state.right = currentX > lastX;
|
|
141
|
+
}
|
|
142
|
+
state.lastX = currentX;
|
|
143
|
+
const currentY = viewAreaElement.scrollTop;
|
|
144
|
+
const lastY = state.lastY;
|
|
145
|
+
if (currentY !== lastY) {
|
|
146
|
+
state.down = currentY > lastY;
|
|
147
|
+
}
|
|
148
|
+
state.lastY = currentY;
|
|
149
|
+
callback(state);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const state = {
|
|
153
|
+
right: true,
|
|
154
|
+
down: true,
|
|
155
|
+
lastX: viewAreaElement.scrollLeft,
|
|
156
|
+
lastY: viewAreaElement.scrollTop,
|
|
157
|
+
_eventHandler: debounceScroll
|
|
158
|
+
};
|
|
159
|
+
let rAF = null;
|
|
160
|
+
viewAreaElement.addEventListener("scroll", debounceScroll, true);
|
|
161
|
+
return state;
|
|
162
|
+
}
|
|
163
|
+
|
|
176
164
|
/**
|
|
177
165
|
* Helper function to parse query string (e.g. ?param1=value&parm2=...).
|
|
178
|
-
*/
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return params;
|
|
193
|
-
}
|
|
166
|
+
*/
|
|
167
|
+
function parseQueryString(query) {
|
|
168
|
+
const parts = query.split("&");
|
|
169
|
+
const params = Object.create(null);
|
|
170
|
+
for (let i = 0, ii = parts.length; i < ii; ++i) {
|
|
171
|
+
const param = parts[i].split("=");
|
|
172
|
+
const key = param[0].toLowerCase();
|
|
173
|
+
const value = param.length > 1 ? param[1] : null;
|
|
174
|
+
params[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
175
|
+
}
|
|
176
|
+
return params;
|
|
177
|
+
}
|
|
178
|
+
|
|
194
179
|
/**
|
|
195
180
|
* Use binary search to find the index of the first item in a given array which
|
|
196
181
|
* passes a given condition. The items are expected to be sorted in the sense
|
|
@@ -199,123 +184,106 @@ function parseQueryString(query) {
|
|
|
199
184
|
*
|
|
200
185
|
* @returns {number} Index of the first array element to pass the test,
|
|
201
186
|
* or |items.length| if no such element exists.
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
minIndex = currentIndex + 1;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return minIndex;
|
|
229
|
-
/* === maxIndex */
|
|
230
|
-
}
|
|
187
|
+
*/
|
|
188
|
+
function binarySearchFirstItem(items, condition) {
|
|
189
|
+
let minIndex = 0;
|
|
190
|
+
let maxIndex = items.length - 1;
|
|
191
|
+
if (maxIndex < 0 || !condition(items[maxIndex])) {
|
|
192
|
+
return items.length;
|
|
193
|
+
}
|
|
194
|
+
if (condition(items[minIndex])) {
|
|
195
|
+
return minIndex;
|
|
196
|
+
}
|
|
197
|
+
while (minIndex < maxIndex) {
|
|
198
|
+
const currentIndex = minIndex + maxIndex >> 1;
|
|
199
|
+
const currentItem = items[currentIndex];
|
|
200
|
+
if (condition(currentItem)) {
|
|
201
|
+
maxIndex = currentIndex;
|
|
202
|
+
} else {
|
|
203
|
+
minIndex = currentIndex + 1;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return minIndex; /* === maxIndex */
|
|
207
|
+
}
|
|
208
|
+
|
|
231
209
|
/**
|
|
232
210
|
* Approximates float number as a fraction using Farey sequence (max order
|
|
233
211
|
* of 8).
|
|
234
212
|
* @param {number} x - Positive float number.
|
|
235
213
|
* @returns {Array} Estimated fraction: the first array item is a numerator,
|
|
236
214
|
* the second one is a denominator.
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return result;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function roundToDivide(x, div) {
|
|
292
|
-
const r = x % div;
|
|
293
|
-
return r === 0 ? x : Math.round(x - r + div);
|
|
294
|
-
}
|
|
215
|
+
*/
|
|
216
|
+
function approximateFraction(x) {
|
|
217
|
+
// Fast paths for int numbers or their inversions.
|
|
218
|
+
if (Math.floor(x) === x) {
|
|
219
|
+
return [x, 1];
|
|
220
|
+
}
|
|
221
|
+
const xinv = 1 / x;
|
|
222
|
+
const limit = 8;
|
|
223
|
+
if (xinv > limit) {
|
|
224
|
+
return [1, limit];
|
|
225
|
+
} else if (Math.floor(xinv) === xinv) {
|
|
226
|
+
return [1, xinv];
|
|
227
|
+
}
|
|
228
|
+
const x_ = x > 1 ? xinv : x;
|
|
229
|
+
// a/b and c/d are neighbours in Farey sequence.
|
|
230
|
+
let a = 0,
|
|
231
|
+
b = 1,
|
|
232
|
+
c = 1,
|
|
233
|
+
d = 1;
|
|
234
|
+
// Limiting search to order 8.
|
|
235
|
+
while (true) {
|
|
236
|
+
// Generating next term in sequence (order of q).
|
|
237
|
+
const p = a + c,
|
|
238
|
+
q = b + d;
|
|
239
|
+
if (q > limit) {
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
if (x_ <= p / q) {
|
|
243
|
+
c = p;
|
|
244
|
+
d = q;
|
|
245
|
+
} else {
|
|
246
|
+
a = p;
|
|
247
|
+
b = q;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
let result;
|
|
251
|
+
// Select closest of the neighbours to x.
|
|
252
|
+
if (x_ - a / b < c / d - x_) {
|
|
253
|
+
result = x_ === x ? [a, b] : [b, a];
|
|
254
|
+
} else {
|
|
255
|
+
result = x_ === x ? [c, d] : [d, c];
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
function roundToDivide(x, div) {
|
|
260
|
+
const r = x % div;
|
|
261
|
+
return r === 0 ? x : Math.round(x - r + div);
|
|
262
|
+
}
|
|
263
|
+
|
|
295
264
|
/**
|
|
296
265
|
* Gets the size of the specified page, converted from PDF units to inches.
|
|
297
266
|
* @param {Object} An Object containing the properties: {Array} `view`,
|
|
298
267
|
* {number} `userUnit`, and {number} `rotate`.
|
|
299
268
|
* @returns {Object} An Object containing the properties: {number} `width`
|
|
300
269
|
* and {number} `height`, given in inches.
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
270
|
+
*/
|
|
271
|
+
function getPageSizeInches({
|
|
272
|
+
view,
|
|
273
|
+
userUnit,
|
|
274
|
+
rotate
|
|
275
|
+
}) {
|
|
276
|
+
const [x1, y1, x2, y2] = view;
|
|
277
|
+
// We need to take the page rotation into account as well.
|
|
278
|
+
const changeOrientation = rotate % 180 !== 0;
|
|
279
|
+
const width = (x2 - x1) / 72 * userUnit;
|
|
280
|
+
const height = (y2 - y1) / 72 * userUnit;
|
|
281
|
+
return {
|
|
282
|
+
width: changeOrientation ? height : width,
|
|
283
|
+
height: changeOrientation ? width : height
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
319
287
|
/**
|
|
320
288
|
* Helper function for getVisibleElements.
|
|
321
289
|
*
|
|
@@ -326,83 +294,80 @@ function getPageSizeInches({
|
|
|
326
294
|
* before the first visible element in `views`, but not by too much. (Usually,
|
|
327
295
|
* this will be the first element in the first partially visible row in
|
|
328
296
|
* `views`, although sometimes it goes back one row further.)
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
//
|
|
337
|
-
//
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
// (
|
|
354
|
-
//
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
//
|
|
362
|
-
//
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
//
|
|
367
|
-
// case
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
let elt = views[index].div;
|
|
371
|
-
let pageTop = elt.offsetTop + elt.clientTop;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
//
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
//
|
|
387
|
-
//
|
|
388
|
-
//
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
elt
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
//
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return index;
|
|
405
|
-
}
|
|
297
|
+
*/
|
|
298
|
+
function backtrackBeforeAllVisibleElements(index, views, top) {
|
|
299
|
+
// binarySearchFirstItem's assumption is that the input is ordered, with only
|
|
300
|
+
// one index where the conditions flips from false to true: [false ...,
|
|
301
|
+
// true...]. With vertical scrolling and spreads, it is possible to have
|
|
302
|
+
// [false ..., true, false, true ...]. With wrapped scrolling we can have a
|
|
303
|
+
// similar sequence, with many more mixed true and false in the middle.
|
|
304
|
+
//
|
|
305
|
+
// So there is no guarantee that the binary search yields the index of the
|
|
306
|
+
// first visible element. It could have been any of the other visible elements
|
|
307
|
+
// that were preceded by a hidden element.
|
|
308
|
+
|
|
309
|
+
// Of course, if either this element or the previous (hidden) element is also
|
|
310
|
+
// the first element, there's nothing to worry about.
|
|
311
|
+
if (index < 2) {
|
|
312
|
+
return index;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// That aside, the possible cases are represented below.
|
|
316
|
+
//
|
|
317
|
+
// **** = fully hidden
|
|
318
|
+
// A*B* = mix of partially visible and/or hidden pages
|
|
319
|
+
// CDEF = fully visible
|
|
320
|
+
//
|
|
321
|
+
// (1) Binary search could have returned A, in which case we can stop.
|
|
322
|
+
// (2) Binary search could also have returned B, in which case we need to
|
|
323
|
+
// check the whole row.
|
|
324
|
+
// (3) Binary search could also have returned C, in which case we need to
|
|
325
|
+
// check the whole previous row.
|
|
326
|
+
//
|
|
327
|
+
// There's one other possibility:
|
|
328
|
+
//
|
|
329
|
+
// **** = fully hidden
|
|
330
|
+
// ABCD = mix of fully and/or partially visible pages
|
|
331
|
+
//
|
|
332
|
+
// (4) Binary search could only have returned A.
|
|
333
|
+
|
|
334
|
+
// Initially assume that we need to find the beginning of the current row
|
|
335
|
+
// (case 1, 2, or 4), which means finding a page that is above the current
|
|
336
|
+
// page's top. If the found page is partially visible, we're definitely not in
|
|
337
|
+
// case 3, and this assumption is correct.
|
|
338
|
+
let elt = views[index].div;
|
|
339
|
+
let pageTop = elt.offsetTop + elt.clientTop;
|
|
340
|
+
if (pageTop >= top) {
|
|
341
|
+
// The found page is fully visible, so we're actually either in case 3 or 4,
|
|
342
|
+
// and unfortunately we can't tell the difference between them without
|
|
343
|
+
// scanning the entire previous row, so we just conservatively assume that
|
|
344
|
+
// we do need to backtrack to that row. In both cases, the previous page is
|
|
345
|
+
// in the previous row, so use its top instead.
|
|
346
|
+
elt = views[index - 1].div;
|
|
347
|
+
pageTop = elt.offsetTop + elt.clientTop;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Now we backtrack to the first page that still has its bottom below
|
|
351
|
+
// `pageTop`, which is the top of a page in the first visible row (unless
|
|
352
|
+
// we're in case 4, in which case it's the row before that).
|
|
353
|
+
// `index` is found by binary search, so the page at `index - 1` is
|
|
354
|
+
// invisible and we can start looking for potentially visible pages from
|
|
355
|
+
// `index - 2`. (However, if this loop terminates on its first iteration,
|
|
356
|
+
// which is the case when pages are stacked vertically, `index` should remain
|
|
357
|
+
// unchanged, so we use a distinct loop variable.)
|
|
358
|
+
for (let i = index - 2; i >= 0; --i) {
|
|
359
|
+
elt = views[i].div;
|
|
360
|
+
if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
|
|
361
|
+
// We have reached the previous row, so stop now.
|
|
362
|
+
// This loop is expected to terminate relatively quickly because the
|
|
363
|
+
// number of pages per row is expected to be small.
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
index = i;
|
|
367
|
+
}
|
|
368
|
+
return index;
|
|
369
|
+
}
|
|
370
|
+
|
|
406
371
|
/**
|
|
407
372
|
* @typedef {Object} GetVisibleElementsParameters
|
|
408
373
|
* @property {HTMLElement} scrollEl - A container that can possibly scroll.
|
|
@@ -416,8 +381,8 @@ function backtrackBeforeAllVisibleElements(index, views, top) {
|
|
|
416
381
|
* laid out horizontally instead of vertically. The default value is `false`.
|
|
417
382
|
* @property {boolean} rtl - If `true`, the `scrollEl` container is assumed to
|
|
418
383
|
* be in right-to-left mode. The default value is `false`.
|
|
419
|
-
*/
|
|
420
|
-
|
|
384
|
+
*/
|
|
385
|
+
|
|
421
386
|
/**
|
|
422
387
|
* Generic helper to find out what elements are visible within a scroll pane.
|
|
423
388
|
*
|
|
@@ -437,186 +402,166 @@ function backtrackBeforeAllVisibleElements(index, views, top) {
|
|
|
437
402
|
*
|
|
438
403
|
* @param {GetVisibleElementsParameters}
|
|
439
404
|
* @returns {Object} `{ first, last, views: [{ id, x, y, view, percent }] }`
|
|
440
|
-
*/
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
// PDF document pages, which is the most important and complex case. In this
|
|
455
|
-
// case, the visible elements we're actually interested is the page canvas,
|
|
456
|
-
// which is contained in a wrapper which adds no padding/border/margin, which
|
|
457
|
-
// is itself contained in `view.div` which adds no padding (but does add a
|
|
458
|
-
// border). So, as specified in this function's doc comment, this function
|
|
459
|
-
// does all of its work on the padding edge of the provided views, starting at
|
|
460
|
-
// offsetLeft/Top (which includes margin) and adding clientLeft/Top (which is
|
|
461
|
-
// the border). Adding clientWidth/Height gets us the bottom-right corner of
|
|
462
|
-
// the padding edge.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
//
|
|
484
|
-
//
|
|
485
|
-
//
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
// subsequent pages will be hidden.
|
|
491
|
-
//
|
|
492
|
-
// When using wrapped scrolling or vertical scrolling with spreads, we can't
|
|
493
|
-
// simply stop the first time we reach a page below the bottom of the view;
|
|
494
|
-
// the tops of subsequent pages on the same row could still be visible. In
|
|
495
|
-
// horizontal scrolling, we don't have that issue, so we can stop as soon as
|
|
496
|
-
// we pass `right`, without needing the code below that handles the -1 case.
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return a.id - b.id; // ensure stability
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return {
|
|
558
|
-
first,
|
|
559
|
-
last,
|
|
560
|
-
views: visible
|
|
561
|
-
};
|
|
562
|
-
}
|
|
405
|
+
*/
|
|
406
|
+
function getVisibleElements({
|
|
407
|
+
scrollEl,
|
|
408
|
+
views,
|
|
409
|
+
sortByVisibility = false,
|
|
410
|
+
horizontal = false,
|
|
411
|
+
rtl = false
|
|
412
|
+
}) {
|
|
413
|
+
const top = scrollEl.scrollTop,
|
|
414
|
+
bottom = top + scrollEl.clientHeight;
|
|
415
|
+
const left = scrollEl.scrollLeft,
|
|
416
|
+
right = left + scrollEl.clientWidth;
|
|
417
|
+
|
|
418
|
+
// Throughout this "generic" function, comments will assume we're working with
|
|
419
|
+
// PDF document pages, which is the most important and complex case. In this
|
|
420
|
+
// case, the visible elements we're actually interested is the page canvas,
|
|
421
|
+
// which is contained in a wrapper which adds no padding/border/margin, which
|
|
422
|
+
// is itself contained in `view.div` which adds no padding (but does add a
|
|
423
|
+
// border). So, as specified in this function's doc comment, this function
|
|
424
|
+
// does all of its work on the padding edge of the provided views, starting at
|
|
425
|
+
// offsetLeft/Top (which includes margin) and adding clientLeft/Top (which is
|
|
426
|
+
// the border). Adding clientWidth/Height gets us the bottom-right corner of
|
|
427
|
+
// the padding edge.
|
|
428
|
+
function isElementBottomAfterViewTop(view) {
|
|
429
|
+
const element = view.div;
|
|
430
|
+
const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
|
|
431
|
+
return elementBottom > top;
|
|
432
|
+
}
|
|
433
|
+
function isElementNextAfterViewHorizontally(view) {
|
|
434
|
+
const element = view.div;
|
|
435
|
+
const elementLeft = element.offsetLeft + element.clientLeft;
|
|
436
|
+
const elementRight = elementLeft + element.clientWidth;
|
|
437
|
+
return rtl ? elementLeft < right : elementRight > left;
|
|
438
|
+
}
|
|
439
|
+
const visible = [],
|
|
440
|
+
numViews = views.length;
|
|
441
|
+
let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
|
|
442
|
+
|
|
443
|
+
// Please note the return value of the `binarySearchFirstItem` function when
|
|
444
|
+
// no valid element is found (hence the `firstVisibleElementInd` check below).
|
|
445
|
+
if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
|
|
446
|
+
// In wrapped scrolling (or vertical scrolling with spreads), with some page
|
|
447
|
+
// sizes, isElementBottomAfterViewTop doesn't satisfy the binary search
|
|
448
|
+
// condition: there can be pages with bottoms above the view top between
|
|
449
|
+
// pages with bottoms below. This function detects and corrects that error;
|
|
450
|
+
// see it for more comments.
|
|
451
|
+
firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// lastEdge acts as a cutoff for us to stop looping, because we know all
|
|
455
|
+
// subsequent pages will be hidden.
|
|
456
|
+
//
|
|
457
|
+
// When using wrapped scrolling or vertical scrolling with spreads, we can't
|
|
458
|
+
// simply stop the first time we reach a page below the bottom of the view;
|
|
459
|
+
// the tops of subsequent pages on the same row could still be visible. In
|
|
460
|
+
// horizontal scrolling, we don't have that issue, so we can stop as soon as
|
|
461
|
+
// we pass `right`, without needing the code below that handles the -1 case.
|
|
462
|
+
let lastEdge = horizontal ? right : -1;
|
|
463
|
+
for (let i = firstVisibleElementInd; i < numViews; i++) {
|
|
464
|
+
const view = views[i],
|
|
465
|
+
element = view.div;
|
|
466
|
+
const currentWidth = element.offsetLeft + element.clientLeft;
|
|
467
|
+
const currentHeight = element.offsetTop + element.clientTop;
|
|
468
|
+
const viewWidth = element.clientWidth,
|
|
469
|
+
viewHeight = element.clientHeight;
|
|
470
|
+
const viewRight = currentWidth + viewWidth;
|
|
471
|
+
const viewBottom = currentHeight + viewHeight;
|
|
472
|
+
if (lastEdge === -1) {
|
|
473
|
+
// As commented above, this is only needed in non-horizontal cases.
|
|
474
|
+
// Setting lastEdge to the bottom of the first page that is partially
|
|
475
|
+
// visible ensures that the next page fully below lastEdge is on the
|
|
476
|
+
// next row, which has to be fully hidden along with all subsequent rows.
|
|
477
|
+
if (viewBottom >= bottom) {
|
|
478
|
+
lastEdge = viewBottom;
|
|
479
|
+
}
|
|
480
|
+
} else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
|
|
487
|
+
const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
|
|
488
|
+
const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
|
|
489
|
+
fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
|
|
490
|
+
const percent = fractionHeight * fractionWidth * 100 | 0;
|
|
491
|
+
visible.push({
|
|
492
|
+
id: view.id,
|
|
493
|
+
x: currentWidth,
|
|
494
|
+
y: currentHeight,
|
|
495
|
+
view,
|
|
496
|
+
percent,
|
|
497
|
+
widthPercent: fractionWidth * 100 | 0
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
const first = visible[0],
|
|
501
|
+
last = visible[visible.length - 1];
|
|
502
|
+
if (sortByVisibility) {
|
|
503
|
+
visible.sort(function (a, b) {
|
|
504
|
+
const pc = a.percent - b.percent;
|
|
505
|
+
if (Math.abs(pc) > 0.001) {
|
|
506
|
+
return -pc;
|
|
507
|
+
}
|
|
508
|
+
return a.id - b.id; // ensure stability
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
first,
|
|
513
|
+
last,
|
|
514
|
+
views: visible
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
563
518
|
/**
|
|
564
519
|
* Event handler to suppress context menu.
|
|
565
|
-
*/
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
return
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function isPortraitOrientation(size) {
|
|
613
|
-
return size.width <= size.height;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
const WaitOnType = {
|
|
617
|
-
EVENT: "event",
|
|
618
|
-
TIMEOUT: "timeout"
|
|
619
|
-
};
|
|
520
|
+
*/
|
|
521
|
+
function noContextMenuHandler(evt) {
|
|
522
|
+
evt.preventDefault();
|
|
523
|
+
}
|
|
524
|
+
function normalizeWheelEventDirection(evt) {
|
|
525
|
+
let delta = Math.hypot(evt.deltaX, evt.deltaY);
|
|
526
|
+
const angle = Math.atan2(evt.deltaY, evt.deltaX);
|
|
527
|
+
if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
|
|
528
|
+
// All that is left-up oriented has to change the sign.
|
|
529
|
+
delta = -delta;
|
|
530
|
+
}
|
|
531
|
+
return delta;
|
|
532
|
+
}
|
|
533
|
+
function normalizeWheelEventDelta(evt) {
|
|
534
|
+
let delta = normalizeWheelEventDirection(evt);
|
|
535
|
+
const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
|
|
536
|
+
const MOUSE_DOM_DELTA_LINE_MODE = 1;
|
|
537
|
+
const MOUSE_PIXELS_PER_LINE = 30;
|
|
538
|
+
const MOUSE_LINES_PER_PAGE = 30;
|
|
539
|
+
|
|
540
|
+
// Converts delta to per-page units
|
|
541
|
+
if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
|
|
542
|
+
delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
|
|
543
|
+
} else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
|
|
544
|
+
delta /= MOUSE_LINES_PER_PAGE;
|
|
545
|
+
}
|
|
546
|
+
return delta;
|
|
547
|
+
}
|
|
548
|
+
function isValidRotation(angle) {
|
|
549
|
+
return Number.isInteger(angle) && angle % 90 === 0;
|
|
550
|
+
}
|
|
551
|
+
function isValidScrollMode(mode) {
|
|
552
|
+
return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
|
|
553
|
+
}
|
|
554
|
+
function isValidSpreadMode(mode) {
|
|
555
|
+
return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
|
|
556
|
+
}
|
|
557
|
+
function isPortraitOrientation(size) {
|
|
558
|
+
return size.width <= size.height;
|
|
559
|
+
}
|
|
560
|
+
const WaitOnType = {
|
|
561
|
+
EVENT: "event",
|
|
562
|
+
TIMEOUT: "timeout"
|
|
563
|
+
};
|
|
564
|
+
|
|
620
565
|
/**
|
|
621
566
|
* @typedef {Object} WaitOnEventOrTimeoutParameters
|
|
622
567
|
* @property {Object} target - The event target, can for example be:
|
|
@@ -624,8 +569,8 @@ const WaitOnType = {
|
|
|
624
569
|
* @property {string} name - The name of the event.
|
|
625
570
|
* @property {number} delay - The delay, in milliseconds, after which the
|
|
626
571
|
* timeout occurs (if the event wasn't already dispatched).
|
|
627
|
-
*/
|
|
628
|
-
|
|
572
|
+
*/
|
|
573
|
+
|
|
629
574
|
/**
|
|
630
575
|
* Allows waiting for an event or a timeout, whichever occurs first.
|
|
631
576
|
* Can be used to ensure that an action always occurs, even when an event
|
|
@@ -633,322 +578,273 @@ const WaitOnType = {
|
|
|
633
578
|
*
|
|
634
579
|
* @param {WaitOnEventOrTimeoutParameters}
|
|
635
580
|
* @returns {Promise} A promise that is resolved with a {WaitOnType} value.
|
|
636
|
-
*/
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
target.
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
|
|
671
|
-
const timeout = setTimeout(timeoutHandler, delay);
|
|
672
|
-
});
|
|
673
|
-
}
|
|
581
|
+
*/
|
|
582
|
+
function waitOnEventOrTimeout({
|
|
583
|
+
target,
|
|
584
|
+
name,
|
|
585
|
+
delay = 0
|
|
586
|
+
}) {
|
|
587
|
+
return new Promise(function (resolve, reject) {
|
|
588
|
+
if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
|
|
589
|
+
throw new Error("waitOnEventOrTimeout - invalid parameters.");
|
|
590
|
+
}
|
|
591
|
+
function handler(type) {
|
|
592
|
+
if (target instanceof EventBus) {
|
|
593
|
+
target._off(name, eventHandler);
|
|
594
|
+
} else {
|
|
595
|
+
target.removeEventListener(name, eventHandler);
|
|
596
|
+
}
|
|
597
|
+
if (timeout) {
|
|
598
|
+
clearTimeout(timeout);
|
|
599
|
+
}
|
|
600
|
+
resolve(type);
|
|
601
|
+
}
|
|
602
|
+
const eventHandler = handler.bind(null, WaitOnType.EVENT);
|
|
603
|
+
if (target instanceof EventBus) {
|
|
604
|
+
target._on(name, eventHandler);
|
|
605
|
+
} else {
|
|
606
|
+
target.addEventListener(name, eventHandler);
|
|
607
|
+
}
|
|
608
|
+
const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
|
|
609
|
+
const timeout = setTimeout(timeoutHandler, delay);
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
|
|
674
613
|
/**
|
|
675
614
|
* Promise that is resolved when DOM window becomes visible.
|
|
676
|
-
*/
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
window.requestAnimationFrame(resolve);
|
|
688
|
-
});
|
|
615
|
+
*/
|
|
616
|
+
const animationStarted = new Promise(function (resolve) {
|
|
617
|
+
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB") && typeof window === "undefined") {
|
|
618
|
+
// Prevent "ReferenceError: window is not defined" errors when running the
|
|
619
|
+
// unit-tests in Node.js environments.
|
|
620
|
+
setTimeout(resolve, 20);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
window.requestAnimationFrame(resolve);
|
|
624
|
+
});
|
|
625
|
+
|
|
689
626
|
/**
|
|
690
627
|
* NOTE: Only used to support various PDF viewer tests in `mozilla-central`.
|
|
691
|
-
*/
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
const event = document.createEvent("CustomEvent");
|
|
719
|
-
event.initCustomEvent(eventName, true, true, details);
|
|
720
|
-
document.dispatchEvent(event);
|
|
721
|
-
}
|
|
628
|
+
*/
|
|
629
|
+
function dispatchDOMEvent(eventName, args = null) {
|
|
630
|
+
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("MOZCENTRAL")) {
|
|
631
|
+
throw new Error("Not implemented: dispatchDOMEvent");
|
|
632
|
+
}
|
|
633
|
+
const details = Object.create(null);
|
|
634
|
+
if ((args === null || args === void 0 ? void 0 : args.length) > 0) {
|
|
635
|
+
const obj = args[0];
|
|
636
|
+
for (const key in obj) {
|
|
637
|
+
const value = obj[key];
|
|
638
|
+
if (key === "source") {
|
|
639
|
+
if (value === window || value === document) {
|
|
640
|
+
return; // No need to re-dispatch (already) global events.
|
|
641
|
+
}
|
|
642
|
+
continue; // Ignore the `source` property.
|
|
643
|
+
}
|
|
644
|
+
details[key] = value;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const event = document.createEvent("CustomEvent");
|
|
648
|
+
event.initCustomEvent(eventName, true, true, details);
|
|
649
|
+
document.dispatchEvent(event);
|
|
650
|
+
}
|
|
651
|
+
|
|
722
652
|
/**
|
|
723
653
|
* Simple event bus for an application. Listeners are attached using the `on`
|
|
724
654
|
* and `off` methods. To raise an event, the `dispatch` method shall be used.
|
|
725
|
-
*/
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
}
|
|
735
|
-
}
|
|
655
|
+
*/
|
|
656
|
+
class EventBus {
|
|
657
|
+
constructor(options) {
|
|
658
|
+
this._listeners = Object.create(null);
|
|
659
|
+
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("MOZCENTRAL")) {
|
|
660
|
+
this._isInAutomation = (options === null || options === void 0 ? void 0 : options.isInAutomation) === true;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
736
664
|
/**
|
|
737
665
|
* @param {string} eventName
|
|
738
666
|
* @param {function} listener
|
|
739
667
|
* @param {Object} [options]
|
|
740
|
-
*/
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
668
|
+
*/
|
|
669
|
+
on(eventName, listener, options = null) {
|
|
670
|
+
this._on(eventName, listener, {
|
|
671
|
+
external: true,
|
|
672
|
+
once: options === null || options === void 0 ? void 0 : options.once
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
|
|
749
676
|
/**
|
|
750
677
|
* @param {string} eventName
|
|
751
678
|
* @param {function} listener
|
|
752
679
|
* @param {Object} [options]
|
|
753
|
-
*/
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
external
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
listener.apply(null, args);
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
externalListeners = null;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
if ((typeof PDFJSDev === "undefined" || PDFJSDev.test("MOZCENTRAL")) && this._isInAutomation) {
|
|
808
|
-
dispatchDOMEvent(eventName, args);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
680
|
+
*/
|
|
681
|
+
off(eventName, listener, options = null) {
|
|
682
|
+
this._off(eventName, listener, {
|
|
683
|
+
external: true,
|
|
684
|
+
once: options === null || options === void 0 ? void 0 : options.once
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
dispatch(eventName) {
|
|
688
|
+
const eventListeners = this._listeners[eventName];
|
|
689
|
+
if (!eventListeners || eventListeners.length === 0) {
|
|
690
|
+
if ((typeof PDFJSDev === "undefined" || PDFJSDev.test("MOZCENTRAL")) && this._isInAutomation) {
|
|
691
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
|
692
|
+
dispatchDOMEvent(eventName, args);
|
|
693
|
+
}
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
// Passing all arguments after the eventName to the listeners.
|
|
697
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
|
698
|
+
let externalListeners;
|
|
699
|
+
// Making copy of the listeners array in case if it will be modified
|
|
700
|
+
// during dispatch.
|
|
701
|
+
for (const {
|
|
702
|
+
listener,
|
|
703
|
+
external,
|
|
704
|
+
once
|
|
705
|
+
} of eventListeners.slice(0)) {
|
|
706
|
+
if (once) {
|
|
707
|
+
this._off(eventName, listener);
|
|
708
|
+
}
|
|
709
|
+
if (external) {
|
|
710
|
+
(externalListeners || (externalListeners = [])).push(listener);
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
listener.apply(null, args);
|
|
714
|
+
}
|
|
715
|
+
// Dispatch any "external" listeners *after* the internal ones, to give the
|
|
716
|
+
// viewer components time to handle events and update their state first.
|
|
717
|
+
if (externalListeners) {
|
|
718
|
+
for (const listener of externalListeners) {
|
|
719
|
+
listener.apply(null, args);
|
|
720
|
+
}
|
|
721
|
+
externalListeners = null;
|
|
722
|
+
}
|
|
723
|
+
if ((typeof PDFJSDev === "undefined" || PDFJSDev.test("MOZCENTRAL")) && this._isInAutomation) {
|
|
724
|
+
dispatchDOMEvent(eventName, args);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
811
728
|
/**
|
|
812
729
|
* @ignore
|
|
813
|
-
*/
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
});
|
|
825
|
-
}
|
|
730
|
+
*/
|
|
731
|
+
_on(eventName, listener, options = null) {
|
|
732
|
+
var _this$_listeners;
|
|
733
|
+
const eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
|
|
734
|
+
eventListeners.push({
|
|
735
|
+
listener,
|
|
736
|
+
external: (options === null || options === void 0 ? void 0 : options.external) === true,
|
|
737
|
+
once: (options === null || options === void 0 ? void 0 : options.once) === true
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
|
|
826
741
|
/**
|
|
827
742
|
* @ignore
|
|
828
|
-
*/
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
this.
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
this.height = height
|
|
865
|
-
this.
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
this.
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
this.visible = false;
|
|
915
|
-
this.bar.classList.add("hidden");
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
show() {
|
|
919
|
-
if (this.visible) {
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
this.visible = true;
|
|
924
|
-
this.bar.classList.remove("hidden");
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
}
|
|
743
|
+
*/
|
|
744
|
+
_off(eventName, listener, options = null) {
|
|
745
|
+
const eventListeners = this._listeners[eventName];
|
|
746
|
+
if (!eventListeners) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
for (let i = 0, ii = eventListeners.length; i < ii; i++) {
|
|
750
|
+
if (eventListeners[i].listener === listener) {
|
|
751
|
+
eventListeners.splice(i, 1);
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
function clamp(v, min, max) {
|
|
758
|
+
return Math.min(Math.max(v, min), max);
|
|
759
|
+
}
|
|
760
|
+
class ProgressBar {
|
|
761
|
+
constructor(id, {
|
|
762
|
+
height,
|
|
763
|
+
width,
|
|
764
|
+
units
|
|
765
|
+
} = {}) {
|
|
766
|
+
this.visible = true;
|
|
767
|
+
|
|
768
|
+
// Fetch the sub-elements for later.
|
|
769
|
+
this.div = document.querySelector(id + " .progress");
|
|
770
|
+
// Get the loading bar element, so it can be resized to fit the viewer.
|
|
771
|
+
this.bar = this.div.parentNode;
|
|
772
|
+
|
|
773
|
+
// Get options, with sensible defaults.
|
|
774
|
+
this.height = height || 100;
|
|
775
|
+
this.width = width || 100;
|
|
776
|
+
this.units = units || "%";
|
|
777
|
+
|
|
778
|
+
// Initialize heights.
|
|
779
|
+
this.div.style.height = this.height + this.units;
|
|
780
|
+
this.percent = 0;
|
|
781
|
+
}
|
|
782
|
+
_updateBar() {
|
|
783
|
+
if (this._indeterminate) {
|
|
784
|
+
this.div.classList.add("indeterminate");
|
|
785
|
+
this.div.style.width = this.width + this.units;
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
this.div.classList.remove("indeterminate");
|
|
789
|
+
const progressSize = this.width * this._percent / 100;
|
|
790
|
+
this.div.style.width = progressSize + this.units;
|
|
791
|
+
}
|
|
792
|
+
get percent() {
|
|
793
|
+
return this._percent;
|
|
794
|
+
}
|
|
795
|
+
set percent(val) {
|
|
796
|
+
this._indeterminate = isNaN(val);
|
|
797
|
+
this._percent = clamp(val, 0, 100);
|
|
798
|
+
this._updateBar();
|
|
799
|
+
}
|
|
800
|
+
setWidth(viewer) {
|
|
801
|
+
if (!viewer) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const container = viewer.parentNode;
|
|
805
|
+
const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
|
806
|
+
if (scrollbarWidth > 0) {
|
|
807
|
+
const doc = document.documentElement;
|
|
808
|
+
doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, `${scrollbarWidth}px`);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
hide() {
|
|
812
|
+
if (!this.visible) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
this.visible = false;
|
|
816
|
+
this.bar.classList.add("hidden");
|
|
817
|
+
}
|
|
818
|
+
show() {
|
|
819
|
+
if (this.visible) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
this.visible = true;
|
|
823
|
+
this.bar.classList.remove("hidden");
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
928
827
|
/**
|
|
929
828
|
* Moves all elements of an array that satisfy condition to the end of the
|
|
930
829
|
* array, preserving the order of the rest.
|
|
931
|
-
*/
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
arr[write] = moved[read];
|
|
950
|
-
}
|
|
951
|
-
}
|
|
830
|
+
*/
|
|
831
|
+
function moveToEndOfArray(arr, condition) {
|
|
832
|
+
const moved = [],
|
|
833
|
+
len = arr.length;
|
|
834
|
+
let write = 0;
|
|
835
|
+
for (let read = 0; read < len; ++read) {
|
|
836
|
+
if (condition(arr[read])) {
|
|
837
|
+
moved.push(arr[read]);
|
|
838
|
+
} else {
|
|
839
|
+
arr[write] = arr[read];
|
|
840
|
+
++write;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
for (let read = 0; write < len; ++read, ++write) {
|
|
844
|
+
arr[write] = moved[read];
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
952
848
|
/**
|
|
953
849
|
* Get the active or focused element in current DOM.
|
|
954
850
|
*
|
|
@@ -956,22 +852,18 @@ function moveToEndOfArray(arr, condition) {
|
|
|
956
852
|
* shadow DOMs.
|
|
957
853
|
*
|
|
958
854
|
* @returns {Element} the truly active or focused element.
|
|
959
|
-
*/
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
return curActiveOrFocused;
|
|
974
|
-
}
|
|
855
|
+
*/
|
|
856
|
+
function getActiveOrFocusedElement() {
|
|
857
|
+
let curRoot = document;
|
|
858
|
+
let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
|
|
859
|
+
while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) {
|
|
860
|
+
var _curActiveOrFocused;
|
|
861
|
+
curRoot = curActiveOrFocused.shadowRoot;
|
|
862
|
+
curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
|
|
863
|
+
}
|
|
864
|
+
return curActiveOrFocused;
|
|
865
|
+
}
|
|
866
|
+
|
|
975
867
|
/**
|
|
976
868
|
* Converts API PageLayout values to the format used by `BaseViewer`.
|
|
977
869
|
* NOTE: This is supported to the extent that the viewer implements the
|
|
@@ -979,26 +871,22 @@ function getActiveOrFocusedElement() {
|
|
|
979
871
|
* and TwoPageRight all suggests using non-continuous scrolling).
|
|
980
872
|
* @param {string} mode - The API PageLayout value.
|
|
981
873
|
* @returns {number} A value from {SpreadMode}.
|
|
982
|
-
*/
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
case "
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
case "
|
|
992
|
-
case "
|
|
993
|
-
return SpreadMode.
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
return SpreadMode.NONE; // Default value.
|
|
1001
|
-
}
|
|
874
|
+
*/
|
|
875
|
+
function apiPageLayoutToSpreadMode(layout) {
|
|
876
|
+
switch (layout) {
|
|
877
|
+
case "SinglePage":
|
|
878
|
+
case "OneColumn":
|
|
879
|
+
return SpreadMode.NONE;
|
|
880
|
+
case "TwoColumnLeft":
|
|
881
|
+
case "TwoPageLeft":
|
|
882
|
+
return SpreadMode.ODD;
|
|
883
|
+
case "TwoColumnRight":
|
|
884
|
+
case "TwoPageRight":
|
|
885
|
+
return SpreadMode.EVEN;
|
|
886
|
+
}
|
|
887
|
+
return SpreadMode.NONE; // Default value.
|
|
888
|
+
}
|
|
889
|
+
|
|
1002
890
|
/**
|
|
1003
891
|
* Converts API PageMode values to the format used by `PDFSidebar`.
|
|
1004
892
|
* NOTE: There's also a "FullScreen" parameter which is not possible to support,
|
|
@@ -1006,28 +894,21 @@ function apiPageLayoutToSpreadMode(layout) {
|
|
|
1006
894
|
* fullscreen mode only occurs as a result of a user-initiated event.
|
|
1007
895
|
* @param {string} mode - The API PageMode value.
|
|
1008
896
|
* @returns {number} A value from {SidebarView}.
|
|
1009
|
-
*/
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
case "
|
|
1015
|
-
return SidebarView.
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
case "
|
|
1021
|
-
return SidebarView.
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
return SidebarView.LAYERS;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
return SidebarView.NONE; // Default value.
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
export { AutoPrintRegExp, CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, EventBus, MAX_AUTO_SCALE, MAX_SCALE, MIN_SCALE, PresentationModeState, ProgressBar, RendererType, SCROLLBAR_PADDING, ScrollMode, SidebarView, SpreadMode, TextLayerMode, UNKNOWN_SCALE, VERTICAL_PADDING, WaitOnType, animationStarted, apiPageLayoutToSpreadMode, apiPageModeToSidebarView, approximateFraction, backtrackBeforeAllVisibleElements, binarySearchFirstItem, getActiveOrFocusedElement, getOutputScale, getPageSizeInches, getVisibleElements, isPortraitOrientation, isValidRotation, isValidScrollMode, isValidSpreadMode, moveToEndOfArray, noContextMenuHandler, normalizeWheelEventDelta, normalizeWheelEventDirection, parseQueryString, roundToDivide, scrollIntoView, waitOnEventOrTimeout, watchScroll };
|
|
897
|
+
*/
|
|
898
|
+
function apiPageModeToSidebarView(mode) {
|
|
899
|
+
switch (mode) {
|
|
900
|
+
case "UseNone":
|
|
901
|
+
return SidebarView.NONE;
|
|
902
|
+
case "UseThumbs":
|
|
903
|
+
return SidebarView.THUMBS;
|
|
904
|
+
case "UseOutlines":
|
|
905
|
+
return SidebarView.OUTLINE;
|
|
906
|
+
case "UseAttachments":
|
|
907
|
+
return SidebarView.ATTACHMENTS;
|
|
908
|
+
case "UseOC":
|
|
909
|
+
return SidebarView.LAYERS;
|
|
910
|
+
}
|
|
911
|
+
return SidebarView.NONE; // Default value.
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
export { AutoPrintRegExp, CSS_UNITS, DEFAULT_SCALE, DEFAULT_SCALE_VALUE, EventBus, MAX_AUTO_SCALE, MAX_SCALE, MIN_SCALE, PresentationModeState, ProgressBar, RendererType, SCROLLBAR_PADDING, ScrollMode, SidebarView, SpreadMode, TextLayerMode, UNKNOWN_SCALE, VERTICAL_PADDING, WaitOnType, animationStarted, apiPageLayoutToSpreadMode, apiPageModeToSidebarView, approximateFraction, backtrackBeforeAllVisibleElements, binarySearchFirstItem, getActiveOrFocusedElement, getOutputScale, getPageSizeInches, getVisibleElements, isPortraitOrientation, isValidRotation, isValidScrollMode, isValidSpreadMode, moveToEndOfArray, noContextMenuHandler, normalizeWheelEventDelta, normalizeWheelEventDirection, parseQueryString, roundToDivide, scrollIntoView, waitOnEventOrTimeout, watchScroll };
|