@internetarchive/bookreader 5.0.0-3 → 5.0.0-30-d
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +17 -5
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/node.js.yml +10 -1
- package/.husky/_/husky.sh +30 -0
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +75 -323
- package/BookReader/BookReader.js +32261 -2
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +15235 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/jquery-1.10.1.js +108 -2
- package/BookReader/plugins/plugin.archive_analytics.js +170 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +163 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +333 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +72 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +332 -1
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +241 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1261 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +839 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +9115 -2
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +811 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +326 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +412 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +14 -1
- package/BookReaderDemo/IADemoBr.js +107 -0
- package/BookReaderDemo/demo-advanced.html +1 -1
- package/BookReaderDemo/demo-autoplay.html +1 -0
- package/BookReaderDemo/demo-embed-iframe-src.html +1 -0
- package/BookReaderDemo/demo-fullscreen-mobile.html +1 -0
- package/BookReaderDemo/demo-fullscreen.html +1 -0
- package/BookReaderDemo/demo-iiif.html +1 -0
- package/BookReaderDemo/demo-internetarchive.html +66 -18
- package/BookReaderDemo/demo-multiple.html +1 -0
- package/BookReaderDemo/demo-preview-pages.html +1 -0
- package/BookReaderDemo/demo-simple.html +1 -0
- package/BookReaderDemo/demo-vendor-fullscreen.html +1 -0
- package/BookReaderDemo/immersion-1up.html +1 -0
- package/BookReaderDemo/immersion-mode.html +1 -0
- package/BookReaderDemo/toggle_controls.html +1 -0
- package/BookReaderDemo/view_mode.html +1 -0
- package/BookReaderDemo/viewmode-cycle.html +1 -2
- package/CHANGELOG.md +114 -0
- package/babel.config.js +18 -0
- package/index.html +3 -0
- package/jsconfig.json +19 -0
- package/package.json +45 -27
- package/src/BookNavigator/assets/button-base.js +8 -1
- package/src/BookNavigator/assets/ia-logo.js +17 -0
- package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
- package/src/BookNavigator/assets/icon_volumes.js +11 -0
- package/src/BookNavigator/book-navigator.js +528 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +2 -1
- package/src/BookNavigator/bookmarks/bookmark-edit.js +2 -1
- package/src/BookNavigator/bookmarks/bookmarks-list.js +1 -0
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +4 -9
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +32 -11
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +88 -43
- package/src/BookNavigator/downloads/downloads-provider.js +22 -16
- package/src/BookNavigator/downloads/downloads.js +16 -23
- package/src/BookNavigator/search/a-search-result.js +1 -0
- package/src/BookNavigator/search/search-provider.js +54 -20
- package/src/BookNavigator/search/search-results.js +7 -18
- package/src/BookNavigator/sharing.js +27 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +10 -12
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +1 -0
- package/src/BookNavigator/volumes/volumes-provider.js +114 -0
- package/src/BookNavigator/volumes/volumes.js +189 -0
- package/src/BookReader/DebugConsole.js +3 -3
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +50 -351
- package/src/BookReader/Mode1UpLit.js +434 -0
- package/src/BookReader/Mode2Up.js +94 -72
- package/src/BookReader/ModeSmoothZoom.js +177 -0
- package/src/BookReader/ModeThumb.js +16 -8
- package/src/BookReader/Navbar/Navbar.js +2 -31
- package/src/BookReader/PageContainer.js +47 -2
- package/src/BookReader/ReduceSet.js +1 -1
- package/src/BookReader/Toolbar/Toolbar.js +5 -5
- package/src/BookReader/options.js +10 -0
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils.js +68 -13
- package/src/BookReader.js +316 -232
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/voice.svg +1 -0
- package/src/css/BookReader.scss +0 -12
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +19 -24
- package/src/css/_BRnav.scss +4 -26
- package/src/css/_BRpages.scss +35 -0
- package/src/css/_BRsearch.scss +11 -215
- package/src/css/_TextSelection.scss +1 -17
- package/src/css/_controls.scss +16 -3
- package/src/css/_icons.scss +6 -0
- package/src/ia-bookreader/ia-bookreader.js +206 -0
- package/src/plugins/plugin.chapters.js +15 -18
- package/src/plugins/plugin.mobile_nav.js +11 -10
- package/src/plugins/plugin.resume.js +3 -3
- package/src/plugins/plugin.text_selection.js +17 -29
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +113 -104
- package/src/plugins/search/view.js +48 -163
- package/src/plugins/tts/AbstractTTSEngine.js +7 -0
- package/src/plugins/tts/FestivalTTSEngine.js +2 -2
- package/src/plugins/tts/WebTTSEngine.js +5 -0
- package/src/plugins/tts/plugin.tts.js +67 -102
- package/src/plugins/url/UrlPlugin.js +184 -0
- package/src/plugins/url/plugin.url.js +220 -0
- package/{src → stat}/BookNavigator/BookModel.js +0 -0
- package/{src → stat}/BookNavigator/BookNavigator.js +151 -104
- package/stat/BookNavigator/assets/bookmark-colors.js +15 -0
- package/stat/BookNavigator/assets/button-base.js +61 -0
- package/stat/BookNavigator/assets/ia-logo.js +17 -0
- package/stat/BookNavigator/assets/icon_checkmark.js +6 -0
- package/stat/BookNavigator/assets/icon_close.js +3 -0
- package/stat/BookNavigator/assets/icon_sort_asc.js +5 -0
- package/stat/BookNavigator/assets/icon_sort_desc.js +5 -0
- package/stat/BookNavigator/assets/icon_sort_neutral.js +5 -0
- package/stat/BookNavigator/assets/icon_volumes.js +11 -0
- package/stat/BookNavigator/bookmarks/bookmark-button.js +64 -0
- package/stat/BookNavigator/bookmarks/bookmark-edit.js +215 -0
- package/stat/BookNavigator/bookmarks/bookmarks-list.js +285 -0
- package/stat/BookNavigator/bookmarks/bookmarks-loginCTA.js +28 -0
- package/stat/BookNavigator/bookmarks/bookmarks-provider.js +56 -0
- package/stat/BookNavigator/bookmarks/ia-bookmarks.js +523 -0
- package/{src → stat}/BookNavigator/br-fullscreen-mgr.js +1 -2
- package/stat/BookNavigator/delete-modal-actions.js +49 -0
- package/stat/BookNavigator/downloads/downloads-provider.js +72 -0
- package/stat/BookNavigator/downloads/downloads.js +139 -0
- package/stat/BookNavigator/provider-config.js +0 -0
- package/stat/BookNavigator/search/a-search-result.js +55 -0
- package/stat/BookNavigator/search/search-provider.js +180 -0
- package/stat/BookNavigator/search/search-results.js +360 -0
- package/stat/BookNavigator/sharing.js +31 -0
- package/stat/BookNavigator/visual-adjustments/visual-adjustments-provider.js +94 -0
- package/stat/BookNavigator/visual-adjustments/visual-adjustments.js +280 -0
- package/stat/BookNavigator/volumes/volumes-provider.js +83 -0
- package/stat/BookNavigator/volumes/volumes.js +178 -0
- package/stat/BookReader/BookModel.js +518 -0
- package/stat/BookReader/DebugConsole.js +54 -0
- package/stat/BookReader/DragScrollable.js +233 -0
- package/stat/BookReader/ImageCache.js +116 -0
- package/stat/BookReader/Mode1Up.js +102 -0
- package/stat/BookReader/Mode1UpLit.js +434 -0
- package/stat/BookReader/Mode2Up.js +1372 -0
- package/stat/BookReader/ModeSmoothZoom.js +177 -0
- package/stat/BookReader/ModeThumb.js +344 -0
- package/stat/BookReader/Navbar/Navbar.js +310 -0
- package/stat/BookReader/PageContainer.js +120 -0
- package/stat/BookReader/ReduceSet.js +26 -0
- package/stat/BookReader/Toolbar/Toolbar.js +384 -0
- package/stat/BookReader/events.js +20 -0
- package/stat/BookReader/options.js +324 -0
- package/stat/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/stat/BookReader/utils/classes.js +36 -0
- package/stat/BookReader/utils.js +240 -0
- package/stat/BookReader.js +2550 -0
- package/{src → stat}/BookReaderComponent/BookReaderComponent.js +16 -11
- package/stat/assets/icons/1up.svg +12 -0
- package/stat/assets/icons/2up.svg +15 -0
- package/stat/assets/icons/advance.svg +26 -0
- package/stat/assets/icons/chevron-right.svg +1 -0
- package/stat/assets/icons/close-circle-dark.svg +1 -0
- package/stat/assets/icons/close-circle.svg +1 -0
- package/stat/assets/icons/fullscreen.svg +17 -0
- package/stat/assets/icons/fullscreen_exit.svg +17 -0
- package/stat/assets/icons/hamburger.svg +15 -0
- package/stat/assets/icons/left-arrow.svg +12 -0
- package/stat/assets/icons/magnify-minus.svg +16 -0
- package/stat/assets/icons/magnify-plus.svg +17 -0
- package/stat/assets/icons/magnify.svg +15 -0
- package/stat/assets/icons/pause.svg +23 -0
- package/stat/assets/icons/play.svg +22 -0
- package/stat/assets/icons/playback-speed.svg +34 -0
- package/stat/assets/icons/read-aloud.svg +22 -0
- package/stat/assets/icons/review.svg +22 -0
- package/stat/assets/icons/thumbnails.svg +17 -0
- package/stat/assets/icons/voice.svg +1 -0
- package/stat/assets/icons/volume-full.svg +22 -0
- package/stat/assets/images/BRicons.png +0 -0
- package/stat/assets/images/BRicons.svg +94 -0
- package/stat/assets/images/BRicons_ia.png +0 -0
- package/stat/assets/images/back_pages.png +0 -0
- package/stat/assets/images/book_bottom_icon.png +0 -0
- package/stat/assets/images/book_down_icon.png +0 -0
- package/stat/assets/images/book_left_icon.png +0 -0
- package/stat/assets/images/book_leftmost_icon.png +0 -0
- package/stat/assets/images/book_right_icon.png +0 -0
- package/stat/assets/images/book_rightmost_icon.png +0 -0
- package/stat/assets/images/book_top_icon.png +0 -0
- package/stat/assets/images/book_up_icon.png +0 -0
- package/stat/assets/images/books_graphic.svg +177 -0
- package/stat/assets/images/booksplit.png +0 -0
- package/stat/assets/images/control_pause_icon.png +0 -0
- package/stat/assets/images/control_play_icon.png +0 -0
- package/stat/assets/images/embed_icon.png +0 -0
- package/stat/assets/images/icon-home-ia.png +0 -0
- package/stat/assets/images/icon_OL-logo-xs.png +0 -0
- package/stat/assets/images/icon_alert-xs.png +0 -0
- package/stat/assets/images/icon_book.svg +12 -0
- package/stat/assets/images/icon_bookmark.svg +12 -0
- package/stat/assets/images/icon_close-pop.png +0 -0
- package/stat/assets/images/icon_download.png +0 -0
- package/stat/assets/images/icon_gear.svg +14 -0
- package/stat/assets/images/icon_hamburger.svg +20 -0
- package/stat/assets/images/icon_home.png +0 -0
- package/stat/assets/images/icon_home.svg +21 -0
- package/stat/assets/images/icon_home_ia.png +0 -0
- package/stat/assets/images/icon_indicator.png +0 -0
- package/stat/assets/images/icon_info.svg +11 -0
- package/stat/assets/images/icon_one_page.svg +8 -0
- package/stat/assets/images/icon_pause.svg +1 -0
- package/stat/assets/images/icon_play.svg +1 -0
- package/stat/assets/images/icon_playback-rate.svg +15 -0
- package/stat/assets/images/icon_return.png +0 -0
- package/stat/assets/images/icon_search_button.svg +8 -0
- package/stat/assets/images/icon_share.svg +9 -0
- package/stat/assets/images/icon_skip-ahead.svg +6 -0
- package/stat/assets/images/icon_skip-back.svg +13 -0
- package/stat/assets/images/icon_speaker.svg +18 -0
- package/stat/assets/images/icon_speaker_open.svg +10 -0
- package/stat/assets/images/icon_thumbnails.svg +12 -0
- package/stat/assets/images/icon_toc.svg +5 -0
- package/stat/assets/images/icon_two_pages.svg +9 -0
- package/stat/assets/images/icon_zoomer.png +0 -0
- package/stat/assets/images/loading.gif +0 -0
- package/stat/assets/images/logo_icon.png +0 -0
- package/stat/assets/images/marker_chap-off.png +0 -0
- package/stat/assets/images/marker_chap-off.svg +11 -0
- package/stat/assets/images/marker_chap-off_ia.png +0 -0
- package/stat/assets/images/marker_chap-on.png +0 -0
- package/stat/assets/images/marker_chap-on.svg +11 -0
- package/stat/assets/images/marker_srch-on.svg +11 -0
- package/stat/assets/images/marker_srchchap-off.png +0 -0
- package/stat/assets/images/marker_srchchap-on.png +0 -0
- package/stat/assets/images/nav_control-dn.png +0 -0
- package/stat/assets/images/nav_control-dn_ia.png +0 -0
- package/stat/assets/images/nav_control-up.png +0 -0
- package/stat/assets/images/nav_control-up_ia.png +0 -0
- package/stat/assets/images/nav_control.png +0 -0
- package/stat/assets/images/one_page_mode_icon.png +0 -0
- package/stat/assets/images/paper-badge.png +0 -0
- package/stat/assets/images/print_icon.png +0 -0
- package/stat/assets/images/progressbar.gif +0 -0
- package/stat/assets/images/right_edges.png +0 -0
- package/stat/assets/images/slider.png +0 -0
- package/stat/assets/images/slider_ia.png +0 -0
- package/stat/assets/images/thumbnail_mode_icon.png +0 -0
- package/stat/assets/images/transparent.png +0 -0
- package/stat/assets/images/two_page_mode_icon.png +0 -0
- package/stat/assets/images/zoom_in_icon.png +0 -0
- package/stat/assets/images/zoom_out_icon.png +0 -0
- package/stat/css/BookReader.scss +89 -0
- package/stat/css/_BRBookmarks.scss +29 -0
- package/stat/css/_BRComponent.scss +13 -0
- package/stat/css/_BRfloat.scss +197 -0
- package/stat/css/_BRicon.scss +48 -0
- package/stat/css/_BRmain.scss +251 -0
- package/stat/css/_BRnav.scss +359 -0
- package/stat/css/_BRpages.scss +139 -0
- package/stat/css/_BRsearch.scss +226 -0
- package/stat/css/_BRtoolbar.scss +84 -0
- package/stat/css/_BRvendor.scss +5 -0
- package/stat/css/_MobileNav.scss +194 -0
- package/stat/css/_TextSelection.scss +32 -0
- package/stat/css/_colorbox.scss +52 -0
- package/stat/css/_controls.scss +253 -0
- package/stat/css/_icons.scss +121 -0
- package/stat/jquery-wrapper.js +4 -0
- package/stat/plugins/plugin.archive_analytics.js +86 -0
- package/stat/plugins/plugin.autoplay.js +129 -0
- package/stat/plugins/plugin.chapters.js +248 -0
- package/stat/plugins/plugin.iframe.js +48 -0
- package/stat/plugins/plugin.mobile_nav.js +288 -0
- package/stat/plugins/plugin.resume.js +68 -0
- package/stat/plugins/plugin.text_selection.js +291 -0
- package/{src → stat}/plugins/plugin.url.js +4 -4
- package/stat/plugins/plugin.vendor-fullscreen.js +247 -0
- package/stat/plugins/search/plugin.search.js +439 -0
- package/stat/plugins/search/view.js +439 -0
- package/stat/plugins/tts/AbstractTTSEngine.js +249 -0
- package/stat/plugins/tts/FestivalTTSEngine.js +169 -0
- package/stat/plugins/tts/PageChunk.js +107 -0
- package/stat/plugins/tts/PageChunkIterator.js +163 -0
- package/stat/plugins/tts/WebTTSEngine.js +357 -0
- package/stat/plugins/tts/plugin.tts.js +357 -0
- package/stat/plugins/tts/tooltip_dict.js +15 -0
- package/stat/plugins/tts/utils.js +91 -0
- package/stat/util/browserSniffing.js +30 -0
- package/stat/util/debouncer.js +26 -0
- package/stat/util/docCookies.js +67 -0
- package/stat/util/strings.js +34 -0
- package/tests/e2e/README.md +37 -0
- package/tests/e2e/autoplay.test.js +2 -2
- package/tests/e2e/base.test.js +5 -7
- package/tests/e2e/helpers/base.js +8 -3
- package/tests/e2e/helpers/debug.js +1 -1
- package/tests/e2e/helpers/desktopSearch.js +1 -1
- package/tests/e2e/helpers/mobileSearch.js +3 -3
- package/tests/e2e/helpers/params.js +17 -0
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +30 -31
- package/tests/{BookReader → jest/BookReader}/BookModel.test.js +3 -3
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +176 -0
- package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +87 -0
- package/tests/{BookReader → jest/BookReader}/Mode2Up.test.js +5 -7
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +149 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +7 -7
- package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +74 -2
- package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
- package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
- package/tests/jest/BookReader/utils.test.js +136 -0
- package/tests/jest/BookReader.keyboard.test.js +190 -0
- package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
- package/tests/{BookReader.test.js → jest/BookReader.test.js} +20 -4
- package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +8 -8
- package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
- package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
- package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +14 -24
- package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
- package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +12 -5
- package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +6 -6
- package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +3 -3
- package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
- package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
- package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
- package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +1 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +3 -3
- package/tests/jest/plugins/url/UrlPlugin.test.js +175 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +33 -14
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/{util → jest/util}/docCookies.test.js +1 -1
- package/tests/{util → jest/util}/strings.test.js +1 -1
- package/tests/{utils.js → jest/utils.js} +38 -0
- package/tests/karma/BookNavigator/book-navigator.test.js +485 -0
- package/tests/karma/BookNavigator/bookmarks/bookmark-button.test.js +44 -0
- package/tests/karma/BookNavigator/bookmarks/bookmark-edit.test.js +1 -3
- package/tests/karma/BookNavigator/bookmarks/bookmarks-list.test.js +1 -2
- package/tests/karma/BookNavigator/downloads/downloads-provider.test.js +67 -0
- package/tests/karma/BookNavigator/downloads/downloads.test.js +54 -0
- package/tests/karma/BookNavigator/search/search-provider.test.js +123 -0
- package/tests/karma/BookNavigator/{search-results.test.js → search/search-results.test.js} +1 -4
- package/tests/karma/BookNavigator/sharing/sharing-provider.test.js +49 -0
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -2
- package/tests/karma/BookNavigator/volumes/volumes-provider.test.js +184 -0
- package/tests/karma/BookNavigator/volumes/volumes.test.js +98 -0
- package/webpack.config.js +11 -5
- package/.babelrc +0 -12
- package/.dependabot/config.yml +0 -6
- package/.testcaferc.json +0 -5
- package/BookReader/BookReader.js.LICENSE.txt +0 -72
- package/BookReader/bookreader-component-bundle.js +0 -1450
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -2
- package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +0 -27
- package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/ItemNavigator/ItemNavigator.js +0 -372
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/dragscrollable-br.js +0 -261
- package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
- package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
- package/tests/BookReader/Mode1Up.test.js +0 -164
- package/tests/BookReader/utils.test.js +0 -109
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
@@ -0,0 +1,190 @@
|
|
1
|
+
import BookReader from '@/src/BookReader.js';
|
2
|
+
import * as utils from '@/src/BookReader/utils.js';
|
3
|
+
|
4
|
+
let br;
|
5
|
+
beforeAll(() => {
|
6
|
+
document.body.innerHTML = '<div id="BookReader">';
|
7
|
+
br = new BookReader();
|
8
|
+
});
|
9
|
+
|
10
|
+
afterEach(() => {
|
11
|
+
jest.clearAllMocks();
|
12
|
+
});
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Only run init() once. Otherwise multiple EventListeners will be added.
|
16
|
+
*/
|
17
|
+
test('Initialzation enables IntersectionObserver and defaults', () => {
|
18
|
+
const observe = jest.fn();
|
19
|
+
window.IntersectionObserver = jest.fn(() => ({
|
20
|
+
observe
|
21
|
+
}));
|
22
|
+
br.init();
|
23
|
+
expect(br.hasKeyFocus).toBe(true);
|
24
|
+
expect(observe).toHaveBeenCalledTimes(1);
|
25
|
+
});
|
26
|
+
|
27
|
+
describe('Keyboard shortcuts turned off', () => {
|
28
|
+
|
29
|
+
test('Focus flag disables', () => {
|
30
|
+
br.next = jest.fn();
|
31
|
+
br.hasKeyFocus = false;
|
32
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowDown'});
|
33
|
+
keyEvent.preventDefault = jest.fn();
|
34
|
+
document.dispatchEvent(keyEvent);
|
35
|
+
expect(br.next).toHaveBeenCalledTimes(0);
|
36
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(0);
|
37
|
+
// Must reset for following tests
|
38
|
+
br.hasKeyFocus = true;
|
39
|
+
});
|
40
|
+
|
41
|
+
test('Input active disables', () => {
|
42
|
+
// eslint-disable-next-line no-import-assign
|
43
|
+
utils.isInputActive = jest.fn(() => true);
|
44
|
+
br.next = jest.fn();
|
45
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowDown'});
|
46
|
+
keyEvent.preventDefault = jest.fn();
|
47
|
+
document.dispatchEvent(keyEvent);
|
48
|
+
expect(br.next).toHaveBeenCalledTimes(0);
|
49
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(0);
|
50
|
+
// Must reset for following tests
|
51
|
+
utils.isInputActive.mockReset();
|
52
|
+
});
|
53
|
+
|
54
|
+
});
|
55
|
+
|
56
|
+
describe('Keyboard shortcuts', () => {
|
57
|
+
|
58
|
+
test('Home key', () => {
|
59
|
+
br.first = jest.fn();
|
60
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'Home'});
|
61
|
+
keyEvent.preventDefault = jest.fn();
|
62
|
+
document.dispatchEvent(keyEvent);
|
63
|
+
expect(br.first).toHaveBeenCalledTimes(1);
|
64
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
65
|
+
});
|
66
|
+
|
67
|
+
test('End key', () => {
|
68
|
+
br.last = jest.fn();
|
69
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'End'});
|
70
|
+
keyEvent.preventDefault = jest.fn();
|
71
|
+
document.dispatchEvent(keyEvent);
|
72
|
+
expect(br.last).toHaveBeenCalledTimes(1);
|
73
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
74
|
+
});
|
75
|
+
|
76
|
+
test('ArrowDown key', () => {
|
77
|
+
br.mode = br.constMode2up;
|
78
|
+
br.next = jest.fn();
|
79
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowDown'});
|
80
|
+
keyEvent.preventDefault = jest.fn();
|
81
|
+
document.dispatchEvent(keyEvent);
|
82
|
+
expect(br.next).toHaveBeenCalledTimes(1);
|
83
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
84
|
+
});
|
85
|
+
|
86
|
+
test('PageDown key', () => {
|
87
|
+
br.mode = br.constMode2up;
|
88
|
+
br.next = jest.fn();
|
89
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'PageDown'});
|
90
|
+
keyEvent.preventDefault = jest.fn();
|
91
|
+
document.dispatchEvent(keyEvent);
|
92
|
+
expect(br.next).toHaveBeenCalledTimes(1);
|
93
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
94
|
+
});
|
95
|
+
|
96
|
+
test('ArrowUp key', () => {
|
97
|
+
br.mode = br.constMode2up;
|
98
|
+
br.prev = jest.fn();
|
99
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowUp'});
|
100
|
+
keyEvent.preventDefault = jest.fn();
|
101
|
+
document.dispatchEvent(keyEvent);
|
102
|
+
expect(br.prev).toHaveBeenCalledTimes(1);
|
103
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
104
|
+
});
|
105
|
+
|
106
|
+
test('PageUp key', () => {
|
107
|
+
br.mode = br.constMode2up;
|
108
|
+
br.prev = jest.fn();
|
109
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'PageUp'});
|
110
|
+
keyEvent.preventDefault = jest.fn();
|
111
|
+
document.dispatchEvent(keyEvent);
|
112
|
+
expect(br.prev).toHaveBeenCalledTimes(1);
|
113
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
114
|
+
});
|
115
|
+
|
116
|
+
test('ArrowLeft key', () => {
|
117
|
+
br.mode = br.constMode2up;
|
118
|
+
br.left = jest.fn();
|
119
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowLeft'});
|
120
|
+
keyEvent.preventDefault = jest.fn();
|
121
|
+
document.dispatchEvent(keyEvent);
|
122
|
+
expect(br.left).toHaveBeenCalledTimes(1);
|
123
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
124
|
+
});
|
125
|
+
|
126
|
+
test('ArrowRight key', () => {
|
127
|
+
br.mode = br.constMode2up;
|
128
|
+
br.right = jest.fn();
|
129
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'ArrowRight'});
|
130
|
+
keyEvent.preventDefault = jest.fn();
|
131
|
+
document.dispatchEvent(keyEvent);
|
132
|
+
expect(br.right).toHaveBeenCalledTimes(1);
|
133
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
134
|
+
});
|
135
|
+
|
136
|
+
test('Subtract key', () => {
|
137
|
+
br.zoom = jest.fn();
|
138
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'Subtract'});
|
139
|
+
keyEvent.preventDefault = jest.fn();
|
140
|
+
document.dispatchEvent(keyEvent);
|
141
|
+
expect(br.zoom).toHaveBeenCalledTimes(1);
|
142
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
143
|
+
});
|
144
|
+
|
145
|
+
test('- key', () => {
|
146
|
+
br.zoom = jest.fn();
|
147
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': '-'});
|
148
|
+
keyEvent.preventDefault = jest.fn();
|
149
|
+
document.dispatchEvent(keyEvent);
|
150
|
+
expect(br.zoom).toHaveBeenCalledTimes(1);
|
151
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
152
|
+
});
|
153
|
+
|
154
|
+
test('Add key', () => {
|
155
|
+
br.zoom = jest.fn();
|
156
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'Add'});
|
157
|
+
keyEvent.preventDefault = jest.fn();
|
158
|
+
document.dispatchEvent(keyEvent);
|
159
|
+
expect(br.zoom).toHaveBeenCalledTimes(1);
|
160
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
161
|
+
});
|
162
|
+
|
163
|
+
test('+ key', () => {
|
164
|
+
br.zoom = jest.fn();
|
165
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': '+'});
|
166
|
+
keyEvent.preventDefault = jest.fn();
|
167
|
+
document.dispatchEvent(keyEvent);
|
168
|
+
expect(br.zoom).toHaveBeenCalledTimes(1);
|
169
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
170
|
+
});
|
171
|
+
|
172
|
+
test('= key', () => {
|
173
|
+
br.zoom = jest.fn();
|
174
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': '='});
|
175
|
+
keyEvent.preventDefault = jest.fn();
|
176
|
+
document.dispatchEvent(keyEvent);
|
177
|
+
expect(br.zoom).toHaveBeenCalledTimes(1);
|
178
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
179
|
+
});
|
180
|
+
|
181
|
+
test('F key', () => {
|
182
|
+
br.toggleFullscreen = jest.fn();
|
183
|
+
const keyEvent = new KeyboardEvent('keydown', {'key': 'F'});
|
184
|
+
keyEvent.preventDefault = jest.fn();
|
185
|
+
document.dispatchEvent(keyEvent);
|
186
|
+
expect(br.toggleFullscreen).toHaveBeenCalledTimes(1);
|
187
|
+
expect(keyEvent.preventDefault).toHaveBeenCalledTimes(1);
|
188
|
+
});
|
189
|
+
|
190
|
+
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
import BookReader from '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
3
|
|
4
4
|
beforeAll(() => {
|
5
5
|
document.body.innerHTML = '<div id="BookReader">';
|
@@ -36,4 +36,12 @@ describe('BookReader options', () => {
|
|
36
36
|
expect(br.options.autoResize).toBe(true);
|
37
37
|
});
|
38
38
|
});
|
39
|
+
|
40
|
+
describe('`showNavbar`', () => {
|
41
|
+
it('is on by default', () => {
|
42
|
+
const br = new BookReader();
|
43
|
+
br.init();
|
44
|
+
expect(br.options.showNavbar).toBe(true);
|
45
|
+
});
|
46
|
+
});
|
39
47
|
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
-
import BookReader from '
|
3
|
-
import '
|
4
|
-
import '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
|
+
import '@/src/plugins/plugin.resume.js';
|
4
|
+
import '@/src/plugins/url/plugin.url.js';
|
5
5
|
|
6
6
|
let br;
|
7
7
|
beforeAll(() => {
|
@@ -124,7 +124,7 @@ test('has suppressFragmentChange false when init with fragment', () => {
|
|
124
124
|
test('has suppressFragmentChange false when init with hash fragment', () => {
|
125
125
|
br.getResumeValue = jest.fn(() => null);
|
126
126
|
br.urlReadFragment = jest.fn(() => '');
|
127
|
-
br.urlReadHashFragment = jest.fn(() => 'mode/1up')
|
127
|
+
br.urlReadHashFragment = jest.fn(() => 'mode/1up');
|
128
128
|
br.switchMode = jest.fn();
|
129
129
|
br.options.urlMode = 'history',
|
130
130
|
|
@@ -192,6 +192,22 @@ test('_getPageURISrcset with the most elements in srcset', () => {
|
|
192
192
|
expect(br._getPageURISrcset(5, 35, undefined)).toBe("correctURL.png&scale=16 2x, correctURL.png&scale=8 4x, correctURL.png&scale=4 8x, correctURL.png&scale=2 16x, correctURL.png&scale=1 32x");
|
193
193
|
});
|
194
194
|
|
195
|
+
describe('Navigation Bars', () => {
|
196
|
+
test('Standard navigation is being used by default', () => {
|
197
|
+
br.initNavbar = jest.fn();
|
198
|
+
br.options.ui = '';
|
199
|
+
br.init();
|
200
|
+
expect(br.initNavbar).toHaveBeenCalledTimes(1);
|
201
|
+
});
|
202
|
+
test('Standard navigation is being used by default - when bookreader is embedded', () => {
|
203
|
+
br.initNavbar = jest.fn();
|
204
|
+
br.options.ui = 'embed';
|
205
|
+
br.init();
|
206
|
+
expect(br.initNavbar).toHaveBeenCalledTimes(1);
|
207
|
+
expect(br.options.ui).toEqual('embed');
|
208
|
+
});
|
209
|
+
});
|
210
|
+
|
195
211
|
describe('quantizeReduce', () => {
|
196
212
|
const quantizeReduce = BookReader.prototype.quantizeReduce;
|
197
213
|
const SAMPLE_FACTORS = [
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
|
-
import BookReader from '
|
3
|
-
import '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
|
+
import '@/src/plugins/plugin.archive_analytics.js';
|
4
4
|
|
5
5
|
describe('archiveAnalyticsSendEvent', () => {
|
6
6
|
const sendEvent = BookReader.prototype.archiveAnalyticsSendEvent;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
2
|
|
3
|
-
import BookReader from '
|
4
|
-
import '
|
5
|
-
import '
|
3
|
+
import BookReader from '@/src/BookReader.js';
|
4
|
+
import '@/src/plugins/plugin.mobile_nav.js';
|
5
|
+
import '@/src/plugins/plugin.chapters.js';
|
6
6
|
|
7
7
|
const SAMPLE_TOC = [{
|
8
8
|
"pagenum": "3",
|
@@ -53,7 +53,7 @@ const SAMPLE_TOC_UNDEF = [
|
|
53
53
|
"title": "THE COUNTRY AND THE MISSION 2",
|
54
54
|
"pageIndex": undefined,
|
55
55
|
}
|
56
|
-
]
|
56
|
+
];
|
57
57
|
|
58
58
|
let br;
|
59
59
|
beforeEach(() => {
|
@@ -111,20 +111,20 @@ describe('updateTOCState', () => {
|
|
111
111
|
test('Only one element has .current-chapter', () => {
|
112
112
|
br.updateTOCState(9, SAMPLE_TOC);
|
113
113
|
expect($('li.BRtable-contents-el.current-chapter').length).toBe(1);
|
114
|
-
})
|
114
|
+
});
|
115
115
|
|
116
116
|
test('No chapter has .current-chapter if current index is < than any chapter index', () => {
|
117
117
|
br.updateTOCState(1, SAMPLE_TOC);
|
118
118
|
expect($('li.BRtable-contents-el.current-chapter').length).toBe(0);
|
119
|
-
})
|
119
|
+
});
|
120
120
|
|
121
121
|
test('if current index == chapter index ', () => {
|
122
122
|
br.updateTOCState(17, SAMPLE_TOC);
|
123
123
|
expect($('li.BRtable-contents-el')[1].classList.contains('current-chapter'));
|
124
|
-
})
|
124
|
+
});
|
125
125
|
|
126
126
|
test('No chapter has .current-chapter if all chapter have undefined pageIndex ', () => {
|
127
127
|
br.updateTOCState(10, SAMPLE_TOC_UNDEF);
|
128
128
|
expect($('li.BRtable-contents-el.current-chapter').length).toBe(0);
|
129
|
-
})
|
129
|
+
});
|
130
130
|
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
2
|
|
3
|
-
import BookReader from '
|
4
|
-
import { _attachEventListeners } from '
|
3
|
+
import BookReader from '@/src/BookReader.js';
|
4
|
+
import { _attachEventListeners } from '@/src/plugins/plugin.iframe.js';
|
5
5
|
|
6
6
|
afterEach(() => {
|
7
7
|
sinon.restore();
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
|
-
import BookReader from '
|
3
|
-
import '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
|
+
import '@/src/plugins/plugin.mobile_nav.js';
|
4
4
|
|
5
5
|
/** @type {BookReader} */
|
6
6
|
let br;
|
@@ -37,7 +37,7 @@ describe('Plugin: Mobile Nav', () => {
|
|
37
37
|
return function() {
|
38
38
|
callCount++;
|
39
39
|
_super.apply(this, arguments);
|
40
|
-
}
|
40
|
+
};
|
41
41
|
}(BookReader.prototype.initToolbar);
|
42
42
|
const br = new BookReader();
|
43
43
|
br.init();
|
@@ -47,7 +47,7 @@ describe('Plugin: Mobile Nav', () => {
|
|
47
47
|
expect($(document.body).hasClass('BRbodyMobileNavEnabled')).toEqual(true);
|
48
48
|
});
|
49
49
|
test('loads the navbar on init', () => {
|
50
|
-
expect($('#BRmobileMenu')).toHaveLength(1)
|
50
|
+
expect($('#BRmobileMenu')).toHaveLength(1);
|
51
51
|
});
|
52
52
|
test('There is a Settings Section', () => {
|
53
53
|
expect($('.BRmobileMenu__settings')).toHaveLength(1);
|
@@ -60,7 +60,7 @@ describe('Plugin: Mobile Nav', () => {
|
|
60
60
|
});
|
61
61
|
test('clicking on hamburger opens menu', () => {
|
62
62
|
expect($('html').hasClass('mm-opened')).toEqual(false);
|
63
|
-
$('.BRmobileHamburger').click
|
63
|
+
$('.BRmobileHamburger').trigger("click");
|
64
64
|
expect($('html').hasClass('mm-opened')).toEqual(true);
|
65
65
|
});
|
66
66
|
});
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import BookReader from '
|
2
|
-
import '
|
1
|
+
import BookReader from '@/src/BookReader.js';
|
2
|
+
import '@/src/plugins/plugin.resume.js';
|
3
3
|
|
4
4
|
import sinon from 'sinon';
|
5
|
-
import * as docCookies from '
|
5
|
+
import * as docCookies from '@/src/util/docCookies.js';
|
6
6
|
|
7
7
|
let br;
|
8
8
|
beforeAll(() => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
2
|
|
3
|
-
import '
|
4
|
-
import { BookreaderWithTextSelection, TextSelectionPlugin, Cache } from '
|
3
|
+
import '@/src/BookReader.js';
|
4
|
+
import { BookreaderWithTextSelection, TextSelectionPlugin, Cache } from '@/src/plugins/plugin.text_selection.js';
|
5
5
|
|
6
6
|
|
7
7
|
/** @type {BookReader} */
|
@@ -72,8 +72,8 @@ describe("Generic tests", () => {
|
|
72
72
|
const $container = br.refs.$brContainer;
|
73
73
|
sinon.stub(br.textSelectionPlugin, "getPageText")
|
74
74
|
.returns($(new DOMParser().parseFromString(FAKE_XML_1WORD, "text/xml")));
|
75
|
-
const pageIndex = br.data.length - 1
|
76
|
-
await br.textSelectionPlugin.createTextLayer(pageIndex,
|
75
|
+
const pageIndex = br.data.length - 1;
|
76
|
+
await br.textSelectionPlugin.createTextLayer({ $container, page: { index: pageIndex, width: 100, height: 100 }});
|
77
77
|
expect($container.find(".textSelectionSVG").length).toBe(1);
|
78
78
|
expect($container.find(".BRparagElement").length).toBe(1);
|
79
79
|
});
|
@@ -83,17 +83,7 @@ describe("Generic tests", () => {
|
|
83
83
|
const xml = FAKE_XML_1WORD.replace(/<WORD.*<\/WORD>/, FAKE_XML_1WORD.match(/<WORD.*<\/WORD>/)[0].repeat(3000));
|
84
84
|
sinon.stub(br.textSelectionPlugin, "getPageText")
|
85
85
|
.returns($(new DOMParser().parseFromString(xml, "text/xml")));
|
86
|
-
await br.textSelectionPlugin.createTextLayer(0,
|
87
|
-
expect($container.find(".textSelectionSVG").length).toBe(0);
|
88
|
-
expect($container.find(".BRparagElement").length).toBe(0);
|
89
|
-
expect($container.find(".BRwordElement").length).toBe(0);
|
90
|
-
});
|
91
|
-
|
92
|
-
// GRRRR!!! This is a useful test :( But can't get it working for some reason,
|
93
|
-
// and the error output is super cryptic.
|
94
|
-
test.skip("createTextLayer will not create text layer if index is more than total number of book pages", async () => {
|
95
|
-
const $container = br.refs.$brContainer;
|
96
|
-
await br.textSelectionPlugin.createTextLayer(150, $container);
|
86
|
+
await br.textSelectionPlugin.createTextLayer({ $container, page: { index: 0, width: 100, height: 100 }});
|
97
87
|
expect($container.find(".textSelectionSVG").length).toBe(0);
|
98
88
|
expect($container.find(".BRparagElement").length).toBe(0);
|
99
89
|
expect($container.find(".BRwordElement").length).toBe(0);
|
@@ -103,7 +93,7 @@ describe("Generic tests", () => {
|
|
103
93
|
const $container = br.refs.$brContainer;
|
104
94
|
sinon.stub(br.textSelectionPlugin, "getPageText")
|
105
95
|
.returns($(new DOMParser().parseFromString(FAKE_XML_1WORD, "text/xml")));
|
106
|
-
await br.textSelectionPlugin.createTextLayer(1,
|
96
|
+
await br.textSelectionPlugin.createTextLayer({ $container, page: { index: 1, width: 100, height: 100 }});
|
107
97
|
expect($container.find(".textSelectionSVG").length).toBe(1);
|
108
98
|
expect($container.find(".BRparagElement").length).toBe(1);
|
109
99
|
expect($container.find(".BRwordElement").length).toBe(1);
|
@@ -114,7 +104,7 @@ describe("Generic tests", () => {
|
|
114
104
|
const $container = br.refs.$brContainer;
|
115
105
|
sinon.stub(br.textSelectionPlugin, "getPageText")
|
116
106
|
.returns($(new DOMParser().parseFromString(FAKE_XML_MULT_WORDS, "text/xml")));
|
117
|
-
await br.textSelectionPlugin.createTextLayer(2,
|
107
|
+
await br.textSelectionPlugin.createTextLayer({ $container, page: { index: 2, width: 100, height: 100 }});
|
118
108
|
expect($container.find(".textSelectionSVG").length).toBe(1);
|
119
109
|
expect($container.find(".BRparagElement").length).toBe(1);
|
120
110
|
expect($container.find(".BRwordElement").length).toBe(5);
|
@@ -125,7 +115,7 @@ describe("Generic tests", () => {
|
|
125
115
|
const $container = br.refs.$brContainer;
|
126
116
|
sinon.stub(br.textSelectionPlugin, "getPageText")
|
127
117
|
.returns($(new DOMParser().parseFromString(FAKE_XML_5COORDS, "text/xml")));
|
128
|
-
await br.textSelectionPlugin.createTextLayer(3,
|
118
|
+
await br.textSelectionPlugin.createTextLayer({ $container, page: { index: 3, width: 100, height: 100 }});
|
129
119
|
expect($container.find(".textSelectionSVG").length).toBe(1);
|
130
120
|
expect($container.find(".BRparagElement").length).toBe(1);
|
131
121
|
expect($container.find(".BRwordElement").length).toBe(1);
|
@@ -135,7 +125,7 @@ describe("Generic tests", () => {
|
|
135
125
|
const $container = br.refs.$brContainer;
|
136
126
|
sinon.stub(br.textSelectionPlugin, "getPageText")
|
137
127
|
.returns($(new DOMParser().parseFromString(FAKE_XML_EMPTY, "text/xml")));
|
138
|
-
await br.textSelectionPlugin.createTextLayer(4,
|
128
|
+
await br.textSelectionPlugin.createTextLayer({ $container, page: { index: 4, width: 100, height: 100 }});
|
139
129
|
expect($container.find(".textSelectionSVG").length).toBe(1);
|
140
130
|
expect($container.find(".BRparagElement").length).toBe(0);
|
141
131
|
expect($container.find(".BRwordElement").length).toBe(0);
|
@@ -146,28 +136,28 @@ describe("Generic tests", () => {
|
|
146
136
|
const $container = br.refs.$brContainer;
|
147
137
|
br.textSelectionPlugin.stopPageFlip($container);
|
148
138
|
const currIndex = br.currentIndex();
|
149
|
-
$container.find("BRwordElement").mousedown
|
139
|
+
$container.find("BRwordElement").trigger("mousedown");
|
150
140
|
// Waits for long press
|
151
141
|
setTimeout(() => {
|
152
|
-
$container.find("BRwordElement").mousedown
|
142
|
+
$container.find("BRwordElement").trigger("mousedown");
|
153
143
|
// Waits for flipping animation
|
154
144
|
setTimeout(() => {
|
155
145
|
expect(br.currentIndex()).toBe(currIndex);
|
156
146
|
}, 2000);
|
157
147
|
}, LONG_PRESS_DURATION);
|
158
148
|
});
|
159
|
-
})
|
149
|
+
});
|
160
150
|
|
161
151
|
describe("textSelectionPlugin constructor", () => {
|
162
152
|
test("textSelectionPlugin constructor with firefox browser", () => {
|
163
|
-
const tsp = new TextSelectionPlugin({}, {}, true)
|
153
|
+
const tsp = new TextSelectionPlugin({}, {}, true);
|
164
154
|
expect(tsp.djvuPagesPromise).toBe(null);
|
165
155
|
expect(tsp.svgParagraphElement).toBe("g");
|
166
156
|
expect(tsp.svgWordElement).toBe("text");
|
167
157
|
});
|
168
158
|
|
169
159
|
test("textSelectionPlugin constructor not on firefox browser", () => {
|
170
|
-
const tsp = new TextSelectionPlugin({}, {}, false)
|
160
|
+
const tsp = new TextSelectionPlugin({}, {}, false);
|
171
161
|
expect(tsp.djvuPagesPromise).toBe(null);
|
172
162
|
expect(tsp.svgParagraphElement).toBe("text");
|
173
163
|
expect(tsp.svgWordElement).toBe("tspan");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
|
-
import BookReader from '
|
3
|
-
import * as util from '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
|
+
import * as util from '@/src/plugins/plugin.vendor-fullscreen.js';
|
4
4
|
|
5
5
|
let br;
|
6
6
|
beforeEach(() => {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
import BookReader from '
|
3
|
-
import '
|
4
|
-
import '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
|
+
import '@/src/plugins/plugin.mobile_nav.js';
|
4
|
+
import '@/src/plugins/search/plugin.search.js';
|
5
5
|
|
6
|
-
jest.mock('
|
6
|
+
jest.mock('@/src/plugins/search/view.js');
|
7
7
|
|
8
8
|
let br;
|
9
9
|
const namespace = 'BookReader:';
|
@@ -46,6 +46,7 @@ beforeEach(() => {
|
|
46
46
|
br = new BookReader();
|
47
47
|
br.initToolbar = jest.fn();
|
48
48
|
br.showProgressPopup = jest.fn();
|
49
|
+
br.searchXHR = jest.fn();
|
49
50
|
});
|
50
51
|
|
51
52
|
afterEach(() => {
|
@@ -101,7 +102,7 @@ describe('Plugin: Search', () => {
|
|
101
102
|
expect(br.search.mock.calls[0][1])
|
102
103
|
.toHaveProperty('goToFirstResult', true);
|
103
104
|
expect(br.search.mock.calls[0][1])
|
104
|
-
.toHaveProperty('suppressFragmentChange',
|
105
|
+
.toHaveProperty('suppressFragmentChange', false);
|
105
106
|
});
|
106
107
|
|
107
108
|
test('calling `search` fires ajax call`', () => {
|
@@ -116,6 +117,12 @@ describe('Plugin: Search', () => {
|
|
116
117
|
expect(triggeredEvents()).toContain(`${namespace}SearchStarted`);
|
117
118
|
});
|
118
119
|
|
120
|
+
test('SearchStarted event fires and should go to first result', () => {
|
121
|
+
br.init();
|
122
|
+
br.search('foo', { goToFirstResult: true});
|
123
|
+
expect(br.options.goToFirstResult).toBeTruthy();
|
124
|
+
});
|
125
|
+
|
119
126
|
test('SearchCallback event fires when AJAX search returns results', () => {
|
120
127
|
br.init();
|
121
128
|
const dfd = br.search('foo');
|
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
|
-
import BookReader from '
|
3
|
-
import '
|
4
|
-
import '
|
5
|
-
import '
|
2
|
+
import BookReader from '@/src/BookReader.js';
|
3
|
+
import '@/src/plugins/plugin.mobile_nav.js';
|
4
|
+
import '@/src/plugins/search/plugin.search.js';
|
5
|
+
import '@/src/plugins/search/view.js';
|
6
6
|
|
7
7
|
let br;
|
8
8
|
const namespace = 'BookReader:';
|
@@ -63,14 +63,14 @@ describe('View: Plugin: Search', () => {
|
|
63
63
|
|
64
64
|
expect(br.searchView.dom.searchNavigation).toBeUndefined();
|
65
65
|
|
66
|
-
br.searchView.handleSearchCallback(event, { results, options})
|
66
|
+
br.searchView.handleSearchCallback(event, { results, options});
|
67
67
|
expect(br.searchView.dom.searchNavigation).toBeDefined();
|
68
68
|
});
|
69
69
|
test('has controls', () => {
|
70
70
|
br.init();
|
71
71
|
const event = new CustomEvent(`${namespace}SearchCallback`);
|
72
72
|
const options = { goToFirstResult: false };
|
73
|
-
br.searchView.handleSearchCallback(event, { results, options})
|
73
|
+
br.searchView.handleSearchCallback(event, { results, options});
|
74
74
|
|
75
75
|
const searchResultsNav = document.querySelector('.BRsearch-navigation');
|
76
76
|
expect(searchResultsNav).toBeDefined();
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
2
|
import { afterEventLoop } from '../../utils.js';
|
3
|
-
import AbstractTTSEngine from '
|
4
|
-
import PageChunkIterator from '
|
5
|
-
/** @typedef {import('
|
3
|
+
import AbstractTTSEngine from '@/src/plugins/tts/AbstractTTSEngine.js';
|
4
|
+
import PageChunkIterator from '@/src/plugins/tts/PageChunkIterator.js';
|
5
|
+
/** @typedef {import('@/src/plugins/tts/AbstractTTSEngine.js').TTSEngineOptions} TTSEngineOptions */
|
6
6
|
|
7
7
|
// Skipping because it's flaky. Fix in #672
|
8
8
|
describe.skip('AbstractTTSEngine', () => {
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import FestivalTTSEngine from '
|
1
|
+
import FestivalTTSEngine from '@/src/plugins/tts/FestivalTTSEngine.js';
|
2
2
|
import sinon from 'sinon';
|
3
3
|
import { afterEventLoop } from '../../utils.js';
|
4
4
|
import { DUMMY_TTS_ENGINE_OPTS } from './AbstractTTSEngine.test.js';
|
5
|
-
import PageChunk from '
|
6
|
-
import PageChunkIterator from '
|
7
|
-
/** @typedef {import('
|
5
|
+
import PageChunk from '@/src/plugins/tts/PageChunk.js';
|
6
|
+
import PageChunkIterator from '@/src/plugins/tts/PageChunkIterator.js';
|
7
|
+
/** @typedef {import('@/src/plugins/tts/AbstractTTSEngine.js').TTSEngineOptions} TTSEngineOptions */
|
8
8
|
|
9
9
|
describe('iOSCaptureUserIntentHack', () => {
|
10
10
|
test('synchronously calls createSound/play to capture user intent', () => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
|
-
import PageChunkIterator from "
|
3
|
-
import PageChunk from '
|
2
|
+
import PageChunkIterator from "@/src/plugins/tts/PageChunkIterator";
|
3
|
+
import PageChunk from '@/src/plugins/tts/PageChunk';
|
4
4
|
|
5
5
|
describe('Buffers pages', () => {
|
6
6
|
test('Does not error if no room for reverse buffer', async () => {
|
@@ -109,7 +109,7 @@ describe('Iterates pages', () => {
|
|
109
109
|
expect(iterator._cursor.chunk).toBe(0);
|
110
110
|
|
111
111
|
for (let i = 2; i >= 0; i--) {
|
112
|
-
await iterator.decrement()
|
112
|
+
await iterator.decrement();
|
113
113
|
expect(iterator._cursor.page).toBe(49);
|
114
114
|
expect(iterator._cursor.chunk).toBe(i);
|
115
115
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import sinon from 'sinon';
|
2
2
|
import { afterEventLoop, eventTargetMixin } from '../../utils.js';
|
3
|
-
import * as utils from '
|
3
|
+
import * as utils from '@/src/plugins/tts/utils.js';
|
4
4
|
|
5
5
|
describe('promisifyEvent', () => {
|
6
6
|
const { promisifyEvent } = utils;
|
@@ -10,7 +10,7 @@ describe('promisifyEvent', () => {
|
|
10
10
|
const resolveSpy = sinon.spy();
|
11
11
|
promisifyEvent(fakeTarget, 'pause').then(resolveSpy);
|
12
12
|
|
13
|
-
await afterEventLoop()
|
13
|
+
await afterEventLoop();
|
14
14
|
expect(resolveSpy.callCount).toBe(0);
|
15
15
|
fakeTarget.dispatchEvent('pause', {});
|
16
16
|
await afterEventLoop();
|
@@ -22,7 +22,7 @@ describe('promisifyEvent', () => {
|
|
22
22
|
const resolveSpy = sinon.spy();
|
23
23
|
promisifyEvent(fakeTarget, 'pause').then(resolveSpy);
|
24
24
|
|
25
|
-
await afterEventLoop()
|
25
|
+
await afterEventLoop();
|
26
26
|
expect(resolveSpy.callCount).toBe(0);
|
27
27
|
fakeTarget.dispatchEvent('pause', {});
|
28
28
|
fakeTarget.dispatchEvent('pause', {});
|