@internetarchive/bookreader 5.0.0-6-multiple-files → 5.0.0-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) 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 +241 -377
  6. package/BookReader/BookReader.js +2 -21564
  7. package/BookReader/BookReader.js.LICENSE.txt +24 -20
  8. package/BookReader/BookReader.js.map +1 -1
  9. package/BookReader/ia-bookreader-bundle.js +1519 -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/1up.svg +1 -12
  13. package/BookReader/icons/2up.svg +1 -15
  14. package/BookReader/icons/advance.svg +3 -26
  15. package/BookReader/icons/chevron-right.svg +1 -1
  16. package/BookReader/icons/close-circle-dark.svg +1 -0
  17. package/BookReader/icons/close-circle.svg +1 -1
  18. package/BookReader/icons/fullscreen.svg +1 -17
  19. package/BookReader/icons/fullscreen_exit.svg +1 -17
  20. package/BookReader/icons/hamburger.svg +1 -15
  21. package/BookReader/icons/left-arrow.svg +1 -12
  22. package/BookReader/icons/magnify-minus.svg +1 -16
  23. package/BookReader/icons/magnify-plus.svg +1 -17
  24. package/BookReader/icons/magnify.svg +1 -15
  25. package/BookReader/icons/pause.svg +1 -23
  26. package/BookReader/icons/play.svg +1 -22
  27. package/BookReader/icons/playback-speed.svg +1 -34
  28. package/BookReader/icons/read-aloud.svg +1 -22
  29. package/BookReader/icons/review.svg +3 -22
  30. package/BookReader/icons/thumbnails.svg +1 -17
  31. package/BookReader/icons/voice.svg +1 -0
  32. package/BookReader/icons/volume-full.svg +1 -22
  33. package/BookReader/images/BRicons.svg +5 -94
  34. package/BookReader/images/books_graphic.svg +1 -177
  35. package/BookReader/images/icon_book.svg +1 -12
  36. package/BookReader/images/icon_bookmark.svg +1 -12
  37. package/BookReader/images/icon_gear.svg +1 -14
  38. package/BookReader/images/icon_hamburger.svg +1 -20
  39. package/BookReader/images/icon_home.svg +1 -21
  40. package/BookReader/images/icon_info.svg +1 -11
  41. package/BookReader/images/icon_one_page.svg +1 -8
  42. package/BookReader/images/icon_pause.svg +1 -1
  43. package/BookReader/images/icon_play.svg +1 -1
  44. package/BookReader/images/icon_playback-rate.svg +1 -15
  45. package/BookReader/images/icon_search_button.svg +1 -8
  46. package/BookReader/images/icon_share.svg +1 -9
  47. package/BookReader/images/icon_skip-ahead.svg +1 -6
  48. package/BookReader/images/icon_skip-back.svg +2 -13
  49. package/BookReader/images/icon_speaker.svg +1 -18
  50. package/BookReader/images/icon_speaker_open.svg +1 -10
  51. package/BookReader/images/icon_thumbnails.svg +1 -12
  52. package/BookReader/images/icon_toc.svg +1 -5
  53. package/BookReader/images/icon_two_pages.svg +1 -9
  54. package/BookReader/images/marker_chap-off.svg +1 -11
  55. package/BookReader/images/marker_chap-on.svg +1 -11
  56. package/BookReader/images/marker_srch-on.svg +1 -11
  57. package/BookReader/jquery-3.js +2 -0
  58. package/BookReader/jquery-3.js.LICENSE.txt +24 -0
  59. package/BookReader/plugins/plugin.archive_analytics.js +1 -172
  60. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  61. package/BookReader/plugins/plugin.autoplay.js +1 -165
  62. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  63. package/BookReader/plugins/plugin.chapters.js +1 -304
  64. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  65. package/BookReader/plugins/plugin.iframe.js +1 -74
  66. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  67. package/BookReader/plugins/plugin.mobile_nav.js +1 -334
  68. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
  69. package/BookReader/plugins/plugin.resume.js +1 -368
  70. package/BookReader/plugins/plugin.resume.js.map +1 -1
  71. package/BookReader/plugins/plugin.search.js +1 -1420
  72. package/BookReader/plugins/plugin.search.js.map +1 -1
  73. package/BookReader/plugins/plugin.text_selection.js +1 -1080
  74. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  75. package/BookReader/plugins/plugin.tts.js +2 -9193
  76. package/BookReader/plugins/plugin.tts.js.map +1 -1
  77. package/BookReader/plugins/plugin.url.js +1 -269
  78. package/BookReader/plugins/plugin.url.js.map +1 -1
  79. package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -379
  80. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  81. package/BookReader/webcomponents-bundle.js +3 -0
  82. package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
  83. package/BookReader/webcomponents-bundle.js.map +1 -0
  84. package/BookReaderDemo/BookReaderDemo.css +14 -1
  85. package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
  86. package/BookReaderDemo/BookReaderJSSimple.js +1 -0
  87. package/BookReaderDemo/IADemoBr.js +147 -0
  88. package/BookReaderDemo/demo-advanced.html +2 -2
  89. package/BookReaderDemo/demo-autoplay.html +2 -1
  90. package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
  91. package/BookReaderDemo/demo-fullscreen-mobile.html +2 -1
  92. package/BookReaderDemo/demo-fullscreen.html +2 -1
  93. package/BookReaderDemo/demo-iiif.html +2 -1
  94. package/BookReaderDemo/demo-internetarchive.html +84 -17
  95. package/BookReaderDemo/demo-multiple.html +2 -1
  96. package/BookReaderDemo/demo-preview-pages.html +2 -1
  97. package/BookReaderDemo/demo-simple.html +2 -1
  98. package/BookReaderDemo/demo-vendor-fullscreen.html +2 -1
  99. package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
  100. package/BookReaderDemo/immersion-1up.html +2 -1
  101. package/BookReaderDemo/immersion-mode.html +2 -1
  102. package/BookReaderDemo/toggle_controls.html +2 -1
  103. package/BookReaderDemo/view_mode.html +2 -1
  104. package/BookReaderDemo/viewmode-cycle.html +2 -3
  105. package/CHANGELOG.md +246 -0
  106. package/README.md +14 -1
  107. package/babel.config.js +19 -0
  108. package/codecov.yml +6 -0
  109. package/index.html +3 -0
  110. package/jsconfig.json +19 -0
  111. package/netlify.toml +5 -0
  112. package/package.json +70 -59
  113. package/renovate.json +52 -0
  114. package/scripts/preversion.js +4 -1
  115. package/src/BookNavigator/assets/bookmark-colors.js +1 -1
  116. package/src/BookNavigator/assets/button-base.js +9 -2
  117. package/src/BookNavigator/assets/ia-logo.js +17 -0
  118. package/src/BookNavigator/assets/icon_checkmark.js +1 -1
  119. package/src/BookNavigator/assets/icon_close.js +1 -1
  120. package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
  121. package/src/BookNavigator/assets/{icon_sort_ascending.js → icon_sort_desc.js} +2 -2
  122. package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
  123. package/src/BookNavigator/assets/icon_volumes.js +11 -0
  124. package/src/BookNavigator/book-navigator.js +585 -0
  125. package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
  126. package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
  127. package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
  128. package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
  129. package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
  130. package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
  131. package/src/BookNavigator/delete-modal-actions.js +1 -1
  132. package/src/BookNavigator/downloads/downloads-provider.js +36 -21
  133. package/src/BookNavigator/downloads/downloads.js +41 -25
  134. package/src/BookNavigator/search/search-provider.js +80 -28
  135. package/src/BookNavigator/search/search-results.js +34 -25
  136. package/src/BookNavigator/sharing.js +27 -0
  137. package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
  138. package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
  139. package/src/BookNavigator/volumes/volumes-provider.js +88 -53
  140. package/src/BookNavigator/volumes/volumes.js +41 -14
  141. package/src/BookReader/BookModel.js +59 -30
  142. package/src/BookReader/DebugConsole.js +3 -3
  143. package/src/BookReader/DragScrollable.js +233 -0
  144. package/src/BookReader/Mode1Up.js +56 -351
  145. package/src/BookReader/Mode1UpLit.js +391 -0
  146. package/src/BookReader/Mode2Up.js +73 -1318
  147. package/src/BookReader/Mode2UpLit.js +781 -0
  148. package/src/BookReader/ModeCoordinateSpace.js +29 -0
  149. package/src/BookReader/ModeSmoothZoom.js +211 -0
  150. package/src/BookReader/ModeThumb.js +17 -11
  151. package/src/BookReader/Navbar/Navbar.js +10 -36
  152. package/src/BookReader/PageContainer.js +69 -6
  153. package/src/BookReader/ReduceSet.js +1 -1
  154. package/src/BookReader/Toolbar/Toolbar.js +10 -37
  155. package/src/BookReader/events.js +2 -0
  156. package/src/BookReader/options.js +24 -2
  157. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  158. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  159. package/src/BookReader/utils.js +108 -13
  160. package/src/BookReader.js +480 -825
  161. package/src/assets/icons/close-circle-dark.svg +1 -0
  162. package/src/assets/icons/magnify-minus.svg +3 -7
  163. package/src/assets/icons/magnify-plus.svg +3 -7
  164. package/src/assets/icons/voice.svg +1 -0
  165. package/src/css/BookReader.scss +0 -12
  166. package/src/css/_BRBookmarks.scss +1 -1
  167. package/src/css/_BRComponent.scss +1 -1
  168. package/src/css/_BRmain.scss +33 -24
  169. package/src/css/_BRnav.scss +4 -26
  170. package/src/css/_BRpages.scss +147 -40
  171. package/src/css/_BRsearch.scss +25 -216
  172. package/src/css/_TextSelection.scss +16 -17
  173. package/src/css/_colorbox.scss +2 -2
  174. package/src/css/_controls.scss +17 -5
  175. package/src/css/_icons.scss +7 -1
  176. package/src/ia-bookreader/ia-bookreader.js +224 -0
  177. package/src/plugins/plugin.archive_analytics.js +3 -3
  178. package/src/plugins/plugin.autoplay.js +4 -9
  179. package/src/plugins/plugin.chapters.js +28 -35
  180. package/src/plugins/plugin.mobile_nav.js +11 -10
  181. package/src/plugins/plugin.resume.js +3 -3
  182. package/src/plugins/plugin.text_selection.js +32 -41
  183. package/src/plugins/plugin.vendor-fullscreen.js +4 -4
  184. package/src/plugins/search/plugin.search.js +179 -116
  185. package/src/plugins/search/view.js +63 -179
  186. package/src/plugins/tts/AbstractTTSEngine.js +46 -37
  187. package/src/plugins/tts/FestivalTTSEngine.js +13 -14
  188. package/src/plugins/tts/PageChunk.js +15 -21
  189. package/src/plugins/tts/PageChunkIterator.js +8 -12
  190. package/src/plugins/tts/WebTTSEngine.js +87 -71
  191. package/src/plugins/tts/plugin.tts.js +94 -125
  192. package/src/plugins/tts/utils.js +0 -25
  193. package/src/plugins/url/UrlPlugin.js +193 -0
  194. package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
  195. package/src/util/docCookies.js +21 -2
  196. package/tests/e2e/README.md +37 -0
  197. package/tests/e2e/autoplay.test.js +2 -2
  198. package/tests/e2e/base.test.js +7 -7
  199. package/tests/e2e/helpers/base.js +28 -23
  200. package/tests/e2e/helpers/debug.js +1 -1
  201. package/tests/e2e/helpers/desktopSearch.js +14 -13
  202. package/tests/e2e/helpers/mobileSearch.js +3 -3
  203. package/tests/e2e/helpers/params.js +17 -0
  204. package/tests/e2e/helpers/rightToLeft.js +4 -10
  205. package/tests/e2e/models/Navigation.js +13 -4
  206. package/tests/e2e/rightToLeft.test.js +4 -5
  207. package/tests/e2e/viewmode.test.js +40 -33
  208. package/tests/jest/BookNavigator/book-navigator.test.js +658 -0
  209. package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
  210. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
  211. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
  212. package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
  213. package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
  214. package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
  215. package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
  216. package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +104 -60
  217. package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
  218. package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
  219. package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +184 -0
  220. package/tests/jest/BookNavigator/volumes/volumes.test.js +97 -0
  221. package/tests/{BookReader → jest/BookReader}/BookModel.test.js +59 -14
  222. package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
  223. package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
  224. package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
  225. package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
  226. package/tests/jest/BookReader/Mode2Up.test.js +98 -0
  227. package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
  228. package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
  229. package/tests/jest/BookReader/ModeSmoothZoom.test.js +175 -0
  230. package/tests/jest/BookReader/ModeThumb.test.js +71 -0
  231. package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
  232. package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
  233. package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
  234. package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
  235. package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
  236. package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
  237. package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
  238. package/tests/jest/BookReader/utils.test.js +217 -0
  239. package/tests/jest/BookReader.keyboard.test.js +190 -0
  240. package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
  241. package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
  242. package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
  243. package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
  244. package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +10 -11
  245. package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
  246. package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
  247. package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
  248. package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +39 -47
  249. package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
  250. package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +63 -47
  251. package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +35 -6
  252. package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +9 -9
  253. package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
  254. package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
  255. package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
  256. package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
  257. package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
  258. package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
  259. package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
  260. package/tests/jest/setup.js +3 -0
  261. package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
  262. package/tests/jest/util/docCookies.test.js +24 -0
  263. package/tests/{util → jest/util}/strings.test.js +1 -1
  264. package/tests/{utils.js → jest/utils.js} +38 -0
  265. package/webpack.config.js +11 -5
  266. package/.babelrc +0 -12
  267. package/.dependabot/config.yml +0 -6
  268. package/.testcaferc.json +0 -5
  269. package/BookReader/bookreader-component-bundle.js +0 -14312
  270. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
  271. package/BookReader/bookreader-component-bundle.js.map +0 -1
  272. package/BookReader/icons/sort-ascending.svg +0 -1
  273. package/BookReader/icons/sort-descending.svg +0 -1
  274. package/BookReader/jquery-1.10.1.js +0 -108
  275. package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
  276. package/BookReader/plugins/plugin.menu_toggle.js +0 -369
  277. package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
  278. package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
  279. package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
  280. package/karma.conf.js +0 -23
  281. package/src/BookNavigator/BookModel.js +0 -14
  282. package/src/BookNavigator/BookNavigator.js +0 -452
  283. package/src/BookNavigator/assets/book-loader.js +0 -27
  284. package/src/BookNavigator/assets/icon_sort_descending.js +0 -5
  285. package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
  286. package/src/BookNavigator/search/a-search-result.js +0 -55
  287. package/src/BookReaderComponent/BookReaderComponent.js +0 -112
  288. package/src/ItemNavigator/ItemNavigator.js +0 -372
  289. package/src/ItemNavigator/providers/sharing.js +0 -29
  290. package/src/assets/icons/sort-ascending.svg +0 -1
  291. package/src/assets/icons/sort-descending.svg +0 -1
  292. package/src/dragscrollable-br.js +0 -261
  293. package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
  294. package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
  295. package/tests/BookReader/Mode1Up.test.js +0 -164
  296. package/tests/BookReader/Mode2Up.test.js +0 -247
  297. package/tests/BookReader/utils.test.js +0 -109
  298. package/tests/e2e/ia-production/ia-prod-base.js +0 -17
  299. package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
  300. package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
  301. package/tests/karma/BookNavigator/volumes.test.js +0 -101
  302. package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
  303. package/tests/util/docCookies.test.js +0 -15
