@internetarchive/bookreader 5.0.0-38 → 5.0.0-39

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 (222) hide show
  1. package/BookReader/BookReader.css +8 -0
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.map +1 -1
  4. package/BookReader/ia-bookreader-bundle.js +99 -75
  5. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  6. package/BookReader/icons/magnify-minus.svg +1 -1
  7. package/BookReader/icons/magnify-plus.svg +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.chapters.js +1 -1
  11. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  12. package/BookReader/plugins/plugin.mobile_nav.js +1 -1
  13. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
  14. package/BookReader/plugins/plugin.resume.js +1 -1
  15. package/BookReader/plugins/plugin.resume.js.map +1 -1
  16. package/BookReader/plugins/plugin.search.js +1 -1
  17. package/BookReader/plugins/plugin.search.js.map +1 -1
  18. package/BookReader/plugins/plugin.text_selection.js +1 -1
  19. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  20. package/BookReader/plugins/plugin.tts.js +1 -1
  21. package/BookReader/plugins/plugin.tts.js.map +1 -1
  22. package/BookReader/plugins/plugin.url.js +1 -1
  23. package/BookReader/plugins/plugin.url.js.map +1 -1
  24. package/CHANGELOG.md +5 -0
  25. package/README.md +13 -0
  26. package/package.json +14 -14
  27. package/renovate.json +1 -1
  28. package/src/BookReader/Mode1UpLit.js +7 -1
  29. package/src/BookReader/Mode2Up.js +11 -0
  30. package/src/BookReader/ModeSmoothZoom.js +2 -0
  31. package/src/BookReader/PageContainer.js +10 -4
  32. package/src/BookReader/utils/ScrollClassAdder.js +31 -0
  33. package/src/assets/icons/magnify-minus.svg +3 -7
  34. package/src/assets/icons/magnify-plus.svg +3 -7
  35. package/src/css/_TextSelection.scss +13 -0
  36. package/tests/jest/BookReader/PageContainer.test.js +5 -4
  37. package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
  38. package/.husky/_/husky.sh +0 -30
  39. package/stat/BookNavigator/BookModel.js +0 -14
  40. package/stat/BookNavigator/BookNavigator.js +0 -524
  41. package/stat/BookNavigator/assets/bookmark-colors.js +0 -15
  42. package/stat/BookNavigator/assets/button-base.js +0 -61
  43. package/stat/BookNavigator/assets/ia-logo.js +0 -17
  44. package/stat/BookNavigator/assets/icon_checkmark.js +0 -6
  45. package/stat/BookNavigator/assets/icon_close.js +0 -3
  46. package/stat/BookNavigator/assets/icon_sort_asc.js +0 -5
  47. package/stat/BookNavigator/assets/icon_sort_desc.js +0 -5
  48. package/stat/BookNavigator/assets/icon_sort_neutral.js +0 -5
  49. package/stat/BookNavigator/assets/icon_volumes.js +0 -11
  50. package/stat/BookNavigator/bookmarks/bookmark-button.js +0 -64
  51. package/stat/BookNavigator/bookmarks/bookmark-edit.js +0 -215
  52. package/stat/BookNavigator/bookmarks/bookmarks-list.js +0 -285
  53. package/stat/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -28
  54. package/stat/BookNavigator/bookmarks/bookmarks-provider.js +0 -56
  55. package/stat/BookNavigator/bookmarks/ia-bookmarks.js +0 -523
  56. package/stat/BookNavigator/br-fullscreen-mgr.js +0 -82
  57. package/stat/BookNavigator/delete-modal-actions.js +0 -49
  58. package/stat/BookNavigator/downloads/downloads-provider.js +0 -72
  59. package/stat/BookNavigator/downloads/downloads.js +0 -139
  60. package/stat/BookNavigator/provider-config.js +0 -0
  61. package/stat/BookNavigator/search/a-search-result.js +0 -55
  62. package/stat/BookNavigator/search/search-provider.js +0 -180
  63. package/stat/BookNavigator/search/search-results.js +0 -360
  64. package/stat/BookNavigator/sharing.js +0 -31
  65. package/stat/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -94
  66. package/stat/BookNavigator/visual-adjustments/visual-adjustments.js +0 -280
  67. package/stat/BookNavigator/volumes/volumes-provider.js +0 -83
  68. package/stat/BookNavigator/volumes/volumes.js +0 -178
  69. package/stat/BookReader/BookModel.js +0 -518
  70. package/stat/BookReader/DebugConsole.js +0 -54
  71. package/stat/BookReader/DragScrollable.js +0 -233
  72. package/stat/BookReader/ImageCache.js +0 -116
  73. package/stat/BookReader/Mode1Up.js +0 -102
  74. package/stat/BookReader/Mode1UpLit.js +0 -434
  75. package/stat/BookReader/Mode2Up.js +0 -1372
  76. package/stat/BookReader/ModeSmoothZoom.js +0 -177
  77. package/stat/BookReader/ModeThumb.js +0 -344
  78. package/stat/BookReader/Navbar/Navbar.js +0 -310
  79. package/stat/BookReader/PageContainer.js +0 -120
  80. package/stat/BookReader/ReduceSet.js +0 -26
  81. package/stat/BookReader/Toolbar/Toolbar.js +0 -384
  82. package/stat/BookReader/events.js +0 -20
  83. package/stat/BookReader/options.js +0 -324
  84. package/stat/BookReader/utils/HTMLDimensionsCacher.js +0 -44
  85. package/stat/BookReader/utils/classes.js +0 -36
  86. package/stat/BookReader/utils.js +0 -240
  87. package/stat/BookReader.js +0 -2550
  88. package/stat/BookReaderComponent/BookReaderComponent.js +0 -117
  89. package/stat/assets/icons/1up.svg +0 -12
  90. package/stat/assets/icons/2up.svg +0 -15
  91. package/stat/assets/icons/advance.svg +0 -26
  92. package/stat/assets/icons/chevron-right.svg +0 -1
  93. package/stat/assets/icons/close-circle-dark.svg +0 -1
  94. package/stat/assets/icons/close-circle.svg +0 -1
  95. package/stat/assets/icons/fullscreen.svg +0 -17
  96. package/stat/assets/icons/fullscreen_exit.svg +0 -17
  97. package/stat/assets/icons/hamburger.svg +0 -15
  98. package/stat/assets/icons/left-arrow.svg +0 -12
  99. package/stat/assets/icons/magnify-minus.svg +0 -16
  100. package/stat/assets/icons/magnify-plus.svg +0 -17
  101. package/stat/assets/icons/magnify.svg +0 -15
  102. package/stat/assets/icons/pause.svg +0 -23
  103. package/stat/assets/icons/play.svg +0 -22
  104. package/stat/assets/icons/playback-speed.svg +0 -34
  105. package/stat/assets/icons/read-aloud.svg +0 -22
  106. package/stat/assets/icons/review.svg +0 -22
  107. package/stat/assets/icons/thumbnails.svg +0 -17
  108. package/stat/assets/icons/voice.svg +0 -1
  109. package/stat/assets/icons/volume-full.svg +0 -22
  110. package/stat/assets/images/BRicons.png +0 -0
  111. package/stat/assets/images/BRicons.svg +0 -94
  112. package/stat/assets/images/BRicons_ia.png +0 -0
  113. package/stat/assets/images/back_pages.png +0 -0
  114. package/stat/assets/images/book_bottom_icon.png +0 -0
  115. package/stat/assets/images/book_down_icon.png +0 -0
  116. package/stat/assets/images/book_left_icon.png +0 -0
  117. package/stat/assets/images/book_leftmost_icon.png +0 -0
  118. package/stat/assets/images/book_right_icon.png +0 -0
  119. package/stat/assets/images/book_rightmost_icon.png +0 -0
  120. package/stat/assets/images/book_top_icon.png +0 -0
  121. package/stat/assets/images/book_up_icon.png +0 -0
  122. package/stat/assets/images/books_graphic.svg +0 -177
  123. package/stat/assets/images/booksplit.png +0 -0
  124. package/stat/assets/images/control_pause_icon.png +0 -0
  125. package/stat/assets/images/control_play_icon.png +0 -0
  126. package/stat/assets/images/embed_icon.png +0 -0
  127. package/stat/assets/images/icon-home-ia.png +0 -0
  128. package/stat/assets/images/icon_OL-logo-xs.png +0 -0
  129. package/stat/assets/images/icon_alert-xs.png +0 -0
  130. package/stat/assets/images/icon_book.svg +0 -12
  131. package/stat/assets/images/icon_bookmark.svg +0 -12
  132. package/stat/assets/images/icon_close-pop.png +0 -0
  133. package/stat/assets/images/icon_download.png +0 -0
  134. package/stat/assets/images/icon_gear.svg +0 -14
  135. package/stat/assets/images/icon_hamburger.svg +0 -20
  136. package/stat/assets/images/icon_home.png +0 -0
  137. package/stat/assets/images/icon_home.svg +0 -21
  138. package/stat/assets/images/icon_home_ia.png +0 -0
  139. package/stat/assets/images/icon_indicator.png +0 -0
  140. package/stat/assets/images/icon_info.svg +0 -11
  141. package/stat/assets/images/icon_one_page.svg +0 -8
  142. package/stat/assets/images/icon_pause.svg +0 -1
  143. package/stat/assets/images/icon_play.svg +0 -1
  144. package/stat/assets/images/icon_playback-rate.svg +0 -15
  145. package/stat/assets/images/icon_return.png +0 -0
  146. package/stat/assets/images/icon_search_button.svg +0 -8
  147. package/stat/assets/images/icon_share.svg +0 -9
  148. package/stat/assets/images/icon_skip-ahead.svg +0 -6
  149. package/stat/assets/images/icon_skip-back.svg +0 -13
  150. package/stat/assets/images/icon_speaker.svg +0 -18
  151. package/stat/assets/images/icon_speaker_open.svg +0 -10
  152. package/stat/assets/images/icon_thumbnails.svg +0 -12
  153. package/stat/assets/images/icon_toc.svg +0 -5
  154. package/stat/assets/images/icon_two_pages.svg +0 -9
  155. package/stat/assets/images/icon_zoomer.png +0 -0
  156. package/stat/assets/images/loading.gif +0 -0
  157. package/stat/assets/images/logo_icon.png +0 -0
  158. package/stat/assets/images/marker_chap-off.png +0 -0
  159. package/stat/assets/images/marker_chap-off.svg +0 -11
  160. package/stat/assets/images/marker_chap-off_ia.png +0 -0
  161. package/stat/assets/images/marker_chap-on.png +0 -0
  162. package/stat/assets/images/marker_chap-on.svg +0 -11
  163. package/stat/assets/images/marker_srch-on.svg +0 -11
  164. package/stat/assets/images/marker_srchchap-off.png +0 -0
  165. package/stat/assets/images/marker_srchchap-on.png +0 -0
  166. package/stat/assets/images/nav_control-dn.png +0 -0
  167. package/stat/assets/images/nav_control-dn_ia.png +0 -0
  168. package/stat/assets/images/nav_control-up.png +0 -0
  169. package/stat/assets/images/nav_control-up_ia.png +0 -0
  170. package/stat/assets/images/nav_control.png +0 -0
  171. package/stat/assets/images/one_page_mode_icon.png +0 -0
  172. package/stat/assets/images/paper-badge.png +0 -0
  173. package/stat/assets/images/print_icon.png +0 -0
  174. package/stat/assets/images/progressbar.gif +0 -0
  175. package/stat/assets/images/right_edges.png +0 -0
  176. package/stat/assets/images/slider.png +0 -0
  177. package/stat/assets/images/slider_ia.png +0 -0
  178. package/stat/assets/images/thumbnail_mode_icon.png +0 -0
  179. package/stat/assets/images/transparent.png +0 -0
  180. package/stat/assets/images/two_page_mode_icon.png +0 -0
  181. package/stat/assets/images/zoom_in_icon.png +0 -0
  182. package/stat/assets/images/zoom_out_icon.png +0 -0
  183. package/stat/css/BookReader.scss +0 -89
  184. package/stat/css/_BRBookmarks.scss +0 -29
  185. package/stat/css/_BRComponent.scss +0 -13
  186. package/stat/css/_BRfloat.scss +0 -197
  187. package/stat/css/_BRicon.scss +0 -48
  188. package/stat/css/_BRmain.scss +0 -251
  189. package/stat/css/_BRnav.scss +0 -359
  190. package/stat/css/_BRpages.scss +0 -139
  191. package/stat/css/_BRsearch.scss +0 -226
  192. package/stat/css/_BRtoolbar.scss +0 -84
  193. package/stat/css/_BRvendor.scss +0 -5
  194. package/stat/css/_MobileNav.scss +0 -194
  195. package/stat/css/_TextSelection.scss +0 -32
  196. package/stat/css/_colorbox.scss +0 -52
  197. package/stat/css/_controls.scss +0 -253
  198. package/stat/css/_icons.scss +0 -121
  199. package/stat/jquery-wrapper.js +0 -4
  200. package/stat/plugins/plugin.archive_analytics.js +0 -86
  201. package/stat/plugins/plugin.autoplay.js +0 -129
  202. package/stat/plugins/plugin.chapters.js +0 -248
  203. package/stat/plugins/plugin.iframe.js +0 -48
  204. package/stat/plugins/plugin.mobile_nav.js +0 -288
  205. package/stat/plugins/plugin.resume.js +0 -68
  206. package/stat/plugins/plugin.text_selection.js +0 -291
  207. package/stat/plugins/plugin.url.js +0 -198
  208. package/stat/plugins/plugin.vendor-fullscreen.js +0 -247
  209. package/stat/plugins/search/plugin.search.js +0 -439
  210. package/stat/plugins/search/view.js +0 -439
  211. package/stat/plugins/tts/AbstractTTSEngine.js +0 -249
  212. package/stat/plugins/tts/FestivalTTSEngine.js +0 -169
  213. package/stat/plugins/tts/PageChunk.js +0 -107
  214. package/stat/plugins/tts/PageChunkIterator.js +0 -163
  215. package/stat/plugins/tts/WebTTSEngine.js +0 -357
  216. package/stat/plugins/tts/plugin.tts.js +0 -357
  217. package/stat/plugins/tts/tooltip_dict.js +0 -15
  218. package/stat/plugins/tts/utils.js +0 -91
  219. package/stat/util/browserSniffing.js +0 -30
  220. package/stat/util/debouncer.js +0 -26
  221. package/stat/util/docCookies.js +0 -67
  222. package/stat/util/strings.js +0 -34
