@internetarchive/bookreader 5.0.0-5-multiple-files → 5.0.0-50-a1
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 +77 -6
- package/.github/workflows/npm-publish.yml +6 -20
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +131 -339
- package/BookReader/BookReader.js +2 -21564
- package/BookReader/BookReader.js.LICENSE.txt +24 -0
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1493 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +17 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- 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 -0
- 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 -0
- 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-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +1 -172
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -165
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -304
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -74
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -334
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -368
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1420
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1080
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +2 -9193
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -269
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -379
- 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/IADemoBr.js +148 -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 +202 -0
- package/README.md +14 -1
- package/babel.config.js +18 -0
- package/codecov.yml +6 -0
- package/index.html +3 -0
- package/jsconfig.json +19 -0
- package/package.json +66 -56
- 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_ascending.js → icon_sort_desc.js} +2 -2
- 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 +583 -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 +21 -8
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +102 -66
- 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/a-search-result.js +18 -13
- package/src/BookNavigator/search/search-provider.js +80 -28
- package/src/BookNavigator/search/search-results.js +10 -18
- 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 +93 -63
- package/src/BookNavigator/volumes/volumes.js +40 -46
- package/src/BookReader/BookModel.js +0 -29
- package/src/BookReader/DebugConsole.js +3 -3
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +51 -351
- package/src/BookReader/Mode1UpLit.js +441 -0
- package/src/BookReader/Mode2Up.js +120 -105
- package/src/BookReader/ModeSmoothZoom.js +179 -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/options.js +10 -0
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils.js +92 -13
- package/src/BookReader.js +431 -620
- 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/BookReader.scss +0 -12
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +19 -24
- package/src/css/_BRnav.scss +4 -26
- package/src/css/_BRpages.scss +35 -0
- package/src/css/_BRsearch.scss +25 -216
- package/src/css/_TextSelection.scss +14 -17
- package/src/css/_colorbox.scss +2 -2
- package/src/css/_controls.scss +17 -5
- package/src/css/_icons.scss +6 -0
- package/src/ia-bookreader/ia-bookreader.js +224 -0
- package/src/plugins/plugin.autoplay.js +4 -4
- 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 +26 -39
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +174 -116
- package/src/plugins/search/view.js +63 -179
- 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 +66 -69
- package/src/plugins/tts/plugin.tts.js +92 -109
- package/src/plugins/tts/utils.js +0 -9
- package/src/plugins/url/UrlPlugin.js +184 -0
- package/src/plugins/{plugin.url.js → url/plugin.url.js} +28 -6
- package/src/util/manifestGenerator.js +0 -0
- 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 +9 -3
- 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/models/Navigation.js +13 -4
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +38 -33
- package/tests/jest/BookNavigator/book-navigator.test.js +634 -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 +102 -58
- 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 +34 -14
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +176 -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 +92 -0
- package/tests/{BookReader → jest/BookReader}/Mode2Up.test.js +36 -15
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +149 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +7 -7
- 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 +186 -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} +18 -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 +63 -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 +1 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +3 -28
- package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +33 -14
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/{util → jest/util}/docCookies.test.js +1 -1
- 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 -14275
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/icons/sort-ascending.svg +0 -1
- package/BookReader/icons/sort-descending.svg +0 -1
- package/BookReader/jquery-1.10.1.js +0 -108
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -369
- 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 -448
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/BookNavigator/assets/icon_sort_descending.js +0 -5
- package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
- package/src/BookReaderComponent/BookReaderComponent.js +0 -112
- package/src/ItemNavigator/ItemNavigator.js +0 -373
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/assets/icons/sort-ascending.svg +0 -1
- package/src/assets/icons/sort-descending.svg +0 -1
- 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/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/karma/BookNavigator/volumes.test.js +0 -101
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
@@ -1,6 +1,5 @@
|
|
1
|
-
import { css, html, LitElement } from 'lit
|
2
|
-
import {
|
3
|
-
import { repeat } from 'lit-html/directives/repeat';
|
1
|
+
import { css, html, LitElement, nothing } from 'lit';
|
2
|
+
import { repeat } from 'lit/directives/repeat.js';
|
4
3
|
|
5
4
|
export class Volumes extends LitElement {
|
6
5
|
static get properties() {
|
@@ -8,23 +7,44 @@ export class Volumes extends LitElement {
|
|
8
7
|
subPrefix: { type: String },
|
9
8
|
hostUrl: { type: String },
|
10
9
|
viewableFiles: { type: Array },
|
11
|
-
|
10
|
+
sortOrderBy: { type: String },
|
12
11
|
};
|
13
12
|
}
|
14
13
|
|
15
14
|
constructor() {
|
16
15
|
super();
|
17
|
-
this.viewableFiles = [];
|
18
16
|
this.hostUrl = '';
|
17
|
+
this.sortOrderBy = '';
|
19
18
|
this.subPrefix = '';
|
20
|
-
this.
|
19
|
+
this.viewableFiles = [];
|
20
|
+
}
|
21
|
+
|
22
|
+
firstUpdated() {
|
23
|
+
const activeFile = this.shadowRoot.querySelector('.content.active');
|
24
|
+
// allow for css animations to run before scrolling to active file
|
25
|
+
setTimeout(() => {
|
26
|
+
// scroll active file into view if needed
|
27
|
+
// note: `scrollIntoViewIfNeeded` handles auto-scroll gracefully for Chrome, Safari
|
28
|
+
// Firefox does not have this capability yet as it does not support `scrollIntoViewIfNeeded`
|
29
|
+
if (activeFile?.scrollIntoViewIfNeeded) {
|
30
|
+
activeFile?.scrollIntoViewIfNeeded(true);
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
|
34
|
+
// Todo: support `scrollIntoView` or `parentContainer.crollTop = x` for FF & "IE 11"
|
35
|
+
// currently, the hard `position: absolutes` misaligns subpanel when `scrollIntoView` is applied :(
|
36
|
+
}, 350);
|
21
37
|
}
|
22
38
|
|
23
39
|
volumeItemWithImageTitle(item) {
|
40
|
+
const hrefUrl = this.sortOrderBy === 'default'
|
41
|
+
? `${this.hostUrl}${item.url_path}`
|
42
|
+
: `${this.hostUrl}${item.url_path}?sort=${this.sortOrderBy}`;
|
43
|
+
|
24
44
|
return html`
|
25
45
|
<li class="content active">
|
26
46
|
<div class="separator"></div>
|
27
|
-
<a class="container" href="${
|
47
|
+
<a class="container" href="${hrefUrl}">
|
28
48
|
<div class="image">
|
29
49
|
<img src="${item.image}">
|
30
50
|
</div>
|
@@ -34,51 +54,26 @@ export class Volumes extends LitElement {
|
|
34
54
|
</div>
|
35
55
|
</a>
|
36
56
|
</li>
|
37
|
-
|
57
|
+
`;
|
38
58
|
}
|
39
59
|
|
40
60
|
volumeItem(item) {
|
41
|
-
const activeClass = this.subPrefix === item.file_subprefix ? 'active' : ''
|
61
|
+
const activeClass = this.subPrefix === item.file_subprefix ? ' active' : '';
|
62
|
+
|
63
|
+
const hrefUrl = this.sortOrderBy === 'default'
|
64
|
+
? `${this.hostUrl}${item.url_path}`
|
65
|
+
: `${this.hostUrl}${item.url_path}?sort=${this.sortOrderBy}`;
|
66
|
+
|
42
67
|
return html`
|
43
68
|
<li>
|
44
69
|
<div class="separator"></div>
|
45
|
-
<div class="content
|
46
|
-
<a href="
|
70
|
+
<div class="content${activeClass}">
|
71
|
+
<a href="https://${hrefUrl}">
|
47
72
|
<p class="item-title">${item.title}</p>
|
48
73
|
</a>
|
49
74
|
</div>
|
50
75
|
</li>
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
sortVolumes() {
|
55
|
-
this.isSortAscending = !this.isSortAscending;
|
56
|
-
const sortedFiles = this.viewableFiles.sort((a, b) => {
|
57
|
-
if (this.isSortAscending) return a.title.localeCompare(b.title);
|
58
|
-
else return b.title.localeCompare(a.title);
|
59
|
-
})
|
60
|
-
|
61
|
-
this.viewableFiles = [...sortedFiles]
|
62
|
-
}
|
63
|
-
|
64
|
-
get sortAscendingIcon() {
|
65
|
-
const icon = html`<ia-icon icon="sortAscending"></ia-icon>`;
|
66
|
-
return html`<button class="sort-asc icon" @click=${() => this.sortVolumes()}>${icon}</button>`;
|
67
|
-
}
|
68
|
-
|
69
|
-
get sortDescendingIcon() {
|
70
|
-
const icon = html`<ia-icon icon="sortDescending"></ia-icon>`;
|
71
|
-
return html`<button class="sort-desc icon" @click=${() => this.sortVolumes()}>${icon}</button>`;
|
72
|
-
}
|
73
|
-
|
74
|
-
get headerIcon() {
|
75
|
-
return this.isSortAscending ? this.sortAscendingIcon : this.sortDescendingIcon
|
76
|
-
}
|
77
|
-
|
78
|
-
get headerSection() {
|
79
|
-
return html `<header>
|
80
|
-
<h3>Viewable Files (${this.viewableFiles.length}) <span>${this.headerIcon}</span></h3>
|
81
|
-
</header>`;
|
76
|
+
`;
|
82
77
|
}
|
83
78
|
|
84
79
|
get volumesList() {
|
@@ -88,14 +83,13 @@ export class Volumes extends LitElement {
|
|
88
83
|
${volumes}
|
89
84
|
<div class="separator"></div>
|
90
85
|
</ul>
|
91
|
-
|
86
|
+
`;
|
92
87
|
}
|
93
88
|
|
94
89
|
render() {
|
95
90
|
return html`
|
96
|
-
${this.
|
97
|
-
|
98
|
-
`
|
91
|
+
${this.viewableFiles.length ? this.volumesList : nothing}
|
92
|
+
`;
|
99
93
|
}
|
100
94
|
|
101
95
|
static get styles() {
|
@@ -26,39 +26,10 @@ export class BookModel {
|
|
26
26
|
|
27
27
|
/** @type {{width: number, height: number}} memoize storage */
|
28
28
|
this._medianPageSize = null;
|
29
|
-
/** @deprecated @type {{width: number, height: number}} memoize storage */
|
30
|
-
this._medianPageSizePixels = null;
|
31
29
|
/** @type {[PageData[], number]} */
|
32
30
|
this._getDataFlattenedCached = null;
|
33
31
|
}
|
34
32
|
|
35
|
-
/**
|
36
|
-
* @deprecated Use getMedianPageSizeInches
|
37
|
-
* Memoized
|
38
|
-
* @return {{width: number, height: number}}
|
39
|
-
*/
|
40
|
-
getMedianPageSize() {
|
41
|
-
if (this._medianPageSizePixels) {
|
42
|
-
return this._medianPageSizePixels;
|
43
|
-
}
|
44
|
-
|
45
|
-
// A little expensive but we just do it once
|
46
|
-
const widths = [];
|
47
|
-
const heights = [];
|
48
|
-
for (let i = 0; i < this.getNumLeafs(); i++) {
|
49
|
-
widths.push(this.getPageWidth(i));
|
50
|
-
heights.push(this.getPageHeight(i));
|
51
|
-
}
|
52
|
-
|
53
|
-
widths.sort();
|
54
|
-
heights.sort();
|
55
|
-
this._medianPageSizePixels = {
|
56
|
-
width: widths[Math.floor(widths.length / 2)],
|
57
|
-
height: heights[Math.floor(heights.length / 2)]
|
58
|
-
};
|
59
|
-
return this._medianPageSizePixels;
|
60
|
-
}
|
61
|
-
|
62
33
|
/** Get median width/height of page in inches. Memoized for performance. */
|
63
34
|
getMedianPageSizeInches() {
|
64
35
|
if (this._medianPageSize) {
|
@@ -19,7 +19,7 @@ export class DebugConsole {
|
|
19
19
|
</form>`);
|
20
20
|
this.$log.append(this.$form);
|
21
21
|
|
22
|
-
this.$form.submit
|
22
|
+
this.$form.on("submit", ev => {
|
23
23
|
ev.preventDefault();
|
24
24
|
const result = eval(this.$form.find('input').val());
|
25
25
|
this.logToScreen([result]);
|
@@ -29,7 +29,7 @@ export class DebugConsole {
|
|
29
29
|
console.log = (...args) => {
|
30
30
|
_realLog(...args);
|
31
31
|
this.logToScreen(args);
|
32
|
-
}
|
32
|
+
};
|
33
33
|
|
34
34
|
window.onerror = (...args) => this.logToScreen(args);
|
35
35
|
}
|
@@ -40,7 +40,7 @@ export class DebugConsole {
|
|
40
40
|
*/
|
41
41
|
logToScreen(args) {
|
42
42
|
const html = args.map(JSON.stringify).join(',');
|
43
|
-
const $lastEntry = this.$log.children('.log-entry:last-child')
|
43
|
+
const $lastEntry = this.$log.children('.log-entry:last-child');
|
44
44
|
if ($lastEntry.find('.entry-code').html() == html) {
|
45
45
|
$lastEntry.find('.count').text(`(${++this.currentRun})`);
|
46
46
|
} else {
|
@@ -0,0 +1,233 @@
|
|
1
|
+
// @ts-check
|
2
|
+
/*
|
3
|
+
* jQuery dragscrollable Plugin
|
4
|
+
* Based off version: 1.0 (25-Jun-2009)
|
5
|
+
* Copyright (c) 2009 Miquel Herrera
|
6
|
+
*
|
7
|
+
* Portions Copyright (c) 2010 Reg Braithwaite
|
8
|
+
* Copyright (c) 2010 Internet Archive / Michael Ang
|
9
|
+
* Copyright (c) 2016 Internet Archive / Richard Caceres
|
10
|
+
*
|
11
|
+
* Dual licensed under the MIT and GPL licenses:
|
12
|
+
* http://www.opensource.org/licenses/mit-license.php
|
13
|
+
* http://www.gnu.org/licenses/gpl.html
|
14
|
+
*/
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @param {string} string_of_events
|
18
|
+
* @param {string} ns
|
19
|
+
* @returns
|
20
|
+
*/
|
21
|
+
function append_namespace(string_of_events, ns) {
|
22
|
+
return string_of_events
|
23
|
+
.split(' ')
|
24
|
+
.map(event_name => event_name + ns)
|
25
|
+
.join(' ');
|
26
|
+
}
|
27
|
+
|
28
|
+
function left_top(event) {
|
29
|
+
/** @type {number} */
|
30
|
+
let x;
|
31
|
+
/** @type {number} */
|
32
|
+
let y;
|
33
|
+
if (typeof(event.clientX) != 'undefined') {
|
34
|
+
x = event.clientX;
|
35
|
+
y = event.clientY;
|
36
|
+
}
|
37
|
+
else if (typeof(event.screenX) != 'undefined') {
|
38
|
+
x = event.screenX;
|
39
|
+
y = event.screenY;
|
40
|
+
}
|
41
|
+
else if (typeof(event.targetTouches) != 'undefined') {
|
42
|
+
x = event.targetTouches[0].pageX;
|
43
|
+
y = event.targetTouches[0].pageY;
|
44
|
+
}
|
45
|
+
else if (typeof(event.originalEvent) == 'undefined') {
|
46
|
+
console.error("don't understand x and y for " + event.type, event);
|
47
|
+
}
|
48
|
+
else if (typeof(event.originalEvent.clientX) != 'undefined') {
|
49
|
+
x = event.originalEvent.clientX;
|
50
|
+
y = event.originalEvent.clientY;
|
51
|
+
}
|
52
|
+
else if (typeof(event.originalEvent.screenX) != 'undefined') {
|
53
|
+
x = event.originalEvent.screenX;
|
54
|
+
y = event.originalEvent.screenY;
|
55
|
+
}
|
56
|
+
else if (typeof(event.originalEvent.targetTouches) != 'undefined') {
|
57
|
+
x = event.originalEvent.targetTouches[0].pageX;
|
58
|
+
y = event.originalEvent.targetTouches[0].pageY;
|
59
|
+
}
|
60
|
+
|
61
|
+
return { left: x, top: y };
|
62
|
+
}
|
63
|
+
|
64
|
+
const DEFAULT_OPTIONS = {
|
65
|
+
/**
|
66
|
+
* @type {String|HTMLElement} jQuery selector to apply to each wrapped element to
|
67
|
+
* find which will be the dragging elements. Defaults to the first child of scrollable
|
68
|
+
* element
|
69
|
+
*/
|
70
|
+
dragSelector: '>:first',
|
71
|
+
|
72
|
+
/** Will the dragging element accept propagated events? default is yes, a propagated
|
73
|
+
* mouse event on a inner element will be accepted and processed. If set to false,
|
74
|
+
* only events originated on the draggable elements will be processed. */
|
75
|
+
acceptPropagatedEvent: true,
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Prevents the event to propagate further effectively disabling other default actions
|
79
|
+
*/
|
80
|
+
preventDefault: true,
|
81
|
+
|
82
|
+
dragstart: 'mousedown touchstart',
|
83
|
+
dragcontinue: 'mousemove touchmove',
|
84
|
+
dragend: 'mouseup touchend', // mouseleave
|
85
|
+
dragMinDistance: 5,
|
86
|
+
namespace: '.ds',
|
87
|
+
|
88
|
+
/** Scroll the window rather than the element */
|
89
|
+
scrollWindow: false,
|
90
|
+
};
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Adds the ability to manage elements scroll by dragging
|
94
|
+
* one or more of its descendant elements. Options parameter
|
95
|
+
* allow to specifically select which inner elements will
|
96
|
+
* respond to the drag events.
|
97
|
+
* usage examples:
|
98
|
+
*
|
99
|
+
* To add the scroll by drag to the element id=viewport when dragging its
|
100
|
+
* first child accepting any propagated events
|
101
|
+
* `new DragScrollable($('#viewport')[0]);`
|
102
|
+
*
|
103
|
+
* To add the scroll by drag ability to any element div of class viewport
|
104
|
+
* when dragging its first descendant of class dragMe responding only to
|
105
|
+
* evcents originated on the '.dragMe' elements.
|
106
|
+
* ```js
|
107
|
+
* new DragScrollable($('div.viewport')[0], {
|
108
|
+
* dragSelector: '.dragMe:first',
|
109
|
+
* acceptPropagatedEvent: false
|
110
|
+
* });
|
111
|
+
* ```
|
112
|
+
*
|
113
|
+
* Notice that some 'viewports' could be nested within others but events
|
114
|
+
* would not interfere as acceptPropagatedEvent is set to false.
|
115
|
+
*/
|
116
|
+
export class DragScrollable {
|
117
|
+
/**
|
118
|
+
* @param {HTMLElement} element
|
119
|
+
* @param {Partial<DEFAULT_OPTIONS>} options
|
120
|
+
*/
|
121
|
+
constructor(element, options = {}) {
|
122
|
+
this.handling_element = $(element);
|
123
|
+
/** @type {typeof DEFAULT_OPTIONS} */
|
124
|
+
this.settings = $.extend({}, DEFAULT_OPTIONS, options || {});
|
125
|
+
this.firstCoord = { left: 0, top: 0 };
|
126
|
+
this.lastCoord = { left: 0, top: 0 };
|
127
|
+
|
128
|
+
this.settings.dragstart = append_namespace(this.settings.dragstart, this.settings.namespace);
|
129
|
+
this.settings.dragcontinue = append_namespace(this.settings.dragcontinue, this.settings.namespace);
|
130
|
+
//settings.dragend = append_namespace(settings.dragend, settings.namespace);
|
131
|
+
|
132
|
+
// Set mouse initiating event on the desired descendant
|
133
|
+
this.handling_element.find(this.settings.dragSelector)
|
134
|
+
.on(this.settings.dragstart, this._dragStartHandler);
|
135
|
+
}
|
136
|
+
|
137
|
+
_shouldAbort() {
|
138
|
+
const isTouchDevice = !!('ontouchstart' in window) || !!('msmaxtouchpoints' in window.navigator);
|
139
|
+
return isTouchDevice;
|
140
|
+
}
|
141
|
+
|
142
|
+
/** @param {MouseEvent} event */
|
143
|
+
_dragStartHandler = (event) => {
|
144
|
+
if (this._shouldAbort()) { return true; }
|
145
|
+
|
146
|
+
// mousedown, left click, check propagation
|
147
|
+
if (event.which > 1 ||
|
148
|
+
(!this.settings.acceptPropagatedEvent && event.target != this.handling_element[0])) {
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
|
152
|
+
// Initial coordinates will be the last when dragging
|
153
|
+
this.lastCoord = this.firstCoord = left_top(event);
|
154
|
+
|
155
|
+
this.handling_element
|
156
|
+
.on(this.settings.dragcontinue, this._dragContinueHandler)
|
157
|
+
//.on(this.settings.dragend, this._dragEndHandler)
|
158
|
+
;
|
159
|
+
|
160
|
+
// Note, we bind using addEventListener so we can use "capture" binding
|
161
|
+
// instead of "bubble" binding
|
162
|
+
this.settings.dragend.split(' ').forEach(event_name => {
|
163
|
+
this.handling_element[0].addEventListener(event_name, this._dragEndHandler, true);
|
164
|
+
});
|
165
|
+
|
166
|
+
if (this.settings.preventDefault) {
|
167
|
+
event.preventDefault();
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
/** @param {MouseEvent} event */
|
173
|
+
_dragContinueHandler = (event) => { // User is dragging
|
174
|
+
// console.log('drag continue');
|
175
|
+
if (this._shouldAbort()) { return true; }
|
176
|
+
|
177
|
+
const lt = left_top(event);
|
178
|
+
|
179
|
+
// How much did the mouse move?
|
180
|
+
const delta = {
|
181
|
+
left: (lt.left - this.lastCoord.left),
|
182
|
+
top: (lt.top - this.lastCoord.top)
|
183
|
+
};
|
184
|
+
|
185
|
+
const scrollTarget = this.settings.scrollWindow ? $(window) : this.handling_element;
|
186
|
+
|
187
|
+
// Set the scroll position relative to what ever the scroll is now
|
188
|
+
scrollTarget.scrollLeft( scrollTarget.scrollLeft() - delta.left );
|
189
|
+
scrollTarget.scrollTop( scrollTarget.scrollTop() - delta.top );
|
190
|
+
|
191
|
+
// Save where the cursor is
|
192
|
+
this.lastCoord = lt;
|
193
|
+
|
194
|
+
if (this.settings.preventDefault) {
|
195
|
+
event.preventDefault();
|
196
|
+
return false;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
/** @param {MouseEvent} event */
|
201
|
+
_dragEndHandler = (event) => { // Stop scrolling
|
202
|
+
//console.log('dragEndHandler');
|
203
|
+
|
204
|
+
if (this._shouldAbort()) { return true; }
|
205
|
+
|
206
|
+
this.handling_element
|
207
|
+
.off(this.settings.dragcontinue)
|
208
|
+
// Note, for some reason, even though I removeEventListener below,
|
209
|
+
// this call to unbind is still necessary. I don't know why.
|
210
|
+
.off(this.settings.dragend);
|
211
|
+
|
212
|
+
// Note, we bind using addEventListener so we can use "capture" binding
|
213
|
+
// instead of "bubble" binding
|
214
|
+
this.settings.dragend.split(' ').forEach(event_name => {
|
215
|
+
this.handling_element[0].removeEventListener(event_name, this._dragEndHandler, true);
|
216
|
+
});
|
217
|
+
|
218
|
+
// How much did the mouse move total?
|
219
|
+
const delta = {
|
220
|
+
left: Math.abs(this.lastCoord.left - this.firstCoord.left),
|
221
|
+
top: Math.abs(this.lastCoord.top - this.firstCoord.top)
|
222
|
+
};
|
223
|
+
const distance = Math.max(delta.left, delta.top);
|
224
|
+
|
225
|
+
// Allow event to propagate if min distance was not achieved
|
226
|
+
if (this.settings.preventDefault && distance > this.settings.dragMinDistance) {
|
227
|
+
event.preventDefault();
|
228
|
+
event.stopImmediatePropagation();
|
229
|
+
event.stopPropagation();
|
230
|
+
return false;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|