@internetarchive/bookreader 5.0.0-88-alpha.7 → 5.0.0-88-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +30 -12
- package/dist/esm/BookNavigator/assets/bookmark-colors.js +4 -0
- package/dist/esm/BookNavigator/assets/button-base.js +4 -0
- package/dist/esm/BookNavigator/assets/ia-logo.js +4 -0
- package/dist/esm/BookNavigator/assets/icon_checkmark.js +8 -0
- package/dist/esm/BookNavigator/assets/icon_close.js +4 -0
- package/dist/esm/BookNavigator/book-navigator.js +612 -0
- package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +35 -0
- package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +78 -0
- package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +160 -0
- package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +24 -0
- package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +55 -0
- package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +521 -0
- package/dist/esm/BookNavigator/delete-modal-actions.js +29 -0
- package/dist/esm/BookNavigator/downloads/downloads-provider.js +84 -0
- package/dist/esm/BookNavigator/downloads/downloads.js +69 -0
- package/dist/esm/BookNavigator/search/search-provider.js +238 -0
- package/dist/esm/BookNavigator/search/search-results.js +161 -0
- package/dist/esm/BookNavigator/sharing.js +26 -0
- package/dist/esm/BookNavigator/viewable-files.js +94 -0
- package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +83 -0
- package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +131 -0
- package/dist/esm/BookReader/BookModel.js +575 -0
- package/dist/esm/BookReader/DragScrollable.js +224 -0
- package/dist/esm/BookReader/ImageCache.js +122 -0
- package/dist/esm/BookReader/Mode1Up.js +114 -0
- package/dist/esm/BookReader/Mode1UpLit.js +579 -0
- package/dist/esm/BookReader/Mode2Up.js +106 -0
- package/dist/esm/BookReader/Mode2UpLit.js +1020 -0
- package/dist/esm/BookReader/ModeCoordinateSpace.js +28 -0
- package/dist/esm/BookReader/ModeSmoothZoom.js +318 -0
- package/dist/esm/BookReader/ModeThumb.js +366 -0
- package/dist/esm/BookReader/Navbar/Navbar.js +253 -0
- package/dist/esm/BookReader/PageContainer.js +165 -0
- package/dist/esm/BookReader/ReduceSet.js +27 -0
- package/dist/esm/BookReader/Toolbar/Toolbar.js +242 -0
- package/dist/esm/BookReader/events.js +20 -0
- package/dist/esm/BookReader/options.js +331 -0
- package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +48 -0
- package/dist/esm/BookReader/utils/ScrollClassAdder.js +31 -0
- package/dist/esm/BookReader/utils/SelectionObserver.js +42 -0
- package/dist/esm/BookReader/utils/classes.js +37 -0
- package/dist/esm/BookReader/utils.js +315 -0
- package/dist/esm/BookReader.js +1827 -0
- package/dist/esm/assets/icons/1up.svg +12 -0
- package/dist/esm/assets/icons/2up.svg +15 -0
- package/dist/esm/assets/icons/advance.svg +26 -0
- package/dist/esm/assets/icons/chevron-right.svg +1 -0
- package/dist/esm/assets/icons/close-circle-dark.svg +1 -0
- package/dist/esm/assets/icons/close-circle.svg +1 -0
- package/dist/esm/assets/icons/fullscreen.svg +17 -0
- package/dist/esm/assets/icons/fullscreen_exit.svg +17 -0
- package/dist/esm/assets/icons/hamburger.svg +15 -0
- package/dist/esm/assets/icons/left-arrow.svg +12 -0
- package/dist/esm/assets/icons/magnify-minus.svg +12 -0
- package/dist/esm/assets/icons/magnify-plus.svg +13 -0
- package/dist/esm/assets/icons/magnify.svg +15 -0
- package/dist/esm/assets/icons/pause.svg +23 -0
- package/dist/esm/assets/icons/play.svg +22 -0
- package/dist/esm/assets/icons/playback-speed.svg +34 -0
- package/dist/esm/assets/icons/read-aloud.svg +22 -0
- package/dist/esm/assets/icons/review.svg +22 -0
- package/dist/esm/assets/icons/thumbnails.svg +17 -0
- package/dist/esm/assets/icons/voice.svg +1 -0
- package/dist/esm/assets/icons/volume-full.svg +22 -0
- package/dist/esm/assets/images/BRicons.png +0 -0
- package/dist/esm/assets/images/BRicons.svg +94 -0
- package/dist/esm/assets/images/BRicons_ia.png +0 -0
- package/dist/esm/assets/images/back_pages.png +0 -0
- package/dist/esm/assets/images/book_bottom_icon.png +0 -0
- package/dist/esm/assets/images/book_down_icon.png +0 -0
- package/dist/esm/assets/images/book_left_icon.png +0 -0
- package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
- package/dist/esm/assets/images/book_right_icon.png +0 -0
- package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
- package/dist/esm/assets/images/book_top_icon.png +0 -0
- package/dist/esm/assets/images/book_up_icon.png +0 -0
- package/dist/esm/assets/images/books_graphic.svg +177 -0
- package/dist/esm/assets/images/booksplit.png +0 -0
- package/dist/esm/assets/images/control_pause_icon.png +0 -0
- package/dist/esm/assets/images/control_play_icon.png +0 -0
- package/dist/esm/assets/images/embed_icon.png +0 -0
- package/dist/esm/assets/images/icon-home-ia.png +0 -0
- package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
- package/dist/esm/assets/images/icon_alert-xs.png +0 -0
- package/dist/esm/assets/images/icon_book.svg +12 -0
- package/dist/esm/assets/images/icon_bookmark.svg +12 -0
- package/dist/esm/assets/images/icon_close-pop.png +0 -0
- package/dist/esm/assets/images/icon_download.png +0 -0
- package/dist/esm/assets/images/icon_gear.svg +14 -0
- package/dist/esm/assets/images/icon_hamburger.svg +20 -0
- package/dist/esm/assets/images/icon_home.png +0 -0
- package/dist/esm/assets/images/icon_home.svg +21 -0
- package/dist/esm/assets/images/icon_home_ia.png +0 -0
- package/dist/esm/assets/images/icon_indicator.png +0 -0
- package/dist/esm/assets/images/icon_info.svg +11 -0
- package/dist/esm/assets/images/icon_one_page.svg +8 -0
- package/dist/esm/assets/images/icon_pause.svg +1 -0
- package/dist/esm/assets/images/icon_play.svg +1 -0
- package/dist/esm/assets/images/icon_playback-rate.svg +15 -0
- package/dist/esm/assets/images/icon_return.png +0 -0
- package/dist/esm/assets/images/icon_search_button.svg +8 -0
- package/dist/esm/assets/images/icon_share.svg +9 -0
- package/dist/esm/assets/images/icon_skip-ahead.svg +6 -0
- package/dist/esm/assets/images/icon_skip-back.svg +13 -0
- package/dist/esm/assets/images/icon_speaker.svg +18 -0
- package/dist/esm/assets/images/icon_speaker_open.svg +10 -0
- package/dist/esm/assets/images/icon_thumbnails.svg +12 -0
- package/dist/esm/assets/images/icon_toc.svg +5 -0
- package/dist/esm/assets/images/icon_two_pages.svg +9 -0
- package/dist/esm/assets/images/icon_zoomer.png +0 -0
- package/dist/esm/assets/images/loading.gif +0 -0
- package/dist/esm/assets/images/logo_icon.png +0 -0
- package/dist/esm/assets/images/marker_chap-off.png +0 -0
- package/dist/esm/assets/images/marker_chap-off.svg +11 -0
- package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
- package/dist/esm/assets/images/marker_chap-on.png +0 -0
- package/dist/esm/assets/images/marker_chap-on.svg +11 -0
- package/dist/esm/assets/images/marker_srch-on.svg +11 -0
- package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
- package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
- package/dist/esm/assets/images/nav_control-dn.png +0 -0
- package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
- package/dist/esm/assets/images/nav_control-up.png +0 -0
- package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
- package/dist/esm/assets/images/nav_control.png +0 -0
- package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
- package/dist/esm/assets/images/paper-badge.png +0 -0
- package/dist/esm/assets/images/print_icon.png +0 -0
- package/dist/esm/assets/images/progressbar.gif +0 -0
- package/dist/esm/assets/images/right_edges.png +0 -0
- package/dist/esm/assets/images/slider.png +0 -0
- package/dist/esm/assets/images/slider_ia.png +0 -0
- package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
- package/dist/esm/assets/images/transparent.png +0 -0
- package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
- package/dist/esm/assets/images/unviewable_page.png +0 -0
- package/dist/esm/assets/images/zoom_in_icon.png +0 -0
- package/dist/esm/assets/images/zoom_out_icon.png +0 -0
- package/dist/esm/css/BookReader.scss +85 -0
- package/dist/esm/css/_BRBookmarks.scss +29 -0
- package/dist/esm/css/_BRComponent.scss +13 -0
- package/dist/esm/css/_BRfloat.scss +197 -0
- package/dist/esm/css/_BRicon.scss +54 -0
- package/dist/esm/css/_BRmain.scss +262 -0
- package/dist/esm/css/_BRnav.scss +354 -0
- package/dist/esm/css/_BRpages.scss +213 -0
- package/dist/esm/css/_BRsearch.scss +268 -0
- package/dist/esm/css/_BRtoolbar.scss +84 -0
- package/dist/esm/css/_BRvendor.scss +5 -0
- package/dist/esm/css/_TextSelection.scss +108 -0
- package/dist/esm/css/_colorbox.scss +52 -0
- package/dist/esm/css/_controls.scss +257 -0
- package/dist/esm/css/_icons.scss +121 -0
- package/dist/esm/ia-bookreader/ia-bookreader.js +141 -0
- package/dist/esm/jquery-wrapper.js +3 -0
- package/dist/esm/plugins/plugin.archive_analytics.js +72 -0
- package/dist/esm/plugins/plugin.autoplay.js +119 -0
- package/dist/esm/plugins/plugin.chapters.js +288 -0
- package/dist/esm/plugins/plugin.iframe.js +44 -0
- package/dist/esm/plugins/plugin.iiif.js +146 -0
- package/dist/esm/plugins/plugin.resume.js +66 -0
- package/dist/esm/plugins/plugin.text_selection.js +621 -0
- package/dist/esm/plugins/plugin.vendor-fullscreen.js +227 -0
- package/dist/esm/plugins/search/plugin.search.js +499 -0
- package/dist/esm/plugins/search/utils.js +42 -0
- package/dist/esm/plugins/search/view.js +360 -0
- package/dist/esm/plugins/tts/AbstractTTSEngine.js +282 -0
- package/dist/esm/plugins/tts/FestivalTTSEngine.js +192 -0
- package/dist/esm/plugins/tts/PageChunk.js +105 -0
- package/dist/esm/plugins/tts/PageChunkIterator.js +155 -0
- package/dist/esm/plugins/tts/WebTTSEngine.js +364 -0
- package/dist/esm/plugins/tts/plugin.tts.js +315 -0
- package/dist/esm/plugins/tts/tooltip_dict.js +14 -0
- package/dist/esm/plugins/tts/utils.js +79 -0
- package/dist/esm/plugins/url/UrlPlugin.js +197 -0
- package/dist/esm/plugins/url/plugin.url.js +212 -0
- package/dist/esm/util/browserSniffing.js +56 -0
- package/dist/esm/util/debouncer.js +25 -0
- package/dist/esm/util/docCookies.js +75 -0
- package/dist/esm/util/strings.js +34 -0
- package/jsconfig.json +1 -0
- package/package.json +13 -6
@@ -0,0 +1,288 @@
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
2
|
+
function _decorate(e, r, t, i) { var o = _getDecoratorsApi(); if (i) for (var n = 0; n < i.length; n++) o = i[n](o); var s = r(function (e) { o.initializeInstanceElements(e, a.elements); }, t), a = o.decorateClass(_coalesceClassElements(s.d.map(_createElementDescriptor)), e); return o.initializeClassElements(s.F, a.elements), o.runClassFinishers(s.F, a.finishers); }
|
3
|
+
function _getDecoratorsApi() { _getDecoratorsApi = function _getDecoratorsApi() { return e; }; var e = { elementsDefinitionOrder: [["method"], ["field"]], initializeInstanceElements: function initializeInstanceElements(e, r) { ["method", "field"].forEach(function (t) { r.forEach(function (r) { r.kind === t && "own" === r.placement && this.defineClassElement(e, r); }, this); }, this); }, initializeClassElements: function initializeClassElements(e, r) { var t = e.prototype; ["method", "field"].forEach(function (i) { r.forEach(function (r) { var o = r.placement; if (r.kind === i && ("static" === o || "prototype" === o)) { var n = "static" === o ? e : t; this.defineClassElement(n, r); } }, this); }, this); }, defineClassElement: function defineClassElement(e, r) { var t = r.descriptor; if ("field" === r.kind) { var i = r.initializer; t = { enumerable: t.enumerable, writable: t.writable, configurable: t.configurable, value: void 0 === i ? void 0 : i.call(e) }; } Object.defineProperty(e, r.key, t); }, decorateClass: function decorateClass(e, r) { var t = [], i = [], o = { static: [], prototype: [], own: [] }; if (e.forEach(function (e) { this.addElementPlacement(e, o); }, this), e.forEach(function (e) { if (!_hasDecorators(e)) return t.push(e); var r = this.decorateElement(e, o); t.push(r.element), t.push.apply(t, r.extras), i.push.apply(i, r.finishers); }, this), !r) return { elements: t, finishers: i }; var n = this.decorateConstructor(t, r); return i.push.apply(i, n.finishers), n.finishers = i, n; }, addElementPlacement: function addElementPlacement(e, r, t) { var i = r[e.placement]; if (!t && -1 !== i.indexOf(e.key)) throw new TypeError("Duplicated element (" + e.key + ")"); i.push(e.key); }, decorateElement: function decorateElement(e, r) { for (var t = [], i = [], o = e.decorators, n = o.length - 1; n >= 0; n--) { var s = r[e.placement]; s.splice(s.indexOf(e.key), 1); var a = this.fromElementDescriptor(e), l = this.toElementFinisherExtras((0, o[n])(a) || a); e = l.element, this.addElementPlacement(e, r), l.finisher && i.push(l.finisher); var c = l.extras; if (c) { for (var p = 0; p < c.length; p++) this.addElementPlacement(c[p], r); t.push.apply(t, c); } } return { element: e, finishers: i, extras: t }; }, decorateConstructor: function decorateConstructor(e, r) { for (var t = [], i = r.length - 1; i >= 0; i--) { var o = this.fromClassDescriptor(e), n = this.toClassDescriptor((0, r[i])(o) || o); if (void 0 !== n.finisher && t.push(n.finisher), void 0 !== n.elements) { e = n.elements; for (var s = 0; s < e.length - 1; s++) for (var a = s + 1; a < e.length; a++) if (e[s].key === e[a].key && e[s].placement === e[a].placement) throw new TypeError("Duplicated element (" + e[s].key + ")"); } } return { elements: e, finishers: t }; }, fromElementDescriptor: function fromElementDescriptor(e) { var r = { kind: e.kind, key: e.key, placement: e.placement, descriptor: e.descriptor }; return Object.defineProperty(r, Symbol.toStringTag, { value: "Descriptor", configurable: !0 }), "field" === e.kind && (r.initializer = e.initializer), r; }, toElementDescriptors: function toElementDescriptors(e) { if (void 0 !== e) return _toArray(e).map(function (e) { var r = this.toElementDescriptor(e); return this.disallowProperty(e, "finisher", "An element descriptor"), this.disallowProperty(e, "extras", "An element descriptor"), r; }, this); }, toElementDescriptor: function toElementDescriptor(e) { var r = e.kind + ""; if ("method" !== r && "field" !== r) throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "' + r + '"'); var t = _toPropertyKey(e.key), i = e.placement + ""; if ("static" !== i && "prototype" !== i && "own" !== i) throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "' + i + '"'); var o = e.descriptor; this.disallowProperty(e, "elements", "An element descriptor"); var n = { kind: r, key: t, placement: i, descriptor: Object.assign({}, o) }; return "field" !== r ? this.disallowProperty(e, "initializer", "A method descriptor") : (this.disallowProperty(o, "get", "The property descriptor of a field descriptor"), this.disallowProperty(o, "set", "The property descriptor of a field descriptor"), this.disallowProperty(o, "value", "The property descriptor of a field descriptor"), n.initializer = e.initializer), n; }, toElementFinisherExtras: function toElementFinisherExtras(e) { return { element: this.toElementDescriptor(e), finisher: _optionalCallableProperty(e, "finisher"), extras: this.toElementDescriptors(e.extras) }; }, fromClassDescriptor: function fromClassDescriptor(e) { var r = { kind: "class", elements: e.map(this.fromElementDescriptor, this) }; return Object.defineProperty(r, Symbol.toStringTag, { value: "Descriptor", configurable: !0 }), r; }, toClassDescriptor: function toClassDescriptor(e) { var r = e.kind + ""; if ("class" !== r) throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "' + r + '"'); this.disallowProperty(e, "key", "A class descriptor"), this.disallowProperty(e, "placement", "A class descriptor"), this.disallowProperty(e, "descriptor", "A class descriptor"), this.disallowProperty(e, "initializer", "A class descriptor"), this.disallowProperty(e, "extras", "A class descriptor"); var t = _optionalCallableProperty(e, "finisher"); return { elements: this.toElementDescriptors(e.elements), finisher: t }; }, runClassFinishers: function runClassFinishers(e, r) { for (var t = 0; t < r.length; t++) { var i = (0, r[t])(e); if (void 0 !== i) { if ("function" != typeof i) throw new TypeError("Finishers must return a constructor."); e = i; } } return e; }, disallowProperty: function disallowProperty(e, r, t) { if (void 0 !== e[r]) throw new TypeError(t + " can't have a ." + r + " property."); } }; return e; }
|
4
|
+
function _createElementDescriptor(e) { var r, t = _toPropertyKey(e.key); "method" === e.kind ? r = { value: e.value, writable: !0, configurable: !0, enumerable: !1 } : "get" === e.kind ? r = { get: e.value, configurable: !0, enumerable: !1 } : "set" === e.kind ? r = { set: e.value, configurable: !0, enumerable: !1 } : "field" === e.kind && (r = { configurable: !0, writable: !0, enumerable: !0 }); var i = { kind: "field" === e.kind ? "field" : "method", key: t, placement: e.static ? "static" : "field" === e.kind ? "own" : "prototype", descriptor: r }; return e.decorators && (i.decorators = e.decorators), "field" === e.kind && (i.initializer = e.value), i; }
|
5
|
+
function _coalesceGetterSetter(e, r) { void 0 !== e.descriptor.get ? r.descriptor.get = e.descriptor.get : r.descriptor.set = e.descriptor.set; }
|
6
|
+
function _coalesceClassElements(e) { for (var r = [], isSameElement = function isSameElement(e) { return "method" === e.kind && e.key === o.key && e.placement === o.placement; }, t = 0; t < e.length; t++) { var i, o = e[t]; if ("method" === o.kind && (i = r.find(isSameElement))) { if (_isDataDescriptor(o.descriptor) || _isDataDescriptor(i.descriptor)) { if (_hasDecorators(o) || _hasDecorators(i)) throw new ReferenceError("Duplicated methods (" + o.key + ") can't be decorated."); i.descriptor = o.descriptor; } else { if (_hasDecorators(o)) { if (_hasDecorators(i)) throw new ReferenceError("Decorators can't be placed on different accessors with for the same property (" + o.key + ")."); i.decorators = o.decorators; } _coalesceGetterSetter(o, i); } } else r.push(o); } return r; }
|
7
|
+
function _hasDecorators(e) { return e.decorators && e.decorators.length; }
|
8
|
+
function _isDataDescriptor(e) { return void 0 !== e && !(void 0 === e.value && void 0 === e.writable); }
|
9
|
+
function _optionalCallableProperty(e, r) { var t = e[r]; if (void 0 !== t && "function" != typeof t) throw new TypeError("Expected '" + r + "' to be a function"); return t; }
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
12
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
13
|
+
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."); }
|
14
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
15
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
16
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
17
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
18
|
+
function _superPropGet(t, e, o, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), e, o); return 2 & r && "function" == typeof p ? function (t) { return p.apply(o, t); } : p; }
|
19
|
+
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
|
20
|
+
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
21
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
22
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
23
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
24
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
25
|
+
/* global BookReader */
|
26
|
+
import { css, html, LitElement, nothing } from "lit";
|
27
|
+
import { customElement, property } from 'lit/decorators.js';
|
28
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
29
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
30
|
+
import '@internetarchive/icon-toc/icon-toc';
|
31
|
+
/** @typedef {import('@/src/BookNavigator/book-navigator.js').BookNavigator} BookNavigator */
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Plugin for chapter markers in BookReader. Fetches from openlibrary.org
|
35
|
+
* Could be forked, or extended to alter behavior
|
36
|
+
*/
|
37
|
+
|
38
|
+
jQuery.extend(BookReader.defaultOptions, {
|
39
|
+
olHost: 'https://openlibrary.org',
|
40
|
+
enableChaptersPlugin: true,
|
41
|
+
bookId: ''
|
42
|
+
});
|
43
|
+
|
44
|
+
/** @override Extend to call Open Library for TOC */
|
45
|
+
BookReader.prototype.init = function (super_) {
|
46
|
+
return function () {
|
47
|
+
super_.call(this);
|
48
|
+
if (this.options.enableChaptersPlugin && this.ui !== 'embed') {
|
49
|
+
this._chapterInit();
|
50
|
+
}
|
51
|
+
};
|
52
|
+
}(BookReader.prototype.init);
|
53
|
+
BookReader.prototype._chapterInit = /*#__PURE__*/_asyncToGenerator(function* () {
|
54
|
+
var _this$options$table_o;
|
55
|
+
var rawTableOfContents = null;
|
56
|
+
// Prefer IA TOC for now, until we update the second half to check for
|
57
|
+
// `openlibrary_edition` on the IA metadata instead of making a bunch of
|
58
|
+
// requests to OL.
|
59
|
+
if ((_this$options$table_o = this.options.table_of_contents) !== null && _this$options$table_o !== void 0 && _this$options$table_o.length) {
|
60
|
+
rawTableOfContents = this.options.table_of_contents;
|
61
|
+
} else {
|
62
|
+
var _olEdition$table_of_c;
|
63
|
+
var olEdition = yield this.getOpenLibraryRecord(this.options.olHost, this.options.bookId);
|
64
|
+
if (olEdition !== null && olEdition !== void 0 && (_olEdition$table_of_c = olEdition.table_of_contents) !== null && _olEdition$table_of_c !== void 0 && _olEdition$table_of_c.length) {
|
65
|
+
rawTableOfContents = olEdition.table_of_contents;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
if (rawTableOfContents) {
|
69
|
+
this._tocEntries = rawTableOfContents.map(rawTOCEntry => Object.assign({}, rawTOCEntry, {
|
70
|
+
pageIndex: typeof rawTOCEntry.leaf == 'number' ? this.book.leafNumToIndex(rawTOCEntry.leaf) : rawTOCEntry.pagenum ? this.book.getPageIndex(rawTOCEntry.pagenum) : undefined
|
71
|
+
}));
|
72
|
+
this._chaptersRender(this._tocEntries);
|
73
|
+
this.bind(BookReader.eventNames.pageChanged, () => this._chaptersUpdateCurrent());
|
74
|
+
}
|
75
|
+
});
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Update the table of contents based on array of TOC entries.
|
79
|
+
*/
|
80
|
+
BookReader.prototype._chaptersRender = function () {
|
81
|
+
var shell = /** @type {BookNavigator} */this.shell;
|
82
|
+
shell.menuProviders['chapters'] = {
|
83
|
+
id: 'chapters',
|
84
|
+
icon: html(_templateObject || (_templateObject = _taggedTemplateLiteral(["<ia-icon-toc style=\"width: var(--iconWidth); height: var(--iconHeight);\"></ia-icon-toc>"]))),
|
85
|
+
label: 'Table of Contents',
|
86
|
+
component: html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["<br-chapters-panel\n .contents=\"", "\"\n .jumpToPage=\"", "\"\n @connected=\"", "\"\n />"])), this._tocEntries, pageIndex => {
|
87
|
+
this._chaptersUpdateCurrent(pageIndex);
|
88
|
+
this.jumpToIndex(pageIndex);
|
89
|
+
}, e => {
|
90
|
+
this._chaptersPanel = e.target;
|
91
|
+
this._chaptersUpdateCurrent();
|
92
|
+
})
|
93
|
+
};
|
94
|
+
shell.addMenuShortcut('chapters');
|
95
|
+
shell.updateMenuContents();
|
96
|
+
this._tocEntries.forEach((tocEntry, i) => this._chaptersRenderMarker(tocEntry, i));
|
97
|
+
};
|
98
|
+
|
99
|
+
/**
|
100
|
+
* @typedef {Object} TocEntry
|
101
|
+
* Table of contents entry as defined by Open Library, with some extra values for internal use
|
102
|
+
* @property {number} [level]
|
103
|
+
* @property {string} [label]
|
104
|
+
* @property {string} [title]
|
105
|
+
* @property {PageString} [pagenum]
|
106
|
+
* @property {LeafNum} [leaf]
|
107
|
+
* @property {number} [pageIndex] - Added
|
108
|
+
*
|
109
|
+
* @example {
|
110
|
+
* "pagenum": "17",
|
111
|
+
* "level": 1,
|
112
|
+
* "label": "CHAPTER I",
|
113
|
+
* "title": "THE COUNTRY AND THE MISSION"
|
114
|
+
* }
|
115
|
+
*/
|
116
|
+
|
117
|
+
/**
|
118
|
+
* @param {TocEntry} tocEntry
|
119
|
+
* @param {number} entryIndex
|
120
|
+
*/
|
121
|
+
BookReader.prototype._chaptersRenderMarker = function (tocEntry, entryIndex) {
|
122
|
+
if (tocEntry.pageIndex == undefined) return;
|
123
|
+
|
124
|
+
//creates a string with non-void tocEntry.label and tocEntry.title
|
125
|
+
var chapterStr = [tocEntry.label, tocEntry.title].filter(x => x).join(' ') || "Chapter ".concat(entryIndex + 1);
|
126
|
+
var percentThrough = BookReader.util.cssPercentage(tocEntry.pageIndex, this.book.getNumLeafs() - 1);
|
127
|
+
$("<div></div>").append($('<div />').text(chapterStr).append($('<div class="BRchapterPage" />').text(this.book.getPageName(tocEntry.pageIndex)))).addClass('BRchapter').css({
|
128
|
+
left: percentThrough
|
129
|
+
}).appendTo(this.$('.BRnavline')).on("mouseenter", event => {
|
130
|
+
// remove hover effect from other markers then turn on just for this
|
131
|
+
var marker = event.currentTarget;
|
132
|
+
var tooltip = marker.querySelector('div');
|
133
|
+
var tooltipOffset = tooltip.getBoundingClientRect();
|
134
|
+
var targetOffset = marker.getBoundingClientRect();
|
135
|
+
var boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;
|
136
|
+
if (tooltipOffset.x - boxSizeAdjust < 0) {
|
137
|
+
tooltip.style.setProperty('transform', "translateX(-".concat(targetOffset.left - boxSizeAdjust, "px)"));
|
138
|
+
}
|
139
|
+
this.$('.BRsearch,.BRchapter').removeClass('front');
|
140
|
+
$(event.target).addClass('front');
|
141
|
+
}).on("mouseleave", event => $(event.target).removeClass('front')).on('click', () => {
|
142
|
+
this._chaptersUpdateCurrent(tocEntry.pageIndex);
|
143
|
+
this.jumpToIndex(tocEntry.pageIndex);
|
144
|
+
});
|
145
|
+
this.$('.BRchapter, .BRsearch').each((i, el) => {
|
146
|
+
var $el = $(el);
|
147
|
+
$el.on("mouseenter", () => $el.addClass('front')).on("mouseleave", () => $el.removeClass('front'));
|
148
|
+
});
|
149
|
+
};
|
150
|
+
|
151
|
+
/**
|
152
|
+
* This makes a call to OL API and calls the given callback function with the
|
153
|
+
* response from the API.
|
154
|
+
*
|
155
|
+
* @param {string} olHost
|
156
|
+
* @param {string} ocaid
|
157
|
+
*/
|
158
|
+
BookReader.prototype.getOpenLibraryRecord = /*#__PURE__*/function () {
|
159
|
+
var _ref2 = _asyncToGenerator(function* (olHost, ocaid) {
|
160
|
+
var _data;
|
161
|
+
// Try looking up by ocaid first, then by source_record
|
162
|
+
var baseURL = "".concat(olHost, "/query.json?type=/type/edition&*=");
|
163
|
+
var fetchUrlByBookId = "".concat(baseURL, "&ocaid=").concat(ocaid);
|
164
|
+
var data = yield $.ajax({
|
165
|
+
url: fetchUrlByBookId
|
166
|
+
});
|
167
|
+
if (!data || !data.length) {
|
168
|
+
// try sourceid
|
169
|
+
data = yield $.ajax({
|
170
|
+
url: "".concat(baseURL, "&source_records=ia:").concat(ocaid)
|
171
|
+
});
|
172
|
+
}
|
173
|
+
return (_data = data) === null || _data === void 0 ? void 0 : _data[0];
|
174
|
+
});
|
175
|
+
return function (_x, _x2) {
|
176
|
+
return _ref2.apply(this, arguments);
|
177
|
+
};
|
178
|
+
}();
|
179
|
+
|
180
|
+
/**
|
181
|
+
* @private
|
182
|
+
* Highlights the current chapter based on current page
|
183
|
+
* @param {PageIndex} curIndex
|
184
|
+
*/
|
185
|
+
BookReader.prototype._chaptersUpdateCurrent = function () {
|
186
|
+
var curIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.mode == 2 ? Math.max(...this.displayedIndices) : this.firstIndex;
|
187
|
+
var tocEntriesIndexed = this._tocEntries.filter(el => el.pageIndex != undefined).reverse();
|
188
|
+
var currChapter = tocEntriesIndexed[
|
189
|
+
// subtract one so that 2up shows the right label
|
190
|
+
tocEntriesIndexed.findIndex(chapter => chapter.pageIndex <= curIndex)];
|
191
|
+
if (this._chaptersPanel) {
|
192
|
+
this._chaptersPanel.currentChapter = currChapter;
|
193
|
+
}
|
194
|
+
};
|
195
|
+
export var BRChaptersPanel = _decorate(null, function (_initialize, _LitElement) {
|
196
|
+
class BRChaptersPanel extends _LitElement {
|
197
|
+
/** @type {TocEntry[]} */
|
198
|
+
|
199
|
+
/** @type {TocEntry?} */
|
200
|
+
|
201
|
+
/** @type {(pageIndex: PageIndex) => void} */
|
202
|
+
|
203
|
+
/**
|
204
|
+
* @param {TocEntry[]} contents
|
205
|
+
*/
|
206
|
+
constructor(contents) {
|
207
|
+
super();
|
208
|
+
_initialize(this);
|
209
|
+
this.contents = contents;
|
210
|
+
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* @param {TocEntry} tocEntry
|
214
|
+
*/
|
215
|
+
}
|
216
|
+
return {
|
217
|
+
F: BRChaptersPanel,
|
218
|
+
d: [{
|
219
|
+
kind: "field",
|
220
|
+
decorators: [property({
|
221
|
+
type: Array
|
222
|
+
})],
|
223
|
+
key: "contents",
|
224
|
+
value() {
|
225
|
+
return [];
|
226
|
+
}
|
227
|
+
}, {
|
228
|
+
kind: "field",
|
229
|
+
decorators: [property({
|
230
|
+
type: Object
|
231
|
+
})],
|
232
|
+
key: "currentChapter",
|
233
|
+
value() {
|
234
|
+
return {};
|
235
|
+
}
|
236
|
+
}, {
|
237
|
+
kind: "field",
|
238
|
+
key: "jumpToPage",
|
239
|
+
value() {
|
240
|
+
return () => {};
|
241
|
+
}
|
242
|
+
}, {
|
243
|
+
kind: "method",
|
244
|
+
key: "render",
|
245
|
+
value: function render() {
|
246
|
+
return html(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n <ol>\n ", "\n </ol>\n "])), this.contents.map(tocEntry => this.renderTOCEntry(tocEntry)));
|
247
|
+
}
|
248
|
+
}, {
|
249
|
+
kind: "method",
|
250
|
+
key: "renderTOCEntry",
|
251
|
+
value: function renderTOCEntry(tocEntry) {
|
252
|
+
var chapterTitle = [tocEntry.label, tocEntry.title].filter(x => x).join(' ');
|
253
|
+
var clickable = tocEntry.pageIndex != undefined;
|
254
|
+
// note the click-tracking won't work...
|
255
|
+
return html(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral([" <li\n class=\"\n BRtable-contents-el\n ", "\n ", "\n \"\n style=\"", "\"\n data-event-click-tracking=\"", "\"\n @click=\"", "\"\n >\n ", "\n ", "\n </li>"])), clickable ? 'clickable' : '', tocEntry == this.currentChapter ? 'current' : '', styleMap({
|
256
|
+
marginLeft: (tocEntry.level - 1) * 10 + 'px'
|
257
|
+
}), ifDefined(clickable ? 'BRTOCPanel|GoToChapter' : undefined), () => this.jumpToPage(tocEntry.pageIndex), chapterTitle, tocEntry.pagenum ? html(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n <br />\n <span class=\"BRTOCElementPage\">Page ", "</span>\n "])), tocEntry.pagenum) : nothing);
|
258
|
+
}
|
259
|
+
}, {
|
260
|
+
kind: "method",
|
261
|
+
key: "connectedCallback",
|
262
|
+
value: function connectedCallback() {
|
263
|
+
_superPropGet(BRChaptersPanel, "connectedCallback", this, 3)([]);
|
264
|
+
this.dispatchEvent(new CustomEvent('connected'));
|
265
|
+
}
|
266
|
+
}, {
|
267
|
+
kind: "method",
|
268
|
+
key: "updated",
|
269
|
+
value: function updated(changedProperties) {
|
270
|
+
if (changedProperties.has('currentChapter')) {
|
271
|
+
var _this$shadowRoot$quer;
|
272
|
+
(_this$shadowRoot$quer = this.shadowRoot.querySelector('li.current')) === null || _this$shadowRoot$quer === void 0 || _this$shadowRoot$quer.scrollIntoView({
|
273
|
+
block: 'nearest',
|
274
|
+
behavior: 'smooth'
|
275
|
+
});
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}, {
|
279
|
+
kind: "get",
|
280
|
+
static: true,
|
281
|
+
key: "styles",
|
282
|
+
value: function value() {
|
283
|
+
return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ol {\n padding: 0;\n margin: 0;\n margin-right: 5px;\n }\n li {\n padding: 10px;\n overflow: hidden;\n border-radius: 4px;\n }\n li.clickable {\n font-weight: normal;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n li.clickable:not(.current):hover {\n background-color: rgba(255, 255, 255, 0.05);\n }\n\n li.current {\n background-color: rgba(255, 255, 255, 0.9);\n color: #333;\n }\n\n .BRTOCElementPage {\n font-size: 0.85em;\n opacity: 0.8;\n }\n "])));
|
284
|
+
}
|
285
|
+
}]
|
286
|
+
};
|
287
|
+
}, LitElement);
|
288
|
+
customElements.define('br-chapters-panel', BRChaptersPanel);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/* global BookReader */
|
2
|
+
/**
|
3
|
+
* Plugin for two-way communication between a BookReader in an IFrame and the
|
4
|
+
* parent web page
|
5
|
+
*/
|
6
|
+
|
7
|
+
var MESSAGE_TYPE_FRAGMENT_CHANGE = 'bookReaderFragmentChange';
|
8
|
+
BookReader.prototype.init = function (super_) {
|
9
|
+
return function () {
|
10
|
+
super_.call(this);
|
11
|
+
_attachEventListeners(this);
|
12
|
+
};
|
13
|
+
}(BookReader.prototype.init);
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @private
|
17
|
+
* Using window.postMessage() and event listeners, the plugin notifies the
|
18
|
+
* parent window when pages change, and the parent window can also
|
19
|
+
* explicitly request a page change by sending its own message.
|
20
|
+
*
|
21
|
+
* @param {BookReader} br
|
22
|
+
* @param {Window?} [parent]
|
23
|
+
*/
|
24
|
+
export function _attachEventListeners(br) {
|
25
|
+
var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.parent;
|
26
|
+
// Not embedded, abort
|
27
|
+
if (!parent) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
br.bind(BookReader.eventNames.fragmentChange, () => {
|
31
|
+
var fragment = br.fragmentFromParams(br.paramsFromCurrent());
|
32
|
+
parent.postMessage({
|
33
|
+
type: MESSAGE_TYPE_FRAGMENT_CHANGE,
|
34
|
+
fragment
|
35
|
+
}, '*');
|
36
|
+
});
|
37
|
+
window.addEventListener('message', event => {
|
38
|
+
// Not a recognized message type, abort
|
39
|
+
if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
br.updateFromParams(br.paramsFromFragment(event.data.fragment));
|
43
|
+
});
|
44
|
+
}
|
@@ -0,0 +1,146 @@
|
|
1
|
+
// @ts-check
|
2
|
+
var BookReader = /** @type {typeof import('../BookReader').default} */window.BookReader;
|
3
|
+
export var DEFAULT_OPTIONS = {
|
4
|
+
enabled: true,
|
5
|
+
/** @type {import('@iiif/presentation-3').Manifest | import('@iiif/presentation-2').Manifest} */
|
6
|
+
manifest: null
|
7
|
+
};
|
8
|
+
class IIIFPlugin {
|
9
|
+
constructor() {
|
10
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_OPTIONS;
|
11
|
+
var optionVariables = arguments.length > 1 ? arguments[1] : undefined;
|
12
|
+
this.options = options;
|
13
|
+
this.optionVariables = optionVariables;
|
14
|
+
this.manifest = options.manifest;
|
15
|
+
}
|
16
|
+
load() {
|
17
|
+
if (this.manifest["@context"] == "http://iiif.io/api/presentation/2/context.json") {
|
18
|
+
var manifest = /** @type {import('@iiif/presentation-2').Manifest} */this.manifest;
|
19
|
+
return this.manifestToBookReaderV2(manifest);
|
20
|
+
} else if (this.manifest["@context"] == "http://iiif.io/api/presentation/3/context.json") {
|
21
|
+
var _manifest = /** @type {import('@iiif/presentation-3').Manifest} */this.manifest;
|
22
|
+
return this.manifestToBookReaderV3(_manifest);
|
23
|
+
} else {
|
24
|
+
throw new Error("Unsupported IIIF context " + this.manifest["@context"]);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
/**
|
29
|
+
* @param {import('@iiif/presentation-3').Manifest} manifest
|
30
|
+
*/
|
31
|
+
manifestToBookReaderV3(manifest) {
|
32
|
+
/** @type {import('../BookReader/options.js').BookReaderOptions} */
|
33
|
+
var book = {
|
34
|
+
bookTitle: resolveInternationalString(manifest.label),
|
35
|
+
pageProgression: manifest.viewingDirection == "right-to-left" ? "rl" : "lr",
|
36
|
+
// numLeafs: manifest.items.length,
|
37
|
+
metadata: (manifest.metadata || []).map(metadata => {
|
38
|
+
return {
|
39
|
+
label: resolveInternationalString(metadata.label),
|
40
|
+
value: resolveInternationalString(metadata.value)
|
41
|
+
};
|
42
|
+
}),
|
43
|
+
data: [],
|
44
|
+
/**
|
45
|
+
* @this {import('../BookReader.js').default}
|
46
|
+
*/
|
47
|
+
getPageURI(pageIndex, reduce, rotate) {
|
48
|
+
var percent = Math.floor(100 * 1 / reduce);
|
49
|
+
var bodyArr = manifest.items[pageIndex].items[0].items[0].body;
|
50
|
+
var body = bodyArr instanceof Array ? bodyArr[0] : bodyArr;
|
51
|
+
var uri = body.service[0].id;
|
52
|
+
return "".concat(uri, "/full/pct:").concat(percent, "/0/default.jpg");
|
53
|
+
}
|
54
|
+
};
|
55
|
+
if (manifest.viewingDirection == "top-to-bottom" || manifest.viewingDirection == "bottom-to-top") {
|
56
|
+
console.warn("Unsupported viewingDirection", manifest.viewingDirection);
|
57
|
+
}
|
58
|
+
var spread = [];
|
59
|
+
manifest.items.forEach((item, index) => {
|
60
|
+
var bodyArr = manifest.items[index].items[0].items[0].body;
|
61
|
+
var body = bodyArr instanceof Array ? bodyArr[0] : bodyArr;
|
62
|
+
var uri = body.service[0].id;
|
63
|
+
/** @type {import('../BookReader/options.js').PageData} */
|
64
|
+
var pageData = {
|
65
|
+
uri,
|
66
|
+
width: item.width,
|
67
|
+
height: item.height,
|
68
|
+
pageNum: resolveInternationalString(item.label)
|
69
|
+
};
|
70
|
+
spread.push(pageData);
|
71
|
+
if (index % 2 == 0) {
|
72
|
+
book.data.push(spread);
|
73
|
+
spread = [];
|
74
|
+
}
|
75
|
+
});
|
76
|
+
if (spread.length > 0) {
|
77
|
+
book.data.push(spread);
|
78
|
+
}
|
79
|
+
return book;
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @param {import('@iiif/presentation-2').Manifest} manifest
|
84
|
+
*/
|
85
|
+
manifestToBookReaderV2(manifest) {
|
86
|
+
var _manifest$thumbnail;
|
87
|
+
/** @type {import('../BookReader/options.js').BookReaderOptions} */
|
88
|
+
var book = {
|
89
|
+
bookTitle: manifest.label,
|
90
|
+
metadata: manifest.metadata,
|
91
|
+
thumbnail: (_manifest$thumbnail = manifest.thumbnail) === null || _manifest$thumbnail === void 0 ? void 0 : _manifest$thumbnail['@id'],
|
92
|
+
// numLeafs: manifest.sequences[0].canvases.length,
|
93
|
+
data: [],
|
94
|
+
/**
|
95
|
+
* @this {import('../BookReader.js').default}
|
96
|
+
*/
|
97
|
+
getPageURI(pageIndex, reduce, rotate) {
|
98
|
+
var percent = Math.floor(100 * 1 / reduce);
|
99
|
+
var uri = manifest.sequences[0].canvases[pageIndex].images[0].resource.service['@id'];
|
100
|
+
return "".concat(uri, "/full/pct:").concat(percent, "/0/default.jpg");
|
101
|
+
}
|
102
|
+
};
|
103
|
+
var spread = [];
|
104
|
+
manifest.sequences[0].canvases.forEach((canvas, index) => {
|
105
|
+
/** @type {import('../BookReader/options.js').PageData} */
|
106
|
+
var pageData = {
|
107
|
+
uri: canvas.images[0].resource.service['@id'],
|
108
|
+
width: canvas.width,
|
109
|
+
height: canvas.height,
|
110
|
+
pageNum: canvas.label
|
111
|
+
};
|
112
|
+
spread.push(pageData);
|
113
|
+
if (index % 2 == 0) {
|
114
|
+
book.data.push(spread);
|
115
|
+
spread = [];
|
116
|
+
}
|
117
|
+
});
|
118
|
+
if (spread.length > 0) {
|
119
|
+
book.data.push(spread);
|
120
|
+
}
|
121
|
+
return book;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* @param {import('@iiif/presentation-3').InternationalString} internationalString
|
127
|
+
*/
|
128
|
+
function resolveInternationalString(internationalString) {
|
129
|
+
var anyLang = Object.keys(internationalString)[0];
|
130
|
+
return (internationalString[navigator.language] || internationalString[anyLang])[0];
|
131
|
+
}
|
132
|
+
export class BookReaderWithIIIFPlugin extends BookReader {
|
133
|
+
setup(options) {
|
134
|
+
var pluginOpts = Object.assign({}, DEFAULT_OPTIONS, options.plugins.iiif);
|
135
|
+
if (pluginOpts.enabled) {
|
136
|
+
this.iiifPlugin = new IIIFPlugin(pluginOpts, options.vars);
|
137
|
+
// Write this back; this way the plugin is the source of truth, and BR just
|
138
|
+
// contains a reference to it.
|
139
|
+
options.plugins.iiif = this.iiifPlugin.options;
|
140
|
+
Object.assign(options, this.iiifPlugin.load());
|
141
|
+
}
|
142
|
+
return super.setup(options);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
window.BookReader = BookReaderWithIIIFPlugin;
|
146
|
+
export default BookReaderWithIIIFPlugin;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import * as docCookies from '../util/docCookies.js';
|
2
|
+
|
3
|
+
/* global BookReader */
|
4
|
+
|
5
|
+
/** @deprecated Exposed for backward compatibility */
|
6
|
+
BookReader.docCookies = docCookies;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Plugin to remember the current page number in a cookie
|
10
|
+
*/
|
11
|
+
jQuery.extend(BookReader.defaultOptions, {
|
12
|
+
enablePageResume: true,
|
13
|
+
/** @type {string|null} eg '/', '/details/id' */
|
14
|
+
resumeCookiePath: null
|
15
|
+
});
|
16
|
+
|
17
|
+
/** @override */
|
18
|
+
BookReader.prototype.init = function (super_) {
|
19
|
+
return function () {
|
20
|
+
super_.call(this);
|
21
|
+
if (this.options.enablePageResume) {
|
22
|
+
this.bind(BookReader.eventNames.fragmentChange, () => {
|
23
|
+
var params = this.paramsFromCurrent();
|
24
|
+
this.updateResumeValue(params.index);
|
25
|
+
});
|
26
|
+
}
|
27
|
+
};
|
28
|
+
}(BookReader.prototype.init);
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Gets page resume value, for remembering reader's page
|
32
|
+
* Can be overridden for different implementation
|
33
|
+
*
|
34
|
+
* @return {number|null}
|
35
|
+
*/
|
36
|
+
BookReader.prototype.getResumeValue = function () {
|
37
|
+
var val = BookReader.docCookies.getItem('br-resume');
|
38
|
+
if (val !== null) return parseInt(val);else return null;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Return cookie path using pathname up to /page/... or /mode/...
|
43
|
+
* using window.location.pathname for urlPathPart:
|
44
|
+
* - matches encoding
|
45
|
+
* - ignores querystring part
|
46
|
+
* - ignores fragment part (after #)
|
47
|
+
* @param {string} urlPathPart - window.location.pathname
|
48
|
+
*/
|
49
|
+
BookReader.prototype.getCookiePath = function (urlPathPart) {
|
50
|
+
return urlPathPart.match('.+?(?=/page/|/mode/|$)')[0];
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Sets page resume value, for remembering reader's page
|
55
|
+
* Can be overridden for different implementation
|
56
|
+
*
|
57
|
+
* @param {Number} index leaf index
|
58
|
+
* @param {string} [cookieName]
|
59
|
+
*/
|
60
|
+
BookReader.prototype.updateResumeValue = function (index, cookieName) {
|
61
|
+
var ttl = new Date(+new Date() + 12096e5); // 2 weeks
|
62
|
+
// For multiple files in item, leave resumeCookiePath blank
|
63
|
+
// It's likely we can remove resumeCookiePath using getCookiePath()
|
64
|
+
var path = this.options.resumeCookiePath || this.getCookiePath(window.location.pathname);
|
65
|
+
BookReader.docCookies.setItem(cookieName || 'br-resume', index, ttl, path, null, false);
|
66
|
+
};
|