@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.
- package/.eslintrc.js +58 -0
- package/.gitattributes +2 -0
- package/.github/ISSUE_TEMPLATE/bug.md +32 -0
- package/.github/ISSUE_TEMPLATE/feature-request.md +30 -0
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +15 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/node.js.yml +37 -0
- package/.github/workflows/npm-publish.yml +47 -0
- package/.testcaferc.json +5 -0
- package/BookReader/BookReader.css +2983 -0
- package/BookReader/BookReader.js +3 -0
- package/BookReader/BookReader.js.LICENSE.txt +117 -0
- package/BookReader/BookReader.js.map +1 -0
- package/BookReader/bookreader-component-bundle.js +1436 -0
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +27 -0
- package/BookReader/bookreader-component-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -0
- package/BookReader/icons/2up.svg +1 -0
- package/BookReader/icons/advance.svg +3 -0
- package/BookReader/icons/chevron-right.svg +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/close-circle.svg +1 -0
- package/BookReader/icons/fullscreen.svg +1 -0
- package/BookReader/icons/fullscreen_exit.svg +1 -0
- package/BookReader/icons/hamburger.svg +1 -0
- package/BookReader/icons/left-arrow.svg +1 -0
- package/BookReader/icons/magnify-minus.svg +1 -0
- package/BookReader/icons/magnify-plus.svg +1 -0
- package/BookReader/icons/magnify.svg +1 -0
- package/BookReader/icons/pause.svg +1 -0
- package/BookReader/icons/play.svg +1 -0
- package/BookReader/icons/playback-speed.svg +1 -0
- package/BookReader/icons/read-aloud.svg +1 -0
- package/BookReader/icons/review.svg +3 -0
- package/BookReader/icons/thumbnails.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -0
- package/BookReader/images/BRicons.png +0 -0
- package/BookReader/images/BRicons.svg +5 -0
- package/BookReader/images/BRicons_ia.png +0 -0
- package/BookReader/images/back_pages.png +0 -0
- package/BookReader/images/book_bottom_icon.png +0 -0
- package/BookReader/images/book_down_icon.png +0 -0
- package/BookReader/images/book_left_icon.png +0 -0
- package/BookReader/images/book_leftmost_icon.png +0 -0
- package/BookReader/images/book_right_icon.png +0 -0
- package/BookReader/images/book_rightmost_icon.png +0 -0
- package/BookReader/images/book_top_icon.png +0 -0
- package/BookReader/images/book_up_icon.png +0 -0
- package/BookReader/images/books_graphic.svg +1 -0
- package/BookReader/images/booksplit.png +0 -0
- package/BookReader/images/control_pause_icon.png +0 -0
- package/BookReader/images/control_play_icon.png +0 -0
- package/BookReader/images/embed_icon.png +0 -0
- package/BookReader/images/icon-home-ia.png +0 -0
- package/BookReader/images/icon_OL-logo-xs.png +0 -0
- package/BookReader/images/icon_alert-xs.png +0 -0
- package/BookReader/images/icon_book.svg +1 -0
- package/BookReader/images/icon_bookmark.svg +1 -0
- package/BookReader/images/icon_close-pop.png +0 -0
- package/BookReader/images/icon_download.png +0 -0
- package/BookReader/images/icon_gear.svg +1 -0
- package/BookReader/images/icon_hamburger.svg +1 -0
- package/BookReader/images/icon_home.png +0 -0
- package/BookReader/images/icon_home.svg +1 -0
- package/BookReader/images/icon_home_ia.png +0 -0
- package/BookReader/images/icon_indicator.png +0 -0
- package/BookReader/images/icon_info.svg +1 -0
- package/BookReader/images/icon_one_page.svg +1 -0
- package/BookReader/images/icon_pause.svg +1 -0
- package/BookReader/images/icon_play.svg +1 -0
- package/BookReader/images/icon_playback-rate.svg +1 -0
- package/BookReader/images/icon_return.png +0 -0
- package/BookReader/images/icon_search_button.svg +1 -0
- package/BookReader/images/icon_share.svg +1 -0
- package/BookReader/images/icon_skip-ahead.svg +1 -0
- package/BookReader/images/icon_skip-back.svg +2 -0
- package/BookReader/images/icon_speaker.svg +1 -0
- package/BookReader/images/icon_speaker_open.svg +1 -0
- package/BookReader/images/icon_thumbnails.svg +1 -0
- package/BookReader/images/icon_toc.svg +1 -0
- package/BookReader/images/icon_two_pages.svg +1 -0
- package/BookReader/images/icon_zoomer.png +0 -0
- package/BookReader/images/loading.gif +0 -0
- package/BookReader/images/logo_icon.png +0 -0
- package/BookReader/images/marker_chap-off.png +0 -0
- package/BookReader/images/marker_chap-off.svg +1 -0
- package/BookReader/images/marker_chap-off_ia.png +0 -0
- package/BookReader/images/marker_chap-on.png +0 -0
- package/BookReader/images/marker_chap-on.svg +1 -0
- package/BookReader/images/marker_srch-on.svg +1 -0
- package/BookReader/images/marker_srchchap-off.png +0 -0
- package/BookReader/images/marker_srchchap-on.png +0 -0
- package/BookReader/images/nav_control-dn.png +0 -0
- package/BookReader/images/nav_control-dn_ia.png +0 -0
- package/BookReader/images/nav_control-up.png +0 -0
- package/BookReader/images/nav_control-up_ia.png +0 -0
- package/BookReader/images/nav_control.png +0 -0
- package/BookReader/images/one_page_mode_icon.png +0 -0
- package/BookReader/images/paper-badge.png +0 -0
- package/BookReader/images/print_icon.png +0 -0
- package/BookReader/images/progressbar.gif +0 -0
- package/BookReader/images/right_edges.png +0 -0
- package/BookReader/images/slider.png +0 -0
- package/BookReader/images/slider_ia.png +0 -0
- package/BookReader/images/thumbnail_mode_icon.png +0 -0
- package/BookReader/images/transparent.png +0 -0
- package/BookReader/images/two_page_mode_icon.png +0 -0
- package/BookReader/images/zoom_in_icon.png +0 -0
- package/BookReader/images/zoom_out_icon.png +0 -0
- package/BookReader/jquery-1.10.1.js +2 -0
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +2 -0
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -0
- package/BookReader/plugins/plugin.autoplay.js +2 -0
- package/BookReader/plugins/plugin.autoplay.js.map +1 -0
- package/BookReader/plugins/plugin.chapters.js +2 -0
- package/BookReader/plugins/plugin.chapters.js.map +1 -0
- package/BookReader/plugins/plugin.iframe.js +2 -0
- package/BookReader/plugins/plugin.iframe.js.map +1 -0
- package/BookReader/plugins/plugin.mobile_nav.js +2 -0
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -0
- package/BookReader/plugins/plugin.resume.js +2 -0
- package/BookReader/plugins/plugin.resume.js.map +1 -0
- package/BookReader/plugins/plugin.search.js +2 -0
- package/BookReader/plugins/plugin.search.js.map +1 -0
- package/BookReader/plugins/plugin.text_selection.js +2 -0
- package/BookReader/plugins/plugin.text_selection.js.map +1 -0
- package/BookReader/plugins/plugin.tts.js +3 -0
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +27 -0
- package/BookReader/plugins/plugin.tts.js.map +1 -0
- package/BookReader/plugins/plugin.url.js +2 -0
- package/BookReader/plugins/plugin.url.js.map +1 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js +2 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +41 -0
- package/BookReaderDemo/BookReaderJSAdvanced.js +115 -0
- package/BookReaderDemo/BookReaderJSAutoplay.js +56 -0
- package/BookReaderDemo/BookReaderJSSimple.js +55 -0
- package/BookReaderDemo/IIIFBookReader.js +207 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +1 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +1 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +1 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +1 -0
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
- package/BookReaderDemo/bookreader-template-bundle.js +7178 -0
- package/BookReaderDemo/demo-advanced.html +32 -0
- package/BookReaderDemo/demo-autoplay.html +38 -0
- package/BookReaderDemo/demo-embed-iframe-src.html +84 -0
- package/BookReaderDemo/demo-embed.html +26 -0
- package/BookReaderDemo/demo-fullscreen-mobile.html +36 -0
- package/BookReaderDemo/demo-fullscreen.html +33 -0
- package/BookReaderDemo/demo-iiif.html +34 -0
- package/BookReaderDemo/demo-iiif.js +26 -0
- package/BookReaderDemo/demo-internetarchive.html +74 -0
- package/BookReaderDemo/demo-multiple.html +43 -0
- package/BookReaderDemo/demo-preview-pages.html +1092 -0
- package/BookReaderDemo/demo-simple.html +34 -0
- package/BookReaderDemo/demo-vendor-fullscreen.html +36 -0
- package/BookReaderDemo/immersion-1up.html +64 -0
- package/BookReaderDemo/immersion-mode.html +35 -0
- package/BookReaderDemo/toggle_controls.html +53 -0
- package/BookReaderDemo/view_mode.html +39 -0
- package/BookReaderDemo/viewmode-cycle.html +41 -0
- package/CHANGELOG.md +540 -0
- package/CONTRIBUTING.md +7 -0
- package/LICENSE +661 -0
- package/README.md +205 -0
- package/babel.config.js +18 -0
- package/codecov.yml +17 -0
- package/index.html +31 -0
- package/jsconfig.json +14 -0
- package/karma.conf.js +23 -0
- package/package.json +129 -0
- package/screenshot.png +0 -0
- package/scripts/postversion.js +10 -0
- package/scripts/preversion.js +14 -0
- package/scripts/version.js +26 -0
- package/src/BookNavigator/BookModel.js +14 -0
- package/src/BookNavigator/BookNavigator.js +468 -0
- package/src/BookNavigator/assets/book-loader.js +27 -0
- package/src/BookNavigator/assets/bookmark-colors.js +15 -0
- package/src/BookNavigator/assets/button-base.js +61 -0
- package/src/BookNavigator/assets/icon_checkmark.js +6 -0
- package/src/BookNavigator/assets/icon_close.js +3 -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/bookmarks/bookmark-button.js +64 -0
- package/src/BookNavigator/bookmarks/bookmark-edit.js +215 -0
- package/src/BookNavigator/bookmarks/bookmarks-list.js +285 -0
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +28 -0
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +53 -0
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +500 -0
- package/src/BookNavigator/br-fullscreen-mgr.js +83 -0
- package/src/BookNavigator/delete-modal-actions.js +49 -0
- package/src/BookNavigator/downloads/downloads-provider.js +76 -0
- package/src/BookNavigator/downloads/downloads.js +138 -0
- package/src/BookNavigator/search/a-search-result.js +55 -0
- package/src/BookNavigator/search/search-provider.js +180 -0
- package/src/BookNavigator/search/search-results.js +360 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +93 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +280 -0
- package/src/BookNavigator/volumes/volumes-provider.js +83 -0
- package/src/BookNavigator/volumes/volumes.js +178 -0
- package/src/BookReader/BookModel.js +518 -0
- package/src/BookReader/DebugConsole.js +54 -0
- package/src/BookReader/ImageCache.js +116 -0
- package/src/BookReader/Mode1Up.js +90 -0
- package/src/BookReader/Mode1UpLit.js +434 -0
- package/src/BookReader/Mode2Up.js +1372 -0
- package/src/BookReader/ModeSmoothZoom.js +177 -0
- package/src/BookReader/ModeThumb.js +336 -0
- package/src/BookReader/Navbar/Navbar.js +339 -0
- package/src/BookReader/PageContainer.js +120 -0
- package/src/BookReader/ReduceSet.js +26 -0
- package/src/BookReader/Toolbar/Toolbar.js +384 -0
- package/src/BookReader/events.js +20 -0
- package/src/BookReader/options.js +320 -0
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/classes.js +36 -0
- package/src/BookReader/utils.js +240 -0
- package/src/BookReader.js +2546 -0
- package/src/BookReaderComponent/BookReaderComponent.js +112 -0
- package/src/ItemNavigator/ItemNavigator.js +376 -0
- package/src/ItemNavigator/providers/sharing.js +33 -0
- package/src/assets/icons/1up.svg +12 -0
- package/src/assets/icons/2up.svg +15 -0
- package/src/assets/icons/advance.svg +26 -0
- package/src/assets/icons/chevron-right.svg +1 -0
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/close-circle.svg +1 -0
- package/src/assets/icons/fullscreen.svg +17 -0
- package/src/assets/icons/fullscreen_exit.svg +17 -0
- package/src/assets/icons/hamburger.svg +15 -0
- package/src/assets/icons/left-arrow.svg +12 -0
- package/src/assets/icons/magnify-minus.svg +16 -0
- package/src/assets/icons/magnify-plus.svg +17 -0
- package/src/assets/icons/magnify.svg +15 -0
- package/src/assets/icons/pause.svg +23 -0
- package/src/assets/icons/play.svg +22 -0
- package/src/assets/icons/playback-speed.svg +34 -0
- package/src/assets/icons/read-aloud.svg +22 -0
- package/src/assets/icons/review.svg +22 -0
- package/src/assets/icons/thumbnails.svg +17 -0
- package/src/assets/icons/volume-full.svg +22 -0
- package/src/assets/images/BRicons.png +0 -0
- package/src/assets/images/BRicons.svg +94 -0
- package/src/assets/images/BRicons_ia.png +0 -0
- package/src/assets/images/back_pages.png +0 -0
- package/src/assets/images/book_bottom_icon.png +0 -0
- package/src/assets/images/book_down_icon.png +0 -0
- package/src/assets/images/book_left_icon.png +0 -0
- package/src/assets/images/book_leftmost_icon.png +0 -0
- package/src/assets/images/book_right_icon.png +0 -0
- package/src/assets/images/book_rightmost_icon.png +0 -0
- package/src/assets/images/book_top_icon.png +0 -0
- package/src/assets/images/book_up_icon.png +0 -0
- package/src/assets/images/books_graphic.svg +177 -0
- package/src/assets/images/booksplit.png +0 -0
- package/src/assets/images/control_pause_icon.png +0 -0
- package/src/assets/images/control_play_icon.png +0 -0
- package/src/assets/images/embed_icon.png +0 -0
- package/src/assets/images/icon-home-ia.png +0 -0
- package/src/assets/images/icon_OL-logo-xs.png +0 -0
- package/src/assets/images/icon_alert-xs.png +0 -0
- package/src/assets/images/icon_book.svg +12 -0
- package/src/assets/images/icon_bookmark.svg +12 -0
- package/src/assets/images/icon_close-pop.png +0 -0
- package/src/assets/images/icon_download.png +0 -0
- package/src/assets/images/icon_gear.svg +14 -0
- package/src/assets/images/icon_hamburger.svg +20 -0
- package/src/assets/images/icon_home.png +0 -0
- package/src/assets/images/icon_home.svg +21 -0
- package/src/assets/images/icon_home_ia.png +0 -0
- package/src/assets/images/icon_indicator.png +0 -0
- package/src/assets/images/icon_info.svg +11 -0
- package/src/assets/images/icon_one_page.svg +8 -0
- package/src/assets/images/icon_pause.svg +1 -0
- package/src/assets/images/icon_play.svg +1 -0
- package/src/assets/images/icon_playback-rate.svg +15 -0
- package/src/assets/images/icon_return.png +0 -0
- package/src/assets/images/icon_search_button.svg +8 -0
- package/src/assets/images/icon_share.svg +9 -0
- package/src/assets/images/icon_skip-ahead.svg +6 -0
- package/src/assets/images/icon_skip-back.svg +13 -0
- package/src/assets/images/icon_speaker.svg +18 -0
- package/src/assets/images/icon_speaker_open.svg +10 -0
- package/src/assets/images/icon_thumbnails.svg +12 -0
- package/src/assets/images/icon_toc.svg +5 -0
- package/src/assets/images/icon_two_pages.svg +9 -0
- package/src/assets/images/icon_zoomer.png +0 -0
- package/src/assets/images/loading.gif +0 -0
- package/src/assets/images/logo_icon.png +0 -0
- package/src/assets/images/marker_chap-off.png +0 -0
- package/src/assets/images/marker_chap-off.svg +11 -0
- package/src/assets/images/marker_chap-off_ia.png +0 -0
- package/src/assets/images/marker_chap-on.png +0 -0
- package/src/assets/images/marker_chap-on.svg +11 -0
- package/src/assets/images/marker_srch-on.svg +11 -0
- package/src/assets/images/marker_srchchap-off.png +0 -0
- package/src/assets/images/marker_srchchap-on.png +0 -0
- package/src/assets/images/nav_control-dn.png +0 -0
- package/src/assets/images/nav_control-dn_ia.png +0 -0
- package/src/assets/images/nav_control-up.png +0 -0
- package/src/assets/images/nav_control-up_ia.png +0 -0
- package/src/assets/images/nav_control.png +0 -0
- package/src/assets/images/one_page_mode_icon.png +0 -0
- package/src/assets/images/paper-badge.png +0 -0
- package/src/assets/images/print_icon.png +0 -0
- package/src/assets/images/progressbar.gif +0 -0
- package/src/assets/images/right_edges.png +0 -0
- package/src/assets/images/slider.png +0 -0
- package/src/assets/images/slider_ia.png +0 -0
- package/src/assets/images/thumbnail_mode_icon.png +0 -0
- package/src/assets/images/transparent.png +0 -0
- package/src/assets/images/two_page_mode_icon.png +0 -0
- package/src/assets/images/zoom_in_icon.png +0 -0
- package/src/assets/images/zoom_out_icon.png +0 -0
- package/src/css/BookReader.scss +89 -0
- package/src/css/_BRBookmarks.scss +29 -0
- package/src/css/_BRComponent.scss +13 -0
- package/src/css/_BRfloat.scss +197 -0
- package/src/css/_BRicon.scss +48 -0
- package/src/css/_BRmain.scss +251 -0
- package/src/css/_BRnav.scss +382 -0
- package/src/css/_BRpages.scss +139 -0
- package/src/css/_BRsearch.scss +226 -0
- package/src/css/_BRtoolbar.scss +84 -0
- package/src/css/_BRvendor.scss +5 -0
- package/src/css/_MobileNav.scss +194 -0
- package/src/css/_TextSelection.scss +32 -0
- package/src/css/_colorbox.scss +52 -0
- package/src/css/_controls.scss +244 -0
- package/src/css/_icons.scss +121 -0
- package/src/dragscrollable-br.js +261 -0
- package/src/jquery-wrapper.js +4 -0
- package/src/plugins/plugin.archive_analytics.js +86 -0
- package/src/plugins/plugin.autoplay.js +129 -0
- package/src/plugins/plugin.chapters.js +251 -0
- package/src/plugins/plugin.iframe.js +48 -0
- package/src/plugins/plugin.mobile_nav.js +287 -0
- package/src/plugins/plugin.resume.js +68 -0
- package/src/plugins/plugin.text_selection.js +291 -0
- package/src/plugins/plugin.url.js +198 -0
- package/src/plugins/plugin.vendor-fullscreen.js +247 -0
- package/src/plugins/search/plugin.search.js +439 -0
- package/src/plugins/search/view.js +440 -0
- package/src/plugins/tts/AbstractTTSEngine.js +242 -0
- package/src/plugins/tts/FestivalTTSEngine.js +169 -0
- package/src/plugins/tts/PageChunk.js +107 -0
- package/src/plugins/tts/PageChunkIterator.js +163 -0
- package/src/plugins/tts/WebTTSEngine.js +352 -0
- package/src/plugins/tts/plugin.tts.js +335 -0
- package/src/plugins/tts/tooltip_dict.js +15 -0
- package/src/plugins/tts/utils.js +91 -0
- package/src/util/browserSniffing.js +30 -0
- package/src/util/debouncer.js +26 -0
- package/src/util/docCookies.js +67 -0
- package/src/util/strings.js +34 -0
- package/tests/BookReader/BookModel.test.js +312 -0
- package/tests/BookReader/BookReaderPublicFunctions.test.js +164 -0
- package/tests/BookReader/DebugConsole.test.js +25 -0
- package/tests/BookReader/ImageCache.test.js +150 -0
- package/tests/BookReader/Mode1UpLit.test.js +87 -0
- package/tests/BookReader/Mode2Up.test.js +245 -0
- package/tests/BookReader/ModeSmoothZoom.test.js +149 -0
- package/tests/BookReader/Navbar/Navbar.test.js +169 -0
- package/tests/BookReader/PageContainer.test.js +187 -0
- package/tests/BookReader/ReduceSet.test.js +38 -0
- package/tests/BookReader/Toolbar/Toolbar.test.js +26 -0
- package/tests/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/BookReader/utils/classes.test.js +88 -0
- package/tests/BookReader/utils.test.js +136 -0
- package/tests/BookReader.options.test.js +39 -0
- package/tests/BookReader.test.js +301 -0
- package/tests/e2e/README.md +75 -0
- package/tests/e2e/autoplay.test.js +13 -0
- package/tests/e2e/base.test.js +35 -0
- package/tests/e2e/helpers/base.js +263 -0
- package/tests/e2e/helpers/debug.js +13 -0
- package/tests/e2e/helpers/desktopSearch.js +72 -0
- package/tests/e2e/helpers/mobileSearch.js +85 -0
- package/tests/e2e/helpers/mockSearch.js +93 -0
- package/tests/e2e/helpers/rightToLeft.js +29 -0
- package/tests/e2e/ia-production/ia-prod-base.js +17 -0
- package/tests/e2e/models/BookReader.js +11 -0
- package/tests/e2e/models/Navigation.js +56 -0
- package/tests/e2e/rightToLeft.test.js +20 -0
- package/tests/e2e/viewmode.test.js +37 -0
- package/tests/karma/BookNavigator/book-navigator.test.js +180 -0
- package/tests/karma/BookNavigator/bookmarks/bookmark-edit.test.js +133 -0
- package/tests/karma/BookNavigator/bookmarks/bookmarks-list.test.js +222 -0
- package/tests/karma/BookNavigator/downloads/downloads-provider.test.js +64 -0
- package/tests/karma/BookNavigator/downloads/downloads.test.js +54 -0
- package/tests/karma/BookNavigator/search/search-provider.test.js +23 -0
- package/tests/karma/BookNavigator/search/search-results.test.js +240 -0
- package/tests/karma/BookNavigator/sharing/sharing-provider.test.js +40 -0
- package/tests/karma/BookNavigator/visual-adjustments.test.js +201 -0
- package/tests/karma/BookNavigator/volumes/volumes-provider.test.js +160 -0
- package/tests/karma/BookNavigator/volumes/volumes.test.js +98 -0
- package/tests/plugins/plugin.archive_analytics.test.js +23 -0
- package/tests/plugins/plugin.autoplay.test.js +52 -0
- package/tests/plugins/plugin.chapters.test.js +130 -0
- package/tests/plugins/plugin.iframe.test.js +42 -0
- package/tests/plugins/plugin.mobile_nav.test.js +66 -0
- package/tests/plugins/plugin.resume.test.js +98 -0
- package/tests/plugins/plugin.text_selection.test.js +193 -0
- package/tests/plugins/plugin.url.test.js +129 -0
- package/tests/plugins/plugin.vendor-fullscreen.test.js +65 -0
- package/tests/plugins/search/plugin.search.test.js +173 -0
- package/tests/plugins/search/plugin.search.view.test.js +106 -0
- package/tests/plugins/tts/AbstractTTSEngine.test.js +153 -0
- package/tests/plugins/tts/FestivalTTSEngine.test.js +59 -0
- package/tests/plugins/tts/PageChunk.test.js +57 -0
- package/tests/plugins/tts/PageChunkIterator.test.js +179 -0
- package/tests/plugins/tts/WebTTSEngine.test.js +126 -0
- package/tests/plugins/tts/utils.test.js +133 -0
- package/tests/util/browserSniffing.test.js +56 -0
- package/tests/util/docCookies.test.js +15 -0
- package/tests/util/strings.test.js +63 -0
- package/tests/utils.js +80 -0
- 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
|
+
}
|