@internetarchive/bookreader 5.0.0-5 → 5.0.0-50-a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. package/.eslintrc.js +17 -15
  2. package/.github/workflows/node.js.yml +77 -6
  3. package/.github/workflows/npm-publish.yml +6 -20
  4. package/.testcaferc.js +10 -0
  5. package/BookReader/BookReader.css +131 -339
  6. package/BookReader/BookReader.js +1 -1
  7. package/BookReader/BookReader.js.LICENSE.txt +24 -0
  8. package/BookReader/BookReader.js.map +1 -1
  9. package/BookReader/ia-bookreader-bundle.js +1493 -0
  10. package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +17 -0
  11. package/BookReader/ia-bookreader-bundle.js.map +1 -0
  12. package/BookReader/icons/close-circle-dark.svg +1 -0
  13. package/BookReader/icons/magnify-minus.svg +1 -1
  14. package/BookReader/icons/magnify-plus.svg +1 -1
  15. package/BookReader/icons/pause.svg +1 -1
  16. package/BookReader/icons/playback-speed.svg +1 -1
  17. package/BookReader/icons/read-aloud.svg +1 -1
  18. package/BookReader/icons/voice.svg +1 -0
  19. package/BookReader/images/BRicons.svg +2 -2
  20. package/BookReader/images/books_graphic.svg +1 -1
  21. package/BookReader/images/icon_book.svg +1 -1
  22. package/BookReader/images/icon_gear.svg +1 -1
  23. package/BookReader/images/icon_info.svg +1 -1
  24. package/BookReader/images/icon_playback-rate.svg +1 -1
  25. package/BookReader/images/icon_search_button.svg +1 -1
  26. package/BookReader/images/icon_share.svg +1 -1
  27. package/BookReader/images/icon_speaker.svg +1 -1
  28. package/BookReader/images/icon_speaker_open.svg +1 -1
  29. package/BookReader/images/marker_chap-off.svg +1 -1
  30. package/BookReader/images/marker_chap-on.svg +1 -1
  31. package/BookReader/images/marker_srch-on.svg +1 -1
  32. package/BookReader/jquery-3.js +2 -0
  33. package/BookReader/jquery-3.js.LICENSE.txt +24 -0
  34. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  35. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  36. package/BookReader/plugins/plugin.autoplay.js +1 -1
  37. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  38. package/BookReader/plugins/plugin.chapters.js +1 -1
  39. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  40. package/BookReader/plugins/plugin.iframe.js +1 -1
  41. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  42. package/BookReader/plugins/plugin.mobile_nav.js +1 -1
  43. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
  44. package/BookReader/plugins/plugin.resume.js +1 -1
  45. package/BookReader/plugins/plugin.resume.js.map +1 -1
  46. package/BookReader/plugins/plugin.search.js +1 -1
  47. package/BookReader/plugins/plugin.search.js.map +1 -1
  48. package/BookReader/plugins/plugin.text_selection.js +1 -1
  49. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  50. package/BookReader/plugins/plugin.tts.js +1 -1
  51. package/BookReader/plugins/plugin.tts.js.map +1 -1
  52. package/BookReader/plugins/plugin.url.js +1 -1
  53. package/BookReader/plugins/plugin.url.js.map +1 -1
  54. package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
  55. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  56. package/BookReader/webcomponents-bundle.js +3 -0
  57. package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
  58. package/BookReader/webcomponents-bundle.js.map +1 -0
  59. package/BookReaderDemo/BookReaderDemo.css +14 -1
  60. package/BookReaderDemo/IADemoBr.js +148 -0
  61. package/BookReaderDemo/demo-advanced.html +2 -2
  62. package/BookReaderDemo/demo-autoplay.html +2 -1
  63. package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
  64. package/BookReaderDemo/demo-fullscreen-mobile.html +2 -1
  65. package/BookReaderDemo/demo-fullscreen.html +2 -1
  66. package/BookReaderDemo/demo-iiif.html +2 -1
  67. package/BookReaderDemo/demo-internetarchive.html +84 -17
  68. package/BookReaderDemo/demo-multiple.html +2 -1
  69. package/BookReaderDemo/demo-preview-pages.html +2 -1
  70. package/BookReaderDemo/demo-simple.html +2 -1
  71. package/BookReaderDemo/demo-vendor-fullscreen.html +2 -1
  72. package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
  73. package/BookReaderDemo/immersion-1up.html +2 -1
  74. package/BookReaderDemo/immersion-mode.html +2 -1
  75. package/BookReaderDemo/toggle_controls.html +2 -1
  76. package/BookReaderDemo/view_mode.html +2 -1
  77. package/BookReaderDemo/viewmode-cycle.html +2 -3
  78. package/CHANGELOG.md +202 -0
  79. package/README.md +14 -1
  80. package/babel.config.js +18 -0
  81. package/codecov.yml +6 -0
  82. package/index.html +3 -0
  83. package/jsconfig.json +19 -0
  84. package/package.json +66 -56
  85. package/renovate.json +52 -0
  86. package/scripts/preversion.js +4 -1
  87. package/src/BookNavigator/assets/bookmark-colors.js +1 -1
  88. package/src/BookNavigator/assets/button-base.js +9 -2
  89. package/src/BookNavigator/assets/ia-logo.js +17 -0
  90. package/src/BookNavigator/assets/icon_checkmark.js +1 -1
  91. package/src/BookNavigator/assets/icon_close.js +1 -1
  92. package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
  93. package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
  94. package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
  95. package/src/BookNavigator/assets/icon_volumes.js +11 -0
  96. package/src/BookNavigator/book-navigator.js +583 -0
  97. package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
  98. package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
  99. package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
  100. package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
  101. package/src/BookNavigator/bookmarks/bookmarks-provider.js +21 -8
  102. package/src/BookNavigator/bookmarks/ia-bookmarks.js +102 -66
  103. package/src/BookNavigator/delete-modal-actions.js +1 -1
  104. package/src/BookNavigator/downloads/downloads-provider.js +36 -21
  105. package/src/BookNavigator/downloads/downloads.js +41 -25
  106. package/src/BookNavigator/search/a-search-result.js +18 -13
  107. package/src/BookNavigator/search/search-provider.js +80 -28
  108. package/src/BookNavigator/search/search-results.js +10 -18
  109. package/src/BookNavigator/sharing.js +27 -0
  110. package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
  111. package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
  112. package/src/BookNavigator/volumes/volumes-provider.js +114 -0
  113. package/src/BookNavigator/volumes/volumes.js +188 -0
  114. package/src/BookReader/BookModel.js +0 -29
  115. package/src/BookReader/DebugConsole.js +3 -3
  116. package/src/BookReader/DragScrollable.js +233 -0
  117. package/src/BookReader/Mode1Up.js +51 -351
  118. package/src/BookReader/Mode1UpLit.js +441 -0
  119. package/src/BookReader/Mode2Up.js +120 -105
  120. package/src/BookReader/ModeSmoothZoom.js +179 -0
  121. package/src/BookReader/ModeThumb.js +17 -11
  122. package/src/BookReader/Navbar/Navbar.js +10 -36
  123. package/src/BookReader/PageContainer.js +69 -6
  124. package/src/BookReader/ReduceSet.js +1 -1
  125. package/src/BookReader/Toolbar/Toolbar.js +10 -37
  126. package/src/BookReader/options.js +10 -0
  127. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  128. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  129. package/src/BookReader/utils.js +92 -13
  130. package/src/BookReader.js +431 -620
  131. package/src/assets/icons/close-circle-dark.svg +1 -0
  132. package/src/assets/icons/magnify-minus.svg +3 -7
  133. package/src/assets/icons/magnify-plus.svg +3 -7
  134. package/src/assets/icons/voice.svg +1 -0
  135. package/src/css/BookReader.scss +0 -12
  136. package/src/css/_BRComponent.scss +1 -1
  137. package/src/css/_BRmain.scss +19 -24
  138. package/src/css/_BRnav.scss +4 -26
  139. package/src/css/_BRpages.scss +35 -0
  140. package/src/css/_BRsearch.scss +25 -216
  141. package/src/css/_TextSelection.scss +14 -17
  142. package/src/css/_colorbox.scss +2 -2
  143. package/src/css/_controls.scss +17 -5
  144. package/src/css/_icons.scss +6 -0
  145. package/src/ia-bookreader/ia-bookreader.js +224 -0
  146. package/src/plugins/plugin.autoplay.js +4 -4
  147. package/src/plugins/plugin.chapters.js +28 -35
  148. package/src/plugins/plugin.mobile_nav.js +11 -10
  149. package/src/plugins/plugin.resume.js +3 -3
  150. package/src/plugins/plugin.text_selection.js +26 -39
  151. package/src/plugins/plugin.vendor-fullscreen.js +4 -4
  152. package/src/plugins/search/plugin.search.js +174 -116
  153. package/src/plugins/search/view.js +63 -179
  154. package/src/plugins/tts/AbstractTTSEngine.js +46 -37
  155. package/src/plugins/tts/FestivalTTSEngine.js +13 -14
  156. package/src/plugins/tts/PageChunk.js +15 -21
  157. package/src/plugins/tts/PageChunkIterator.js +8 -12
  158. package/src/plugins/tts/WebTTSEngine.js +66 -69
  159. package/src/plugins/tts/plugin.tts.js +92 -109
  160. package/src/plugins/tts/utils.js +0 -9
  161. package/src/plugins/url/UrlPlugin.js +184 -0
  162. package/src/plugins/{plugin.url.js → url/plugin.url.js} +28 -6
  163. package/src/util/manifestGenerator.js +0 -0
  164. package/tests/e2e/README.md +37 -0
  165. package/tests/e2e/autoplay.test.js +2 -2
  166. package/tests/e2e/base.test.js +7 -7
  167. package/tests/e2e/helpers/base.js +9 -3
  168. package/tests/e2e/helpers/debug.js +1 -1
  169. package/tests/e2e/helpers/desktopSearch.js +14 -13
  170. package/tests/e2e/helpers/mobileSearch.js +3 -3
  171. package/tests/e2e/helpers/params.js +17 -0
  172. package/tests/e2e/models/Navigation.js +13 -4
  173. package/tests/e2e/rightToLeft.test.js +4 -5
  174. package/tests/e2e/viewmode.test.js +38 -33
  175. package/tests/jest/BookNavigator/book-navigator.test.js +634 -0
  176. package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
  177. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
  178. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
  179. package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
  180. package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
  181. package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
  182. package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
  183. package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +102 -58
  184. package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
  185. package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
  186. package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +184 -0
  187. package/tests/jest/BookNavigator/volumes/volumes.test.js +97 -0
  188. package/tests/{BookReader → jest/BookReader}/BookModel.test.js +34 -14
  189. package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +176 -0
  190. package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
  191. package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
  192. package/tests/jest/BookReader/Mode1UpLit.test.js +92 -0
  193. package/tests/{BookReader → jest/BookReader}/Mode2Up.test.js +36 -15
  194. package/tests/jest/BookReader/ModeSmoothZoom.test.js +149 -0
  195. package/tests/jest/BookReader/ModeThumb.test.js +71 -0
  196. package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +7 -7
  197. package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
  198. package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
  199. package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
  200. package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
  201. package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
  202. package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
  203. package/tests/jest/BookReader/utils.test.js +186 -0
  204. package/tests/jest/BookReader.keyboard.test.js +190 -0
  205. package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
  206. package/tests/{BookReader.test.js → jest/BookReader.test.js} +18 -37
  207. package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
  208. package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
  209. package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +10 -11
  210. package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
  211. package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
  212. package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
  213. package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +39 -47
  214. package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
  215. package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +63 -47
  216. package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +35 -6
  217. package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +9 -9
  218. package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
  219. package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
  220. package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
  221. package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +1 -1
  222. package/tests/{plugins → jest/plugins}/tts/utils.test.js +3 -28
  223. package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
  224. package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +33 -14
  225. package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
  226. package/tests/{util → jest/util}/docCookies.test.js +1 -1
  227. package/tests/{util → jest/util}/strings.test.js +1 -1
  228. package/tests/{utils.js → jest/utils.js} +38 -0
  229. package/webpack.config.js +11 -5
  230. package/.babelrc +0 -12
  231. package/.dependabot/config.yml +0 -6
  232. package/.testcaferc.json +0 -5
  233. package/BookReader/bookreader-component-bundle.js +0 -1450
  234. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
  235. package/BookReader/bookreader-component-bundle.js.map +0 -1
  236. package/BookReader/jquery-1.10.1.js +0 -2
  237. package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
  238. package/BookReader/plugins/plugin.menu_toggle.js +0 -2
  239. package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
  240. package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
  241. package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
  242. package/karma.conf.js +0 -23
  243. package/src/BookNavigator/BookModel.js +0 -14
  244. package/src/BookNavigator/BookNavigator.js +0 -438
  245. package/src/BookNavigator/assets/book-loader.js +0 -27
  246. package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
  247. package/src/BookReaderComponent/BookReaderComponent.js +0 -112
  248. package/src/ItemNavigator/ItemNavigator.js +0 -372
  249. package/src/ItemNavigator/providers/sharing.js +0 -29
  250. package/src/Layers/sharing/sharing-provider.js +0 -22
  251. package/src/dragscrollable-br.js +0 -261
  252. package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
  253. package/src/plugins/plugin.bookmarks.js +0 -50
  254. package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
  255. package/tests/BookReader/Mode1Up.test.js +0 -164
  256. package/tests/BookReader/utils.test.js +0 -109
  257. package/tests/e2e/ia-production/ia-prod-base.js +0 -17
  258. package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
  259. package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
  260. package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