@@ -1,384 +0,0 @@
1
- import 'jquery-colorbox';
2
- import { escapeHTML } from '../utils.js';
3
- import { EVENTS } from '../events.js';
4
- /** @typedef {import("../../BookReader.js").default} BookReader */
5
-
6
- export class Toolbar {
7
- /**
8
- * @param {BookReader} br
9
- */
10
- constructor(br) {
11
- this.br = br;
12
- }
13
-
14
- /**
15
- * This method builds the html for the toolbar. It can be decorated to extend
16
- * the toolbar.
17
- * @return {JQuery}
18
- */
19
- buildToolbarElement() {
20
- const { br } = this;
21
- const logoHtml = !br.showLogo ? '' : `
22
- <span class="BRtoolbarSection BRtoolbarSectionLogo">
23
- <a class="logo" href="${br.logoURL}"></a>
24
- </span>`;
25
-
26
- // Add large screen navigation
27
- br.refs.$BRtoolbar = $(`
28
- <div class="BRtoolbar header">
29
- <div class="BRtoolbarbuttons">
30
- <div class="BRtoolbarLeft">
31
- ${logoHtml}
32
- <span class="BRtoolbarSection BRtoolbarSectionTitle"></span>
33
- </div>
34
- <div class="BRtoolbarRight">
35
- <span class="BRtoolbarSection BRtoolbarSectionInfo">
36
- <button class="BRpill info js-tooltip">Info</button>
37
- <button class="BRpill share js-tooltip">Share</button>
38
- </span>
39
- </div>
40
- </div>
41
- </div>`);
42
- // TODO actual hamburger menu
43
- // <span class="BRtoolbarSection BRtoolbarSectionMenu">
44
- // <button class="BRpill BRtoolbarHamburger">
45
- // <img src="${br.imagesBaseURL}icon_hamburger.svg" />
46
- // <div class="BRhamburgerDrawer"><ul><li>hi</li></ul></div>
47
- // </button>
48
- // </span>
49
-
50
- const $titleSectionEl = br.refs.$BRtoolbar.find('.BRtoolbarSectionTitle');
51
- if (br.bookUrl && br.options.enableBookTitleLink) {
52
- $titleSectionEl.append(
53
- $('<a>')
54
- .attr({href: br.bookUrl, title: br.bookUrlTitle})
55
- .addClass('BRreturn')
56
- .html(br.bookUrlText || br.bookTitle)
57
- );
58
- } else if (br.bookTitle) {
59
- $titleSectionEl.append(br.bookUrlText || br.bookTitle);
60
- }
61
-
62
- // const $hamburger = br.refs.$BRtoolbar.find('BRtoolbarHamburger');
63
- return br.refs.$BRtoolbar;
64
- }
65
-
66
- /**
67
- * Initializes the toolbar (top)
68
- * @param {string} mode
69
- * @param {string} ui
70
- */
71
- initToolbar(mode, ui) {
72
- const { br } = this;
73
- br.refs.$br.append(this.buildToolbarElement());
74
-
75
- br.$('.BRnavCntl').addClass('BRup');
76
- br.$('.pause').hide();
77
-
78
- this.updateToolbarZoom(br.reduce); // Pretty format
79
-
80
- // We build in mode 2
81
- br.refs.$BRtoolbar.append();
82
-
83
- // Hide mode buttons and autoplay if 2up is not available
84
- // $$$ if we end up with more than two modes we should show the applicable buttons
85
- if ( !br.canSwitchToMode(br.constMode2up) ) {
86
- br.$('.two_page_mode, .play, .pause').hide();
87
- }
88
- if ( !br.canSwitchToMode(br.constModeThumb) ) {
89
- br.$('.thumbnail_mode').hide();
90
- }
91
-
92
- // Hide one page button if it is the only mode available
93
- if ( ! (br.canSwitchToMode(br.constMode2up) || br.canSwitchToMode(br.constModeThumb)) ) {
94
- br.$('.one_page_mode').hide();
95
- }
96
-
97
- $('<div style="display: none;"></div>')
98
- .append(blankShareDiv())
99
- .append(blankInfoDiv())
100
- .appendTo(br.refs.$br);
101
-
102
- br.$('.BRinfo .BRfloatTitle a')
103
- .attr({href: br.bookUrl})
104
- .text(br.bookTitle)
105
- .addClass('title');
106
-
107
- // These functions can be overridden
108
- this.buildInfoDiv(br.$('.BRinfo'));
109
- this.buildShareDiv(br.$('.BRshare'));
110
-
111
- br.$('.share').colorbox({
112
- inline: true,
113
- opacity: "0.5",
114
- href: br.$('.BRshare'),
115
- onLoad: () => {
116
- br.trigger(EVENTS.stop);
117
- br.$('.BRpageviewValue').val(window.location.href);
118
- }
119
- });
120
- br.$('.info').colorbox({
121
- inline: true,
122
- opacity: "0.5",
123
- href: br.$('.BRinfo'),
124
- onLoad: () => {
125
- br.trigger(EVENTS.stop);
126
- }
127
- });
128
- }
129
-
130
- /**
131
- * @deprecated
132
- * @todo .BRzoom doesn't exist anywhere, so this is likely dead code
133
- * Update the displayed zoom factor based on reduction factor
134
- * @param {number} reduce
135
- */
136
- updateToolbarZoom(reduce) {
137
- const { br } = this;
138
- // $$$ TODO preserve zoom/fit for each mode
139
- const autofit = br.mode == br.constMode2up ? br.twoPage.autofit : br.onePage.autofit;
140
- /** @type {string} */
141
- let value;
142
- if (autofit) {
143
- value = autofit.slice(0,1).toUpperCase() + autofit.slice(1);
144
- } else {
145
- value = (100 / reduce)
146
- .toFixed(2)
147
- // Strip trailing zeroes and decimal if all zeroes
148
- .replace(/0+$/,'')
149
- .replace(/\.$/,'')
150
- + '%';
151
- }
152
- br.$('.BRzoom').text(value);
153
- }
154
-
155
- /**
156
- * @param {JQuery} $shareDiv
157
- */
158
- buildShareDiv($shareDiv) {
159
- const { br } = this;
160
- const pageView = document.location + '';
161
- const bookView = (pageView + '').replace(/#.*/,'');
162
-
163
- const embedHtml = !br.getEmbedCode ? '' : `
164
- <div class="share-embed">
165
- <p class="share-embed-prompt">Copy and paste one of these options to share this book elsewhere.</p>
166
- <form method="post" action="">
167
- <fieldset class="fieldset-share-pageview">
168
- <label for="pageview">Link to this page view</label>
169
- <input type="text" name="pageview" class="BRpageviewValue" value="${pageView}"/>
170
- </fieldset>
171
- <fieldset class="fieldset-share-book-link">
172
- <label for="booklink">Link to the book</label>
173
- <input type="text" name="booklink" class="booklink" value="${bookView}"/>
174
- </fieldset>
175
- <fieldset class="fieldset-embed">
176
- <label for="iframe">Embed a mini Book Reader</label>
177
- <fieldset class="sub">
178
- <label class="sub">
179
- <input type="radio" name="pages" value="${br.constMode1up}" checked="checked"/>
180
- 1 page
181
- </label>
182
- <label class="sub">
183
- <input type="radio" name="pages" value="${br.constMode2up}"/>
184
- 2 pages
185
- </label>
186
- <label class="sub">
187
- <input type="checkbox" name="thispage" value="thispage"/>
188
- Open to this page?
189
- </label>
190
- </fieldset>
191
- <textarea cols="30" rows="4" name="iframe" class="BRframeEmbed"></textarea>
192
- </fieldset>
193
- </form>
194
- </div>`;
195
-
196
- const $form = $(`
197
- <div class="share-title">Share this book</div>
198
- <div class="share-social">
199
- <label class="sub open-to-this-page">
200
- <input class="thispage-social" type="checkbox" />
201
- Open to this page?
202
- </label>
203
- <div><button class="BRaction share facebook-share-button"><i class="BRicon fb" /> Facebook</button></div>
204
- <div><button class="BRaction share twitter-share-button"><i class="BRicon twitter" /> Twitter</button></div>
205
- <div><button class="BRaction share email-share-button"><i class="BRicon email" /> Email</button></div>
206
- </div>
207
- ${embedHtml}
208
- <div class="BRfloatFoot">
209
- <button class="share-finished" type="button" onclick="$.fn.colorbox.close();">Finished</button>
210
- </div>`);
211
-
212
- $form.appendTo($shareDiv);
213
-
214
- $form.find('.fieldset-embed input').on('change', event => {
215
- const form = $(event.target).parents('form').first();
216
- const params = {};
217
- params.mode = $(form.find('.fieldset-embed input[name=pages]:checked')).val();
218
- if (form.find('.fieldset-embed input[name=thispage]').prop('checked')) {
219
- params.page = br.getPageNum(br.currentIndex());
220
- }
221
-
222
- if (br.getEmbedCode) {
223
- // $$$ changeable width/height to be added to share UI
224
- const frameWidth = "480px";
225
- const frameHeight = "430px";
226
- form.find('.BRframeEmbed').val(br.getEmbedCode(frameWidth, frameHeight, params));
227
- }
228
- });
229
-
230
- $form.find('input, textarea').on('focus', event => event.target.select());
231
-
232
- // Bind share buttons
233
-
234
- // Use url without hashes
235
- $form.find('.facebook-share-button').on("click", () => {
236
- const params = $.param({ u: this._getSocialShareUrl() });
237
- const url = 'https://www.facebook.com/sharer.php?' + params;
238
- createPopup(url, 600, 400, 'Share');
239
- });
240
- $form.find('.twitter-share-button').on("click", () => {
241
- const params = $.param({
242
- url: this._getSocialShareUrl(),
243
- text: br.bookTitle
244
- });
245
- const url = 'https://twitter.com/intent/tweet?' + params;
246
- createPopup(url, 600, 400, 'Share');
247
- });
248
- $form.find('.email-share-button').on("click", () => {
249
- const body = `${br.bookTitle}\n\n${this._getSocialShareUrl()}`;
250
- window.location.href = `mailto:?subject=${encodeURI(br.bookTitle)}&body=${encodeURI(body)}`;
251
- });
252
-
253
- $form.find('input[name=thispage]').trigger('change');
254
-
255
- $form.appendTo($shareDiv);
256
- }
257
-
258
- _getSocialShareUrl() {
259
- const { br } = this;
260
- const shareThisPage = br.$('.thispage-social').prop('checked');
261
- if (shareThisPage) {
262
- return window.location.href;
263
- } else {
264
- return `${document.location.protocol}//${window.location.hostname}${window.location.pathname}`;
265
- }
266
- }
267
-
268
- /**
269
- * @param {JQuery} $infoDiv DOM element. Appends info to this element
270
- * Can be overridden or extended
271
- */
272
- buildInfoDiv($infoDiv) {
273
- const { br } = this;
274
- // Remove these legacy elements
275
- $infoDiv.find('.BRfloatBody, .BRfloatCover, .BRfloatFoot').remove();
276
-
277
- const $leftCol = $(`<div class="BRinfoLeftCol"></div>`);
278
- if (br.thumbnail) {
279
- $leftCol.append($(`
280
- <div class="BRimageW">
281
- <img src="${br.thumbnail}" alt="${escapeHTML(br.bookTitle)}" />
282
- </div>`));
283
- }
284
-
285
- const $rightCol = $(`<div class="BRinfoRightCol">`);
286
-
287
- // A loop to build fields
288
- for (const {extraValueClass = '', label, value} of br.metadata) {
289
- const escapedValue = label === 'Title' ? escapeHTML(value) : value;
290
- $rightCol.append($(`
291
- <div class="BRinfoValueWrapper">
292
- <div class="BRinfoLabel">${label}</div>
293
- <div class="BRinfoValue ${extraValueClass}">${escapedValue}</div>
294
- </div>`));
295
- }
296
-
297
- const moreInfoText = br.bookUrlMoreInfo ? br.bookUrlMoreInfo : br.bookTitle;
298
- if (moreInfoText && br.bookUrl) {
299
- $rightCol.append($(`
300
- <div class="BRinfoValueWrapper">
301
- <div class="BRinfoMoreInfoWrapper">
302
- <a class="BRinfoMoreInfo" href="${br.bookUrl}">
303
- ${escapeHTML(moreInfoText)}
304
- </a>
305
- </div>
306
- </div>`));
307
- }
308
-
309
- const $footer = $(`<div class="BRfloatFoot BRinfoFooter"></div>`);
310
- const $children = $('<div class="BRinfoW mv20-lg">').append([
311
- $leftCol,
312
- $rightCol,
313
- $('<br style="clear:both"/>'),
314
- ]);
315
-
316
- $infoDiv
317
- .append($children, $footer)
318
- .addClass('wide');
319
- }
320
-
321
- /**
322
- * @return {number} (in pixels) of the toolbar height. 0 if no toolbar.
323
- */
324
- getToolBarHeight() {
325
- const { $BRtoolbar } = this.br.refs;
326
- if ($BRtoolbar && $BRtoolbar.css('display') === 'block') {
327
- return ($BRtoolbar.outerHeight() + parseInt($BRtoolbar.css('top')));
328
- } else {
329
- return 0;
330
- }
331
- }
332
- }
333
-
334
- export function blankInfoDiv() {
335
- return $(`
336
- <div class="BRfloat BRinfo">
337
- <div class="BRfloatHead">About this book
338
- <button class="floatShut" href="javascript:;" onclick="$.fn.colorbox.close();"><span class="shift">Close</span></button>
339
- </div>
340
- <div class="BRfloatBody">
341
- <div class="BRfloatCover"></div>
342
- <div class="BRfloatMeta">
343
- <div class="BRfloatTitle">
344
- <h2><a /></h2>
345
- </div>
346
- </div>
347
- </div>
348
- <div class="BRfloatFoot">
349
- <a href="https://openlibrary.org/dev/docs/bookreader">About the BookReader</a>
350
- </div>
351
- </div>`);
352
- }
353
-
354
- export function blankShareDiv() {
355
- return $(`
356
- <div class="BRfloat BRshare">
357
- <div class="BRfloatHead">
358
- Share
359
- <button class="floatShut" href="javascript:;" onclick="$.fn.colorbox.close();"><span class="shift">Close</span></button>
360
- </div>
361
- </div>`);
362
- }
363
-
364
- /**
365
- * Helper opens a popup window. On mobile it only opens a new tab. Used for share.
366
- * @param {string} href
367
- * @param {number} width
368
- * @param {number} height
369
- * @param {string} name
370
- */
371
- export function createPopup(href, width, height, name) {
372
- // Fixes dual-screen position
373
- const dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
374
- const dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
375
-
376
- const win_w = window.innerWidth || document.documentElement.clientWidth || screen.width;
377
- const win_h = window.innerHeight || document.documentElement.clientHeight || screen.height;
378
-
379
- const left = ((win_w / 2) - (width / 2)) + dualScreenLeft;
380
- const top = ((win_h / 2) - (height / 2)) + dualScreenTop;
381
- const opts = `status=1,width=${width},height=${height},top=${top},left=${left}`;
382
-
383
- window.open(href, name, opts);
384
- }
@@ -1,20 +0,0 @@
1
- /** @enum {string} */
2
- export const EVENTS = {
3
- /** Indicates that the fragment (a serialization of the reader
4
- * state) has changed. */
5
- fragmentChange: 'fragmentChange',
6
- PostInit: 'PostInit',
7
- stop: 'stop',
8
- resize: 'resize',
9
- // nav events:
10
- navToggled: 'navToggled',
11
- // menu click events
12
- fullscreenToggled: 'fullscreenToggled',
13
- zoomOut: 'zoomOut',
14
- zoomIn: 'zoomIn',
15
- '1PageViewSelected': '1PageViewSelected',
16
- '2PageViewSelected': '2PageViewSelected',
17
- /* currently 3 represents thumbnail view */
18
- '3PageViewSelected': '3PageViewSelected',
19
- mobileNavOpen: 'mobileNavOpen',
20
- };