@internetarchive/bookreader 5.0.0-88-alpha.11 → 5.0.0-89
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 +17 -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.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +1 -1
- package/BookReader/plugins/plugin.iiif.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/CHANGELOG.md +14 -0
- package/babel.config.js +12 -30
- package/codecov.yml +1 -1
- package/jsconfig.json +1 -3
- package/package.json +14 -16
- package/src/BookNavigator/search/search-results.js +1 -1
- package/src/BookReader/ImageCache.js +48 -15
- package/src/BookReader/Mode1UpLit.js +56 -86
- package/src/BookReader/Mode2UpLit.js +5 -5
- package/src/BookReader/Navbar/Navbar.js +53 -11
- package/src/BookReader/PageContainer.js +41 -22
- package/src/BookReader/options.js +27 -3
- package/src/BookReader/utils.js +10 -0
- package/src/BookReader.js +120 -21
- package/src/BookReaderPlugin.js +44 -0
- package/src/css/_BRnav.scss +0 -3
- package/src/css/_BRpages.scss +21 -2
- package/src/css/_controls.scss +4 -0
- package/src/plugins/plugin.archive_analytics.js +84 -78
- package/src/plugins/plugin.autoplay.js +98 -102
- package/src/plugins/plugin.chapters.js +17 -22
- package/src/plugins/plugin.iiif.js +16 -30
- package/src/plugins/plugin.resume.js +54 -51
- package/src/plugins/plugin.text_selection.js +68 -76
- package/src/plugins/tts/AbstractTTSEngine.js +2 -4
- package/src/plugins/tts/PageChunk.js +5 -9
- package/src/plugins/tts/PageChunkIterator.js +3 -5
- package/src/plugins/tts/plugin.tts.js +309 -329
- package/src/plugins/url/plugin.url.js +1 -1
- package/src/util/strings.js +1 -0
- package/tests/e2e/autoplay.test.js +8 -5
- package/tests/e2e/helpers/base.js +2 -2
- package/tests/e2e/helpers/mockSearch.js +6 -9
- package/tests/jest/BookReader/Navbar/Navbar.test.js +16 -3
- package/tests/jest/BookReader/PageContainer.test.js +96 -55
- package/tests/jest/BookReader/utils.test.js +21 -0
- package/tests/jest/BookReader.test.js +13 -12
- package/tests/jest/plugins/plugin.archive_analytics.test.js +8 -11
- package/tests/jest/plugins/plugin.autoplay.test.js +9 -22
- package/tests/jest/plugins/plugin.resume.test.js +19 -32
- package/tests/jest/plugins/plugin.text_selection.test.js +23 -24
- 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 -1828
- 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,212 +0,0 @@
|
|
1
|
-
/* global BookReader */
|
2
|
-
|
3
|
-
import { UrlPlugin } from "./UrlPlugin";
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Plugin for URL management in BookReader
|
7
|
-
* Note read more about the url "fragment" here:
|
8
|
-
* https://openlibrary.org/dev/docs/bookurls
|
9
|
-
*/
|
10
|
-
|
11
|
-
jQuery.extend(BookReader.defaultOptions, {
|
12
|
-
enableUrlPlugin: true,
|
13
|
-
bookId: '',
|
14
|
-
/** @type {string} Defaults can be a urlFragment string */
|
15
|
-
defaults: null,
|
16
|
-
updateWindowTitle: false,
|
17
|
-
/** @type {'history' | 'hash'} */
|
18
|
-
urlMode: 'hash',
|
19
|
-
/**
|
20
|
-
* When using 'history' mode, this part of the URL is kept constant
|
21
|
-
* @example /details/plato/
|
22
|
-
*/
|
23
|
-
urlHistoryBasePath: '/',
|
24
|
-
/** Only these params will be reflected onto the URL */
|
25
|
-
urlTrackedParams: ['page', 'search', 'mode', 'region', 'highlight', 'view'],
|
26
|
-
/** If true, don't update the URL when `page == n0 (eg "/page/n0")` */
|
27
|
-
urlTrackIndex0: false
|
28
|
-
});
|
29
|
-
|
30
|
-
/** @override */
|
31
|
-
BookReader.prototype.setup = function (super_) {
|
32
|
-
return function (options) {
|
33
|
-
super_.call(this, options);
|
34
|
-
this.bookId = options.bookId;
|
35
|
-
this.defaults = options.defaults;
|
36
|
-
this.locationPollId = null;
|
37
|
-
this.oldLocationHash = null;
|
38
|
-
this.oldUserHash = null;
|
39
|
-
};
|
40
|
-
}(BookReader.prototype.setup);
|
41
|
-
|
42
|
-
/** @override */
|
43
|
-
BookReader.prototype.init = function (super_) {
|
44
|
-
return function () {
|
45
|
-
if (this.options.enableUrlPlugin) {
|
46
|
-
this.bind(BookReader.eventNames.PostInit, () => {
|
47
|
-
var {
|
48
|
-
updateWindowTitle,
|
49
|
-
urlMode
|
50
|
-
} = this.options;
|
51
|
-
if (updateWindowTitle) {
|
52
|
-
document.title = this.shortTitle(this.bookTitle, 50);
|
53
|
-
}
|
54
|
-
if (urlMode === 'hash') {
|
55
|
-
this.urlStartLocationPolling();
|
56
|
-
}
|
57
|
-
});
|
58
|
-
this.bind(BookReader.eventNames.fragmentChange, this.urlUpdateFragment.bind(this));
|
59
|
-
}
|
60
|
-
super_.call(this);
|
61
|
-
};
|
62
|
-
}(BookReader.prototype.init);
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Returns a shortened version of the title with the maximum number of characters
|
66
|
-
* @param {number} maximumCharacters
|
67
|
-
* @return {string}
|
68
|
-
*/
|
69
|
-
BookReader.prototype.shortTitle = function (maximumCharacters) {
|
70
|
-
if (this.bookTitle.length < maximumCharacters) {
|
71
|
-
return this.bookTitle;
|
72
|
-
}
|
73
|
-
var title = "".concat(this.bookTitle.substr(0, maximumCharacters - 3), "...");
|
74
|
-
return title;
|
75
|
-
};
|
76
|
-
|
77
|
-
/**
|
78
|
-
* Starts polling of window.location to see hash fragment changes
|
79
|
-
*/
|
80
|
-
BookReader.prototype.urlStartLocationPolling = function () {
|
81
|
-
this.oldLocationHash = this.urlReadFragment();
|
82
|
-
if (this.locationPollId) {
|
83
|
-
clearInterval(this.locationPollId);
|
84
|
-
this.locationPollId = null;
|
85
|
-
}
|
86
|
-
var updateHash = () => {
|
87
|
-
var newFragment = this.urlReadFragment();
|
88
|
-
var hasFragmentChange = newFragment != this.oldLocationHash && newFragment != this.oldUserHash;
|
89
|
-
if (!hasFragmentChange) {
|
90
|
-
return;
|
91
|
-
}
|
92
|
-
var params = this.paramsFromFragment(newFragment);
|
93
|
-
var updateParams = () => this.updateFromParams(params);
|
94
|
-
this.trigger(BookReader.eventNames.stop);
|
95
|
-
if (this.animating) {
|
96
|
-
// Queue change if animating
|
97
|
-
if (this.autoStop) this.autoStop();
|
98
|
-
this.animationFinishedCallback = updateParams;
|
99
|
-
} else {
|
100
|
-
// update immediately
|
101
|
-
updateParams();
|
102
|
-
}
|
103
|
-
this.oldUserHash = newFragment;
|
104
|
-
};
|
105
|
-
this.locationPollId = setInterval(updateHash, 500);
|
106
|
-
};
|
107
|
-
|
108
|
-
/**
|
109
|
-
* Update URL from the current parameters.
|
110
|
-
* Call this instead of manually using window.location.replace
|
111
|
-
*/
|
112
|
-
BookReader.prototype.urlUpdateFragment = function () {
|
113
|
-
var allParams = this.paramsFromCurrent();
|
114
|
-
var {
|
115
|
-
urlTrackIndex0,
|
116
|
-
urlTrackedParams
|
117
|
-
} = this.options;
|
118
|
-
if (!urlTrackIndex0 && typeof allParams.index !== 'undefined' && allParams.index === 0) {
|
119
|
-
delete allParams.index;
|
120
|
-
delete allParams.page;
|
121
|
-
}
|
122
|
-
var params = urlTrackedParams.reduce((validParams, paramName) => {
|
123
|
-
if (paramName in allParams) {
|
124
|
-
validParams[paramName] = allParams[paramName];
|
125
|
-
}
|
126
|
-
return validParams;
|
127
|
-
}, {});
|
128
|
-
var newFragment = this.fragmentFromParams(params, this.options.urlMode);
|
129
|
-
var currFragment = this.urlReadFragment();
|
130
|
-
var currQueryString = this.getLocationSearch();
|
131
|
-
var newQueryString = this.queryStringFromParams(params, currQueryString, this.options.urlMode);
|
132
|
-
if (currFragment === newFragment && currQueryString === newQueryString) {
|
133
|
-
return;
|
134
|
-
}
|
135
|
-
if (this.options.urlMode === 'history') {
|
136
|
-
if (!window.history || !window.history.replaceState) {
|
137
|
-
this.options.urlMode = 'hash';
|
138
|
-
} else {
|
139
|
-
var baseWithoutSlash = this.options.urlHistoryBasePath.replace(/\/+$/, '');
|
140
|
-
var newFragmentWithSlash = newFragment === '' ? '' : "/".concat(newFragment);
|
141
|
-
var newUrlPath = "".concat(baseWithoutSlash).concat(newFragmentWithSlash).concat(newQueryString);
|
142
|
-
try {
|
143
|
-
window.history.replaceState({}, null, newUrlPath);
|
144
|
-
this.oldLocationHash = newFragment + newQueryString;
|
145
|
-
} catch (e) {
|
146
|
-
// DOMException on Chrome when in sandboxed iframe
|
147
|
-
this.options.urlMode = 'hash';
|
148
|
-
}
|
149
|
-
}
|
150
|
-
}
|
151
|
-
if (this.options.urlMode === 'hash') {
|
152
|
-
var newQueryStringSearch = this.urlParamsFiltersOnlySearch(this.readQueryString());
|
153
|
-
window.location.replace('#' + newFragment + newQueryStringSearch);
|
154
|
-
this.oldLocationHash = newFragment + newQueryStringSearch;
|
155
|
-
}
|
156
|
-
};
|
157
|
-
|
158
|
-
/**
|
159
|
-
* @private
|
160
|
-
* Filtering query parameters to select only book search param (?q=foo)
|
161
|
-
This needs to be updated/URL system modified if future query params are to be added
|
162
|
-
* @param {string} url
|
163
|
-
* @return {string}
|
164
|
-
* */
|
165
|
-
BookReader.prototype.urlParamsFiltersOnlySearch = function (url) {
|
166
|
-
var params = new URLSearchParams(url);
|
167
|
-
return params.has('q') ? "?".concat(new URLSearchParams({
|
168
|
-
q: params.get('q')
|
169
|
-
})) : '';
|
170
|
-
};
|
171
|
-
|
172
|
-
/**
|
173
|
-
* Will read either the hash or URL and return the bookreader fragment
|
174
|
-
* @return {string}
|
175
|
-
*/
|
176
|
-
BookReader.prototype.urlReadFragment = function () {
|
177
|
-
var {
|
178
|
-
urlMode,
|
179
|
-
urlHistoryBasePath
|
180
|
-
} = this.options;
|
181
|
-
if (urlMode === 'history') {
|
182
|
-
return window.location.pathname.substr(urlHistoryBasePath.length);
|
183
|
-
} else {
|
184
|
-
return window.location.hash.substr(1);
|
185
|
-
}
|
186
|
-
};
|
187
|
-
|
188
|
-
/**
|
189
|
-
* Will read the hash return the bookreader fragment
|
190
|
-
* @return {string}
|
191
|
-
*/
|
192
|
-
BookReader.prototype.urlReadHashFragment = function () {
|
193
|
-
return window.location.hash.substr(1);
|
194
|
-
};
|
195
|
-
export class BookreaderUrlPlugin extends BookReader {
|
196
|
-
init() {
|
197
|
-
if (this.options.enableUrlPlugin) {
|
198
|
-
this.urlPlugin = new UrlPlugin(this.options);
|
199
|
-
this.bind(BookReader.eventNames.PostInit, () => {
|
200
|
-
var {
|
201
|
-
urlMode
|
202
|
-
} = this.options;
|
203
|
-
if (urlMode === 'hash') {
|
204
|
-
this.urlPlugin.listenForHashChanges();
|
205
|
-
}
|
206
|
-
});
|
207
|
-
}
|
208
|
-
super.init();
|
209
|
-
}
|
210
|
-
}
|
211
|
-
window.BookReader = BookreaderUrlPlugin;
|
212
|
-
export default BookreaderUrlPlugin;
|
@@ -1,56 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Checks whether the current browser is a Chrome/Chromium browser
|
3
|
-
* Code from https://stackoverflow.com/a/4565120/2317712
|
4
|
-
* @param {string} [userAgent]
|
5
|
-
* @param {string} [vendor]
|
6
|
-
* @return {boolean}
|
7
|
-
*/
|
8
|
-
export function isChrome() {
|
9
|
-
var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : navigator.userAgent;
|
10
|
-
var vendor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : navigator.vendor;
|
11
|
-
return /chrome/i.test(userAgent) && /google inc/i.test(vendor);
|
12
|
-
}
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Checks whether the current browser is firefox
|
16
|
-
* @param {string} [userAgent]
|
17
|
-
* @return {boolean}
|
18
|
-
*/
|
19
|
-
export function isFirefox() {
|
20
|
-
var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : navigator.userAgent;
|
21
|
-
return /firefox/i.test(userAgent);
|
22
|
-
}
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Checks whether the current browser is safari
|
26
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Browser_Name
|
27
|
-
* @param {string} [userAgent]
|
28
|
-
* @return {boolean}
|
29
|
-
*/
|
30
|
-
export function isSafari() {
|
31
|
-
var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : navigator.userAgent;
|
32
|
-
return /safari/i.test(userAgent) && !/chrome|chromium/i.test(userAgent);
|
33
|
-
}
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Checks whether the current browser is iOS (and hence iOS webkit)
|
37
|
-
* @return {boolean}
|
38
|
-
*/
|
39
|
-
export function isIOS() {
|
40
|
-
// We can't just check the userAgent because as of iOS 13,
|
41
|
-
// the userAgent is the same as desktop Safari because
|
42
|
-
// they wanted iPad's to be served the same version of websites
|
43
|
-
// as desktops.
|
44
|
-
return 'ongesturestart' in window && navigator.maxTouchPoints > 0;
|
45
|
-
}
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Checks whether the current browser is Samsung Internet
|
49
|
-
* https://stackoverflow.com/a/40684162/2317712
|
50
|
-
* @param {string} [userAgent]
|
51
|
-
* @return {boolean}
|
52
|
-
*/
|
53
|
-
export function isSamsungInternet() {
|
54
|
-
var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : navigator.userAgent;
|
55
|
-
return /SamsungBrowser/i.test(userAgent);
|
56
|
-
}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Wait until some time has passed before executing a callback.
|
3
|
-
*
|
4
|
-
* @param {Function} callback
|
5
|
-
* @param {Number} threshhold - in milliseconds
|
6
|
-
* @param {*} context - will be bound to callback as its "this" value
|
7
|
-
*/
|
8
|
-
class Debouncer {
|
9
|
-
constructor(callback) {
|
10
|
-
var threshhold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
11
|
-
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
12
|
-
this.callback = callback;
|
13
|
-
this.threshhold = threshhold;
|
14
|
-
this.context = context;
|
15
|
-
this.deferTimeout = undefined;
|
16
|
-
}
|
17
|
-
execute() {
|
18
|
-
clearTimeout(this.deferTimeout);
|
19
|
-
this.deferTimeout = setTimeout(this.executeCallback.bind(this), this.threshhold);
|
20
|
-
}
|
21
|
-
executeCallback() {
|
22
|
-
this.callback.apply(this.context);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
export { Debouncer as default };
|
@@ -1,75 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Helper module use to get, set and remove item from cookie
|
3
|
-
*
|
4
|
-
* See more:
|
5
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
|
6
|
-
* https://developer.mozilla.org/User:fusionchess
|
7
|
-
* https://github.com/madmurphy/cookies.js
|
8
|
-
* This framework is released under the GNU Public License, version 3 or later.
|
9
|
-
* http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
10
|
-
*/
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Check to see if the browser has cookies enabled.
|
14
|
-
* Accessing document.cookies errors if eg iframe with sandbox enabled.
|
15
|
-
* @returns {boolean}
|
16
|
-
*/
|
17
|
-
export function areCookiesBlocked() {
|
18
|
-
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
19
|
-
try {
|
20
|
-
doc.cookie;
|
21
|
-
return false;
|
22
|
-
} catch (e) {
|
23
|
-
return true;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
var COOKIES_BLOCKED = areCookiesBlocked();
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Get specific key's value stored in cookie
|
30
|
-
*
|
31
|
-
* @param {string} sKey
|
32
|
-
*
|
33
|
-
* @returns {string|null}
|
34
|
-
*/
|
35
|
-
export function getItem(sKey) {
|
36
|
-
if (COOKIES_BLOCKED || !sKey) return null;
|
37
|
-
return decodeURIComponent(
|
38
|
-
// eslint-disable-next-line no-useless-escape
|
39
|
-
document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
|
40
|
-
}
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Set specific key's value in cookie
|
44
|
-
*
|
45
|
-
* @param {string} sKey cookie name
|
46
|
-
* @param {string} sValue cookie value
|
47
|
-
* @param {string} [vEnd] expire|max-age
|
48
|
-
* @param {string} [sPath] path of current item
|
49
|
-
* @param {string} [sDomain] domain name
|
50
|
-
* @param {boolean} [bSecure]
|
51
|
-
*
|
52
|
-
* @returns {boolean}
|
53
|
-
*/
|
54
|
-
export function setItem(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
|
55
|
-
if (COOKIES_BLOCKED) return false;
|
56
|
-
document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + (vEnd ? "; expires=".concat(vEnd.toUTCString()) : '') + (sDomain ? "; domain=".concat(sDomain) : '') + (sPath ? "; path=".concat(sPath) : '') + (bSecure ? "; secure" : '');
|
57
|
-
return true;
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* BROKEN Remove specific key's value from cookie
|
62
|
-
* @fixme hasItem isn't even implemented! This will always error.
|
63
|
-
* @param {string} sKey cookie name
|
64
|
-
* @param {string} [sPath] path of current item
|
65
|
-
* @param {string} [sDomain]
|
66
|
-
*
|
67
|
-
* @returns {boolean}
|
68
|
-
*/
|
69
|
-
export function removeItem(sKey, sPath, sDomain) {
|
70
|
-
if (COOKIES_BLOCKED) return false;
|
71
|
-
// eslint-disable-next-line
|
72
|
-
if (!hasItem(sKey)) return false;
|
73
|
-
document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=".concat(sDomain) : '') + (sPath ? "; path=".concat(sPath) : '');
|
74
|
-
return true;
|
75
|
-
}
|
package/dist/esm/util/strings.js
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @typedef {String} StringWithVars
|
3
|
-
* A template string with {{foo}} style variables
|
4
|
-
* Also supports filters, like {{bookPath|urlencode}} (See APPLY_FILTERS for the
|
5
|
-
* supported list of filters)
|
6
|
-
**/
|
7
|
-
|
8
|
-
/**
|
9
|
-
* @param {StringWithVars|String} template
|
10
|
-
* @param { {[varName: string]: { toString: () => string} } } vars
|
11
|
-
* @param { {[varName: string]: { toString: () => string} } } [overrides]
|
12
|
-
*/
|
13
|
-
export function applyVariables(template, vars) {
|
14
|
-
var overrides = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
15
|
-
var possibleFilters = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : APPLY_FILTERS;
|
16
|
-
return template === null || template === void 0 ? void 0 : template.replace(/\{\{([^}]*?)\}\}/g, ($0, $1) => {
|
17
|
-
if (!$1) return $0;
|
18
|
-
/** @type {string} */
|
19
|
-
var expression = $1;
|
20
|
-
var [varName, ...filterNames] = expression.split('|').map(x => x.trim());
|
21
|
-
var defined = varName in overrides || varName in vars;
|
22
|
-
|
23
|
-
// If it's not defined, don't expand it at all
|
24
|
-
if (!defined) return $0;
|
25
|
-
var value = varName in overrides ? overrides[varName] : varName in vars ? vars[varName] : null;
|
26
|
-
var filters = filterNames.map(n => possibleFilters[n]);
|
27
|
-
return filters.reduce((acc, cur) => cur(acc), value && value.toString());
|
28
|
-
});
|
29
|
-
}
|
30
|
-
|
31
|
-
/** @type { {[filterName: String]:( string => string)} } */
|
32
|
-
export var APPLY_FILTERS = {
|
33
|
-
urlencode: encodeURIComponent
|
34
|
-
};
|
package/index.js
DELETED