@internetarchive/bookreader 5.0.0-32-shadydom2 → 5.0.0-33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/BookReader.js +2 -32261
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1138 -14867
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/icons/1up.svg +1 -12
- package/BookReader/icons/2up.svg +1 -15
- package/BookReader/icons/advance.svg +3 -26
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -1
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +1 -17
- package/BookReader/icons/fullscreen_exit.svg +1 -17
- package/BookReader/icons/hamburger.svg +1 -15
- package/BookReader/icons/left-arrow.svg +1 -12
- package/BookReader/icons/magnify-minus.svg +1 -16
- package/BookReader/icons/magnify-plus.svg +1 -17
- package/BookReader/icons/magnify.svg +1 -15
- package/BookReader/icons/pause.svg +1 -23
- package/BookReader/icons/play.svg +1 -22
- package/BookReader/icons/playback-speed.svg +1 -34
- package/BookReader/icons/read-aloud.svg +1 -22
- package/BookReader/icons/review.svg +3 -22
- package/BookReader/icons/thumbnails.svg +1 -17
- package/BookReader/icons/voice.svg +1 -1
- package/BookReader/icons/volume-full.svg +1 -22
- package/BookReader/images/BRicons.svg +5 -94
- package/BookReader/images/books_graphic.svg +1 -177
- package/BookReader/images/icon_book.svg +1 -12
- package/BookReader/images/icon_bookmark.svg +1 -12
- package/BookReader/images/icon_gear.svg +1 -14
- package/BookReader/images/icon_hamburger.svg +1 -20
- package/BookReader/images/icon_home.svg +1 -21
- package/BookReader/images/icon_info.svg +1 -11
- package/BookReader/images/icon_one_page.svg +1 -8
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -15
- package/BookReader/images/icon_search_button.svg +1 -8
- package/BookReader/images/icon_share.svg +1 -9
- package/BookReader/images/icon_skip-ahead.svg +1 -6
- package/BookReader/images/icon_skip-back.svg +2 -13
- package/BookReader/images/icon_speaker.svg +1 -18
- package/BookReader/images/icon_speaker_open.svg +1 -10
- package/BookReader/images/icon_thumbnails.svg +1 -12
- package/BookReader/images/icon_toc.svg +1 -5
- package/BookReader/images/icon_two_pages.svg +1 -9
- package/BookReader/images/marker_chap-off.svg +1 -11
- package/BookReader/images/marker_chap-on.svg +1 -11
- package/BookReader/images/marker_srch-on.svg +1 -11
- package/BookReader/jquery-1.10.1.js +2 -108
- package/BookReader/plugins/plugin.archive_analytics.js +1 -170
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -163
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -333
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -72
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -332
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -241
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1261
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -839
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +2 -9115
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -811
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -326
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +2 -411
- package/BookReader/webcomponents-bundle.js.map +1 -1
- package/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/BookNavigator/book-navigator.js +19 -10
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +1 -1
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +5 -3
- package/tests/karma/BookNavigator/book-navigator.test.js +0 -5
- package/tests/karma/BookNavigator/bookmarks/ia-bookmarks.test.js +57 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/bookreader",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-33",
|
|
4
4
|
"description": "The Internet Archive BookReader.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"private": false,
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@internetarchive/ia-activity-indicator": "^0.0.1",
|
|
29
|
-
"@internetarchive/ia-item-navigator": "0.0.5
|
|
29
|
+
"@internetarchive/ia-item-navigator": "0.0.5",
|
|
30
30
|
"@internetarchive/ia-menu-slider": "^1.1.1",
|
|
31
31
|
"@internetarchive/ia-sharing-options": "^0.1.4",
|
|
32
32
|
"@internetarchive/icon-bookmark": "^1.1.3",
|
|
@@ -3,6 +3,7 @@ import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
|
|
3
3
|
// eslint-disable-next-line no-unused-vars
|
|
4
4
|
import { ModalManager } from '@internetarchive/modal-manager';
|
|
5
5
|
import { css, html, LitElement } from 'lit-element';
|
|
6
|
+
import { nothing } from 'lit-html';
|
|
6
7
|
import SearchProvider from './search/search-provider.js';
|
|
7
8
|
import DownloadProvider from './downloads/downloads-provider.js';
|
|
8
9
|
import VisualAdjustmentProvider from './visual-adjustments/visual-adjustments-provider.js';
|
|
@@ -417,6 +418,7 @@ export class BookNavigator extends LitElement {
|
|
|
417
418
|
this.lendingStatus = lendingStatus;
|
|
418
419
|
this.isAdmin = isAdmin;
|
|
419
420
|
this.bookReaderCannotLoad = previewType === 'singlePagePreview';
|
|
421
|
+
this.emitLoadingStatusUpdate(true);
|
|
420
422
|
});
|
|
421
423
|
window.addEventListener('BRJSIA:PostInit', ({ detail }) => {
|
|
422
424
|
const { isRestricted, downloadURLs } = detail;
|
|
@@ -491,20 +493,20 @@ export class BookNavigator extends LitElement {
|
|
|
491
493
|
this.dispatchEvent(event);
|
|
492
494
|
}
|
|
493
495
|
|
|
494
|
-
get
|
|
495
|
-
|
|
496
|
+
get itemImage() {
|
|
497
|
+
const identifier = this.itemMD?.metadata.identifier;
|
|
498
|
+
const url = `https://${this.baseHost}/services/img/${identifier}`;
|
|
499
|
+
return html`<img class="cover-img" src=${url} alt="cover image for ${identifier}">`;
|
|
496
500
|
}
|
|
497
501
|
|
|
498
|
-
get
|
|
499
|
-
|
|
500
|
-
return html`<img class="cover-img" src=${url} alt="cover image for ${this.item.metadata.identifier}">`;
|
|
502
|
+
get placeholder() {
|
|
503
|
+
return html`<div class="placeholder">${this.itemImage}</div>`;
|
|
501
504
|
}
|
|
502
505
|
|
|
503
506
|
render() {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
${
|
|
507
|
-
<slot name="main"></slot>
|
|
507
|
+
return html`<div id="book-navigator__root">
|
|
508
|
+
${this.bookReaderCannotLoad ? this.placeholder : nothing}
|
|
509
|
+
${!this.bookReaderCannotLoad ? html`<slot name="main"></slot>` : nothing}
|
|
508
510
|
</div>
|
|
509
511
|
`;
|
|
510
512
|
}
|
|
@@ -512,13 +514,20 @@ export class BookNavigator extends LitElement {
|
|
|
512
514
|
static get styles() {
|
|
513
515
|
return css`
|
|
514
516
|
:host,
|
|
515
|
-
#book-
|
|
517
|
+
#book-navigator__root,
|
|
516
518
|
slot,
|
|
517
519
|
slot > * {
|
|
518
520
|
display: block;
|
|
519
521
|
height: inherit;
|
|
520
522
|
width: inherit;
|
|
521
523
|
}
|
|
524
|
+
.placeholder {
|
|
525
|
+
display: flex;
|
|
526
|
+
align-items: center;
|
|
527
|
+
justify-content: center;
|
|
528
|
+
flex-direction: column;
|
|
529
|
+
margin: 5%;
|
|
530
|
+
}
|
|
522
531
|
.cover-img {
|
|
523
532
|
max-height: 300px;
|
|
524
533
|
}
|
|
@@ -142,9 +142,8 @@ class IABookmarks extends LitElement {
|
|
|
142
142
|
if (this.displayMode === 'login') {
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
this.updateDisplay();
|
|
146
|
-
this.setBREventListeners();
|
|
147
145
|
this.fetchUserBookmarks();
|
|
146
|
+
this.setBREventListeners();
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
updateDisplay() {
|
|
@@ -154,6 +153,9 @@ class IABookmarks extends LitElement {
|
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
fetchUserBookmarks() {
|
|
156
|
+
if (!this.api.identifier) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
157
159
|
this.fetchBookmarks()
|
|
158
160
|
.then(() => {
|
|
159
161
|
this.initializeBookmarks();
|
|
@@ -228,7 +230,7 @@ class IABookmarks extends LitElement {
|
|
|
228
230
|
}
|
|
229
231
|
|
|
230
232
|
fetchBookmarks() {
|
|
231
|
-
return this.api.getAll().then((res) => {
|
|
233
|
+
return this.api.getAll().then(res => res.text()).then((res) => {
|
|
232
234
|
let response;
|
|
233
235
|
try {
|
|
234
236
|
response = JSON.parse(res);
|
|
@@ -111,11 +111,6 @@ describe('<book-navigator>', () => {
|
|
|
111
111
|
|
|
112
112
|
it('creates an item image from metadata', async () => {
|
|
113
113
|
const el = fixtureSync(container());
|
|
114
|
-
el.item = {
|
|
115
|
-
metadata: { identifier: 'foo' },
|
|
116
|
-
};
|
|
117
|
-
await elementUpdated(el);
|
|
118
|
-
|
|
119
114
|
const itemImage = fixtureSync(el.itemImage);
|
|
120
115
|
expect(itemImage).to.be.instanceOf(HTMLImageElement);
|
|
121
116
|
expect(itemImage.getAttribute('class')).to.equal('cover-img');
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
html,
|
|
3
|
+
fixtureSync,
|
|
4
|
+
expect,
|
|
5
|
+
fixtureCleanup,
|
|
6
|
+
} from '@open-wc/testing';
|
|
7
|
+
import '../../../../src/BookNavigator/bookmarks/ia-bookmarks.js';
|
|
8
|
+
import sinon from 'sinon';
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
sinon.restore();
|
|
12
|
+
fixtureCleanup();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('<ia-bookmarks>', () => {
|
|
16
|
+
it('uses `setup` to start component', async () => {
|
|
17
|
+
const el = fixtureSync(html`<ia-bookmarks></ia-bookmarks>`);
|
|
18
|
+
await el.updateComplete;
|
|
19
|
+
|
|
20
|
+
let fetchHappened = false;
|
|
21
|
+
el.bookreader.bookId = 'foo';
|
|
22
|
+
el.displayMode = 'bookmarks';
|
|
23
|
+
|
|
24
|
+
el.fetchBookmarks = async () => {
|
|
25
|
+
fetchHappened = true;
|
|
26
|
+
return await Promise.resolve();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const fetchSpy = sinon.spy(el, 'fetchUserBookmarks');
|
|
30
|
+
|
|
31
|
+
el.setup();
|
|
32
|
+
await el.updateComplete;
|
|
33
|
+
|
|
34
|
+
expect(fetchSpy.callCount).to.equal(1);
|
|
35
|
+
expect(fetchHappened).to.equal(true);
|
|
36
|
+
});
|
|
37
|
+
it('does not fetch user bookmarks if displayMode = login', async () => {
|
|
38
|
+
const el = fixtureSync(html`<ia-bookmarks></ia-bookmarks>`);
|
|
39
|
+
await el.updateComplete;
|
|
40
|
+
|
|
41
|
+
let fetchHappened = false;
|
|
42
|
+
el.displayMode = 'login';
|
|
43
|
+
|
|
44
|
+
el.fetchBookmarks = async () => {
|
|
45
|
+
fetchHappened = true;
|
|
46
|
+
return await Promise.resolve();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const fetchSpy = sinon.spy(el, 'fetchUserBookmarks');
|
|
50
|
+
|
|
51
|
+
el.setup();
|
|
52
|
+
await el.updateComplete;
|
|
53
|
+
|
|
54
|
+
expect(fetchSpy.callCount).to.equal(0);
|
|
55
|
+
expect(fetchHappened).to.equal(false);
|
|
56
|
+
});
|
|
57
|
+
});
|