@internetarchive/bookreader 5.0.0-18

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 (428) hide show
  1. package/.eslintrc.js +58 -0
  2. package/.gitattributes +2 -0
  3. package/.github/ISSUE_TEMPLATE/bug.md +32 -0
  4. package/.github/ISSUE_TEMPLATE/feature-request.md +30 -0
  5. package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +15 -0
  6. package/.github/dependabot.yml +8 -0
  7. package/.github/workflows/node.js.yml +37 -0
  8. package/.github/workflows/npm-publish.yml +47 -0
  9. package/.testcaferc.json +5 -0
  10. package/BookReader/BookReader.css +2983 -0
  11. package/BookReader/BookReader.js +3 -0
  12. package/BookReader/BookReader.js.LICENSE.txt +117 -0
  13. package/BookReader/BookReader.js.map +1 -0
  14. package/BookReader/bookreader-component-bundle.js +1436 -0
  15. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +27 -0
  16. package/BookReader/bookreader-component-bundle.js.map +1 -0
  17. package/BookReader/icons/1up.svg +1 -0
  18. package/BookReader/icons/2up.svg +1 -0
  19. package/BookReader/icons/advance.svg +3 -0
  20. package/BookReader/icons/chevron-right.svg +1 -0
  21. package/BookReader/icons/close-circle-dark.svg +1 -0
  22. package/BookReader/icons/close-circle.svg +1 -0
  23. package/BookReader/icons/fullscreen.svg +1 -0
  24. package/BookReader/icons/fullscreen_exit.svg +1 -0
  25. package/BookReader/icons/hamburger.svg +1 -0
  26. package/BookReader/icons/left-arrow.svg +1 -0
  27. package/BookReader/icons/magnify-minus.svg +1 -0
  28. package/BookReader/icons/magnify-plus.svg +1 -0
  29. package/BookReader/icons/magnify.svg +1 -0
  30. package/BookReader/icons/pause.svg +1 -0
  31. package/BookReader/icons/play.svg +1 -0
  32. package/BookReader/icons/playback-speed.svg +1 -0
  33. package/BookReader/icons/read-aloud.svg +1 -0
  34. package/BookReader/icons/review.svg +3 -0
  35. package/BookReader/icons/thumbnails.svg +1 -0
  36. package/BookReader/icons/volume-full.svg +1 -0
  37. package/BookReader/images/BRicons.png +0 -0
  38. package/BookReader/images/BRicons.svg +5 -0
  39. package/BookReader/images/BRicons_ia.png +0 -0
  40. package/BookReader/images/back_pages.png +0 -0
  41. package/BookReader/images/book_bottom_icon.png +0 -0
  42. package/BookReader/images/book_down_icon.png +0 -0
  43. package/BookReader/images/book_left_icon.png +0 -0
  44. package/BookReader/images/book_leftmost_icon.png +0 -0
  45. package/BookReader/images/book_right_icon.png +0 -0
  46. package/BookReader/images/book_rightmost_icon.png +0 -0
  47. package/BookReader/images/book_top_icon.png +0 -0
  48. package/BookReader/images/book_up_icon.png +0 -0
  49. package/BookReader/images/books_graphic.svg +1 -0
  50. package/BookReader/images/booksplit.png +0 -0
  51. package/BookReader/images/control_pause_icon.png +0 -0
  52. package/BookReader/images/control_play_icon.png +0 -0
  53. package/BookReader/images/embed_icon.png +0 -0
  54. package/BookReader/images/icon-home-ia.png +0 -0
  55. package/BookReader/images/icon_OL-logo-xs.png +0 -0
  56. package/BookReader/images/icon_alert-xs.png +0 -0
  57. package/BookReader/images/icon_book.svg +1 -0
  58. package/BookReader/images/icon_bookmark.svg +1 -0
  59. package/BookReader/images/icon_close-pop.png +0 -0
  60. package/BookReader/images/icon_download.png +0 -0
  61. package/BookReader/images/icon_gear.svg +1 -0
  62. package/BookReader/images/icon_hamburger.svg +1 -0
  63. package/BookReader/images/icon_home.png +0 -0
  64. package/BookReader/images/icon_home.svg +1 -0
  65. package/BookReader/images/icon_home_ia.png +0 -0
  66. package/BookReader/images/icon_indicator.png +0 -0
  67. package/BookReader/images/icon_info.svg +1 -0
  68. package/BookReader/images/icon_one_page.svg +1 -0
  69. package/BookReader/images/icon_pause.svg +1 -0
  70. package/BookReader/images/icon_play.svg +1 -0
  71. package/BookReader/images/icon_playback-rate.svg +1 -0
  72. package/BookReader/images/icon_return.png +0 -0
  73. package/BookReader/images/icon_search_button.svg +1 -0
  74. package/BookReader/images/icon_share.svg +1 -0
  75. package/BookReader/images/icon_skip-ahead.svg +1 -0
  76. package/BookReader/images/icon_skip-back.svg +2 -0
  77. package/BookReader/images/icon_speaker.svg +1 -0
  78. package/BookReader/images/icon_speaker_open.svg +1 -0
  79. package/BookReader/images/icon_thumbnails.svg +1 -0
  80. package/BookReader/images/icon_toc.svg +1 -0
  81. package/BookReader/images/icon_two_pages.svg +1 -0
  82. package/BookReader/images/icon_zoomer.png +0 -0
  83. package/BookReader/images/loading.gif +0 -0
  84. package/BookReader/images/logo_icon.png +0 -0
  85. package/BookReader/images/marker_chap-off.png +0 -0
  86. package/BookReader/images/marker_chap-off.svg +1 -0
  87. package/BookReader/images/marker_chap-off_ia.png +0 -0
  88. package/BookReader/images/marker_chap-on.png +0 -0
  89. package/BookReader/images/marker_chap-on.svg +1 -0
  90. package/BookReader/images/marker_srch-on.svg +1 -0
  91. package/BookReader/images/marker_srchchap-off.png +0 -0
  92. package/BookReader/images/marker_srchchap-on.png +0 -0
  93. package/BookReader/images/nav_control-dn.png +0 -0
  94. package/BookReader/images/nav_control-dn_ia.png +0 -0
  95. package/BookReader/images/nav_control-up.png +0 -0
  96. package/BookReader/images/nav_control-up_ia.png +0 -0
  97. package/BookReader/images/nav_control.png +0 -0
  98. package/BookReader/images/one_page_mode_icon.png +0 -0
  99. package/BookReader/images/paper-badge.png +0 -0
  100. package/BookReader/images/print_icon.png +0 -0
  101. package/BookReader/images/progressbar.gif +0 -0
  102. package/BookReader/images/right_edges.png +0 -0
  103. package/BookReader/images/slider.png +0 -0
  104. package/BookReader/images/slider_ia.png +0 -0
  105. package/BookReader/images/thumbnail_mode_icon.png +0 -0
  106. package/BookReader/images/transparent.png +0 -0
  107. package/BookReader/images/two_page_mode_icon.png +0 -0
  108. package/BookReader/images/zoom_in_icon.png +0 -0
  109. package/BookReader/images/zoom_out_icon.png +0 -0
  110. package/BookReader/jquery-1.10.1.js +2 -0
  111. package/BookReader/jquery-1.10.1.js.LICENSE.txt +24 -0
  112. package/BookReader/plugins/plugin.archive_analytics.js +2 -0
  113. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -0
  114. package/BookReader/plugins/plugin.autoplay.js +2 -0
  115. package/BookReader/plugins/plugin.autoplay.js.map +1 -0
  116. package/BookReader/plugins/plugin.chapters.js +2 -0
  117. package/BookReader/plugins/plugin.chapters.js.map +1 -0
  118. package/BookReader/plugins/plugin.iframe.js +2 -0
  119. package/BookReader/plugins/plugin.iframe.js.map +1 -0
  120. package/BookReader/plugins/plugin.mobile_nav.js +2 -0
  121. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -0
  122. package/BookReader/plugins/plugin.resume.js +2 -0
  123. package/BookReader/plugins/plugin.resume.js.map +1 -0
  124. package/BookReader/plugins/plugin.search.js +2 -0
  125. package/BookReader/plugins/plugin.search.js.map +1 -0
  126. package/BookReader/plugins/plugin.text_selection.js +2 -0
  127. package/BookReader/plugins/plugin.text_selection.js.map +1 -0
  128. package/BookReader/plugins/plugin.tts.js +3 -0
  129. package/BookReader/plugins/plugin.tts.js.LICENSE.txt +27 -0
  130. package/BookReader/plugins/plugin.tts.js.map +1 -0
  131. package/BookReader/plugins/plugin.url.js +2 -0
  132. package/BookReader/plugins/plugin.url.js.map +1 -0
  133. package/BookReader/plugins/plugin.vendor-fullscreen.js +2 -0
  134. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -0
  135. package/BookReaderDemo/BookReaderDemo.css +41 -0
  136. package/BookReaderDemo/BookReaderJSAdvanced.js +115 -0
  137. package/BookReaderDemo/BookReaderJSAutoplay.js +56 -0
  138. package/BookReaderDemo/BookReaderJSSimple.js +55 -0
  139. package/BookReaderDemo/IIIFBookReader.js +207 -0
  140. package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +1 -0
  141. package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +1 -0
  142. package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
  143. package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
  144. package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
  145. package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +1 -0
  146. package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +1 -0
  147. package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
  148. package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
  149. package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
  150. package/BookReaderDemo/bookreader-template-bundle.js +7178 -0
  151. package/BookReaderDemo/demo-advanced.html +32 -0
  152. package/BookReaderDemo/demo-autoplay.html +38 -0
  153. package/BookReaderDemo/demo-embed-iframe-src.html +84 -0
  154. package/BookReaderDemo/demo-embed.html +26 -0
  155. package/BookReaderDemo/demo-fullscreen-mobile.html +36 -0
  156. package/BookReaderDemo/demo-fullscreen.html +33 -0
  157. package/BookReaderDemo/demo-iiif.html +34 -0
  158. package/BookReaderDemo/demo-iiif.js +26 -0
  159. package/BookReaderDemo/demo-internetarchive.html +74 -0
  160. package/BookReaderDemo/demo-multiple.html +43 -0
  161. package/BookReaderDemo/demo-preview-pages.html +1092 -0
  162. package/BookReaderDemo/demo-simple.html +34 -0
  163. package/BookReaderDemo/demo-vendor-fullscreen.html +36 -0
  164. package/BookReaderDemo/immersion-1up.html +64 -0
  165. package/BookReaderDemo/immersion-mode.html +35 -0
  166. package/BookReaderDemo/toggle_controls.html +53 -0
  167. package/BookReaderDemo/view_mode.html +39 -0
  168. package/BookReaderDemo/viewmode-cycle.html +41 -0
  169. package/CHANGELOG.md +540 -0
  170. package/CONTRIBUTING.md +7 -0
  171. package/LICENSE +661 -0
  172. package/README.md +205 -0
  173. package/babel.config.js +18 -0
  174. package/codecov.yml +17 -0
  175. package/index.html +31 -0
  176. package/jsconfig.json +14 -0
  177. package/karma.conf.js +23 -0
  178. package/package.json +129 -0
  179. package/screenshot.png +0 -0
  180. package/scripts/postversion.js +10 -0
  181. package/scripts/preversion.js +14 -0
  182. package/scripts/version.js +26 -0
  183. package/src/BookNavigator/BookModel.js +14 -0
  184. package/src/BookNavigator/BookNavigator.js +468 -0
  185. package/src/BookNavigator/assets/book-loader.js +27 -0
  186. package/src/BookNavigator/assets/bookmark-colors.js +15 -0
  187. package/src/BookNavigator/assets/button-base.js +61 -0
  188. package/src/BookNavigator/assets/icon_checkmark.js +6 -0
  189. package/src/BookNavigator/assets/icon_close.js +3 -0
  190. package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
  191. package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
  192. package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
  193. package/src/BookNavigator/assets/icon_volumes.js +11 -0
  194. package/src/BookNavigator/bookmarks/bookmark-button.js +64 -0
  195. package/src/BookNavigator/bookmarks/bookmark-edit.js +215 -0
  196. package/src/BookNavigator/bookmarks/bookmarks-list.js +285 -0
  197. package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +28 -0
  198. package/src/BookNavigator/bookmarks/bookmarks-provider.js +53 -0
  199. package/src/BookNavigator/bookmarks/ia-bookmarks.js +500 -0
  200. package/src/BookNavigator/br-fullscreen-mgr.js +83 -0
  201. package/src/BookNavigator/delete-modal-actions.js +49 -0
  202. package/src/BookNavigator/downloads/downloads-provider.js +76 -0
  203. package/src/BookNavigator/downloads/downloads.js +138 -0
  204. package/src/BookNavigator/search/a-search-result.js +55 -0
  205. package/src/BookNavigator/search/search-provider.js +180 -0
  206. package/src/BookNavigator/search/search-results.js +360 -0
  207. package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +93 -0
  208. package/src/BookNavigator/visual-adjustments/visual-adjustments.js +280 -0
  209. package/src/BookNavigator/volumes/volumes-provider.js +83 -0
  210. package/src/BookNavigator/volumes/volumes.js +178 -0
  211. package/src/BookReader/BookModel.js +518 -0
  212. package/src/BookReader/DebugConsole.js +54 -0
  213. package/src/BookReader/ImageCache.js +116 -0
  214. package/src/BookReader/Mode1Up.js +90 -0
  215. package/src/BookReader/Mode1UpLit.js +434 -0
  216. package/src/BookReader/Mode2Up.js +1372 -0
  217. package/src/BookReader/ModeSmoothZoom.js +177 -0
  218. package/src/BookReader/ModeThumb.js +336 -0
  219. package/src/BookReader/Navbar/Navbar.js +339 -0
  220. package/src/BookReader/PageContainer.js +120 -0
  221. package/src/BookReader/ReduceSet.js +26 -0
  222. package/src/BookReader/Toolbar/Toolbar.js +384 -0
  223. package/src/BookReader/events.js +20 -0
  224. package/src/BookReader/options.js +320 -0
  225. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  226. package/src/BookReader/utils/classes.js +36 -0
  227. package/src/BookReader/utils.js +240 -0
  228. package/src/BookReader.js +2546 -0
  229. package/src/BookReaderComponent/BookReaderComponent.js +112 -0
  230. package/src/ItemNavigator/ItemNavigator.js +376 -0
  231. package/src/ItemNavigator/providers/sharing.js +33 -0
  232. package/src/assets/icons/1up.svg +12 -0
  233. package/src/assets/icons/2up.svg +15 -0
  234. package/src/assets/icons/advance.svg +26 -0
  235. package/src/assets/icons/chevron-right.svg +1 -0
  236. package/src/assets/icons/close-circle-dark.svg +1 -0
  237. package/src/assets/icons/close-circle.svg +1 -0
  238. package/src/assets/icons/fullscreen.svg +17 -0
  239. package/src/assets/icons/fullscreen_exit.svg +17 -0
  240. package/src/assets/icons/hamburger.svg +15 -0
  241. package/src/assets/icons/left-arrow.svg +12 -0
  242. package/src/assets/icons/magnify-minus.svg +16 -0
  243. package/src/assets/icons/magnify-plus.svg +17 -0
  244. package/src/assets/icons/magnify.svg +15 -0
  245. package/src/assets/icons/pause.svg +23 -0
  246. package/src/assets/icons/play.svg +22 -0
  247. package/src/assets/icons/playback-speed.svg +34 -0
  248. package/src/assets/icons/read-aloud.svg +22 -0
  249. package/src/assets/icons/review.svg +22 -0
  250. package/src/assets/icons/thumbnails.svg +17 -0
  251. package/src/assets/icons/volume-full.svg +22 -0
  252. package/src/assets/images/BRicons.png +0 -0
  253. package/src/assets/images/BRicons.svg +94 -0
  254. package/src/assets/images/BRicons_ia.png +0 -0
  255. package/src/assets/images/back_pages.png +0 -0
  256. package/src/assets/images/book_bottom_icon.png +0 -0
  257. package/src/assets/images/book_down_icon.png +0 -0
  258. package/src/assets/images/book_left_icon.png +0 -0
  259. package/src/assets/images/book_leftmost_icon.png +0 -0
  260. package/src/assets/images/book_right_icon.png +0 -0
  261. package/src/assets/images/book_rightmost_icon.png +0 -0
  262. package/src/assets/images/book_top_icon.png +0 -0
  263. package/src/assets/images/book_up_icon.png +0 -0
  264. package/src/assets/images/books_graphic.svg +177 -0
  265. package/src/assets/images/booksplit.png +0 -0
  266. package/src/assets/images/control_pause_icon.png +0 -0
  267. package/src/assets/images/control_play_icon.png +0 -0
  268. package/src/assets/images/embed_icon.png +0 -0
  269. package/src/assets/images/icon-home-ia.png +0 -0
  270. package/src/assets/images/icon_OL-logo-xs.png +0 -0
  271. package/src/assets/images/icon_alert-xs.png +0 -0
  272. package/src/assets/images/icon_book.svg +12 -0
  273. package/src/assets/images/icon_bookmark.svg +12 -0
  274. package/src/assets/images/icon_close-pop.png +0 -0
  275. package/src/assets/images/icon_download.png +0 -0
  276. package/src/assets/images/icon_gear.svg +14 -0
  277. package/src/assets/images/icon_hamburger.svg +20 -0
  278. package/src/assets/images/icon_home.png +0 -0
  279. package/src/assets/images/icon_home.svg +21 -0
  280. package/src/assets/images/icon_home_ia.png +0 -0
  281. package/src/assets/images/icon_indicator.png +0 -0
  282. package/src/assets/images/icon_info.svg +11 -0
  283. package/src/assets/images/icon_one_page.svg +8 -0
  284. package/src/assets/images/icon_pause.svg +1 -0
  285. package/src/assets/images/icon_play.svg +1 -0
  286. package/src/assets/images/icon_playback-rate.svg +15 -0
  287. package/src/assets/images/icon_return.png +0 -0
  288. package/src/assets/images/icon_search_button.svg +8 -0
  289. package/src/assets/images/icon_share.svg +9 -0
  290. package/src/assets/images/icon_skip-ahead.svg +6 -0
  291. package/src/assets/images/icon_skip-back.svg +13 -0
  292. package/src/assets/images/icon_speaker.svg +18 -0
  293. package/src/assets/images/icon_speaker_open.svg +10 -0
  294. package/src/assets/images/icon_thumbnails.svg +12 -0
  295. package/src/assets/images/icon_toc.svg +5 -0
  296. package/src/assets/images/icon_two_pages.svg +9 -0
  297. package/src/assets/images/icon_zoomer.png +0 -0
  298. package/src/assets/images/loading.gif +0 -0
  299. package/src/assets/images/logo_icon.png +0 -0
  300. package/src/assets/images/marker_chap-off.png +0 -0
  301. package/src/assets/images/marker_chap-off.svg +11 -0
  302. package/src/assets/images/marker_chap-off_ia.png +0 -0
  303. package/src/assets/images/marker_chap-on.png +0 -0
  304. package/src/assets/images/marker_chap-on.svg +11 -0
  305. package/src/assets/images/marker_srch-on.svg +11 -0
  306. package/src/assets/images/marker_srchchap-off.png +0 -0
  307. package/src/assets/images/marker_srchchap-on.png +0 -0
  308. package/src/assets/images/nav_control-dn.png +0 -0
  309. package/src/assets/images/nav_control-dn_ia.png +0 -0
  310. package/src/assets/images/nav_control-up.png +0 -0
  311. package/src/assets/images/nav_control-up_ia.png +0 -0
  312. package/src/assets/images/nav_control.png +0 -0
  313. package/src/assets/images/one_page_mode_icon.png +0 -0
  314. package/src/assets/images/paper-badge.png +0 -0
  315. package/src/assets/images/print_icon.png +0 -0
  316. package/src/assets/images/progressbar.gif +0 -0
  317. package/src/assets/images/right_edges.png +0 -0
  318. package/src/assets/images/slider.png +0 -0
  319. package/src/assets/images/slider_ia.png +0 -0
  320. package/src/assets/images/thumbnail_mode_icon.png +0 -0
  321. package/src/assets/images/transparent.png +0 -0
  322. package/src/assets/images/two_page_mode_icon.png +0 -0
  323. package/src/assets/images/zoom_in_icon.png +0 -0
  324. package/src/assets/images/zoom_out_icon.png +0 -0
  325. package/src/css/BookReader.scss +89 -0
  326. package/src/css/_BRBookmarks.scss +29 -0
  327. package/src/css/_BRComponent.scss +13 -0
  328. package/src/css/_BRfloat.scss +197 -0
  329. package/src/css/_BRicon.scss +48 -0
  330. package/src/css/_BRmain.scss +251 -0
  331. package/src/css/_BRnav.scss +382 -0
  332. package/src/css/_BRpages.scss +139 -0
  333. package/src/css/_BRsearch.scss +226 -0
  334. package/src/css/_BRtoolbar.scss +84 -0
  335. package/src/css/_BRvendor.scss +5 -0
  336. package/src/css/_MobileNav.scss +194 -0
  337. package/src/css/_TextSelection.scss +32 -0
  338. package/src/css/_colorbox.scss +52 -0
  339. package/src/css/_controls.scss +244 -0
  340. package/src/css/_icons.scss +121 -0
  341. package/src/dragscrollable-br.js +261 -0
  342. package/src/jquery-wrapper.js +4 -0
  343. package/src/plugins/plugin.archive_analytics.js +86 -0
  344. package/src/plugins/plugin.autoplay.js +129 -0
  345. package/src/plugins/plugin.chapters.js +251 -0
  346. package/src/plugins/plugin.iframe.js +48 -0
  347. package/src/plugins/plugin.mobile_nav.js +287 -0
  348. package/src/plugins/plugin.resume.js +68 -0
  349. package/src/plugins/plugin.text_selection.js +291 -0
  350. package/src/plugins/plugin.url.js +198 -0
  351. package/src/plugins/plugin.vendor-fullscreen.js +247 -0
  352. package/src/plugins/search/plugin.search.js +439 -0
  353. package/src/plugins/search/view.js +440 -0
  354. package/src/plugins/tts/AbstractTTSEngine.js +242 -0
  355. package/src/plugins/tts/FestivalTTSEngine.js +169 -0
  356. package/src/plugins/tts/PageChunk.js +107 -0
  357. package/src/plugins/tts/PageChunkIterator.js +163 -0
  358. package/src/plugins/tts/WebTTSEngine.js +352 -0
  359. package/src/plugins/tts/plugin.tts.js +335 -0
  360. package/src/plugins/tts/tooltip_dict.js +15 -0
  361. package/src/plugins/tts/utils.js +91 -0
  362. package/src/util/browserSniffing.js +30 -0
  363. package/src/util/debouncer.js +26 -0
  364. package/src/util/docCookies.js +67 -0
  365. package/src/util/strings.js +34 -0
  366. package/tests/BookReader/BookModel.test.js +312 -0
  367. package/tests/BookReader/BookReaderPublicFunctions.test.js +164 -0
  368. package/tests/BookReader/DebugConsole.test.js +25 -0
  369. package/tests/BookReader/ImageCache.test.js +150 -0
  370. package/tests/BookReader/Mode1UpLit.test.js +87 -0
  371. package/tests/BookReader/Mode2Up.test.js +245 -0
  372. package/tests/BookReader/ModeSmoothZoom.test.js +149 -0
  373. package/tests/BookReader/Navbar/Navbar.test.js +169 -0
  374. package/tests/BookReader/PageContainer.test.js +187 -0
  375. package/tests/BookReader/ReduceSet.test.js +38 -0
  376. package/tests/BookReader/Toolbar/Toolbar.test.js +26 -0
  377. package/tests/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
  378. package/tests/BookReader/utils/classes.test.js +88 -0
  379. package/tests/BookReader/utils.test.js +136 -0
  380. package/tests/BookReader.options.test.js +39 -0
  381. package/tests/BookReader.test.js +301 -0
  382. package/tests/e2e/README.md +75 -0
  383. package/tests/e2e/autoplay.test.js +13 -0
  384. package/tests/e2e/base.test.js +35 -0
  385. package/tests/e2e/helpers/base.js +263 -0
  386. package/tests/e2e/helpers/debug.js +13 -0
  387. package/tests/e2e/helpers/desktopSearch.js +72 -0
  388. package/tests/e2e/helpers/mobileSearch.js +85 -0
  389. package/tests/e2e/helpers/mockSearch.js +93 -0
  390. package/tests/e2e/helpers/rightToLeft.js +29 -0
  391. package/tests/e2e/ia-production/ia-prod-base.js +17 -0
  392. package/tests/e2e/models/BookReader.js +11 -0
  393. package/tests/e2e/models/Navigation.js +56 -0
  394. package/tests/e2e/rightToLeft.test.js +20 -0
  395. package/tests/e2e/viewmode.test.js +37 -0
  396. package/tests/karma/BookNavigator/book-navigator.test.js +180 -0
  397. package/tests/karma/BookNavigator/bookmarks/bookmark-edit.test.js +133 -0
  398. package/tests/karma/BookNavigator/bookmarks/bookmarks-list.test.js +222 -0
  399. package/tests/karma/BookNavigator/downloads/downloads-provider.test.js +64 -0
  400. package/tests/karma/BookNavigator/downloads/downloads.test.js +54 -0
  401. package/tests/karma/BookNavigator/search/search-provider.test.js +23 -0
  402. package/tests/karma/BookNavigator/search/search-results.test.js +240 -0
  403. package/tests/karma/BookNavigator/sharing/sharing-provider.test.js +40 -0
  404. package/tests/karma/BookNavigator/visual-adjustments.test.js +201 -0
  405. package/tests/karma/BookNavigator/volumes/volumes-provider.test.js +160 -0
  406. package/tests/karma/BookNavigator/volumes/volumes.test.js +98 -0
  407. package/tests/plugins/plugin.archive_analytics.test.js +23 -0
  408. package/tests/plugins/plugin.autoplay.test.js +52 -0
  409. package/tests/plugins/plugin.chapters.test.js +130 -0
  410. package/tests/plugins/plugin.iframe.test.js +42 -0
  411. package/tests/plugins/plugin.mobile_nav.test.js +66 -0
  412. package/tests/plugins/plugin.resume.test.js +98 -0
  413. package/tests/plugins/plugin.text_selection.test.js +193 -0
  414. package/tests/plugins/plugin.url.test.js +129 -0
  415. package/tests/plugins/plugin.vendor-fullscreen.test.js +65 -0
  416. package/tests/plugins/search/plugin.search.test.js +173 -0
  417. package/tests/plugins/search/plugin.search.view.test.js +106 -0
  418. package/tests/plugins/tts/AbstractTTSEngine.test.js +153 -0
  419. package/tests/plugins/tts/FestivalTTSEngine.test.js +59 -0
  420. package/tests/plugins/tts/PageChunk.test.js +57 -0
  421. package/tests/plugins/tts/PageChunkIterator.test.js +179 -0
  422. package/tests/plugins/tts/WebTTSEngine.test.js +126 -0
  423. package/tests/plugins/tts/utils.test.js +133 -0
  424. package/tests/util/browserSniffing.test.js +56 -0
  425. package/tests/util/docCookies.test.js +15 -0
  426. package/tests/util/strings.test.js +63 -0
  427. package/tests/utils.js +80 -0
  428. package/webpack.config.js +85 -0
