@internetarchive/bookreader 5.0.0-6-14 → 5.0.0-60
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +17 -15
- package/.github/workflows/node.js.yml +72 -10
- package/.github/workflows/npm-publish.yml +6 -20
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +241 -140
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.LICENSE.txt +24 -20
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1519 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +17 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/icons/pause.svg +1 -1
- package/BookReader/icons/playback-speed.svg +1 -1
- package/BookReader/icons/read-aloud.svg +1 -1
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/images/BRicons.svg +2 -2
- package/BookReader/images/books_graphic.svg +1 -1
- package/BookReader/images/icon_book.svg +1 -1
- package/BookReader/images/icon_gear.svg +1 -1
- package/BookReader/images/icon_info.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -1
- package/BookReader/images/icon_search_button.svg +1 -1
- package/BookReader/images/icon_share.svg +1 -1
- package/BookReader/images/icon_speaker.svg +1 -1
- package/BookReader/images/icon_speaker_open.svg +1 -1
- package/BookReader/images/marker_chap-off.svg +1 -1
- package/BookReader/images/marker_chap-on.svg +1 -1
- package/BookReader/images/marker_srch-on.svg +1 -1
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +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.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.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/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +14 -1
- package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
- package/BookReaderDemo/BookReaderJSSimple.js +1 -0
- package/BookReaderDemo/IADemoBr.js +147 -0
- package/BookReaderDemo/demo-advanced.html +2 -2
- package/BookReaderDemo/demo-autoplay.html +2 -1
- package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
- package/BookReaderDemo/demo-fullscreen-mobile.html +2 -1
- package/BookReaderDemo/demo-fullscreen.html +2 -1
- package/BookReaderDemo/demo-iiif.html +2 -1
- package/BookReaderDemo/demo-internetarchive.html +84 -17
- package/BookReaderDemo/demo-multiple.html +2 -1
- package/BookReaderDemo/demo-preview-pages.html +2 -1
- package/BookReaderDemo/demo-simple.html +2 -1
- package/BookReaderDemo/demo-vendor-fullscreen.html +2 -1
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
- package/BookReaderDemo/immersion-1up.html +2 -1
- package/BookReaderDemo/immersion-mode.html +2 -1
- package/BookReaderDemo/toggle_controls.html +2 -1
- package/BookReaderDemo/view_mode.html +2 -1
- package/BookReaderDemo/viewmode-cycle.html +2 -3
- package/CHANGELOG.md +244 -0
- package/README.md +14 -1
- package/babel.config.js +19 -0
- package/codecov.yml +6 -0
- package/index.html +3 -0
- package/jsconfig.json +19 -0
- package/netlify.toml +5 -0
- package/package.json +70 -59
- package/renovate.json +52 -0
- package/scripts/preversion.js +4 -1
- package/src/BookNavigator/assets/bookmark-colors.js +1 -1
- package/src/BookNavigator/assets/button-base.js +9 -2
- package/src/BookNavigator/assets/ia-logo.js +17 -0
- package/src/BookNavigator/assets/icon_checkmark.js +1 -1
- package/src/BookNavigator/assets/icon_close.js +1 -1
- package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
- package/src/BookNavigator/assets/icon_volumes.js +11 -0
- package/src/BookNavigator/book-navigator.js +585 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
- package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
- package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
- package/src/BookNavigator/delete-modal-actions.js +1 -1
- package/src/BookNavigator/downloads/downloads-provider.js +36 -21
- package/src/BookNavigator/downloads/downloads.js +41 -25
- package/src/BookNavigator/search/search-provider.js +80 -28
- package/src/BookNavigator/search/search-results.js +34 -25
- package/src/BookNavigator/sharing.js +27 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
- package/src/BookNavigator/volumes/volumes-provider.js +111 -0
- package/src/BookNavigator/volumes/volumes.js +188 -0
- package/src/BookReader/BookModel.js +59 -30
- package/src/BookReader/DebugConsole.js +3 -3
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +56 -351
- package/src/BookReader/Mode1UpLit.js +391 -0
- package/src/BookReader/Mode2Up.js +73 -1318
- package/src/BookReader/Mode2UpLit.js +781 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +211 -0
- package/src/BookReader/ModeThumb.js +17 -11
- package/src/BookReader/Navbar/Navbar.js +10 -36
- package/src/BookReader/PageContainer.js +69 -6
- package/src/BookReader/ReduceSet.js +1 -1
- package/src/BookReader/Toolbar/Toolbar.js +10 -37
- package/src/BookReader/events.js +2 -0
- package/src/BookReader/options.js +24 -2
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils.js +108 -13
- package/src/BookReader.js +481 -828
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/assets/icons/voice.svg +1 -0
- package/src/css/_BRBookmarks.scss +1 -1
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +33 -0
- package/src/css/_BRnav.scss +4 -26
- package/src/css/_BRpages.scss +147 -40
- package/src/css/_BRsearch.scss +25 -11
- package/src/css/_TextSelection.scss +16 -17
- package/src/css/_colorbox.scss +2 -2
- package/src/css/_controls.scss +17 -5
- package/src/css/_icons.scss +7 -1
- package/src/ia-bookreader/ia-bookreader.js +224 -0
- package/src/plugins/plugin.archive_analytics.js +3 -3
- package/src/plugins/plugin.autoplay.js +4 -9
- package/src/plugins/plugin.chapters.js +28 -35
- package/src/plugins/plugin.mobile_nav.js +11 -10
- package/src/plugins/plugin.resume.js +3 -3
- package/src/plugins/plugin.text_selection.js +32 -41
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +179 -103
- package/src/plugins/search/view.js +59 -44
- package/src/plugins/tts/AbstractTTSEngine.js +46 -37
- package/src/plugins/tts/FestivalTTSEngine.js +13 -14
- package/src/plugins/tts/PageChunk.js +15 -21
- package/src/plugins/tts/PageChunkIterator.js +8 -12
- package/src/plugins/tts/WebTTSEngine.js +87 -71
- package/src/plugins/tts/plugin.tts.js +94 -125
- package/src/plugins/tts/utils.js +0 -25
- package/src/plugins/url/UrlPlugin.js +193 -0
- package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
- package/src/util/docCookies.js +21 -2
- package/tests/e2e/README.md +37 -0
- package/tests/e2e/autoplay.test.js +2 -2
- package/tests/e2e/base.test.js +7 -7
- package/tests/e2e/helpers/base.js +28 -23
- package/tests/e2e/helpers/debug.js +1 -1
- package/tests/e2e/helpers/desktopSearch.js +14 -13
- package/tests/e2e/helpers/mobileSearch.js +3 -3
- package/tests/e2e/helpers/params.js +17 -0
- package/tests/e2e/helpers/rightToLeft.js +4 -10
- package/tests/e2e/models/Navigation.js +13 -4
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +40 -33
- package/tests/jest/BookNavigator/book-navigator.test.js +658 -0
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
- package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
- package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
- package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +104 -60
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +184 -0
- package/tests/jest/BookNavigator/volumes/volumes.test.js +97 -0
- package/tests/{BookReader → jest/BookReader}/BookModel.test.js +59 -14
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
- package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
- package/tests/jest/BookReader/Mode2Up.test.js +98 -0
- package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
- package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +175 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
- package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
- package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
- package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
- package/tests/jest/BookReader/utils.test.js +217 -0
- package/tests/jest/BookReader.keyboard.test.js +190 -0
- package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
- package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
- package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
- package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +10 -11
- package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
- package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
- package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +39 -47
- package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
- package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +57 -47
- package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +35 -6
- package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +9 -9
- package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
- package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
- package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
- package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
- package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
- package/tests/jest/setup.js +3 -0
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/jest/util/docCookies.test.js +24 -0
- package/tests/{util → jest/util}/strings.test.js +1 -1
- package/tests/{utils.js → jest/utils.js} +38 -0
- package/webpack.config.js +11 -5
- package/.babelrc +0 -12
- package/.dependabot/config.yml +0 -6
- package/.testcaferc.json +0 -5
- package/BookReader/bookreader-component-bundle.js +0 -1450
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/jquery-1.10.1.js +0 -2
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -2
- package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
- package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
- package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
- package/karma.conf.js +0 -23
- package/src/BookNavigator/BookModel.js +0 -14
- package/src/BookNavigator/BookNavigator.js +0 -438
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
- package/src/BookNavigator/search/a-search-result.js +0 -55
- package/src/BookReaderComponent/BookReaderComponent.js +0 -112
- package/src/ItemNavigator/ItemNavigator.js +0 -372
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/dragscrollable-br.js +0 -261
- package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
- package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
- package/tests/BookReader/Mode1Up.test.js +0 -164
- package/tests/BookReader/Mode2Up.test.js +0 -247
- package/tests/BookReader/utils.test.js +0 -109
- package/tests/e2e/ia-production/ia-prod-base.js +0 -17
- package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
- package/tests/util/docCookies.test.js +0 -15
@@ -0,0 +1,224 @@
|
|
1
|
+
/**
|
2
|
+
* BookReaderTemplate to load BookNavigator components
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { LitElement, html, css } from 'lit';
|
6
|
+
|
7
|
+
import '@internetarchive/ia-item-navigator';
|
8
|
+
import '../BookNavigator/book-navigator.js';
|
9
|
+
// eslint-disable-next-line no-unused-vars
|
10
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
11
|
+
import '@internetarchive/modal-manager';
|
12
|
+
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
13
|
+
|
14
|
+
export class IaBookReader extends LitElement {
|
15
|
+
static get properties() {
|
16
|
+
return {
|
17
|
+
item: { type: Object },
|
18
|
+
baseHost: { type: String },
|
19
|
+
signedIn: { type: Boolean },
|
20
|
+
fullscreen: { type: Boolean, reflect: true, attribute: true },
|
21
|
+
sharedObserver: { type: Object, attribute: false },
|
22
|
+
modal: { type: Object, attribute: false },
|
23
|
+
loaded: { type: Boolean },
|
24
|
+
menuShortcuts: { type: Array },
|
25
|
+
menuContents: { type: Array },
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
constructor() {
|
30
|
+
super();
|
31
|
+
this.item = undefined;
|
32
|
+
this.bookreader = undefined;
|
33
|
+
this.baseHost = 'https://archive.org';
|
34
|
+
this.fullscreen = false;
|
35
|
+
this.signedIn = false;
|
36
|
+
/** @type {ModalManager} */
|
37
|
+
this.modal = undefined;
|
38
|
+
/** @type {SharedResizeObserver} */
|
39
|
+
this.sharedObserver = undefined;
|
40
|
+
this.loaded = false;
|
41
|
+
this.menuShortcuts = [];
|
42
|
+
this.menuContents = [];
|
43
|
+
this.openMenuName = '';
|
44
|
+
}
|
45
|
+
|
46
|
+
updated() {
|
47
|
+
if (!this.modal) {
|
48
|
+
this.setModalManager();
|
49
|
+
}
|
50
|
+
|
51
|
+
if (!this.sharedObserver) {
|
52
|
+
this.sharedObserver = new SharedResizeObserver();
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
get itemNav() {
|
57
|
+
return this.shadowRoot.querySelector('ia-item-navigator');
|
58
|
+
}
|
59
|
+
|
60
|
+
/** Creates modal DOM & attaches to `<body>` */
|
61
|
+
setModalManager() {
|
62
|
+
let modalManager = document.querySelector('modal-manager');
|
63
|
+
if (!modalManager) {
|
64
|
+
modalManager = document.createElement(
|
65
|
+
'modal-manager'
|
66
|
+
);
|
67
|
+
document.body.appendChild(modalManager);
|
68
|
+
}
|
69
|
+
|
70
|
+
this.modal = modalManager;
|
71
|
+
}
|
72
|
+
|
73
|
+
manageFullscreen(e) {
|
74
|
+
const { detail } = e;
|
75
|
+
const fullscreen = !!detail.isFullScreen;
|
76
|
+
this.fullscreen = fullscreen;
|
77
|
+
this.dispatchEvent(new CustomEvent('fullscreenStateUpdated', { detail: { fullscreen }}));
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
loadingStateUpdated(e) {
|
82
|
+
const { loaded } = e.detail;
|
83
|
+
this.loaded = loaded || null;
|
84
|
+
this.dispatchEvent(new CustomEvent('loadingStateUpdated', { detail: { loaded }}));
|
85
|
+
}
|
86
|
+
|
87
|
+
setMenuShortcuts(e) {
|
88
|
+
this.menuShortcuts = [...e.detail];
|
89
|
+
}
|
90
|
+
|
91
|
+
setMenuContents(e) {
|
92
|
+
const updatedContents = [...e.detail];
|
93
|
+
this.menuContents = updatedContents;
|
94
|
+
}
|
95
|
+
|
96
|
+
manageSideMenuEvents(e) {
|
97
|
+
const { menuId, action } = e.detail;
|
98
|
+
if (!menuId) {
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
|
102
|
+
this.openMenuName = menuId;
|
103
|
+
|
104
|
+
if (action === 'open') {
|
105
|
+
this.itemNav?.openShortcut(menuId);
|
106
|
+
} else if (action === 'toggle') {
|
107
|
+
this.itemNav?.toggleMenu();
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
render() {
|
112
|
+
return html`
|
113
|
+
<div class="main-component">
|
114
|
+
<ia-item-navigator
|
115
|
+
?viewportInFullscreen=${this.fullscreen}
|
116
|
+
.basehost=${this.baseHost}
|
117
|
+
.item=${this.item}
|
118
|
+
.modal=${this.modal}
|
119
|
+
.loaded=${this.loaded}
|
120
|
+
.sharedObserver=${this.sharedObserver}
|
121
|
+
?signedIn=${this.signedIn}
|
122
|
+
.menuShortcuts=${this.menuShortcuts}
|
123
|
+
.menuContents=${this.menuContents}
|
124
|
+
.openMenu=${this.openMenuName}
|
125
|
+
>
|
126
|
+
<div slot="header">
|
127
|
+
<slot name="header"></slot>
|
128
|
+
</div>
|
129
|
+
<div slot="main">
|
130
|
+
<book-navigator
|
131
|
+
.modal=${this.modal}
|
132
|
+
.baseHost=${this.baseHost}
|
133
|
+
.itemMD=${this.item}
|
134
|
+
?signedIn=${this.signedIn}
|
135
|
+
?sideMenuOpen=${this.menuOpened}
|
136
|
+
.sharedObserver=${this.sharedObserver}
|
137
|
+
@ViewportInFullScreen=${this.manageFullscreen}
|
138
|
+
@loadingStateUpdated=${this.loadingStateUpdated}
|
139
|
+
@updateSideMenu=${this.manageSideMenuEvents}
|
140
|
+
@menuUpdated=${this.setMenuContents}
|
141
|
+
@menuShortcutsUpdated=${this.setMenuShortcuts}
|
142
|
+
>
|
143
|
+
<div slot="main">
|
144
|
+
<slot name="main"></slot>
|
145
|
+
</div>
|
146
|
+
</book-navigator>
|
147
|
+
</div>
|
148
|
+
</ia-item-navigator>
|
149
|
+
</div>
|
150
|
+
`;
|
151
|
+
}
|
152
|
+
|
153
|
+
static get styles() {
|
154
|
+
return css`
|
155
|
+
:host {
|
156
|
+
display: block;
|
157
|
+
--primaryBGColor: var(--black, #000);
|
158
|
+
--secondaryBGColor: #222;
|
159
|
+
--tertiaryBGColor: #333;
|
160
|
+
--primaryTextColor: var(--white, #fff);
|
161
|
+
--primaryCTAFill: #194880;
|
162
|
+
--primaryCTABorder: #c5d1df;
|
163
|
+
--secondaryCTAFill: #333;
|
164
|
+
--secondaryCTABorder: #999;
|
165
|
+
--primaryErrorCTAFill: #e51c26;
|
166
|
+
--primaryErrorCTABorder: #f8c6c8;
|
167
|
+
background-color: var(--primaryBGColor);
|
168
|
+
position: relative;
|
169
|
+
}
|
170
|
+
|
171
|
+
:host([fullscreen]),
|
172
|
+
ia-item-navigator[viewportinfullscreen] {
|
173
|
+
position: fixed;
|
174
|
+
inset: 0;
|
175
|
+
height: 100%;
|
176
|
+
min-height: unset;
|
177
|
+
}
|
178
|
+
|
179
|
+
.main-component {
|
180
|
+
height: 100%;
|
181
|
+
width: 100%;
|
182
|
+
min-height: inherit;
|
183
|
+
}
|
184
|
+
|
185
|
+
div[slot="header"],
|
186
|
+
div[slot="main"] {
|
187
|
+
display: flex;
|
188
|
+
width: 100%;
|
189
|
+
}
|
190
|
+
|
191
|
+
slot {
|
192
|
+
display: block;
|
193
|
+
flex: 1;
|
194
|
+
}
|
195
|
+
|
196
|
+
ia-item-navigator {
|
197
|
+
min-height: var(--br-height, inherit);
|
198
|
+
height: var(--br-height, inherit);
|
199
|
+
display: block;
|
200
|
+
width: 100%;
|
201
|
+
color: var(--primaryTextColor);
|
202
|
+
--menuButtonLabelDisplay: block;
|
203
|
+
--menuWidth: 320px;
|
204
|
+
--menuSliderBg: var(--secondaryBGColor);
|
205
|
+
--activeButtonBg: var(--tertiaryBGColor);
|
206
|
+
--subpanelRightBorderColor: var(--secondaryCTABorder);
|
207
|
+
--animationTiming: 100ms;
|
208
|
+
--iconFillColor: var(--primaryTextColor);
|
209
|
+
--iconStrokeColor: var(--primaryTextColor);
|
210
|
+
--menuSliderHeaderIconHeight: 2rem;
|
211
|
+
--menuSliderHeaderIconWidth: 2rem;
|
212
|
+
--iconWidth: 2.4rem;
|
213
|
+
--iconHeight: 2.4rem;
|
214
|
+
--shareLinkColor: var(--primaryTextColor);
|
215
|
+
--shareIconBorder: var(--primaryTextColor);
|
216
|
+
--shareIconBg: var(--secondaryBGColor);
|
217
|
+
--activityIndicatorLoadingDotColor: var(--primaryTextColor);
|
218
|
+
--activityIndicatorLoadingRingColor: var(--primaryTextColor);
|
219
|
+
}
|
220
|
+
`;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
window.customElements.define("ia-bookreader", IaBookReader);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* global BookReader
|
1
|
+
/* global BookReader */
|
2
2
|
/**
|
3
3
|
* Plugin for Archive.org analytics
|
4
4
|
*/
|
@@ -50,13 +50,13 @@ BookReader.prototype.archiveAnalyticsSendFragmentChange = function() {
|
|
50
50
|
// avoids embed cross site exceptions -- but on (+) side, means it is and keeps marked offite!
|
51
51
|
|
52
52
|
// Send bookreader ping
|
53
|
-
archive_analytics.send_ping(values, null, "augment_for_ao_site");
|
53
|
+
window.archive_analytics.send_ping(values, null, "augment_for_ao_site");
|
54
54
|
|
55
55
|
// Also send tracking event ping
|
56
56
|
const additionalEventParams = this.options.lendingInfo && this.options.lendingInfo.loanId
|
57
57
|
? { loanId: this.options.lendingInfo.loanId }
|
58
58
|
: {};
|
59
|
-
archive_analytics.send_event('BookReader', 'UserChangedView', window.location.pathname, additionalEventParams);
|
59
|
+
window.archive_analytics.send_event('BookReader', 'UserChangedView', window.location.pathname, additionalEventParams);
|
60
60
|
|
61
61
|
this.archiveAnalyticsSendFragmentChange.prevFragment = newFragment;
|
62
62
|
}
|
@@ -80,11 +80,6 @@ BookReader.prototype.autoToggle = function(overrides) {
|
|
80
80
|
this.switchMode(this.constMode2up);
|
81
81
|
}
|
82
82
|
|
83
|
-
// Change to autofit if book is too large
|
84
|
-
if (this.reduce < this.twoPageGetAutofitReduce()) {
|
85
|
-
this.zoom('auto');
|
86
|
-
}
|
87
|
-
|
88
83
|
if (null == this.autoTimer) {
|
89
84
|
// $$$ Draw events currently cause layout problems when they occur during animation.
|
90
85
|
// There is a specific problem when changing from 1-up immediately to autoplay in RTL so
|
@@ -94,7 +89,7 @@ BookReader.prototype.autoToggle = function(overrides) {
|
|
94
89
|
// don't flip immediately -- wait until timer fires
|
95
90
|
} else {
|
96
91
|
// flip immediately
|
97
|
-
this.
|
92
|
+
this.next({ triggerStop: false });
|
98
93
|
}
|
99
94
|
|
100
95
|
this.$('.play').hide();
|
@@ -102,10 +97,10 @@ BookReader.prototype.autoToggle = function(overrides) {
|
|
102
97
|
this.autoTimer = setInterval(() => {
|
103
98
|
if (this.animating) return;
|
104
99
|
|
105
|
-
if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.
|
106
|
-
this.
|
100
|
+
if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.book.getNumLeafs() - 1) {
|
101
|
+
this.prev({ triggerStop: false }); // $$$ really what we want?
|
107
102
|
} else {
|
108
|
-
this.
|
103
|
+
this.next({ triggerStop: false });
|
109
104
|
}
|
110
105
|
}, this.flipDelay);
|
111
106
|
} else {
|
@@ -36,14 +36,12 @@ BookReader.prototype.init = (function(super_) {
|
|
36
36
|
this.updateTOCState(this.firstIndex, this._tocEntries);
|
37
37
|
}
|
38
38
|
}
|
39
|
-
)
|
40
|
-
$(".BRmobileMenu__tableContents").click(
|
41
|
-
() => {
|
42
|
-
this.updateTOCState(this.firstIndex, this._tocEntries);
|
43
|
-
}
|
44
39
|
);
|
40
|
+
$(".BRmobileMenu__tableContents").on("click", () => {
|
41
|
+
this.updateTOCState(this.firstIndex, this._tocEntries);
|
42
|
+
});
|
45
43
|
}
|
46
|
-
}
|
44
|
+
};
|
47
45
|
})(BookReader.prototype.init);
|
48
46
|
|
49
47
|
/**
|
@@ -55,12 +53,12 @@ BookReader.prototype.init = (function(super_) {
|
|
55
53
|
*/
|
56
54
|
BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex) {
|
57
55
|
const uiStringPage = 'Page'; // i18n
|
58
|
-
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.getNumLeafs() - 1);
|
56
|
+
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.book.getNumLeafs() - 1);
|
59
57
|
const jumpToChapter = (event) => {
|
60
58
|
this.jumpToIndex($(event.delegateTarget).data('pageIndex'));
|
61
59
|
$('.current-chapter').removeClass('current-chapter');
|
62
60
|
$(event.delegateTarget).addClass('current-chapter');
|
63
|
-
}
|
61
|
+
};
|
64
62
|
const title = `${chapterTitle} | `;
|
65
63
|
const pageStr = `${uiStringPage} ${pageNumber}`;
|
66
64
|
|
@@ -79,7 +77,7 @@ BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex)
|
|
79
77
|
.css({ left: percentThrough })
|
80
78
|
.appendTo(this.$('.BRnavline'))
|
81
79
|
.data({ pageIndex })
|
82
|
-
.
|
80
|
+
.on("mouseenter", event => {
|
83
81
|
// remove hover effect from other markers then turn on just for this
|
84
82
|
const marker = event.currentTarget;
|
85
83
|
const tooltip = marker.querySelector('div');
|
@@ -91,9 +89,8 @@ BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex)
|
|
91
89
|
}
|
92
90
|
this.$('.BRsearch,.BRchapter').removeClass('front');
|
93
91
|
$(event.target).addClass('front');
|
94
|
-
}
|
95
|
-
event => $(event.target).removeClass('front')
|
96
|
-
)
|
92
|
+
})
|
93
|
+
.on("mouseleave", event => $(event.target).removeClass('front'))
|
97
94
|
.on('click', jumpToChapter);
|
98
95
|
|
99
96
|
//adding clickable properties to mobile chapters
|
@@ -126,7 +123,7 @@ BookReader.prototype.updateTOC = function(tocEntries) {
|
|
126
123
|
this._tocEntries = tocEntries;
|
127
124
|
$('.table-contents-list').children().each((i, el) => {
|
128
125
|
tocEntries[i].mobileHTML = el;
|
129
|
-
})
|
126
|
+
});
|
130
127
|
};
|
131
128
|
|
132
129
|
/**
|
@@ -154,7 +151,7 @@ BookReader.prototype.updateTOC = function(tocEntries) {
|
|
154
151
|
* @param {TocEntry} tocEntryObject
|
155
152
|
*/
|
156
153
|
BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
157
|
-
tocEntryObject.pageIndex = this.getPageIndex(tocEntryObject['pagenum']);
|
154
|
+
tocEntryObject.pageIndex = this.book.getPageIndex(tocEntryObject['pagenum']);
|
158
155
|
//creates a string with non-void tocEntryObject.label and tocEntryObject.title
|
159
156
|
const chapterStr = [tocEntryObject.label, tocEntryObject.title]
|
160
157
|
.filter(x => x)
|
@@ -162,9 +159,9 @@ BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
|
162
159
|
this.addChapter(chapterStr, tocEntryObject['pagenum'], tocEntryObject.pageIndex);
|
163
160
|
this.$('.BRchapter, .BRsearch').each((i, el) => {
|
164
161
|
const $el = $(el);
|
165
|
-
$el
|
166
|
-
() => $el.addClass('front')
|
167
|
-
() => $el.removeClass('front'));
|
162
|
+
$el
|
163
|
+
.on("mouseenter", () => $el.addClass('front'))
|
164
|
+
.on("mouseleave", () => $el.removeClass('front'));
|
168
165
|
});
|
169
166
|
};
|
170
167
|
|
@@ -177,7 +174,7 @@ BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
|
177
174
|
* This makes a call to OL API and calls the given callback function with the
|
178
175
|
* response from the API.
|
179
176
|
*/
|
180
|
-
BookReader.prototype.getOpenLibraryRecord = function () {
|
177
|
+
BookReader.prototype.getOpenLibraryRecord = async function () {
|
181
178
|
// Try looking up by ocaid first, then by source_record
|
182
179
|
const baseURL = `${this.olHost}/query.json?type=/type/edition&*=`;
|
183
180
|
const fetchUrlByBookId = `${baseURL}&ocaid=${this.bookId}`;
|
@@ -193,21 +190,17 @@ BookReader.prototype.getOpenLibraryRecord = function () {
|
|
193
190
|
}
|
194
191
|
};
|
195
192
|
|
196
|
-
$.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' })
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
setUpChapterMarkers(data[0]);
|
208
|
-
}
|
209
|
-
});
|
210
|
-
}
|
193
|
+
let data = await $.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' });
|
194
|
+
|
195
|
+
if (!data || !data.length) {
|
196
|
+
// try sourceid
|
197
|
+
data = await $.ajax({ url: `${baseURL}&source_records=ia:${this.bookId}`, dataType: 'jsonp' });
|
198
|
+
}
|
199
|
+
|
200
|
+
if (data && data.length > 0) {
|
201
|
+
setUpChapterMarkers(data[0]);
|
202
|
+
}
|
203
|
+
};
|
211
204
|
|
212
205
|
// Extend buildMobileDrawerElement with table of contents list
|
213
206
|
BookReader.prototype.buildMobileDrawerElement = (function (super_) {
|
@@ -240,7 +233,7 @@ BookReader.prototype.buildMobileDrawerElement = (function (super_) {
|
|
240
233
|
*/
|
241
234
|
BookReader.prototype.updateTOCState = function(currIndex, tocEntries) {
|
242
235
|
//this function won't have any effects if called before OpenLibrary request is finished
|
243
|
-
if (!tocEntries) {return}
|
236
|
+
if (!tocEntries) {return;}
|
244
237
|
$('.current-chapter').removeClass('current-chapter');
|
245
238
|
const tocEntriesIndexed = tocEntries.filter((el) => el.pageIndex != undefined).reverse();
|
246
239
|
const currChapter = tocEntriesIndexed[tocEntriesIndexed.findIndex(
|
@@ -248,4 +241,4 @@ BookReader.prototype.updateTOCState = function(currIndex, tocEntries) {
|
|
248
241
|
if (currChapter != undefined) {
|
249
242
|
$(currChapter.mobileHTML).addClass('current-chapter');
|
250
243
|
}
|
251
|
-
}
|
244
|
+
};
|
@@ -25,7 +25,7 @@ const FILTERLIST = [
|
|
25
25
|
filter: "contrast(120%)",
|
26
26
|
label: "High contrast"
|
27
27
|
},
|
28
|
-
]
|
28
|
+
];
|
29
29
|
|
30
30
|
jQuery.extend(BookReader.defaultOptions, {
|
31
31
|
enableMobileNav: true,
|
@@ -86,15 +86,16 @@ BookReader.prototype.initToolbar = (function (super_) {
|
|
86
86
|
});
|
87
87
|
|
88
88
|
//apply filters when checkboxs clicked
|
89
|
-
$drawerEl.find('.BRcheckbox-filters')
|
89
|
+
$drawerEl.find('.BRcheckbox-filters')
|
90
|
+
.on("click", () => applyFilters($drawerEl, this));
|
90
91
|
|
91
92
|
// Bind mobile switch buttons
|
92
|
-
$drawerEl.find('.DrawerLayoutButton.one_page_mode')
|
93
|
-
() => this.switchMode(this.constMode1up));
|
94
|
-
$drawerEl.find('.DrawerLayoutButton.two_page_mode')
|
95
|
-
() => this.switchMode(this.constMode2up));
|
96
|
-
$drawerEl.find('.DrawerLayoutButton.thumbnail_mode')
|
97
|
-
() => this.switchMode(this.constModeThumb));
|
93
|
+
$drawerEl.find('.DrawerLayoutButton.one_page_mode')
|
94
|
+
.on("click", () => this.switchMode(this.constMode1up));
|
95
|
+
$drawerEl.find('.DrawerLayoutButton.two_page_mode')
|
96
|
+
.on("click", () => this.switchMode(this.constMode2up));
|
97
|
+
$drawerEl.find('.DrawerLayoutButton.thumbnail_mode')
|
98
|
+
.on("click", () => this.switchMode(this.constModeThumb));
|
98
99
|
|
99
100
|
if (this.mobileNavFullscreenOnly) {
|
100
101
|
$(document.body).addClass('BRbodyMobileNavEnabledFullscreen');
|
@@ -178,7 +179,7 @@ BookReader.prototype.buildMobileDrawerElement = function() {
|
|
178
179
|
|
179
180
|
`;
|
180
181
|
experimentalHtml = experimentalHtml.concat(checkboxHtml);
|
181
|
-
})
|
182
|
+
});
|
182
183
|
experimentalHtml = experimentalHtml.concat("</div>");
|
183
184
|
}
|
184
185
|
|
@@ -284,4 +285,4 @@ const applyFilters = (drawerEl, br) => {
|
|
284
285
|
filter: ${filterStr};
|
285
286
|
-webkit-filter: ${filterStr};}`;
|
286
287
|
document.body.appendChild(filtersSheet);
|
287
|
-
}
|
288
|
+
};
|
@@ -37,7 +37,7 @@ BookReader.prototype.getResumeValue = function() {
|
|
37
37
|
const val = BookReader.docCookies.getItem('br-resume');
|
38
38
|
if (val !== null) return parseInt(val);
|
39
39
|
else return null;
|
40
|
-
}
|
40
|
+
};
|
41
41
|
|
42
42
|
/**
|
43
43
|
* Return cookie path using pathname up to /page/... or /mode/...
|
@@ -49,7 +49,7 @@ BookReader.prototype.getResumeValue = function() {
|
|
49
49
|
*/
|
50
50
|
BookReader.prototype.getCookiePath = function(urlPathPart) {
|
51
51
|
return urlPathPart.match('.+?(?=/page/|/mode/|$)')[0];
|
52
|
-
}
|
52
|
+
};
|
53
53
|
|
54
54
|
/**
|
55
55
|
* Sets page resume value, for remembering reader's page
|
@@ -65,4 +65,4 @@ BookReader.prototype.updateResumeValue = function(index, cookieName) {
|
|
65
65
|
const path = this.options.resumeCookiePath
|
66
66
|
|| this.getCookiePath(window.location.pathname);
|
67
67
|
BookReader.docCookies.setItem(cookieName || 'br-resume', index, ttl, path, null, false);
|
68
|
-
}
|
68
|
+
};
|
@@ -1,7 +1,9 @@
|
|
1
1
|
//@ts-check
|
2
|
+
import { createSVGPageLayer } from '../BookReader/PageContainer.js';
|
2
3
|
import { isFirefox, isSafari } from '../util/browserSniffing.js';
|
3
4
|
import { applyVariables } from '../util/strings.js';
|
4
5
|
/** @typedef {import('../util/strings.js').StringWithVars} StringWithVars */
|
6
|
+
/** @typedef {import('../BookReader/PageContainer.js').PageContainer} PageContainer */
|
5
7
|
|
6
8
|
const BookReader = /** @type {typeof import('../BookReader').default} */(window.BookReader);
|
7
9
|
|
@@ -11,6 +13,8 @@ export const DEFAULT_OPTIONS = {
|
|
11
13
|
fullDjvuXmlUrl: null,
|
12
14
|
/** @type {StringWithVars} The URL to fetch a single page of the DJVU xml. Supports options.vars. Also has {{pageIndex}} */
|
13
15
|
singlePageDjvuXmlUrl: null,
|
16
|
+
/** Whether to fetch the XML as a jsonp */
|
17
|
+
jsonp: false,
|
14
18
|
};
|
15
19
|
/** @typedef {typeof DEFAULT_OPTIONS} TextSelectionPluginOptions */
|
16
20
|
|
@@ -46,7 +50,7 @@ export class TextSelectionPlugin {
|
|
46
50
|
// Tspans are necessary on Chrome because they prevent newline character after every word when copying
|
47
51
|
this.svgParagraphElement = "text";
|
48
52
|
this.svgWordElement = "tspan";
|
49
|
-
this.insertNewlines = avoidTspans
|
53
|
+
this.insertNewlines = avoidTspans;
|
50
54
|
// Safari has a bug where `pointer-events` doesn't work on `<tspans>`. So
|
51
55
|
// there we will set `pointer-events: all` on the paragraph element. We don't
|
52
56
|
// do this everywhere, because it's a worse experience. Thanks Safari :/
|
@@ -72,7 +76,8 @@ export class TextSelectionPlugin {
|
|
72
76
|
this.djvuPagesPromise = $.ajax({
|
73
77
|
type: "GET",
|
74
78
|
url: applyVariables(this.options.fullDjvuXmlUrl, this.optionVariables),
|
75
|
-
dataType: "html",
|
79
|
+
dataType: this.options.jsonp ? "jsonp" : "html",
|
80
|
+
cache: true,
|
76
81
|
error: (e) => undefined
|
77
82
|
}).then((res) => {
|
78
83
|
try {
|
@@ -94,21 +99,21 @@ export class TextSelectionPlugin {
|
|
94
99
|
if (cachedEntry) {
|
95
100
|
return cachedEntry.response;
|
96
101
|
}
|
97
|
-
|
102
|
+
const res = await $.ajax({
|
98
103
|
type: "GET",
|
99
104
|
url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }),
|
100
|
-
dataType: "html",
|
105
|
+
dataType: this.options.jsonp ? "jsonp" : "html",
|
106
|
+
cache: true,
|
101
107
|
error: (e) => undefined,
|
102
|
-
}).then((res) => {
|
103
|
-
try {
|
104
|
-
const xmlDoc = $.parseXML(res);
|
105
|
-
const result = xmlDoc && $(xmlDoc).find("OBJECT")[0];
|
106
|
-
this.pageTextCache.add({ index, response: result });
|
107
|
-
return result;
|
108
|
-
} catch (e) {
|
109
|
-
return undefined;
|
110
|
-
}
|
111
108
|
});
|
109
|
+
try {
|
110
|
+
const xmlDoc = $.parseXML(res);
|
111
|
+
const result = xmlDoc && $(xmlDoc).find("OBJECT")[0];
|
112
|
+
this.pageTextCache.add({ index, response: result });
|
113
|
+
return result;
|
114
|
+
} catch (e) {
|
115
|
+
return undefined;
|
116
|
+
}
|
112
117
|
} else {
|
113
118
|
const XMLpagesArr = await this.djvuPagesPromise;
|
114
119
|
if (XMLpagesArr) return XMLpagesArr[index];
|
@@ -144,8 +149,8 @@ export class TextSelectionPlugin {
|
|
144
149
|
this.textSelectingMode(svg);
|
145
150
|
}
|
146
151
|
else svg.classList.remove("selectingSVG");
|
147
|
-
})
|
148
|
-
})
|
152
|
+
});
|
153
|
+
});
|
149
154
|
}
|
150
155
|
|
151
156
|
/**
|
@@ -158,13 +163,13 @@ export class TextSelectionPlugin {
|
|
158
163
|
if (window.getSelection().toString() != "") window.getSelection().removeAllRanges();
|
159
164
|
}
|
160
165
|
event.stopPropagation();
|
161
|
-
})
|
166
|
+
});
|
162
167
|
$(svg).on('mouseup.textSelectPluginHandler', (event) => {
|
163
168
|
event.stopPropagation();
|
164
169
|
if (window.getSelection().toString() == "") {
|
165
170
|
$(svg).off(".textSelectPluginHandler");
|
166
171
|
this.defaultMode(svg); }
|
167
|
-
})
|
172
|
+
});
|
168
173
|
}
|
169
174
|
|
170
175
|
/**
|
@@ -175,21 +180,20 @@ export class TextSelectionPlugin {
|
|
175
180
|
/** @type {JQuery<SVGElement>} */
|
176
181
|
const $svg = $container.find('svg.textSelectionSVG');
|
177
182
|
if (!$svg.length) return;
|
178
|
-
$svg.each((i, s) => this.defaultMode(s))
|
183
|
+
$svg.each((i, s) => this.defaultMode(s));
|
179
184
|
this.interceptCopy($container);
|
180
185
|
}
|
181
186
|
|
182
187
|
/**
|
183
|
-
* @param {
|
184
|
-
* @param {JQuery} $container
|
188
|
+
* @param {PageContainer} pageContainer
|
185
189
|
*/
|
186
|
-
async createTextLayer(
|
190
|
+
async createTextLayer(pageContainer) {
|
191
|
+
const pageIndex = pageContainer.page.index;
|
192
|
+
const $container = pageContainer.$container;
|
187
193
|
const $svgLayers = $container.find('.textSelectionSVG');
|
188
194
|
if ($svgLayers.length) return;
|
189
195
|
const XMLpage = await this.getPageText(pageIndex);
|
190
196
|
if (!XMLpage) return;
|
191
|
-
const XMLwidth = $(XMLpage).attr("width");
|
192
|
-
const XMLheight = $(XMLpage).attr("height");
|
193
197
|
|
194
198
|
const totalWords = $(XMLpage).find("WORD").length;
|
195
199
|
if (totalWords > this.maxWordRendered) {
|
@@ -197,19 +201,8 @@ export class TextSelectionPlugin {
|
|
197
201
|
return;
|
198
202
|
}
|
199
203
|
|
200
|
-
const svg =
|
201
|
-
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
202
|
-
svg.setAttribute("viewBox", `0 0 ${XMLwidth} ${XMLheight}`);
|
204
|
+
const svg = createSVGPageLayer(pageContainer.page, 'textSelectionSVG');
|
203
205
|
$container.append(svg);
|
204
|
-
svg.setAttribute('class', 'textSelectionSVG');
|
205
|
-
svg.setAttribute('preserveAspectRatio', 'none');
|
206
|
-
$(svg).css({
|
207
|
-
"width": "100%",
|
208
|
-
"position": "absolute",
|
209
|
-
"height": "100%",
|
210
|
-
"top": "0",
|
211
|
-
"left": "0",
|
212
|
-
});
|
213
206
|
|
214
207
|
$(XMLpage).find("PARAGRAPH").each((i, paragraph) => {
|
215
208
|
// Adding text element for each paragraph in the page
|
@@ -266,7 +259,7 @@ export class TextSelectionPlugin {
|
|
266
259
|
const paragWordHeight = wordHeightArr[Math.floor(wordHeightArr.length * 0.85)];
|
267
260
|
paragSvg.setAttribute("font-size", paragWordHeight.toString());
|
268
261
|
svg.appendChild(paragSvg);
|
269
|
-
})
|
262
|
+
});
|
270
263
|
this.stopPageFlip($container);
|
271
264
|
}
|
272
265
|
}
|
@@ -290,11 +283,9 @@ export class BookreaderWithTextSelection extends BookReader {
|
|
290
283
|
_createPageContainer(index) {
|
291
284
|
const pageContainer = super._createPageContainer(index);
|
292
285
|
// Disable if thumb mode; it's too janky
|
293
|
-
//
|
294
|
-
|
295
|
-
|
296
|
-
if (this.mode !== this.constModeThumb && (index >= 0 && index <= lastPageIndex)) {
|
297
|
-
this.textSelectionPlugin?.createTextLayer(index, pageContainer.$container);
|
286
|
+
// .page can be null for "pre-cover" region
|
287
|
+
if (this.mode !== this.constModeThumb && pageContainer.page) {
|
288
|
+
this.textSelectionPlugin?.createTextLayer(pageContainer);
|
298
289
|
}
|
299
290
|
return pageContainer;
|
300
291
|
}
|
@@ -56,7 +56,7 @@ if (!isMobile()) {
|
|
56
56
|
$(document.body).append(cboxOverlay).append(cbox);
|
57
57
|
}
|
58
58
|
});
|
59
|
-
}
|
59
|
+
};
|
60
60
|
})(BookReader.prototype.init);
|
61
61
|
|
62
62
|
/**
|
@@ -92,7 +92,7 @@ if (!isMobile()) {
|
|
92
92
|
$(document).off('keyup' + EVENT_NAMESPACE);
|
93
93
|
|
94
94
|
this.isFullscreenActive = false;
|
95
|
-
this.updateBrClasses()
|
95
|
+
this.updateBrClasses();
|
96
96
|
|
97
97
|
this.resize();
|
98
98
|
this.refs.$brContainer.animate({ opacity: 1 }, 400, 'linear');
|
@@ -233,8 +233,8 @@ export function bindFullscreenChangeListener(
|
|
233
233
|
'moz',
|
234
234
|
'ms'
|
235
235
|
];
|
236
|
-
const all_events =
|
237
|
-
$(document).
|
236
|
+
const all_events = (event + vendor_prefixes.join(event) + event).trim();
|
237
|
+
$(document).on(all_events, data, fullscreenchangeListener);
|
238
238
|
}
|
239
239
|
|
240
240
|
/**
|