@internetarchive/bookreader 5.0.0-38 → 5.0.0-39

Sign up to get free protection for your applications and to get access to all the features.
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,64 +0,0 @@
1
- import { LitElement, html, css } from 'lit-element';
2
-
3
- export default class BookmarkButton extends LitElement {
4
- static get styles() {
5
- return css`
6
- button {
7
- -webkit-appearance: none;
8
- appearance: none;
9
- outline: 0;
10
- border: none;
11
- padding: 0;
12
- height: 4rem;
13
- width: 4rem;
14
- background: transparent;
15
- cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 24' width='16'%3E%3Cg fill='%23333' fill-rule='evenodd'%3E%3Cpath d='m15 0c.5522847 0 1 .44771525 1 1v23l-8-5.4545455-8 5.4545455v-23c0-.55228475.44771525-1 1-1zm-2 2h-10c-.51283584 0-.93550716.38604019-.99327227.88337887l-.00672773.11662113v18l6-4.3181818 6 4.3181818v-18c0-.51283584-.3860402-.93550716-.8833789-.99327227z'/%3E%3Cpath d='m8.75 6v2.25h2.25v1.5h-2.25v2.25h-1.5v-2.25h-2.25v-1.5h2.25v-2.25z' fill-rule='nonzero'/%3E%3C/g%3E%3C/svg%3E"), pointer;
16
- position: relative;
17
- }
18
- button > * {
19
- display: block;
20
- position: absolute;
21
- top: 0.2rem;
22
- }
23
- button.left > * {
24
- left: 0.2rem;
25
- }
26
-
27
- button.right > * {
28
- right: 0.2rem;
29
- }
30
- `;
31
- }
32
-
33
- static get properties() {
34
- return {
35
- side: { type: String },
36
- state: { type: String },
37
- };
38
- }
39
-
40
- constructor() {
41
- super();
42
- this.state = 'hollow';
43
- }
44
-
45
- handleClick(e) {
46
- e.preventDefault();
47
- this.dispatchEvent(new CustomEvent('bookmarkButtonClicked'));
48
- }
49
-
50
- get title() {
51
- return `${this.state === 'hollow' ? 'Add' : 'Remove'} bookmark`;
52
- }
53
-
54
- render() {
55
- const position = this.side || 'right';
56
- return html`
57
- <button title=${this.title} @click=${this.handleClick} class=${position}>
58
- <icon-bookmark state=${this.state}></icon-bookmark>
59
- </button>
60
- `;
61
- }
62
- }
63
-
64
- customElements.define('bookmark-button', BookmarkButton);
@@ -1,215 +0,0 @@
1
- import { nothing } from 'lit-html';
2
- import { repeat } from 'lit-html/directives/repeat.js';
3
- import { css, html, LitElement } from 'lit-element';
4
- import bookmarkColorsCSS from '../assets/bookmark-colors.js';
5
- import buttonCSS from '../assets/button-base.js';
6
-
7
- export class IABookmarkEdit extends LitElement {
8
- static get properties() {
9
- return {
10
- bookmark: { type: Object },
11
- bookmarkColors: { type: Array },
12
- renderHeader: { type: Boolean },
13
- showBookmark: { type: Boolean },
14
- };
15
- }
16
-
17
- constructor() {
18
- super();
19
- this.bookmark = {};
20
- this.bookmarkColors = [];
21
- this.renderHeader = false;
22
- this.showBookmark = true;
23
- }
24
-
25
- emitSaveEvent(e) {
26
- e.preventDefault();
27
- this.dispatchEvent(new CustomEvent('saveBookmark', {
28
- detail: {
29
- bookmark: this.bookmark,
30
- },
31
- }));
32
- }
33
-
34
- emitDeleteEvent() {
35
- this.dispatchEvent(new CustomEvent('deleteBookmark', {
36
- detail: {
37
- id: this.bookmark.id,
38
- },
39
- }));
40
- }
41
-
42
- emitColorChangedEvent(colorId) {
43
- this.dispatchEvent(new CustomEvent('bookmarkColorChanged', {
44
- detail: {
45
- bookmarkId: this.bookmark.id,
46
- colorId,
47
- },
48
- }));
49
- }
50
-
51
- changeColorTo(id) {
52
- this.bookmark.color = id;
53
- this.emitColorChangedEvent(id);
54
- }
55
-
56
- updateNote(e) {
57
- this.bookmark.note = e.currentTarget.value;
58
- }
59
-
60
- static get headerSection() {
61
- return html`<header>
62
- <h3>Edit Bookmark</h3>
63
- </header>`;
64
- }
65
-
66
- bookmarkColor(color) {
67
- return html`
68
- <li>
69
- <input type="radio" name="color" id="color_${color.id}" .value=${color.id} @change=${() => this.changeColorTo(color.id)} ?checked=${this.bookmark.color === color.id}>
70
- <label for="color_${color.id}">
71
- <icon-bookmark class=${color.className}></icon-bookmark>
72
- </label>
73
- </li>
74
- `;
75
- }
76
-
77
- get bookmarkTemplate() {
78
- return html`
79
- <div class="bookmark">
80
- <img src=${this.bookmark.thumbnail} />
81
- <h4>Page ${this.bookmark.page}</h4>
82
- </div>
83
- `;
84
- }
85
-
86
- render() {
87
- return html`
88
- ${this.renderHeader ? IABookmarkEdit.headerSection : nothing}
89
- ${this.showBookmark ? this.bookmarkTemplate : nothing}
90
- <form action="" method="put" @submit=${this.emitSaveEvent}>
91
- <fieldset>
92
- <label for="note">Note <small>(optional)</small></label>
93
- <textarea rows="4" cols="80" name="note" id="note" @change=${this.updateNote}>${this.bookmark.note}</textarea>
94
- <label for="color">Bookmark color</label>
95
- <ul>
96
- ${repeat(this.bookmarkColors, color => color.id, this.bookmarkColor.bind(this))}
97
- </ul>
98
- <div class="actions">
99
- <button type="button" class="ia-button cancel" @click=${this.emitDeleteEvent}>Delete</button>
100
- <input class="ia-button" type="submit" value="Save">
101
- </div>
102
- </fieldset>
103
- </form>
104
- `;
105
- }
106
-
107
- static get styles() {
108
- const bookmarkEditCSS = css`
109
- :host {
110
- display: block;
111
- padding: 0 1rem 2rem 1rem;
112
- color: var(--primaryTextColor);
113
- }
114
-
115
- small {
116
- font-style: italic;
117
- }
118
-
119
- .bookmark {
120
- display: grid;
121
- grid-template-columns: 37px 1fr;
122
- grid-gap: 0 1rem;
123
- align-items: center;
124
- }
125
-
126
- h4 {
127
- margin: 0;
128
- font-size: 1.4rem;
129
- }
130
-
131
- fieldset {
132
- padding: 2rem 0 0 0;
133
- border: none;
134
- }
135
-
136
- label {
137
- display: block;
138
- font-weight: bold;
139
- }
140
-
141
- p {
142
- padding: 0;
143
- margin: .5rem 0;
144
- font-size: 1.2rem;
145
- line-height: 120%;
146
- }
147
-
148
- textarea {
149
- width: 100%;
150
- margin-bottom: 2rem;
151
- box-sizing: border-box;
152
- font: normal 1.4rem "Helvetica Neue", Helvetica, Arial, sans-serif;
153
- resize: vertical;
154
- }
155
-
156
- ul {
157
- display: grid;
158
- grid-template-columns: repeat(3, auto);
159
- grid-gap: 0 2rem;
160
- justify-content: start;
161
- padding: 1rem 0 0 0;
162
- margin: 0 0 2rem 0;
163
- list-style: none;
164
- }
165
-
166
- li input {
167
- display: none;
168
- }
169
-
170
- li label {
171
- display: block;
172
- min-width: 50px;
173
- padding-top: .4rem;
174
- text-align: center;
175
- border: 1px solid transparent;
176
- border-radius: 4px;
177
- cursor: pointer;
178
- }
179
-
180
- li input:checked + label {
181
- border-color: var(--primaryTextColor);
182
- }
183
-
184
- input[type="submit"] {
185
- background: var(--primaryCTAFill);
186
- border-color: var(--primaryCTABorder);
187
- }
188
-
189
- button {
190
- background: var(--primaryErrorCTAFill);
191
- border-color: var(--primaryErrorCTABorder);
192
- }
193
-
194
- .button {
195
- -webkit-appearance: none;
196
- appearance: none;
197
- padding: .5rem 1rem;
198
- box-sizing: border-box;
199
- color: var(--primaryTextColor);
200
- border: none;
201
- border-radius: 4px;
202
- cursor: pointer;
203
- }
204
-
205
- .actions {
206
- display: grid;
207
- grid-template-columns: auto auto;
208
- grid-gap: 0 1rem;
209
- justify-items: stretch;
210
- }
211
- `;
212
- return [buttonCSS, bookmarkColorsCSS, bookmarkEditCSS];
213
- }
214
- }
215
- customElements.define('ia-bookmark-edit', IABookmarkEdit);
@@ -1,285 +0,0 @@
1
- import { nothing } from 'lit-html';
2
- import { repeat } from 'lit-html/directives/repeat.js';
3
- import { css, html, LitElement } from 'lit-element';
4
- import './bookmark-edit.js';
5
- import '@internetarchive/icon-edit-pencil/icon-edit-pencil.js';
6
- import bookmarkColorsCSS from '../assets/bookmark-colors.js';
7
-
8
- export class IABookmarksList extends LitElement {
9
- static get properties() {
10
- return {
11
- activeBookmarkID: { type: Number },
12
- bookmarkColors: { type: Array },
13
- defaultBookmarkColor: { type: Object },
14
- bookmarks: { type: Object },
15
- editedBookmark: { type: Object },
16
- renderHeader: { type: Boolean },
17
- };
18
- }
19
-
20
- constructor() {
21
- super();
22
- this.activeBookmarkID = undefined;
23
- this.bookmarkColors = [];
24
- this.defaultBookmarkColor = {};
25
- this.bookmarks = {};
26
- this.editedBookmark = {};
27
- this.renderHeader = false;
28
- }
29
-
30
- emitEditEvent(e, bookmark) {
31
- this.dispatchEvent(new CustomEvent('bookmarkEdited', {
32
- detail: {
33
- bookmark,
34
- },
35
- }));
36
- }
37
-
38
- emitSelectedEvent(bookmark) {
39
- this.activeBookmarkID = bookmark.id;
40
- this.dispatchEvent(new CustomEvent('bookmarkSelected', {
41
- detail: {
42
- bookmark,
43
- },
44
- }));
45
- }
46
-
47
- emitSaveBookmark(bookmark) {
48
- this.dispatchEvent(new CustomEvent('saveBookmark', {
49
- detail: {
50
- bookmark,
51
- },
52
- }));
53
- }
54
-
55
- emitDeleteBookmark(id) {
56
- this.dispatchEvent(new CustomEvent('deleteBookmark', {
57
- detail: {
58
- id,
59
- },
60
- }));
61
- }
62
-
63
- emitBookmarkColorChanged({ detail }) {
64
- const { bookmarkId, colorId } = detail;
65
- this.dispatchEvent(new CustomEvent('bookmarkColorChanged', {
66
- detail: {
67
- bookmarkId,
68
- colorId,
69
- },
70
- }));
71
- }
72
-
73
- emitAddBookmark() {
74
- this.dispatchEvent(new CustomEvent('addBookmark'));
75
- }
76
-
77
- editBookmark(e, bookmark) {
78
- this.emitEditEvent(e, bookmark);
79
- this.editedBookmark = this.editedBookmark === bookmark ? {} : bookmark;
80
- }
81
-
82
- saveBookmark({ detail }) {
83
- const { bookmark } = detail;
84
- this.editedBookmark = {};
85
- this.emitSaveBookmark(bookmark);
86
- }
87
-
88
- deleteBookmark({ detail }) {
89
- const { id } = detail;
90
- this.editedBookmark = {};
91
- this.emitDeleteBookmark(id);
92
- }
93
-
94
- bookmarkColorInfo(colorVal = 0) {
95
- return this.bookmarkColors.find(labelInfo => labelInfo?.id === colorVal);
96
- }
97
-
98
- bookmarkItem(bookmark) {
99
- const editMode = this.editedBookmark.id === bookmark.id;
100
- const { className } = this.bookmarkColorInfo(bookmark.color);
101
- const activeClass = bookmark.id === this.activeBookmarkID ? 'active' : '';
102
- return html`
103
- <li
104
- @click=${() => this.emitSelectedEvent(bookmark)}
105
- tabindex="0"
106
- data-pageIndex=${bookmark.id}
107
- >
108
- <div class="separator"></div>
109
- <div class="content ${activeClass}">
110
- <button
111
- class="edit"
112
- @click=${e => this.editBookmark(e, bookmark)}
113
- title="Edit this bookmark"
114
- >
115
- <ia-icon-edit-pencil></ia-icon-edit-pencil>
116
- </button>
117
- <h4>
118
- <icon-bookmark class=${className}></icon-bookmark>
119
- <span> Page ${bookmark.page}</span>
120
- </h4>
121
- ${!editMode && bookmark.note ? html`<p>${bookmark.note}</p>` : nothing}
122
- ${editMode ? this.editBookmarkComponent : nothing}
123
- </div>
124
- </li>
125
- `;
126
- }
127
-
128
- get editBookmarkComponent() {
129
- const showBookmark = false;
130
- return html`
131
- <ia-bookmark-edit
132
- .bookmark=${this.editedBookmark}
133
- .bookmarkColors=${this.bookmarkColors}
134
- .defaultBookmarkColor=${this.defaultBookmarkColor}
135
- .showBookmark=${showBookmark}
136
- @saveBookmark=${this.saveBookmark}
137
- @deleteBookmark=${this.deleteBookmark}
138
- @bookmarkColorChanged=${this.emitBookmarkColorChanged}
139
- ></ia-bookmark-edit>
140
- `;
141
- }
142
-
143
- sortBookmarks() {
144
- const sortedKeys = Object.keys(this.bookmarks).sort((a, b) => {
145
- if (+a > +b) { return 1; }
146
- if (+a < +b) { return -1; }
147
- return 0;
148
- });
149
- const sortedBookmarks = sortedKeys.map(key => this.bookmarks[key]);
150
- return sortedBookmarks;
151
- }
152
-
153
- get bookmarksCount() {
154
- const count = this.bookmarks.length;
155
- return html`<small>(${count})</small>`;
156
- }
157
-
158
- get headerSection() {
159
- return html`<header>
160
- <h3>
161
- Bookmarks
162
- ${this.bookmarks.length ? this.bookmarksCount : nothing}
163
- </h3>
164
- </header>`;
165
- }
166
-
167
- get bookmarkslist() {
168
- const sortedBookmarks = this.sortBookmarks();
169
- const bookmarks = repeat(sortedBookmarks, bookmark => bookmark?.id, this.bookmarkItem.bind(this));
170
- return html`
171
- <ul>
172
- ${bookmarks}
173
- <div class="separator"></div>
174
- </ul>
175
- `;
176
- }
177
-
178
- render() {
179
- return html`
180
- ${this.renderHeader ? this.headerSection : nothing}
181
- ${Object.keys(this.bookmarks).length ? this.bookmarkslist : nothing}
182
- `;
183
- }
184
-
185
- static get styles() {
186
- const main = css`
187
- :host {
188
- display: block;
189
- overflow-y: auto;
190
- box-sizing: border-box;
191
- color: var(--primaryTextColor);
192
- margin-bottom: 2rem;
193
- --activeBorderWidth: 2px;
194
- }
195
-
196
- icon-bookmark {
197
- width: 16px;
198
- height: 24px;
199
- }
200
-
201
- .separator {
202
- background-color: var(--secondaryBGColor);
203
- width: 98%;
204
- margin: 1px auto;
205
- height: 1px;
206
- }
207
-
208
- small {
209
- font-style: italic;
210
- }
211
-
212
- h4 {
213
- margin: 0;
214
- font-size: 1.4rem;
215
- }
216
- h4 * {
217
- display: inline-block;
218
- }
219
- h4 icon-bookmark {
220
- vertical-align: bottom;
221
- }
222
- h4 span {
223
- vertical-align: top;
224
- padding-top: 1%;
225
- }
226
-
227
- p {
228
- padding: 0;
229
- margin: 5px 0 0 0;
230
- width: 98%;
231
- overflow-wrap: break-word;
232
- }
233
-
234
- ia-bookmark-edit {
235
- margin: 5px 5px 3px 6px;
236
- }
237
-
238
- ul {
239
- padding: 0;
240
- list-style: none;
241
- margin: var(--activeBorderWidth) 0.5rem 1rem 0;
242
- }
243
- ul > li:first-child .separator {
244
- display: none;
245
- }
246
- li {
247
- cursor: pointer;
248
- outline: none;
249
- position: relative;
250
- }
251
- li .content {
252
- padding: 2px 0 4px 2px;
253
- border: var(--activeBorderWidth) solid transparent;
254
- padding: .2rem 0 .4rem .2rem;
255
- }
256
- li .content.active {
257
- border: var(--activeBorderWidth) solid #538bc5;
258
- }
259
- li button.edit {
260
- padding: 5px 2px 0 0;
261
- background: transparent;
262
- cursor: pointer;
263
- height: 40px;
264
- width: 40px;
265
- position: absolute;
266
- right: 2px;
267
- top: 2px;
268
- text-align: right;
269
- -webkit-appearance: none;
270
- appearance: none;
271
- outline: none;
272
- box-sizing: border-box;
273
- border: none;
274
- }
275
- li button.edit > * {
276
- display: block;
277
- height: 100%;
278
- width: 100%;
279
- }
280
- `;
281
-
282
- return [main, bookmarkColorsCSS];
283
- }
284
- }
285
- customElements.define('ia-bookmarks-list', IABookmarksList);
@@ -1,28 +0,0 @@
1
- import { LitElement, html } from 'lit-element';
2
- import buttonStyles from '../assets/button-base.js';
3
-
4
- class BookmarksLogin extends LitElement {
5
- static get properties() {
6
- return {
7
- url: { type: String }
8
- };
9
- }
10
-
11
- static get styles() {
12
- return buttonStyles;
13
- }
14
-
15
- constructor() {
16
- super();
17
- this.url = 'https://archive.org/account/login';
18
- }
19
- render() {
20
-
21
- return html`
22
- <p>A free account is required to save and access bookmarks.</p>
23
- <a class="ia-button link primary" href="${this.url}">Log in</a>
24
- `;
25
- }
26
- }
27
-
28
- customElements.define('bookmarks-login', BookmarksLogin);
@@ -1,56 +0,0 @@
1
- import { html } from 'lit-element';
2
- import '../delete-modal-actions.js';
3
- import './bookmark-button.js';
4
- import './ia-bookmarks.js';
5
-
6
- import './bookmark-edit.js';
7
- import './bookmarks-list.js';
8
- import { IAIconBookmark } from '@internetarchive/icon-bookmark';
9
-
10
- customElements.define('icon-bookmark', IAIconBookmark);
11
-
12
- export default class BookmarksProvider {
13
- constructor(options) {
14
- console.log("BookmarksProvider", {...options});
15
- const { bookreader, modal } = options;
16
- this.modal = options.modal;
17
- const boundOptions = Object.assign(this, options, {loginClicked: this.bookmarksLoginClicked});
18
- this.component = document.createElement('ia-bookmarks');
19
- this.component.bookreader = bookreader;
20
- this.component.options = boundOptions;
21
- this.component.displayMode = this.component.options.displayMode;
22
- this.component.modal = modal;
23
-
24
- this.bindEvents();
25
-
26
- this.icon = html`<icon-bookmark state="hollow" style="--iconWidth: 16px; --iconHeight: 24px;"></icon-bookmark>`;
27
- this.label = 'Bookmarks';
28
- this.id = 'bookmarks';
29
- this.component.setup();
30
- this.updateMenu(this.component.bookmarks.length);
31
- }
32
-
33
- updateMenu(count) {
34
- this.menuDetails = `(${count})`;
35
- }
36
-
37
- bindEvents() {
38
- this.component.addEventListener('bookmarksChanged', this.bookmarksChanged.bind(this));
39
- }
40
-
41
- bookmarksChanged({ detail }) {
42
- const bookmarksLength = Object.keys(detail.bookmarks).length;
43
- this.updateMenu(bookmarksLength);
44
- this.onBookmarksChanged(detail.bookmarks, detail.showSidePanel);
45
- }
46
-
47
- bookmarksLoginClicked() {
48
- if (window.archive_analytics) {
49
- window.archive_analytics?.send_event_no_sampling(
50
- 'BookReader',
51
- `BookmarksLogin`,
52
- window.location.path,
53
- );
54
- }
55
- }
56
- }