@@ -0,0 +1,17 @@
1
+ import { svg } from 'lit';
2
+
3
+ export default svg`
4
+ <svg class="ia-logo" width="27" height="30" viewBox="0 0 27 30" xmlns="http://www.w3.org/2000/svg" aria-labelledby="logoTitleID logoDescID">
5
+ <title id="logoTitleID">Internet Archive logo</title>
6
+ <desc id="logoDescID">A line drawing of the Internet Archive headquarters building façade.</desc>
7
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <mask id="mask-2" fill="white">
9
+ <path d="M26.6666667,28.6046512 L26.6666667,30 L0,30 L0.000283687943,28.6046512 L26.6666667,28.6046512 Z M25.6140351,26.5116279 L25.6140351,28.255814 L1.05263158,28.255814 L1.05263158,26.5116279 L25.6140351,26.5116279 Z M3.62469203,7.6744186 L3.91746909,7.82153285 L4.0639977,10.1739544 L4.21052632,13.9963932 L4.21052632,17.6725617 L4.0639977,22.255044 L4.03962296,25.3421929 L3.62469203,25.4651163 L2.16024641,25.4651163 L1.72094074,25.3421929 L1.55031755,22.255044 L1.40350877,17.6970339 L1.40350877,14.0211467 L1.55031755,10.1739544 L1.68423854,7.80887484 L1.98962322,7.6744186 L3.62469203,7.6744186 Z M24.6774869,7.6744186 L24.9706026,7.82153285 L25.1168803,10.1739544 L25.2631579,13.9963932 L25.2631579,17.6725617 L25.1168803,22.255044 L25.0927809,25.3421929 L24.6774869,25.4651163 L23.2130291,25.4651163 L22.7736357,25.3421929 L22.602418,22.255044 L22.4561404,17.6970339 L22.4561404,14.0211467 L22.602418,10.1739544 L22.7369262,7.80887484 L23.0420916,7.6744186 L24.6774869,7.6744186 Z M9.94042303,7.6744186 L10.2332293,7.82153285 L10.3797725,10.1739544 L10.5263158,13.9963932 L10.5263158,17.6725617 L10.3797725,22.255044 L10.3556756,25.3421929 L9.94042303,25.4651163 L8.47583122,25.4651163 L8.0362015,25.3421929 L7.86556129,22.255044 L7.71929825,17.6970339 L7.71929825,14.0211467 L7.86556129,10.1739544 L8.00005604,7.80887484 L8.30491081,7.6744186 L9.94042303,7.6744186 Z M18.0105985,7.6744186 L18.3034047,7.82153285 L18.449948,10.1739544 L18.5964912,13.9963932 L18.5964912,17.6725617 L18.449948,22.255044 L18.425851,25.3421929 L18.0105985,25.4651163 L16.5460067,25.4651163 L16.1066571,25.3421929 L15.9357367,22.255044 L15.7894737,17.6970339 L15.7894737,14.0211467 L15.9357367,10.1739544 L16.0702315,7.80887484 L16.3753664,7.6744186 L18.0105985,7.6744186 Z M25.6140351,4.53488372 L25.6140351,6.97674419 L1.05263158,6.97674419 L1.05263158,4.53488372 L25.6140351,4.53488372 Z M13.0806755,0 L25.9649123,2.93331338 L25.4484139,3.8372093 L0.771925248,3.8372093 L0,3.1041615 L13.0806755,0 Z" id="path-1"></path>
10
+ </mask>
11
+ <use fill="#FFFFFF" xlink:href="#path-1"></use>
12
+ <g mask="url(#mask-2)" fill="#FFFFFF">
13
+ <path d="M0,0 L26.6666667,0 L26.6666667,30 L0,30 L0,0 Z" id="swatch"></path>
14
+ </g>
15
+ </g>
16
+ </svg>
17
+ `;
@@ -1,4 +1,4 @@
1
- import { css } from 'lit-element';
1
+ import { css } from 'lit';
2
2
 
