@internetarchive/bookreader 5.0.0-88-alpha.11 → 5.0.0-89

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.
Files changed (243) hide show
  1. package/BookReader/BookReader.css +17 -3
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.map +1 -1
  4. package/BookReader/ia-bookreader-bundle.js +87 -108
  5. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  6. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  7. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  8. package/BookReader/plugins/plugin.autoplay.js +1 -1
  9. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  10. package/BookReader/plugins/plugin.iiif.js +1 -1
  11. package/BookReader/plugins/plugin.iiif.js.map +1 -1
  12. package/BookReader/plugins/plugin.resume.js +1 -1
  13. package/BookReader/plugins/plugin.resume.js.map +1 -1
  14. package/BookReader/plugins/plugin.search.js +1 -1
  15. package/BookReader/plugins/plugin.search.js.map +1 -1
  16. package/BookReader/plugins/plugin.text_selection.js +1 -1
  17. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  18. package/BookReader/plugins/plugin.tts.js +1 -1
  19. package/BookReader/plugins/plugin.tts.js.map +1 -1
  20. package/BookReader/plugins/plugin.url.js +1 -1
  21. package/BookReader/plugins/plugin.url.js.map +1 -1
  22. package/CHANGELOG.md +14 -0
  23. package/babel.config.js +12 -30
  24. package/codecov.yml +1 -1
  25. package/jsconfig.json +1 -3
  26. package/package.json +14 -16
  27. package/src/BookNavigator/search/search-results.js +1 -1
  28. package/src/BookReader/ImageCache.js +48 -15
  29. package/src/BookReader/Mode1UpLit.js +56 -86
  30. package/src/BookReader/Mode2UpLit.js +5 -5
  31. package/src/BookReader/Navbar/Navbar.js +53 -11
  32. package/src/BookReader/PageContainer.js +41 -22
  33. package/src/BookReader/options.js +27 -3
  34. package/src/BookReader/utils.js +10 -0
  35. package/src/BookReader.js +120 -21
  36. package/src/BookReaderPlugin.js +44 -0
  37. package/src/css/_BRnav.scss +0 -3
  38. package/src/css/_BRpages.scss +21 -2
  39. package/src/css/_controls.scss +4 -0
  40. package/src/plugins/plugin.archive_analytics.js +84 -78
  41. package/src/plugins/plugin.autoplay.js +98 -102
  42. package/src/plugins/plugin.chapters.js +17 -22
  43. package/src/plugins/plugin.iiif.js +16 -30
  44. package/src/plugins/plugin.resume.js +54 -51
  45. package/src/plugins/plugin.text_selection.js +68 -76
  46. package/src/plugins/tts/AbstractTTSEngine.js +2 -4
  47. package/src/plugins/tts/PageChunk.js +5 -9
  48. package/src/plugins/tts/PageChunkIterator.js +3 -5
  49. package/src/plugins/tts/plugin.tts.js +309 -329
  50. package/src/plugins/url/plugin.url.js +1 -1
  51. package/src/util/strings.js +1 -0
  52. package/tests/e2e/autoplay.test.js +8 -5
  53. package/tests/e2e/helpers/base.js +2 -2
  54. package/tests/e2e/helpers/mockSearch.js +6 -9
  55. package/tests/jest/BookReader/Navbar/Navbar.test.js +16 -3
  56. package/tests/jest/BookReader/PageContainer.test.js +96 -55
  57. package/tests/jest/BookReader/utils.test.js +21 -0
  58. package/tests/jest/BookReader.test.js +13 -12
  59. package/tests/jest/plugins/plugin.archive_analytics.test.js +8 -11
  60. package/tests/jest/plugins/plugin.autoplay.test.js +9 -22
  61. package/tests/jest/plugins/plugin.resume.test.js +19 -32
  62. package/tests/jest/plugins/plugin.text_selection.test.js +23 -24
  63. package/dist/esm/BookNavigator/assets/bookmark-colors.js +0 -4
  64. package/dist/esm/BookNavigator/assets/button-base.js +0 -4
  65. package/dist/esm/BookNavigator/assets/ia-logo.js +0 -4
  66. package/dist/esm/BookNavigator/assets/icon_checkmark.js +0 -8
  67. package/dist/esm/BookNavigator/assets/icon_close.js +0 -4
  68. package/dist/esm/BookNavigator/book-navigator.js +0 -612
  69. package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +0 -35
  70. package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +0 -78
  71. package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +0 -160
  72. package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -24
  73. package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +0 -55
  74. package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +0 -521
  75. package/dist/esm/BookNavigator/delete-modal-actions.js +0 -29
  76. package/dist/esm/BookNavigator/downloads/downloads-provider.js +0 -84
  77. package/dist/esm/BookNavigator/downloads/downloads.js +0 -69
  78. package/dist/esm/BookNavigator/search/search-provider.js +0 -238
  79. package/dist/esm/BookNavigator/search/search-results.js +0 -161
  80. package/dist/esm/BookNavigator/sharing.js +0 -26
  81. package/dist/esm/BookNavigator/viewable-files.js +0 -94
  82. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -83
  83. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +0 -131
  84. package/dist/esm/BookReader/BookModel.js +0 -575
  85. package/dist/esm/BookReader/DragScrollable.js +0 -224
  86. package/dist/esm/BookReader/ImageCache.js +0 -122
  87. package/dist/esm/BookReader/Mode1Up.js +0 -114
  88. package/dist/esm/BookReader/Mode1UpLit.js +0 -579
  89. package/dist/esm/BookReader/Mode2Up.js +0 -106
  90. package/dist/esm/BookReader/Mode2UpLit.js +0 -1020
  91. package/dist/esm/BookReader/ModeCoordinateSpace.js +0 -28
  92. package/dist/esm/BookReader/ModeSmoothZoom.js +0 -318
  93. package/dist/esm/BookReader/ModeThumb.js +0 -366
  94. package/dist/esm/BookReader/Navbar/Navbar.js +0 -253
  95. package/dist/esm/BookReader/PageContainer.js +0 -165
  96. package/dist/esm/BookReader/ReduceSet.js +0 -27
  97. package/dist/esm/BookReader/Toolbar/Toolbar.js +0 -242
  98. package/dist/esm/BookReader/events.js +0 -20
  99. package/dist/esm/BookReader/options.js +0 -331
  100. package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +0 -48
  101. package/dist/esm/BookReader/utils/ScrollClassAdder.js +0 -31
  102. package/dist/esm/BookReader/utils/SelectionObserver.js +0 -42
  103. package/dist/esm/BookReader/utils/classes.js +0 -37
  104. package/dist/esm/BookReader/utils.js +0 -315
  105. package/dist/esm/BookReader.js +0 -1828
  106. package/dist/esm/assets/icons/1up.svg +0 -12
  107. package/dist/esm/assets/icons/2up.svg +0 -15
  108. package/dist/esm/assets/icons/advance.svg +0 -26
  109. package/dist/esm/assets/icons/chevron-right.svg +0 -1
  110. package/dist/esm/assets/icons/close-circle-dark.svg +0 -1
  111. package/dist/esm/assets/icons/close-circle.svg +0 -1
  112. package/dist/esm/assets/icons/fullscreen.svg +0 -17
  113. package/dist/esm/assets/icons/fullscreen_exit.svg +0 -17
  114. package/dist/esm/assets/icons/hamburger.svg +0 -15
  115. package/dist/esm/assets/icons/left-arrow.svg +0 -12
  116. package/dist/esm/assets/icons/magnify-minus.svg +0 -12
  117. package/dist/esm/assets/icons/magnify-plus.svg +0 -13
  118. package/dist/esm/assets/icons/magnify.svg +0 -15
  119. package/dist/esm/assets/icons/pause.svg +0 -23
  120. package/dist/esm/assets/icons/play.svg +0 -22
  121. package/dist/esm/assets/icons/playback-speed.svg +0 -34
  122. package/dist/esm/assets/icons/read-aloud.svg +0 -22
  123. package/dist/esm/assets/icons/review.svg +0 -22
  124. package/dist/esm/assets/icons/thumbnails.svg +0 -17
  125. package/dist/esm/assets/icons/voice.svg +0 -1
  126. package/dist/esm/assets/icons/volume-full.svg +0 -22
  127. package/dist/esm/assets/images/BRicons.png +0 -0
  128. package/dist/esm/assets/images/BRicons.svg +0 -94
  129. package/dist/esm/assets/images/BRicons_ia.png +0 -0
  130. package/dist/esm/assets/images/back_pages.png +0 -0
  131. package/dist/esm/assets/images/book_bottom_icon.png +0 -0
  132. package/dist/esm/assets/images/book_down_icon.png +0 -0
  133. package/dist/esm/assets/images/book_left_icon.png +0 -0
  134. package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
  135. package/dist/esm/assets/images/book_right_icon.png +0 -0
  136. package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
  137. package/dist/esm/assets/images/book_top_icon.png +0 -0
  138. package/dist/esm/assets/images/book_up_icon.png +0 -0
  139. package/dist/esm/assets/images/books_graphic.svg +0 -177
  140. package/dist/esm/assets/images/booksplit.png +0 -0
  141. package/dist/esm/assets/images/control_pause_icon.png +0 -0
  142. package/dist/esm/assets/images/control_play_icon.png +0 -0
  143. package/dist/esm/assets/images/embed_icon.png +0 -0
  144. package/dist/esm/assets/images/icon-home-ia.png +0 -0
  145. package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
  146. package/dist/esm/assets/images/icon_alert-xs.png +0 -0
  147. package/dist/esm/assets/images/icon_book.svg +0 -12
  148. package/dist/esm/assets/images/icon_bookmark.svg +0 -12
  149. package/dist/esm/assets/images/icon_close-pop.png +0 -0
  150. package/dist/esm/assets/images/icon_download.png +0 -0
  151. package/dist/esm/assets/images/icon_gear.svg +0 -14
  152. package/dist/esm/assets/images/icon_hamburger.svg +0 -20
  153. package/dist/esm/assets/images/icon_home.png +0 -0
  154. package/dist/esm/assets/images/icon_home.svg +0 -21
  155. package/dist/esm/assets/images/icon_home_ia.png +0 -0
  156. package/dist/esm/assets/images/icon_indicator.png +0 -0
  157. package/dist/esm/assets/images/icon_info.svg +0 -11
  158. package/dist/esm/assets/images/icon_one_page.svg +0 -8
  159. package/dist/esm/assets/images/icon_pause.svg +0 -1
  160. package/dist/esm/assets/images/icon_play.svg +0 -1
  161. package/dist/esm/assets/images/icon_playback-rate.svg +0 -15
  162. package/dist/esm/assets/images/icon_return.png +0 -0
  163. package/dist/esm/assets/images/icon_search_button.svg +0 -8
  164. package/dist/esm/assets/images/icon_share.svg +0 -9
  165. package/dist/esm/assets/images/icon_skip-ahead.svg +0 -6
  166. package/dist/esm/assets/images/icon_skip-back.svg +0 -13
  167. package/dist/esm/assets/images/icon_speaker.svg +0 -18
  168. package/dist/esm/assets/images/icon_speaker_open.svg +0 -10
  169. package/dist/esm/assets/images/icon_thumbnails.svg +0 -12
  170. package/dist/esm/assets/images/icon_toc.svg +0 -5
  171. package/dist/esm/assets/images/icon_two_pages.svg +0 -9
  172. package/dist/esm/assets/images/icon_zoomer.png +0 -0
  173. package/dist/esm/assets/images/loading.gif +0 -0
  174. package/dist/esm/assets/images/logo_icon.png +0 -0
  175. package/dist/esm/assets/images/marker_chap-off.png +0 -0
  176. package/dist/esm/assets/images/marker_chap-off.svg +0 -11
  177. package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
  178. package/dist/esm/assets/images/marker_chap-on.png +0 -0
  179. package/dist/esm/assets/images/marker_chap-on.svg +0 -11
  180. package/dist/esm/assets/images/marker_srch-on.svg +0 -11
  181. package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
  182. package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
  183. package/dist/esm/assets/images/nav_control-dn.png +0 -0
  184. package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
  185. package/dist/esm/assets/images/nav_control-up.png +0 -0
  186. package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
  187. package/dist/esm/assets/images/nav_control.png +0 -0
  188. package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
  189. package/dist/esm/assets/images/paper-badge.png +0 -0
  190. package/dist/esm/assets/images/print_icon.png +0 -0
  191. package/dist/esm/assets/images/progressbar.gif +0 -0
  192. package/dist/esm/assets/images/right_edges.png +0 -0
  193. package/dist/esm/assets/images/slider.png +0 -0
  194. package/dist/esm/assets/images/slider_ia.png +0 -0
  195. package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
  196. package/dist/esm/assets/images/transparent.png +0 -0
  197. package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
  198. package/dist/esm/assets/images/unviewable_page.png +0 -0
  199. package/dist/esm/assets/images/zoom_in_icon.png +0 -0
  200. package/dist/esm/assets/images/zoom_out_icon.png +0 -0
  201. package/dist/esm/css/BookReader.scss +0 -85
  202. package/dist/esm/css/_BRBookmarks.scss +0 -29
  203. package/dist/esm/css/_BRComponent.scss +0 -13
  204. package/dist/esm/css/_BRfloat.scss +0 -197
  205. package/dist/esm/css/_BRicon.scss +0 -54
  206. package/dist/esm/css/_BRmain.scss +0 -262
  207. package/dist/esm/css/_BRnav.scss +0 -354
  208. package/dist/esm/css/_BRpages.scss +0 -213
  209. package/dist/esm/css/_BRsearch.scss +0 -268
  210. package/dist/esm/css/_BRtoolbar.scss +0 -84
  211. package/dist/esm/css/_BRvendor.scss +0 -5
  212. package/dist/esm/css/_TextSelection.scss +0 -108
  213. package/dist/esm/css/_colorbox.scss +0 -52
  214. package/dist/esm/css/_controls.scss +0 -257
  215. package/dist/esm/css/_icons.scss +0 -121
  216. package/dist/esm/ia-bookreader/ia-bookreader.js +0 -141
  217. package/dist/esm/jquery-wrapper.js +0 -3
  218. package/dist/esm/plugins/plugin.archive_analytics.js +0 -72
  219. package/dist/esm/plugins/plugin.autoplay.js +0 -119
  220. package/dist/esm/plugins/plugin.chapters.js +0 -288
  221. package/dist/esm/plugins/plugin.iframe.js +0 -44
  222. package/dist/esm/plugins/plugin.iiif.js +0 -146
  223. package/dist/esm/plugins/plugin.resume.js +0 -66
  224. package/dist/esm/plugins/plugin.text_selection.js +0 -621
  225. package/dist/esm/plugins/plugin.vendor-fullscreen.js +0 -227
  226. package/dist/esm/plugins/search/plugin.search.js +0 -499
  227. package/dist/esm/plugins/search/utils.js +0 -42
  228. package/dist/esm/plugins/search/view.js +0 -360
  229. package/dist/esm/plugins/tts/AbstractTTSEngine.js +0 -282
  230. package/dist/esm/plugins/tts/FestivalTTSEngine.js +0 -192
  231. package/dist/esm/plugins/tts/PageChunk.js +0 -105
  232. package/dist/esm/plugins/tts/PageChunkIterator.js +0 -155
  233. package/dist/esm/plugins/tts/WebTTSEngine.js +0 -364
  234. package/dist/esm/plugins/tts/plugin.tts.js +0 -315
  235. package/dist/esm/plugins/tts/tooltip_dict.js +0 -14
  236. package/dist/esm/plugins/tts/utils.js +0 -79
  237. package/dist/esm/plugins/url/UrlPlugin.js +0 -197
  238. package/dist/esm/plugins/url/plugin.url.js +0 -212
  239. package/dist/esm/util/browserSniffing.js +0 -56
  240. package/dist/esm/util/debouncer.js +0 -25
  241. package/dist/esm/util/docCookies.js +0 -75
  242. package/dist/esm/util/strings.js +0 -34
  243. package/index.js +0 -2
@@ -1,288 +0,0 @@
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);
@@ -1,44 +0,0 @@
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
- }
@@ -1,146 +0,0 @@
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;
@@ -1,66 +0,0 @@
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
- };