@internetarchive/bookreader 5.0.0-6-14 → 5.0.0-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. package/.eslintrc.js +17 -15
  2. package/.github/workflows/node.js.yml +72 -10
  3. package/.github/workflows/npm-publish.yml +6 -20
  4. package/.testcaferc.js +10 -0
  5. package/BookReader/BookReader.css +241 -140
  6. package/BookReader/BookReader.js +1 -1
  7. package/BookReader/BookReader.js.LICENSE.txt +24 -20
  8. package/BookReader/BookReader.js.map +1 -1
  9. package/BookReader/ia-bookreader-bundle.js +1519 -0
  10. package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +17 -0
  11. package/BookReader/ia-bookreader-bundle.js.map +1 -0
  12. package/BookReader/icons/close-circle-dark.svg +1 -0
  13. package/BookReader/icons/magnify-minus.svg +1 -1
  14. package/BookReader/icons/magnify-plus.svg +1 -1
  15. package/BookReader/icons/pause.svg +1 -1
  16. package/BookReader/icons/playback-speed.svg +1 -1
  17. package/BookReader/icons/read-aloud.svg +1 -1
  18. package/BookReader/icons/voice.svg +1 -0
  19. package/BookReader/images/BRicons.svg +2 -2
  20. package/BookReader/images/books_graphic.svg +1 -1
  21. package/BookReader/images/icon_book.svg +1 -1
  22. package/BookReader/images/icon_gear.svg +1 -1
  23. package/BookReader/images/icon_info.svg +1 -1
  24. package/BookReader/images/icon_playback-rate.svg +1 -1
  25. package/BookReader/images/icon_search_button.svg +1 -1
  26. package/BookReader/images/icon_share.svg +1 -1
  27. package/BookReader/images/icon_speaker.svg +1 -1
  28. package/BookReader/images/icon_speaker_open.svg +1 -1
  29. package/BookReader/images/marker_chap-off.svg +1 -1
  30. package/BookReader/images/marker_chap-on.svg +1 -1
  31. package/BookReader/images/marker_srch-on.svg +1 -1
  32. package/BookReader/jquery-3.js +2 -0
  33. package/BookReader/jquery-3.js.LICENSE.txt +24 -0
  34. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  35. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  36. package/BookReader/plugins/plugin.autoplay.js +1 -1
  37. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  38. package/BookReader/plugins/plugin.chapters.js +1 -1
  39. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  40. package/BookReader/plugins/plugin.iframe.js +1 -1
  41. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  42. package/BookReader/plugins/plugin.mobile_nav.js +1 -1
  43. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
  44. package/BookReader/plugins/plugin.resume.js +1 -1
  45. package/BookReader/plugins/plugin.resume.js.map +1 -1
  46. package/BookReader/plugins/plugin.search.js +1 -1
  47. package/BookReader/plugins/plugin.search.js.map +1 -1
  48. package/BookReader/plugins/plugin.text_selection.js +1 -1
  49. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  50. package/BookReader/plugins/plugin.tts.js +1 -1
  51. package/BookReader/plugins/plugin.tts.js.map +1 -1
  52. package/BookReader/plugins/plugin.url.js +1 -1
  53. package/BookReader/plugins/plugin.url.js.map +1 -1
  54. package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
  55. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  56. package/BookReader/webcomponents-bundle.js +3 -0
  57. package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
  58. package/BookReader/webcomponents-bundle.js.map +1 -0
  59. package/BookReaderDemo/BookReaderDemo.css +14 -1
  60. package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
  61. package/BookReaderDemo/BookReaderJSSimple.js +1 -0
  62. package/BookReaderDemo/IADemoBr.js +147 -0
  63. package/BookReaderDemo/demo-advanced.html +2 -2
  64. package/BookReaderDemo/demo-autoplay.html +2 -1
  65. package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
  66. package/BookReaderDemo/demo-fullscreen-mobile.html +2 -1
  67. package/BookReaderDemo/demo-fullscreen.html +2 -1
  68. package/BookReaderDemo/demo-iiif.html +2 -1
  69. package/BookReaderDemo/demo-internetarchive.html +84 -17
  70. package/BookReaderDemo/demo-multiple.html +2 -1
  71. package/BookReaderDemo/demo-preview-pages.html +2 -1
  72. package/BookReaderDemo/demo-simple.html +2 -1
  73. package/BookReaderDemo/demo-vendor-fullscreen.html +2 -1
  74. package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
  75. package/BookReaderDemo/immersion-1up.html +2 -1
  76. package/BookReaderDemo/immersion-mode.html +2 -1
  77. package/BookReaderDemo/toggle_controls.html +2 -1
  78. package/BookReaderDemo/view_mode.html +2 -1
  79. package/BookReaderDemo/viewmode-cycle.html +2 -3
  80. package/CHANGELOG.md +244 -0
  81. package/README.md +14 -1
  82. package/babel.config.js +19 -0
  83. package/codecov.yml +6 -0
  84. package/index.html +3 -0
  85. package/jsconfig.json +19 -0
  86. package/netlify.toml +5 -0
  87. package/package.json +70 -59
  88. package/renovate.json +52 -0
  89. package/scripts/preversion.js +4 -1
  90. package/src/BookNavigator/assets/bookmark-colors.js +1 -1
  91. package/src/BookNavigator/assets/button-base.js +9 -2
  92. package/src/BookNavigator/assets/ia-logo.js +17 -0
  93. package/src/BookNavigator/assets/icon_checkmark.js +1 -1
  94. package/src/BookNavigator/assets/icon_close.js +1 -1
  95. package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
  96. package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
  97. package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
  98. package/src/BookNavigator/assets/icon_volumes.js +11 -0
  99. package/src/BookNavigator/book-navigator.js +585 -0
  100. package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
  101. package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
  102. package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
  103. package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
  104. package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
  105. package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
  106. package/src/BookNavigator/delete-modal-actions.js +1 -1
  107. package/src/BookNavigator/downloads/downloads-provider.js +36 -21
  108. package/src/BookNavigator/downloads/downloads.js +41 -25
  109. package/src/BookNavigator/search/search-provider.js +80 -28
  110. package/src/BookNavigator/search/search-results.js +34 -25
  111. package/src/BookNavigator/sharing.js +27 -0
  112. package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
  113. package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
  114. package/src/BookNavigator/volumes/volumes-provider.js +111 -0
  115. package/src/BookNavigator/volumes/volumes.js +188 -0
  116. package/src/BookReader/BookModel.js +59 -30
  117. package/src/BookReader/DebugConsole.js +3 -3
  118. package/src/BookReader/DragScrollable.js +233 -0
  119. package/src/BookReader/Mode1Up.js +56 -351
  120. package/src/BookReader/Mode1UpLit.js +391 -0
  121. package/src/BookReader/Mode2Up.js +73 -1318
  122. package/src/BookReader/Mode2UpLit.js +781 -0
  123. package/src/BookReader/ModeCoordinateSpace.js +29 -0
  124. package/src/BookReader/ModeSmoothZoom.js +211 -0
  125. package/src/BookReader/ModeThumb.js +17 -11
  126. package/src/BookReader/Navbar/Navbar.js +10 -36
  127. package/src/BookReader/PageContainer.js +69 -6
  128. package/src/BookReader/ReduceSet.js +1 -1
  129. package/src/BookReader/Toolbar/Toolbar.js +10 -37
  130. package/src/BookReader/events.js +2 -0
  131. package/src/BookReader/options.js +24 -2
  132. package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
  133. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  134. package/src/BookReader/utils.js +108 -13
  135. package/src/BookReader.js +481 -828
  136. package/src/assets/icons/close-circle-dark.svg +1 -0
  137. package/src/assets/icons/magnify-minus.svg +3 -7
  138. package/src/assets/icons/magnify-plus.svg +3 -7
  139. package/src/assets/icons/voice.svg +1 -0
  140. package/src/css/_BRBookmarks.scss +1 -1
  141. package/src/css/_BRComponent.scss +1 -1
  142. package/src/css/_BRmain.scss +33 -0
  143. package/src/css/_BRnav.scss +4 -26
  144. package/src/css/_BRpages.scss +147 -40
  145. package/src/css/_BRsearch.scss +25 -11
  146. package/src/css/_TextSelection.scss +16 -17
  147. package/src/css/_colorbox.scss +2 -2
  148. package/src/css/_controls.scss +17 -5
  149. package/src/css/_icons.scss +7 -1
  150. package/src/ia-bookreader/ia-bookreader.js +224 -0
  151. package/src/plugins/plugin.archive_analytics.js +3 -3
  152. package/src/plugins/plugin.autoplay.js +4 -9
  153. package/src/plugins/plugin.chapters.js +28 -35
  154. package/src/plugins/plugin.mobile_nav.js +11 -10
  155. package/src/plugins/plugin.resume.js +3 -3
  156. package/src/plugins/plugin.text_selection.js +32 -41
  157. package/src/plugins/plugin.vendor-fullscreen.js +4 -4
  158. package/src/plugins/search/plugin.search.js +179 -103
  159. package/src/plugins/search/view.js +59 -44
  160. package/src/plugins/tts/AbstractTTSEngine.js +46 -37
  161. package/src/plugins/tts/FestivalTTSEngine.js +13 -14
  162. package/src/plugins/tts/PageChunk.js +15 -21
  163. package/src/plugins/tts/PageChunkIterator.js +8 -12
  164. package/src/plugins/tts/WebTTSEngine.js +87 -71
  165. package/src/plugins/tts/plugin.tts.js +94 -125
  166. package/src/plugins/tts/utils.js +0 -25
  167. package/src/plugins/url/UrlPlugin.js +193 -0
  168. package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
  169. package/src/util/docCookies.js +21 -2
  170. package/tests/e2e/README.md +37 -0
  171. package/tests/e2e/autoplay.test.js +2 -2
  172. package/tests/e2e/base.test.js +7 -7
  173. package/tests/e2e/helpers/base.js +28 -23
  174. package/tests/e2e/helpers/debug.js +1 -1
  175. package/tests/e2e/helpers/desktopSearch.js +14 -13
  176. package/tests/e2e/helpers/mobileSearch.js +3 -3
  177. package/tests/e2e/helpers/params.js +17 -0
  178. package/tests/e2e/helpers/rightToLeft.js +4 -10
  179. package/tests/e2e/models/Navigation.js +13 -4
  180. package/tests/e2e/rightToLeft.test.js +4 -5
  181. package/tests/e2e/viewmode.test.js +40 -33
  182. package/tests/jest/BookNavigator/book-navigator.test.js +658 -0
  183. package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
  184. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
  185. package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
  186. package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
  187. package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
  188. package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
  189. package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
  190. package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +104 -60
  191. package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
  192. package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
  193. package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +184 -0
  194. package/tests/jest/BookNavigator/volumes/volumes.test.js +97 -0
  195. package/tests/{BookReader → jest/BookReader}/BookModel.test.js +59 -14
  196. package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
  197. package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
  198. package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
  199. package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
  200. package/tests/jest/BookReader/Mode2Up.test.js +98 -0
  201. package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
  202. package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
  203. package/tests/jest/BookReader/ModeSmoothZoom.test.js +175 -0
  204. package/tests/jest/BookReader/ModeThumb.test.js +71 -0
  205. package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
  206. package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
  207. package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
  208. package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
  209. package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
  210. package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
  211. package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
  212. package/tests/jest/BookReader/utils.test.js +217 -0
  213. package/tests/jest/BookReader.keyboard.test.js +190 -0
  214. package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
  215. package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
  216. package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
  217. package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
  218. package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +10 -11
  219. package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
  220. package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
  221. package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
  222. package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +39 -47
  223. package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
  224. package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +57 -47
  225. package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +35 -6
  226. package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +9 -9
  227. package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
  228. package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
  229. package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
  230. package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
  231. package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
  232. package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
  233. package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
  234. package/tests/jest/setup.js +3 -0
  235. package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
  236. package/tests/jest/util/docCookies.test.js +24 -0
  237. package/tests/{util → jest/util}/strings.test.js +1 -1
  238. package/tests/{utils.js → jest/utils.js} +38 -0
  239. package/webpack.config.js +11 -5
  240. package/.babelrc +0 -12
  241. package/.dependabot/config.yml +0 -6
  242. package/.testcaferc.json +0 -5
  243. package/BookReader/bookreader-component-bundle.js +0 -1450
  244. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
  245. package/BookReader/bookreader-component-bundle.js.map +0 -1
  246. package/BookReader/jquery-1.10.1.js +0 -2
  247. package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
  248. package/BookReader/plugins/plugin.menu_toggle.js +0 -2
  249. package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
  250. package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
  251. package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
  252. package/karma.conf.js +0 -23
  253. package/src/BookNavigator/BookModel.js +0 -14
  254. package/src/BookNavigator/BookNavigator.js +0 -438
  255. package/src/BookNavigator/assets/book-loader.js +0 -27
  256. package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
  257. package/src/BookNavigator/search/a-search-result.js +0 -55
  258. package/src/BookReaderComponent/BookReaderComponent.js +0 -112
  259. package/src/ItemNavigator/ItemNavigator.js +0 -372
  260. package/src/ItemNavigator/providers/sharing.js +0 -29
  261. package/src/dragscrollable-br.js +0 -261
  262. package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
  263. package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
  264. package/tests/BookReader/Mode1Up.test.js +0 -164
  265. package/tests/BookReader/Mode2Up.test.js +0 -247
  266. package/tests/BookReader/utils.test.js +0 -109
  267. package/tests/e2e/ia-production/ia-prod-base.js +0 -17
  268. package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
  269. package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
  270. package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
  271. package/tests/util/docCookies.test.js +0 -15