3
3
  // Original SVG object for reference
4
4
  // <svg height="10" viewBox="0 0 13 10" width="13" xmlns="http://www.w3.org/2000/svg"><path d="m4.33333333 10-4.33333333-4.16666667 1.73333333-1.66666666 2.6 2.5 6.93333337-6.66666667 1.7333333 1.66666667z" fill="#fff" fill-rule="evenodd"/></svg>
@@ -1,3 +1,3 @@
1
- import { css } from 'lit-element';
1
+ import { css } from 'lit';
2
2
 
3
3
  export default css`data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNDAgNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgYXJpYS1sYWJlbGxlZGJ5PSJjbG9zZVRpdGxlSUQgY2xvc2VEZXNjSUQiPjxwYXRoIGQ9Ik0yOS4xOTIgMTAuODA4YTEuNSAxLjUgMCAwMTAgMi4xMkwyMi4xMjIgMjBsNy4wNyA3LjA3MmExLjUgMS41IDAgMDEtMi4xMiAyLjEyMWwtNy4wNzMtNy4wNy03LjA3IDcuMDdhMS41IDEuNSAwIDAxLTIuMTIxLTIuMTJsNy4wNy03LjA3My03LjA3LTcuMDdhMS41IDEuNSAwIDAxMi4xMi0yLjEyMUwyMCAxNy44NzhsNy4wNzItNy4wN2ExLjUgMS41IDAgMDEyLjEyMSAweiIgY2xhc3M9ImZpbGwtY29sb3IiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==`;
