@internetarchive/bookreader 5.0.0-8-multiple-files → 5.0.0-80
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +17 -15
- package/.github/workflows/node.js.yml +78 -6
- package/.github/workflows/npm-publish.yml +6 -20
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +442 -1393
- package/BookReader/BookReader.js +2 -21564
- package/BookReader/BookReader.js.LICENSE.txt +20 -20
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1782 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -12
- package/BookReader/icons/2up.svg +1 -15
- package/BookReader/icons/advance.svg +3 -26
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +1 -17
- package/BookReader/icons/fullscreen_exit.svg +1 -17
- package/BookReader/icons/hamburger.svg +1 -15
- package/BookReader/icons/left-arrow.svg +1 -12
- package/BookReader/icons/magnify-minus.svg +1 -16
- package/BookReader/icons/magnify-plus.svg +1 -17
- package/BookReader/icons/magnify.svg +1 -15
- package/BookReader/icons/pause.svg +1 -23
- package/BookReader/icons/play.svg +1 -22
- package/BookReader/icons/playback-speed.svg +1 -34
- package/BookReader/icons/read-aloud.svg +1 -22
- package/BookReader/icons/review.svg +3 -22
- package/BookReader/icons/thumbnails.svg +1 -17
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -22
- package/BookReader/images/BRicons.svg +5 -94
- package/BookReader/images/books_graphic.svg +1 -177
- package/BookReader/images/icon_book.svg +1 -12
- package/BookReader/images/icon_bookmark.svg +1 -12
- package/BookReader/images/icon_gear.svg +1 -14
- package/BookReader/images/icon_hamburger.svg +1 -20
- package/BookReader/images/icon_home.svg +1 -21
- package/BookReader/images/icon_info.svg +1 -11
- package/BookReader/images/icon_one_page.svg +1 -8
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -15
- package/BookReader/images/icon_search_button.svg +1 -8
- package/BookReader/images/icon_share.svg +1 -9
- package/BookReader/images/icon_skip-ahead.svg +1 -6
- package/BookReader/images/icon_skip-back.svg +2 -13
- package/BookReader/images/icon_speaker.svg +1 -18
- package/BookReader/images/icon_speaker_open.svg +1 -10
- package/BookReader/images/icon_thumbnails.svg +1 -12
- package/BookReader/images/icon_toc.svg +1 -5
- package/BookReader/images/icon_two_pages.svg +1 -9
- package/BookReader/images/marker_chap-off.svg +1 -11
- package/BookReader/images/marker_chap-on.svg +1 -11
- package/BookReader/images/marker_srch-on.svg +1 -11
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +1 -172
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -165
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +22 -301
- package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -74
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +2 -0
- package/BookReader/plugins/plugin.iiif.js.map +1 -0
- package/BookReader/plugins/plugin.resume.js +1 -368
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +2 -1420
- package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +2 -1080
- package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +2 -9193
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +2 -0
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -269
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -379
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +18 -19
- package/BookReaderDemo/BookReaderJSAdvanced.js +0 -3
- package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
- package/BookReaderDemo/BookReaderJSSimple.js +1 -0
- package/BookReaderDemo/IADemoBr.js +147 -0
- package/BookReaderDemo/demo-advanced.html +2 -2
- package/BookReaderDemo/demo-autoplay.html +2 -3
- package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
- package/BookReaderDemo/demo-fullscreen-mobile.html +3 -5
- package/BookReaderDemo/demo-fullscreen.html +2 -4
- package/BookReaderDemo/demo-iiif.html +99 -12
- package/BookReaderDemo/demo-internetarchive.html +214 -18
- package/BookReaderDemo/demo-multiple.html +2 -1
- package/BookReaderDemo/demo-preview-pages.html +2 -1
- package/BookReaderDemo/demo-simple.html +2 -1
- package/BookReaderDemo/demo-vendor-fullscreen.html +2 -4
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
- package/BookReaderDemo/immersion-1up.html +2 -2
- package/BookReaderDemo/immersion-mode.html +2 -4
- package/BookReaderDemo/toggle_controls.html +3 -2
- package/BookReaderDemo/view_mode.html +2 -1
- package/BookReaderDemo/viewmode-cycle.html +2 -3
- package/CHANGELOG.md +545 -33
- package/README.md +14 -1
- package/babel.config.js +20 -0
- package/codecov.yml +6 -0
- package/index.html +4 -1
- package/jsconfig.json +19 -0
- package/netlify.toml +9 -0
- package/package.json +70 -60
- package/renovate.json +52 -0
- package/scripts/preversion.js +0 -1
- package/src/BookNavigator/assets/bookmark-colors.js +1 -1
- package/src/BookNavigator/assets/button-base.js +9 -2
- package/src/BookNavigator/assets/ia-logo.js +17 -0
- package/src/BookNavigator/assets/icon_checkmark.js +1 -1
- package/src/BookNavigator/assets/icon_close.js +1 -1
- package/src/BookNavigator/book-navigator.js +590 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
- package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
- package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
- package/src/BookNavigator/delete-modal-actions.js +1 -1
- package/src/BookNavigator/downloads/downloads-provider.js +36 -21
- package/src/BookNavigator/downloads/downloads.js +41 -25
- package/src/BookNavigator/search/search-provider.js +80 -28
- package/src/BookNavigator/search/search-results.js +28 -25
- package/src/BookNavigator/sharing.js +27 -0
- package/src/BookNavigator/viewable-files.js +95 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
- package/src/BookReader/BookModel.js +64 -34
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +56 -351
- package/src/BookReader/Mode1UpLit.js +388 -0
- package/src/BookReader/Mode2Up.js +73 -1318
- package/src/BookReader/Mode2UpLit.js +776 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +312 -0
- package/src/BookReader/ModeThumb.js +18 -12
- package/src/BookReader/Navbar/Navbar.js +14 -40
- package/src/BookReader/PageContainer.js +81 -6
- package/src/BookReader/ReduceSet.js +1 -1
- package/src/BookReader/Toolbar/Toolbar.js +10 -37
- package/src/BookReader/events.js +2 -3
- package/src/BookReader/options.js +27 -2
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils/SelectionObserver.js +45 -0
- package/src/BookReader/utils.js +118 -13
- package/src/BookReader.js +446 -1062
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/assets/icons/voice.svg +1 -0
- package/src/css/BookReader.scss +1 -17
- package/src/css/_BRBookmarks.scss +1 -1
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +33 -27
- package/src/css/_BRnav.scss +12 -39
- package/src/css/_BRpages.scss +149 -40
- package/src/css/_BRsearch.scss +68 -230
- package/src/css/_BRtoolbar.scss +5 -5
- package/src/css/_TextSelection.scss +87 -27
- package/src/css/_colorbox.scss +2 -2
- package/src/css/_controls.scss +20 -7
- package/src/css/_icons.scss +7 -1
- package/src/ia-bookreader/ia-bookreader.js +224 -0
- package/src/plugins/plugin.archive_analytics.js +3 -3
- package/src/plugins/plugin.autoplay.js +5 -11
- package/src/plugins/plugin.chapters.js +237 -191
- package/src/plugins/plugin.iiif.js +151 -0
- package/src/plugins/plugin.resume.js +3 -3
- package/src/plugins/plugin.text_selection.js +464 -134
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +175 -120
- package/src/plugins/search/utils.js +43 -0
- package/src/plugins/search/view.js +64 -202
- package/src/plugins/tts/AbstractTTSEngine.js +71 -40
- package/src/plugins/tts/FestivalTTSEngine.js +13 -14
- package/src/plugins/tts/PageChunk.js +15 -21
- package/src/plugins/tts/PageChunkIterator.js +8 -12
- package/src/plugins/tts/WebTTSEngine.js +87 -71
- package/src/plugins/tts/plugin.tts.js +96 -127
- package/src/plugins/tts/utils.js +15 -25
- package/src/plugins/url/UrlPlugin.js +191 -0
- package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
- package/src/util/browserSniffing.js +22 -0
- package/src/util/docCookies.js +21 -2
- package/tests/e2e/README.md +37 -0
- package/tests/e2e/autoplay.test.js +2 -2
- package/tests/e2e/base.test.js +8 -16
- package/tests/e2e/helpers/base.js +53 -48
- package/tests/e2e/helpers/debug.js +1 -1
- package/tests/e2e/helpers/params.js +17 -0
- package/tests/e2e/helpers/rightToLeft.js +8 -14
- package/tests/e2e/helpers/search.js +73 -0
- package/tests/e2e/models/Navigation.js +20 -37
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +40 -33
- package/tests/jest/BookNavigator/book-navigator.test.js +661 -0
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
- package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
- package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
- package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +109 -60
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
- package/tests/jest/BookNavigator/viewable-files/viewable-files-provider.test.js +80 -0
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/{BookReader → jest/BookReader}/BookModel.test.js +74 -14
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
- package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
- package/tests/jest/BookReader/Mode2Up.test.js +98 -0
- package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
- package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +218 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
- package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
- 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/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/tests/jest/BookReader/utils/SelectionObserver.test.js +57 -0
- package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
- package/tests/jest/BookReader/utils.test.js +229 -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} +26 -37
- package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
- package/tests/jest/plugins/plugin.chapters.test.js +195 -0
- package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
- package/tests/jest/plugins/plugin.text_selection.test.js +317 -0
- package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
- package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +26 -47
- package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +39 -6
- package/tests/jest/plugins/search/utils.js +25 -0
- package/tests/jest/plugins/search/utils.test.js +29 -0
- package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +29 -9
- 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 +47 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
- package/tests/jest/plugins/url/UrlPlugin.test.js +198 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
- package/tests/jest/setup.js +3 -0
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/jest/util/docCookies.test.js +24 -0
- package/tests/{util → jest/util}/strings.test.js +1 -1
- package/tests/{utils.js → jest/utils.js} +38 -0
- package/webpack.config.js +12 -6
- package/.babelrc +0 -12
- package/.dependabot/config.yml +0 -6
- package/.testcaferc.json +0 -5
- package/BookReader/bookreader-component-bundle.js +0 -14312
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/icons/sort-ascending.svg +0 -1
- package/BookReader/icons/sort-descending.svg +0 -1
- package/BookReader/jquery-1.10.1.js +0 -108
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -369
- package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
- package/BookReader/plugins/plugin.mobile_nav.js +0 -335
- package/BookReader/plugins/plugin.mobile_nav.js.map +0 -1
- package/BookReaderDemo/IIIFBookReader.js +0 -207
- package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
- package/BookReaderDemo/demo-iiif.js +0 -26
- package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
- package/karma.conf.js +0 -23
- package/src/BookNavigator/BookModel.js +0 -14
- package/src/BookNavigator/BookNavigator.js +0 -452
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/BookNavigator/assets/icon_sort_ascending.js +0 -5
- package/src/BookNavigator/assets/icon_sort_descending.js +0 -5
- package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
- package/src/BookNavigator/search/a-search-result.js +0 -55
- package/src/BookNavigator/volumes/volumes-provider.js +0 -76
- package/src/BookNavigator/volumes/volumes.js +0 -161
- package/src/BookReader/DebugConsole.js +0 -54
- package/src/BookReaderComponent/BookReaderComponent.js +0 -112
- package/src/ItemNavigator/ItemNavigator.js +0 -372
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/assets/icons/sort-ascending.svg +0 -1
- package/src/assets/icons/sort-descending.svg +0 -1
- package/src/css/_MobileNav.scss +0 -194
- package/src/dragscrollable-br.js +0 -261
- package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
- package/src/plugins/plugin.mobile_nav.js +0 -287
- package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
- package/tests/BookReader/DebugConsole.test.js +0 -25
- package/tests/BookReader/Mode1Up.test.js +0 -164
- package/tests/BookReader/Mode2Up.test.js +0 -247
- package/tests/BookReader/utils.test.js +0 -109
- package/tests/e2e/helpers/desktopSearch.js +0 -72
- package/tests/e2e/helpers/mobileSearch.js +0 -85
- package/tests/e2e/ia-production/ia-prod-base.js +0 -17
- package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
- package/tests/karma/BookNavigator/volumes.test.js +0 -101
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
- package/tests/plugins/plugin.chapters.test.js +0 -130
- package/tests/plugins/plugin.mobile_nav.test.js +0 -66
- package/tests/plugins/plugin.text_selection.test.js +0 -203
- package/tests/util/docCookies.test.js +0 -15
@@ -1,1421 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
/***/ "./src/plugins/search/plugin.search.js":
|
4
|
-
/*!*********************************************!*\
|
5
|
-
!*** ./src/plugins/search/plugin.search.js ***!
|
6
|
-
\*********************************************/
|
7
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
8
|
-
|
9
|
-
"use strict";
|
10
|
-
__webpack_require__.r(__webpack_exports__);
|
11
|
-
/* harmony import */ var regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! regenerator-runtime/runtime.js */ "./node_modules/regenerator-runtime/runtime.js");
|
12
|
-
/* harmony import */ var regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_0__);
|
13
|
-
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "./node_modules/core-js/modules/es.regexp.exec.js");
|
14
|
-
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1__);
|
15
|
-
/* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.string.search.js */ "./node_modules/core-js/modules/es.string.search.js");
|
16
|
-
/* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_2__);
|
17
|
-
/* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.array.find.js */ "./node_modules/core-js/modules/es.array.find.js");
|
18
|
-
/* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_3__);
|
19
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.string.replace.js */ "./node_modules/core-js/modules/es.string.replace.js");
|
20
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_4__);
|
21
|
-
/* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/es.array.concat.js */ "./node_modules/core-js/modules/es.array.concat.js");
|
22
|
-
/* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_5__);
|
23
|
-
/* harmony import */ var core_js_modules_es_object_assign_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.object.assign.js */ "./node_modules/core-js/modules/es.object.assign.js");
|
24
|
-
/* harmony import */ var core_js_modules_es_object_assign_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_assign_js__WEBPACK_IMPORTED_MODULE_6__);
|
25
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ "./node_modules/core-js/modules/web.dom-collections.for-each.js");
|
26
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_7__);
|
27
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "./node_modules/core-js/modules/es.object.to-string.js");
|
28
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_8__);
|
29
|
-
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.promise.js */ "./node_modules/core-js/modules/es.promise.js");
|
30
|
-
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_9__);
|
31
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "./node_modules/core-js/modules/es.array.iterator.js");
|
32
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_10__);
|
33
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "./node_modules/core-js/modules/es.string.iterator.js");
|
34
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_11__);
|
35
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "./node_modules/core-js/modules/web.dom-collections.iterator.js");
|
36
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_12__);
|
37
|
-
/* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/web.url.js */ "./node_modules/core-js/modules/web.url.js");
|
38
|
-
/* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_13__);
|
39
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/es.array.slice.js */ "./node_modules/core-js/modules/es.array.slice.js");
|
40
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_14__);
|
41
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ "./node_modules/core-js/modules/es.function.name.js");
|
42
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_15__);
|
43
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! core-js/modules/es.array.from.js */ "./node_modules/core-js/modules/es.array.from.js");
|
44
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_16__);
|
45
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "./node_modules/core-js/modules/es.symbol.js");
|
46
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_17__);
|
47
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "./node_modules/core-js/modules/es.symbol.description.js");
|
48
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_18__);
|
49
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "./node_modules/core-js/modules/es.symbol.iterator.js");
|
50
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_19__);
|
51
|
-
/* harmony import */ var _view_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./view.js */ "./src/plugins/search/view.js");
|
52
|
-
/* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery");
|
53
|
-
/* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery");
|
54
|
-
|
55
|
-
|
56
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
57
|
-
|
58
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
59
|
-
|
60
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
61
|
-
|
62
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
63
|
-
|
64
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
/* global BookReader */
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Plugin for Archive.org book search
|
90
|
-
* NOTE: This script must be loaded AFTER `plugin.mobile_nav.js`
|
91
|
-
* as it mutates mobile nav drawer
|
92
|
-
*
|
93
|
-
* Events fired at various points throughout search processing are published
|
94
|
-
* on the document DOM element. These can be subscribed to using jQuery's event
|
95
|
-
* binding method `$.fn.on`. All of the events are prefixed with a BookReader
|
96
|
-
* namespace. The events are:
|
97
|
-
*
|
98
|
-
* @event BookReader:SearchStarted - When a search form is submitted, immediately
|
99
|
-
* before an AJAX call is made to request search results
|
100
|
-
* @event BookReader:SearchCallback - When the search AJAX call is returned and at
|
101
|
-
* least one result is returned. The event callback receives an object
|
102
|
-
* with the `results`, plugin `options`, and the BookReader `instance`
|
103
|
-
* @event BookReader:SearchCallbackError - When the AJAX request returns an error.
|
104
|
-
* Receives the `results` and `instance`
|
105
|
-
* @event BookReader:SearchCallbackNotIndexed - When a message is received that
|
106
|
-
* the book has not had OCR text indexed yet. Receives `instance`
|
107
|
-
* @event BookReader:SearchCallbackEmpty - When no results found. Receives
|
108
|
-
* `instance`
|
109
|
-
*/
|
110
|
-
|
111
|
-
jQuery.extend(BookReader.defaultOptions, {
|
112
|
-
server: 'ia600609.us.archive.org',
|
113
|
-
bookId: '',
|
114
|
-
subPrefix: '',
|
115
|
-
bookPath: '',
|
116
|
-
enableSearch: true,
|
117
|
-
searchInsideUrl: '/fulltext/inside.php',
|
118
|
-
initialSearchTerm: null
|
119
|
-
});
|
120
|
-
/** @override */
|
121
|
-
|
122
|
-
BookReader.prototype.setup = function (super_) {
|
123
|
-
return function (options) {
|
124
|
-
super_.call(this, options);
|
125
|
-
this.searchTerm = '';
|
126
|
-
this.searchResults = null;
|
127
|
-
this.searchInsideUrl = options.searchInsideUrl;
|
128
|
-
this.enableSearch = options.enableSearch;
|
129
|
-
this.goToFirstResult = false; // Base server used by some api calls
|
130
|
-
|
131
|
-
this.bookId = options.bookId;
|
132
|
-
this.server = options.server;
|
133
|
-
this.subPrefix = options.subPrefix;
|
134
|
-
this.bookPath = options.bookPath;
|
135
|
-
|
136
|
-
if (this.searchView) {
|
137
|
-
return;
|
138
|
-
}
|
139
|
-
|
140
|
-
this.searchView = new _view_js__WEBPACK_IMPORTED_MODULE_20__.default({
|
141
|
-
br: this,
|
142
|
-
selector: '#BRsearch_tray'
|
143
|
-
});
|
144
|
-
};
|
145
|
-
}(BookReader.prototype.setup);
|
146
|
-
/** @override */
|
147
|
-
|
148
|
-
|
149
|
-
BookReader.prototype.init = function (super_) {
|
150
|
-
return function () {
|
151
|
-
super_.call(this);
|
152
|
-
|
153
|
-
if (this.options.enableSearch && this.options.initialSearchTerm) {
|
154
|
-
this.search(this.options.initialSearchTerm, {
|
155
|
-
goToFirstResult: this.goToFirstResult,
|
156
|
-
suppressFragmentChange: true
|
157
|
-
});
|
158
|
-
}
|
159
|
-
};
|
160
|
-
}(BookReader.prototype.init);
|
161
|
-
/** @override */
|
162
|
-
|
163
|
-
|
164
|
-
BookReader.prototype.buildMobileDrawerElement = function (super_) {
|
165
|
-
return function () {
|
166
|
-
var $el = super_.call(this);
|
167
|
-
|
168
|
-
if (!this.enableSearch) {
|
169
|
-
return;
|
170
|
-
}
|
171
|
-
|
172
|
-
if (this.searchView.dom.mobileSearch) {
|
173
|
-
$el.find('.BRmobileMenu__moreInfoRow').after(this.searchView.dom.mobileSearch);
|
174
|
-
}
|
175
|
-
|
176
|
-
return $el;
|
177
|
-
};
|
178
|
-
}(BookReader.prototype.buildMobileDrawerElement);
|
179
|
-
/** @override */
|
180
|
-
|
181
|
-
|
182
|
-
BookReader.prototype.buildToolbarElement = function (super_) {
|
183
|
-
return function () {
|
184
|
-
var $el = super_.call(this);
|
185
|
-
|
186
|
-
if (!this.enableSearch) {
|
187
|
-
return;
|
188
|
-
}
|
189
|
-
|
190
|
-
if (this.searchView.dom.toolbarSearch) {
|
191
|
-
$el.find('.BRtoolbarSectionInfo').after(this.searchView.dom.toolbarSearch);
|
192
|
-
}
|
193
|
-
|
194
|
-
return $el;
|
195
|
-
};
|
196
|
-
}(BookReader.prototype.buildToolbarElement);
|
197
|
-
/**
|
198
|
-
* @typedef {object} SearchOptions
|
199
|
-
* @property {boolean} goToFirstResult
|
200
|
-
* @property {boolean} disablePopup
|
201
|
-
* @property {(null|function)} error - @deprecated at v.5.0
|
202
|
-
* @property {(null|function)} success - @deprecated at v.5.0
|
203
|
-
*/
|
204
|
-
|
205
|
-
/**
|
206
|
-
* Submits search request
|
207
|
-
*
|
208
|
-
* @param {string} term
|
209
|
-
* @param {SearchOptions} overrides
|
210
|
-
*/
|
211
|
-
|
212
|
-
|
213
|
-
BookReader.prototype.search = function () {
|
214
|
-
var _this = this;
|
215
|
-
|
216
|
-
var term = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
217
|
-
var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
218
|
-
|
219
|
-
/** @type {SearchOptions} */
|
220
|
-
var defaultOptions = {
|
221
|
-
goToFirstResult: false,
|
222
|
-
|
223
|
-
/* jump to the first result (default=false) */
|
224
|
-
disablePopup: false,
|
225
|
-
|
226
|
-
/* don't show the modal progress (default=false) */
|
227
|
-
suppressFragmentChange: false,
|
228
|
-
|
229
|
-
/* don't change the URL on initial load */
|
230
|
-
error: null,
|
231
|
-
|
232
|
-
/* optional error handler (default=null) */
|
233
|
-
success: null
|
234
|
-
/* optional success handler (default=null) */
|
235
|
-
|
236
|
-
};
|
237
|
-
var options = jQuery.extend({}, defaultOptions, overrides);
|
238
|
-
this.suppressFragmentChange = options.suppressFragmentChange; // strip slashes, since this goes in the url
|
239
|
-
|
240
|
-
this.searchTerm = term.replace(/\//g, ' ');
|
241
|
-
|
242
|
-
if (!options.suppressFragmentChange) {
|
243
|
-
this.trigger(BookReader.eventNames.fragmentChange);
|
244
|
-
} // Add quotes to the term. This is to compenstate for the backends default OR query
|
245
|
-
// term = term.replace(/['"]+/g, '');
|
246
|
-
// term = '"' + term + '"';
|
247
|
-
// Remove the port and userdir
|
248
|
-
|
249
|
-
|
250
|
-
var serverPath = this.server.replace(/:.+/, '');
|
251
|
-
var baseUrl = "https://".concat(serverPath).concat(this.searchInsideUrl, "?"); // Remove subPrefix from end of path
|
252
|
-
|
253
|
-
var path = this.bookPath;
|
254
|
-
var subPrefixWithSlash = "/".concat(this.subPrefix);
|
255
|
-
|
256
|
-
if (this.bookPath.length - this.bookPath.lastIndexOf(subPrefixWithSlash) == subPrefixWithSlash.length) {
|
257
|
-
path = this.bookPath.substr(0, this.bookPath.length - subPrefixWithSlash.length);
|
258
|
-
}
|
259
|
-
|
260
|
-
var urlParams = {
|
261
|
-
item_id: this.bookId,
|
262
|
-
doc: this.subPrefix,
|
263
|
-
path: path,
|
264
|
-
q: term
|
265
|
-
}; // NOTE that the API does not expect / (slashes) to be encoded. (%2F) won't work
|
266
|
-
|
267
|
-
var paramStr = $.param(urlParams).replace(/%2F/g, '/');
|
268
|
-
var url = "".concat(baseUrl).concat(paramStr);
|
269
|
-
|
270
|
-
var processSearchResults = function processSearchResults(searchInsideResults) {
|
271
|
-
var responseHasError = searchInsideResults.error || !searchInsideResults.matches.length;
|
272
|
-
var hasCustomError = typeof options.error === 'function';
|
273
|
-
var hasCustomSuccess = typeof options.success === 'function';
|
274
|
-
|
275
|
-
if (responseHasError) {
|
276
|
-
hasCustomError ? options.error.call(_this, searchInsideResults, options) : _this.BRSearchCallbackError(searchInsideResults, options);
|
277
|
-
} else {
|
278
|
-
hasCustomSuccess ? options.success.call(_this, searchInsideResults, options) : _this.BRSearchCallback(searchInsideResults, options);
|
279
|
-
}
|
280
|
-
};
|
281
|
-
|
282
|
-
this.trigger('SearchStarted', {
|
283
|
-
term: this.searchTerm
|
284
|
-
});
|
285
|
-
return $.ajax({
|
286
|
-
url: url,
|
287
|
-
dataType: 'jsonp'
|
288
|
-
}).then(processSearchResults);
|
289
|
-
};
|
290
|
-
/**
|
291
|
-
* @typedef {object} SearchInsideMatchBox
|
292
|
-
* @property {number} page
|
293
|
-
* @property {number} r
|
294
|
-
* @property {number} l
|
295
|
-
* @property {number} b
|
296
|
-
* @property {number} t
|
297
|
-
* @property {HTMLDivElement} [div]
|
298
|
-
*/
|
299
|
-
|
300
|
-
/**
|
301
|
-
* @typedef {object} SearchInsideMatch
|
302
|
-
* @property {string} text
|
303
|
-
* @property {Array<{ page: number, boxes: SearchInsideMatchBox[] }>} par
|
304
|
-
*/
|
305
|
-
|
306
|
-
/**
|
307
|
-
* @typedef {object} SearchInsideResults
|
308
|
-
* @property {string} error
|
309
|
-
* @property {SearchInsideMatch[]} matches
|
310
|
-
* @property {boolean} indexed
|
311
|
-
*/
|
312
|
-
|
313
|
-
/**
|
314
|
-
* Search Results return handler
|
315
|
-
* @callback
|
316
|
-
* @param {SearchInsideResults} results
|
317
|
-
* @param {object} options
|
318
|
-
* @param {boolean} options.goToFirstResult
|
319
|
-
*/
|
320
|
-
|
321
|
-
|
322
|
-
BookReader.prototype.BRSearchCallback = function (results, options) {
|
323
|
-
this.searchResults = results;
|
324
|
-
this.updateSearchHilites();
|
325
|
-
this.removeProgressPopup();
|
326
|
-
|
327
|
-
if (options.goToFirstResult) {
|
328
|
-
this._searchPluginGoToResult(results.matches[0].par[0].page);
|
329
|
-
}
|
330
|
-
|
331
|
-
this.trigger('SearchCallback', {
|
332
|
-
results: results,
|
333
|
-
options: options,
|
334
|
-
instance: this
|
335
|
-
});
|
336
|
-
};
|
337
|
-
/**
|
338
|
-
* Main search results error handler
|
339
|
-
* @callback
|
340
|
-
* @param {SearchInsideResults} results
|
341
|
-
*/
|
342
|
-
|
343
|
-
|
344
|
-
BookReader.prototype.BRSearchCallbackError = function (results) {
|
345
|
-
this._BRSearchCallbackError(results);
|
346
|
-
};
|
347
|
-
/**
|
348
|
-
* @private draws search results error
|
349
|
-
* @callback
|
350
|
-
* @param {SearchInsideResults} results
|
351
|
-
* @param {jQuery} $el
|
352
|
-
* @param {boolean} fade
|
353
|
-
*/
|
354
|
-
|
355
|
-
|
356
|
-
BookReader.prototype._BRSearchCallbackError = function (results) {
|
357
|
-
this.searchResults = results;
|
358
|
-
var basePayload = {
|
359
|
-
term: this.searchTerm,
|
360
|
-
instance: this
|
361
|
-
};
|
362
|
-
|
363
|
-
if (results.error) {
|
364
|
-
var payload = Object.assign({}, basePayload, {
|
365
|
-
results: results
|
366
|
-
});
|
367
|
-
this.trigger('SearchCallbackError', payload);
|
368
|
-
} else if (0 == results.matches.length) {
|
369
|
-
if (false === results.indexed) {
|
370
|
-
this.trigger('SearchCallbackBookNotIndexed', basePayload);
|
371
|
-
return;
|
372
|
-
}
|
373
|
-
|
374
|
-
this.trigger('SearchCallbackEmpty', basePayload);
|
375
|
-
}
|
376
|
-
};
|
377
|
-
/**
|
378
|
-
* updates search on-page highlights controller
|
379
|
-
*/
|
380
|
-
|
381
|
-
|
382
|
-
BookReader.prototype.updateSearchHilites = function () {
|
383
|
-
if (this.constMode2up == this.mode) {
|
384
|
-
this.updateSearchHilites2UP();
|
385
|
-
return;
|
386
|
-
}
|
387
|
-
|
388
|
-
this.updateSearchHilites1UP();
|
389
|
-
};
|
390
|
-
/**
|
391
|
-
* update search on-page highlights in 1up mode
|
392
|
-
*/
|
393
|
-
|
394
|
-
|
395
|
-
BookReader.prototype.updateSearchHilites1UP = function () {
|
396
|
-
var _this2 = this;
|
397
|
-
|
398
|
-
var results = this.searchResults;
|
399
|
-
if (null == results) return;
|
400
|
-
results.matches.forEach(function (match) {
|
401
|
-
match.par[0].boxes.forEach(function (box) {
|
402
|
-
var pageIndex = _this2.leafNumToIndex(box.page);
|
403
|
-
|
404
|
-
var pageIsInView = jQuery.inArray(pageIndex, _this2.displayedIndices) >= 0;
|
405
|
-
|
406
|
-
if (pageIsInView) {
|
407
|
-
if (!box.div) {
|
408
|
-
//create a div for the search highlight, and stash it in the box object
|
409
|
-
box.div = document.createElement('div');
|
410
|
-
$(box.div).prop('className', 'BookReaderSearchHilite').appendTo(_this2.$(".pagediv".concat(pageIndex)));
|
411
|
-
}
|
412
|
-
|
413
|
-
var page = _this2._models.book.getPage(pageIndex);
|
414
|
-
|
415
|
-
var highlight = {
|
416
|
-
width: _this2._modes.mode1Up.physicalInchesToDisplayPixels((box.r - box.l) / page.ppi),
|
417
|
-
height: _this2._modes.mode1Up.physicalInchesToDisplayPixels((box.b - box.t) / page.ppi),
|
418
|
-
left: _this2._modes.mode1Up.physicalInchesToDisplayPixels(box.l / page.ppi),
|
419
|
-
top: _this2._modes.mode1Up.physicalInchesToDisplayPixels(box.t / page.ppi)
|
420
|
-
};
|
421
|
-
$(box.div).css(highlight);
|
422
|
-
} else {
|
423
|
-
if (box.div) {
|
424
|
-
$(box.div).remove();
|
425
|
-
box.div = null;
|
426
|
-
}
|
427
|
-
}
|
428
|
-
});
|
429
|
-
});
|
430
|
-
};
|
431
|
-
/**
|
432
|
-
* update search on-page highlights in 2up mode
|
433
|
-
*/
|
434
|
-
|
435
|
-
|
436
|
-
BookReader.prototype.updateSearchHilites2UP = function () {
|
437
|
-
var _this3 = this;
|
438
|
-
|
439
|
-
var results = this.searchResults;
|
440
|
-
if (results === null) return;
|
441
|
-
var matches = results.matches;
|
442
|
-
matches.forEach(function (match) {
|
443
|
-
match.par[0].boxes.forEach(function (box) {
|
444
|
-
var pageIndex = _this3.leafNumToIndex(match.par[0].page);
|
445
|
-
|
446
|
-
var pageIsInView = jQuery.inArray(pageIndex, _this3.displayedIndices) >= 0;
|
447
|
-
|
448
|
-
var _this3$_models$book$g = _this3._models.book.getPage(pageIndex),
|
449
|
-
isViewable = _this3$_models$book$g.isViewable;
|
450
|
-
|
451
|
-
if (pageIsInView && isViewable) {
|
452
|
-
if (!box.div) {
|
453
|
-
//create a div for the search highlight, and stash it in the box object
|
454
|
-
box.div = document.createElement('div');
|
455
|
-
$(box.div).addClass('BookReaderSearchHilite').appendTo(_this3.refs.$brTwoPageView);
|
456
|
-
}
|
457
|
-
|
458
|
-
_this3.setHilightCss2UP(box.div, pageIndex, box.l, box.r, box.t, box.b);
|
459
|
-
} else {
|
460
|
-
// clear stale reference
|
461
|
-
if (box.div) {
|
462
|
-
$(box.div).remove();
|
463
|
-
box.div = null;
|
464
|
-
}
|
465
|
-
}
|
466
|
-
});
|
467
|
-
});
|
468
|
-
};
|
469
|
-
/**
|
470
|
-
* remove search highlights
|
471
|
-
*/
|
472
|
-
|
473
|
-
|
474
|
-
BookReader.prototype.removeSearchHilites = function () {
|
475
|
-
var results = this.searchResults;
|
476
|
-
|
477
|
-
if (null == results || !results.matches) {
|
478
|
-
return;
|
479
|
-
}
|
480
|
-
|
481
|
-
results.matches.forEach(function (match) {
|
482
|
-
match.par[0].boxes.forEach(function (box) {
|
483
|
-
if (null != box.div) {
|
484
|
-
$(box.div).remove();
|
485
|
-
box.div = null;
|
486
|
-
}
|
487
|
-
});
|
488
|
-
});
|
489
|
-
};
|
490
|
-
/**
|
491
|
-
* @private
|
492
|
-
* Goes to the page specified. If the page is not viewable, tries to load the page
|
493
|
-
* FIXME Most of this logic is IA specific, and should be less integrated into here
|
494
|
-
* or at least more configurable.
|
495
|
-
* @param {PageIndex} pageIndex
|
496
|
-
*/
|
497
|
-
|
498
|
-
|
499
|
-
BookReader.prototype._searchPluginGoToResult = /*#__PURE__*/function () {
|
500
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(pageIndex) {
|
501
|
-
var book, page, makeUnviewableAtEnd, resp, _iterator, _step, leafNum;
|
502
|
-
|
503
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
504
|
-
while (1) {
|
505
|
-
switch (_context.prev = _context.next) {
|
506
|
-
case 0:
|
507
|
-
book = this._models.book;
|
508
|
-
page = book.getPage(pageIndex);
|
509
|
-
makeUnviewableAtEnd = false;
|
510
|
-
|
511
|
-
if (page.isViewable) {
|
512
|
-
_context.next = 10;
|
513
|
-
break;
|
514
|
-
}
|
515
|
-
|
516
|
-
_context.next = 6;
|
517
|
-
return fetch('/services/bookreader/request_page?' + new URLSearchParams({
|
518
|
-
id: this.options.bookId,
|
519
|
-
subprefix: this.options.subPrefix,
|
520
|
-
leafNum: page.leafNum
|
521
|
-
})).then(function (r) {
|
522
|
-
return r.json();
|
523
|
-
});
|
524
|
-
|
525
|
-
case 6:
|
526
|
-
resp = _context.sent;
|
527
|
-
_iterator = _createForOfIteratorHelper(resp.value);
|
528
|
-
|
529
|
-
try {
|
530
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
531
|
-
leafNum = _step.value;
|
532
|
-
book.getPage(book.leafNumToIndex(leafNum)).makeViewable();
|
533
|
-
} // not able to show page; make the page viewable anyways so that it can
|
534
|
-
// actually open. On IA, it has a fallback to a special error page.
|
535
|
-
|
536
|
-
} catch (err) {
|
537
|
-
_iterator.e(err);
|
538
|
-
} finally {
|
539
|
-
_iterator.f();
|
540
|
-
}
|
541
|
-
|
542
|
-
if (!resp.value.length) {
|
543
|
-
book.getPage(pageIndex).makeViewable();
|
544
|
-
makeUnviewableAtEnd = true;
|
545
|
-
}
|
546
|
-
|
547
|
-
case 10:
|
548
|
-
/* this updates the URL */
|
549
|
-
this.suppressFragmentChange = false;
|
550
|
-
this.jumpToIndex(pageIndex); // Reset it to unviewable if it wasn't resolved
|
551
|
-
|
552
|
-
if (makeUnviewableAtEnd) {
|
553
|
-
book.getPage(pageIndex).makeViewable(false);
|
554
|
-
}
|
555
|
-
|
556
|
-
case 13:
|
557
|
-
case "end":
|
558
|
-
return _context.stop();
|
559
|
-
}
|
560
|
-
}
|
561
|
-
}, _callee, this);
|
562
|
-
}));
|
563
|
-
|
564
|
-
return function (_x) {
|
565
|
-
return _ref.apply(this, arguments);
|
566
|
-
};
|
567
|
-
}();
|
568
|
-
/**
|
569
|
-
* Removes all search pins
|
570
|
-
*/
|
571
|
-
|
572
|
-
|
573
|
-
BookReader.prototype.removeSearchResults = function () {
|
574
|
-
var suppressFragmentChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
575
|
-
this.removeSearchHilites(); //be sure to set all box.divs to null
|
576
|
-
|
577
|
-
this.searchTerm = null;
|
578
|
-
this.searchResults = null;
|
579
|
-
|
580
|
-
if (!suppressFragmentChange) {
|
581
|
-
this.trigger(BookReader.eventNames.fragmentChange);
|
582
|
-
}
|
583
|
-
};
|
584
|
-
/**
|
585
|
-
* Returns true if a search highlight is currently being displayed
|
586
|
-
* @returns {boolean}
|
587
|
-
*/
|
588
|
-
|
589
|
-
|
590
|
-
BookReader.prototype.searchHighlightVisible = function () {
|
591
|
-
var _this4 = this;
|
592
|
-
|
593
|
-
var results = this.searchResults;
|
594
|
-
var visiblePages = [];
|
595
|
-
if (null == results) return false;
|
596
|
-
|
597
|
-
if (this.constMode2up == this.mode) {
|
598
|
-
visiblePages = [this.twoPage.currentIndexL, this.twoPage.currentIndexR];
|
599
|
-
} else if (this.constMode1up == this.mode) {
|
600
|
-
visiblePages = [this.currentIndex()];
|
601
|
-
} else {
|
602
|
-
return false;
|
603
|
-
}
|
604
|
-
|
605
|
-
results.matches.some(function (match) {
|
606
|
-
return match.par[0].boxes.some(function (box) {
|
607
|
-
var pageIndex = _this4.leafNumToIndex(box.page);
|
608
|
-
|
609
|
-
if (jQuery.inArray(pageIndex, visiblePages) >= 0) {
|
610
|
-
return true;
|
611
|
-
}
|
612
|
-
});
|
613
|
-
});
|
614
|
-
return false;
|
615
|
-
};
|
616
|
-
|
617
|
-
/***/ }),
|
618
|
-
|
619
|
-
/***/ "./src/plugins/search/view.js":
|
620
|
-
/*!************************************!*\
|
621
|
-
!*** ./src/plugins/search/view.js ***!
|
622
|
-
\************************************/
|
623
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
624
|
-
|
625
|
-
"use strict";
|
626
|
-
__webpack_require__.r(__webpack_exports__);
|
627
|
-
/* harmony import */ var core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.regexp.constructor.js */ "./node_modules/core-js/modules/es.regexp.constructor.js");
|
628
|
-
/* harmony import */ var core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_0__);
|
629
|
-
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "./node_modules/core-js/modules/es.regexp.exec.js");
|
630
|
-
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1__);
|
631
|
-
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ "./node_modules/core-js/modules/es.regexp.to-string.js");
|
632
|
-
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_2__);
|
633
|
-
/* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.array.concat.js */ "./node_modules/core-js/modules/es.array.concat.js");
|
634
|
-
/* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_3__);
|
635
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.string.replace.js */ "./node_modules/core-js/modules/es.string.replace.js");
|
636
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_4__);
|
637
|
-
/* harmony import */ var core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/es.array.map.js */ "./node_modules/core-js/modules/es.array.map.js");
|
638
|
-
/* harmony import */ var core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_5__);
|
639
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.array.slice.js */ "./node_modules/core-js/modules/es.array.slice.js");
|
640
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_6__);
|
641
|
-
/* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/es.array.find.js */ "./node_modules/core-js/modules/es.array.find.js");
|
642
|
-
/* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_7__);
|
643
|
-
/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.array.join.js */ "./node_modules/core-js/modules/es.array.join.js");
|
644
|
-
/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_8__);
|
645
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ "./node_modules/core-js/modules/web.dom-collections.for-each.js");
|
646
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_9__);
|
647
|
-
/* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.string.search.js */ "./node_modules/core-js/modules/es.string.search.js");
|
648
|
-
/* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_10__);
|
649
|
-
/* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery");
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
663
|
-
|
664
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
665
|
-
|
666
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
667
|
-
|
668
|
-
var SearchView = /*#__PURE__*/function () {
|
669
|
-
/**
|
670
|
-
* @param {object} params
|
671
|
-
* @param {string} params.selector A selector for the element that the search tray will be rendered in
|
672
|
-
* @param {string} params.query An existing query string
|
673
|
-
* @param {object} params.br The BookReader instance
|
674
|
-
*
|
675
|
-
* @event BookReader:SearchResultsCleared - when the search results nav gets cleared
|
676
|
-
* @event BookReader:ToggleSearchMenu - when search results menu should toggle
|
677
|
-
*/
|
678
|
-
function SearchView(params) {
|
679
|
-
_classCallCheck(this, SearchView);
|
680
|
-
|
681
|
-
if (!params.selector) {
|
682
|
-
console.warn('BookReader::Search - SearchView must be passed a valid CSS selector');
|
683
|
-
return;
|
684
|
-
}
|
685
|
-
|
686
|
-
this.br = params.br; // Search results are returned as a text blob with the hits wrapped in
|
687
|
-
// triple mustaches. Hits occasionally include text beyond the search
|
688
|
-
// term, so everything within the staches is captured and wrapped.
|
689
|
-
|
690
|
-
this.matcher = new RegExp('{{{(.+?)}}}', 'g');
|
691
|
-
this.matches = [];
|
692
|
-
this.cacheDOMElements(params.selector);
|
693
|
-
this.bindEvents();
|
694
|
-
}
|
695
|
-
/**
|
696
|
-
* @param {string} selector A selector for the element that the search tray will be rendered in
|
697
|
-
*/
|
698
|
-
|
699
|
-
|
700
|
-
_createClass(SearchView, [{
|
701
|
-
key: "cacheDOMElements",
|
702
|
-
value: function cacheDOMElements(selector) {
|
703
|
-
this.dom = {}; // The parent search tray in mobile menu
|
704
|
-
|
705
|
-
this.dom.searchTray = this.renderSearchTray(selector); // Container for rendered search results
|
706
|
-
|
707
|
-
this.dom.results = this.dom.searchTray.querySelector('[data-id="results"]'); // Element used to display number of results
|
708
|
-
|
709
|
-
this.dom.resultsCount = this.dom.searchTray.querySelector('[data-id="results_count"]'); // Search input within the mobile search tray
|
710
|
-
|
711
|
-
this.dom.searchField = this.dom.searchTray.querySelector('[name="query"]'); // Waiting indicator displayed while waiting for a search request
|
712
|
-
|
713
|
-
this.dom.searchPending = this.dom.searchTray.querySelector('[data-id="searchPending"]'); // The element added to the mobile menu that is animated into view when
|
714
|
-
// the "search" nav item is clicked
|
715
|
-
|
716
|
-
this.dom.mobileSearch = this.buildMobileDrawer(); // Search input within the top toolbar. Will be removed once the mobile menu is replaced.
|
717
|
-
|
718
|
-
this.dom.toolbarSearch = this.buildToolbarSearch();
|
719
|
-
}
|
720
|
-
/**
|
721
|
-
* @param {boolean} bool
|
722
|
-
*/
|
723
|
-
|
724
|
-
}, {
|
725
|
-
key: "toggleSearchTray",
|
726
|
-
value: function toggleSearchTray() {
|
727
|
-
var bool = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.dom.searchTray.classList.contains('hidden');
|
728
|
-
this.dom.searchTray.classList.toggle('hidden', !bool);
|
729
|
-
}
|
730
|
-
/**
|
731
|
-
* @param {boolean} bool
|
732
|
-
*/
|
733
|
-
|
734
|
-
}, {
|
735
|
-
key: "toggleResultsCount",
|
736
|
-
value: function toggleResultsCount(bool) {
|
737
|
-
this.dom.resultsCount.classList.toggle('visible', bool);
|
738
|
-
}
|
739
|
-
/**
|
740
|
-
* @param {SearchInsideResults} results
|
741
|
-
*/
|
742
|
-
|
743
|
-
}, {
|
744
|
-
key: "updateResultsCount",
|
745
|
-
value: function updateResultsCount(results) {
|
746
|
-
this.dom.resultsCount.innerText = "(".concat(results, " result").concat(results != 1 ? 's' : '', ")");
|
747
|
-
this.toggleResultsCount(true);
|
748
|
-
}
|
749
|
-
/**
|
750
|
-
* @param {string} query
|
751
|
-
*/
|
752
|
-
|
753
|
-
}, {
|
754
|
-
key: "setQuery",
|
755
|
-
value: function setQuery(query) {
|
756
|
-
this.br.$('[name="query"]').val(query);
|
757
|
-
}
|
758
|
-
}, {
|
759
|
-
key: "emptyMatches",
|
760
|
-
value: function emptyMatches() {
|
761
|
-
this.dom.results.innerHTML = '';
|
762
|
-
this.matches = [];
|
763
|
-
}
|
764
|
-
}, {
|
765
|
-
key: "removeResultPins",
|
766
|
-
value: function removeResultPins() {
|
767
|
-
this.br.$('.BRnavpos .BRsearch').remove();
|
768
|
-
}
|
769
|
-
}, {
|
770
|
-
key: "clearSearchFieldAndResults",
|
771
|
-
value: function clearSearchFieldAndResults() {
|
772
|
-
this.br.removeSearchResults();
|
773
|
-
this.toggleResultsCount(false);
|
774
|
-
this.removeResultPins();
|
775
|
-
this.emptyMatches();
|
776
|
-
this.setQuery('');
|
777
|
-
this.teardownSearchNavigation();
|
778
|
-
this.br.trigger('SearchResultsCleared');
|
779
|
-
}
|
780
|
-
}, {
|
781
|
-
key: "toggleSidebar",
|
782
|
-
value: function toggleSidebar() {
|
783
|
-
this.br.trigger('ToggleSearchMenu');
|
784
|
-
}
|
785
|
-
/**
|
786
|
-
* @param {string} selector The ID attribute to be used for the search tray
|
787
|
-
*/
|
788
|
-
|
789
|
-
}, {
|
790
|
-
key: "renderSearchTray",
|
791
|
-
value: function renderSearchTray(selector) {
|
792
|
-
var searchTray = document.createElement('div');
|
793
|
-
searchTray.setAttribute('id', selector.replace(/^#/, ''));
|
794
|
-
searchTray.innerHTML = "\n <header>\n <div>\n <h3>Search inside</h3>\n <p data-id=\"results_count\"></p>\n </div>\n <a href=\"#\" class=\"close\"></a>\n </header>\n <form action=\"\" method=\"get\">\n <fieldset>\n <input name=\"all_files\" id=\"all_files\" type=\"checkbox\" />\n <label class=\"checkbox\" for=\"all_files\">Search all files</label>\n <input type=\"search\" name=\"query\" placeholder=\"Enter a search term\" />\n </fieldset>\n </form>\n <div data-id=\"searchPending\" id=\"search_pending\">\n <p>Your search results will appear below</p>\n <div class=\"loader tc mt20\"></div>\n </div>\n <ul data-id=\"results\"></ul>\n ";
|
795
|
-
return searchTray;
|
796
|
-
}
|
797
|
-
}, {
|
798
|
-
key: "renderSearchNavigation",
|
799
|
-
value: function renderSearchNavigation() {
|
800
|
-
var selector = 'BRsearch-navigation';
|
801
|
-
$('.BRnav').before("\n <div class=\"".concat(selector, "\">\n <button class=\"toggle-sidebar\">\n <h4>\n <span class=\"icon icon-search\"></span> Results\n </h4>\n </button>\n <div class=\"pagination\">\n <button class=\"prev\" title=\"Previous result\"><span class=\"icon icon-chevron hflip\"></span></button>\n <span data-id=\"resultsCount\">").concat(this.resultsPosition(), "</span>\n <button class=\"next\" title=\"Next result\"><span class=\"icon icon-chevron\"></button>\n </div>\n <button class=\"clear\" title=\"Clear search results\">\n <span class=\"icon icon-close\"></span>\n </button>\n </div>\n "));
|
802
|
-
this.dom.searchNavigation = $(".".concat(selector));
|
803
|
-
}
|
804
|
-
}, {
|
805
|
-
key: "resultsPosition",
|
806
|
-
value: function resultsPosition() {
|
807
|
-
var positionMessage = "".concat(this.matches.length, " result").concat(this.matches.length === 1 ? '' : 's');
|
808
|
-
|
809
|
-
if (~this.currentMatchIndex) {
|
810
|
-
positionMessage = "".concat(this.currentMatchIndex + 1, " / ").concat(this.matches.length);
|
811
|
-
}
|
812
|
-
|
813
|
-
return positionMessage;
|
814
|
-
}
|
815
|
-
}, {
|
816
|
-
key: "bindSearchNavigationEvents",
|
817
|
-
value: function bindSearchNavigationEvents() {
|
818
|
-
if (!this.dom.searchNavigation) {
|
819
|
-
return;
|
820
|
-
}
|
821
|
-
|
822
|
-
var namespace = 'searchNavigation';
|
823
|
-
this.dom.searchNavigation.on("click.".concat(namespace), '.clear', this.clearSearchFieldAndResults.bind(this)).on("click.".concat(namespace), '.prev', this.showPrevResult.bind(this)).on("click.".concat(namespace), '.next', this.showNextResult.bind(this)).on("click.".concat(namespace), '.toggle-sidebar', this.toggleSidebar.bind(this)).on("click.".concat(namespace), false);
|
824
|
-
}
|
825
|
-
}, {
|
826
|
-
key: "showPrevResult",
|
827
|
-
value: function showPrevResult() {
|
828
|
-
if (this.currentMatchIndex === 0) {
|
829
|
-
return;
|
830
|
-
}
|
831
|
-
|
832
|
-
if (this.br.mode === this.br.constModeThumb) {
|
833
|
-
this.br.switchMode(this.br.constMode1up);
|
834
|
-
}
|
835
|
-
|
836
|
-
if (!~this.currentMatchIndex) {
|
837
|
-
this.currentMatchIndex = this.getClosestMatchIndex(function (start, end, comparator) {
|
838
|
-
return end[0] > comparator;
|
839
|
-
}) + 1;
|
840
|
-
}
|
841
|
-
|
842
|
-
this.br.$('.BRnavline .BRsearch').eq(--this.currentMatchIndex).click();
|
843
|
-
this.updateResultsPosition();
|
844
|
-
this.updateSearchNavigationButtons();
|
845
|
-
}
|
846
|
-
}, {
|
847
|
-
key: "showNextResult",
|
848
|
-
value: function showNextResult() {
|
849
|
-
if (this.currentMatchIndex + 1 === this.matches.length) {
|
850
|
-
return;
|
851
|
-
}
|
852
|
-
|
853
|
-
if (this.br.mode === this.br.constModeThumb) {
|
854
|
-
this.br.switchMode(this.br.constMode1up);
|
855
|
-
}
|
856
|
-
|
857
|
-
if (!~this.currentMatchIndex) {
|
858
|
-
this.currentMatchIndex = this.getClosestMatchIndex(function (start, end, comparator) {
|
859
|
-
return start[start.length - 1] > comparator;
|
860
|
-
}) - 1;
|
861
|
-
}
|
862
|
-
|
863
|
-
this.br.$('.BRnavline .BRsearch').eq(++this.currentMatchIndex).click();
|
864
|
-
this.updateResultsPosition();
|
865
|
-
this.updateSearchNavigationButtons();
|
866
|
-
}
|
867
|
-
/**
|
868
|
-
* Obtains closest match based on the logical comparison function passed in.
|
869
|
-
* When the comparison function returns true, the starting (left) half of the
|
870
|
-
* matches array is used in the binary split, else the ending (right) half is
|
871
|
-
* used. A recursive call is made to perform the same split and comparison
|
872
|
-
* on the winning half of the matches. This is traditionally known as binary
|
873
|
-
* search (https://en.wikipedia.org/wiki/Binary_search_algorithm), and in
|
874
|
-
* most cases (medium to large search result arrays) should outperform
|
875
|
-
* traversing the array from start to finish. In the case of small arrays,
|
876
|
-
* the speed difference is negligible.
|
877
|
-
*
|
878
|
-
* @param {function} comparisonFn
|
879
|
-
* @return {number} matchIndex
|
880
|
-
*/
|
881
|
-
|
882
|
-
}, {
|
883
|
-
key: "getClosestMatchIndex",
|
884
|
-
value: function getClosestMatchIndex(comparisonFn) {
|
885
|
-
var matchPages = this.matches.map(function (m) {
|
886
|
-
return m.par[0].page;
|
887
|
-
});
|
888
|
-
var currentPage = this.br.currentIndex() + 1;
|
889
|
-
|
890
|
-
var closestTo = function closestTo(pool, comparator) {
|
891
|
-
if (pool.length === 1) {
|
892
|
-
return pool[0];
|
893
|
-
}
|
894
|
-
|
895
|
-
var start = pool.slice(0, pool.length / 2);
|
896
|
-
var end = pool.slice(pool.length / 2);
|
897
|
-
return closestTo(comparisonFn(start, end, comparator) ? start : end, comparator);
|
898
|
-
};
|
899
|
-
|
900
|
-
var closestPage = closestTo(matchPages, currentPage);
|
901
|
-
return this.matches.indexOf(this.matches.find(function (m) {
|
902
|
-
return m.par[0].page === closestPage;
|
903
|
-
}));
|
904
|
-
}
|
905
|
-
}, {
|
906
|
-
key: "updateResultsPosition",
|
907
|
-
value: function updateResultsPosition() {
|
908
|
-
this.dom.searchNavigation.find('[data-id=resultsCount]').text(this.resultsPosition());
|
909
|
-
}
|
910
|
-
}, {
|
911
|
-
key: "updateSearchNavigationButtons",
|
912
|
-
value: function updateSearchNavigationButtons() {
|
913
|
-
this.dom.searchNavigation.find('.prev').attr('disabled', !this.currentMatchIndex);
|
914
|
-
this.dom.searchNavigation.find('.next').attr('disabled', this.currentMatchIndex + 1 === this.matches.length);
|
915
|
-
}
|
916
|
-
}, {
|
917
|
-
key: "teardownSearchNavigation",
|
918
|
-
value: function teardownSearchNavigation() {
|
919
|
-
if (!this.dom.searchNavigation) {
|
920
|
-
this.dom.searchNavigation = $('.BRsearch-navigation');
|
921
|
-
}
|
922
|
-
|
923
|
-
if (!this.dom.searchNavigation.length) {
|
924
|
-
return;
|
925
|
-
}
|
926
|
-
|
927
|
-
this.dom.searchNavigation.off('.searchNavigation').remove();
|
928
|
-
this.dom.searchNavigation = null;
|
929
|
-
this.br.resize();
|
930
|
-
}
|
931
|
-
}, {
|
932
|
-
key: "setCurrentMatchIndex",
|
933
|
-
value: function setCurrentMatchIndex() {
|
934
|
-
var matchingSearchResult;
|
935
|
-
|
936
|
-
if (this.br.mode === this.br.constModeThumb) {
|
937
|
-
this.currentMatchIndex = -1;
|
938
|
-
return;
|
939
|
-
}
|
940
|
-
|
941
|
-
if (this.br.mode === this.br.constMode2up) {
|
942
|
-
matchingSearchResult = this.find2upMatchingSearchResult();
|
943
|
-
} else {
|
944
|
-
matchingSearchResult = this.find1upMatchingSearchResult();
|
945
|
-
}
|
946
|
-
|
947
|
-
this.currentMatchIndex = this.matches.indexOf(matchingSearchResult);
|
948
|
-
}
|
949
|
-
}, {
|
950
|
-
key: "find1upMatchingSearchResult",
|
951
|
-
value: function find1upMatchingSearchResult() {
|
952
|
-
var _this = this;
|
953
|
-
|
954
|
-
return this.matches.find(function (m) {
|
955
|
-
return _this.br.currentIndex() === m.par[0].page - 1;
|
956
|
-
});
|
957
|
-
}
|
958
|
-
}, {
|
959
|
-
key: "find2upMatchingSearchResult",
|
960
|
-
value: function find2upMatchingSearchResult() {
|
961
|
-
var _this2 = this;
|
962
|
-
|
963
|
-
return this.matches.find(function (m) {
|
964
|
-
return _this2.br._isIndexDisplayed(m.par[0].page - 1);
|
965
|
-
});
|
966
|
-
}
|
967
|
-
}, {
|
968
|
-
key: "updateSearchNavigation",
|
969
|
-
value: function updateSearchNavigation() {
|
970
|
-
if (!this.matches.length) {
|
971
|
-
return;
|
972
|
-
}
|
973
|
-
|
974
|
-
this.setCurrentMatchIndex();
|
975
|
-
this.updateResultsPosition();
|
976
|
-
this.updateSearchNavigationButtons();
|
977
|
-
}
|
978
|
-
/**
|
979
|
-
* @param {array} matches
|
980
|
-
*/
|
981
|
-
|
982
|
-
}, {
|
983
|
-
key: "renderMatches",
|
984
|
-
value: function renderMatches(matches) {
|
985
|
-
var _this3 = this;
|
986
|
-
|
987
|
-
var items = matches.map(function (match) {
|
988
|
-
return "\n <li data-page=\"".concat(match.par[0].page, "\" data-page-index=\"").concat(_this3.br.leafNumToIndex(match.par[0].page), "\">\n <h4>Page ").concat(match.par[0].page, "</h4>\n <p>").concat(match.text.replace(_this3.matcher, '<mark>$1</mark>'), "</p>\n </li>\n ");
|
989
|
-
});
|
990
|
-
this.dom.results.innerHTML = items.join('');
|
991
|
-
}
|
992
|
-
/**
|
993
|
-
* @param {boolean} bool
|
994
|
-
*/
|
995
|
-
|
996
|
-
}, {
|
997
|
-
key: "togglePinsFor",
|
998
|
-
value: function togglePinsFor(bool) {
|
999
|
-
var pinsVisibleState = bool ? 'visible' : 'hidden';
|
1000
|
-
this.br.refs.$BRfooter.find('.BRsearch').css({
|
1001
|
-
visibility: pinsVisibleState
|
1002
|
-
});
|
1003
|
-
}
|
1004
|
-
}, {
|
1005
|
-
key: "buildMobileDrawer",
|
1006
|
-
value: function buildMobileDrawer() {
|
1007
|
-
var mobileSearch = document.createElement('li');
|
1008
|
-
mobileSearch.innerHTML = "\n <span>\n <span class=\"DrawerIconWrapper\">\n <img class=\"DrawerIcon\" src=\"".concat(this.br.imagesBaseURL, "icon_search_button.svg\" />\n </span>\n Search\n </span>\n <div data-id=\"search_slot\">\n </div>\n ");
|
1009
|
-
mobileSearch.querySelector('[data-id="search_slot"]').appendChild(this.dom.searchTray);
|
1010
|
-
mobileSearch.classList.add('BRmobileMenu__search');
|
1011
|
-
return mobileSearch;
|
1012
|
-
}
|
1013
|
-
}, {
|
1014
|
-
key: "buildToolbarSearch",
|
1015
|
-
value: function buildToolbarSearch() {
|
1016
|
-
var toolbarSearch = document.createElement('span');
|
1017
|
-
toolbarSearch.classList.add('BRtoolbarSection', 'BRtoolbarSectionSearch');
|
1018
|
-
toolbarSearch.innerHTML = "\n <form class=\"BRbooksearch desktop\">\n <input type=\"search\" name=\"query\" class=\"BRsearchInput\" value=\"\" placeholder=\"Search inside\"/>\n <button type=\"submit\" class=\"BRsearchSubmit\">\n <img src=\"".concat(this.br.imagesBaseURL, "icon_search_button.svg\" />\n </button>\n </form>\n ");
|
1019
|
-
return toolbarSearch;
|
1020
|
-
}
|
1021
|
-
/**
|
1022
|
-
* @param {array} matches
|
1023
|
-
*/
|
1024
|
-
|
1025
|
-
}, {
|
1026
|
-
key: "renderPins",
|
1027
|
-
value: function renderPins(matches) {
|
1028
|
-
var _this4 = this;
|
1029
|
-
|
1030
|
-
matches.forEach(function (match) {
|
1031
|
-
var queryString = match.text;
|
1032
|
-
|
1033
|
-
var pageIndex = _this4.br.leafNumToIndex(match.par[0].page);
|
1034
|
-
|
1035
|
-
var pageNumber = _this4.br.getPageNum(pageIndex);
|
1036
|
-
|
1037
|
-
var uiStringSearch = "Search result"; // i18n
|
1038
|
-
|
1039
|
-
var uiStringPage = "Page"; // i18n
|
1040
|
-
|
1041
|
-
var percentThrough = _this4.br.constructor.util.cssPercentage(pageIndex, _this4.br.getNumLeafs() - 1);
|
1042
|
-
|
1043
|
-
var queryStringWithB = queryString.replace(_this4.matcher, '<b>$1</b>');
|
1044
|
-
var queryStringWithBTruncated = '';
|
1045
|
-
|
1046
|
-
if (queryString.length > 100) {
|
1047
|
-
queryStringWithBTruncated = queryString.replace(/^(.{100}[^\s]*).*/, "$1").replace(_this4.matcher, '<b>$1</b>') + '...';
|
1048
|
-
} // draw marker
|
1049
|
-
|
1050
|
-
|
1051
|
-
$('<div>').addClass('BRsearch').css({
|
1052
|
-
left: percentThrough
|
1053
|
-
}).attr('title', uiStringSearch).append("\n <div class=\"BRquery\">\n <div>".concat(queryStringWithBTruncated || queryStringWithB, "</div>\n <div>").concat(uiStringPage, " ").concat(pageNumber, "</div>\n </div>\n ")).data({
|
1054
|
-
pageIndex: pageIndex
|
1055
|
-
}).appendTo(_this4.br.$('.BRnavline')).hover(function (event) {
|
1056
|
-
// remove from other markers then turn on just for this
|
1057
|
-
// XXX should be done when nav slider moves
|
1058
|
-
var marker = event.currentTarget;
|
1059
|
-
var tooltip = marker.querySelector('.BRquery');
|
1060
|
-
var tooltipOffset = tooltip.getBoundingClientRect();
|
1061
|
-
var targetOffset = marker.getBoundingClientRect();
|
1062
|
-
var boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;
|
1063
|
-
|
1064
|
-
if (tooltipOffset.x - boxSizeAdjust < 0) {
|
1065
|
-
tooltip.style.setProperty('transform', "translateX(-".concat(targetOffset.left - boxSizeAdjust, "px)"));
|
1066
|
-
}
|
1067
|
-
|
1068
|
-
$('.BRsearch,.BRchapter').removeClass('front');
|
1069
|
-
$(event.target).addClass('front');
|
1070
|
-
}, function (event) {
|
1071
|
-
return $(event.target).removeClass('front');
|
1072
|
-
}).click(function (event) {
|
1073
|
-
// closures are nested and deep, using an arrow function breaks references.
|
1074
|
-
// Todo: update to arrow function & clean up closures
|
1075
|
-
// to remove `bind` dependency
|
1076
|
-
this.br._searchPluginGoToResult(+$(event.target).data('pageIndex'));
|
1077
|
-
|
1078
|
-
this.br.updateSearchHilites();
|
1079
|
-
}.bind(_this4));
|
1080
|
-
});
|
1081
|
-
}
|
1082
|
-
/**
|
1083
|
-
* @param {boolean} bool
|
1084
|
-
*/
|
1085
|
-
|
1086
|
-
}, {
|
1087
|
-
key: "toggleSearchPending",
|
1088
|
-
value: function toggleSearchPending(bool) {
|
1089
|
-
this.dom.searchPending.classList.toggle('visible', bool);
|
1090
|
-
|
1091
|
-
if (bool) {
|
1092
|
-
this.br.showProgressPopup("Search results will appear below...");
|
1093
|
-
} else {
|
1094
|
-
this.br.removeProgressPopup();
|
1095
|
-
}
|
1096
|
-
}
|
1097
|
-
}, {
|
1098
|
-
key: "renderErrorModal",
|
1099
|
-
value: function renderErrorModal() {
|
1100
|
-
this.renderModalMessage("\n Sorry, there was an error with your search.\n <br />\n The text may still be processing.\n ");
|
1101
|
-
this.delayModalRemovalFor(4000);
|
1102
|
-
}
|
1103
|
-
}, {
|
1104
|
-
key: "renderBookNotIndexedModal",
|
1105
|
-
value: function renderBookNotIndexedModal() {
|
1106
|
-
this.renderModalMessage("\n <p>\n This book hasn't been indexed for searching yet.\n We've just started indexing it, so search should be available soon.\n <br />\n Please try again later. Thanks!\n </p>\n ");
|
1107
|
-
this.delayModalRemovalFor(5000);
|
1108
|
-
}
|
1109
|
-
}, {
|
1110
|
-
key: "renderResultsEmptyModal",
|
1111
|
-
value: function renderResultsEmptyModal() {
|
1112
|
-
this.renderModalMessage('No matches were found.');
|
1113
|
-
this.delayModalRemovalFor(2000);
|
1114
|
-
}
|
1115
|
-
/**
|
1116
|
-
* @param {string} messageHTML The innerHTML string used to popupate the modal contents
|
1117
|
-
*/
|
1118
|
-
|
1119
|
-
}, {
|
1120
|
-
key: "renderModalMessage",
|
1121
|
-
value: function renderModalMessage(messageHTML) {
|
1122
|
-
var modal = document.createElement('div');
|
1123
|
-
modal.classList.add('BRprogresspopup', 'search_modal');
|
1124
|
-
modal.innerHTML = messageHTML;
|
1125
|
-
document.querySelector(this.br.el).append(modal);
|
1126
|
-
}
|
1127
|
-
/**
|
1128
|
-
* @param {number} timeoutMS
|
1129
|
-
*/
|
1130
|
-
|
1131
|
-
}, {
|
1132
|
-
key: "delayModalRemovalFor",
|
1133
|
-
value: function delayModalRemovalFor(timeoutMS) {
|
1134
|
-
setTimeout(this.br.removeProgressPopup.bind(this.br), timeoutMS);
|
1135
|
-
}
|
1136
|
-
}, {
|
1137
|
-
key: "openMobileMenu",
|
1138
|
-
value: function openMobileMenu() {
|
1139
|
-
this.br.refs.$mmenu.data('mmenu').open();
|
1140
|
-
}
|
1141
|
-
}, {
|
1142
|
-
key: "closeMobileMenu",
|
1143
|
-
value: function closeMobileMenu() {
|
1144
|
-
this.br.refs.$mmenu.data('mmenu').close();
|
1145
|
-
}
|
1146
|
-
/**
|
1147
|
-
* @param {Event} e
|
1148
|
-
*/
|
1149
|
-
|
1150
|
-
}, {
|
1151
|
-
key: "submitHandler",
|
1152
|
-
value: function submitHandler(e) {
|
1153
|
-
e.preventDefault();
|
1154
|
-
var query = e.target.querySelector('[name="query"]').value;
|
1155
|
-
|
1156
|
-
if (!query.length) {
|
1157
|
-
return false;
|
1158
|
-
}
|
1159
|
-
|
1160
|
-
this.br.search(query);
|
1161
|
-
this.dom.searchField.blur();
|
1162
|
-
this.emptyMatches();
|
1163
|
-
this.toggleSearchPending(true);
|
1164
|
-
return false;
|
1165
|
-
}
|
1166
|
-
/**
|
1167
|
-
* @param {Event} e
|
1168
|
-
* @param {object} properties
|
1169
|
-
* @param {object} properties.results
|
1170
|
-
* @param {object} properties.options
|
1171
|
-
*/
|
1172
|
-
|
1173
|
-
}, {
|
1174
|
-
key: "handleSearchCallback",
|
1175
|
-
value: function handleSearchCallback(e, _ref) {
|
1176
|
-
var _this5 = this;
|
1177
|
-
|
1178
|
-
var results = _ref.results,
|
1179
|
-
options = _ref.options;
|
1180
|
-
this.matches = results.matches;
|
1181
|
-
this.setCurrentMatchIndex();
|
1182
|
-
this.teardownSearchNavigation();
|
1183
|
-
this.renderSearchNavigation();
|
1184
|
-
this.bindSearchNavigationEvents();
|
1185
|
-
this.renderMatches(results.matches);
|
1186
|
-
this.renderPins(results.matches);
|
1187
|
-
this.updateResultsCount(results.matches.length);
|
1188
|
-
this.toggleSearchPending(false);
|
1189
|
-
|
1190
|
-
if (options.goToFirstResult) {
|
1191
|
-
$(document).one('BookReader:pageChanged', function () {
|
1192
|
-
_this5.br.resize();
|
1193
|
-
});
|
1194
|
-
} else {
|
1195
|
-
this.br.resize();
|
1196
|
-
}
|
1197
|
-
}
|
1198
|
-
/**
|
1199
|
-
* @param {Event} e
|
1200
|
-
*/
|
1201
|
-
|
1202
|
-
}, {
|
1203
|
-
key: "handleNavToggledCallback",
|
1204
|
-
value: function handleNavToggledCallback(e) {
|
1205
|
-
var is_visible = this.br.navigationIsVisible();
|
1206
|
-
this.togglePinsFor(is_visible);
|
1207
|
-
this.toggleSearchTray(is_visible ? !!this.dom.results.querySelector('li') : false);
|
1208
|
-
}
|
1209
|
-
}, {
|
1210
|
-
key: "handleSearchStarted",
|
1211
|
-
value: function handleSearchStarted() {
|
1212
|
-
this.emptyMatches();
|
1213
|
-
this.br.removeSearchHilites();
|
1214
|
-
this.removeResultPins();
|
1215
|
-
this.toggleSearchPending(true);
|
1216
|
-
this.teardownSearchNavigation();
|
1217
|
-
this.setQuery(this.br.searchTerm);
|
1218
|
-
}
|
1219
|
-
}, {
|
1220
|
-
key: "handleSearchCallbackError",
|
1221
|
-
value: function handleSearchCallbackError() {
|
1222
|
-
this.toggleSearchPending(false);
|
1223
|
-
this.renderErrorModal();
|
1224
|
-
}
|
1225
|
-
}, {
|
1226
|
-
key: "handleSearchCallbackBookNotIndexed",
|
1227
|
-
value: function handleSearchCallbackBookNotIndexed() {
|
1228
|
-
this.toggleSearchPending(false);
|
1229
|
-
this.renderBookNotIndexedModal();
|
1230
|
-
}
|
1231
|
-
}, {
|
1232
|
-
key: "handleSearchCallbackEmpty",
|
1233
|
-
value: function handleSearchCallbackEmpty() {
|
1234
|
-
this.toggleSearchPending(false);
|
1235
|
-
this.renderResultsEmptyModal();
|
1236
|
-
}
|
1237
|
-
}, {
|
1238
|
-
key: "bindEvents",
|
1239
|
-
value: function bindEvents() {
|
1240
|
-
var _this6 = this;
|
1241
|
-
|
1242
|
-
var namespace = 'BookReader:';
|
1243
|
-
$(document).on("".concat(namespace, "SearchCallback"), this.handleSearchCallback.bind(this)).on("".concat(namespace, "navToggled"), this.handleNavToggledCallback.bind(this)).on("".concat(namespace, "SearchStarted"), this.handleSearchStarted.bind(this)).on("".concat(namespace, "SearchCallbackError"), this.handleSearchCallbackError.bind(this)).on("".concat(namespace, "SearchCallbackBookNotIndexed"), this.handleSearchCallbackBookNotIndexed.bind(this)).on("".concat(namespace, "SearchCallbackEmpty"), this.handleSearchCallbackEmpty.bind(this)).on("".concat(namespace, "pageChanged"), this.updateSearchNavigation.bind(this));
|
1244
|
-
this.dom.searchTray.addEventListener('submit', this.submitHandler.bind(this));
|
1245
|
-
this.dom.toolbarSearch.querySelector('form').addEventListener('submit', this.submitHandler.bind(this));
|
1246
|
-
this.dom.searchField.addEventListener('search', function () {
|
1247
|
-
if (_this6.dom.searchField.value) {
|
1248
|
-
return;
|
1249
|
-
}
|
1250
|
-
|
1251
|
-
_this6.clearSearchFieldAndResults();
|
1252
|
-
});
|
1253
|
-
$(this.dom.results).on('click', 'li', function (e) {
|
1254
|
-
_this6.br._searchPluginGoToResult(+e.currentTarget.dataset.pageIndex);
|
1255
|
-
|
1256
|
-
_this6.br.updateSearchHilites();
|
1257
|
-
|
1258
|
-
_this6.closeMobileMenu();
|
1259
|
-
});
|
1260
|
-
}
|
1261
|
-
}]);
|
1262
|
-
|
1263
|
-
return SearchView;
|
1264
|
-
}();
|
1265
|
-
|
1266
|
-
/* harmony default export */ __webpack_exports__["default"] = (SearchView);
|
1267
|
-
|
1268
|
-
/***/ }),
|
1269
|
-
|
1270
|
-
/***/ "./node_modules/core-js/internals/inherit-if-required.js":
|
1271
|
-
/*!***************************************************************!*\
|
1272
|
-
!*** ./node_modules/core-js/internals/inherit-if-required.js ***!
|
1273
|
-
\***************************************************************/
|
1274
|
-
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
1275
|
-
|
1276
|
-
var isObject = __webpack_require__(/*! ../internals/is-object */ "./node_modules/core-js/internals/is-object.js");
|
1277
|
-
var setPrototypeOf = __webpack_require__(/*! ../internals/object-set-prototype-of */ "./node_modules/core-js/internals/object-set-prototype-of.js");
|
1278
|
-
|
1279
|
-
// makes subclassing work correct for wrapped built-ins
|
1280
|
-
module.exports = function ($this, dummy, Wrapper) {
|
1281
|
-
var NewTarget, NewTargetPrototype;
|
1282
|
-
if (
|
1283
|
-
// it can work only with native `setPrototypeOf`
|
1284
|
-
setPrototypeOf &&
|
1285
|
-
// we haven't completely correct pre-ES6 way for getting `new.target`, so use this
|
1286
|
-
typeof (NewTarget = dummy.constructor) == 'function' &&
|
1287
|
-
NewTarget !== Wrapper &&
|
1288
|
-
isObject(NewTargetPrototype = NewTarget.prototype) &&
|
1289
|
-
NewTargetPrototype !== Wrapper.prototype
|
1290
|
-
) setPrototypeOf($this, NewTargetPrototype);
|
1291
|
-
return $this;
|
1292
|
-
};
|
1293
|
-
|
1294
|
-
|
1295
|
-
/***/ }),
|
1296
|
-
|
1297
|
-
/***/ "./node_modules/core-js/modules/es.object.assign.js":
|
1298
|
-
/*!**********************************************************!*\
|
1299
|
-
!*** ./node_modules/core-js/modules/es.object.assign.js ***!
|
1300
|
-
\**********************************************************/
|
1301
|
-
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
1302
|
-
|
1303
|
-
var $ = __webpack_require__(/*! ../internals/export */ "./node_modules/core-js/internals/export.js");
|
1304
|
-
var assign = __webpack_require__(/*! ../internals/object-assign */ "./node_modules/core-js/internals/object-assign.js");
|
1305
|
-
|
1306
|
-
// `Object.assign` method
|
1307
|
-
// https://tc39.es/ecma262/#sec-object.assign
|
1308
|
-
// eslint-disable-next-line es/no-object-assign -- required for testing
|
1309
|
-
$({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
|
1310
|
-
assign: assign
|
1311
|
-
});
|
1312
|
-
|
1313
|
-
|
1314
|
-
/***/ }),
|
1315
|
-
|
1316
|
-
/***/ "./node_modules/core-js/modules/es.regexp.constructor.js":
|
1317
|
-
/*!***************************************************************!*\
|
1318
|
-
!*** ./node_modules/core-js/modules/es.regexp.constructor.js ***!
|
1319
|
-
\***************************************************************/
|
1320
|
-
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
1321
|
-
|
1322
|
-
var DESCRIPTORS = __webpack_require__(/*! ../internals/descriptors */ "./node_modules/core-js/internals/descriptors.js");
|
1323
|
-
var global = __webpack_require__(/*! ../internals/global */ "./node_modules/core-js/internals/global.js");
|
1324
|
-
var isForced = __webpack_require__(/*! ../internals/is-forced */ "./node_modules/core-js/internals/is-forced.js");
|
1325
|
-
var inheritIfRequired = __webpack_require__(/*! ../internals/inherit-if-required */ "./node_modules/core-js/internals/inherit-if-required.js");
|
1326
|
-
var defineProperty = __webpack_require__(/*! ../internals/object-define-property */ "./node_modules/core-js/internals/object-define-property.js").f;
|
1327
|
-
var getOwnPropertyNames = __webpack_require__(/*! ../internals/object-get-own-property-names */ "./node_modules/core-js/internals/object-get-own-property-names.js").f;
|
1328
|
-
var isRegExp = __webpack_require__(/*! ../internals/is-regexp */ "./node_modules/core-js/internals/is-regexp.js");
|
1329
|
-
var getFlags = __webpack_require__(/*! ../internals/regexp-flags */ "./node_modules/core-js/internals/regexp-flags.js");
|
1330
|
-
var stickyHelpers = __webpack_require__(/*! ../internals/regexp-sticky-helpers */ "./node_modules/core-js/internals/regexp-sticky-helpers.js");
|
1331
|
-
var redefine = __webpack_require__(/*! ../internals/redefine */ "./node_modules/core-js/internals/redefine.js");
|
1332
|
-
var fails = __webpack_require__(/*! ../internals/fails */ "./node_modules/core-js/internals/fails.js");
|
1333
|
-
var enforceInternalState = __webpack_require__(/*! ../internals/internal-state */ "./node_modules/core-js/internals/internal-state.js").enforce;
|
1334
|
-
var setSpecies = __webpack_require__(/*! ../internals/set-species */ "./node_modules/core-js/internals/set-species.js");
|
1335
|
-
var wellKnownSymbol = __webpack_require__(/*! ../internals/well-known-symbol */ "./node_modules/core-js/internals/well-known-symbol.js");
|
1336
|
-
|
1337
|
-
var MATCH = wellKnownSymbol('match');
|
1338
|
-
var NativeRegExp = global.RegExp;
|
1339
|
-
var RegExpPrototype = NativeRegExp.prototype;
|
1340
|
-
var re1 = /a/g;
|
1341
|
-
var re2 = /a/g;
|
1342
|
-
|
1343
|
-
// "new" should create a new object, old webkit bug
|
1344
|
-
var CORRECT_NEW = new NativeRegExp(re1) !== re1;
|
1345
|
-
|
1346
|
-
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
|
1347
|
-
|
1348
|
-
var FORCED = DESCRIPTORS && isForced('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y || fails(function () {
|
1349
|
-
re2[MATCH] = false;
|
1350
|
-
// RegExp constructor can alter flags and IsRegExp works correct with @@match
|
1351
|
-
return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
|
1352
|
-
})));
|
1353
|
-
|
1354
|
-
// `RegExp` constructor
|
1355
|
-
// https://tc39.es/ecma262/#sec-regexp-constructor
|
1356
|
-
if (FORCED) {
|
1357
|
-
var RegExpWrapper = function RegExp(pattern, flags) {
|
1358
|
-
var thisIsRegExp = this instanceof RegExpWrapper;
|
1359
|
-
var patternIsRegExp = isRegExp(pattern);
|
1360
|
-
var flagsAreUndefined = flags === undefined;
|
1361
|
-
var sticky;
|
1362
|
-
|
1363
|
-
if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
|
1364
|
-
return pattern;
|
1365
|
-
}
|
1366
|
-
|
1367
|
-
if (CORRECT_NEW) {
|
1368
|
-
if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;
|
1369
|
-
} else if (pattern instanceof RegExpWrapper) {
|
1370
|
-
if (flagsAreUndefined) flags = getFlags.call(pattern);
|
1371
|
-
pattern = pattern.source;
|
1372
|
-
}
|
1373
|
-
|
1374
|
-
if (UNSUPPORTED_Y) {
|
1375
|
-
sticky = !!flags && flags.indexOf('y') > -1;
|
1376
|
-
if (sticky) flags = flags.replace(/y/g, '');
|
1377
|
-
}
|
1378
|
-
|
1379
|
-
var result = inheritIfRequired(
|
1380
|
-
CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),
|
1381
|
-
thisIsRegExp ? this : RegExpPrototype,
|
1382
|
-
RegExpWrapper
|
1383
|
-
);
|
1384
|
-
|
1385
|
-
if (UNSUPPORTED_Y && sticky) {
|
1386
|
-
var state = enforceInternalState(result);
|
1387
|
-
state.sticky = true;
|
1388
|
-
}
|
1389
|
-
|
1390
|
-
return result;
|
1391
|
-
};
|
1392
|
-
var proxy = function (key) {
|
1393
|
-
key in RegExpWrapper || defineProperty(RegExpWrapper, key, {
|
1394
|
-
configurable: true,
|
1395
|
-
get: function () { return NativeRegExp[key]; },
|
1396
|
-
set: function (it) { NativeRegExp[key] = it; }
|
1397
|
-
});
|
1398
|
-
};
|
1399
|
-
var keys = getOwnPropertyNames(NativeRegExp);
|
1400
|
-
var index = 0;
|
1401
|
-
while (keys.length > index) proxy(keys[index++]);
|
1402
|
-
RegExpPrototype.constructor = RegExpWrapper;
|
1403
|
-
RegExpWrapper.prototype = RegExpPrototype;
|
1404
|
-
redefine(global, 'RegExp', RegExpWrapper);
|
1405
|
-
}
|
1406
|
-
|
1407
|
-
// https://tc39.es/ecma262/#sec-get-regexp-@@species
|
1408
|
-
setSpecies('RegExp');
|
1409
|
-
|
1410
|
-
|
1411
|
-
/***/ })
|
1412
|
-
|
1413
|
-
},
|
1414
|
-
/******/ function(__webpack_require__) { // webpackRuntimeModules
|
1415
|
-
/******/ "use strict";
|
1416
|
-
/******/
|
1417
|
-
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
1418
|
-
/******/ var __webpack_exports__ = (__webpack_exec__("./src/plugins/search/plugin.search.js"));
|
1419
|
-
/******/ }
|
1420
|
-
]);
|
1
|
+
/*! For license information please see plugin.search.js.LICENSE.txt */
|
2
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[73],{2225:function(e,t,r){r(4043),r(1514),r(5728),r(228),r(886),r(7267),r(4338),r(429),r(3964),r(6585),r(939),r(752),r(1694),r(6265),r(9307),r(9749),r(6544),r(4254),r(8373),r(6793),r(7629),r(7509),r(8052),r(7522),r(4284),r(3374),r(9730),r(2826),r(7049);var n=r(5685),a=r(9860),o=(r(2320),r(9373),r(9903),r(9288),r(5311));function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(void 0,a=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key),"symbol"===i(a)?a:String(a)),n)}var a}var c=function(){function e(t){var r=t.br,n=t.searchCancelledCallback,a=void 0===n?function(){}:n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.br=r,this.matches=[],this.cacheDOMElements(),this.bindEvents(),this.cancelSearch=a}var t,r;return t=e,r=[{key:"cacheDOMElements",value:function(){this.dom={},this.dom.toolbarSearch=this.buildToolbarSearch()}},{key:"setQuery",value:function(e){this.br.$('[name="query"]').val(e)}},{key:"emptyMatches",value:function(){this.matches=[]}},{key:"removeResultPins",value:function(){this.br.$(".BRnavpos .BRsearch").remove()}},{key:"clearSearchFieldAndResults",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.br.removeSearchResults(),this.removeResultPins(),this.emptyMatches(),this.setQuery(""),this.teardownSearchNavigation(),e&&this.br.trigger("SearchResultsCleared")}},{key:"toggleSidebar",value:function(){this.br.trigger("ToggleSearchMenu")}},{key:"renderSearchNavigation",value:function(){var e="BRsearch-navigation";o(".BRnav").before('\n <div class="'.concat(e,'">\n <button class="toggle-sidebar">\n <h4>\n <span class="icon icon-search"></span> Results\n </h4>\n </button>\n <div class="pagination">\n <button class="prev" title="Previous result"><span class="icon icon-chevron hflip"></span></button>\n <span data-id="resultsCount">').concat(this.resultsPosition(),'</span>\n <button class="next" title="Next result"><span class="icon icon-chevron"></button>\n </div>\n <button class="clear" title="Clear search results">\n <span class="icon icon-close"></span>\n </button>\n </div>\n ')),this.dom.searchNavigation=o(".".concat(e))}},{key:"resultsPosition",value:function(){var e="".concat(this.matches.length," result").concat(1===this.matches.length?"":"s");return~this.currentMatchIndex&&(e="".concat(this.currentMatchIndex+1," / ").concat(this.matches.length)),e}},{key:"bindSearchNavigationEvents",value:function(){if(this.dom.searchNavigation){var e="searchNavigation";this.dom.searchNavigation.on("click.".concat(e),".clear",this.clearSearchFieldAndResults.bind(this)).on("click.".concat(e),".prev",this.showPrevResult.bind(this)).on("click.".concat(e),".next",this.showNextResult.bind(this)).on("click.".concat(e),".toggle-sidebar",this.toggleSidebar.bind(this)).on("click.".concat(e),!1)}}},{key:"showPrevResult",value:function(){0!==this.currentMatchIndex&&(this.br.mode===this.br.constModeThumb&&this.br.switchMode(this.br.constMode1up),~this.currentMatchIndex||(this.currentMatchIndex=this.getClosestMatchIndex((function(e,t,r){return t[0]>r}))+1),this.br.$(".BRnavline .BRsearch").eq(--this.currentMatchIndex).click(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"showNextResult",value:function(){this.currentMatchIndex+1!==this.matches.length&&(this.br.mode===this.br.constModeThumb&&this.br.switchMode(this.br.constMode1up),~this.currentMatchIndex||(this.currentMatchIndex=this.getClosestMatchIndex((function(e,t,r){return e[e.length-1]>r}))-1),this.br.$(".BRnavline .BRsearch").eq(++this.currentMatchIndex).click(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"getClosestMatchIndex",value:function(e){var t=function t(r,n){if(1===r.length)return r[0];var a=r.slice(0,r.length/2),o=r.slice(r.length/2);return t(e(a,o,n)?a:o,n)}(this.matches.map((function(e){return e.par[0].page})),this.br.currentIndex()+1);return this.matches.indexOf(this.matches.find((function(e){return e.par[0].page===t})))}},{key:"updateResultsPosition",value:function(){this.dom.searchNavigation&&this.dom.searchNavigation.find("[data-id=resultsCount]").text(this.resultsPosition())}},{key:"updateSearchNavigationButtons",value:function(){this.dom.searchNavigation&&(this.dom.searchNavigation.find(".prev").attr("disabled",!this.currentMatchIndex),this.dom.searchNavigation.find(".next").attr("disabled",this.currentMatchIndex+1===this.matches.length))}},{key:"teardownSearchNavigation",value:function(){this.dom.searchNavigation||(this.dom.searchNavigation=o(".BRsearch-navigation")),this.dom.searchNavigation.length&&(this.dom.searchNavigation.off(".searchNavigation").remove(),this.dom.searchNavigation=null,this.br.resize())}},{key:"setCurrentMatchIndex",value:function(){var e;this.br.mode!==this.br.constModeThumb?(e=this.br.mode===this.br.constMode2up?this.find2upMatchingSearchResult():this.find1upMatchingSearchResult(),this.currentMatchIndex=this.matches.indexOf(e)):this.currentMatchIndex=-1}},{key:"find1upMatchingSearchResult",value:function(){var e=this;return this.matches.find((function(t){return e.br.currentIndex()===t.par[0].page-1}))}},{key:"find2upMatchingSearchResult",value:function(){var e=this;return this.matches.find((function(t){return e.br._isIndexDisplayed(t.par[0].page-1)}))}},{key:"updateSearchNavigation",value:function(){this.matches.length&&(this.setCurrentMatchIndex(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"togglePinsFor",value:function(e){var t=e?"visible":"hidden";this.br.refs.$BRfooter.find(".BRsearch").css({visibility:t})}},{key:"buildToolbarSearch",value:function(){var e=document.createElement("span");return e.classList.add("BRtoolbarSection","BRtoolbarSectionSearch"),e.innerHTML='\n <form class="BRbooksearch desktop">\n <input type="search" name="query" class="BRsearchInput" value="" placeholder="Search inside"/>\n <button type="submit" class="BRsearchSubmit">\n <img src="'.concat(this.br.imagesBaseURL,'icon_search_button.svg" />\n </button>\n </form>\n '),e}},{key:"renderPins",value:function(e){var t=this;e.forEach((function(e){var r=t.br.book.leafNumToIndex(e.par[0].page),n=t.br.constructor.util.cssPercentage(r,t.br.book.getNumLeafs()-1),a=e.html;if(a.length>200){var i=Math.max(0,a.indexOf("<mark>")-100);0!=i&&(a="…"+e.html.substring(i).replace(/^\S+/,""))}o("<div>").addClass("BRsearch").css({left:n}).attr("title","Search result").append('\n <div class="BRquery">\n <main>'.concat(a,"</main>\n <footer>Page ").concat(e.displayPageNumber,"</footer>\n </div>\n ")).appendTo(t.br.$(".BRnavline")).on("mouseenter",(function(e){var t=e.currentTarget,r=t.querySelector(".BRquery"),n=r.getBoundingClientRect(),a=t.getBoundingClientRect(),i=2*parseInt(getComputedStyle(r).paddingLeft);n.x-i<0&&r.style.setProperty("transform","translateX(-".concat(a.left-i,"px)")),o(".BRsearch,.BRchapter").removeClass("front"),o(e.target).addClass("front")})).on("mouseleave",(function(e){return o(e.target).removeClass("front")})).on("click",(function(){t.br._searchPluginGoToResult(e.matchIndex)}))}))}},{key:"toggleSearchPending",value:function(e){var t=this;e?this.br.showProgressPopup("Search results will appear below...",(function(){return t.progressPopupClosed()})):this.br.removeProgressPopup()}},{key:"progressPopupClosed",value:function(){this.toggleSearchPending(),this.cancelSearch()}},{key:"renderErrorModal",value:function(){var e="".concat(arguments.length>0&&void 0!==arguments[0]&&arguments[0]?"":"The text may still be processing. ","Please try again.");this.renderModalMessage("\n Sorry, there was an error with your search.\n <br />\n ".concat(e,"\n ")),this.delayModalRemovalFor(4e3)}},{key:"renderBookNotIndexedModal",value:function(){this.renderModalMessage("\n <p>\n This book hasn't been indexed for searching yet.\n We've just started indexing it, so search should be available soon.\n <br />\n Please try again later. Thanks!\n </p>\n "),this.delayModalRemovalFor(5e3)}},{key:"renderResultsEmptyModal",value:function(){this.renderModalMessage("No matches were found."),this.delayModalRemovalFor(2e3)}},{key:"renderModalMessage",value:function(e){var t=document.createElement("div");t.classList.add("BRprogresspopup","search_modal"),t.innerHTML=e,document.querySelector(this.br.el).append(t)}},{key:"delayModalRemovalFor",value:function(e){setTimeout(this.br.removeProgressPopup.bind(this.br),e)}},{key:"submitHandler",value:function(e){e.preventDefault();var t=e.target.querySelector('[name="query"]').value;return!!t.length&&(this.br.search(t),this.emptyMatches(),this.toggleSearchPending(!0),!1)}},{key:"handleSearchCallback",value:function(e,t){var r=this,n=t.results,a=t.options;this.matches=n.matches,this.setCurrentMatchIndex(),this.teardownSearchNavigation(),this.renderSearchNavigation(),this.bindSearchNavigationEvents(),this.renderPins(n.matches),this.toggleSearchPending(!1),a.goToFirstResult?o(document).one("BookReader:pageChanged",(function(){r.br.resize()})):this.br.resize()}},{key:"handleSearchStarted",value:function(){this.emptyMatches(),this.br.removeSearchHilites(),this.removeResultPins(),this.toggleSearchPending(!0),this.teardownSearchNavigation(),this.setQuery(this.br.searchTerm)}},{key:"handleSearchCallbackError",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.toggleSearchPending(!1);var r=null==t||null===(e=t.detail)||void 0===e||null===(e=e.props)||void 0===e||null===(e=e.results)||void 0===e?void 0:e.indexed;this.renderErrorModal(r)}},{key:"handleSearchCallbackBookNotIndexed",value:function(){this.toggleSearchPending(!1),this.renderBookNotIndexedModal()}},{key:"handleSearchCallbackEmpty",value:function(){this.toggleSearchPending(!1),this.renderResultsEmptyModal()}},{key:"bindEvents",value:function(){var e="BookReader:";window.addEventListener("".concat(e,"SearchCallbackError"),this.handleSearchCallbackError.bind(this)),o(document).on("".concat(e,"SearchCallback"),this.handleSearchCallback.bind(this)).on("".concat(e,"SearchStarted"),this.handleSearchStarted.bind(this)).on("".concat(e,"SearchCallbackBookNotIndexed"),this.handleSearchCallbackBookNotIndexed.bind(this)).on("".concat(e,"SearchCallbackEmpty"),this.handleSearchCallbackEmpty.bind(this)).on("".concat(e,"pageChanged"),this.updateSearchNavigation.bind(this)),this.dom.toolbarSearch.querySelector("form").addEventListener("submit",this.submitHandler.bind(this))}}],r&&s(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),h=c;function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=u(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw o}}}}function u(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r){var a=(0,n.escapeRegExp)((0,n.escapeHTML)(t)),o=(0,n.escapeRegExp)((0,n.escapeHTML)(r)),i=new RegExp("".concat(a,"([^]+?)").concat(o),"g");return(0,n.escapeHTML)(e).replace(i,"<mark>$1</mark>").replace(/(\b)- /g,"$1")}r(2003);var p,v=r(5311),g=r(5311);function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function y(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=b(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw o}}}}function b(e,t){if(e){if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S(){S=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),s=new N(n||[]);return a(i,"_invoke",{value:C(e,r,s)}),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var d="suspendedStart",f="suspendedYield",p="executing",v="completed",g={};function y(){}function b(){}function k(){}var x={};h(x,i,(function(){return this}));var R=Object.getPrototypeOf,w=R&&R(R(L([])));w&&w!==r&&n.call(w,i)&&(x=w);var P=k.prototype=y.prototype=Object.create(x);function I(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function B(e,t){function r(a,o,i,s){var c=u(e[a],e,o);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==m(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(l).then((function(e){h.value=e,i(h)}),(function(e){return r("throw",e,i,s)}))}s(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function C(t,r,n){var a=d;return function(o,i){if(a===p)throw new Error("Generator is already running");if(a===v){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var c=M(s,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var h=u(t,r,n);if("normal"===h.type){if(a=n.done?v:f,h.arg===g)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(a=v,n.method="throw",n.arg=h.arg)}}}function M(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,M(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=u(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(m(t)+" is not iterable")}return b.prototype=k,a(P,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:b,configurable:!0}),b.displayName=h(k,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,h(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},I(B.prototype),h(B.prototype,s,(function(){return this})),t.AsyncIterator=B,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new B(l(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},I(P),h(P,c,"Generator"),h(P,i,(function(){return this})),h(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),h=n.call(i,"finallyLoc");if(c&&h){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;E(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function x(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function R(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){x(o,n,a,i,s,"next",e)}function s(e){x(o,n,a,i,s,"throw",e)}i(void 0)}))}}v.extend(BookReader.defaultOptions,{server:"ia600609.us.archive.org",bookId:"",subPrefix:"",bookPath:"",enableSearch:!0,searchInsideProtocol:"https",searchInsideUrl:"/fulltext/inside.php",searchInsidePreTag:"{{{",searchInsidePostTag:"}}}",initialSearchTerm:null}),BookReader.prototype.setup=(p=BookReader.prototype.setup,function(e){p.call(this,e),this.searchTerm="",this.searchResults=null,this.searchInsideUrl=e.searchInsideUrl,this.enableSearch=e.enableSearch,this.bookId=e.bookId,this.server=e.server,this.subPrefix=e.subPrefix,this.bookPath=e.bookPath,this.searchXHR=null,this._cancelSearch.bind(this),this.cancelSearchRequest.bind(this),this._searchBoxesByIndex={},this.searchView=void 0}),BookReader.prototype.init=function(e){return function(){var t=this;e.call(this),this.searchView=new h({br:this,searchCancelledCallback:function(){t._cancelSearch(),t.trigger("SearchCanceled",{term:t.searchTerm,instance:t})}}),this.options.enableSearch&&this.options.initialSearchTerm&&this.search(this.options.initialSearchTerm,{goToFirstResult:this.options.goToFirstResult,suppressFragmentChange:!1})}}(BookReader.prototype.init),BookReader.prototype.buildToolbarElement=function(e){return function(){var t=e.call(this);if(this.enableSearch)return this.searchView.dom.toolbarSearch&&t.find(".BRtoolbarSectionInfo").after(this.searchView.dom.toolbarSearch),t}}(BookReader.prototype.buildToolbarElement),BookReader.prototype._createPageContainer=function(e){return function(t){var r=e.call(this,t);if(this.enableSearch&&r.page&&t in this._searchBoxesByIndex){var n=r.page.index,o=this._searchBoxesByIndex[n];(0,a.Tm)("searchHiliteLayer",o,r.page,r.$container[0],o.map((function(e){return"match-index-".concat(e.matchIndex)})))}return r}}(BookReader.prototype._createPageContainer),BookReader.prototype.search=R(S().mark((function e(){var t,r,n,a,o,i,s,c,h,l,u,d,f=this,p=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n={goToFirstResult:!1,disablePopup:!1,suppressFragmentChange:!1,error:null,success:null},a=v.extend({},n,r),this.suppressFragmentChange=a.suppressFragmentChange,this.searchCancelled=!1,this.searchTerm=t.replace(/\//g," "),a.suppressFragmentChange||this.trigger(BookReader.eventNames.fragmentChange),o=this.server.replace(/:.+/,""),i="".concat(this.options.searchInsideProtocol,"://").concat(o).concat(this.searchInsideUrl,"?"),s=this.bookPath,c="/".concat(this.subPrefix),this.bookPath.length-this.bookPath.lastIndexOf(c)==c.length&&(s=this.bookPath.substr(0,this.bookPath.length-c.length)),h={item_id:this.bookId,doc:this.subPrefix,path:s,q:t,pre_tag:this.options.searchInsidePreTag,post_tag:this.options.searchInsidePostTag},l=g.param(h).replace(/%2F/g,"/"),u="".concat(i).concat(l),d=function(e){if(!f.searchCancelled){var t=e.error||!e.matches.length,r="function"==typeof a.error,n="function"==typeof a.success;t?(console.error("Search Inside Response Error",e.error||"matches.length == 0"),r?a.error.call(f,e,a):f.BRSearchCallbackError(e,a)):n?a.success.call(f,e,a):f.BRSearchCallback(e,a)}},this.trigger("SearchStarted",{term:this.searchTerm,instance:this}),e.t0=d,e.next=21,g.ajax({url:u,dataType:"jsonp",cache:!0,beforeSend:function(e){f.searchXHR=e}});case 21:e.t1=e.sent,(0,e.t0)(e.t1);case 23:case"end":return e.stop()}}),e,this)}))),BookReader.prototype._cancelSearch=function(){var e;null===(e=this.searchXHR)||void 0===e||e.abort(),this.searchView.clearSearchFieldAndResults(!1),this.searchTerm="",this.searchXHR=null,this.searchCancelled=!0,this.searchResults=[]},BookReader.prototype.cancelSearchRequest=function(){this.searchCancelled=!0,null!==this.searchXHR&&(this._cancelSearch(),this.searchView.toggleSearchPending(),this.trigger("SearchCanceled",{term:this.searchTerm,instance:this}))},BookReader.prototype.BRSearchCallback=function(e,t){var r=this;!function(e,t,n,a){var o,i,s,c,h=l(e.matches.entries());try{for(h.s();!(o=h.n()).done;){var d=(s=o.value,c=2,function(e){if(Array.isArray(e))return e}(s)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,s=[],c=!0,h=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){h=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(h)throw a}}return s}}(s,c)||u(s,c)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),p=d[0],v=d[1];v.matchIndex=p,v.displayPageNumber=(i=v.par[0].page,r.book.getPageNum(r.book.leafNumToIndex(i))),v.html=f(v.text,n,a);var g,m=l(v.par);try{for(m.s();!(g=m.n()).done;){var y,b=l(g.value.boxes);try{for(b.s();!(y=b.n()).done;)y.value.matchIndex=p}catch(e){b.e(e)}finally{b.f()}}}catch(e){m.e(e)}finally{m.f()}}}catch(e){h.e(e)}finally{h.f()}}(e,0,this.options.searchInsidePreTag,this.options.searchInsidePostTag),this.searchResults=e||[],this.updateSearchHilites(),this.removeProgressPopup(),t.goToFirstResult&&this._searchPluginGoToResult(0),this.trigger("SearchCallback",{results:e,options:t,instance:this})},BookReader.prototype.BRSearchCallbackError=function(e){this._BRSearchCallbackError(e)},BookReader.prototype._BRSearchCallbackError=function(e){this.searchResults=e;var t={term:this.searchTerm,instance:this};if(e.error){var r=Object.assign({},t,{results:e});this.trigger("SearchCallbackError",r)}else if(0==e.matches.length){if(!1===e.indexed)return void this.trigger("SearchCallbackBookNotIndexed",t);this.trigger("SearchCallbackEmpty",t)}},BookReader.prototype.updateSearchHilites=function(){var e,t=(null===(e=this.searchResults)||void 0===e?void 0:e.matches)||[],r={};this.removeSearchHilites();var n,o,i,s=y(t);try{for(s.s();!(n=s.n()).done;){var c,h=y(n.value.par[0].boxes);try{for(h.s();!(c=h.n()).done;){var l=c.value,u=this.book.leafNumToIndex(l.page);(r[u]||(r[u]=[])).push(l)}}catch(e){h.e(e)}finally{h.f()}}}catch(e){s.e(e)}finally{s.f()}for(var d=0,f=Object.entries(r);d<f.length;d++){var p,v=(o=f[d],i=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,s=[],c=!0,h=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){h=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(h)throw a}}return s}}(o,i)||b(o,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),g=v[0],m=v[1],k=parseFloat(g),S=this.book.getPage(k),x=y(this.getActivePageContainerElementsForIndex(k));try{for(x.s();!(p=x.n()).done;){var R=p.value;(0,a.Tm)("searchHiliteLayer",m,S,R,m.map((function(e){return"match-index-".concat(e.matchIndex)})))}}catch(e){x.e(e)}finally{x.f()}}this._searchBoxesByIndex=r},BookReader.prototype.removeSearchHilites=function(){g(this.getActivePageContainerElements()).find(".searchHiliteLayer").remove()},BookReader.prototype._searchPluginGoToResult=function(){var e=R(S().mark((function e(t){var r,a,o,i,s,c,h,l,u,d,f,p;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(r=this.searchResults)||void 0===r?void 0:r.matches[t],o=this.book,i=o.leafNumToIndex(a.par[0].page),s=o.getPage(i),c=Math.abs(this.currentIndex()-i)<3,h=!1,s.isViewable){e.next=17;break}return e.next=9,fetch("/services/bookreader/request_page?"+new URLSearchParams({id:this.options.bookId,subprefix:this.options.subPrefix,leafNum:s.leafNum})).then((function(e){return e.json()}));case 9:l=e.sent,u=y(l.value);try{for(u.s();!(d=u.n()).done;)f=d.value,o.getPage(o.leafNumToIndex(f)).makeViewable()}catch(e){u.e(e)}finally{u.f()}if(l.value.length||(o.getPage(i).makeViewable(),h=!0),this._modes.mode1Up.mode1UpLit.updatePages(),this.activeMode!=this._modes.mode1Up){e.next=17;break}return e.next=17,this._modes.mode1Up.mode1UpLit.updateComplete;case 17:return this._isIndexDisplayed(i)||(this.suppressFragmentChange=!1,this.jumpToIndex(i)),h&&o.getPage(i).makeViewable(!1),e.next=21,(0,n.poll)((function(){return g("rect.match-index-".concat(a.matchIndex))}),{until:function(e){return e.length>0}});case 21:if(!(p=e.sent).length){e.next=28;break}return p.css("animation","none"),p[0].scrollIntoView({block:this.constMode1up==this.mode||this.isFullscreenActive?"center":"nearest",inline:"center",behavior:c?"smooth":"auto"}),e.next=27,new Promise((function(e){return setTimeout(e,100)}));case 27:p.removeAttr("style");case 28:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),BookReader.prototype.removeSearchResults=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.removeSearchHilites(),this.searchTerm=null,this.searchResults=null,e||this.trigger(BookReader.eventNames.fragmentChange)},BookReader.prototype.searchHighlightVisible=function(){var e=this,t=this.searchResults,r=[];if(null==t)return!1;if(this.constMode2up==this.mode)r=[this.twoPage.currentIndexL,this.twoPage.currentIndexR];else{if(this.constMode1up!=this.mode)return!1;r=[this.currentIndex()]}return t.matches.some((function(t){return t.par[0].boxes.some((function(t){var n=e.book.leafNumToIndex(t.page);if(v.inArray(n,r)>=0)return!0}))})),!1}},6585:function(e,t,r){var n=r(9989),a=r(9419).entries;n({target:"Object",stat:!0},{entries:function(e){return a(e)}})}},function(e){e(e.s=2225)}]);
|
1421
3
|
//# sourceMappingURL=plugin.search.js.map
|