@internetarchive/bookreader 5.0.0-24-sortingstate-11 → 5.0.0-26
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.css +4 -0
- package/BookReader/BookReader.js +2 -32145
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/bookreader-component-bundle.js +1286 -11256
- package/BookReader/bookreader-component-bundle.js.map +1 -1
- 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 -1
- 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 -1
- 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-1.10.1.js +2 -108
- package/BookReader/plugins/plugin.archive_analytics.js +1 -170
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -163
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -333
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -72
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -332
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -241
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1263
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -839
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +2 -9114
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -768
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -326
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +2 -411
- package/BookReader/webcomponents-bundle.js.map +1 -1
- package/BookReaderDemo/demo-internetarchive.html +86 -4
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +1 -0
- package/src/BookNavigator/volumes/volumes-provider.js +9 -40
- package/src/BookReader.js +102 -64
- package/src/css/_controls.scss +4 -0
- package/src/plugins/plugin.url.js +2 -218
- package/tests/jest/BookReader.keyboard.test.js +190 -0
- package/tests/jest/plugins/plugin.url.test.js +1 -151
- package/.nvmrc +0 -1
@@ -1,769 +1,2 @@
|
|
1
|
-
(self["
|
2
|
-
|
3
|
-
/***/ "./src/plugins/plugin.url.js":
|
4
|
-
/*!***********************************!*\
|
5
|
-
!*** ./src/plugins/plugin.url.js ***!
|
6
|
-
\***********************************/
|
7
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
8
|
-
|
9
|
-
"use strict";
|
10
|
-
__webpack_require__.r(__webpack_exports__);
|
11
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
12
|
-
/* harmony export */ "UrlPlugin": function() { return /* binding */ UrlPlugin; },
|
13
|
-
/* harmony export */ "BookreaderUrlPlugin": function() { return /* binding */ BookreaderUrlPlugin; }
|
14
|
-
/* harmony export */ });
|
15
|
-
/* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.reduce.js */ "./node_modules/core-js/modules/es.array.reduce.js");
|
16
|
-
/* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_0__);
|
17
|
-
/* 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");
|
18
|
-
/* 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__);
|
19
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_2__ = __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_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_2__);
|
21
|
-
/* 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");
|
22
|
-
/* 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__);
|
23
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "./node_modules/core-js/modules/es.array.iterator.js");
|
24
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_4__);
|
25
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "./node_modules/core-js/modules/es.object.to-string.js");
|
26
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_5__);
|
27
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "./node_modules/core-js/modules/es.string.iterator.js");
|
28
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_6__);
|
29
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "./node_modules/core-js/modules/web.dom-collections.iterator.js");
|
30
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_7__);
|
31
|
-
/* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/web.url.js */ "./node_modules/core-js/modules/web.url.js");
|
32
|
-
/* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_8__);
|
33
|
-
/* 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");
|
34
|
-
/* 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__);
|
35
|
-
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.object.keys.js */ "./node_modules/core-js/modules/es.object.keys.js");
|
36
|
-
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_10__);
|
37
|
-
/* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.array.find.js */ "./node_modules/core-js/modules/es.array.find.js");
|
38
|
-
/* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_11__);
|
39
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ "./node_modules/core-js/modules/es.function.name.js");
|
40
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_12__);
|
41
|
-
/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/es.array.join.js */ "./node_modules/core-js/modules/es.array.join.js");
|
42
|
-
/* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_13__);
|
43
|
-
/* harmony import */ var core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/es.array.map.js */ "./node_modules/core-js/modules/es.array.map.js");
|
44
|
-
/* harmony import */ var core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_14__);
|
45
|
-
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! core-js/modules/es.array.filter.js */ "./node_modules/core-js/modules/es.array.filter.js");
|
46
|
-
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_15__);
|
47
|
-
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ "./node_modules/core-js/modules/es.regexp.to-string.js");
|
48
|
-
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_16__);
|
49
|
-
/* harmony import */ var core_js_modules_es_object_from_entries_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! core-js/modules/es.object.from-entries.js */ "./node_modules/core-js/modules/es.object.from-entries.js");
|
50
|
-
/* harmony import */ var core_js_modules_es_object_from_entries_js__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_from_entries_js__WEBPACK_IMPORTED_MODULE_17__);
|
51
|
-
/* harmony import */ var core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! core-js/modules/es.string.match.js */ "./node_modules/core-js/modules/es.string.match.js");
|
52
|
-
/* harmony import */ var core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_18__);
|
53
|
-
/* harmony import */ var core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! core-js/modules/es.string.split.js */ "./node_modules/core-js/modules/es.string.split.js");
|
54
|
-
/* harmony import */ var core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_19__);
|
55
|
-
/* harmony import */ var core_js_modules_es_object_entries_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! core-js/modules/es.object.entries.js */ "./node_modules/core-js/modules/es.object.entries.js");
|
56
|
-
/* harmony import */ var core_js_modules_es_object_entries_js__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_entries_js__WEBPACK_IMPORTED_MODULE_20__);
|
57
|
-
/* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! core-js/modules/es.string.search.js */ "./node_modules/core-js/modules/es.string.search.js");
|
58
|
-
/* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_21__);
|
59
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "./node_modules/core-js/modules/es.symbol.js");
|
60
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_22__);
|
61
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "./node_modules/core-js/modules/es.symbol.description.js");
|
62
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_23__);
|
63
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "./node_modules/core-js/modules/es.symbol.iterator.js");
|
64
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_24__);
|
65
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! core-js/modules/es.array.slice.js */ "./node_modules/core-js/modules/es.array.slice.js");
|
66
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_25__);
|
67
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! core-js/modules/es.array.from.js */ "./node_modules/core-js/modules/es.array.from.js");
|
68
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_26__);
|
69
|
-
/* harmony import */ var core_js_modules_es_object_get_prototype_of_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ "./node_modules/core-js/modules/es.object.get-prototype-of.js");
|
70
|
-
/* harmony import */ var core_js_modules_es_object_get_prototype_of_js__WEBPACK_IMPORTED_MODULE_27___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_prototype_of_js__WEBPACK_IMPORTED_MODULE_27__);
|
71
|
-
/* harmony import */ var core_js_modules_es_reflect_construct_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! core-js/modules/es.reflect.construct.js */ "./node_modules/core-js/modules/es.reflect.construct.js");
|
72
|
-
/* harmony import */ var core_js_modules_es_reflect_construct_js__WEBPACK_IMPORTED_MODULE_28___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_reflect_construct_js__WEBPACK_IMPORTED_MODULE_28__);
|
73
|
-
/* harmony import */ var core_js_modules_es_reflect_get_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! core-js/modules/es.reflect.get.js */ "./node_modules/core-js/modules/es.reflect.get.js");
|
74
|
-
/* harmony import */ var core_js_modules_es_reflect_get_js__WEBPACK_IMPORTED_MODULE_29___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_reflect_get_js__WEBPACK_IMPORTED_MODULE_29__);
|
75
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ "./node_modules/core-js/modules/es.object.get-own-property-descriptor.js");
|
76
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_30___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_30__);
|
77
|
-
/* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery");
|
78
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
79
|
-
|
80
|
-
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
81
|
-
|
82
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
83
|
-
|
84
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
85
|
-
|
86
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
87
|
-
|
88
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
89
|
-
|
90
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
91
|
-
|
92
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
93
|
-
|
94
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
95
|
-
|
96
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
97
|
-
|
98
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
99
|
-
|
100
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
101
|
-
|
102
|
-
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); }
|
103
|
-
|
104
|
-
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; }
|
105
|
-
|
106
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
107
|
-
|
108
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
109
|
-
|
110
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
111
|
-
|
112
|
-
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); } }
|
113
|
-
|
114
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
/* global BookReader */
|
149
|
-
|
150
|
-
/**
|
151
|
-
* Plugin for URL management in BookReader
|
152
|
-
* Note read more about the url "fragment" here:
|
153
|
-
* https://openlibrary.org/dev/docs/bookurls
|
154
|
-
*/
|
155
|
-
jQuery.extend(BookReader.defaultOptions, {
|
156
|
-
enableUrlPlugin: true,
|
157
|
-
bookId: '',
|
158
|
-
|
159
|
-
/** @type {string} Defaults can be a urlFragment string */
|
160
|
-
defaults: null,
|
161
|
-
updateWindowTitle: false,
|
162
|
-
|
163
|
-
/** @type {'history' | 'hash'} */
|
164
|
-
urlMode: 'hash',
|
165
|
-
|
166
|
-
/**
|
167
|
-
* When using 'history' mode, this part of the URL is kept constant
|
168
|
-
* @example /details/plato/
|
169
|
-
*/
|
170
|
-
urlHistoryBasePath: '/',
|
171
|
-
|
172
|
-
/** Only these params will be reflected onto the URL */
|
173
|
-
urlTrackedParams: ['page', 'search', 'mode', 'region', 'highlight', 'view'],
|
174
|
-
|
175
|
-
/** If true, don't update the URL when `page == n0 (eg "/page/n0")` */
|
176
|
-
urlTrackIndex0: false
|
177
|
-
});
|
178
|
-
/** @override */
|
179
|
-
|
180
|
-
BookReader.prototype.setup = function (super_) {
|
181
|
-
return function (options) {
|
182
|
-
super_.call(this, options);
|
183
|
-
this.bookId = options.bookId;
|
184
|
-
this.defaults = options.defaults;
|
185
|
-
this.locationPollId = null;
|
186
|
-
this.oldLocationHash = null;
|
187
|
-
this.oldUserHash = null;
|
188
|
-
};
|
189
|
-
}(BookReader.prototype.setup);
|
190
|
-
/** @override */
|
191
|
-
|
192
|
-
|
193
|
-
BookReader.prototype.init = function (super_) {
|
194
|
-
return function () {
|
195
|
-
var _this = this;
|
196
|
-
|
197
|
-
if (this.options.enableUrlPlugin) {
|
198
|
-
this.bind(BookReader.eventNames.PostInit, function () {
|
199
|
-
var _this$options = _this.options,
|
200
|
-
updateWindowTitle = _this$options.updateWindowTitle,
|
201
|
-
urlMode = _this$options.urlMode;
|
202
|
-
|
203
|
-
if (updateWindowTitle) {
|
204
|
-
document.title = _this.shortTitle(_this.bookTitle, 50);
|
205
|
-
}
|
206
|
-
|
207
|
-
if (urlMode === 'hash') {
|
208
|
-
_this.urlStartLocationPolling();
|
209
|
-
}
|
210
|
-
});
|
211
|
-
this.bind(BookReader.eventNames.fragmentChange, this.urlUpdateFragment.bind(this));
|
212
|
-
}
|
213
|
-
|
214
|
-
super_.call(this);
|
215
|
-
};
|
216
|
-
}(BookReader.prototype.init);
|
217
|
-
/**
|
218
|
-
* Returns a shortened version of the title with the maximum number of characters
|
219
|
-
* @param {number} maximumCharacters
|
220
|
-
* @return {string}
|
221
|
-
*/
|
222
|
-
|
223
|
-
|
224
|
-
BookReader.prototype.shortTitle = function (maximumCharacters) {
|
225
|
-
if (this.bookTitle.length < maximumCharacters) {
|
226
|
-
return this.bookTitle;
|
227
|
-
}
|
228
|
-
|
229
|
-
var title = "".concat(this.bookTitle.substr(0, maximumCharacters - 3), "...");
|
230
|
-
return title;
|
231
|
-
};
|
232
|
-
/**
|
233
|
-
* Starts polling of window.location to see hash fragment changes
|
234
|
-
*/
|
235
|
-
|
236
|
-
|
237
|
-
BookReader.prototype.urlStartLocationPolling = function () {
|
238
|
-
var _this2 = this;
|
239
|
-
|
240
|
-
this.oldLocationHash = this.urlReadFragment();
|
241
|
-
|
242
|
-
if (this.locationPollId) {
|
243
|
-
clearInterval(this.locationPollId);
|
244
|
-
this.locationPollId = null;
|
245
|
-
}
|
246
|
-
|
247
|
-
var updateHash = function updateHash() {
|
248
|
-
var newFragment = _this2.urlReadFragment();
|
249
|
-
|
250
|
-
var hasFragmentChange = newFragment != _this2.oldLocationHash && newFragment != _this2.oldUserHash;
|
251
|
-
|
252
|
-
if (!hasFragmentChange) {
|
253
|
-
return;
|
254
|
-
}
|
255
|
-
|
256
|
-
var params = _this2.paramsFromFragment(newFragment);
|
257
|
-
|
258
|
-
var updateParams = function updateParams() {
|
259
|
-
return _this2.updateFromParams(params);
|
260
|
-
};
|
261
|
-
|
262
|
-
_this2.trigger(BookReader.eventNames.stop);
|
263
|
-
|
264
|
-
if (_this2.animating) {
|
265
|
-
// Queue change if animating
|
266
|
-
if (_this2.autoStop) _this2.autoStop();
|
267
|
-
_this2.animationFinishedCallback = updateParams;
|
268
|
-
} else {
|
269
|
-
// update immediately
|
270
|
-
updateParams();
|
271
|
-
}
|
272
|
-
|
273
|
-
_this2.oldUserHash = newFragment;
|
274
|
-
};
|
275
|
-
|
276
|
-
this.locationPollId = setInterval(updateHash, 500);
|
277
|
-
};
|
278
|
-
/**
|
279
|
-
* Update URL from the current parameters.
|
280
|
-
* Call this instead of manually using window.location.replace
|
281
|
-
*/
|
282
|
-
|
283
|
-
|
284
|
-
BookReader.prototype.urlUpdateFragment = function () {
|
285
|
-
var allParams = this.paramsFromCurrent();
|
286
|
-
var _this$options2 = this.options,
|
287
|
-
urlMode = _this$options2.urlMode,
|
288
|
-
urlTrackIndex0 = _this$options2.urlTrackIndex0,
|
289
|
-
urlTrackedParams = _this$options2.urlTrackedParams;
|
290
|
-
|
291
|
-
if (!urlTrackIndex0 && typeof allParams.index !== 'undefined' && allParams.index === 0) {
|
292
|
-
delete allParams.index;
|
293
|
-
delete allParams.page;
|
294
|
-
}
|
295
|
-
|
296
|
-
var params = urlTrackedParams.reduce(function (validParams, paramName) {
|
297
|
-
if (paramName in allParams) {
|
298
|
-
validParams[paramName] = allParams[paramName];
|
299
|
-
}
|
300
|
-
|
301
|
-
return validParams;
|
302
|
-
}, {});
|
303
|
-
var newFragment = this.fragmentFromParams(params, urlMode);
|
304
|
-
var currFragment = this.urlReadFragment();
|
305
|
-
var currQueryString = this.getLocationSearch();
|
306
|
-
var newQueryString = this.queryStringFromParams(params, currQueryString, urlMode);
|
307
|
-
|
308
|
-
if (currFragment === newFragment && currQueryString === newQueryString) {
|
309
|
-
return;
|
310
|
-
}
|
311
|
-
|
312
|
-
if (urlMode === 'history') {
|
313
|
-
if (window.history && window.history.replaceState) {
|
314
|
-
var baseWithoutSlash = this.options.urlHistoryBasePath.replace(/\/+$/, '');
|
315
|
-
var newFragmentWithSlash = newFragment === '' ? '' : "/".concat(newFragment);
|
316
|
-
var newUrlPath = "".concat(baseWithoutSlash).concat(newFragmentWithSlash).concat(newQueryString);
|
317
|
-
window.history.replaceState({}, null, newUrlPath);
|
318
|
-
this.oldLocationHash = newFragment + newQueryString;
|
319
|
-
}
|
320
|
-
} else {
|
321
|
-
var newQueryStringSearch = this.urlParamsFiltersOnlySearch(this.readQueryString());
|
322
|
-
window.location.replace('#' + newFragment + newQueryStringSearch);
|
323
|
-
this.oldLocationHash = newFragment + newQueryStringSearch;
|
324
|
-
}
|
325
|
-
};
|
326
|
-
/**
|
327
|
-
* @private
|
328
|
-
* Filtering query parameters to select only book search param (?q=foo)
|
329
|
-
This needs to be updated/URL system modified if future query params are to be added
|
330
|
-
* @param {string} url
|
331
|
-
* @return {string}
|
332
|
-
* */
|
333
|
-
|
334
|
-
|
335
|
-
BookReader.prototype.urlParamsFiltersOnlySearch = function (url) {
|
336
|
-
var params = new URLSearchParams(url);
|
337
|
-
return params.has('q') ? "?".concat(new URLSearchParams({
|
338
|
-
q: params.get('q')
|
339
|
-
})) : '';
|
340
|
-
};
|
341
|
-
/**
|
342
|
-
* Will read either the hash or URL and return the bookreader fragment
|
343
|
-
* @return {string}
|
344
|
-
*/
|
345
|
-
|
346
|
-
|
347
|
-
BookReader.prototype.urlReadFragment = function () {
|
348
|
-
var _this$options3 = this.options,
|
349
|
-
urlMode = _this$options3.urlMode,
|
350
|
-
urlHistoryBasePath = _this$options3.urlHistoryBasePath;
|
351
|
-
|
352
|
-
if (urlMode === 'history') {
|
353
|
-
return window.location.pathname.substr(urlHistoryBasePath.length);
|
354
|
-
} else {
|
355
|
-
return window.location.hash.substr(1);
|
356
|
-
}
|
357
|
-
};
|
358
|
-
/**
|
359
|
-
* Will read the hash return the bookreader fragment
|
360
|
-
* @return {string}
|
361
|
-
*/
|
362
|
-
|
363
|
-
|
364
|
-
BookReader.prototype.urlReadHashFragment = function () {
|
365
|
-
return window.location.hash.substr(1);
|
366
|
-
};
|
367
|
-
|
368
|
-
var UrlPlugin = /*#__PURE__*/function () {
|
369
|
-
function UrlPlugin() {
|
370
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
371
|
-
|
372
|
-
_classCallCheck(this, UrlPlugin);
|
373
|
-
|
374
|
-
this.bookReaderOptions = options; // the canonical order of elements is important in the path and query string
|
375
|
-
|
376
|
-
this.urlSchema = [{
|
377
|
-
name: 'page',
|
378
|
-
position: 'path',
|
379
|
-
default: 'n0'
|
380
|
-
}, {
|
381
|
-
name: 'mode',
|
382
|
-
position: 'path',
|
383
|
-
default: '2up'
|
384
|
-
}, {
|
385
|
-
name: 'search',
|
386
|
-
position: 'path',
|
387
|
-
deprecated_for: 'q'
|
388
|
-
}, {
|
389
|
-
name: 'q',
|
390
|
-
position: 'query_param'
|
391
|
-
}, {
|
392
|
-
name: 'sort',
|
393
|
-
position: 'query_param'
|
394
|
-
}, {
|
395
|
-
name: 'view',
|
396
|
-
position: 'query_param'
|
397
|
-
}, {
|
398
|
-
name: 'admin',
|
399
|
-
position: 'query_param'
|
400
|
-
}];
|
401
|
-
this.urlState = {};
|
402
|
-
this.urlMode = this.bookReaderOptions.urlMode || 'hash';
|
403
|
-
this.urlHistoryBasePath = this.bookReaderOptions.urlHistoryBasePath || '/';
|
404
|
-
this.urlLocationPollId = null;
|
405
|
-
this.oldLocationHash = null;
|
406
|
-
this.oldUserHash = null;
|
407
|
-
}
|
408
|
-
/**
|
409
|
-
* Parse JSON object URL state to string format
|
410
|
-
* Arrange path names in an order that it is positioned on the urlSchema
|
411
|
-
* @param {Object} urlState
|
412
|
-
* @returns {string}
|
413
|
-
*/
|
414
|
-
|
415
|
-
|
416
|
-
_createClass(UrlPlugin, [{
|
417
|
-
key: "urlStateToUrlString",
|
418
|
-
value: function urlStateToUrlString(urlState) {
|
419
|
-
var _this3 = this;
|
420
|
-
|
421
|
-
var searchParams = new URLSearchParams();
|
422
|
-
var pathParams = {};
|
423
|
-
Object.keys(urlState).forEach(function (key) {
|
424
|
-
var _schema, _schema2;
|
425
|
-
|
426
|
-
var schema = _this3.urlSchema.find(function (schema) {
|
427
|
-
return schema.name === key;
|
428
|
-
});
|
429
|
-
|
430
|
-
if ((_schema = schema) !== null && _schema !== void 0 && _schema.deprecated_for) {
|
431
|
-
schema = _this3.urlSchema.find(function (schemaKey) {
|
432
|
-
return schemaKey.name === schema.deprecated_for;
|
433
|
-
});
|
434
|
-
}
|
435
|
-
|
436
|
-
if (((_schema2 = schema) === null || _schema2 === void 0 ? void 0 : _schema2.position) == 'path') {
|
437
|
-
var _schema3;
|
438
|
-
|
439
|
-
pathParams[(_schema3 = schema) === null || _schema3 === void 0 ? void 0 : _schema3.name] = urlState[key];
|
440
|
-
} else {
|
441
|
-
var _schema4;
|
442
|
-
|
443
|
-
searchParams.append(((_schema4 = schema) === null || _schema4 === void 0 ? void 0 : _schema4.name) || key, urlState[key]);
|
444
|
-
}
|
445
|
-
});
|
446
|
-
var strPathParams = this.urlSchema.filter(function (s) {
|
447
|
-
return s.position == 'path';
|
448
|
-
}).map(function (schema) {
|
449
|
-
return pathParams[schema.name] ? "".concat(schema.name, "/").concat(pathParams[schema.name]) : '';
|
450
|
-
}).join('/');
|
451
|
-
var strStrippedTrailingSlash = "".concat(strPathParams.replace(/\/$/, ''));
|
452
|
-
var concatenatedPath = "/".concat(strStrippedTrailingSlash, "?").concat(searchParams.toString());
|
453
|
-
return searchParams.toString() ? concatenatedPath : "/".concat(strStrippedTrailingSlash);
|
454
|
-
}
|
455
|
-
/**
|
456
|
-
* Parse string URL and add it in the current urlState
|
457
|
-
* Example:
|
458
|
-
* /page/n7/mode/2up => {page: 'n7', mode: '2up'}
|
459
|
-
* /page/n7/mode/2up/search/hello => {page: 'n7', mode: '2up', q: 'hello'}
|
460
|
-
* @param {string} urlString
|
461
|
-
* @returns {object}
|
462
|
-
*/
|
463
|
-
|
464
|
-
}, {
|
465
|
-
key: "urlStringToUrlState",
|
466
|
-
value: function urlStringToUrlState(urlString) {
|
467
|
-
console.log('urlString: ', urlString);
|
468
|
-
var urlState = {}; // Fetch searchParams from given {urlString}
|
469
|
-
// Note: whole URL path is needed for URLSearchParams
|
470
|
-
|
471
|
-
var urlPath = new URL(urlString, 'http://example.com');
|
472
|
-
console.log('urlPath: ', urlPath);
|
473
|
-
console.log('urlSearch: ', urlPath.searchParams, ' urlPath: ', urlPath.pathname);
|
474
|
-
var urlSearchParamsObj = Object.fromEntries(urlPath.searchParams.entries());
|
475
|
-
var urlStrSplitSlashObj = Object.fromEntries(urlPath.pathname.match(/[^\\/]+\/[^\\/]+/g).map(function (x) {
|
476
|
-
return x.split('/');
|
477
|
-
}));
|
478
|
-
|
479
|
-
var doesKeyExists = function doesKeyExists(_object, _key) {
|
480
|
-
return Object.keys(_object).some(function (value) {
|
481
|
-
return value == _key;
|
482
|
-
});
|
483
|
-
}; // Add path objects to urlState
|
484
|
-
|
485
|
-
|
486
|
-
this.urlSchema.filter(function (schema) {
|
487
|
-
return schema.position == 'path';
|
488
|
-
}).forEach(function (schema) {
|
489
|
-
if (!urlStrSplitSlashObj[schema.name] && schema.default) {
|
490
|
-
return urlState[schema.name] = schema.default;
|
491
|
-
}
|
492
|
-
|
493
|
-
var hasPropertyKey = doesKeyExists(urlStrSplitSlashObj, schema.name);
|
494
|
-
var hasDeprecatedKey = doesKeyExists(schema, 'deprecated_for') && hasPropertyKey;
|
495
|
-
|
496
|
-
if (hasDeprecatedKey) {
|
497
|
-
urlState[schema.deprecated_for] = urlStrSplitSlashObj[schema.name];
|
498
|
-
return;
|
499
|
-
}
|
500
|
-
|
501
|
-
if (hasPropertyKey) {
|
502
|
-
urlState[schema.name] = urlStrSplitSlashObj[schema.name];
|
503
|
-
return;
|
504
|
-
}
|
505
|
-
}); // Add searchParams to urlState
|
506
|
-
// Check if Object value is a Boolean and convert value to Boolean
|
507
|
-
// Otherwise, return Object value
|
508
|
-
|
509
|
-
var isBooleanValue = function isBooleanValue(value) {
|
510
|
-
return value === 'true' || (value === 'false' ? false : value);
|
511
|
-
};
|
512
|
-
|
513
|
-
Object.entries(urlSearchParamsObj).forEach(function (_ref) {
|
514
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
515
|
-
key = _ref2[0],
|
516
|
-
value = _ref2[1];
|
517
|
-
|
518
|
-
urlState[key] = isBooleanValue(value);
|
519
|
-
});
|
520
|
-
return urlState;
|
521
|
-
}
|
522
|
-
/**
|
523
|
-
* Add or update key-value to the urlState
|
524
|
-
* @param {string} key
|
525
|
-
* @param {string} val
|
526
|
-
*/
|
527
|
-
|
528
|
-
}, {
|
529
|
-
key: "setUrlParam",
|
530
|
-
value: function setUrlParam(key, value) {
|
531
|
-
this.urlState[key] = value;
|
532
|
-
this.pushToAddressBar();
|
533
|
-
}
|
534
|
-
/**
|
535
|
-
* Delete key-value to the urlState
|
536
|
-
* @param {string} key
|
537
|
-
*/
|
538
|
-
|
539
|
-
}, {
|
540
|
-
key: "removeUrlParam",
|
541
|
-
value: function removeUrlParam(key) {
|
542
|
-
delete this.urlState[key];
|
543
|
-
this.pushToAddressBar();
|
544
|
-
}
|
545
|
-
/**
|
546
|
-
* Get key-value from the urlState
|
547
|
-
* @param {string} key
|
548
|
-
* @return {string}
|
549
|
-
*/
|
550
|
-
|
551
|
-
}, {
|
552
|
-
key: "getUrlParam",
|
553
|
-
value: function getUrlParam(key) {
|
554
|
-
return this.urlState[key];
|
555
|
-
}
|
556
|
-
/**
|
557
|
-
* Push URL params to addressbar
|
558
|
-
*/
|
559
|
-
|
560
|
-
}, {
|
561
|
-
key: "pushToAddressBar",
|
562
|
-
value: function pushToAddressBar() {
|
563
|
-
var urlStrPath = this.urlStateToUrlString(this.urlState);
|
564
|
-
|
565
|
-
if (this.urlMode == 'history') {
|
566
|
-
if (window.history && window.history.replaceState) {
|
567
|
-
var newUrlPath = "".concat(this.urlHistoryBasePath).concat(urlStrPath);
|
568
|
-
console.log('newUrlPath: ', newUrlPath);
|
569
|
-
window.history.replaceState({}, null, newUrlPath);
|
570
|
-
}
|
571
|
-
} else {
|
572
|
-
window.location.replace('#' + urlStrPath);
|
573
|
-
}
|
574
|
-
|
575
|
-
this.oldLocationHash = urlStrPath;
|
576
|
-
}
|
577
|
-
/**
|
578
|
-
* Get the url and check if it has changed
|
579
|
-
* If it was changeed, update the urlState
|
580
|
-
*/
|
581
|
-
|
582
|
-
}, {
|
583
|
-
key: "listenForHashChanges",
|
584
|
-
value: function listenForHashChanges() {
|
585
|
-
var _this4 = this;
|
586
|
-
|
587
|
-
this.oldLocationHash = window.location.hash.substr(1);
|
588
|
-
|
589
|
-
if (this.urlLocationPollId) {
|
590
|
-
clearInterval(this.urlLocationPollId);
|
591
|
-
this.urlLocationPollId = null;
|
592
|
-
} // check if the URL changes
|
593
|
-
|
594
|
-
|
595
|
-
var updateHash = function updateHash() {
|
596
|
-
var newFragment = window.location.hash.substr(1);
|
597
|
-
var hasFragmentChange = newFragment != _this4.oldLocationHash;
|
598
|
-
|
599
|
-
if (!hasFragmentChange) {
|
600
|
-
return;
|
601
|
-
}
|
602
|
-
|
603
|
-
_this4.urlState = _this4.urlStringToUrlState(newFragment);
|
604
|
-
};
|
605
|
-
|
606
|
-
this.urlLocationPollId = setInterval(updateHash, 500);
|
607
|
-
}
|
608
|
-
/**
|
609
|
-
* Will read either the hash or URL and return the bookreader fragment
|
610
|
-
*/
|
611
|
-
|
612
|
-
}, {
|
613
|
-
key: "pullFromAddressBar",
|
614
|
-
value: function pullFromAddressBar() {
|
615
|
-
var location = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location;
|
616
|
-
var path = this.urlMode === 'history' ? location.pathname.substr(this.urlHistoryBasePath.length) + location.search : location.hash.substr(1);
|
617
|
-
console.log('path: ', path);
|
618
|
-
this.urlState = this.urlStringToUrlState(path);
|
619
|
-
}
|
620
|
-
}]);
|
621
|
-
|
622
|
-
return UrlPlugin;
|
623
|
-
}();
|
624
|
-
var BookreaderUrlPlugin = /*#__PURE__*/function (_BookReader) {
|
625
|
-
_inherits(BookreaderUrlPlugin, _BookReader);
|
626
|
-
|
627
|
-
var _super = _createSuper(BookreaderUrlPlugin);
|
628
|
-
|
629
|
-
function BookreaderUrlPlugin() {
|
630
|
-
_classCallCheck(this, BookreaderUrlPlugin);
|
631
|
-
|
632
|
-
return _super.apply(this, arguments);
|
633
|
-
}
|
634
|
-
|
635
|
-
_createClass(BookreaderUrlPlugin, [{
|
636
|
-
key: "init",
|
637
|
-
value: function init() {
|
638
|
-
var _this5 = this;
|
639
|
-
|
640
|
-
if (this.options.enableUrlPlugin) {
|
641
|
-
this.urlPlugin = new UrlPlugin(this.options);
|
642
|
-
this.bind(BookReader.eventNames.PostInit, function () {
|
643
|
-
var urlMode = _this5.options.urlMode;
|
644
|
-
|
645
|
-
if (urlMode === 'hash') {
|
646
|
-
_this5.urlPlugin.listenForHashChanges();
|
647
|
-
}
|
648
|
-
});
|
649
|
-
}
|
650
|
-
|
651
|
-
_get(_getPrototypeOf(BookreaderUrlPlugin.prototype), "init", this).call(this);
|
652
|
-
}
|
653
|
-
}]);
|
654
|
-
|
655
|
-
return BookreaderUrlPlugin;
|
656
|
-
}(BookReader);
|
657
|
-
window.BookReader = BookreaderUrlPlugin;
|
658
|
-
/* harmony default export */ __webpack_exports__["default"] = (BookreaderUrlPlugin);
|
659
|
-
|
660
|
-
/***/ }),
|
661
|
-
|
662
|
-
/***/ "./node_modules/core-js/modules/es.object.entries.js":
|
663
|
-
/*!***********************************************************!*\
|
664
|
-
!*** ./node_modules/core-js/modules/es.object.entries.js ***!
|
665
|
-
\***********************************************************/
|
666
|
-
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
667
|
-
|
668
|
-
var $ = __webpack_require__(/*! ../internals/export */ "./node_modules/core-js/internals/export.js");
|
669
|
-
var $entries = __webpack_require__(/*! ../internals/object-to-array */ "./node_modules/core-js/internals/object-to-array.js").entries;
|
670
|
-
|
671
|
-
// `Object.entries` method
|
672
|
-
// https://tc39.es/ecma262/#sec-object.entries
|
673
|
-
$({ target: 'Object', stat: true }, {
|
674
|
-
entries: function entries(O) {
|
675
|
-
return $entries(O);
|
676
|
-
}
|
677
|
-
});
|
678
|
-
|
679
|
-
|
680
|
-
/***/ }),
|
681
|
-
|
682
|
-
/***/ "./node_modules/core-js/modules/es.object.from-entries.js":
|
683
|
-
/*!****************************************************************!*\
|
684
|
-
!*** ./node_modules/core-js/modules/es.object.from-entries.js ***!
|
685
|
-
\****************************************************************/
|
686
|
-
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
687
|
-
|
688
|
-
var $ = __webpack_require__(/*! ../internals/export */ "./node_modules/core-js/internals/export.js");
|
689
|
-
var iterate = __webpack_require__(/*! ../internals/iterate */ "./node_modules/core-js/internals/iterate.js");
|
690
|
-
var createProperty = __webpack_require__(/*! ../internals/create-property */ "./node_modules/core-js/internals/create-property.js");
|
691
|
-
|
692
|
-
// `Object.fromEntries` method
|
693
|
-
// https://github.com/tc39/proposal-object-from-entries
|
694
|
-
$({ target: 'Object', stat: true }, {
|
695
|
-
fromEntries: function fromEntries(iterable) {
|
696
|
-
var obj = {};
|
697
|
-
iterate(iterable, function (k, v) {
|
698
|
-
createProperty(obj, k, v);
|
699
|
-
}, { AS_ENTRIES: true });
|
700
|
-
return obj;
|
701
|
-
}
|
702
|
-
});
|
703
|
-
|
704
|
-
|
705
|
-
/***/ }),
|
706
|
-
|
707
|
-
/***/ "./node_modules/core-js/modules/es.string.match.js":
|
708
|
-
/*!*********************************************************!*\
|
709
|
-
!*** ./node_modules/core-js/modules/es.string.match.js ***!
|
710
|
-
\*********************************************************/
|
711
|
-
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
712
|
-
|
713
|
-
"use strict";
|
714
|
-
|
715
|
-
var fixRegExpWellKnownSymbolLogic = __webpack_require__(/*! ../internals/fix-regexp-well-known-symbol-logic */ "./node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js");
|
716
|
-
var anObject = __webpack_require__(/*! ../internals/an-object */ "./node_modules/core-js/internals/an-object.js");
|
717
|
-
var toLength = __webpack_require__(/*! ../internals/to-length */ "./node_modules/core-js/internals/to-length.js");
|
718
|
-
var toString = __webpack_require__(/*! ../internals/to-string */ "./node_modules/core-js/internals/to-string.js");
|
719
|
-
var requireObjectCoercible = __webpack_require__(/*! ../internals/require-object-coercible */ "./node_modules/core-js/internals/require-object-coercible.js");
|
720
|
-
var advanceStringIndex = __webpack_require__(/*! ../internals/advance-string-index */ "./node_modules/core-js/internals/advance-string-index.js");
|
721
|
-
var regExpExec = __webpack_require__(/*! ../internals/regexp-exec-abstract */ "./node_modules/core-js/internals/regexp-exec-abstract.js");
|
722
|
-
|
723
|
-
// @@match logic
|
724
|
-
fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
|
725
|
-
return [
|
726
|
-
// `String.prototype.match` method
|
727
|
-
// https://tc39.es/ecma262/#sec-string.prototype.match
|
728
|
-
function match(regexp) {
|
729
|
-
var O = requireObjectCoercible(this);
|
730
|
-
var matcher = regexp == undefined ? undefined : regexp[MATCH];
|
731
|
-
return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](toString(O));
|
732
|
-
},
|
733
|
-
// `RegExp.prototype[@@match]` method
|
734
|
-
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
|
735
|
-
function (string) {
|
736
|
-
var rx = anObject(this);
|
737
|
-
var S = toString(string);
|
738
|
-
var res = maybeCallNative(nativeMatch, rx, S);
|
739
|
-
|
740
|
-
if (res.done) return res.value;
|
741
|
-
|
742
|
-
if (!rx.global) return regExpExec(rx, S);
|
743
|
-
|
744
|
-
var fullUnicode = rx.unicode;
|
745
|
-
rx.lastIndex = 0;
|
746
|
-
var A = [];
|
747
|
-
var n = 0;
|
748
|
-
var result;
|
749
|
-
while ((result = regExpExec(rx, S)) !== null) {
|
750
|
-
var matchStr = toString(result[0]);
|
751
|
-
A[n] = matchStr;
|
752
|
-
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
|
753
|
-
n++;
|
754
|
-
}
|
755
|
-
return n === 0 ? null : A;
|
756
|
-
}
|
757
|
-
];
|
758
|
-
});
|
759
|
-
|
760
|
-
|
761
|
-
/***/ })
|
762
|
-
|
763
|
-
},
|
764
|
-
/******/ function(__webpack_require__) { // webpackRuntimeModules
|
765
|
-
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
766
|
-
/******/ var __webpack_exports__ = (__webpack_exec__("./src/plugins/plugin.url.js"));
|
767
|
-
/******/ }
|
768
|
-
]);
|
1
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[336],{8837:function(t,o,e){var a;e(5827),e(4916),e(5306),e(2222),e(6992),e(1539),e(8783),e(3948),e(285),e(3609).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view"],urlTrackIndex0:!1}),BookReader.prototype.setup=(a=BookReader.prototype.setup,function(t){a.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var o=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,(function(){var t=o.options,e=t.updateWindowTitle,a=t.urlMode;e&&(document.title=o.shortTitle(50)),"hash"===a&&o.urlStartLocationPolling()})),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollID),this.locationPollId=null),this.locationPollId=setInterval((function(){var o=t.urlReadFragment();if(o!=t.oldLocationHash&&o!=t.oldUserHash){var e=t.paramsFromFragment(o),a=function(){return t.updateFromParams(e)};t.trigger(BookReader.eventNames.stop),t.animating?(t.autoStop&&t.autoStop(),t.animationFinishedCallback=a):a(),t.oldUserHash=o}}),500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),o=this.options,e=o.urlMode,a=o.urlTrackIndex0,r=o.urlTrackedParams;a||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var i=r.reduce((function(o,e){return e in t&&(o[e]=t[e]),o}),{}),n=this.fragmentFromParams(i,e),s=this.urlReadFragment(),l=this.getLocationSearch(),h=this.queryStringFromParams(i,l,e);if(s!==n||l!==h)if("history"===e){if(window.history&&window.history.replaceState){var d=this.options.urlHistoryBasePath.replace(/\/+$/,""),u=""===n?"":"/".concat(n),c="".concat(d).concat(u).concat(h);window.history.replaceState({},null,c),this.oldLocationHash=n+h}}else{var p=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+n+p),this.oldLocationHash=n+p}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var o=new URLSearchParams(t);return o.has("q")?"?".concat(new URLSearchParams({q:o.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,o=t.urlMode,e=t.urlHistoryBasePath;return"history"===o?window.location.pathname.substr(e.length):window.location.hash.substr(1)},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)}}},function(t){t(t.s=8837)}]);
|
769
2
|
//# sourceMappingURL=plugin.url.js.map
|