@internetarchive/bookreader 5.0.0-38 → 5.0.0-39
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.css +8 -0
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +99 -75
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/CHANGELOG.md +5 -0
- package/README.md +13 -0
- package/package.json +14 -14
- package/renovate.json +1 -1
- package/src/BookReader/Mode1UpLit.js +7 -1
- package/src/BookReader/Mode2Up.js +11 -0
- package/src/BookReader/ModeSmoothZoom.js +2 -0
- package/src/BookReader/PageContainer.js +10 -4
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/css/_TextSelection.scss +13 -0
- package/tests/jest/BookReader/PageContainer.test.js +5 -4
- package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/.husky/_/husky.sh +0 -30
- package/stat/BookNavigator/BookModel.js +0 -14
- package/stat/BookNavigator/BookNavigator.js +0 -524
- package/stat/BookNavigator/assets/bookmark-colors.js +0 -15
- package/stat/BookNavigator/assets/button-base.js +0 -61
- package/stat/BookNavigator/assets/ia-logo.js +0 -17
- package/stat/BookNavigator/assets/icon_checkmark.js +0 -6
- package/stat/BookNavigator/assets/icon_close.js +0 -3
- package/stat/BookNavigator/assets/icon_sort_asc.js +0 -5
- package/stat/BookNavigator/assets/icon_sort_desc.js +0 -5
- package/stat/BookNavigator/assets/icon_sort_neutral.js +0 -5
- package/stat/BookNavigator/assets/icon_volumes.js +0 -11
- package/stat/BookNavigator/bookmarks/bookmark-button.js +0 -64
- package/stat/BookNavigator/bookmarks/bookmark-edit.js +0 -215
- package/stat/BookNavigator/bookmarks/bookmarks-list.js +0 -285
- package/stat/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -28
- package/stat/BookNavigator/bookmarks/bookmarks-provider.js +0 -56
- package/stat/BookNavigator/bookmarks/ia-bookmarks.js +0 -523
- package/stat/BookNavigator/br-fullscreen-mgr.js +0 -82
- package/stat/BookNavigator/delete-modal-actions.js +0 -49
- package/stat/BookNavigator/downloads/downloads-provider.js +0 -72
- package/stat/BookNavigator/downloads/downloads.js +0 -139
- package/stat/BookNavigator/provider-config.js +0 -0
- package/stat/BookNavigator/search/a-search-result.js +0 -55
- package/stat/BookNavigator/search/search-provider.js +0 -180
- package/stat/BookNavigator/search/search-results.js +0 -360
- package/stat/BookNavigator/sharing.js +0 -31
- package/stat/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -94
- package/stat/BookNavigator/visual-adjustments/visual-adjustments.js +0 -280
- package/stat/BookNavigator/volumes/volumes-provider.js +0 -83
- package/stat/BookNavigator/volumes/volumes.js +0 -178
- package/stat/BookReader/BookModel.js +0 -518
- package/stat/BookReader/DebugConsole.js +0 -54
- package/stat/BookReader/DragScrollable.js +0 -233
- package/stat/BookReader/ImageCache.js +0 -116
- package/stat/BookReader/Mode1Up.js +0 -102
- package/stat/BookReader/Mode1UpLit.js +0 -434
- package/stat/BookReader/Mode2Up.js +0 -1372
- package/stat/BookReader/ModeSmoothZoom.js +0 -177
- package/stat/BookReader/ModeThumb.js +0 -344
- package/stat/BookReader/Navbar/Navbar.js +0 -310
- package/stat/BookReader/PageContainer.js +0 -120
- package/stat/BookReader/ReduceSet.js +0 -26
- package/stat/BookReader/Toolbar/Toolbar.js +0 -384
- package/stat/BookReader/events.js +0 -20
- package/stat/BookReader/options.js +0 -324
- package/stat/BookReader/utils/HTMLDimensionsCacher.js +0 -44
- package/stat/BookReader/utils/classes.js +0 -36
- package/stat/BookReader/utils.js +0 -240
- package/stat/BookReader.js +0 -2550
- package/stat/BookReaderComponent/BookReaderComponent.js +0 -117
- package/stat/assets/icons/1up.svg +0 -12
- package/stat/assets/icons/2up.svg +0 -15
- package/stat/assets/icons/advance.svg +0 -26
- package/stat/assets/icons/chevron-right.svg +0 -1
- package/stat/assets/icons/close-circle-dark.svg +0 -1
- package/stat/assets/icons/close-circle.svg +0 -1
- package/stat/assets/icons/fullscreen.svg +0 -17
- package/stat/assets/icons/fullscreen_exit.svg +0 -17
- package/stat/assets/icons/hamburger.svg +0 -15
- package/stat/assets/icons/left-arrow.svg +0 -12
- package/stat/assets/icons/magnify-minus.svg +0 -16
- package/stat/assets/icons/magnify-plus.svg +0 -17
- package/stat/assets/icons/magnify.svg +0 -15
- package/stat/assets/icons/pause.svg +0 -23
- package/stat/assets/icons/play.svg +0 -22
- package/stat/assets/icons/playback-speed.svg +0 -34
- package/stat/assets/icons/read-aloud.svg +0 -22
- package/stat/assets/icons/review.svg +0 -22
- package/stat/assets/icons/thumbnails.svg +0 -17
- package/stat/assets/icons/voice.svg +0 -1
- package/stat/assets/icons/volume-full.svg +0 -22
- package/stat/assets/images/BRicons.png +0 -0
- package/stat/assets/images/BRicons.svg +0 -94
- package/stat/assets/images/BRicons_ia.png +0 -0
- package/stat/assets/images/back_pages.png +0 -0
- package/stat/assets/images/book_bottom_icon.png +0 -0
- package/stat/assets/images/book_down_icon.png +0 -0
- package/stat/assets/images/book_left_icon.png +0 -0
- package/stat/assets/images/book_leftmost_icon.png +0 -0
- package/stat/assets/images/book_right_icon.png +0 -0
- package/stat/assets/images/book_rightmost_icon.png +0 -0
- package/stat/assets/images/book_top_icon.png +0 -0
- package/stat/assets/images/book_up_icon.png +0 -0
- package/stat/assets/images/books_graphic.svg +0 -177
- package/stat/assets/images/booksplit.png +0 -0
- package/stat/assets/images/control_pause_icon.png +0 -0
- package/stat/assets/images/control_play_icon.png +0 -0
- package/stat/assets/images/embed_icon.png +0 -0
- package/stat/assets/images/icon-home-ia.png +0 -0
- package/stat/assets/images/icon_OL-logo-xs.png +0 -0
- package/stat/assets/images/icon_alert-xs.png +0 -0
- package/stat/assets/images/icon_book.svg +0 -12
- package/stat/assets/images/icon_bookmark.svg +0 -12
- package/stat/assets/images/icon_close-pop.png +0 -0
- package/stat/assets/images/icon_download.png +0 -0
- package/stat/assets/images/icon_gear.svg +0 -14
- package/stat/assets/images/icon_hamburger.svg +0 -20
- package/stat/assets/images/icon_home.png +0 -0
- package/stat/assets/images/icon_home.svg +0 -21
- package/stat/assets/images/icon_home_ia.png +0 -0
- package/stat/assets/images/icon_indicator.png +0 -0
- package/stat/assets/images/icon_info.svg +0 -11
- package/stat/assets/images/icon_one_page.svg +0 -8
- package/stat/assets/images/icon_pause.svg +0 -1
- package/stat/assets/images/icon_play.svg +0 -1
- package/stat/assets/images/icon_playback-rate.svg +0 -15
- package/stat/assets/images/icon_return.png +0 -0
- package/stat/assets/images/icon_search_button.svg +0 -8
- package/stat/assets/images/icon_share.svg +0 -9
- package/stat/assets/images/icon_skip-ahead.svg +0 -6
- package/stat/assets/images/icon_skip-back.svg +0 -13
- package/stat/assets/images/icon_speaker.svg +0 -18
- package/stat/assets/images/icon_speaker_open.svg +0 -10
- package/stat/assets/images/icon_thumbnails.svg +0 -12
- package/stat/assets/images/icon_toc.svg +0 -5
- package/stat/assets/images/icon_two_pages.svg +0 -9
- package/stat/assets/images/icon_zoomer.png +0 -0
- package/stat/assets/images/loading.gif +0 -0
- package/stat/assets/images/logo_icon.png +0 -0
- package/stat/assets/images/marker_chap-off.png +0 -0
- package/stat/assets/images/marker_chap-off.svg +0 -11
- package/stat/assets/images/marker_chap-off_ia.png +0 -0
- package/stat/assets/images/marker_chap-on.png +0 -0
- package/stat/assets/images/marker_chap-on.svg +0 -11
- package/stat/assets/images/marker_srch-on.svg +0 -11
- package/stat/assets/images/marker_srchchap-off.png +0 -0
- package/stat/assets/images/marker_srchchap-on.png +0 -0
- package/stat/assets/images/nav_control-dn.png +0 -0
- package/stat/assets/images/nav_control-dn_ia.png +0 -0
- package/stat/assets/images/nav_control-up.png +0 -0
- package/stat/assets/images/nav_control-up_ia.png +0 -0
- package/stat/assets/images/nav_control.png +0 -0
- package/stat/assets/images/one_page_mode_icon.png +0 -0
- package/stat/assets/images/paper-badge.png +0 -0
- package/stat/assets/images/print_icon.png +0 -0
- package/stat/assets/images/progressbar.gif +0 -0
- package/stat/assets/images/right_edges.png +0 -0
- package/stat/assets/images/slider.png +0 -0
- package/stat/assets/images/slider_ia.png +0 -0
- package/stat/assets/images/thumbnail_mode_icon.png +0 -0
- package/stat/assets/images/transparent.png +0 -0
- package/stat/assets/images/two_page_mode_icon.png +0 -0
- package/stat/assets/images/zoom_in_icon.png +0 -0
- package/stat/assets/images/zoom_out_icon.png +0 -0
- package/stat/css/BookReader.scss +0 -89
- package/stat/css/_BRBookmarks.scss +0 -29
- package/stat/css/_BRComponent.scss +0 -13
- package/stat/css/_BRfloat.scss +0 -197
- package/stat/css/_BRicon.scss +0 -48
- package/stat/css/_BRmain.scss +0 -251
- package/stat/css/_BRnav.scss +0 -359
- package/stat/css/_BRpages.scss +0 -139
- package/stat/css/_BRsearch.scss +0 -226
- package/stat/css/_BRtoolbar.scss +0 -84
- package/stat/css/_BRvendor.scss +0 -5
- package/stat/css/_MobileNav.scss +0 -194
- package/stat/css/_TextSelection.scss +0 -32
- package/stat/css/_colorbox.scss +0 -52
- package/stat/css/_controls.scss +0 -253
- package/stat/css/_icons.scss +0 -121
- package/stat/jquery-wrapper.js +0 -4
- package/stat/plugins/plugin.archive_analytics.js +0 -86
- package/stat/plugins/plugin.autoplay.js +0 -129
- package/stat/plugins/plugin.chapters.js +0 -248
- package/stat/plugins/plugin.iframe.js +0 -48
- package/stat/plugins/plugin.mobile_nav.js +0 -288
- package/stat/plugins/plugin.resume.js +0 -68
- package/stat/plugins/plugin.text_selection.js +0 -291
- package/stat/plugins/plugin.url.js +0 -198
- package/stat/plugins/plugin.vendor-fullscreen.js +0 -247
- package/stat/plugins/search/plugin.search.js +0 -439
- package/stat/plugins/search/view.js +0 -439
- package/stat/plugins/tts/AbstractTTSEngine.js +0 -249
- package/stat/plugins/tts/FestivalTTSEngine.js +0 -169
- package/stat/plugins/tts/PageChunk.js +0 -107
- package/stat/plugins/tts/PageChunkIterator.js +0 -163
- package/stat/plugins/tts/WebTTSEngine.js +0 -357
- package/stat/plugins/tts/plugin.tts.js +0 -357
- package/stat/plugins/tts/tooltip_dict.js +0 -15
- package/stat/plugins/tts/utils.js +0 -91
- package/stat/util/browserSniffing.js +0 -30
- package/stat/util/debouncer.js +0 -26
- package/stat/util/docCookies.js +0 -67
- package/stat/util/strings.js +0 -34
@@ -1,310 +0,0 @@
|
|
1
|
-
/** @typedef {import("../../BookReader.js").default} BookReader */
|
2
|
-
|
3
|
-
import 'jquery-ui/ui/widget.js';
|
4
|
-
import 'jquery-ui/ui/widgets/mouse.js';
|
5
|
-
import 'jquery-ui/ui/widgets/slider.js';
|
6
|
-
import { EVENTS } from '../events.js';
|
7
|
-
|
8
|
-
export class Navbar {
|
9
|
-
/**
|
10
|
-
* @param {BookReader} br
|
11
|
-
*/
|
12
|
-
constructor(br) {
|
13
|
-
this.br = br;
|
14
|
-
|
15
|
-
/** @type {JQuery} */
|
16
|
-
this.$root = null;
|
17
|
-
/** @type {JQuery} */
|
18
|
-
this.$nav = null;
|
19
|
-
/** @type {number} */
|
20
|
-
this.maxPageNum = null;
|
21
|
-
|
22
|
-
/** @type {Object} controls will be switch over "this.maximumControls" */
|
23
|
-
this.minimumControls = [
|
24
|
-
'viewmode'
|
25
|
-
];
|
26
|
-
/** @type {Object} controls will be switch over "this.minimumControls" */
|
27
|
-
this.maximumControls = [
|
28
|
-
'book_left', 'book_right', 'zoom_in', 'zoom_out', 'onepg', 'twopg', 'thumb'
|
29
|
-
];
|
30
|
-
}
|
31
|
-
|
32
|
-
controlFor(controlName) {
|
33
|
-
const option = this.br.options.controls[controlName];
|
34
|
-
if (!option.visible) { return ''; }
|
35
|
-
if (option.template) {
|
36
|
-
return `<li>${option.template(this.br)}</li>`;
|
37
|
-
}
|
38
|
-
return `<li>
|
39
|
-
<button class="BRicon ${option.className}" title="${option.label}">
|
40
|
-
<div class="icon icon-${option.iconClassName}"></div>
|
41
|
-
<span class="tooltip">${option.label}</span>
|
42
|
-
</button>
|
43
|
-
</li>`;
|
44
|
-
}
|
45
|
-
|
46
|
-
/** @private */
|
47
|
-
_renderControls() {
|
48
|
-
return [
|
49
|
-
'bookLeft',
|
50
|
-
'bookRight',
|
51
|
-
'onePage',
|
52
|
-
'twoPage',
|
53
|
-
'thumbnail',
|
54
|
-
'viewmode',
|
55
|
-
'zoomOut',
|
56
|
-
'zoomIn',
|
57
|
-
'fullScreen',
|
58
|
-
].map((mode) => (
|
59
|
-
this.controlFor(mode)
|
60
|
-
)).join('');
|
61
|
-
}
|
62
|
-
|
63
|
-
/** @private */
|
64
|
-
_bindViewModeButton() {
|
65
|
-
const { br } = this;
|
66
|
-
const viewModeOptions = br.options.controls.viewmode;
|
67
|
-
const viewModes = [{
|
68
|
-
mode: br.constMode1up,
|
69
|
-
className: 'onepg',
|
70
|
-
title: 'One-page view',
|
71
|
-
}, {
|
72
|
-
mode: br.constMode2up,
|
73
|
-
className: 'twopg',
|
74
|
-
title: 'Two-page view',
|
75
|
-
}, {
|
76
|
-
mode: br.constModeThumb,
|
77
|
-
className: 'thumb',
|
78
|
-
title: 'Thumbnail view',
|
79
|
-
}].filter((mode) => (
|
80
|
-
!viewModeOptions.excludedModes.includes(mode.mode)
|
81
|
-
));
|
82
|
-
const viewModeOrder = viewModes.map((m) => m.mode);
|
83
|
-
|
84
|
-
if (viewModeOptions.excludedModes.includes(br.mode)) {
|
85
|
-
br.switchMode(viewModeOrder[0]);
|
86
|
-
}
|
87
|
-
|
88
|
-
// Reorder the viewModeOrder so the current view mode is at the end
|
89
|
-
const currentModeIndex = viewModeOrder.indexOf(br.mode);
|
90
|
-
for (let i = 0; i <= currentModeIndex; i++) {
|
91
|
-
viewModeOrder.push(viewModeOrder.shift());
|
92
|
-
}
|
93
|
-
|
94
|
-
if (viewModes.length < 2) {
|
95
|
-
this.$nav.find(`.${viewModeOptions.className}`).remove();
|
96
|
-
}
|
97
|
-
|
98
|
-
this.br.bind(EVENTS.PostInit, () => {
|
99
|
-
const $button = this.$nav.find(`.${viewModeOptions.className}`)
|
100
|
-
.off('.bindNavigationHandlers')
|
101
|
-
.on('click', (e) => {
|
102
|
-
const nextModeID = viewModeOrder.shift();
|
103
|
-
const newViewMode = viewModes.find((m) => m.mode === nextModeID);
|
104
|
-
const nextViewMode = viewModes.find((m) => m.mode === viewModeOrder[0]);
|
105
|
-
|
106
|
-
viewModeOrder.push(nextModeID);
|
107
|
-
br.viewModeOrder = viewModeOrder;
|
108
|
-
this.updateViewModeButton($(e.currentTarget), nextViewMode.className, nextViewMode.title);
|
109
|
-
br.switchMode(newViewMode.mode);
|
110
|
-
});
|
111
|
-
const currentViewModeButton = viewModes.find((m) => m.mode === viewModeOrder[0]);
|
112
|
-
this.updateViewModeButton(
|
113
|
-
$button,
|
114
|
-
currentViewModeButton.className,
|
115
|
-
currentViewModeButton.title
|
116
|
-
);
|
117
|
-
});
|
118
|
-
}
|
119
|
-
|
120
|
-
/**
|
121
|
-
* Toggle viewmode button to change page view
|
122
|
-
*/
|
123
|
-
updateViewModeButton($button, iconClass, tooltipText) {
|
124
|
-
$button
|
125
|
-
.attr('title', tooltipText)
|
126
|
-
.find('.icon')
|
127
|
-
.removeClass()
|
128
|
-
.addClass(`icon icon-${iconClass}`)
|
129
|
-
.end()
|
130
|
-
.find('.tooltip')
|
131
|
-
.text(tooltipText);
|
132
|
-
}
|
133
|
-
|
134
|
-
/**
|
135
|
-
* Switch navbar controls on mobile and desktop
|
136
|
-
*/
|
137
|
-
switchNavbarControls() {
|
138
|
-
// we don't want navbar controls switching with liner-notes
|
139
|
-
if (this.br.options.bookType !== 'linerNotes') {
|
140
|
-
if (this.br.refs.$brContainer.prop('clientWidth') < 640) {
|
141
|
-
this.showMinimumNavbarControls();
|
142
|
-
} else {
|
143
|
-
this.showMaximumNavbarControls();
|
144
|
-
}
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
/**
|
149
|
-
* Switch Book Navbar controls to minimised
|
150
|
-
* NOTE: only `this.minimumControls` and `this.maximumControls` switch on resize
|
151
|
-
*/
|
152
|
-
showMinimumNavbarControls() {
|
153
|
-
this.minimumControls.forEach((control) => {
|
154
|
-
const element = document.querySelector(`.controls .${control}`);
|
155
|
-
if (element) element.classList.remove('hide');
|
156
|
-
});
|
157
|
-
this.maximumControls.forEach((control) => {
|
158
|
-
const element = document.querySelector(`.controls .${control}`);
|
159
|
-
if (element) element.classList.add('hide');
|
160
|
-
});
|
161
|
-
}
|
162
|
-
|
163
|
-
/**
|
164
|
-
* Switch Book Navbar controls to maximized
|
165
|
-
* NOTE: only `this.minimumControls` and `this.maximumControls` switch on resize
|
166
|
-
*/
|
167
|
-
showMaximumNavbarControls() {
|
168
|
-
this.maximumControls.forEach((control) => {
|
169
|
-
const element = document.querySelector(`.controls .${control}`);
|
170
|
-
if (element) element.classList.remove('hide');
|
171
|
-
});
|
172
|
-
this.minimumControls.forEach((control) => {
|
173
|
-
const element = document.querySelector(`.controls .${control}`);
|
174
|
-
if (element) element.classList.add('hide');
|
175
|
-
});
|
176
|
-
}
|
177
|
-
|
178
|
-
/**
|
179
|
-
* Initialize the navigation bar (bottom)
|
180
|
-
* @return {JQuery}
|
181
|
-
*/
|
182
|
-
init() {
|
183
|
-
const { br } = this;
|
184
|
-
const { navbarTitle: title } = br.options;
|
185
|
-
const isRTL = br.pageProgression === 'rl';
|
186
|
-
const bookFlipLeft = isRTL ? 'book_flip_next' : 'book_flip_prev';
|
187
|
-
const bookFlipRight = isRTL ? 'book_flip_prev' : 'book_flip_next';
|
188
|
-
|
189
|
-
this.br.options.controls['bookLeft'].className = `book_left ${bookFlipLeft}`;
|
190
|
-
this.br.options.controls['bookRight'].className = `book_right ${bookFlipRight}`;
|
191
|
-
|
192
|
-
br.refs.$BRfooter = this.$root = $(`<div class="BRfooter"></div>`);
|
193
|
-
br.refs.$BRnav = this.$nav = $(
|
194
|
-
`<div class="BRnav BRnavDesktop">
|
195
|
-
${title ? `<div class="BRnavTitle">${title}</div>` : ''}
|
196
|
-
<nav class="BRcontrols">
|
197
|
-
<ul class="controls">
|
198
|
-
<li class="scrubber">
|
199
|
-
<div class="BRnavpos">
|
200
|
-
<div class="BRpager"></div>
|
201
|
-
<div class="BRnavline"></div>
|
202
|
-
</div>
|
203
|
-
<p><span class='BRcurrentpage'></span></p>
|
204
|
-
</li>
|
205
|
-
${this._renderControls()}
|
206
|
-
</ul>
|
207
|
-
</nav>
|
208
|
-
</div>`);
|
209
|
-
|
210
|
-
this.$root.append(this.$nav);
|
211
|
-
br.refs.$br.append(this.$root);
|
212
|
-
|
213
|
-
const $slider = this.$root.find('.BRpager').slider({
|
214
|
-
animate: true,
|
215
|
-
min: 0,
|
216
|
-
max: br.getNumLeafs() - 1,
|
217
|
-
value: br.currentIndex(),
|
218
|
-
range: "min"
|
219
|
-
});
|
220
|
-
|
221
|
-
$slider.on('slide', (event, ui) => {
|
222
|
-
this.updateNavPageNum(ui.value);
|
223
|
-
return true;
|
224
|
-
});
|
225
|
-
|
226
|
-
$slider.on('slidechange', (event, ui) => {
|
227
|
-
this.updateNavPageNum(ui.value);
|
228
|
-
// recursion prevention for jumpToIndex
|
229
|
-
if ($slider.data('swallowchange')) {
|
230
|
-
$slider.data('swallowchange', false);
|
231
|
-
} else {
|
232
|
-
br.jumpToIndex(ui.value);
|
233
|
-
}
|
234
|
-
return true;
|
235
|
-
});
|
236
|
-
|
237
|
-
br.options.controls.viewmode.visible && this._bindViewModeButton();
|
238
|
-
this.updateNavPageNum(br.currentIndex());
|
239
|
-
|
240
|
-
return this.$nav;
|
241
|
-
}
|
242
|
-
|
243
|
-
/**
|
244
|
-
* Returns the textual representation of the current page for the navbar
|
245
|
-
* @param {number} index
|
246
|
-
* @return {string}
|
247
|
-
*/
|
248
|
-
getNavPageNumString(index) {
|
249
|
-
const { br } = this;
|
250
|
-
// Accessible index starts at 0 (alas) so we add 1 to make human
|
251
|
-
const pageNum = br.getPageNum(index);
|
252
|
-
const pageType = br.getPageProp(index, 'pageType');
|
253
|
-
const numLeafs = br.getNumLeafs();
|
254
|
-
|
255
|
-
if (!this.maxPageNum) {
|
256
|
-
// Calculate Max page num (used for pagination display)
|
257
|
-
let maxPageNum = 0;
|
258
|
-
let pageNumVal;
|
259
|
-
for (let i = 0; i < numLeafs; i++) {
|
260
|
-
pageNumVal = br.getPageNum(i);
|
261
|
-
if (!isNaN(pageNumVal) && pageNumVal > maxPageNum) {
|
262
|
-
maxPageNum = pageNumVal;
|
263
|
-
}
|
264
|
-
}
|
265
|
-
this.maxPageNum = maxPageNum;
|
266
|
-
}
|
267
|
-
|
268
|
-
return getNavPageNumHtml(index, numLeafs, pageNum, pageType, this.maxPageNum);
|
269
|
-
}
|
270
|
-
|
271
|
-
/**
|
272
|
-
* Renders the navbar string to the DOM
|
273
|
-
* @param {number} index
|
274
|
-
*/
|
275
|
-
updateNavPageNum(index) {
|
276
|
-
this.$root.find('.BRcurrentpage').html(this.getNavPageNumString(index));
|
277
|
-
}
|
278
|
-
|
279
|
-
/**
|
280
|
-
* Update the nav bar display - does not cause navigation.
|
281
|
-
* @param {number} index
|
282
|
-
*/
|
283
|
-
updateNavIndex(index) {
|
284
|
-
// We want to update the value, but normally moving the slider
|
285
|
-
// triggers jumpToIndex which triggers this method
|
286
|
-
index = index !== undefined ? index : this.br.currentIndex();
|
287
|
-
this.$root.find('.BRpager').data('swallowchange', true).slider('value', index);
|
288
|
-
}
|
289
|
-
}
|
290
|
-
|
291
|
-
/**
|
292
|
-
* Renders the html for the page string
|
293
|
-
* @param {number} index
|
294
|
-
* @param {number} numLeafs
|
295
|
-
* @param {number|string} pageNum
|
296
|
-
* @param {*} pageType @deprecated
|
297
|
-
* @param {number} maxPageNum
|
298
|
-
* @return {string}
|
299
|
-
*/
|
300
|
-
export function getNavPageNumHtml(index, numLeafs, pageNum, pageType, maxPageNum) {
|
301
|
-
const pageIsAsserted = pageNum[0] != 'n';
|
302
|
-
|
303
|
-
if (!pageIsAsserted) {
|
304
|
-
const pageIndex = index + 1;
|
305
|
-
return `(${pageIndex} of ${numLeafs})`; // Page (8 of 10)
|
306
|
-
}
|
307
|
-
|
308
|
-
const bookLengthLabel = maxPageNum ? ` of ${maxPageNum}` : '';
|
309
|
-
return `${pageNum}${bookLengthLabel}`;
|
310
|
-
}
|
@@ -1,120 +0,0 @@
|
|
1
|
-
// @ts-check
|
2
|
-
/** @typedef {import('./BookModel.js').PageModel} PageModel */
|
3
|
-
/** @typedef {import('./ImageCache.js').ImageCache} ImageCache */
|
4
|
-
|
5
|
-
|
6
|
-
export class PageContainer {
|
7
|
-
/**
|
8
|
-
* @param {PageModel} page
|
9
|
-
* @param {object} opts
|
10
|
-
* @param {boolean} opts.isProtected Whether we're in a protected book
|
11
|
-
* @param {ImageCache} opts.imageCache
|
12
|
-
* @param {string} opts.loadingImage
|
13
|
-
*/
|
14
|
-
constructor(page, {isProtected, imageCache, loadingImage}) {
|
15
|
-
this.page = page;
|
16
|
-
this.imageCache = imageCache;
|
17
|
-
this.loadingImage = loadingImage;
|
18
|
-
this.$container = $('<div />', {
|
19
|
-
'class': `BRpagecontainer ${page ? `pagediv${page.index}` : 'BRemptypage'}`,
|
20
|
-
css: { position: 'absolute' },
|
21
|
-
}).attr('data-side', page?.pageSide);
|
22
|
-
|
23
|
-
if (isProtected) {
|
24
|
-
this.$container.append($('<div class="BRscreen" />'));
|
25
|
-
this.$container.addClass('protected');
|
26
|
-
}
|
27
|
-
|
28
|
-
/** @type {JQuery<HTMLImageElement>} The main book page image */
|
29
|
-
this.$img = null;
|
30
|
-
}
|
31
|
-
|
32
|
-
/**
|
33
|
-
* @param {object} param0
|
34
|
-
* @param {{ width: number, height: number, top: number, left: number }} [param0.dimensions]
|
35
|
-
* @param {number} param0.reduce
|
36
|
-
*/
|
37
|
-
update({dimensions = null, reduce = null}) {
|
38
|
-
if (dimensions) {
|
39
|
-
this.$container.css(dimensions);
|
40
|
-
}
|
41
|
-
|
42
|
-
if (reduce == null || !this.page) {
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
|
46
|
-
const alreadyLoaded = this.imageCache.imageLoaded(this.page.index, reduce);
|
47
|
-
const nextBestLoadedReduce = !alreadyLoaded && this.imageCache.getBestLoadedReduce(this.page.index, reduce);
|
48
|
-
|
49
|
-
// Add the actual, highres image
|
50
|
-
this.$img?.remove();
|
51
|
-
this.$img = this.imageCache
|
52
|
-
.image(this.page.index, reduce)
|
53
|
-
.prependTo(this.$container);
|
54
|
-
|
55
|
-
const backgroundLayers = [];
|
56
|
-
if (!alreadyLoaded) {
|
57
|
-
this.$container.addClass('BRpageloading');
|
58
|
-
backgroundLayers.push(`url("${this.loadingImage}") center/20px no-repeat`);
|
59
|
-
}
|
60
|
-
if (nextBestLoadedReduce) {
|
61
|
-
backgroundLayers.push(`url("${this.page.getURI(nextBestLoadedReduce, 0)}") center/100% 100% no-repeat`);
|
62
|
-
}
|
63
|
-
|
64
|
-
if (!alreadyLoaded) {
|
65
|
-
this.$img
|
66
|
-
.css('background', backgroundLayers.join(','))
|
67
|
-
.one('loadend', async (ev) => {
|
68
|
-
$(ev.target).css({ 'background': '' });
|
69
|
-
$(ev.target).parent().removeClass('BRpageloading');
|
70
|
-
});
|
71
|
-
}
|
72
|
-
|
73
|
-
return this;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
|
78
|
-
/**
|
79
|
-
* @param {PageModel} page
|
80
|
-
* @param {string} className
|
81
|
-
*/
|
82
|
-
export function createSVGPageLayer(page, className) {
|
83
|
-
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
84
|
-
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
85
|
-
svg.setAttribute("viewBox", `0 0 ${page.width} ${page.height}`);
|
86
|
-
svg.setAttribute('class', `BRPageLayer ${className}`);
|
87
|
-
svg.setAttribute('preserveAspectRatio', 'none');
|
88
|
-
return svg;
|
89
|
-
}
|
90
|
-
|
91
|
-
/**
|
92
|
-
* @param {{ l: number, r: number, b: number, t: number }} box
|
93
|
-
*/
|
94
|
-
export function boxToSVGRect({ l: left, r: right, b: bottom, t: top }) {
|
95
|
-
const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
96
|
-
rect.setAttribute("x", left.toString());
|
97
|
-
rect.setAttribute("y", top.toString());
|
98
|
-
rect.setAttribute("width", (right - left).toString());
|
99
|
-
rect.setAttribute("height", (bottom - top).toString());
|
100
|
-
return rect;
|
101
|
-
}
|
102
|
-
|
103
|
-
/**
|
104
|
-
* @param {string} layerClass
|
105
|
-
* @param {Array<{ l: number, r: number, b: number, t: number }>} boxes
|
106
|
-
* @param {PageModel} page
|
107
|
-
* @param {HTMLElement} containerEl
|
108
|
-
*/
|
109
|
-
export function renderBoxesInPageContainerLayer(layerClass, boxes, page, containerEl) {
|
110
|
-
const mountedSvg = containerEl.querySelector(`.${layerClass}`);
|
111
|
-
// Create the layer if it's not there
|
112
|
-
const svg = mountedSvg || createSVGPageLayer(page, layerClass);
|
113
|
-
if (!mountedSvg) {
|
114
|
-
// Insert after the image if the image is already loaded.
|
115
|
-
const imgEl = containerEl.querySelector('.BRpageimage');
|
116
|
-
if (imgEl) $(svg).insertAfter(imgEl);
|
117
|
-
else $(svg).prependTo(containerEl);
|
118
|
-
}
|
119
|
-
boxes.forEach(box => svg.appendChild(boxToSVGRect(box)));
|
120
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @typedef {object} ReduceSet Set of valid numbers for a reduce variable.
|
3
|
-
* @property {(n: number) => number} floor
|
4
|
-
* @property {(n: number) => number} decr Return the predecessor of the given element
|
5
|
-
*/
|
6
|
-
|
7
|
-
/** @type {ReduceSet} */
|
8
|
-
export const IntegerReduceSet = {
|
9
|
-
floor: Math.floor,
|
10
|
-
decr(n) { return n - 1; }
|
11
|
-
};
|
12
|
-
|
13
|
-
/** @type {ReduceSet} */
|
14
|
-
export const Pow2ReduceSet = {
|
15
|
-
floor(n) {
|
16
|
-
return 2 ** (Math.floor(Math.log2(Math.max(1, n))));
|
17
|
-
},
|
18
|
-
decr(n) {
|
19
|
-
return 2 ** (Math.log2(n) - 1);
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
export const NAMED_REDUCE_SETS = {
|
24
|
-
pow2: Pow2ReduceSet,
|
25
|
-
integer: IntegerReduceSet,
|
26
|
-
};
|