@@ -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);
@@ -81,7 +81,7 @@ BookReader.prototype.autoToggle = function(overrides) {
81
81
  }
82
82
 
83
83
  // Change to autofit if book is too large
84
- if (this.reduce < this.twoPageGetAutofitReduce()) {
84
+ if (this.reduce < this._modes.mode2Up.getAutofitReduce()) {
85
85
  this.zoom('auto');
86
86
  }
87
87
 
@@ -94,7 +94,7 @@ BookReader.prototype.autoToggle = function(overrides) {
94
94
  // don't flip immediately -- wait until timer fires
95
95
  } else {
96
96
  // flip immediately
97
- this.flipFwdToIndex();
97
+ this.next({ triggerStop: false });
98
98
  }
99
99
 
100
100
  this.$('.play').hide();
@@ -103,9 +103,9 @@ BookReader.prototype.autoToggle = function(overrides) {
103
103
  if (this.animating) return;
104
104
 
105
105
  if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.lastDisplayableIndex()) {
106
- this.flipBackToIndex(1); // $$$ really what we want?
106
+ this.prev({ triggerStop: false }); // $$$ really what we want?
107
107
  } else {
108
- this.flipFwdToIndex();
108
+ this.next({ triggerStop: false });
109
109
  }
110
110
  }, this.flipDelay);