@@ -16,8 +16,21 @@ body {
16
16
  display: none;
17
17
  }
18
18
 
19
+ body.BRfullscreenActive section.theater {
20
+ height: 100vh;
21
+ }
22
+ ia-bookreader[fullscreen] {
23
+ height: unset;
24
+ }
25
+
26
+ ia-bookreader{
27
+ --br-height: calc(100vh - 100px);
28
+ display: block;
29
+ height: var(--br-height);
30
+ }
31
+
19
32
  .BookReader {
20
- height: 600px;
33
+ height: var(--br-height);
21
34
  overflow: hidden;
22
35
  margin: 0 auto;
23
36
  }
@@ -8,6 +8,7 @@ function instantiateBookReader(selector, extraOptions) {
8
8
  selector = selector || '#BookReader';
9
9
  extraOptions = extraOptions || {};
10
10
  var options = {
11
+ ppi: 100,
11
12
  data: [
12
13
  [
13
14
  { width: 800, height: 1200,
@@ -52,5 +53,7 @@ function instantiateBookReader(selector, extraOptions) {
52
53
  $.extend(options, extraOptions);
53
54
  var br = new BookReader(options);
54
55
  br.init();
55
- br.autoToggle(options);
56
+ setTimeout(function() {
57
+ br.autoToggle(options);
58
+ }, 0);
56
59
  }
@@ -8,6 +8,7 @@ function instantiateBookReader(selector, extraOptions) {
8
8
  selector = selector || '#BookReader';
9
9
  extraOptions = extraOptions || {};
10
10
  var options = {
11
+ ppi: 100,
11
12
  data: [
12
13
  [
13
14
  { width: 800, height: 1200,
@@ -0,0 +1,147 @@
1
+ /* global BookReader, BookReaderJSIAinit */
2
+ import { extraVolOptions, custvolumesManifest } from './ia-multiple-volumes-manifest.js';
3
+
4
+ /**
5
+ * This is how Internet Archive loads bookreader
6
+ */
7
+ const urlParams = new URLSearchParams(window.location.search);
8
+
9
+ const ocaid = urlParams.get('ocaid');
10
+ const openFullImmersionTheater = urlParams.get('view') === 'theater';
11
+ const ui = urlParams.get('ui');
12
+ const autoflip = urlParams.get('autoflip');
13
+ const searchTerm = urlParams.get('q');
14
+
15
+ const iaBookReader = document.querySelector('ia-bookreader');
16
+
17
+ const downloadListWithLCP = [
18
+ [
19
+ "lcpPDF",
20
+ "link to lcp pdf"
21
+ ],
22
+ [
23
+ "lcpEPUB",
24
+ "link to lcp epub"
25
+ ]
26
+ ];
27
+
28
+ if (openFullImmersionTheater) {
29
+ $(document.body).addClass('BRfullscreenActive');
30
+ iaBookReader.fullscreen = openFullImmersionTheater;
31
+ }
32
+
33
+ const modal = document.querySelector('modal-manager');
34
+ iaBookReader.modal = modal;
35
+
36
+ // Override options coming from IA
37
+ BookReader.optionOverrides.imagesBaseURL = '/BookReader/images/';
38
+
39
+ const initializeBookReader = (brManifest) => {
40
+ console.log('initializeBookReader', brManifest);
41
+
42
+ const customAutoflipParams = {
43
+ autoflip: !!autoflip,
44
+ flipSpeed: urlParams.flipSpeed || 2000,
45
+ flipDelay: urlParams.flipDelay || 5000
46
+ };
47
+
48
+ const options = {
49
+ el: '#BookReader',
50
+ /* Url plugin - IA uses History mode for URL */
51
+ // commenting these out as demo uses hash mode
52
+ // keeping them here for reference
53
+ // urlHistoryBasePath: `/details/{$ocaid}/`,
54
+ // resumeCookiePath: `/details/{$ocaid}/`,
55
+ // urlMode: 'history',
56
+ // Only reflect these params onto the URL
57
+ // urlTrackedParams: ['page', 'search', 'mode'],
58
+ /* End url plugin */
59
+ enableBookTitleLink: false,
60
+ bookUrlText: null,
61
+ startFullscreen: openFullImmersionTheater,
62
+ initialSearchTerm: searchTerm ? searchTerm : '',
63
+ // leaving this option commented out bc we change given user agent on archive.org
64
+ // onePage: { autofit: <?=json_encode($this->ios ? 'width' : 'auto')?> },
65
+ showToolbar: false,
66
+ /* Multiple volumes */
67
+ // To show multiple volumes:
68
+ enableMultipleBooks: false, // turn this on
69
+ multipleBooksList: [], // populate this // TODO: get sample blob and tie into demo
70
+ /* End multiple volumes */
71
+ enableBookmarks: true, // turn this on
72
+ enableFSLogoShortcut: true,
73
+ };
74
+
75
+ // we want to show item as embedded when ?ui=embed is in URI
76
+ if (ui === 'embed') {
77
+ options.mode = 1;
78
+ options.ui = 'embed';
79
+ }
80
+
81
+ // we expect this at the global level
82
+ BookReaderJSIAinit(brManifest.data, options);
83
+
84
+ const isRestricted = brManifest.data.isRestricted;
85
+ window.dispatchEvent(new CustomEvent('contextmenu', { detail: { isRestricted } }));
86
+ if (customAutoflipParams.autoflip) {
87
+ window.br.autoToggle(customAutoflipParams);
88
+ }
89
+ };
90
+
91
+ window.initializeBookReader = initializeBookReader;
92
+
93
+ const showLCP = document.querySelector('#show-lcp');
94
+ showLCP.addEventListener('click', async () => {
95
+ const iaBr = document.querySelector('ia-bookreader');
96
+ const bookNav = iaBr.shadowRoot.querySelector('book-navigator');
97
+
98
+ bookNav.downloadableTypes = downloadListWithLCP;
99
+
100
+ bookNav.updateMenuContents();
101
+ await bookNav.updateComplete;
102
+ });
103
+
104
+ const multiVolume = document.querySelector('#multi-volume');
105
+ multiVolume.addEventListener('click', () => {
106
+ // remove everything
107
+ $('#BookReader').empty();
108
+ delete window.br;
109
+ // and re-mount with a new book
110
+ BookReaderJSIAinit(custvolumesManifest, extraVolOptions);
111
+ });
112
+
113
+
114
+ const fetchBookManifestAndInitializeBookreader = async (iaMetadata) => {
115
+ document.querySelector('input[name="itemMD"]').checked = true;
116
+ iaBookReader.item = iaMetadata;
117
+
118
+ const jsiaParams = {
119
+ format: 'jsonp',
120
+ itemPath: iaMetadata.dir,
121
+ id: iaMetadata.metadata.identifier,
122
+ server: iaMetadata.server,
123
+ };
124
+
125
+ const jp2File = iaMetadata.files.find(f => f.name.endsWith('_jp2.zip'))
126
+ if (jp2File) {
127
+ jsiaParams.subPrefix = jp2File.name.replace('_jp2.zip', '');
128
+ }
129
+
130
+ const iaManifestUrl = `https://${iaMetadata.server}/BookReader/BookReaderJSIA.php?${
131
+ new URLSearchParams(jsiaParams)
132
+ }`;
133
+
134
+ const manifest = await fetch(iaManifestUrl).then(response => response.json());
135
+ document.querySelector('input[name="bookManifest"]').checked = true;
136
+
137
+ initializeBookReader(manifest);
138
+ };
139
+
140
+ // Temp; Circumvent bug in BookReaderJSIA code
141
+ window.Sentry = null;
142
+ window.logError = function(e) {
143
+ console.error(e);
144
+ };
145
+ fetch(`https://archive.org/metadata/${ocaid}`)
146
+ .then(response => response.json())
147
+ .then(iaMetadata => fetchBookManifestAndInitializeBookreader(iaMetadata));
@@ -7,14 +7,14 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
14
15
  <link rel="stylesheet" href="../BookReader/BookReader.css"/>
15
16
  <script src="../BookReader/BookReader.js"></script>
16
17
  <script type="text/javascript" src="../BookReader/plugins/plugin.url.js"></script>
17
- <script type="text/javascript" src="../BookReader/plugins/plugin.menu_toggle.js"></script>
18
18
 
19
19
  <!-- Custom CSS overrides -->
20
20
  <link rel="stylesheet" href="BookReaderDemo.css"/>
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -8,7 +8,8 @@
8
8
 
9
9
  <link rel="stylesheet" href="../BookReader/BookReader.css"/>
10
10
 
11
- <script src="../BookReader/jquery-1.10.1.js"></script>
11
+ <script src="../BookReader/webcomponents-bundle.js"></script>
12
+ <script src="../BookReader/jquery-3.js"></script>
12
13
 
13
14
 
14
15
  <script src="../BookReader/BookReader.js"></script>
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -5,7 +5,8 @@
5
5
  <meta name="apple-mobile-web-app-capable" content="yes">
6
6
 
7
7
  <!-- JS dependencies -->
8
- <script src="../BookReader/jquery-1.10.1.js"></script>
8
+ <script src="../BookReader/webcomponents-bundle.js"></script>
9
+ <script src="../BookReader/jquery-3.js"></script>
9
10
 
10
11
 
11
12
  <!-- BookReader -->
@@ -7,8 +7,14 @@
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
8
8
  <meta name="apple-mobile-web-app-capable" content="yes">
9
9
 
10
+ <!-- WC dependencies -->
11
+ <script type="text/javascript" src="https://polyfill.io/v3/polyfill.min.js?features=es2015%2Ces5%2CglobalThis"></script>
12
+ <script type="text/javascript" src="https://unpkg.com/lit@2.1.2/polyfill-support.js"></script>
13
+ <script type="text/javascript" src="https://unpkg.com/@webcomponents/webcomponentsjs@2.2.10/webcomponents-bundle.js"></script>
14
+
10
15
  <!-- JS dependencies -->
11
- <script src="../BookReader/jquery-1.10.1.js"></script>
16
+ <script src="../BookReader/webcomponents-bundle.js"></script>
17
+ <script src="../BookReader/jquery-3.js"></script>
12
18
 
13
19
 
14
20
  <!-- Bookreader -->
@@ -25,17 +31,21 @@
25
31
  <script src="../BookReader/plugins/plugin.archive_analytics.js"></script>
26
32
  <script src="../BookReader/plugins/plugin.text_selection.js"></script>
27
33
 
28
- <script type="module" src="../BookReader/bookreader-component-bundle.js"></script>
34
+ <script type="module" src="../BookReader/ia-bookreader-bundle.js"></script>
29
35
 
30
36
  <link rel="stylesheet" href="BookReaderDemo.css"/>
31
- </head>
37
+
38
+ <!-- IA scripts -->
39
+ <script src="https://archive.org/bookreader/BookReaderJSIA.js"></script>
40
+
41
+ </head>
32
42
 
33
43
  <body>
34
- <section style="width: 100%; overflow: hidden; background-color: black;">
44
+ <section class="theater" style="width: 100%; overflow: hidden; background-color: black;">
35
45
  <ia-bookreader
36
46
  baseHost="https://archive.org"
37
47
  >
38
- <div id="IABookReaderWrapper" slot="bookreader">
48
+ <div id="IABookReaderWrapper" slot="main">
39
49
  <div id="BookReader" class="BookReader"></div>
40
50
  </div>
41
51
  <div>
@@ -50,25 +60,82 @@
50
60
  </div>
51
61
  </ia-bookreader>
52
62
  </section>
53
- <section style="height: 800px; width: 200px;">
54
- <p>placeholder div to allow scrolling</p>
63
+ <style>
64
+ .demos {
65
+ height: 800px;
66
+ width: inherit;
67
+ padding: 10px;
68
+ }
69
+ .demo {
70
+ border: 1px solid white;
71
+ padding: 10px;
72
+ }
73
+ </style>
74
+ <section class="demos">
75
+ <div class="demo">
76
+ <button id="toggle-loggedin">Toggle Logged in view</button>
77
+ <p>Features behind signed in gate: Bookmarks</p>
78
+ <p>Logged In Status: <span id="logged-in-status">Logged Out</span></p>
79
+ </div>
80
+ <div class="demo">
81
+ <button id="show-lcp">LCP Download option</button>
82
+ </div>
83
+ <div class="demo">
84
+ <button id="multi-volume">Multiple books</button>
85
+ </div>
86
+ <div class="demo">
87
+ <button id="start-fs">Start at Fullscreen</button>
88
+ </div>
89
+ <div class="demo">
90
+ <h3 id="placeholder">please wait as we are fetching the following: </h3>
91
+ <input type='checkbox' class='group1' name='itemMD' disabled>Item metadata</input><br>
92
+ <input type='checkbox' class='group1' name='bookManifest' disabled> Book manifest</input><br>
93
+ </div>
55
94
  </section>
95
+ <div class="demo">
96
+ <h3>Placeholder div to allow scrolling</h3>
97
+ </div>
56
98
 
99
+ <!-- Certain features, like Bookmarks, use modal-manager to draw their interface -->
100
+ <modal-manager></modal-manager>
101
+ <script >
102
+ // Set up demo things
103
+ const iaBR = document.querySelector('ia-bookreader');
104
+ const toggleLoginBtn = document.querySelector('#toggle-loggedin');
105
+ toggleLoginBtn.addEventListener('click', () => {
106
+ const currLoggedIn = iaBR.signedIn;
107
+ iaBR.signedIn = !currLoggedIn;
57
108
 
58
- <script id="pageUrl" type="text/javascript"></script>
59
-
60
- <script>
61
- var ocaid = location.href.match(/ocaid=([^&#]+)/i)[1];
109
+ document.querySelector('#logged-in-status').innerText = iaBR.signedIn ? 'Logged In' : 'Logged Out';
110
+ console.log("Toggled SignedIn state", iaBR.signedIn, { currLoggedIn })
111
+ });
62
112
 
63
- // Override options coming from IA
64
- BookReader.optionOverrides.imagesBaseURL = '/BookReader/images/';
113
+ const startFSBtn = document.querySelector('#start-fs');
114
+ startFSBtn.addEventListener('click', () => {
115
+ const urlParams = new URLSearchParams(window.location.search);
116
+ if (urlParams.has('view')) {
117
+ const url = new URL(window.location);
118
+ url.searchParams.delete('view');
119
+ window.history.pushState({}, '', url);
120
+ }
121
+ urlParams.set('view', 'theater');
122
+ window.location.search = urlParams.toString();
123
+ });
65
124
 
66
- // Temp; Circumvent bug in BookReaderJSIA code
67
- window.Sentry = null;
125
+ window.addEventListener('BookReader:PostInit', () => {
126
+ const placeholder = document.querySelector('#placeholder');
127
+ placeholder.innerHTML = 'Dependencies are complete, bookreader has loaded';
128
+ });
68
129
 
69
- var script_url = 'https://archive.org/bookreader/BookReaderJSLocate.php?subPrefix=&id=' + ocaid;
70
- document.getElementById('pageUrl').src = script_url;
130
+ // analytics stub
131
+ window.archive_analytics = {
132
+ send_event_no_sampling: (category, action, label) => console.log('~~~ NO SAMPLE EVENT CALLED: ', { category, action, label }),
133
+ send_event: (category, action, label) => console.log('~~~ send_event SAMPLE EVENT CALLED: ', { category, action, label }),
134
+ send_ping: (category, action, label) => console.log('~~~ send_ping SAMPLE EVENT CALLED: ', { category, action, label }),
135
+ }
71
136
  </script>
72
137
 
138
+ <!-- IA fetch demo -->
139
+ <script type="module" src="IADemoBr.js"></script>
73
140
  </body>
74
141
  </html>
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -8,7 +8,8 @@
8
8
  <meta name="apple-mobile-web-app-capable" content="yes">
9
9
 
10
10
  <!-- JS dependencies -->
11
- <script src="../BookReader/jquery-1.10.1.js"></script>
11
+ <script src="../BookReader/webcomponents-bundle.js"></script>
12
+ <script src="../BookReader/jquery-3.js"></script>
12
13
 
13
14
 
14
15
  <!-- BookReader and plugins -->
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -0,0 +1,170 @@
1
+ /* eslint-disable no-useless-escape */
2
+ const extraVolOptions = {
3
+ "isBeta": false,
4
+ "el": "#BookReader",
5
+ "enableBookTitleLink": false,
6
+ "bookUrlText": null,
7
+ "startFullscreen": false,
8
+ "initialSearchTerm": null,
9
+ "onePage": {
10
+ "autofit": "auto"
11
+ },
12
+ "showToolbar": false,
13
+ "autoResize": false,
14
+ "enableFSLogoShortcut": true,
15
+ "enableBookmarks": true,
16
+ "enableMultipleBooks": true,
17
+ "purchase_url": "",
18
+ "multipleBooksList": {
19
+ "by_subprefix": {
20
+ "book1/GPORFP": {
21
+ "url_path": "/details/SubBookTest",
22
+ "file_subprefix": "book1/GPORFP",
23
+ "title": "book1/GPORFP.pdf",
24
+ "file_source": "/book1/GPORFP_jp2.zip",
25
+ "orig_sort": 0
26
+ },
27
+ "subdir/book2/brewster_kahle_internet_archive": {
28
+ "url_path": "/details/SubBookTest/subdir/book2/brewster_kahle_internet_archive",
29
+ "file_subprefix": "subdir/book2/brewster_kahle_internet_archive",
30
+ "title": "subdir/book2/brewster_kahle_internet_archive.pdf",
31
+ "file_source": "/subdir/book2/brewster_kahle_internet_archive_jp2.zip",
32
+ "orig_sort": 1
33
+ },
34
+ "subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume": {
35
+ "url_path": "/details/SubBookTest/subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume",
36
+ "file_subprefix": "subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume",
37
+ "title": "subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume.pdf",
38
+ "file_source": "/subdir/subsubdir/book3/Rfp008011ResponseInternetArchive-without-resume_jp2.zip",
39
+ "orig_sort": 2
40
+ }
41
+ },
42
+ "main_dir": "/2/items/SubBookTest"
43
+ }
44
+ };
45
+ const custvolumesManifest = {
46
+ "data": {
47
+ "streamOnly": false,
48
+ "isRestricted": false,
49
+ "id": "SubBookTest",
50
+ "subPrefix": "book1/GPORFP",
51
+ "olHost": "https://openlibrary.org",
52
+ "bookUrl": "/details/SubBookTest",
53
+ "downloadUrls": [
54
+ [
55
+ "PDF",
56
+ "//archive.org/download/SubBookTest/book1/GPORFP.pdf"
57
+ ],
58
+ [
59
+ "ePub",
60
+ "//archive.org/download/SubBookTest/book1/GPORFP.epub"
61
+ ],
62
+ [
63
+ "Plain Text",
64
+ "//archive.org/download/SubBookTest/book1/GPORFP_djvu.txt"
65
+ ],
66
+ [
67
+ "DAISY",
68
+ "//archive.org/download/SubBookTest/book1/GPORFP_daisy.zip"
69
+ ],
70
+ [
71
+ "Kindle",
72
+ "//archive.org/download/SubBookTest/book1/GPORFP.mobi"
73
+ ]
74
+ ]
75
+ },
76
+ "brOptions": {
77
+ "bookId": "SubBookTest",
78
+ "bookPath": "/2/items/SubBookTest/book1/GPORFP",
79
+ "imageFormat": "jp2",
80
+ "server": "ia800304.us.archive.org",
81
+ "subPrefix": "book1/GPORFP",
82
+ "zip": "/2/items/SubBookTest/book1/GPORFP_jp2.zip",
83
+ "bookTitle": "Test with sub-dirs",
84
+ "ppi": "600",
85
+ "defaultStartLeaf": 0,
86
+ "pageProgression": "lr",
87
+ "vars": {
88
+ "bookId": "SubBookTest",
89
+ "bookPath": "/2/items/SubBookTest/book1/GPORFP",
90
+ "server": "ia800304.us.archive.org",
91
+ "subPrefix": "book1/GPORFP"
92
+ },
93
+ "plugins": {
94
+ "textSelection": {
95
+ "enabled": true,
96
+ "singlePageDjvuXmlUrl": "https://{{server}}/BookReader/BookReaderGetTextWrapper.php?path={{bookPath|urlencode}}_djvu.xml&mode=djvu_xml&page={{pageIndex}}"
97
+ }
98
+ },
99
+ "data": [
100
+ [
101
+ {
102
+ "width": 5213,
103
+ "height": 6566,
104
+ "uri": "https://ia800304.us.archive.org/BookReader/BookReaderImages.php?zip=/2/items/SubBookTest/book1/GPORFP_jp2.zip&file=GPORFP_jp2/GPORFP_0000.jp2&id=SubBookTest",
105
+ "leafNum": 0,
106
+ "uri_2": {
107
+ "link": "https://archive.org/download/SubBookTest/book1/GPORFP_jp2.zip/GPORFP_jp2%2FGPORFP_0000.jp2",
108
+ "base_params": "ext=jpg"
109
+ },
110
+ "pageType": "Title",
111
+ "pageSide": "R"
112
+ }
113
+ ]
114
+ ]
115
+ },
116
+ "lendingInfo": {
117
+ "lendingStatus": null,
118
+ "userid": 0,
119
+ "isAdmin": false,
120
+ "isArchiveOrgLending": false,
121
+ "isOpenLibraryLending": false,
122
+ "isLendingRequired": false,
123
+ "isBrowserBorrowable": false,
124
+ "isPrintDisabledOnly": false,
125
+ "isAvailable": false,
126
+ "isAvailableForBrowsing": false,
127
+ "userHasBorrowed": false,
128
+ "userHasBrowsed": false,
129
+ "userOnWaitingList": false,
130
+ "userHoldIsReady": false,
131
+ "userIsPrintDisabled": false,
132
+ "shouldProtectImages": false,
133
+ "daysLeftOnLoan": 0,
134
+ "secondsLeftOnLoan": 0,
135
+ "loansUrl": "",
136
+ "bookUrl": "",
137
+ "loanCount": 0,
138
+ "totalWaitlistCount": 0,
139
+ "userWaitlistPosition": -1,
140
+ "maxLoans": 10,
141
+ "loanRecord": [
142
+
143
+ ]
144
+ },
145
+ "metadata": {
146
+ "identifier": "SubBookTest",
147
+ "title": "Test with sub-dirs",
148
+ "mediatype": "texts",
149
+ "collection": [
150
+ "opensource",
151
+ "community"
152
+ ],
153
+ "publicdate": "2009-07-08 23:10:10",
154
+ "addeddate": "2009-07-08 23:09:09",
155
+ "uploader": "mang@archive.org",
156
+ "updatedate": "2009-07-08 23:10:24",
157
+ "updater": "mang@archive",
158
+ "language": "English",
159
+ "identifier-access": "http://www.archive.org/details/SubBookTest",
160
+ "identifier-ark": "ark:/13960/t08w3w21h",
161
+ "ppi": "600",
162
+ "ocr": "ABBYY FineReader 8.0",
163
+ "repub_state": "4",
164
+ "noindex": "true",
165
+ "curation": "[curator]validator@archive.org[/curator][date]20140402011645[/date][comment]checked for malware[/comment]",
166
+ "backup_location": "ia903603_14"
167
+ }
168
+ };
169
+
170
+ export { custvolumesManifest, extraVolOptions };
@@ -5,7 +5,8 @@
5
5
  <meta name="apple-mobile-web-app-capable" content="yes">
6
6
 
7
7
  <!-- JS dependencies -->
8
- <script src="../BookReader/jquery-1.10.1.js"></script>
8
+ <script src="../BookReader/webcomponents-bundle.js"></script>
9
+ <script src="../BookReader/jquery-3.js"></script>
9
10
 
10
11
 
11
12
  <!-- Bookreader -->
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->
@@ -7,7 +7,8 @@
7
7
  <meta name="apple-mobile-web-app-capable" content="yes">
8
8
 
9
9
  <!-- JS dependencies -->
10
- <script src="../BookReader/jquery-1.10.1.js"></script>
10
+ <script src="../BookReader/webcomponents-bundle.js"></script>
11
+ <script src="../BookReader/jquery-3.js"></script>
11
12
 
12
13
 
13
14
  <!-- BookReader and plugins -->