@@ -0,0 +1,86 @@
1
+ /* global BookReader, archive_analytics */
2
+ /**
3
+ * Plugin for Archive.org analytics
4
+ */
5
+ jQuery.extend(BookReader.defaultOptions, {
6
+ enableArchiveAnalytics: true,
7
+ /** Provide a means of debugging, cause otherwise it's impossible to test locally */
8
+ debugArchiveAnaltyics: false,
9
+ });
10
+
11
+ BookReader.prototype.init = (function(super_) {
12
+ return function() {
13
+ super_.call(this);
14
+
15
+ if (this.options.enableArchiveAnalytics) {
16
+ this.bind(BookReader.eventNames.fragmentChange, () => this.archiveAnalyticsSendFragmentChange());
17
+ }
18
+ };
19
+ })(BookReader.prototype.init);
20
+
21
+ /** @private */
22
+ BookReader.prototype.archiveAnalyticsSendFragmentChange = function() {
23
+ if (!window.archive_analytics) {
24
+ return;
25
+ }
26
+
27
+ const prevFragment = this.archiveAnalyticsSendFragmentChange.prevFragment;
28
+
29
+ const params = this.paramsFromCurrent();
30
+ const newFragment = this.fragmentFromParams(params);
31
+
32
+ if (prevFragment != newFragment) {
33
+ const values = {
34
+ bookreader: "user_changed_view",
35
+ itemid: this.bookId,
36
+ cache_bust: Math.random()
37
+ };
38
+ // EEK! offsite embedding and /details/ page books look the same in analytics, otherwise!
39
+ values.offsite = 1;
40
+ values.details = 0;
41
+ try {
42
+ values.offsite = window.top.location.hostname.match(/\.archive.org$/)
43
+ ? 0
44
+ : 1;
45
+ values.details =
46
+ !values.offsite && window.top.location.pathname.match(/^\/details\//)
47
+ ? 1
48
+ : 0;
49
+ } catch (e) {}
50
+ // avoids embed cross site exceptions -- but on (+) side, means it is and keeps marked offite!
51
+
52
+ // Send bookreader ping
53
+ archive_analytics.send_ping(values, null, "augment_for_ao_site");
54
+
55
+ // Also send tracking event ping
56
+ const additionalEventParams = this.options.lendingInfo && this.options.lendingInfo.loanId
57
+ ? { loanId: this.options.lendingInfo.loanId }
58
+ : {};
59
+ archive_analytics.send_event('BookReader', 'UserChangedView', window.location.pathname, additionalEventParams);
60
+
61
+ this.archiveAnalyticsSendFragmentChange.prevFragment = newFragment;
62
+ }
63
+ };
64
+
65
+ /**
66
+ * Sends a tracking "Event". See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events
67
+ * @param {string} category
68
+ * @param {string} action
69
+ * @param {number} [value] (must be an int)
70
+ * @param {Object} [additionalEventParams]
71
+ */
72
+ BookReader.prototype.archiveAnalyticsSendEvent = function(category, action, value, additionalEventParams) {
73
+ if (!this.options.enableArchiveAnalytics) return;
74
+
75
+ if (this.options.debugArchiveAnaltyics) {
76
+ console.log("archiveAnalyticsSendEvent", arguments, window.archive_analytics);
77
+ }
78
+
79
+ if (!window.archive_analytics) return;
80
+
81
+ additionalEventParams = additionalEventParams || {};
82
+ if (typeof(value) == 'number') {
83
+ additionalEventParams.ev = value;
84
+ }
85
+ window.archive_analytics.send_event(category, action, null, additionalEventParams);
86
+ };
@@ -0,0 +1,129 @@
1
+ /*global BookReader */
2
+
3
+ /**
4
+ * Plugin which adds an autoplay feature. Useful for kiosk situations.
5
+ */
6
+ jQuery.extend(BookReader.defaultOptions, {
7
+ enableAutoPlayPlugin: true
8
+ });
9
+
10
+ /**
11
+ * @override BookReader.setup
12
+ */
13
+ BookReader.prototype.setup = (function(super_) {
14
+ return function (options) {
15
+ super_.call(this, options);
16
+
17
+ this.auto = false;
18
+ this.autoTimer = null;
19
+ this.flipDelay = 5000;
20
+ };
21
+ })(BookReader.prototype.setup);
22
+
23
+ /**
24
+ * @override BookReader.init
25
+ */
26
+ BookReader.prototype.init = (function(super_) {
27
+ return function (options) {
28
+ super_.call(this, options);
29
+
30
+ if (!this.options.enableAutoPlayPlugin) return;
31
+ this.bind(BookReader.eventNames.stop, () => this.autoStop());
32
+ };
33
+ })(BookReader.prototype.init);
34
+
35
+ /**
36
+ * @override BookReader.bindNavigationHandlers
37
+ */
38
+ BookReader.prototype.bindNavigationHandlers = (function(super_) {
39
+ return function() {
40
+ super_.call(this);
41
+
42
+ if (!this.options.enableAutoPlayPlugin) return;
43
+
44
+ // Note the mobile plugin attaches itself to body, so we need to select outside
45
+ const jIcons = this.$('.BRicon').add('.BRmobileMenu .BRicon');
46
+
47
+ jIcons.filter('.play').click(() => {
48
+ this.autoToggle();
49
+ return false;
50
+ });
51
+
52
+ jIcons.filter('.pause').click(() => {
53
+ this.autoToggle();
54
+ return false;
55
+ });
56
+ };
57
+ })(BookReader.prototype.bindNavigationHandlers);
58
+
59
+ /**
60
+ * Starts autoplay mode
61
+ * @param {object} overrides
62
+ * @param {number} overrides.flipSpeed
63
+ * @param {number} overrides.flipDelay
64
+ */
65
+ BookReader.prototype.autoToggle = function(overrides) {
66
+ if (!this.options.enableAutoPlayPlugin) return;
67
+
68
+ const options = $.extend({
69
+ flipSpeed: this.flipSpeed,
70
+ flipDelay: this.flipDelay
71
+ }, overrides);
72
+
73
+ this.flipSpeed = typeof options.flipSpeed === "number" ? options.flipSpeed : this.flipSpeed;
74
+ this.flipDelay = typeof options.flipDelay === "number" ? options.flipDelay : this.flipDelay;
75
+ this.trigger(BookReader.eventNames.stop);
76
+
77
+ let bComingFrom1up = false;
78
+ if (this.constMode2up != this.mode) {
79
+ bComingFrom1up = true;
80
+ this.switchMode(this.constMode2up);
81
+ }
82
+
83
+ // Change to autofit if book is too large
84
+ if (this.reduce < this.twoPageGetAutofitReduce()) {
85
+ this.zoom('auto');
86
+ }
87
+
88
+ if (null == this.autoTimer) {
89
+ // $$$ Draw events currently cause layout problems when they occur during animation.
90
+ // There is a specific problem when changing from 1-up immediately to autoplay in RTL so
91
+ // we workaround for now by not triggering immediate animation in that case.
92
+ // See https://bugs.launchpad.net/gnubook/+bug/328327
93
+ if (('rl' == this.pageProgression) && bComingFrom1up) {
94
+ // don't flip immediately -- wait until timer fires
95
+ } else {
96
+ // flip immediately
97
+ this.flipFwdToIndex();
98
+ }
99
+
100
+ this.$('.play').hide();
101
+ this.$('.pause').show();
102
+ this.autoTimer = setInterval(() => {
103
+ if (this.animating) return;
104
+
105
+ if (Math.max(this.twoPage.currentIndexL, this.twoPage.currentIndexR) >= this.lastDisplayableIndex()) {
106
+ this.flipBackToIndex(1); // $$$ really what we want?
107
+ } else {
108
+ this.flipFwdToIndex();
109
+ }
110
+ }, this.flipDelay);
111
+ } else {
112
+ this.autoStop();
113
+ }
114
+ };
115
+
116
+ /**
117
+ * Stop autoplay mode, allowing animations to finish
118
+ */
119
+ BookReader.prototype.autoStop = function() {
120
+ if (!this.options.enableAutoPlayPlugin) return;
121
+
122
+ if (null != this.autoTimer) {
123
+ clearInterval(this.autoTimer);
124
+ this.flipSpeed = 'fast';
125
+ this.$('.pause').hide();
126
+ this.$('.play').show();
127
+ this.autoTimer = null;
128
+ }
129
+ };
@@ -0,0 +1,251 @@
1
+ /* global BookReader */
2
+ /**
3
+ * Plugin for chapter markers in BookReader. Fetches from openlibrary.org
4
+ * Could be forked, or extended to alter behavior
5
+ */
6
+
7
+ jQuery.extend(BookReader.defaultOptions, {
8
+ olHost: 'https://openlibrary.org',
9
+ enableChaptersPlugin: true,
10
+ bookId: '',
11
+ });
12
+
13
+ /** @override Extend the constructor to add search properties */
14
+ BookReader.prototype.setup = (function (super_) {
15
+ return function (options) {
16
+ super_.call(this, options);
17
+
18
+ this.olHost = options.olHost;
19
+ this.enableChaptersPlugin = options.enableChaptersPlugin;
20
+ this.bookId = options.bookId;
21
+ };
22
+ })(BookReader.prototype.setup);
23
+
24
+ /** @override Extend to call Open Library for TOC */
25
+ BookReader.prototype.init = (function(super_) {
26
+ return function() {
27
+ super_.call(this);
28
+ if (this.enableChaptersPlugin && this.ui !== 'embed') {
29
+ this.getOpenLibraryRecord();
30
+ }
31
+ if (this.enableMobileNav) {
32
+ this.bind(BookReader.eventNames.mobileNavOpen,
33
+ () => {
34
+ this.updateTOCState(this.firstIndex, this._tocEntries);
35
+ if ($('table-contents-list').parent().hasClass('mm-opened')) {
36
+ this.updateTOCState(this.firstIndex, this._tocEntries);
37
+ }
38
+ }
39
+ );
40
+ $(".BRmobileMenu__tableContents").click(
41
+ () => {
42
+ this.updateTOCState(this.firstIndex, this._tocEntries);
43
+ }
44
+ );
45
+ }
46
+ };
47
+ })(BookReader.prototype.init);
48
+
49
+ /**
50
+ * Adds chapter marker to navigation scrubber
51
+ *
52
+ * @param {string} chapterTitle
53
+ * @param {string} pageNumber
54
+ * @param {number} pageIndex
55
+ */
56
+ BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex) {
57
+ const uiStringPage = 'Page'; // i18n
58
+ const percentThrough = BookReader.util.cssPercentage(pageIndex, this.getNumLeafs() - 1);
59
+ const jumpToChapter = (event) => {
60
+ this.jumpToIndex($(event.delegateTarget).data('pageIndex'));
61
+ $('.current-chapter').removeClass('current-chapter');
62
+ $(event.delegateTarget).addClass('current-chapter');
63
+ };
64
+ const title = `${chapterTitle} | `;
65
+ const pageStr = `${uiStringPage} ${pageNumber}`;
66
+
67
+ //adding items to mobile table of contents
68
+ const mobileChapter = $(`<li></li>`).append($(`<span class='BRTOCElementTitle'></span>`).text(title))
69
+ .append($(`<span class='BRTOCElementPage'></span>`).text(pageStr));
70
+ mobileChapter.addClass('BRtable-contents-el')
71
+ .appendTo(this.$('.table-contents-list'))
72
+ .data({ pageIndex });
73
+
74
+ //adds .BRchapters to the slider only if pageIndex exists
75
+ if (pageIndex != undefined) {
76
+ $(`<div></div>`)
77
+ .append($('<div />').text(title + pageStr))
78
+ .addClass('BRchapter')
79
+ .css({ left: percentThrough })
80
+ .appendTo(this.$('.BRnavline'))
81
+ .data({ pageIndex })
82
+ .hover(event => {
83
+ // remove hover effect from other markers then turn on just for this
84
+ const marker = event.currentTarget;
85
+ const tooltip = marker.querySelector('div');
86
+ const tooltipOffset = tooltip.getBoundingClientRect();
87
+ const targetOffset = marker.getBoundingClientRect();
88
+ const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;
89
+ if (tooltipOffset.x - boxSizeAdjust < 0) {
90
+ tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);
91
+ }
92
+ this.$('.BRsearch,.BRchapter').removeClass('front');
93
+ $(event.target).addClass('front');
94
+ },
95
+ event => $(event.target).removeClass('front')
96
+ )
97
+ .on('click', jumpToChapter);
98
+
99
+ //adding clickable properties to mobile chapters
100
+ mobileChapter.bind('click', jumpToChapter)
101
+ .addClass('chapter-clickable')
102
+ .attr("data-event-click-tracking","BRTOCPanel|GoToChapter");
103
+ }
104
+
105
+ };
106
+
107
+ /*
108
+ * Remove all chapters.
109
+ */
110
+ BookReader.prototype.removeChapters = function() {
111
+ this.$('.BRnavpos .BRchapter').remove();
112
+ };
113
+
114
+ /**
115
+ * Update the table of contents based on array of TOC entries.
116
+ * @param {TocEntry[]} tocEntries
117
+ */
118
+ BookReader.prototype.updateTOC = function(tocEntries) {
119
+ this.removeChapters();
120
+ if (this.enableMobileNav && tocEntries.length > 0) {
121
+ this.$(".BRmobileMenu__tableContents").show();
122
+ }
123
+ for (let i = 0; i < tocEntries.length; i++) {
124
+ this.addChapterFromEntry(tocEntries[i]);
125
+ }
126
+ this._tocEntries = tocEntries;
127
+ $('.table-contents-list').children().each((i, el) => {
128
+ tocEntries[i].mobileHTML = el;
129
+ });
130
+ };
131
+
132
+ /**
133
+ * @typedef {Object} TocEntry
134
+ * Table of contents entry as defined -- format is defined by Open Library
135
+ * @property {string} pagenum
136
+ * @property {number} level
137
+ * @property {string} label
138
+ * @property {{type: '/type/toc_item'}} type
139
+ * @property {string} title
140
+ * @property {HTMLElement} mobileHTML
141
+ * @property {number} pageIndex
142
+
143
+ *
144
+ * @example {
145
+ * "pagenum": "17",
146
+ * "level": 1,
147
+ * "label": "CHAPTER I",
148
+ * "type": {"key": "/type/toc_item"},
149
+ * "title": "THE COUNTRY AND THE MISSION"
150
+ * }
151
+ */
152
+
153
+ /**
154
+ * @param {TocEntry} tocEntryObject
155
+ */
156
+ BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
157
+ tocEntryObject.pageIndex = this.getPageIndex(tocEntryObject['pagenum']);
158
+ //creates a string with non-void tocEntryObject.label and tocEntryObject.title
159
+ const chapterStr = [tocEntryObject.label, tocEntryObject.title]
160
+ .filter(x => x)
161
+ .join(' ');
162
+ this.addChapter(chapterStr, tocEntryObject['pagenum'], tocEntryObject.pageIndex);
163
+ this.$('.BRchapter, .BRsearch').each((i, el) => {
164
+ const $el = $(el);
165
+ $el.hover(
166
+ () => $el.addClass('front'),
167
+ () => $el.removeClass('front'));
168
+ });
169
+ };
170
+
171
+ /**
172
+ * getOpenLibraryRecord
173
+ *
174
+ * The bookreader is designed to call openlibrary API and constructs the
175
+ * "Return book" button using the response.
176
+ *
177
+ * This makes a call to OL API and calls the given callback function with the
178
+ * response from the API.
179
+ */
180
+ BookReader.prototype.getOpenLibraryRecord = function () {
181
+ // Try looking up by ocaid first, then by source_record
182
+ const baseURL = `${this.olHost}/query.json?type=/type/edition&*=`;
183
+ const fetchUrlByBookId = `${baseURL}&ocaid=${this.bookId}`;
184
+
185
+ /*
186
+ * Update Chapter markers based on received record from Open Library.
187
+ * Notes that Open Library record is used for extra metadata, and also for lending
188
+ */
189
+ const setUpChapterMarkers = (olObject) => {
190
+ if (olObject && olObject.table_of_contents) {
191
+ // XXX check here that TOC is valid
192
+ this.updateTOC(olObject.table_of_contents);
193
+ }
194
+ };
195
+
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
+ };
211
+
212
+ // Extend buildMobileDrawerElement with table of contents list
213
+ BookReader.prototype.buildMobileDrawerElement = (function (super_) {
214
+ return function () {
215
+ const $el = super_.call(this);
216
+ if (this.enableMobileNav && this.options.enableChaptersPlugin) {
217
+ $el.find('.BRmobileMenu__moreInfoRow').after($(`
218
+ <li class="BRmobileMenu__tableContents" data-event-click-tracking="BRSidebar|TOCPanel">
219
+ <span>
220
+ <span class="DrawerIconWrapper">
221
+ <img class="DrawerIcon" src="${this.imagesBaseURL}icon_toc.svg" alt="toc-icon"/>
222
+ </span>
223
+ Table of Contents
224
+ </span>
225
+ <div>
226
+ <ol class="table-contents-list">
227
+ </ol>
228
+ </div>
229
+ </li>`).hide());
230
+ }
231
+ return $el;
232
+ };
233
+ })(BookReader.prototype.buildMobileDrawerElement);
234
+
235
+ /**
236
+ * highlights the current chapter based on current page
237
+ * @private
238
+ * @param {TocEntry[]} tocEntries
239
+ * @param {number} tocEntries
240
+ */
241
+ BookReader.prototype.updateTOCState = function(currIndex, tocEntries) {
242
+ //this function won't have any effects if called before OpenLibrary request is finished
243
+ if (!tocEntries) {return;}
244
+ $('.current-chapter').removeClass('current-chapter');
245
+ const tocEntriesIndexed = tocEntries.filter((el) => el.pageIndex != undefined).reverse();
246
+ const currChapter = tocEntriesIndexed[tocEntriesIndexed.findIndex(
247
+ (el) => el.pageIndex <= currIndex)];
248
+ if (currChapter != undefined) {
249
+ $(currChapter.mobileHTML).addClass('current-chapter');
250
+ }
251
+ };
@@ -0,0 +1,48 @@
1
+ /* global BookReader */
2
+ /**
3
+ * Plugin for two-way communication between a BookReader in an IFrame and the
4
+ * parent web page
5
+ */
6
+
7
+ const MESSAGE_TYPE_FRAGMENT_CHANGE = 'bookReaderFragmentChange';
8
+
9
+ BookReader.prototype.init = (function (super_) {
10
+ return function () {
11
+ super_.call(this);
12
+ _attachEventListeners(this);
13
+ };
14
+ })(BookReader.prototype.init);
15
+
16
+ /**
17
+ * @private
18
+ * Using window.postMessage() and event listeners, the plugin notifies the
19
+ * parent window when pages change, and the parent window can also
20
+ * explicitly request a page change by sending its own message.
21
+ *
22
+ * @param {BookReader} br
23
+ * @param {Window?} [parent]
24
+ */
25
+ export function _attachEventListeners(br, parent = window.parent) {
26
+ // Not embedded, abort
27
+ if (!parent) {
28
+ return;
29
+ }
30
+
31
+ br.bind(BookReader.eventNames.fragmentChange, () => {
32
+ const fragment = br.fragmentFromParams(br.paramsFromCurrent());
33
+
34
+ parent.postMessage(
35
+ { type: MESSAGE_TYPE_FRAGMENT_CHANGE, fragment },
36
+ '*'
37
+ );
38
+ });
39
+
40
+ window.addEventListener('message', event => {
41
+ // Not a recognized message type, abort
42
+ if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
43
+ return;
44
+ }
45
+
46
+ br.updateFromParams(br.paramsFromFragment(event.data.fragment));
47
+ });
48
+ }