111
111
  } 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
- .hover(event => {
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.hover(
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
- .then(data => {
198
- if (data && data.length > 0) {
199
- return data;
200
- } else {
201
- // try sourceid
202
- return $.ajax({ url: `${baseURL}&source_records=ia:${this.bookId}`, dataType: 'jsonp' });
203
- }
204
- })
205
- .then(data => {
206
- if (data && data.length > 0) {
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').click(() => applyFilters($drawerEl, this));
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').click(
93
- () => this.switchMode(this.constMode1up));
94
- $drawerEl.find('.DrawerLayoutButton.two_page_mode').click(
95
- () => this.switchMode(this.constMode2up));
96
- $drawerEl.find('.DrawerLayoutButton.thumbnail_mode').click(
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
 
@@ -46,7 +48,7 @@ export class TextSelectionPlugin {
46
48
  // Tspans are necessary on Chrome because they prevent newline character after every word when copying
47
49
  this.svgParagraphElement = "text";
48
50
  this.svgWordElement = "tspan";
49
- this.insertNewlines = avoidTspans
51
+ this.insertNewlines = avoidTspans;
50
52
  // Safari has a bug where `pointer-events` doesn't work on `<tspans>`. So
51
53
  // there we will set `pointer-events: all` on the paragraph element. We don't
52
54
  // do this everywhere, because it's a worse experience. Thanks Safari :/
@@ -94,21 +96,20 @@ export class TextSelectionPlugin {
94
96
  if (cachedEntry) {
95
97
  return cachedEntry.response;
96
98
  }
97
- return $.ajax({
99
+ const res = await $.ajax({
98
100
  type: "GET",
99
101
  url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }),
100
102
  dataType: "html",
101
103
  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
104
  });
105
+ try {
106
+ const xmlDoc = $.parseXML(res);
107
+ const result = xmlDoc && $(xmlDoc).find("OBJECT")[0];
108
+ this.pageTextCache.add({ index, response: result });
109
+ return result;
110
+ } catch (e) {
111
+ return undefined;
112
+ }
112
113
  } else {
113
114
  const XMLpagesArr = await this.djvuPagesPromise;
114
115
  if (XMLpagesArr) return XMLpagesArr[index];
@@ -144,8 +145,8 @@ export class TextSelectionPlugin {
144
145
  this.textSelectingMode(svg);
145
146
  }
146
147
  else svg.classList.remove("selectingSVG");
147
- })
148
- })
148
+ });
149
+ });
149
150
  }
