@internetarchive/bookreader 5.0.0-88-alpha.10 → 5.0.0-88
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.css +3 -3
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +87 -108
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.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/CHANGELOG.md +4 -0
- package/babel.config.js +12 -30
- package/jsconfig.json +1 -3
- package/package.json +14 -16
- package/src/BookNavigator/search/search-results.js +1 -1
- package/src/BookReader/Mode1UpLit.js +56 -86
- package/src/BookReader/Mode2UpLit.js +2 -3
- package/src/BookReader/Navbar/Navbar.js +53 -11
- package/src/BookReader/options.js +3 -0
- package/src/BookReader.js +49 -1
- package/src/BookReaderPlugin.js +28 -0
- package/src/css/_BRnav.scss +0 -3
- package/src/css/_controls.scss +4 -0
- package/src/plugins/plugin.archive_analytics.js +84 -78
- package/src/plugins/plugin.chapters.js +17 -22
- package/src/plugins/plugin.text_selection.js +1 -1
- package/src/plugins/tts/plugin.tts.js +2 -2
- package/tests/jest/BookReader/Navbar/Navbar.test.js +16 -3
- package/tests/jest/plugins/plugin.archive_analytics.test.js +8 -11
- package/dist/esm/BookNavigator/assets/bookmark-colors.js +0 -4
- package/dist/esm/BookNavigator/assets/button-base.js +0 -4
- package/dist/esm/BookNavigator/assets/ia-logo.js +0 -4
- package/dist/esm/BookNavigator/assets/icon_checkmark.js +0 -8
- package/dist/esm/BookNavigator/assets/icon_close.js +0 -4
- package/dist/esm/BookNavigator/book-navigator.js +0 -612
- package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +0 -35
- package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +0 -78
- package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +0 -160
- package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -24
- package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +0 -55
- package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +0 -521
- package/dist/esm/BookNavigator/delete-modal-actions.js +0 -29
- package/dist/esm/BookNavigator/downloads/downloads-provider.js +0 -84
- package/dist/esm/BookNavigator/downloads/downloads.js +0 -69
- package/dist/esm/BookNavigator/search/search-provider.js +0 -238
- package/dist/esm/BookNavigator/search/search-results.js +0 -161
- package/dist/esm/BookNavigator/sharing.js +0 -26
- package/dist/esm/BookNavigator/viewable-files.js +0 -94
- package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -83
- package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +0 -131
- package/dist/esm/BookReader/BookModel.js +0 -575
- package/dist/esm/BookReader/DragScrollable.js +0 -224
- package/dist/esm/BookReader/ImageCache.js +0 -122
- package/dist/esm/BookReader/Mode1Up.js +0 -114
- package/dist/esm/BookReader/Mode1UpLit.js +0 -579
- package/dist/esm/BookReader/Mode2Up.js +0 -106
- package/dist/esm/BookReader/Mode2UpLit.js +0 -1020
- package/dist/esm/BookReader/ModeCoordinateSpace.js +0 -28
- package/dist/esm/BookReader/ModeSmoothZoom.js +0 -318
- package/dist/esm/BookReader/ModeThumb.js +0 -366
- package/dist/esm/BookReader/Navbar/Navbar.js +0 -253
- package/dist/esm/BookReader/PageContainer.js +0 -165
- package/dist/esm/BookReader/ReduceSet.js +0 -27
- package/dist/esm/BookReader/Toolbar/Toolbar.js +0 -242
- package/dist/esm/BookReader/events.js +0 -20
- package/dist/esm/BookReader/options.js +0 -331
- package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +0 -48
- package/dist/esm/BookReader/utils/ScrollClassAdder.js +0 -31
- package/dist/esm/BookReader/utils/SelectionObserver.js +0 -42
- package/dist/esm/BookReader/utils/classes.js +0 -37
- package/dist/esm/BookReader/utils.js +0 -315
- package/dist/esm/BookReader.js +0 -1827
- package/dist/esm/assets/icons/1up.svg +0 -12
- package/dist/esm/assets/icons/2up.svg +0 -15
- package/dist/esm/assets/icons/advance.svg +0 -26
- package/dist/esm/assets/icons/chevron-right.svg +0 -1
- package/dist/esm/assets/icons/close-circle-dark.svg +0 -1
- package/dist/esm/assets/icons/close-circle.svg +0 -1
- package/dist/esm/assets/icons/fullscreen.svg +0 -17
- package/dist/esm/assets/icons/fullscreen_exit.svg +0 -17
- package/dist/esm/assets/icons/hamburger.svg +0 -15
- package/dist/esm/assets/icons/left-arrow.svg +0 -12
- package/dist/esm/assets/icons/magnify-minus.svg +0 -12
- package/dist/esm/assets/icons/magnify-plus.svg +0 -13
- package/dist/esm/assets/icons/magnify.svg +0 -15
- package/dist/esm/assets/icons/pause.svg +0 -23
- package/dist/esm/assets/icons/play.svg +0 -22
- package/dist/esm/assets/icons/playback-speed.svg +0 -34
- package/dist/esm/assets/icons/read-aloud.svg +0 -22
- package/dist/esm/assets/icons/review.svg +0 -22
- package/dist/esm/assets/icons/thumbnails.svg +0 -17
- package/dist/esm/assets/icons/voice.svg +0 -1
- package/dist/esm/assets/icons/volume-full.svg +0 -22
- package/dist/esm/assets/images/BRicons.png +0 -0
- package/dist/esm/assets/images/BRicons.svg +0 -94
- package/dist/esm/assets/images/BRicons_ia.png +0 -0
- package/dist/esm/assets/images/back_pages.png +0 -0
- package/dist/esm/assets/images/book_bottom_icon.png +0 -0
- package/dist/esm/assets/images/book_down_icon.png +0 -0
- package/dist/esm/assets/images/book_left_icon.png +0 -0
- package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
- package/dist/esm/assets/images/book_right_icon.png +0 -0
- package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
- package/dist/esm/assets/images/book_top_icon.png +0 -0
- package/dist/esm/assets/images/book_up_icon.png +0 -0
- package/dist/esm/assets/images/books_graphic.svg +0 -177
- package/dist/esm/assets/images/booksplit.png +0 -0
- package/dist/esm/assets/images/control_pause_icon.png +0 -0
- package/dist/esm/assets/images/control_play_icon.png +0 -0
- package/dist/esm/assets/images/embed_icon.png +0 -0
- package/dist/esm/assets/images/icon-home-ia.png +0 -0
- package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
- package/dist/esm/assets/images/icon_alert-xs.png +0 -0
- package/dist/esm/assets/images/icon_book.svg +0 -12
- package/dist/esm/assets/images/icon_bookmark.svg +0 -12
- package/dist/esm/assets/images/icon_close-pop.png +0 -0
- package/dist/esm/assets/images/icon_download.png +0 -0
- package/dist/esm/assets/images/icon_gear.svg +0 -14
- package/dist/esm/assets/images/icon_hamburger.svg +0 -20
- package/dist/esm/assets/images/icon_home.png +0 -0
- package/dist/esm/assets/images/icon_home.svg +0 -21
- package/dist/esm/assets/images/icon_home_ia.png +0 -0
- package/dist/esm/assets/images/icon_indicator.png +0 -0
- package/dist/esm/assets/images/icon_info.svg +0 -11
- package/dist/esm/assets/images/icon_one_page.svg +0 -8
- package/dist/esm/assets/images/icon_pause.svg +0 -1
- package/dist/esm/assets/images/icon_play.svg +0 -1
- package/dist/esm/assets/images/icon_playback-rate.svg +0 -15
- package/dist/esm/assets/images/icon_return.png +0 -0
- package/dist/esm/assets/images/icon_search_button.svg +0 -8
- package/dist/esm/assets/images/icon_share.svg +0 -9
- package/dist/esm/assets/images/icon_skip-ahead.svg +0 -6
- package/dist/esm/assets/images/icon_skip-back.svg +0 -13
- package/dist/esm/assets/images/icon_speaker.svg +0 -18
- package/dist/esm/assets/images/icon_speaker_open.svg +0 -10
- package/dist/esm/assets/images/icon_thumbnails.svg +0 -12
- package/dist/esm/assets/images/icon_toc.svg +0 -5
- package/dist/esm/assets/images/icon_two_pages.svg +0 -9
- package/dist/esm/assets/images/icon_zoomer.png +0 -0
- package/dist/esm/assets/images/loading.gif +0 -0
- package/dist/esm/assets/images/logo_icon.png +0 -0
- package/dist/esm/assets/images/marker_chap-off.png +0 -0
- package/dist/esm/assets/images/marker_chap-off.svg +0 -11
- package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
- package/dist/esm/assets/images/marker_chap-on.png +0 -0
- package/dist/esm/assets/images/marker_chap-on.svg +0 -11
- package/dist/esm/assets/images/marker_srch-on.svg +0 -11
- package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
- package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
- package/dist/esm/assets/images/nav_control-dn.png +0 -0
- package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
- package/dist/esm/assets/images/nav_control-up.png +0 -0
- package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
- package/dist/esm/assets/images/nav_control.png +0 -0
- package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
- package/dist/esm/assets/images/paper-badge.png +0 -0
- package/dist/esm/assets/images/print_icon.png +0 -0
- package/dist/esm/assets/images/progressbar.gif +0 -0
- package/dist/esm/assets/images/right_edges.png +0 -0
- package/dist/esm/assets/images/slider.png +0 -0
- package/dist/esm/assets/images/slider_ia.png +0 -0
- package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
- package/dist/esm/assets/images/transparent.png +0 -0
- package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
- package/dist/esm/assets/images/unviewable_page.png +0 -0
- package/dist/esm/assets/images/zoom_in_icon.png +0 -0
- package/dist/esm/assets/images/zoom_out_icon.png +0 -0
- package/dist/esm/css/BookReader.scss +0 -85
- package/dist/esm/css/_BRBookmarks.scss +0 -29
- package/dist/esm/css/_BRComponent.scss +0 -13
- package/dist/esm/css/_BRfloat.scss +0 -197
- package/dist/esm/css/_BRicon.scss +0 -54
- package/dist/esm/css/_BRmain.scss +0 -262
- package/dist/esm/css/_BRnav.scss +0 -354
- package/dist/esm/css/_BRpages.scss +0 -213
- package/dist/esm/css/_BRsearch.scss +0 -268
- package/dist/esm/css/_BRtoolbar.scss +0 -84
- package/dist/esm/css/_BRvendor.scss +0 -5
- package/dist/esm/css/_TextSelection.scss +0 -108
- package/dist/esm/css/_colorbox.scss +0 -52
- package/dist/esm/css/_controls.scss +0 -257
- package/dist/esm/css/_icons.scss +0 -121
- package/dist/esm/ia-bookreader/ia-bookreader.js +0 -141
- package/dist/esm/jquery-wrapper.js +0 -3
- package/dist/esm/plugins/plugin.archive_analytics.js +0 -72
- package/dist/esm/plugins/plugin.autoplay.js +0 -119
- package/dist/esm/plugins/plugin.chapters.js +0 -288
- package/dist/esm/plugins/plugin.iframe.js +0 -44
- package/dist/esm/plugins/plugin.iiif.js +0 -146
- package/dist/esm/plugins/plugin.resume.js +0 -66
- package/dist/esm/plugins/plugin.text_selection.js +0 -621
- package/dist/esm/plugins/plugin.vendor-fullscreen.js +0 -227
- package/dist/esm/plugins/search/plugin.search.js +0 -499
- package/dist/esm/plugins/search/utils.js +0 -42
- package/dist/esm/plugins/search/view.js +0 -360
- package/dist/esm/plugins/tts/AbstractTTSEngine.js +0 -282
- package/dist/esm/plugins/tts/FestivalTTSEngine.js +0 -192
- package/dist/esm/plugins/tts/PageChunk.js +0 -105
- package/dist/esm/plugins/tts/PageChunkIterator.js +0 -155
- package/dist/esm/plugins/tts/WebTTSEngine.js +0 -364
- package/dist/esm/plugins/tts/plugin.tts.js +0 -315
- package/dist/esm/plugins/tts/tooltip_dict.js +0 -14
- package/dist/esm/plugins/tts/utils.js +0 -79
- package/dist/esm/plugins/url/UrlPlugin.js +0 -197
- package/dist/esm/plugins/url/plugin.url.js +0 -212
- package/dist/esm/util/browserSniffing.js +0 -56
- package/dist/esm/util/debouncer.js +0 -25
- package/dist/esm/util/docCookies.js +0 -75
- package/dist/esm/util/strings.js +0 -34
- package/index.js +0 -2
@@ -1,69 +0,0 @@
|
|
1
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
2
|
-
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
3
|
-
import { css, html, LitElement, nothing } from 'lit';
|
4
|
-
import buttonStyles from '../assets/button-base.js';
|
5
|
-
export class IABookDownloads extends LitElement {
|
6
|
-
static get properties() {
|
7
|
-
return {
|
8
|
-
downloads: {
|
9
|
-
type: Array
|
10
|
-
},
|
11
|
-
expiration: {
|
12
|
-
type: Number
|
13
|
-
},
|
14
|
-
renderHeader: {
|
15
|
-
type: Boolean
|
16
|
-
},
|
17
|
-
isBookProtected: {
|
18
|
-
type: Boolean
|
19
|
-
}
|
20
|
-
};
|
21
|
-
}
|
22
|
-
constructor() {
|
23
|
-
super();
|
24
|
-
this.downloads = [];
|
25
|
-
this.expiration = 0;
|
26
|
-
this.renderHeader = false;
|
27
|
-
this.isBookProtected = false;
|
28
|
-
}
|
29
|
-
get formatsCount() {
|
30
|
-
var count = this.downloads.length;
|
31
|
-
return count ? html(_templateObject || (_templateObject = _taggedTemplateLiteral(["<p>", " format", "</p>"])), count, count > 1 ? 's' : '') : html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral([""])));
|
32
|
-
}
|
33
|
-
get loanExpiryMessage() {
|
34
|
-
return this.expiration ? html(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["<h2>These files will expire in ", " days.</h2>"])), this.expiration) : html(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral([""])));
|
35
|
-
}
|
36
|
-
renderDownloadOptions() {
|
37
|
-
return this.downloads.map(option => html(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n <li>\n <a class=\"ia-button link primary\" href=\"", "\">Get ", "</a>\n ", "\n </li>\n "])), option.url, option.type, option.note ? html(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["<p>", "</p>"])), option.note) : html(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral([""])))));
|
38
|
-
}
|
39
|
-
|
40
|
-
/**
|
41
|
-
* checks if downloads list contains an LCP option
|
42
|
-
* @return {boolean}
|
43
|
-
*/
|
44
|
-
get hasLCPOption() {
|
45
|
-
var regex = /^(LCP)/g;
|
46
|
-
var lcpAvailable = this.downloads.some(option => {
|
47
|
-
var _option$type;
|
48
|
-
return (_option$type = option.type) === null || _option$type === void 0 ? void 0 : _option$type.match(regex);
|
49
|
-
});
|
50
|
-
return lcpAvailable;
|
51
|
-
}
|
52
|
-
get header() {
|
53
|
-
if (!this.renderHeader) {
|
54
|
-
return nothing;
|
55
|
-
}
|
56
|
-
return html(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n <header>\n <h3>Downloadable files</h3>\n ", "\n </header>\n "])), this.formatsCount);
|
57
|
-
}
|
58
|
-
get installLCPSoftwareMsg() {
|
59
|
-
return html(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n <p>For LCP downloads, make sure you have LCP software such as <a href=\"https://thorium.edrlab.org/\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">Thorium (desktop)</a>, <a href=\"https://apps.apple.com/us/app/cantook-by-aldiko/id1476410111\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">Cantook (iOS)</a> or <a href=\"https://play.google.com/store/apps/details?id=com.aldiko.android\" rel=\"noopener noreferrer nofollow\" target=\"_blank\">Cantook (Android)</a> installed on your device.</p>\n "])));
|
60
|
-
}
|
61
|
-
render() {
|
62
|
-
return html(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n ", "\n ", "\n <ul>", "</ul>\n ", "\n "])), this.header, this.loanExpiryMessage, this.renderDownloadOptions(), this.hasLCPOption ? this.installLCPSoftwareMsg : nothing);
|
63
|
-
}
|
64
|
-
static get styles() {
|
65
|
-
var mainCss = css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n :host {\n display: block;\n height: 100%;\n padding: 1.5rem 0;\n overflow-y: auto;\n font-size: 1.4rem;\n box-sizing: border-box;\n }\n\n a.close ia-icon {\n --iconWidth: 18px;\n --iconHeight: 18px;\n }\n a.close {\n justify-self: end;\n }\n\n header {\n display: flex;\n align-items: center;\n padding: 0 2rem;\n }\n header p {\n padding: 0;\n margin: 0;\n font-size: 1.2rem;\n font-weight: bold;\n font-style: italic;\n }\n header div {\n display: flex;\n align-items: baseline;\n } \n\n h2 {\n font-size: 1.6rem;\n }\n\n h3 {\n padding: 0;\n margin: 0 1rem 0 0;\n font-size: 1.4rem;\n }\n\n ul {\n padding: 0;\n margin: 0;\n list-style: none;\n }\n\n p {\n margin: .3rem 0 0 0;\n }\n\n li,\n ul + p {\n padding-bottom: 1.2rem;\n font-size: 1.2rem;\n line-height: 140%;\n }\n "])));
|
66
|
-
return [buttonStyles, mainCss];
|
67
|
-
}
|
68
|
-
}
|
69
|
-
customElements.define('ia-book-downloads', IABookDownloads);
|
@@ -1,238 +0,0 @@
|
|
1
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
2
|
-
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
3
|
-
import { html, nothing } from 'lit';
|
4
|
-
import '@internetarchive/icon-search/icon-search';
|
5
|
-
import './search-results';
|
6
|
-
/** @typedef {import('@/src/plugins/search/plugin.search.js').SearchInsideMatch} SearchInsideMatch */
|
7
|
-
|
8
|
-
var searchState = {
|
9
|
-
query: '',
|
10
|
-
results: [],
|
11
|
-
resultsCount: 0,
|
12
|
-
queryInProgress: false,
|
13
|
-
errorMessage: ''
|
14
|
-
};
|
15
|
-
export default class SearchProvider {
|
16
|
-
constructor(_ref) {
|
17
|
-
var {
|
18
|
-
onProviderChange,
|
19
|
-
bookreader
|
20
|
-
} = _ref;
|
21
|
-
/* search menu events */
|
22
|
-
this.onBookSearchInitiated = this.onBookSearchInitiated.bind(this);
|
23
|
-
/* bookreader search events */
|
24
|
-
this.onSearchStarted = this.onSearchStarted.bind(this);
|
25
|
-
this.onSearchRequestError = this.onSearchRequestError.bind(this);
|
26
|
-
this.onSearchResultsClicked = this.onSearchResultsClicked.bind(this);
|
27
|
-
this.onSearchResultsChange = this.onSearchResultsChange.bind(this);
|
28
|
-
this.onSearchResultsCleared = this.onSearchResultsCleared.bind(this);
|
29
|
-
this.searchCanceledInMenu = this.searchCanceledInMenu.bind(this);
|
30
|
-
|
31
|
-
/* class methods */
|
32
|
-
this.bindEventListeners = this.bindEventListeners.bind(this);
|
33
|
-
this.getMenuDetails = this.getMenuDetails.bind(this);
|
34
|
-
this.getComponent = this.getComponent.bind(this);
|
35
|
-
this.updateMenu = this.updateMenu.bind(this);
|
36
|
-
this.onProviderChange = onProviderChange;
|
37
|
-
/** @type {import('@/src/BookReader.js').default} */
|
38
|
-
this.bookreader = bookreader;
|
39
|
-
this.icon = html(_templateObject || (_templateObject = _taggedTemplateLiteral(["<ia-icon-search style=\"width: var(--iconWidth); height: var(--iconHeight);\"></ia-icon-search>"])));
|
40
|
-
this.label = 'Search inside';
|
41
|
-
this.menuDetails = this.getMenuDetails();
|
42
|
-
this.id = 'search';
|
43
|
-
this.component = this.getComponent();
|
44
|
-
this.bindEventListeners();
|
45
|
-
}
|
46
|
-
getMenuDetails() {
|
47
|
-
var {
|
48
|
-
resultsCount,
|
49
|
-
query,
|
50
|
-
queryInProgress
|
51
|
-
} = searchState;
|
52
|
-
if (queryInProgress || !query) {
|
53
|
-
return nothing;
|
54
|
-
}
|
55
|
-
var unit = resultsCount === 1 ? 'result' : 'results';
|
56
|
-
return html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["(", " ", ")"])), resultsCount, unit);
|
57
|
-
}
|
58
|
-
bindEventListeners() {
|
59
|
-
window.addEventListener('BookReader:SearchStarted', this.onSearchStarted);
|
60
|
-
window.addEventListener('BookReader:SearchCallback', this.onSearchResultsChange);
|
61
|
-
window.addEventListener('BookReader:SearchCallbackEmpty', event => {
|
62
|
-
this.onSearchRequestError(event, 'noResults');
|
63
|
-
});
|
64
|
-
window.addEventListener('BookReader:SearchCallbackNotIndexed', event => {
|
65
|
-
this.onSearchRequestError(event, 'notIndexed');
|
66
|
-
});
|
67
|
-
window.addEventListener('BookReader:SearchCallbackError', event => {
|
68
|
-
this.onSearchRequestError(event);
|
69
|
-
});
|
70
|
-
window.addEventListener('BookReader:SearchResultsCleared', () => {
|
71
|
-
this.onSearchResultsCleared();
|
72
|
-
});
|
73
|
-
window.addEventListener('BookReader:SearchCanceled', e => {
|
74
|
-
this.onSearchCanceled(e);
|
75
|
-
});
|
76
|
-
}
|
77
|
-
|
78
|
-
/**
|
79
|
-
* Cancel search handler
|
80
|
-
* resets `searchState`
|
81
|
-
*/
|
82
|
-
onSearchCanceled() {
|
83
|
-
searchState = {
|
84
|
-
query: '',
|
85
|
-
results: [],
|
86
|
-
resultsCount: 0,
|
87
|
-
queryInProgress: false,
|
88
|
-
errorMessage: ''
|
89
|
-
};
|
90
|
-
var updateMenuFor = {
|
91
|
-
searchCanceled: true
|
92
|
-
};
|
93
|
-
this.updateMenu(updateMenuFor);
|
94
|
-
if (this.bookreader.urlPlugin) {
|
95
|
-
this.updateSearchInUrl();
|
96
|
-
}
|
97
|
-
}
|
98
|
-
onSearchStarted(e) {
|
99
|
-
var {
|
100
|
-
term = '',
|
101
|
-
instance
|
102
|
-
} = e.detail.props;
|
103
|
-
if (instance) {
|
104
|
-
this.bookreader = instance;
|
105
|
-
}
|
106
|
-
searchState.query = term;
|
107
|
-
searchState.results = [];
|
108
|
-
searchState.resultsCount = 0;
|
109
|
-
searchState.queryInProgress = true;
|
110
|
-
searchState.errorMessage = '';
|
111
|
-
this.updateMenu();
|
112
|
-
}
|
113
|
-
onBookSearchInitiated(_ref2) {
|
114
|
-
var {
|
115
|
-
detail
|
116
|
-
} = _ref2;
|
117
|
-
searchState.query = detail.query;
|
118
|
-
this.bookreader.search(searchState.query);
|
119
|
-
}
|
120
|
-
onSearchRequestError(event) {
|
121
|
-
var _errorMessages$errorT, _instance$searchResul;
|
122
|
-
var errorType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
123
|
-
var {
|
124
|
-
detail: {
|
125
|
-
props = {}
|
126
|
-
}
|
127
|
-
} = event;
|
128
|
-
var {
|
129
|
-
instance = null
|
130
|
-
} = props;
|
131
|
-
if (instance) {
|
132
|
-
/* keep bookreader instance reference up-to-date */
|
133
|
-
this.bookreader = instance;
|
134
|
-
}
|
135
|
-
var errorMessages = {
|
136
|
-
noResults: '0 results',
|
137
|
-
notIndexed: "This book hasn't been indexed for searching yet. We've just started indexing it,\n so search should be available soon. Please try again later. Thanks!",
|
138
|
-
default: 'Sorry, there was an error with your search. Please try again.'
|
139
|
-
};
|
140
|
-
var messageToShow = (_errorMessages$errorT = errorMessages[errorType]) !== null && _errorMessages$errorT !== void 0 ? _errorMessages$errorT : errorMessages.default;
|
141
|
-
searchState.query = (instance === null || instance === void 0 || (_instance$searchResul = instance.searchResults) === null || _instance$searchResul === void 0 ? void 0 : _instance$searchResul.q) || '';
|
142
|
-
searchState.results = [];
|
143
|
-
searchState.resultsCount = 0;
|
144
|
-
searchState.queryInProgress = false;
|
145
|
-
searchState.errorMessage = html(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["<p class=\"error\">", "</p>"])), messageToShow);
|
146
|
-
this.updateMenu();
|
147
|
-
}
|
148
|
-
onSearchResultsChange(_ref3) {
|
149
|
-
var {
|
150
|
-
detail: {
|
151
|
-
props = {}
|
152
|
-
}
|
153
|
-
} = _ref3;
|
154
|
-
var {
|
155
|
-
instance = null,
|
156
|
-
results: searchResults = []
|
157
|
-
} = props;
|
158
|
-
if (instance) {
|
159
|
-
/* keep bookreader instance reference up-to-date */
|
160
|
-
this.bookreader = instance;
|
161
|
-
}
|
162
|
-
var results = searchResults.matches || [];
|
163
|
-
var resultsCount = results.length;
|
164
|
-
var query = searchResults.q;
|
165
|
-
var queryInProgress = false;
|
166
|
-
searchState = {
|
167
|
-
results,
|
168
|
-
resultsCount,
|
169
|
-
query,
|
170
|
-
queryInProgress,
|
171
|
-
errorMessage: ''
|
172
|
-
};
|
173
|
-
this.updateMenu();
|
174
|
-
}
|
175
|
-
searchCanceledInMenu() {
|
176
|
-
var _this$bookreader;
|
177
|
-
(_this$bookreader = this.bookreader) === null || _this$bookreader === void 0 || _this$bookreader.cancelSearchRequest();
|
178
|
-
}
|
179
|
-
onSearchResultsCleared() {
|
180
|
-
var _this$bookreader2;
|
181
|
-
searchState = {
|
182
|
-
query: '',
|
183
|
-
results: [],
|
184
|
-
resultsCount: 0,
|
185
|
-
queryInProgress: false,
|
186
|
-
errorMessage: ''
|
187
|
-
};
|
188
|
-
this.updateMenu({
|
189
|
-
openMenu: false
|
190
|
-
});
|
191
|
-
(_this$bookreader2 = this.bookreader) === null || _this$bookreader2 === void 0 || (_this$bookreader2 = _this$bookreader2.searchView) === null || _this$bookreader2 === void 0 || _this$bookreader2.clearSearchFieldAndResults(false);
|
192
|
-
if (this.bookreader.urlPlugin) {
|
193
|
-
this.updateSearchInUrl();
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
/** update URL `q=<term>` query param in URL */
|
198
|
-
updateSearchInUrl() {
|
199
|
-
if (this.bookreader.urlPlugin) {
|
200
|
-
this.bookreader.urlPlugin.pullFromAddressBar();
|
201
|
-
if (searchState.query) {
|
202
|
-
this.bookreader.urlPlugin.setUrlParam('q', searchState.query);
|
203
|
-
} else {
|
204
|
-
this.bookreader.urlPlugin.removeUrlParam('q');
|
205
|
-
}
|
206
|
-
}
|
207
|
-
}
|
208
|
-
|
209
|
-
/**
|
210
|
-
* Relays how to update side menu given the context of a search update
|
211
|
-
@param {{searchCanceled: boolean}} searchUpdates
|
212
|
-
*/
|
213
|
-
updateMenu() {
|
214
|
-
var searchUpdates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
215
|
-
this.menuDetails = this.getMenuDetails();
|
216
|
-
this.component = this.getComponent();
|
217
|
-
this.onProviderChange(this.bookreader, searchUpdates);
|
218
|
-
}
|
219
|
-
getComponent() {
|
220
|
-
var {
|
221
|
-
query,
|
222
|
-
results,
|
223
|
-
queryInProgress,
|
224
|
-
errorMessage
|
225
|
-
} = searchState;
|
226
|
-
return html(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n <ia-book-search-results\n .query=", "\n .results=", "\n .errorMessage=", "\n ?queryInProgress=", "\n ?renderSearchAllFiles=", "\n @resultSelected=", "\n @bookSearchInitiated=", "\n @bookSearchResultsCleared=", "\n @bookSearchCanceled=", "\n ></ia-book-search-results>\n "])), query, results, errorMessage, queryInProgress, false, this.onSearchResultsClicked, this.onBookSearchInitiated, this.onSearchResultsCleared, this.searchCanceledInMenu);
|
227
|
-
}
|
228
|
-
|
229
|
-
/**
|
230
|
-
* @param {{ detail: {match: SearchInsideMatch} }} param0
|
231
|
-
*/
|
232
|
-
onSearchResultsClicked(_ref4) {
|
233
|
-
var {
|
234
|
-
detail
|
235
|
-
} = _ref4;
|
236
|
-
this.bookreader._searchPluginGoToResult(detail.match.matchIndex);
|
237
|
-
}
|
238
|
-
}
|
@@ -1,161 +0,0 @@
|
|
1
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
|
2
|
-
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
3
|
-
/* eslint-disable class-methods-use-this */
|
4
|
-
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
5
|
-
import { css, html, LitElement, nothing } from 'lit';
|
6
|
-
import '@internetarchive/ia-activity-indicator';
|
7
|
-
import checkmarkIcon from '../assets/icon_checkmark.js';
|
8
|
-
import closeIcon from '../assets/icon_close.js';
|
9
|
-
import buttonCSS from '../assets/button-base.js';
|
10
|
-
/** @typedef {import('@/src/plugins/search/plugin.search.js').SearchInsideMatch} SearchInsideMatch */
|
11
|
-
|
12
|
-
export class IABookSearchResults extends LitElement {
|
13
|
-
static get properties() {
|
14
|
-
return {
|
15
|
-
results: {
|
16
|
-
type: Array
|
17
|
-
},
|
18
|
-
query: {
|
19
|
-
type: String
|
20
|
-
},
|
21
|
-
queryInProgress: {
|
22
|
-
type: Boolean
|
23
|
-
},
|
24
|
-
renderHeader: {
|
25
|
-
type: Boolean
|
26
|
-
},
|
27
|
-
renderSearchAllFiles: {
|
28
|
-
type: Boolean
|
29
|
-
},
|
30
|
-
displayResultImages: {
|
31
|
-
type: Boolean
|
32
|
-
},
|
33
|
-
errorMessage: {
|
34
|
-
type: String
|
35
|
-
}
|
36
|
-
};
|
37
|
-
}
|
38
|
-
constructor() {
|
39
|
-
super();
|
40
|
-
|
41
|
-
/** @type {SearchInsideMatch[]} */
|
42
|
-
this.results = [];
|
43
|
-
this.query = '';
|
44
|
-
this.queryInProgress = false;
|
45
|
-
this.renderHeader = false;
|
46
|
-
this.renderSearchAllFiles = false;
|
47
|
-
this.displayResultImages = false;
|
48
|
-
this.errorMessage = '';
|
49
|
-
this.bindBookReaderListeners();
|
50
|
-
}
|
51
|
-
|
52
|
-
/** @inheritdoc */
|
53
|
-
updated() {
|
54
|
-
this.focusOnInputIfNecessary();
|
55
|
-
}
|
56
|
-
bindBookReaderListeners() {
|
57
|
-
document.addEventListener('BookReader:SearchCallback', this.setResults.bind(this));
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Provide immediate input focus if there aren't any results displayed
|
62
|
-
*/
|
63
|
-
focusOnInputIfNecessary() {
|
64
|
-
if (this.results.length) {
|
65
|
-
return;
|
66
|
-
}
|
67
|
-
var searchInput = this.shadowRoot.querySelector('input[type=\'search\']');
|
68
|
-
searchInput.focus();
|
69
|
-
}
|
70
|
-
setResults(_ref) {
|
71
|
-
var {
|
72
|
-
detail
|
73
|
-
} = _ref;
|
74
|
-
this.results = detail.results;
|
75
|
-
}
|
76
|
-
setQuery(e) {
|
77
|
-
this.query = e.currentTarget.value;
|
78
|
-
if (!this.query) {
|
79
|
-
this.cancelSearch();
|
80
|
-
}
|
81
|
-
}
|
82
|
-
performSearch(e) {
|
83
|
-
e.preventDefault();
|
84
|
-
var input = e.currentTarget.querySelector('input[type="search"]');
|
85
|
-
if (!input || !input.value) {
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
this.dispatchEvent(new CustomEvent('bookSearchInitiated', {
|
89
|
-
bubbles: true,
|
90
|
-
composed: true,
|
91
|
-
detail: {
|
92
|
-
query: this.query
|
93
|
-
}
|
94
|
-
}));
|
95
|
-
}
|
96
|
-
|
97
|
-
/**
|
98
|
-
* @param {SearchInsideMatch} match
|
99
|
-
*/
|
100
|
-
selectResult(match) {
|
101
|
-
this.dispatchEvent(new CustomEvent('resultSelected', {
|
102
|
-
bubbles: true,
|
103
|
-
composed: true,
|
104
|
-
detail: {
|
105
|
-
match
|
106
|
-
}
|
107
|
-
}));
|
108
|
-
this.dispatchEvent(new CustomEvent('closeMenu', {
|
109
|
-
bubbles: true,
|
110
|
-
composed: true
|
111
|
-
}));
|
112
|
-
}
|
113
|
-
cancelSearch() {
|
114
|
-
this.queryInProgress = false;
|
115
|
-
this.dispatchSearchCanceled();
|
116
|
-
}
|
117
|
-
dispatchSearchCanceled() {
|
118
|
-
this.dispatchEvent(new Event('bookSearchCanceled'));
|
119
|
-
}
|
120
|
-
get resultsCount() {
|
121
|
-
var count = this.results.length;
|
122
|
-
return count ? html(_templateObject || (_templateObject = _taggedTemplateLiteral(["<p>(", " result", ")</p>"])), count, count > 1 ? 's' : '') : nothing;
|
123
|
-
}
|
124
|
-
get headerSection() {
|
125
|
-
var header = html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["<header>\n <h3>Search inside</h3>\n ", "\n </header>"])), this.resultsCount);
|
126
|
-
return this.renderHeader ? header : nothing;
|
127
|
-
}
|
128
|
-
get searchMultipleControls() {
|
129
|
-
var controls = html(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n <input name=\"all_files\" id=\"all_files\" type=\"checkbox\" />\n <label class=\"checkbox\" for=\"all_files\">Search all files</label>\n "])));
|
130
|
-
return this.renderSearchAllFiles ? controls : nothing;
|
131
|
-
}
|
132
|
-
get loadingIndicator() {
|
133
|
-
return html(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n <div class=\"loading\">\n <ia-activity-indicator mode=\"processing\"></ia-activity-indicator>\n <p>Searching</p>\n <button class=\"ia-button external cancel-search\" @click=", ">Cancel</button>\n </div>\n "])), this.cancelSearch);
|
134
|
-
}
|
135
|
-
get resultsSet() {
|
136
|
-
var resultsClass = this.displayResultImages ? 'show-image' : '';
|
137
|
-
return html(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n <ul class=\"results ", "\">\n ", "\n </ul>\n "])), resultsClass, this.results.map(match => html(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n <li @click=", ">\n ", "\n <h4>", "</h4>\n <p class=\"page-num\">Page ", "</p>\n <p>", "</p>\n </li>\n "])), this.selectResult.bind(this, match), match.cover ? html(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["<img src=\"", "\" />"])), match.cover) : nothing, match.title || nothing, match.displayPageNumber, unsafeHTML(match.html))));
|
138
|
-
}
|
139
|
-
get searchForm() {
|
140
|
-
return html(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n <form action=\"\" method=\"get\" @submit=", ">\n <fieldset>\n ", "\n <input\n type=\"search\"\n name=\"query\"\n alt=\"Search inside this book.\"\n @keyup=", "\n @search=", "\n .value=", "\n />\n </fieldset>\n </form>\n "])), this.performSearch, this.searchMultipleControls, this.setQuery, this.setQuery, this.query);
|
141
|
-
}
|
142
|
-
get setErrorMessage() {
|
143
|
-
return html(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n <p class=\"error-message\">", "</p>\n "])), this.errorMessage);
|
144
|
-
}
|
145
|
-
get searchCTA() {
|
146
|
-
return html(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["<p class=\"search-cta\"><em>Please enter text to search for</em></p>"])));
|
147
|
-
}
|
148
|
-
render() {
|
149
|
-
var showSearchCTA = !this.queryInProgress && !this.errorMessage && !this.queryInProgress && !this.results.length;
|
150
|
-
return html(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n ", "\n ", "\n <div class=\"results-container\">\n ", "\n ", "\n ", "\n ", "\n </div>\n "])), this.headerSection, this.searchForm, this.queryInProgress ? this.loadingIndicator : nothing, this.errorMessage ? this.setErrorMessage : nothing, this.results.length ? this.resultsSet : nothing, showSearchCTA ? this.searchCTA : nothing);
|
151
|
-
}
|
152
|
-
static get styles() {
|
153
|
-
var searchResultText = css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["var(--searchResultText, #adaedc)"])));
|
154
|
-
var searchResultBg = css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["var(--searchResultBg, #272958)"])));
|
155
|
-
var searchResultBorder = css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["var(--searchResultBorder, #adaedc)"])));
|
156
|
-
var activeButtonBg = css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["(--tertiaryBGColor, #333)"])));
|
157
|
-
var mainCSS = css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n :host {\n display: block;\n height: 100%;\n padding: 1.5rem 1rem 2rem 0;\n overflow-y: auto;\n font-size: 1.4rem;\n box-sizing: border-box;\n }\n\n mark {\n padding: 0 .2rem;\n color: ", ";\n background: ", ";\n border: 1px solid ", ";\n border-radius: 2px;\n }\n\n h3 {\n padding: 0;\n margin: 0 1rem 0 0;\n font-size: 2rem;\n }\n\n header {\n display: flex;\n align-items: center;\n padding: 0 2rem 0 0;\n }\n header p {\n padding: 0;\n margin: 0;\n font-size: 1.2rem;\n font-weight: bold;\n font-style: italic;\n }\n\n fieldset {\n padding: 0 0 1rem 0;\n border: none;\n }\n\n [type=\"checkbox\"] {\n display: none;\n }\n\n label {\n display: block;\n text-align: center;\n }\n\n label.checkbox {\n padding-bottom: .5rem;\n font-size: 1.6rem;\n line-height: 150%;\n vertical-align: middle;\n }\n\n label.checkbox:after {\n display: inline-block;\n width: 14px;\n height: 14px;\n margin-left: .7rem;\n content: \"\";\n border-radius: 2px;\n }\n :checked + label.checkbox:after {\n background-image: url('", "');\n }\n\n label.checkbox[for=\"all_files\"]:after {\n background: ", " 50% 50% no-repeat;\n border: 1px solid var(--primaryTextColor);\n }\n\n [type=\"search\"] {\n color: var(--primaryTextColor);\n border: 1px solid var(--primaryTextColor);\n -webkit-appearance: textfield;\n width: 100%;\n height: 3rem;\n padding: 0 1.5rem;\n box-sizing: border-box;\n font: normal 1.6rem \"Helvetica qNeue\", Helvetica, Arial, sans-serif;\n border-radius: 1.5rem;\n background: transparent;\n }\n [type=\"search\"]:focus {\n outline: none;\n }\n [type=\"search\"]::-webkit-search-cancel-button {\n width: 18px;\n height: 18px;\n -webkit-appearance: none;\n appearance: none;\n -webkit-mask: url('", "') 0 0 no-repeat;\n mask: url('", "') 0 0 no-repeat;\n -webkit-mask-size: 100%;\n mask-size: 100%;\n background: #fff;\n }\n\n p.page-num {\n font-weight: bold;\n padding-bottom: 0;\n }\n\n p.search-cta {\n text-align: center;\n }\n\n .results-container {\n padding-bottom: 2rem;\n }\n\n ul {\n padding: 0 0 2rem 0;\n margin: 0;\n list-style: none;\n }\n\n ul.show-image li {\n display: grid;\n }\n\n li {\n cursor: pointer;\n grid-template-columns: 30px 1fr;\n grid-gap: 0 .5rem;\n }\n\n li img {\n display: block;\n width: 100%;\n }\n\n li h4 {\n grid-column: 2 / 3;\n padding: 0 0 2rem 0;\n margin: 0;\n font-weight: normal;\n }\n\n li p {\n grid-column: 2 / 3;\n padding: 0 0 1.5rem 0;\n margin: 0;\n font-size: 1.2rem;\n }\n\n .loading {\n text-align: center;\n }\n\n .loading p {\n padding: 0 0 1rem 0;\n margin: 0;\n font-size: 1.2rem;\n }\n\n ia-activity-indicator {\n display: block;\n width: 40px;\n height: 40px;\n margin: 0 auto;\n }\n "])), searchResultText, searchResultBg, searchResultBorder, checkmarkIcon, activeButtonBg, closeIcon, closeIcon);
|
158
|
-
return [buttonCSS, mainCSS];
|
159
|
-
}
|
160
|
-
}
|
161
|
-
customElements.define('ia-book-search-results', IABookSearchResults);
|
@@ -1,26 +0,0 @@
|
|
1
|
-
var _templateObject, _templateObject2;
|
2
|
-
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
3
|
-
import { html } from 'lit';
|
4
|
-
import { iauxShareIcon } from '@internetarchive/ia-item-navigator/dist/src/menus/share-panel';
|
5
|
-
import '@internetarchive/ia-item-navigator/dist/src/menus/share-panel';
|
6
|
-
export default class SharingProvider {
|
7
|
-
constructor(_ref) {
|
8
|
-
var {
|
9
|
-
item,
|
10
|
-
baseHost,
|
11
|
-
bookreader
|
12
|
-
} = _ref;
|
13
|
-
var {
|
14
|
-
identifier,
|
15
|
-
creator,
|
16
|
-
title
|
17
|
-
} = item === null || item === void 0 ? void 0 : item.metadata;
|
18
|
-
var creatorToUse = Array.isArray(creator) ? creator[0] : creator;
|
19
|
-
var subPrefix = bookreader.options.subPrefix || '';
|
20
|
-
var label = "Share this book";
|
21
|
-
this.icon = html(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ""])), iauxShareIcon);
|
22
|
-
this.label = label;
|
23
|
-
this.id = 'share';
|
24
|
-
this.component = html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["<iaux-in-share-panel\n .identifier=", "\n .type=", "\n .creator=", "\n .description=", "\n .baseHost=", "\n .fileSubPrefix=", "\n ></iaux-in-share-panel>"])), identifier, "book", creatorToUse, title, baseHost, subPrefix);
|
25
|
-
}
|
26
|
-
}
|
@@ -1,94 +0,0 @@
|
|
1
|
-
var _templateObject;
|
2
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
3
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
4
|
-
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
5
|
-
import { html } from 'lit';
|
6
|
-
import { viewableFilesIcon } from '@internetarchive/ia-item-navigator/dist/src/menus/viewable-files';
|
7
|
-
import '@internetarchive/ia-item-navigator/dist/src/menus/viewable-files';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* * @typedef { 'title_asc' | 'title_desc' | 'default'} SortTypesT
|
11
|
-
*/
|
12
|
-
var sortTypes = {
|
13
|
-
title_asc: 'title_asc',
|
14
|
-
title_desc: 'title_desc',
|
15
|
-
default: 'default'
|
16
|
-
};
|
17
|
-
export default class ViewableFilesProvider {
|
18
|
-
/**
|
19
|
-
* @param {import('../BookReader').default} bookreader
|
20
|
-
*/
|
21
|
-
constructor(_ref) {
|
22
|
-
var {
|
23
|
-
baseHost,
|
24
|
-
bookreader,
|
25
|
-
onProviderChange
|
26
|
-
} = _ref;
|
27
|
-
/** @type {import('../BookReader').default} */
|
28
|
-
this.bookreader = bookreader;
|
29
|
-
this.onProviderChange = onProviderChange;
|
30
|
-
this.baseHost = baseHost;
|
31
|
-
var files = bookreader.options.multipleBooksList.by_subprefix;
|
32
|
-
this.viewableFiles = Object.keys(files).map(item => files[item]);
|
33
|
-
this.volumeCount = Object.keys(files).length;
|
34
|
-
this.id = "volumes";
|
35
|
-
this.label = "Viewable files (".concat(this.volumeCount, ")");
|
36
|
-
this.icon = html(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ""])), viewableFilesIcon);
|
37
|
-
this.sortOrderBy = sortTypes.default;
|
38
|
-
this.component = document.createElement("iaux-in-viewable-files-panel");
|
39
|
-
this.component.addSortToUrl = true;
|
40
|
-
this.component.subPrefix = bookreader.options.subPrefix || "";
|
41
|
-
this.component.baseHost = baseHost;
|
42
|
-
this.component.fileList = [...this.viewableFiles];
|
43
|
-
this.sortFilesComponent = document.createElement("iaux-in-sort-files-button");
|
44
|
-
this.sortFilesComponent.fileListRaw = this.viewableFiles;
|
45
|
-
this.sortFilesComponent.addEventListener('fileListSorted', e => this.handleFileListSorted(e));
|
46
|
-
this.actionButton = this.sortFilesComponent;
|
47
|
-
|
48
|
-
// get sort state from query param
|
49
|
-
if (this.bookreader.urlPlugin) {
|
50
|
-
this.bookreader.urlPlugin.pullFromAddressBar();
|
51
|
-
var urlSortValue = this.bookreader.urlPlugin.getUrlParam('sort');
|
52
|
-
if (urlSortValue === sortTypes.title_asc || urlSortValue === sortTypes.title_desc) {
|
53
|
-
this.sortOrderBy = urlSortValue;
|
54
|
-
}
|
55
|
-
}
|
56
|
-
this.sortFilesComponent.sortVolumes(this.sortOrderBy);
|
57
|
-
this.onProviderChange(this.bookreader);
|
58
|
-
}
|
59
|
-
|
60
|
-
/** @param { SortTypesT } sortType */
|
61
|
-
handleFileListSorted(event) {
|
62
|
-
var _this = this;
|
63
|
-
return _asyncToGenerator(function* () {
|
64
|
-
var {
|
65
|
-
sortType,
|
66
|
-
sortedFiles
|
67
|
-
} = event.detail;
|
68
|
-
_this.viewableFiles = sortedFiles;
|
69
|
-
_this.sortOrderBy = sortType;
|
70
|
-
|
71
|
-
// update the component
|
72
|
-
_this.component.fileList = [..._this.viewableFiles];
|
73
|
-
yield _this.component.updateComplete;
|
74
|
-
if (_this.bookreader.urlPlugin) {
|
75
|
-
_this.bookreader.urlPlugin.pullFromAddressBar();
|
76
|
-
if (_this.sortOrderBy !== sortTypes.default) {
|
77
|
-
_this.bookreader.urlPlugin.setUrlParam('sort', _this.sortOrderBy);
|
78
|
-
} else {
|
79
|
-
_this.bookreader.urlPlugin.removeUrlParam('sort');
|
80
|
-
}
|
81
|
-
}
|
82
|
-
_this.onProviderChange(_this.bookreader);
|
83
|
-
_this.multipleFilesClicked(_this.sortOrderBy);
|
84
|
-
})();
|
85
|
-
}
|
86
|
-
|
87
|
-
/**
|
88
|
-
* @param { SortTypesT } orderBy
|
89
|
-
*/
|
90
|
-
multipleFilesClicked(orderBy) {
|
91
|
-
var _window$archive_analy;
|
92
|
-
(_window$archive_analy = window.archive_analytics) === null || _window$archive_analy === void 0 || _window$archive_analy.send_event('BookReader', "VolumesSort|".concat(orderBy), window.location.path);
|
93
|
-
}
|
94
|
-
}
|