@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.
- package/.eslintrc.js +17 -15
- package/.github/workflows/node.js.yml +72 -10
- package/.github/workflows/npm-publish.yml +6 -20
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +241 -140
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.LICENSE.txt +24 -20
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1519 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +17 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/icons/pause.svg +1 -1
- package/BookReader/icons/playback-speed.svg +1 -1
- package/BookReader/icons/read-aloud.svg +1 -1
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/images/BRicons.svg +2 -2
- package/BookReader/images/books_graphic.svg +1 -1
- package/BookReader/images/icon_book.svg +1 -1
- package/BookReader/images/icon_gear.svg +1 -1
- package/BookReader/images/icon_info.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -1
- package/BookReader/images/icon_search_button.svg +1 -1
- package/BookReader/images/icon_share.svg +1 -1
- package/BookReader/images/icon_speaker.svg +1 -1
- package/BookReader/images/icon_speaker_open.svg +1 -1
- package/BookReader/images/marker_chap-off.svg +1 -1
- package/BookReader/images/marker_chap-on.svg +1 -1
- package/BookReader/images/marker_srch-on.svg +1 -1
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +14 -1
- package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
- package/BookReaderDemo/BookReaderJSSimple.js +1 -0
- package/BookReaderDemo/IADemoBr.js +147 -0
- package/BookReaderDemo/demo-advanced.html +2 -2
- package/BookReaderDemo/demo-autoplay.html +2 -1
- package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
- package/BookReaderDemo/demo-fullscreen-mobile.html +2 -1
- package/BookReaderDemo/demo-fullscreen.html +2 -1
- package/BookReaderDemo/demo-iiif.html +2 -1
- package/BookReaderDemo/demo-internetarchive.html +84 -17
- package/BookReaderDemo/demo-multiple.html +2 -1
- package/BookReaderDemo/demo-preview-pages.html +2 -1
- package/BookReaderDemo/demo-simple.html +2 -1
- package/BookReaderDemo/demo-vendor-fullscreen.html +2 -1
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
- package/BookReaderDemo/immersion-1up.html +2 -1
- package/BookReaderDemo/immersion-mode.html +2 -1
- package/BookReaderDemo/toggle_controls.html +2 -1
- package/BookReaderDemo/view_mode.html +2 -1
- package/BookReaderDemo/viewmode-cycle.html +2 -3
- package/CHANGELOG.md +244 -0
- package/README.md +14 -1
- package/babel.config.js +19 -0
- package/codecov.yml +6 -0
- package/index.html +3 -0
- package/jsconfig.json +19 -0
- package/netlify.toml +5 -0
- package/package.json +70 -59
- package/renovate.json +52 -0
- package/scripts/preversion.js +4 -1
- package/src/BookNavigator/assets/bookmark-colors.js +1 -1
- package/src/BookNavigator/assets/button-base.js +9 -2
- package/src/BookNavigator/assets/ia-logo.js +17 -0
- package/src/BookNavigator/assets/icon_checkmark.js +1 -1
- package/src/BookNavigator/assets/icon_close.js +1 -1
- package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
- package/src/BookNavigator/assets/icon_volumes.js +11 -0
- package/src/BookNavigator/book-navigator.js +585 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
- package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
- package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
- package/src/BookNavigator/delete-modal-actions.js +1 -1
- package/src/BookNavigator/downloads/downloads-provider.js +36 -21
- package/src/BookNavigator/downloads/downloads.js +41 -25
- package/src/BookNavigator/search/search-provider.js +80 -28
- package/src/BookNavigator/search/search-results.js +34 -25
- package/src/BookNavigator/sharing.js +27 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
- package/src/BookNavigator/volumes/volumes-provider.js +111 -0
- package/src/BookNavigator/volumes/volumes.js +188 -0
- package/src/BookReader/BookModel.js +59 -30
- package/src/BookReader/DebugConsole.js +3 -3
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +56 -351
- package/src/BookReader/Mode1UpLit.js +391 -0
- package/src/BookReader/Mode2Up.js +73 -1318
- package/src/BookReader/Mode2UpLit.js +781 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +211 -0
- package/src/BookReader/ModeThumb.js +17 -11
- package/src/BookReader/Navbar/Navbar.js +10 -36
- package/src/BookReader/PageContainer.js +69 -6
- package/src/BookReader/ReduceSet.js +1 -1
- package/src/BookReader/Toolbar/Toolbar.js +10 -37
- package/src/BookReader/events.js +2 -0
- package/src/BookReader/options.js +24 -2
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils.js +108 -13
- package/src/BookReader.js +481 -828
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/assets/icons/voice.svg +1 -0
- package/src/css/_BRBookmarks.scss +1 -1
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +33 -0
- package/src/css/_BRnav.scss +4 -26
- package/src/css/_BRpages.scss +147 -40
- package/src/css/_BRsearch.scss +25 -11
- package/src/css/_TextSelection.scss +16 -17
- package/src/css/_colorbox.scss +2 -2
- package/src/css/_controls.scss +17 -5
- package/src/css/_icons.scss +7 -1
- package/src/ia-bookreader/ia-bookreader.js +224 -0
- package/src/plugins/plugin.archive_analytics.js +3 -3
- package/src/plugins/plugin.autoplay.js +4 -9
- package/src/plugins/plugin.chapters.js +28 -35
- package/src/plugins/plugin.mobile_nav.js +11 -10
- package/src/plugins/plugin.resume.js +3 -3
- package/src/plugins/plugin.text_selection.js +32 -41
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +179 -103
- package/src/plugins/search/view.js +59 -44
- package/src/plugins/tts/AbstractTTSEngine.js +46 -37
- package/src/plugins/tts/FestivalTTSEngine.js +13 -14
- package/src/plugins/tts/PageChunk.js +15 -21
- package/src/plugins/tts/PageChunkIterator.js +8 -12
- package/src/plugins/tts/WebTTSEngine.js +87 -71
- package/src/plugins/tts/plugin.tts.js +94 -125
- package/src/plugins/tts/utils.js +0 -25
- package/src/plugins/url/UrlPlugin.js +193 -0
- package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
- package/src/util/docCookies.js +21 -2
- package/tests/e2e/README.md +37 -0
- package/tests/e2e/autoplay.test.js +2 -2
- package/tests/e2e/base.test.js +7 -7
- package/tests/e2e/helpers/base.js +28 -23
- package/tests/e2e/helpers/debug.js +1 -1
- package/tests/e2e/helpers/desktopSearch.js +14 -13
- package/tests/e2e/helpers/mobileSearch.js +3 -3
- package/tests/e2e/helpers/params.js +17 -0
- package/tests/e2e/helpers/rightToLeft.js +4 -10
- package/tests/e2e/models/Navigation.js +13 -4
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +40 -33
- package/tests/jest/BookNavigator/book-navigator.test.js +658 -0
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
- package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
- package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
- package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +104 -60
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +184 -0
- package/tests/jest/BookNavigator/volumes/volumes.test.js +97 -0
- package/tests/{BookReader → jest/BookReader}/BookModel.test.js +59 -14
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
- package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
- package/tests/jest/BookReader/Mode2Up.test.js +98 -0
- package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
- package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +175 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
- package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
- package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
- package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
- package/tests/jest/BookReader/utils.test.js +217 -0
- package/tests/jest/BookReader.keyboard.test.js +190 -0
- package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
- package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
- package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
- package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +10 -11
- package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
- package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
- package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +39 -47
- package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
- package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +57 -47
- package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +35 -6
- package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +9 -9
- package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
- package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
- package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
- package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
- package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
- package/tests/jest/setup.js +3 -0
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/jest/util/docCookies.test.js +24 -0
- package/tests/{util → jest/util}/strings.test.js +1 -1
- package/tests/{utils.js → jest/utils.js} +38 -0
- package/webpack.config.js +11 -5
- package/.babelrc +0 -12
- package/.dependabot/config.yml +0 -6
- package/.testcaferc.json +0 -5
- package/BookReader/bookreader-component-bundle.js +0 -1450
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/jquery-1.10.1.js +0 -2
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -2
- package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
- package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
- package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
- package/karma.conf.js +0 -23
- package/src/BookNavigator/BookModel.js +0 -14
- package/src/BookNavigator/BookNavigator.js +0 -438
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
- package/src/BookNavigator/search/a-search-result.js +0 -55
- package/src/BookReaderComponent/BookReaderComponent.js +0 -112
- package/src/ItemNavigator/ItemNavigator.js +0 -372
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/dragscrollable-br.js +0 -261
- package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
- package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
- package/tests/BookReader/Mode1Up.test.js +0 -164
- package/tests/BookReader/Mode2Up.test.js +0 -247
- package/tests/BookReader/utils.test.js +0 -109
- package/tests/e2e/ia-production/ia-prod-base.js +0 -17
- package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
- package/tests/util/docCookies.test.js +0 -15
@@ -1,112 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* BookReaderTemplate to load BookNavigator components
|
3
|
-
*/
|
4
|
-
|
5
|
-
import { LitElement, html, css } from 'lit-element';
|
6
|
-
|
7
|
-
import '../ItemNavigator/ItemNavigator.js'
|
8
|
-
import '../BookNavigator/BookNavigator.js'
|
9
|
-
|
10
|
-
export class BookReader extends LitElement {
|
11
|
-
static get properties() {
|
12
|
-
return {
|
13
|
-
base64Json: { type: String },
|
14
|
-
baseHost: { type: String },
|
15
|
-
};
|
16
|
-
}
|
17
|
-
|
18
|
-
constructor() {
|
19
|
-
super();
|
20
|
-
this.base64Json = '';
|
21
|
-
this.baseHost = 'https://archive.org';
|
22
|
-
}
|
23
|
-
|
24
|
-
firstUpdated() {
|
25
|
-
this.fetchData();
|
26
|
-
}
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Fetch metadata response from public metadata API
|
30
|
-
* convert response to base64 data
|
31
|
-
* set base64 data to props
|
32
|
-
*/
|
33
|
-
async fetchData() {
|
34
|
-
const ocaid = new URLSearchParams(location.search).get('ocaid');
|
35
|
-
const response = await fetch(`${this.baseHost}/metadata/${ocaid}`);
|
36
|
-
const bookMetadata = await response.json();
|
37
|
-
const jsonBtoa = btoa(JSON.stringify(bookMetadata));
|
38
|
-
this.setBaseJSON(jsonBtoa);
|
39
|
-
}
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Set base64 data to prop
|
43
|
-
* @param {string} value - base64 string format
|
44
|
-
*/
|
45
|
-
setBaseJSON(value) {
|
46
|
-
this.base64Json = value;
|
47
|
-
}
|
48
|
-
|
49
|
-
render() {
|
50
|
-
return html`
|
51
|
-
<div class="ia-bookreader">
|
52
|
-
<item-navigator
|
53
|
-
itemType="bookreader"
|
54
|
-
basehost=${this.baseHost}
|
55
|
-
item=${this.base64Json}>
|
56
|
-
<div slot="bookreader">
|
57
|
-
<slot name="bookreader"></slot>
|
58
|
-
</div>
|
59
|
-
</item-navigator>
|
60
|
-
</div>
|
61
|
-
`;
|
62
|
-
}
|
63
|
-
|
64
|
-
static get styles() {
|
65
|
-
return css`
|
66
|
-
:host {
|
67
|
-
display: block;
|
68
|
-
--primaryBGColor: var(--black, #000);
|
69
|
-
--secondaryBGColor: #222;
|
70
|
-
--tertiaryBGColor: #333;
|
71
|
-
--primaryTextColor: var(--white, #fff);
|
72
|
-
--primaryCTAFill: #194880;
|
73
|
-
--primaryCTABorder: #c5d1df;
|
74
|
-
--secondaryCTAFill: #333;
|
75
|
-
--secondaryCTABorder: #999;
|
76
|
-
--primaryErrorCTAFill: #e51c26;
|
77
|
-
--primaryErrorCTABorder: #f8c6c8;
|
78
|
-
}
|
79
|
-
|
80
|
-
.ia-bookreader {
|
81
|
-
background-color: var(--primaryBGColor);
|
82
|
-
position: relative;
|
83
|
-
height: auto;
|
84
|
-
}
|
85
|
-
|
86
|
-
item-navigator {
|
87
|
-
display: block;
|
88
|
-
width: 100%;
|
89
|
-
color: var(--primaryTextColor);
|
90
|
-
--menuButtonLabelDisplay: block;
|
91
|
-
--menuWidth: 320px;
|
92
|
-
--menuSliderBg: var(--secondaryBGColor);
|
93
|
-
--activeButtonBg: var(--tertiaryBGColor);
|
94
|
-
--subpanelRightBorderColor: var(--secondaryCTABorder);
|
95
|
-
--animationTiming: 100ms;
|
96
|
-
--iconFillColor: var(--primaryTextColor);
|
97
|
-
--iconStrokeColor: var(--primaryTextColor);
|
98
|
-
--menuSliderHeaderIconHeight: 2rem;
|
99
|
-
--menuSliderHeaderIconWidth: 2rem;
|
100
|
-
--iconWidth: 2.4rem;
|
101
|
-
--iconHeight: 2.4rem;
|
102
|
-
--shareLinkColor: var(--primaryTextColor);
|
103
|
-
--shareIconBorder: var(--primaryTextColor);
|
104
|
-
--shareIconBg: var(--secondaryBGColor);
|
105
|
-
--activityIndicatorLoadingDotColor: var(--primaryTextColor);
|
106
|
-
--activityIndicatorLoadingRingColor: var(--primaryTextColor);
|
107
|
-
}
|
108
|
-
`;
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
window.customElements.define("ia-bookreader", BookReader);
|
@@ -1,372 +0,0 @@
|
|
1
|
-
import { css, html, LitElement } from "lit-element";
|
2
|
-
import { nothing } from "lit-html";
|
3
|
-
import { IAMenuSlider } from "@internetarchive/ia-menu-slider";
|
4
|
-
import IAIcon from "@internetarchive/ia-icons";
|
5
|
-
import { ModalConfig } from "@internetarchive/modal-manager";
|
6
|
-
|
7
|
-
export default class ItemNavigator extends LitElement {
|
8
|
-
static get properties() {
|
9
|
-
return {
|
10
|
-
baseHost: { type: String },
|
11
|
-
item: {
|
12
|
-
type: Object,
|
13
|
-
converter(value) {
|
14
|
-
return !value ? {} : JSON.parse(atob(value));
|
15
|
-
},
|
16
|
-
},
|
17
|
-
itemType: { type: String },
|
18
|
-
menuShortcuts: {
|
19
|
-
type: Array,
|
20
|
-
hasChanged(newVal, oldVal) {
|
21
|
-
if (newVal !== oldVal) {
|
22
|
-
return true;
|
23
|
-
}
|
24
|
-
return false;
|
25
|
-
},
|
26
|
-
},
|
27
|
-
menuOpened: { type: Boolean },
|
28
|
-
menuContents: { type: Array },
|
29
|
-
openMenu: { type: String },
|
30
|
-
signedIn: {
|
31
|
-
type: Boolean,
|
32
|
-
converter: (arg) => {
|
33
|
-
if (typeof (arg) === 'boolean') {
|
34
|
-
return arg;
|
35
|
-
}
|
36
|
-
return arg === 'true';
|
37
|
-
},
|
38
|
-
},
|
39
|
-
viewportInFullscreen: { type: Boolean },
|
40
|
-
};
|
41
|
-
}
|
42
|
-
|
43
|
-
constructor() {
|
44
|
-
/** TODO: Request BookModel.js
|
45
|
-
* Request BookNavigator.js
|
46
|
-
* Show loading spinner
|
47
|
-
* When JS assets loaded:
|
48
|
-
* - render book-navigator component
|
49
|
-
*/
|
50
|
-
super();
|
51
|
-
this.baseHost = 'archive.org';
|
52
|
-
this.item = {};
|
53
|
-
this.itemType = '';
|
54
|
-
this.menuOpened = false;
|
55
|
-
this.signedIn = false;
|
56
|
-
this.menuShortcuts = [];
|
57
|
-
this.menuContents = [];
|
58
|
-
this.viewportInFullscreen = false;
|
59
|
-
this.openMenu = '';
|
60
|
-
this.renderModalManager();
|
61
|
-
}
|
62
|
-
|
63
|
-
showItemNavigatorModal({ detail }) {
|
64
|
-
this.modal.showModal({
|
65
|
-
config: this.modalConfig,
|
66
|
-
customModalContent: detail.customModalContent,
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
closeItemNavigatorModal() {
|
71
|
-
this.modal.closeModal();
|
72
|
-
}
|
73
|
-
|
74
|
-
/**
|
75
|
-
* Event handler - handles viewport slot going into fullscreen
|
76
|
-
* @param {Event} e - custom event object
|
77
|
-
*/
|
78
|
-
manageViewportFullscreen({ detail }) {
|
79
|
-
const { isFullScreen } = detail;
|
80
|
-
this.viewportInFullscreen = isFullScreen;
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Event handler - handles viewport slot going into fullscreen
|
85
|
-
* @param {Event} e - custom event object
|
86
|
-
* @param {object} event.detail - custom event detail
|
87
|
-
* @param {string} detail.action - open, toggle, close
|
88
|
-
* @param {string} detail.menuId - menu id to be shown
|
89
|
-
*/
|
90
|
-
manageSideMenuEvents({ detail }) {
|
91
|
-
const { action = '', menuId = '' } = detail;
|
92
|
-
if (menuId) {
|
93
|
-
if (action === 'open') {
|
94
|
-
this.openShortcut(menuId);
|
95
|
-
} else if (action === 'toggle') {
|
96
|
-
this.openMenu = menuId;
|
97
|
-
this.toggleMenu();
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
toggleMenu() {
|
103
|
-
this.menuOpened = !this.menuOpened;
|
104
|
-
}
|
105
|
-
|
106
|
-
closeMenu() {
|
107
|
-
this.menuOpened = false;
|
108
|
-
}
|
109
|
-
|
110
|
-
/**
|
111
|
-
* Opens menu to selected menu
|
112
|
-
* @param {string} selectedMenuId
|
113
|
-
*/
|
114
|
-
openShortcut(selectedMenuId = '') {
|
115
|
-
// open sidemenu to proper tab
|
116
|
-
this.openMenu = selectedMenuId;
|
117
|
-
this.menuOpened = true;
|
118
|
-
}
|
119
|
-
|
120
|
-
setOpenMenu({ detail }) {
|
121
|
-
const { id } = detail;
|
122
|
-
this.openMenu = id === this.openMenu ? '' : id;
|
123
|
-
}
|
124
|
-
|
125
|
-
setMenuContents({ detail }) {
|
126
|
-
this.menuContents = [...detail];
|
127
|
-
}
|
128
|
-
|
129
|
-
setMenuShortcuts({ detail }) {
|
130
|
-
this.menuShortcuts = [...detail];
|
131
|
-
}
|
132
|
-
|
133
|
-
/**
|
134
|
-
* computes classes for item-navigator <section> node
|
135
|
-
*/
|
136
|
-
get menuClass() {
|
137
|
-
const drawerState = this.menuOpened ? 'open' : '';
|
138
|
-
const fullscreenState = this.viewportInFullscreen ? 'fullscreen' : '';
|
139
|
-
return `${drawerState} ${fullscreenState}`;
|
140
|
-
}
|
141
|
-
|
142
|
-
get menuToggleButton() {
|
143
|
-
return html`
|
144
|
-
<button class="toggle-menu" @click=${this.toggleMenu.bind(this)}>
|
145
|
-
<div>
|
146
|
-
<ia-icon icon="ellipses" style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon>
|
147
|
-
</div>
|
148
|
-
</button>
|
149
|
-
`;
|
150
|
-
}
|
151
|
-
|
152
|
-
get menuSlider() {
|
153
|
-
return html`
|
154
|
-
<div id="menu">
|
155
|
-
<ia-menu-slider
|
156
|
-
.menus=${this.menuContents}
|
157
|
-
.open=${true}
|
158
|
-
.selectedMenu=${this.openMenu}
|
159
|
-
@menuTypeSelected=${this.setOpenMenu}
|
160
|
-
@menuSliderClosed=${this.closeMenu}
|
161
|
-
?manuallyHandleClose=${true}
|
162
|
-
?animateMenuOpen=${false}
|
163
|
-
></ia-menu-slider>
|
164
|
-
</div>
|
165
|
-
`;
|
166
|
-
}
|
167
|
-
|
168
|
-
/**
|
169
|
-
* Returns the shortcut buttons for minimized view
|
170
|
-
* @return html
|
171
|
-
*/
|
172
|
-
get shortcuts() {
|
173
|
-
// todo: aria tags
|
174
|
-
const shortcuts = this.menuShortcuts.map(({
|
175
|
-
icon,
|
176
|
-
id,
|
177
|
-
}) => html`
|
178
|
-
<button class="shortcut ${id}" @click="${(e) => { this.openShortcut(id); }}">
|
179
|
-
${icon}
|
180
|
-
</button>
|
181
|
-
`);
|
182
|
-
|
183
|
-
return html`<div class="shortcuts">${shortcuts}</div>`;
|
184
|
-
}
|
185
|
-
|
186
|
-
/**
|
187
|
-
* Returns the side menu given it's open/close state
|
188
|
-
* @return html
|
189
|
-
*/
|
190
|
-
get renderSideMenu() {
|
191
|
-
// todo: aria tags
|
192
|
-
return html`
|
193
|
-
<nav>
|
194
|
-
<div class="minimized">
|
195
|
-
${this.shortcuts}
|
196
|
-
${this.menuToggleButton}
|
197
|
-
</div>
|
198
|
-
${this.menuSlider}
|
199
|
-
</nav>
|
200
|
-
`;
|
201
|
-
}
|
202
|
-
|
203
|
-
/**
|
204
|
-
* Given a itemType, this chooses the proper viewport component
|
205
|
-
* @return html
|
206
|
-
*/
|
207
|
-
get renderViewport() {
|
208
|
-
if (this.itemType === 'bookreader') {
|
209
|
-
return html`
|
210
|
-
<book-navigator
|
211
|
-
.baseHost=${this.baseHost}
|
212
|
-
.book=${this.item}
|
213
|
-
?signedIn=${this.signedIn}
|
214
|
-
?sideMenuOpen=${this.menuOpened}
|
215
|
-
@ViewportInFullScreen=${this.manageViewportFullscreen}
|
216
|
-
@updateSideMenu=${this.manageSideMenuEvents}
|
217
|
-
@menuUpdated=${this.setMenuContents}
|
218
|
-
@menuShortcutsUpdated=${this.setMenuShortcuts}
|
219
|
-
@showItemNavigatorModal=${this.showItemNavigatorModal}
|
220
|
-
@closeItemNavigatorModal=${this.closeItemNavigatorModal}
|
221
|
-
>
|
222
|
-
<div slot="bookreader">
|
223
|
-
<slot name="bookreader"></slot>
|
224
|
-
</div>
|
225
|
-
</book-navigator>
|
226
|
-
`;
|
227
|
-
}
|
228
|
-
return html`<div class="viewport"></div>`;
|
229
|
-
}
|
230
|
-
|
231
|
-
renderModalManager() {
|
232
|
-
this.modal = document.createElement('modal-manager');
|
233
|
-
this.modal.setAttribute('id', 'item-navigator-modal');
|
234
|
-
this.modalConfig = new ModalConfig();
|
235
|
-
this.modalConfig.title = 'Delete Bookmark';
|
236
|
-
this.modalConfig.headline = 'This bookmark contains a note. Deleting it will permanently delete the note. Are you sure?';
|
237
|
-
this.modalConfig.headerColor = '#194880';
|
238
|
-
document.body.appendChild(this.modal);
|
239
|
-
}
|
240
|
-
|
241
|
-
render() {
|
242
|
-
const renderMenu = this.menuContents.length || this.menuShortcuts.length;
|
243
|
-
return html`
|
244
|
-
<div id="frame" class=${this.menuClass}>
|
245
|
-
<slot name="item-nav-header"></slot>
|
246
|
-
<div class="menu-and-reader">
|
247
|
-
${renderMenu ? this.renderSideMenu : nothing}
|
248
|
-
<div id="reader">
|
249
|
-
${this.renderViewport}
|
250
|
-
</div>
|
251
|
-
</div>
|
252
|
-
</div>
|
253
|
-
`;
|
254
|
-
}
|
255
|
-
|
256
|
-
static get styles() {
|
257
|
-
const subnavWidth = css`var(--menuWidth, 320px)`;
|
258
|
-
const tabletPlusQuery = css`@media (min-width: 640px)`;
|
259
|
-
const transitionTiming = css`var(--animationTiming, 200ms)`;
|
260
|
-
const transitionEffect = css`transform ${transitionTiming} ease-out`;
|
261
|
-
|
262
|
-
return css`
|
263
|
-
#frame {
|
264
|
-
position: relative;
|
265
|
-
overflow: hidden;
|
266
|
-
}
|
267
|
-
|
268
|
-
#frame.fullscreen,
|
269
|
-
#frame.fullscreen #reader {
|
270
|
-
height: 100vh;
|
271
|
-
}
|
272
|
-
|
273
|
-
button {
|
274
|
-
cursor: pointer;
|
275
|
-
padding: 0;
|
276
|
-
border: 0;
|
277
|
-
}
|
278
|
-
|
279
|
-
button:focus,
|
280
|
-
button:active {
|
281
|
-
outline: none;
|
282
|
-
}
|
283
|
-
|
284
|
-
.menu-and-reader {
|
285
|
-
position: relative;
|
286
|
-
}
|
287
|
-
|
288
|
-
nav button {
|
289
|
-
background: none;
|
290
|
-
}
|
291
|
-
|
292
|
-
nav .minimized {
|
293
|
-
background: rgba(0, 0, 0, .7);
|
294
|
-
border-bottom-right-radius: 5%;
|
295
|
-
position: absolute;
|
296
|
-
padding-top: .6rem;
|
297
|
-
left: 0;
|
298
|
-
width: 4rem;
|
299
|
-
z-index: 2;
|
300
|
-
}
|
301
|
-
|
302
|
-
nav .minimized button {
|
303
|
-
width: var(--iconWidth);
|
304
|
-
height: var(--iconHeight);
|
305
|
-
margin: auto;
|
306
|
-
display: inline-flex;
|
307
|
-
vertical-align: middle;
|
308
|
-
-webkit-box-align: center;
|
309
|
-
align-items: center;
|
310
|
-
-webkit-box-pack: center;
|
311
|
-
justify-content: center;
|
312
|
-
width: 4rem;
|
313
|
-
height: 4rem;
|
314
|
-
}
|
315
|
-
|
316
|
-
nav .minimized button.toggle-menu > * {
|
317
|
-
border: 2px solid var(--iconStrokeColor);
|
318
|
-
border-radius: var(--iconWidth);
|
319
|
-
width: var(--iconWidth);
|
320
|
-
height: var(--iconHeight);
|
321
|
-
margin: auto;
|
322
|
-
}
|
323
|
-
|
324
|
-
#menu {
|
325
|
-
position: absolute;
|
326
|
-
top: 0;
|
327
|
-
bottom: 0;
|
328
|
-
left: 0;
|
329
|
-
z-index: 3;
|
330
|
-
overflow: hidden;
|
331
|
-
transform: translateX(-${subnavWidth});
|
332
|
-
width: ${subnavWidth};
|
333
|
-
transform: translateX(calc(${subnavWidth} * -1));
|
334
|
-
transition: ${transitionEffect};
|
335
|
-
}
|
336
|
-
|
337
|
-
#reader {
|
338
|
-
position: relative;
|
339
|
-
z-index: 1;
|
340
|
-
transition: ${transitionEffect};
|
341
|
-
transform: translateX(0);
|
342
|
-
width: 100%;
|
343
|
-
}
|
344
|
-
|
345
|
-
.open #menu {
|
346
|
-
width: ${subnavWidth};
|
347
|
-
transform: translateX(0);
|
348
|
-
transition: ${transitionEffect};
|
349
|
-
}
|
350
|
-
|
351
|
-
${tabletPlusQuery} {
|
352
|
-
.open #reader {
|
353
|
-
transition: ${transitionEffect};
|
354
|
-
transform: translateX(${subnavWidth});
|
355
|
-
width: calc(100% - ${subnavWidth});
|
356
|
-
}
|
357
|
-
}
|
358
|
-
|
359
|
-
#loading-indicator {
|
360
|
-
display: none;
|
361
|
-
}
|
362
|
-
|
363
|
-
#loading-indicator.visible {
|
364
|
-
display: block;
|
365
|
-
}
|
366
|
-
`;
|
367
|
-
}
|
368
|
-
}
|
369
|
-
|
370
|
-
customElements.define('ia-icon', IAIcon);
|
371
|
-
customElements.define('ia-menu-slider', IAMenuSlider);
|
372
|
-
customElements.define('item-navigator', ItemNavigator);
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { html } from 'lit-element';
|
2
|
-
|
3
|
-
/* register subpanel */
|
4
|
-
import { IASharingOptions } from '@internetarchive/ia-sharing-options';
|
5
|
-
customElements.define('ia-sharing-options', IASharingOptions);
|
6
|
-
|
7
|
-
export default class {
|
8
|
-
constructor(metadata = {}, baseHost, baseItemType) {
|
9
|
-
this.itemType = baseItemType;
|
10
|
-
const label = `Share this ${this.reconcileItemType}`;
|
11
|
-
this.icon = html`<ia-icon icon="share" style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon>`;
|
12
|
-
this.label = label;
|
13
|
-
this.id = 'share';
|
14
|
-
this.component = html`<ia-sharing-options
|
15
|
-
identifier="${metadata.identifier}"
|
16
|
-
type="book"
|
17
|
-
creator="${metadata.creator}"
|
18
|
-
description="${metadata.title}"
|
19
|
-
baseHost="${baseHost}"
|
20
|
-
></ia-sharing-options>`;
|
21
|
-
}
|
22
|
-
|
23
|
-
get reconcileItemType() {
|
24
|
-
if (this.itemType === 'bookreader') {
|
25
|
-
return 'book';
|
26
|
-
}
|
27
|
-
return 'item';
|
28
|
-
}
|
29
|
-
}
|