150
151
 
151
152
  /**
@@ -158,13 +159,13 @@ export class TextSelectionPlugin {
158
159
  if (window.getSelection().toString() != "") window.getSelection().removeAllRanges();
159
160
  }
160
161
  event.stopPropagation();
161
- })
162
+ });
162
163
  $(svg).on('mouseup.textSelectPluginHandler', (event) => {
163
164
  event.stopPropagation();
164
165
  if (window.getSelection().toString() == "") {
165
166
  $(svg).off(".textSelectPluginHandler");
166
167
  this.defaultMode(svg); }
167
- })
168
+ });
168
169
  }
169
170
 
170
171
  /**
@@ -175,21 +176,20 @@ export class TextSelectionPlugin {
175
176
  /** @type {JQuery<SVGElement>} */
176
177
  const $svg = $container.find('svg.textSelectionSVG');
177
178
  if (!$svg.length) return;
178
- $svg.each((i, s) => this.defaultMode(s))
179
+ $svg.each((i, s) => this.defaultMode(s));
179
180
  this.interceptCopy($container);
180
181
  }
181
182
 
182
183
  /**
183
- * @param {number} pageIndex
184
- * @param {JQuery} $container
184
+ * @param {PageContainer} pageContainer
185
185
  */
186
- async createTextLayer(pageIndex, $container) {
186
+ async createTextLayer(pageContainer) {
187
+ const pageIndex = pageContainer.page.index;
188
+ const $container = pageContainer.$container;
187
189
  const $svgLayers = $container.find('.textSelectionSVG');
188
190
  if ($svgLayers.length) return;
189
191
  const XMLpage = await this.getPageText(pageIndex);
190
192
  if (!XMLpage) return;
191
- const XMLwidth = $(XMLpage).attr("width");
192
- const XMLheight = $(XMLpage).attr("height");
193
193
 
194
194
  const totalWords = $(XMLpage).find("WORD").length;
195
195
  if (totalWords > this.maxWordRendered) {
@@ -197,19 +197,8 @@ export class TextSelectionPlugin {
197
197
  return;
198
198
  }
199
199
 
200
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
201
- svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
202
- svg.setAttribute("viewBox", `0 0 ${XMLwidth} ${XMLheight}`);
200
+ const svg = createSVGPageLayer(pageContainer.page, 'textSelectionSVG');
203
201
  $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
202
 
214
203
  $(XMLpage).find("PARAGRAPH").each((i, paragraph) => {
215
204
  // Adding text element for each paragraph in the page
@@ -266,7 +255,7 @@ export class TextSelectionPlugin {
266
255
  const paragWordHeight = wordHeightArr[Math.floor(wordHeightArr.length * 0.85)];
267
256
  paragSvg.setAttribute("font-size", paragWordHeight.toString());
268
257
  svg.appendChild(paragSvg);
269
- })
258
+ });
270
259
  this.stopPageFlip($container);
271
260
  }
272
261
  }
@@ -290,11 +279,9 @@ export class BookreaderWithTextSelection extends BookReader {
290
279
  _createPageContainer(index) {
291
280
  const pageContainer = super._createPageContainer(index);
292
281
  // Disable if thumb mode; it's too janky
293
- // index can be -1 for "pre-cover" region
294
- // Added checking of lastPageIndex to avoid loop around index value
295
- const lastPageIndex = this.getNumLeafs() - 1;
296
- if (this.mode !== this.constModeThumb && (index >= 0 && index <= lastPageIndex)) {
297
- this.textSelectionPlugin?.createTextLayer(index, pageContainer.$container);
282
+ // .page can be null for "pre-cover" region
283
+ if (this.mode !== this.constModeThumb && pageContainer.page) {
284
+ this.textSelectionPlugin?.createTextLayer(pageContainer);
298
285
  }
299
286
  return pageContainer;
300
287
  }
@@ -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 = $.trim(event + vendor_prefixes.join(event) + event);
237
- $(document).bind(all_events, data, fullscreenchangeListener);
236
+ const all_events = (event + vendor_prefixes.join(event) + event).trim();
237
+ $(document).on(all_events, data, fullscreenchangeListener);
238
238
  }
239
239
 
240
240
  /**