@@ -0,0 +1,5 @@
1
+ import { html } from 'lit';
2
+
3
+ export default html`
4
+ <svg name="sort-asc" height="18" viewBox="0 0 18 18" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="m2.32514544 8.30769231.7756949-2.08468003h2.92824822l.75630252 2.08468003h1.01809955l-2.70523594-6.92307693h-1.01809955l-2.69553976 6.92307693zm3.41305753-2.86037492h-2.34647705l1.17323853-3.22883h.01939237z" fill="#fff" fill-rule="nonzero"/><path d="m7.1689722 16.6153846v-.7756949h-4.4117647l4.29541047-5.3716871v-.77569491h-5.06140918v.77569491h3.97543633l-4.30510666 5.3716871v.7756949z" fill="#fff" fill-rule="nonzero"/><path d="m10.3846154 11.0769231 2.7692308 5.5384615 2.7692307-5.5384615m-2.7692307 4.1538461v-13.15384612" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.661538" transform="matrix(1 0 0 -1 0 18.692308)"/></g></svg>
5
+ `;
@@ -1,5 +1,5 @@
1
- import { html } from 'lit-html';
1
+ import { html } from 'lit';
2
2
 
3
3
  export default html`
4
- <svg name="ascending" height="18" viewBox="0 0 18 18" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="m2.32514544 8.30769231.7756949-2.08468003h2.92824822l.75630252 2.08468003h1.01809955l-2.70523594-6.92307693h-1.01809955l-2.69553976 6.92307693zm3.41305753-2.86037492h-2.34647705l1.17323853-3.22883h.01939237z" fill="#fff" fill-rule="nonzero"/><path d="m7.1689722 16.6153846v-.7756949h-4.4117647l4.29541047-5.3716871v-.77569491h-5.06140918v.77569491h3.97543633l-4.30510666 5.3716871v.7756949z" fill="#fff" fill-rule="nonzero"/><path d="m10.3846154 11.0769231 2.7692308 5.5384615 2.7692307-5.5384615m-2.7692307 4.1538461v-13.15384612" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.661538"/></g></svg>
4
+ <svg name="sort-desc" height="18" viewBox="0 0 18 18" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="m2.32514544 8.30769231.7756949-2.08468003h2.92824822l.75630252 2.08468003h1.01809955l-2.70523594-6.92307693h-1.01809955l-2.69553976 6.92307693zm3.41305753-2.86037492h-2.34647705l1.17323853-3.22883h.01939237z" fill="#fff" fill-rule="nonzero"/><path d="m7.1689722 16.6153846v-.7756949h-4.4117647l4.29541047-5.3716871v-.77569491h-5.06140918v.77569491h3.97543633l-4.30510666 5.3716871v.7756949z" fill="#fff" fill-rule="nonzero"/><path d="m10.3846154 11.0769231 2.7692308 5.5384615 2.7692307-5.5384615m-2.7692307 4.1538461v-13.15384612" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.661538"/></g></svg>
5
5
  `;
@@ -0,0 +1,5 @@
1
+ import { html } from 'lit';
2
+
3
+ export default html`
4
+ <svg name="sort-neutral" height="18" viewBox="0 0 18 18" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="#fff" fill-rule="evenodd"><path d="m2.32514544 8.30769231.7756949-2.08468003h2.92824822l.75630252 2.08468003h1.01809955l-2.70523594-6.92307693h-1.01809955l-2.69553976 6.92307693zm3.41305753-2.86037492h-2.34647705l1.17323853-3.22883h.01939237z" fill-rule="nonzero"/><path d="m7.1689722 16.6153846v-.7756949h-4.4117647l4.29541047-5.3716871v-.77569491h-5.06140918v.77569491h3.97543633l-4.30510666 5.3716871v.7756949z" fill-rule="nonzero"/><circle cx="13" cy="9" r="2"/></g></svg>
5
+ `;
@@ -0,0 +1,11 @@
1
+ import { html } from 'lit';
2
+
3
+ export default html`
4
+ <svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" aria-labelledby="volumesTitleID volumesDescID">
5
+ <title id="volumesTitleID">Volumes icon</title>
6
+ <desc id="volumesDescID">Three books stacked on each other</desc>
7
+ <g fill="#ffffff">
8
+ <path fill="#ffffff" d="m9.83536396 0h10.07241114c.1725502.47117517.3378411.76385809.4958725.87804878.1295523.11419069.3199719.1998337.5712586.25692905.2512868.05709534.4704647.08564301.6575337.08564301h.2806036v15.24362526h-4.3355343v3.8106985h-4.44275v3.7250554h-12.01318261c-.27306495 0-.50313194-.085643-.69020098-.256929-.18706903-.1712861-.30936193-.3425721-.36687867-.5138581l-.06449694-.2785477v-14.2159091c0-.32815965.08627512-.5922949.25882537-.79240577.17255024-.20011086.34510049-.32150776.51765073-.36419068l.25882537-.0640244h3.36472977v-2.54767184c0-.31374722.08627513-.57067627.25882537-.77078714.17255025-.20011086.34510049-.32150776.51765074-.36419068l.25882536-.06402439h3.36472978v-2.56929047c0-.32815964.08627512-.5922949.25882537-.79240576.17255024-.20011087.34510049-.31430156.51765073-.34257207zm10.78355264 15.6294346v-13.53076498c-.2730649-.08536585-.4456152-.16380266-.5176507-.23531042-.1725502-.1424612-.2730649-.27078714-.3015441-.38497783v13.36031043h-9.87808272c0 .0144124-.02149898.0144124-.06449694 0-.04299795-.0144124-.08962561.006929-.13988296.0640244-.05025735.0570953-.07538603.1427383-.07538603.256929s.02149898.210643.06449694.289357c.04299795.078714.08599591.1322062.12899387.1604767l.06449693.0216187h10.71905571zm-10.2449613-2.4412417h7.98003v-11.60421286h-7.98003zm1.6827837-9.41990022h4.6153002c.1725502 0 .3199718.05349224.4422647.16047672s.1834393.23891353.1834393.39578714c0 .15687362-.0611464.28519956-.1834393.38497783s-.2697145.1496674-.4422647.1496674h-4.6153002c-.1725503 0-.3199719-.04988913-.4422647-.1496674-.1222929-.09977827-.1834394-.22810421-.1834394-.38497783 0-.15687361.0611465-.28880266.1834394-.39578714.1222928-.10698448.2697144-.16047672.4422647-.16047672zm-6.08197737 13.50997782h7.72120467v-.8131929h-3.79610541c-.27306495 0-.49950224-.085643-.67931188-.256929-.17980964-.1712861-.29847284-.3425721-.35598958-.5138581l-.06449694-.2785477v-10.02023282h-2.82530086zm6.77217827-11.36890243h3.2139578c.1295522 0 .240956.05709534.3342113.17128603.0932554.11419069.139883.24972284.139883.40659645 0 .15687362-.0466276.28880267-.139883.39578714-.0932553.10698448-.2046591.16047672-.3342113.16047672h-3.2139578c-.1295523 0-.2373264-.05349224-.3233223-.16047672-.0859959-.10698447-.1289938-.23891352-.1289938-.39578714 0-.15687361.0429979-.29240576.1289938-.40659645s.19377-.17128603.3233223-.17128603zm-11.15043132 15.11557653h7.69942646v-.7491685h-3.79610539c-.25854616 0-.48135376-.0892462-.66842279-.2677384-.18706904-.1784922-.30936193-.3605876-.36687868-.546286l-.06449694-.2569291v-10.04101994h-2.80352266zm14.62237682-4.5606985h-.8191949v2.1410754h-9.89986085s-.04299796.0285477-.12899387.085643c-.08599592.0570954-.12201369.1427384-.10805331.2569291 0 .1141907.01786928.210643.05360784.289357.03573856.0787139.07538603.125.1189424.138858l.06449694.0432373h10.71905575v-2.9542683zm-4.3991936 3.8106985h-.8191949v2.077051h-9.8563045c0 .0144124-.02149898.0144124-.06449694 0-.04299795-.0144125-.08962561.0105321-.13988296.0748337-.05025735.0643015-.07538603.1607538-.07538603.289357 0 .1141906.02149898.2070399.06449694.2785476.04299795.0715078.08599591.1141907.12899387.1280488l.06449693.0216186h10.69811519v-2.8686252z" />
9
+ </g>
10
+ </svg>
11
+ `;
@@ -0,0 +1,585 @@
1
+ // eslint-disable-next-line no-unused-vars
2
+ import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
3
+ // eslint-disable-next-line no-unused-vars
4
+ import { ModalManager } from '@internetarchive/modal-manager';
5
+ import { css, html, LitElement, nothing } from 'lit';
6
+ import SearchProvider from './search/search-provider.js';
7
+ import DownloadProvider from './downloads/downloads-provider.js';
8
+ import VisualAdjustmentProvider from './visual-adjustments/visual-adjustments-provider.js';
9
+ import BookmarksProvider from './bookmarks/bookmarks-provider.js';
10
+ import SharingProvider from './sharing.js';
11
+ import VolumesProvider from './volumes/volumes-provider.js';
12
+ import iaLogo from './assets/ia-logo.js';
13
+
14
+ const events = {
15
+ menuUpdated: 'menuUpdated',
16
+ updateSideMenu: 'updateSideMenu',
17
+ PostInit: 'PostInit',
18
+ ViewportInFullScreen: 'ViewportInFullScreen',
19
+ };
20
+ export class BookNavigator extends LitElement {
21
+ static get properties() {
22
+ return {
23
+ itemMD: { type: Object },
24
+ bookReaderLoaded: { type: Boolean },
25
+ bookreader: { type: Object },
26
+ bookIsRestricted: { type: Boolean },
27
+ downloadableTypes: { type: Array },
28
+ isAdmin: { type: Boolean },
29
+ lendingInitialized: { type: Boolean },
30
+ lendingStatus: { type: Object },
31
+ menuProviders: { type: Object },
32
+ menuShortcuts: { type: Array },
33
+ signedIn: { type: Boolean },
34
+ loaded: { type: Boolean },
35
+ sharedObserver: { type: Object, attribute: false },
36
+ modal: { type: Object, attribute: false },
37
+ fullscreenBranding: { type: Object },
38
+ };
39
+ }
40
+
41
+ constructor() {
42
+ super();
43
+ this.itemMD = undefined;
44
+ this.loaded = false;
45
+ this.bookReaderCannotLoad = false;
46
+ this.bookReaderLoaded = false;
47
+ this.bookreader = null;
48
+ this.bookIsRestricted = false;
49
+ this.downloadableTypes = [];
50
+ this.isAdmin = false;
51
+ this.lendingInitialized = false;
52
+ this.lendingStatus = {};
53
+ this.menuProviders = {};
54
+ this.menuShortcuts = [];
55
+ this.signedIn = false;
56
+ /** @type {ModalManager} */
57
+ this.modal = undefined;
58
+ /** @type {SharedResizeObserver} */
59
+ this.sharedObserver = undefined;
60
+ this.fullscreenBranding = iaLogo;
61
+ // Untracked properties
62
+ this.sharedObserverHandler = undefined;
63
+ this.brWidth = 0;
64
+ this.brHeight = 0;
65
+ this.shortcutOrder = [
66
+ /**
67
+ * sets exit FS button (`this.fullscreenBranding1)
68
+ * when `br.options.enableFSLogoShortcut`
69
+ */
70
+ 'fullscreen',
71
+ 'volumes',
72
+ 'search',
73
+ 'bookmarks'
74
+ ];
75
+ }
76
+
77
+ disconnectedCallback() {
78
+ this.sharedObserver.removeObserver({
79
+ target: this.mainBRContainer,
80
+ handler: this.sharedObserverHandler
81
+ });
82
+ }
83
+
84
+ firstUpdated() {
85
+ this.bindEventListeners();
86
+ this.emitPostInit();
87
+ this.loaded = true;
88
+ }
89
+
90
+ updated(changed) {
91
+ if (!this.bookreader || !this.itemMD || !this.bookReaderLoaded) {
92
+ return;
93
+ }
94
+
95
+ const reload = changed.has('loaded') && this.loaded;
96
+ if (reload
97
+ || changed.has('itemMD')
98
+ || changed.has('bookreader')
99
+ || changed.has('signedIn')
100
+ || changed.has('isAdmin')
101
+ || changed.has('modal')) {
102
+ this.initializeBookSubmenus();
103
+ }
104
+
105
+ if (changed.has('sharedObserver') && this.bookreader) {
106
+ this.loadSharedObserver();
107
+ this.initializeBookSubmenus();
108
+ }
109
+
110
+ if (changed.has('downloadableTypes')) {
111
+ this.initializeBookSubmenus();
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Global event emitter for when Book Navigator loads
117
+ */
118
+ emitPostInit() {
119
+ // emit global event when book nav has loaded with current bookreader selector
120
+ this.dispatchEvent(new CustomEvent(`BrBookNav:${events.PostInit}`, {
121
+ detail: { brSelector: this.bookreader?.el },
122
+ bubbles: true,
123
+ composed: true,
124
+ }));
125
+ }
126
+
127
+ /**
128
+ * @typedef {{
129
+ * baseHost: string,
130
+ * modal: ModalManager,
131
+ * sharedObserver: SharedResizeObserver,
132
+ * bookreader: BookReader,
133
+ * item: Item,
134
+ * signedIn: boolean,
135
+ * isAdmin: boolean,
136
+ * onProviderChange: (BookReader, object) => void,
137
+ * }} baseProviderConfig
138
+ *
139
+ * @return {baseProviderConfig}
140
+ */
141
+ get baseProviderConfig() {
142
+ return {
143
+ baseHost: this.baseHost,
144
+ modal: this.modal,
145
+ sharedObserver: this.sharedObserver,
146
+ bookreader: this.bookreader,
147
+ item: this.itemMD,
148
+ signedIn: this.signedIn,
149
+ isAdmin: this.isAdmin,
150
+ onProviderChange: () => {}
151
+ };
152
+ }
153
+
154
+ get isWideEnoughToOpenMenu() {
155
+ return this.brWidth >= 640;
156
+ }
157
+ /**
158
+ * Instantiates books submenus & their update callbacks
159
+ *
160
+ * NOTE: we are doing our best to scope bookreader's instance.
161
+ * If your submenu provider uses a bookreader instance to read, manually
162
+ * manipulate BookReader, please update the navigator's instance of it
163
+ * to keep it in sync.
164
+ */
165
+ initializeBookSubmenus() {
166
+ const providers = {
167
+ share: new SharingProvider(this.baseProviderConfig),
168
+ visualAdjustments: new VisualAdjustmentProvider({
169
+ ...this.baseProviderConfig,
170
+ /** Update menu contents */
171
+ onProviderChange: () => {
172
+ this.updateMenuContents();
173
+ },
174
+ }),
175
+ };
176
+
177
+ if (this.shouldShowDownloadsMenu()) {
178
+ providers.downloads = new DownloadProvider(this.baseProviderConfig);
179
+ }
180
+
181
+ if (this.bookreader.options.enableSearch) {
182
+ providers.search = new SearchProvider({
183
+ ...this.baseProviderConfig,
184
+ /**
185
+ * Search specific menu updates
186
+ * @param {BookReader} brInstance
187
+ * @param {{ searchCanceled: boolean }} searchUpdates
188
+ */
189
+ onProviderChange: (brInstance = null, searchUpdates = {}) => {
190
+ if (brInstance) {
191
+ /* refresh br instance reference */
192
+ this.bookreader = brInstance;
193
+ }
194
+
195
+ this.updateMenuContents();
196
+
197
+ if (searchUpdates.openMenu === false) {
198
+ return;
199
+ }
200
+
201
+ if (this.isWideEnoughToOpenMenu && !searchUpdates?.searchCanceled) {
202
+ /* open side search menu */
203
+ setTimeout(() => {
204
+ this.updateSideMenu('search', 'open');
205
+ }, 0);
206
+ }
207
+ },
208
+ });
209
+ }
210
+
211
+ if (this.bookreader.options.enableBookmarks) {
212
+ providers.bookmarks = new BookmarksProvider({
213
+ ...this.baseProviderConfig,
214
+ onProviderChange: (bookmarks) => {
215
+ const method = Object.keys(bookmarks).length ? 'add' : 'remove';
216
+ this[`${method}MenuShortcut`]('bookmarks');
217
+ this.updateMenuContents();
218
+ }
219
+ });
220
+ }
221
+
222
+ // add shortcut for volumes if multipleBooksList exists
223
+ if (this.bookreader.options.enableMultipleBooks) {
224
+ providers.volumes = new VolumesProvider({
225
+ ...this.baseProviderConfig,
226
+ onProviderChange: (brInstance = null, volumesUpdates = {}) => {
227
+ if (brInstance) {
228
+ /* refresh br instance reference */
229
+ this.bookreader = brInstance;
230
+ }
231
+ this.updateMenuContents();
232
+ if (this.isWideEnoughToOpenMenu) {
233
+ /* open side search menu */
234
+ setTimeout(() => {
235
+ this.updateSideMenu('volumes', 'open');
236
+ });
237
+ }
238
+ }
239
+ });
240
+ }
241
+
242
+ this.menuProviders = providers;
243
+ this.addMenuShortcut('search');
244
+ this.addMenuShortcut('volumes');
245
+ this.updateMenuContents();
246
+ }
247
+
248
+ /** gets element that houses the bookreader in light dom */
249
+ get mainBRContainer() {
250
+ return document.querySelector(this.bookreader?.el);
251
+ }
252
+
253
+ /** Fullscreen Shortcut */
254
+ addFullscreenShortcut() {
255
+ const closeFS = {
256
+ icon: this.fullscreenShortcut,
257
+ id: 'fullscreen',
258
+ };
259
+ this.menuShortcuts.push(closeFS);
260
+ this.sortMenuShortcuts();
261
+ this.emitMenuShortcutsUpdated();
262
+ }
263
+
264
+ deleteFullscreenShortcut() {
265
+ const updatedShortcuts = this.menuShortcuts.filter(({ id }) => {
266
+ return id !== 'fullscreen';
267
+ });
268
+ this.menuShortcuts = updatedShortcuts;
269
+ this.sortMenuShortcuts();
270
+ this.emitMenuShortcutsUpdated();
271
+ }
272
+
273
+ closeFullscreen() {
274
+ this.bookreader.exitFullScreen();
275
+ }
276
+
277
+ get fullscreenShortcut() {
278
+ return html`
279
+ <button
280
+ @click=${() => this.closeFullscreen()}
281
+ title="Exit fullscreen view"
282
+ >${this.fullscreenBranding}</button>
283
+ `;
284
+ }
285
+ /** End Fullscreen Shortcut */
286
+
287
+ /**
288
+ * Open side menu
289
+ * @param {string} menuId
290
+ * @param {('open'|'close'|'toggle')} action
291
+ */
292
+ updateSideMenu(menuId = '', action = 'open') {
293
+ if (!menuId) {
294
+ return;
295
+ }
296
+ const event = new CustomEvent(
297
+ events.updateSideMenu, {
298
+ detail: { menuId, action },
299
+ },
300
+ );
301
+ this.dispatchEvent(event);
302
+ }
303
+
304
+ /**
305
+ * Sets order of menu and emits custom event when done
306
+ */
307
+ updateMenuContents() {
308
+ const {
309
+ search, downloads, visualAdjustments, share, bookmarks, volumes
310
+ } = this.menuProviders;
311
+ const availableMenus = [volumes, search, bookmarks, visualAdjustments, share].filter((menu) => !!menu);
312
+
313
+ if (this.shouldShowDownloadsMenu()) {
314
+ downloads?.update(this.downloadableTypes);
315
+ availableMenus.splice(1, 0, downloads);
316
+ }
317
+
318
+ const event = new CustomEvent(
319
+ events.menuUpdated, {
320
+ detail: availableMenus,
321
+ },
322
+ );
323
+ this.dispatchEvent(event);
324
+ }
325
+
326
+ /**
327
+ * Confirms if we should show the downloads menu
328
+ * @returns {bool}
329
+ */
330
+ shouldShowDownloadsMenu() {
331
+ if (!this.downloadableTypes.length) { return false; }
332
+ if (this.bookIsRestricted === false) { return true; }
333
+ if (this.isAdmin) { return true; }
334
+ const { user_loan_record = {} } = this.lendingStatus;
335
+ const hasNoLoanRecord = Array.isArray(user_loan_record); /* (bc PHP assoc. arrays) */
336
+
337
+ if (hasNoLoanRecord) { return false; }
338
+
339
+ const hasValidLoan = user_loan_record.type && (user_loan_record.type !== 'SESSION_LOAN');
340
+ return hasValidLoan;
341
+ }
342
+
343
+ /**
344
+ * Adds a provider object to the menuShortcuts array property if it isn't
345
+ * already added. menuShortcuts are then sorted by shortcutOrder and
346
+ * a menuShortcutsUpdated event is emitted.
347
+ *
348
+ * @param {string} menuId - a string matching the id property of a provider
349
+ */
350
+ addMenuShortcut(menuId) {
351
+ if (this.menuShortcuts.find((m) => m.id === menuId)) {
352
+ // menu is already there
353
+ return;
354
+ }
355
+
356
+ if (!this.menuProviders[menuId]) {
357
+ // no provider for this menu
358
+ return;
359
+ }
360
+
361
+ this.menuShortcuts.push(this.menuProviders[menuId]);
362
+
363
+ this.sortMenuShortcuts();
364
+ this.emitMenuShortcutsUpdated();
365
+ }
366
+
367
+ /**
368
+ * Removes a provider object from the menuShortcuts array and emits a
369
+ * menuShortcutsUpdated event.
370
+ *
371
+ * @param {string} menuId - a string matching the id property of a provider
372
+ */
373
+ removeMenuShortcut(menuId) {
374
+ this.menuShortcuts = this.menuShortcuts.filter((m) => m.id !== menuId);
375
+ this.emitMenuShortcutsUpdated();
376
+ }
377
+
378
+ /**
379
+ * Sorts the menuShortcuts property by comparing each provider's id to
380
+ * the id in each iteration over the shortcutOrder array.
381
+ */
382
+ sortMenuShortcuts() {
383
+ this.menuShortcuts = this.shortcutOrder.reduce((shortcuts, id) => {
384
+ const menu = this.menuShortcuts.find((m) => m.id === id);
385
+ if (menu) { shortcuts.push(menu); }
386
+ return shortcuts;
387
+ }, []);
388
+ }
389
+
390
+ emitMenuShortcutsUpdated() {
391
+ const event = new CustomEvent('menuShortcutsUpdated', {
392
+ detail: this.menuShortcuts,
393
+ });
394
+ this.dispatchEvent(event);
395
+ }
396
+
397
+ emitLoadingStatusUpdate(loaded) {
398
+ const event = new CustomEvent('loadingStateUpdated', {
399
+ detail: { loaded },
400
+ });
401
+ this.dispatchEvent(event);
402
+ }
403
+
404
+ /**
405
+ * Core bookreader event handler registry
406
+ *
407
+ * NOTE: we are trying to keep bookreader's instance in scope
408
+ * Please update Book Navigator's instance reference of it to keep it current
409
+ */
410
+ bindEventListeners() {
411
+ window.addEventListener('BookReader:PostInit', (e) => {
412
+ this.bookreader = e.detail.props;
413
+ this.bookReaderLoaded = true;
414
+ this.bookReaderCannotLoad = false;
415
+ this.emitLoadingStatusUpdate(true);
416
+ this.loadSharedObserver();
417
+ setTimeout(() => {
418
+ this.bookreader.resize();
419
+ }, 0);
420
+ });
421
+ window.addEventListener('BookReader:fullscreenToggled', (event) => {
422
+ const { detail: { props: brInstance = null } } = event;
423
+ if (brInstance) {
424
+ this.bookreader = brInstance;
425
+ }
426
+ this.manageFullScreenBehavior();
427
+ }, { passive: true });
428
+ window.addEventListener('BookReader:ToggleSearchMenu', (event) => {
429
+ this.dispatchEvent(new CustomEvent(events.updateSideMenu, {
430
+ detail: { menuId: 'search', action: 'toggle' },
431
+ }));
432
+ });
433
+ window.addEventListener('LendingFlow:PostInit', ({ detail }) => {
434
+ const {
435
+ downloadTypesAvailable, lendingStatus, isAdmin, previewType,
436
+ } = detail;
437
+ this.lendingInitialized = true;
438
+ this.downloadableTypes = downloadTypesAvailable;
439
+ this.lendingStatus = lendingStatus;
440
+ this.isAdmin = isAdmin;
441
+ this.bookReaderCannotLoad = previewType === 'singlePagePreview';
442
+ this.emitLoadingStatusUpdate(true);
443
+ });
444
+ window.addEventListener('BRJSIA:PostInit', ({ detail }) => {
445
+ const { isRestricted, downloadURLs } = detail;
446
+ this.bookReaderLoaded = true;
447
+ this.downloadableTypes = downloadURLs;
448
+ this.bookIsRestricted = isRestricted;
449
+ });
450
+ window.addEventListener('contextmenu', (e) => this.manageContextMenuVisibility(e), { capture: true });
451
+ }
452
+
453
+ /** Display an element's context menu */
454
+ manageContextMenuVisibility(e) {
455
+ window.archive_analytics?.send_event(
456
+ 'BookReader',
457
+ `contextmenu-${this.bookIsRestricted ? 'restricted' : 'unrestricted'}`,
458
+ e.target?.classList?.value
459
+ );
460
+ if (!this.bookIsRestricted) {
461
+ return;
462
+ }
463
+
464
+ const imagePane = e.target.classList.value.match(/BRscreen|BRpageimage/g);
465
+ if (!imagePane) {
466
+ return;
467
+ }
468
+
469
+ e.preventDefault();
470
+ return false;
471
+ }
472
+
473
+ loadSharedObserver() {
474
+ this.sharedObserverHandler = { handleResize: this.handleResize.bind(this) };
475
+ this.sharedObserver?.addObserver({
476
+ target: this.mainBRContainer,
477
+ handler: this.sharedObserverHandler
478
+ });
479
+ }
480
+
481
+ /**
482
+ * Uses resize observer to fire BookReader's `resize` functionality
483
+ * We do not want to trigger resize IF:
484
+ * - book animation is happening
485
+ * - book is in fullscreen (fullscreen is handled separately)
486
+ *
487
+ * @param { target: HTMLElement, contentRect: DOMRectReadOnly } entry
488
+ */
489
+ handleResize({ contentRect, target }) {
490
+ const startBrWidth = this.brWidth;
491
+ const startBrHeight = this.brHeight;
492
+ const { animating } = this.bookreader;
493
+
494
+ if (target === this.mainBRContainer) {
495
+ this.brWidth = contentRect.width;
496
+ this.brHeight = contentRect.height;
497
+ }
498
+
499
+ if (!startBrWidth && this.brWidth) {
500
+ // loading up, let's update side menus
501
+ this.initializeBookSubmenus();
502
+ }
503
+
504
+ const widthChange = startBrWidth !== this.brWidth;
505
+ const heightChange = startBrHeight !== this.brHeight;
506
+
507
+ if (!animating && (widthChange || heightChange)) {
508
+ this.bookreader?.resize();
509
+ }
510
+ }
511
+
512
+ /**
513
+ * Manages Fullscreen behavior
514
+ * This makes sure that controls are _always_ in view
515
+ * We need this to accommodate LOAN BAR during fullscreen
516
+ */
517
+ manageFullScreenBehavior() {
518
+ this.emitFullScreenState();
519
+
520
+ if (!this.bookreader.options.enableFSLogoShortcut) {
521
+ return;
522
+ }
523
+
524
+ const isFullScreen = this.bookreader.isFullscreen();
525
+ if (isFullScreen) {
526
+ this.addFullscreenShortcut();
527
+ } else {
528
+ this.deleteFullscreenShortcut();
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Relays fullscreen toggle events
534
+ */
535
+ emitFullScreenState() {
536
+ const isFullScreen = this.bookreader.isFullscreen();
537
+ const event = new CustomEvent('ViewportInFullScreen', {
538
+ detail: { isFullScreen },
539
+ });
540
+ this.dispatchEvent(event);
541
+ }
542
+
543
+ get itemImage() {
544
+ const identifier = this.itemMD?.metadata.identifier;
545
+ const url = `https://${this.baseHost}/services/img/${identifier}`;
546
+ return html`<img class="cover-img" src=${url} alt="cover image for ${identifier}">`;
547
+ }
548
+
549
+ get placeholder() {
550
+ return html`<div class="placeholder">${this.itemImage}</div>`;
551
+ }
552
+
553
+ render() {
554
+ return html`<div id="book-navigator__root">
555
+ ${this.bookReaderCannotLoad ? this.placeholder : nothing}
556
+ ${!this.bookReaderCannotLoad ? html`<slot name="main"></slot>` : nothing}
557
+ </div>
558
+ `;
559
+ }
560
+
561
+ static get styles() {
562
+ return css`
563
+ :host,
564
+ #book-navigator__root,
565
+ slot,
566
+ slot > * {
567
+ display: block;
568
+ height: inherit;
569
+ width: inherit;
570
+ }
571
+ .placeholder {
572
+ display: flex;
573
+ align-items: center;
574
+ justify-content: center;
575
+ flex-direction: column;
576
+ margin: 5%;
577
+ }
578
+ .cover-img {
579
+ max-height: 300px;
580
+ }
581
+ `;
582
+ }
583
+ }
584
+
585
+ customElements.define('book-navigator', BookNavigator);
@@ -1,4 +1,4 @@
1
- import { LitElement, html, css } from 'lit-element';
1
+ import { LitElement, html, css } from 'lit';
2
2
 
3
3
  export default class BookmarkButton extends LitElement {
4
4
  static get styles() {
@@ -12,7 +12,7 @@ export default class BookmarkButton extends LitElement {
12
12
  height: 4rem;
13
13
  width: 4rem;
14
14
  background: transparent;
15
- cursor: url('/images/bookreader/bookmark-add.png'), pointer;
15
+ cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 24' width='16'%3E%3Cg fill='%23333' fill-rule='evenodd'%3E%3Cpath d='m15 0c.5522847 0 1 .44771525 1 1v23l-8-5.4545455-8 5.4545455v-23c0-.55228475.44771525-1 1-1zm-2 2h-10c-.51283584 0-.93550716.38604019-.99327227.88337887l-.00672773.11662113v18l6-4.3181818 6 4.3181818v-18c0-.51283584-.3860402-.93550716-.8833789-.99327227z'/%3E%3Cpath d='m8.75 6v2.25h2.25v1.5h-2.25v2.25h-1.5v-2.25h-2.25v-1.5h2.25v-2.25z' fill-rule='nonzero'/%3E%3C/g%3E%3C/svg%3E"), pointer;
16
16
  position: relative;
17
17
  }
18
18
  button > * {
@@ -40,6 +40,7 @@ export default class BookmarkButton extends LitElement {
40
40
  constructor() {
41
41
  super();
42
42
  this.state = 'hollow';
43
+ this.side = undefined;
43
44
  }
44
45
 
45
46
  handleClick(e) {