@internetarchive/bookreader 5.0.0-38 → 5.0.0-39
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.css +8 -0
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +99 -75
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/CHANGELOG.md +5 -0
- package/README.md +13 -0
- package/package.json +14 -14
- package/renovate.json +1 -1
- package/src/BookReader/Mode1UpLit.js +7 -1
- package/src/BookReader/Mode2Up.js +11 -0
- package/src/BookReader/ModeSmoothZoom.js +2 -0
- package/src/BookReader/PageContainer.js +10 -4
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/css/_TextSelection.scss +13 -0
- package/tests/jest/BookReader/PageContainer.test.js +5 -4
- package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/.husky/_/husky.sh +0 -30
- package/stat/BookNavigator/BookModel.js +0 -14
- package/stat/BookNavigator/BookNavigator.js +0 -524
- package/stat/BookNavigator/assets/bookmark-colors.js +0 -15
- package/stat/BookNavigator/assets/button-base.js +0 -61
- package/stat/BookNavigator/assets/ia-logo.js +0 -17
- package/stat/BookNavigator/assets/icon_checkmark.js +0 -6
- package/stat/BookNavigator/assets/icon_close.js +0 -3
- package/stat/BookNavigator/assets/icon_sort_asc.js +0 -5
- package/stat/BookNavigator/assets/icon_sort_desc.js +0 -5
- package/stat/BookNavigator/assets/icon_sort_neutral.js +0 -5
- package/stat/BookNavigator/assets/icon_volumes.js +0 -11
- package/stat/BookNavigator/bookmarks/bookmark-button.js +0 -64
- package/stat/BookNavigator/bookmarks/bookmark-edit.js +0 -215
- package/stat/BookNavigator/bookmarks/bookmarks-list.js +0 -285
- package/stat/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -28
- package/stat/BookNavigator/bookmarks/bookmarks-provider.js +0 -56
- package/stat/BookNavigator/bookmarks/ia-bookmarks.js +0 -523
- package/stat/BookNavigator/br-fullscreen-mgr.js +0 -82
- package/stat/BookNavigator/delete-modal-actions.js +0 -49
- package/stat/BookNavigator/downloads/downloads-provider.js +0 -72
- package/stat/BookNavigator/downloads/downloads.js +0 -139
- package/stat/BookNavigator/provider-config.js +0 -0
- package/stat/BookNavigator/search/a-search-result.js +0 -55
- package/stat/BookNavigator/search/search-provider.js +0 -180
- package/stat/BookNavigator/search/search-results.js +0 -360
- package/stat/BookNavigator/sharing.js +0 -31
- package/stat/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -94
- package/stat/BookNavigator/visual-adjustments/visual-adjustments.js +0 -280
- package/stat/BookNavigator/volumes/volumes-provider.js +0 -83
- package/stat/BookNavigator/volumes/volumes.js +0 -178
- package/stat/BookReader/BookModel.js +0 -518
- package/stat/BookReader/DebugConsole.js +0 -54
- package/stat/BookReader/DragScrollable.js +0 -233
- package/stat/BookReader/ImageCache.js +0 -116
- package/stat/BookReader/Mode1Up.js +0 -102
- package/stat/BookReader/Mode1UpLit.js +0 -434
- package/stat/BookReader/Mode2Up.js +0 -1372
- package/stat/BookReader/ModeSmoothZoom.js +0 -177
- package/stat/BookReader/ModeThumb.js +0 -344
- package/stat/BookReader/Navbar/Navbar.js +0 -310
- package/stat/BookReader/PageContainer.js +0 -120
- package/stat/BookReader/ReduceSet.js +0 -26
- package/stat/BookReader/Toolbar/Toolbar.js +0 -384
- package/stat/BookReader/events.js +0 -20
- package/stat/BookReader/options.js +0 -324
- package/stat/BookReader/utils/HTMLDimensionsCacher.js +0 -44
- package/stat/BookReader/utils/classes.js +0 -36
- package/stat/BookReader/utils.js +0 -240
- package/stat/BookReader.js +0 -2550
- package/stat/BookReaderComponent/BookReaderComponent.js +0 -117
- package/stat/assets/icons/1up.svg +0 -12
- package/stat/assets/icons/2up.svg +0 -15
- package/stat/assets/icons/advance.svg +0 -26
- package/stat/assets/icons/chevron-right.svg +0 -1
- package/stat/assets/icons/close-circle-dark.svg +0 -1
- package/stat/assets/icons/close-circle.svg +0 -1
- package/stat/assets/icons/fullscreen.svg +0 -17
- package/stat/assets/icons/fullscreen_exit.svg +0 -17
- package/stat/assets/icons/hamburger.svg +0 -15
- package/stat/assets/icons/left-arrow.svg +0 -12
- package/stat/assets/icons/magnify-minus.svg +0 -16
- package/stat/assets/icons/magnify-plus.svg +0 -17
- package/stat/assets/icons/magnify.svg +0 -15
- package/stat/assets/icons/pause.svg +0 -23
- package/stat/assets/icons/play.svg +0 -22
- package/stat/assets/icons/playback-speed.svg +0 -34
- package/stat/assets/icons/read-aloud.svg +0 -22
- package/stat/assets/icons/review.svg +0 -22
- package/stat/assets/icons/thumbnails.svg +0 -17
- package/stat/assets/icons/voice.svg +0 -1
- package/stat/assets/icons/volume-full.svg +0 -22
- package/stat/assets/images/BRicons.png +0 -0
- package/stat/assets/images/BRicons.svg +0 -94
- package/stat/assets/images/BRicons_ia.png +0 -0
- package/stat/assets/images/back_pages.png +0 -0
- package/stat/assets/images/book_bottom_icon.png +0 -0
- package/stat/assets/images/book_down_icon.png +0 -0
- package/stat/assets/images/book_left_icon.png +0 -0
- package/stat/assets/images/book_leftmost_icon.png +0 -0
- package/stat/assets/images/book_right_icon.png +0 -0
- package/stat/assets/images/book_rightmost_icon.png +0 -0
- package/stat/assets/images/book_top_icon.png +0 -0
- package/stat/assets/images/book_up_icon.png +0 -0
- package/stat/assets/images/books_graphic.svg +0 -177
- package/stat/assets/images/booksplit.png +0 -0
- package/stat/assets/images/control_pause_icon.png +0 -0
- package/stat/assets/images/control_play_icon.png +0 -0
- package/stat/assets/images/embed_icon.png +0 -0
- package/stat/assets/images/icon-home-ia.png +0 -0
- package/stat/assets/images/icon_OL-logo-xs.png +0 -0
- package/stat/assets/images/icon_alert-xs.png +0 -0
- package/stat/assets/images/icon_book.svg +0 -12
- package/stat/assets/images/icon_bookmark.svg +0 -12
- package/stat/assets/images/icon_close-pop.png +0 -0
- package/stat/assets/images/icon_download.png +0 -0
- package/stat/assets/images/icon_gear.svg +0 -14
- package/stat/assets/images/icon_hamburger.svg +0 -20
- package/stat/assets/images/icon_home.png +0 -0
- package/stat/assets/images/icon_home.svg +0 -21
- package/stat/assets/images/icon_home_ia.png +0 -0
- package/stat/assets/images/icon_indicator.png +0 -0
- package/stat/assets/images/icon_info.svg +0 -11
- package/stat/assets/images/icon_one_page.svg +0 -8
- package/stat/assets/images/icon_pause.svg +0 -1
- package/stat/assets/images/icon_play.svg +0 -1
- package/stat/assets/images/icon_playback-rate.svg +0 -15
- package/stat/assets/images/icon_return.png +0 -0
- package/stat/assets/images/icon_search_button.svg +0 -8
- package/stat/assets/images/icon_share.svg +0 -9
- package/stat/assets/images/icon_skip-ahead.svg +0 -6
- package/stat/assets/images/icon_skip-back.svg +0 -13
- package/stat/assets/images/icon_speaker.svg +0 -18
- package/stat/assets/images/icon_speaker_open.svg +0 -10
- package/stat/assets/images/icon_thumbnails.svg +0 -12
- package/stat/assets/images/icon_toc.svg +0 -5
- package/stat/assets/images/icon_two_pages.svg +0 -9
- package/stat/assets/images/icon_zoomer.png +0 -0
- package/stat/assets/images/loading.gif +0 -0
- package/stat/assets/images/logo_icon.png +0 -0
- package/stat/assets/images/marker_chap-off.png +0 -0
- package/stat/assets/images/marker_chap-off.svg +0 -11
- package/stat/assets/images/marker_chap-off_ia.png +0 -0
- package/stat/assets/images/marker_chap-on.png +0 -0
- package/stat/assets/images/marker_chap-on.svg +0 -11
- package/stat/assets/images/marker_srch-on.svg +0 -11
- package/stat/assets/images/marker_srchchap-off.png +0 -0
- package/stat/assets/images/marker_srchchap-on.png +0 -0
- package/stat/assets/images/nav_control-dn.png +0 -0
- package/stat/assets/images/nav_control-dn_ia.png +0 -0
- package/stat/assets/images/nav_control-up.png +0 -0
- package/stat/assets/images/nav_control-up_ia.png +0 -0
- package/stat/assets/images/nav_control.png +0 -0
- package/stat/assets/images/one_page_mode_icon.png +0 -0
- package/stat/assets/images/paper-badge.png +0 -0
- package/stat/assets/images/print_icon.png +0 -0
- package/stat/assets/images/progressbar.gif +0 -0
- package/stat/assets/images/right_edges.png +0 -0
- package/stat/assets/images/slider.png +0 -0
- package/stat/assets/images/slider_ia.png +0 -0
- package/stat/assets/images/thumbnail_mode_icon.png +0 -0
- package/stat/assets/images/transparent.png +0 -0
- package/stat/assets/images/two_page_mode_icon.png +0 -0
- package/stat/assets/images/zoom_in_icon.png +0 -0
- package/stat/assets/images/zoom_out_icon.png +0 -0
- package/stat/css/BookReader.scss +0 -89
- package/stat/css/_BRBookmarks.scss +0 -29
- package/stat/css/_BRComponent.scss +0 -13
- package/stat/css/_BRfloat.scss +0 -197
- package/stat/css/_BRicon.scss +0 -48
- package/stat/css/_BRmain.scss +0 -251
- package/stat/css/_BRnav.scss +0 -359
- package/stat/css/_BRpages.scss +0 -139
- package/stat/css/_BRsearch.scss +0 -226
- package/stat/css/_BRtoolbar.scss +0 -84
- package/stat/css/_BRvendor.scss +0 -5
- package/stat/css/_MobileNav.scss +0 -194
- package/stat/css/_TextSelection.scss +0 -32
- package/stat/css/_colorbox.scss +0 -52
- package/stat/css/_controls.scss +0 -253
- package/stat/css/_icons.scss +0 -121
- package/stat/jquery-wrapper.js +0 -4
- package/stat/plugins/plugin.archive_analytics.js +0 -86
- package/stat/plugins/plugin.autoplay.js +0 -129
- package/stat/plugins/plugin.chapters.js +0 -248
- package/stat/plugins/plugin.iframe.js +0 -48
- package/stat/plugins/plugin.mobile_nav.js +0 -288
- package/stat/plugins/plugin.resume.js +0 -68
- package/stat/plugins/plugin.text_selection.js +0 -291
- package/stat/plugins/plugin.url.js +0 -198
- package/stat/plugins/plugin.vendor-fullscreen.js +0 -247
- package/stat/plugins/search/plugin.search.js +0 -439
- package/stat/plugins/search/view.js +0 -439
- package/stat/plugins/tts/AbstractTTSEngine.js +0 -249
- package/stat/plugins/tts/FestivalTTSEngine.js +0 -169
- package/stat/plugins/tts/PageChunk.js +0 -107
- package/stat/plugins/tts/PageChunkIterator.js +0 -163
- package/stat/plugins/tts/WebTTSEngine.js +0 -357
- package/stat/plugins/tts/plugin.tts.js +0 -357
- package/stat/plugins/tts/tooltip_dict.js +0 -15
- package/stat/plugins/tts/utils.js +0 -91
- package/stat/util/browserSniffing.js +0 -30
- package/stat/util/debouncer.js +0 -26
- package/stat/util/docCookies.js +0 -67
- package/stat/util/strings.js +0 -34
@@ -1,248 +0,0 @@
|
|
1
|
-
/* global BookReader */
|
2
|
-
/**
|
3
|
-
* Plugin for chapter markers in BookReader. Fetches from openlibrary.org
|
4
|
-
* Could be forked, or extended to alter behavior
|
5
|
-
*/
|
6
|
-
|
7
|
-
jQuery.extend(BookReader.defaultOptions, {
|
8
|
-
olHost: 'https://openlibrary.org',
|
9
|
-
enableChaptersPlugin: true,
|
10
|
-
bookId: '',
|
11
|
-
});
|
12
|
-
|
13
|
-
/** @override Extend the constructor to add search properties */
|
14
|
-
BookReader.prototype.setup = (function (super_) {
|
15
|
-
return function (options) {
|
16
|
-
super_.call(this, options);
|
17
|
-
|
18
|
-
this.olHost = options.olHost;
|
19
|
-
this.enableChaptersPlugin = options.enableChaptersPlugin;
|
20
|
-
this.bookId = options.bookId;
|
21
|
-
};
|
22
|
-
})(BookReader.prototype.setup);
|
23
|
-
|
24
|
-
/** @override Extend to call Open Library for TOC */
|
25
|
-
BookReader.prototype.init = (function(super_) {
|
26
|
-
return function() {
|
27
|
-
super_.call(this);
|
28
|
-
if (this.enableChaptersPlugin && this.ui !== 'embed') {
|
29
|
-
this.getOpenLibraryRecord();
|
30
|
-
}
|
31
|
-
if (this.enableMobileNav) {
|
32
|
-
this.bind(BookReader.eventNames.mobileNavOpen,
|
33
|
-
() => {
|
34
|
-
this.updateTOCState(this.firstIndex, this._tocEntries);
|
35
|
-
if ($('table-contents-list').parent().hasClass('mm-opened')) {
|
36
|
-
this.updateTOCState(this.firstIndex, this._tocEntries);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
);
|
40
|
-
$(".BRmobileMenu__tableContents").on("click", () => {
|
41
|
-
this.updateTOCState(this.firstIndex, this._tocEntries);
|
42
|
-
});
|
43
|
-
}
|
44
|
-
};
|
45
|
-
})(BookReader.prototype.init);
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Adds chapter marker to navigation scrubber
|
49
|
-
*
|
50
|
-
* @param {string} chapterTitle
|
51
|
-
* @param {string} pageNumber
|
52
|
-
* @param {number} pageIndex
|
53
|
-
*/
|
54
|
-
BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex) {
|
55
|
-
const uiStringPage = 'Page'; // i18n
|
56
|
-
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.getNumLeafs() - 1);
|
57
|
-
const jumpToChapter = (event) => {
|
58
|
-
this.jumpToIndex($(event.delegateTarget).data('pageIndex'));
|
59
|
-
$('.current-chapter').removeClass('current-chapter');
|
60
|
-
$(event.delegateTarget).addClass('current-chapter');
|
61
|
-
};
|
62
|
-
const title = `${chapterTitle} | `;
|
63
|
-
const pageStr = `${uiStringPage} ${pageNumber}`;
|
64
|
-
|
65
|
-
//adding items to mobile table of contents
|
66
|
-
const mobileChapter = $(`<li></li>`).append($(`<span class='BRTOCElementTitle'></span>`).text(title))
|
67
|
-
.append($(`<span class='BRTOCElementPage'></span>`).text(pageStr));
|
68
|
-
mobileChapter.addClass('BRtable-contents-el')
|
69
|
-
.appendTo(this.$('.table-contents-list'))
|
70
|
-
.data({ pageIndex });
|
71
|
-
|
72
|
-
//adds .BRchapters to the slider only if pageIndex exists
|
73
|
-
if (pageIndex != undefined) {
|
74
|
-
$(`<div></div>`)
|
75
|
-
.append($('<div />').text(title + pageStr))
|
76
|
-
.addClass('BRchapter')
|
77
|
-
.css({ left: percentThrough })
|
78
|
-
.appendTo(this.$('.BRnavline'))
|
79
|
-
.data({ pageIndex })
|
80
|
-
.on("mouseenter", event => {
|
81
|
-
// remove hover effect from other markers then turn on just for this
|
82
|
-
const marker = event.currentTarget;
|
83
|
-
const tooltip = marker.querySelector('div');
|
84
|
-
const tooltipOffset = tooltip.getBoundingClientRect();
|
85
|
-
const targetOffset = marker.getBoundingClientRect();
|
86
|
-
const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;
|
87
|
-
if (tooltipOffset.x - boxSizeAdjust < 0) {
|
88
|
-
tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);
|
89
|
-
}
|
90
|
-
this.$('.BRsearch,.BRchapter').removeClass('front');
|
91
|
-
$(event.target).addClass('front');
|
92
|
-
})
|
93
|
-
.on("mouseleave", event => $(event.target).removeClass('front'))
|
94
|
-
.on('click', jumpToChapter);
|
95
|
-
|
96
|
-
//adding clickable properties to mobile chapters
|
97
|
-
mobileChapter.bind('click', jumpToChapter)
|
98
|
-
.addClass('chapter-clickable')
|
99
|
-
.attr("data-event-click-tracking","BRTOCPanel|GoToChapter");
|
100
|
-
}
|
101
|
-
|
102
|
-
};
|
103
|
-
|
104
|
-
/*
|
105
|
-
* Remove all chapters.
|
106
|
-
*/
|
107
|
-
BookReader.prototype.removeChapters = function() {
|
108
|
-
this.$('.BRnavpos .BRchapter').remove();
|
109
|
-
};
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Update the table of contents based on array of TOC entries.
|
113
|
-
* @param {TocEntry[]} tocEntries
|
114
|
-
*/
|
115
|
-
BookReader.prototype.updateTOC = function(tocEntries) {
|
116
|
-
this.removeChapters();
|
117
|
-
if (this.enableMobileNav && tocEntries.length > 0) {
|
118
|
-
this.$(".BRmobileMenu__tableContents").show();
|
119
|
-
}
|
120
|
-
for (let i = 0; i < tocEntries.length; i++) {
|
121
|
-
this.addChapterFromEntry(tocEntries[i]);
|
122
|
-
}
|
123
|
-
this._tocEntries = tocEntries;
|
124
|
-
$('.table-contents-list').children().each((i, el) => {
|
125
|
-
tocEntries[i].mobileHTML = el;
|
126
|
-
});
|
127
|
-
};
|
128
|
-
|
129
|
-
/**
|
130
|
-
* @typedef {Object} TocEntry
|
131
|
-
* Table of contents entry as defined -- format is defined by Open Library
|
132
|
-
* @property {string} pagenum
|
133
|
-
* @property {number} level
|
134
|
-
* @property {string} label
|
135
|
-
* @property {{type: '/type/toc_item'}} type
|
136
|
-
* @property {string} title
|
137
|
-
* @property {HTMLElement} mobileHTML
|
138
|
-
* @property {number} pageIndex
|
139
|
-
|
140
|
-
*
|
141
|
-
* @example {
|
142
|
-
* "pagenum": "17",
|
143
|
-
* "level": 1,
|
144
|
-
* "label": "CHAPTER I",
|
145
|
-
* "type": {"key": "/type/toc_item"},
|
146
|
-
* "title": "THE COUNTRY AND THE MISSION"
|
147
|
-
* }
|
148
|
-
*/
|
149
|
-
|
150
|
-
/**
|
151
|
-
* @param {TocEntry} tocEntryObject
|
152
|
-
*/
|
153
|
-
BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
154
|
-
tocEntryObject.pageIndex = this.getPageIndex(tocEntryObject['pagenum']);
|
155
|
-
//creates a string with non-void tocEntryObject.label and tocEntryObject.title
|
156
|
-
const chapterStr = [tocEntryObject.label, tocEntryObject.title]
|
157
|
-
.filter(x => x)
|
158
|
-
.join(' ');
|
159
|
-
this.addChapter(chapterStr, tocEntryObject['pagenum'], tocEntryObject.pageIndex);
|
160
|
-
this.$('.BRchapter, .BRsearch').each((i, el) => {
|
161
|
-
const $el = $(el);
|
162
|
-
$el
|
163
|
-
.on("mouseenter", () => $el.addClass('front'))
|
164
|
-
.on("mouseleave", () => $el.removeClass('front'));
|
165
|
-
});
|
166
|
-
};
|
167
|
-
|
168
|
-
/**
|
169
|
-
* getOpenLibraryRecord
|
170
|
-
*
|
171
|
-
* The bookreader is designed to call openlibrary API and constructs the
|
172
|
-
* "Return book" button using the response.
|
173
|
-
*
|
174
|
-
* This makes a call to OL API and calls the given callback function with the
|
175
|
-
* response from the API.
|
176
|
-
*/
|
177
|
-
BookReader.prototype.getOpenLibraryRecord = function () {
|
178
|
-
// Try looking up by ocaid first, then by source_record
|
179
|
-
const baseURL = `${this.olHost}/query.json?type=/type/edition&*=`;
|
180
|
-
const fetchUrlByBookId = `${baseURL}&ocaid=${this.bookId}`;
|
181
|
-
|
182
|
-
/*
|
183
|
-
* Update Chapter markers based on received record from Open Library.
|
184
|
-
* Notes that Open Library record is used for extra metadata, and also for lending
|
185
|
-
*/
|
186
|
-
const setUpChapterMarkers = (olObject) => {
|
187
|
-
if (olObject && olObject.table_of_contents) {
|
188
|
-
// XXX check here that TOC is valid
|
189
|
-
this.updateTOC(olObject.table_of_contents);
|
190
|
-
}
|
191
|
-
};
|
192
|
-
|
193
|
-
$.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' })
|
194
|
-
.then(data => {
|
195
|
-
if (data && data.length > 0) {
|
196
|
-
return data;
|
197
|
-
} else {
|
198
|
-
// try sourceid
|
199
|
-
return $.ajax({ url: `${baseURL}&source_records=ia:${this.bookId}`, dataType: 'jsonp' });
|
200
|
-
}
|
201
|
-
})
|
202
|
-
.then(data => {
|
203
|
-
if (data && data.length > 0) {
|
204
|
-
setUpChapterMarkers(data[0]);
|
205
|
-
}
|
206
|
-
});
|
207
|
-
};
|
208
|
-
|
209
|
-
// Extend buildMobileDrawerElement with table of contents list
|
210
|
-
BookReader.prototype.buildMobileDrawerElement = (function (super_) {
|
211
|
-
return function () {
|
212
|
-
const $el = super_.call(this);
|
213
|
-
if (this.enableMobileNav && this.options.enableChaptersPlugin) {
|
214
|
-
$el.find('.BRmobileMenu__moreInfoRow').after($(`
|
215
|
-
<li class="BRmobileMenu__tableContents" data-event-click-tracking="BRSidebar|TOCPanel">
|
216
|
-
<span>
|
217
|
-
<span class="DrawerIconWrapper">
|
218
|
-
<img class="DrawerIcon" src="${this.imagesBaseURL}icon_toc.svg" alt="toc-icon"/>
|
219
|
-
</span>
|
220
|
-
Table of Contents
|
221
|
-
</span>
|
222
|
-
<div>
|
223
|
-
<ol class="table-contents-list">
|
224
|
-
</ol>
|
225
|
-
</div>
|
226
|
-
</li>`).hide());
|
227
|
-
}
|
228
|
-
return $el;
|
229
|
-
};
|
230
|
-
})(BookReader.prototype.buildMobileDrawerElement);
|
231
|
-
|
232
|
-
/**
|
233
|
-
* highlights the current chapter based on current page
|
234
|
-
* @private
|
235
|
-
* @param {TocEntry[]} tocEntries
|
236
|
-
* @param {number} tocEntries
|
237
|
-
*/
|
238
|
-
BookReader.prototype.updateTOCState = function(currIndex, tocEntries) {
|
239
|
-
//this function won't have any effects if called before OpenLibrary request is finished
|
240
|
-
if (!tocEntries) {return;}
|
241
|
-
$('.current-chapter').removeClass('current-chapter');
|
242
|
-
const tocEntriesIndexed = tocEntries.filter((el) => el.pageIndex != undefined).reverse();
|
243
|
-
const currChapter = tocEntriesIndexed[tocEntriesIndexed.findIndex(
|
244
|
-
(el) => el.pageIndex <= currIndex)];
|
245
|
-
if (currChapter != undefined) {
|
246
|
-
$(currChapter.mobileHTML).addClass('current-chapter');
|
247
|
-
}
|
248
|
-
};
|
@@ -1,48 +0,0 @@
|
|
1
|
-
/* global BookReader */
|
2
|
-
/**
|
3
|
-
* Plugin for two-way communication between a BookReader in an IFrame and the
|
4
|
-
* parent web page
|
5
|
-
*/
|
6
|
-
|
7
|
-
const MESSAGE_TYPE_FRAGMENT_CHANGE = 'bookReaderFragmentChange';
|
8
|
-
|
9
|
-
BookReader.prototype.init = (function (super_) {
|
10
|
-
return function () {
|
11
|
-
super_.call(this);
|
12
|
-
_attachEventListeners(this);
|
13
|
-
};
|
14
|
-
})(BookReader.prototype.init);
|
15
|
-
|
16
|
-
/**
|
17
|
-
* @private
|
18
|
-
* Using window.postMessage() and event listeners, the plugin notifies the
|
19
|
-
* parent window when pages change, and the parent window can also
|
20
|
-
* explicitly request a page change by sending its own message.
|
21
|
-
*
|
22
|
-
* @param {BookReader} br
|
23
|
-
* @param {Window?} [parent]
|
24
|
-
*/
|
25
|
-
export function _attachEventListeners(br, parent = window.parent) {
|
26
|
-
// Not embedded, abort
|
27
|
-
if (!parent) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
|
31
|
-
br.bind(BookReader.eventNames.fragmentChange, () => {
|
32
|
-
const fragment = br.fragmentFromParams(br.paramsFromCurrent());
|
33
|
-
|
34
|
-
parent.postMessage(
|
35
|
-
{ type: MESSAGE_TYPE_FRAGMENT_CHANGE, fragment },
|
36
|
-
'*'
|
37
|
-
);
|
38
|
-
});
|
39
|
-
|
40
|
-
window.addEventListener('message', event => {
|
41
|
-
// Not a recognized message type, abort
|
42
|
-
if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
|
46
|
-
br.updateFromParams(br.paramsFromFragment(event.data.fragment));
|
47
|
-
});
|
48
|
-
}
|
@@ -1,288 +0,0 @@
|
|
1
|
-
/* global BookReader */
|
2
|
-
/**
|
3
|
-
* Adds mobile navigation at responsive breakpoint
|
4
|
-
*/
|
5
|
-
|
6
|
-
import * as utils from '../BookReader/utils.js';
|
7
|
-
import 'jquery.mmenu/dist/js/jquery.mmenu.min.js';
|
8
|
-
import 'jquery.mmenu/dist/addons/navbars/jquery.mmenu.navbars.min.js';
|
9
|
-
|
10
|
-
//contains all filters and labels for checkboxs
|
11
|
-
const FILTERLIST = [
|
12
|
-
{
|
13
|
-
filter: "grayscale(100%)",
|
14
|
-
label: "Grayscale"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
filter: "brightness(120%)",
|
18
|
-
label: "High brightness"
|
19
|
-
},
|
20
|
-
{
|
21
|
-
filter: "invert(100%)",
|
22
|
-
label: "Inverted (dark mode)"
|
23
|
-
},
|
24
|
-
{
|
25
|
-
filter: "contrast(120%)",
|
26
|
-
label: "High contrast"
|
27
|
-
},
|
28
|
-
];
|
29
|
-
|
30
|
-
jQuery.extend(BookReader.defaultOptions, {
|
31
|
-
enableMobileNav: true,
|
32
|
-
mobileNavTitle: 'Internet Archive',
|
33
|
-
mobileNavFullscreenOnly: false,
|
34
|
-
});
|
35
|
-
|
36
|
-
BookReader.prototype.setup = (function(super_) {
|
37
|
-
return function (options) {
|
38
|
-
super_.call(this, options);
|
39
|
-
|
40
|
-
this.enableMobileNav = options.enableMobileNav;
|
41
|
-
this.mobileNavTitle = options.mobileNavTitle;
|
42
|
-
this.mobileNavFullscreenOnly = options.mobileNavFullscreenOnly;
|
43
|
-
|
44
|
-
this.refs.$mmenu = null;
|
45
|
-
};
|
46
|
-
})(BookReader.prototype.setup);
|
47
|
-
|
48
|
-
|
49
|
-
// Extend initToolbar
|
50
|
-
BookReader.prototype.initToolbar = (function (super_) {
|
51
|
-
return function (mode, ui) {
|
52
|
-
let $mmenuEl;
|
53
|
-
if (this.enableMobileNav) {
|
54
|
-
const $drawerEl = this.buildMobileDrawerElement();
|
55
|
-
this.refs.$br.append($drawerEl);
|
56
|
-
|
57
|
-
// Render info into mobile info before mmenu
|
58
|
-
this.buildInfoDiv(this.$('.BRmobileInfo'));
|
59
|
-
this.buildShareDiv(this.$('.BRmobileShare'));
|
60
|
-
|
61
|
-
$mmenuEl = $drawerEl;
|
62
|
-
$mmenuEl.mmenu({
|
63
|
-
navbars: [
|
64
|
-
{ "position": "top" },
|
65
|
-
],
|
66
|
-
navbar: {
|
67
|
-
add: true,
|
68
|
-
title: this.mobileNavTitle,
|
69
|
-
titleLink: 'panel'
|
70
|
-
},
|
71
|
-
extensions: [ "panelshadow" ],
|
72
|
-
}, {
|
73
|
-
offCanvas: {
|
74
|
-
wrapPageIfNeeded: false,
|
75
|
-
zposition: 'next',
|
76
|
-
pageSelector: this.el,
|
77
|
-
}
|
78
|
-
});
|
79
|
-
|
80
|
-
const $BRpageviewField = $mmenuEl.find('.BRpageviewValue');
|
81
|
-
$mmenuEl.data('mmenu').bind('opened', () => {
|
82
|
-
// Update "Link to this page view" link
|
83
|
-
if ($BRpageviewField.length) {
|
84
|
-
$BRpageviewField.val(window.location.href);
|
85
|
-
}
|
86
|
-
});
|
87
|
-
|
88
|
-
//apply filters when checkboxs clicked
|
89
|
-
$drawerEl.find('.BRcheckbox-filters')
|
90
|
-
.on("click", () => applyFilters($drawerEl, this));
|
91
|
-
|
92
|
-
// Bind mobile switch buttons
|
93
|
-
$drawerEl.find('.DrawerLayoutButton.one_page_mode')
|
94
|
-
.on("click", () => this.switchMode(this.constMode1up));
|
95
|
-
$drawerEl.find('.DrawerLayoutButton.two_page_mode')
|
96
|
-
.on("click", () => this.switchMode(this.constMode2up));
|
97
|
-
$drawerEl.find('.DrawerLayoutButton.thumbnail_mode')
|
98
|
-
.on("click", () => this.switchMode(this.constModeThumb));
|
99
|
-
|
100
|
-
if (this.mobileNavFullscreenOnly) {
|
101
|
-
$(document.body).addClass('BRbodyMobileNavEnabledFullscreen');
|
102
|
-
} else {
|
103
|
-
$(document.body).addClass('BRbodyMobileNavEnabled');
|
104
|
-
}
|
105
|
-
|
106
|
-
this.refs.$mmenu = $mmenuEl;
|
107
|
-
|
108
|
-
}
|
109
|
-
|
110
|
-
// Call the parent method at the end, because it binds events to DOM
|
111
|
-
super_.apply(this, arguments);
|
112
|
-
|
113
|
-
|
114
|
-
if (this.enableMobileNav) {
|
115
|
-
// Need to bind more, console after toolbar is initialized
|
116
|
-
this.$('.BRmobileHamburger').click(() => {
|
117
|
-
if ($mmenuEl.data('mmenu').getInstance().vars.opened) {
|
118
|
-
$mmenuEl.data('mmenu').close();
|
119
|
-
} else {
|
120
|
-
$mmenuEl.data('mmenu').open();
|
121
|
-
this.trigger("mobileNavOpen");
|
122
|
-
}
|
123
|
-
});
|
124
|
-
|
125
|
-
|
126
|
-
const closeMobileMenu = (e) => {
|
127
|
-
// Need to close the mobile menu to reset DOM & Style
|
128
|
-
// driven by menu plugin
|
129
|
-
const width = $( window ).width();
|
130
|
-
const mobileMenuIsOpen = $mmenuEl.data('mmenu').getInstance().vars.opened;
|
131
|
-
// $brBreakPointMobile: 800px;
|
132
|
-
if (mobileMenuIsOpen && (width >= 800)) {
|
133
|
-
$mmenuEl.data('mmenu').close ();
|
134
|
-
}
|
135
|
-
};
|
136
|
-
|
137
|
-
window.addEventListener('resize', utils.debounce(closeMobileMenu, 900));
|
138
|
-
}
|
139
|
-
};
|
140
|
-
})(BookReader.prototype.initToolbar);
|
141
|
-
|
142
|
-
|
143
|
-
BookReader.prototype.buildToolbarElement = (function (super_) {
|
144
|
-
return function () {
|
145
|
-
const $el = super_.call(this);
|
146
|
-
if (this.enableMobileNav) {
|
147
|
-
const escapedTitle = BookReader.util.escapeHTML(this.bookTitle);
|
148
|
-
const toolbar = `
|
149
|
-
<span class="BRmobileHamburgerWrapper">
|
150
|
-
<button class="BRmobileHamburger"></button>
|
151
|
-
<span class="BRtoolbarMobileTitle" title="${escapedTitle}">${escapedTitle}</span>
|
152
|
-
</span>
|
153
|
-
`;
|
154
|
-
$el
|
155
|
-
.addClass('responsive')
|
156
|
-
.prepend($(toolbar));
|
157
|
-
}
|
158
|
-
return $el;
|
159
|
-
};
|
160
|
-
})(BookReader.prototype.buildToolbarElement);
|
161
|
-
|
162
|
-
/**
|
163
|
-
* This method builds the html for the mobile drawer. It can be decorated to
|
164
|
-
* extend the default drawer.
|
165
|
-
* @return {jqueryElement}
|
166
|
-
*/
|
167
|
-
BookReader.prototype.buildMobileDrawerElement = function() {
|
168
|
-
let experimentalHtml = '';
|
169
|
-
//builds filters checkbox html
|
170
|
-
if (this.enableExperimentalControls) {
|
171
|
-
experimentalHtml = `
|
172
|
-
<p class="DrawerSettingsTitle">Visual Adjustment</p>
|
173
|
-
<div class="BRcheckbox-group-filters">
|
174
|
-
`;
|
175
|
-
FILTERLIST.forEach( (el, i) => {
|
176
|
-
const checkboxHtml = `
|
177
|
-
<input type="checkbox" class="BRcheckbox-filters" id="filter${i}">
|
178
|
-
<label for="filter${i}" class="BRcheckbox-label-filters">${el.label}</label><br>
|
179
|
-
|
180
|
-
`;
|
181
|
-
experimentalHtml = experimentalHtml.concat(checkboxHtml);
|
182
|
-
});
|
183
|
-
experimentalHtml = experimentalHtml.concat("</div>");
|
184
|
-
}
|
185
|
-
|
186
|
-
|
187
|
-
const settingsSection = `
|
188
|
-
<span>
|
189
|
-
<span class="DrawerIconWrapper">
|
190
|
-
<img class="DrawerIcon" src="${`${this.imagesBaseURL}icon_gear.svg`}" alt="settings-icon"/>
|
191
|
-
</span>
|
192
|
-
Settings
|
193
|
-
</span>
|
194
|
-
<div class=DrawerSettingsWrapper>
|
195
|
-
<div class="DrawerSettingsLayoutWrapper">
|
196
|
-
<button class="DrawerLayoutButton one_page_mode">
|
197
|
-
<img src="${this.imagesBaseURL}icon_one_page.svg" alt="Single Page"/>
|
198
|
-
<br>
|
199
|
-
One Page
|
200
|
-
</button>
|
201
|
-
<button class="DrawerLayoutButton two_page_mode TwoPagesButton">
|
202
|
-
<img src="${this.imagesBaseURL}icon_two_pages.svg" alt="Two Pages"/>
|
203
|
-
<br>
|
204
|
-
Two Pages
|
205
|
-
</button>
|
206
|
-
<button class="DrawerLayoutButton thumbnail_mode">
|
207
|
-
<img src="${this.imagesBaseURL}icon_thumbnails.svg" alt="Thumbnails"/>
|
208
|
-
<br>
|
209
|
-
Thumbnails
|
210
|
-
</button>
|
211
|
-
</div>
|
212
|
-
<br>
|
213
|
-
<div class="DrawerSettingsTitle">Zoom</div>
|
214
|
-
<button class='BRicon zoom_out'></button>
|
215
|
-
<button class='BRicon zoom_in'></button>
|
216
|
-
<br style="clear:both"><br><br>
|
217
|
-
${experimentalHtml}
|
218
|
-
</div>
|
219
|
-
`;
|
220
|
-
const moreInfo = `
|
221
|
-
<span>
|
222
|
-
<span class="DrawerIconWrapper ">
|
223
|
-
<img class="DrawerIcon" src="${this.imagesBaseURL}icon_info.svg" alt="info-icon"/>
|
224
|
-
</span>
|
225
|
-
About This Book
|
226
|
-
</span>
|
227
|
-
<div class="BRmobileInfo"></div>
|
228
|
-
`;
|
229
|
-
const share = `
|
230
|
-
<span>
|
231
|
-
<span class="DrawerIconWrapper">
|
232
|
-
<img class="DrawerIcon" src="${this.imagesBaseURL}icon_share.svg" alt="info-share"/>
|
233
|
-
</span>
|
234
|
-
Share This Book
|
235
|
-
</span>
|
236
|
-
<div class="BRmobileShare"></div>
|
237
|
-
`;
|
238
|
-
const navMenu = `
|
239
|
-
<nav id="BRmobileMenu" class="BRmobileMenu">
|
240
|
-
<ul>
|
241
|
-
<li class="BRmobileMenu__settings">${settingsSection}</li>
|
242
|
-
<li class="BRmobileMenu__moreInfoRow">${moreInfo}</li>
|
243
|
-
<li class="BRmobileMenu__share">${share}</li>
|
244
|
-
</ul>
|
245
|
-
</nav>
|
246
|
-
`;
|
247
|
-
|
248
|
-
const $el = $(navMenu);
|
249
|
-
return $el;
|
250
|
-
};
|
251
|
-
|
252
|
-
/**
|
253
|
-
* Mmenu moves itself out side of the root BookReader element, so we need to
|
254
|
-
* include it in the scoped $ function.
|
255
|
-
*/
|
256
|
-
BookReader.prototype.$ = (function (super_) {
|
257
|
-
return function (arg) {
|
258
|
-
let $results = super_.call(this, arg);
|
259
|
-
if (this.refs.$mmenu) {
|
260
|
-
$results = $results.add(this.refs.$mmenu.find(arg));
|
261
|
-
}
|
262
|
-
return $results;
|
263
|
-
};
|
264
|
-
})(BookReader.prototype.$);
|
265
|
-
|
266
|
-
/**
|
267
|
-
* Dynamically creates styles combining different filters for BookReaders imgs
|
268
|
-
* based on filters checkbox
|
269
|
-
*/
|
270
|
-
const applyFilters = (drawerEl, br) => {
|
271
|
-
let filterStr = "";
|
272
|
-
|
273
|
-
$('.BRcheckbox-filters').each(
|
274
|
-
(i, el) => {
|
275
|
-
br.refs.$br.removeClass("filter-applied");
|
276
|
-
if ($(el).is(':checked')) {
|
277
|
-
br.refs.$br.addClass($(el).attr("filter-applied"));
|
278
|
-
filterStr = filterStr + FILTERLIST[i].filter;
|
279
|
-
}
|
280
|
-
}
|
281
|
-
);
|
282
|
-
const filtersSheet = $("#filtersStyle")[0] || document.createElement('style');
|
283
|
-
filtersSheet.id = "filtersStyle";
|
284
|
-
filtersSheet.innerHTML = `.BRpagecontainer img {
|
285
|
-
filter: ${filterStr};
|
286
|
-
-webkit-filter: ${filterStr};}`;
|
287
|
-
document.body.appendChild(filtersSheet);
|
288
|
-
};
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import * as docCookies from '../util/docCookies.js';
|
2
|
-
|
3
|
-
/* global BookReader */
|
4
|
-
|
5
|
-
/** @deprecated Exposed for backward compatibility */
|
6
|
-
BookReader.docCookies = docCookies;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Plugin to remember the current page number in a cookie
|
10
|
-
*/
|
11
|
-
jQuery.extend(BookReader.defaultOptions, {
|
12
|
-
enablePageResume: true,
|
13
|
-
/** @type {string|null} eg '/', '/details/id' */
|
14
|
-
resumeCookiePath: null,
|
15
|
-
});
|
16
|
-
|
17
|
-
/** @override */
|
18
|
-
BookReader.prototype.init = (function(super_) {
|
19
|
-
return function() {
|
20
|
-
super_.call(this);
|
21
|
-
if (this.options.enablePageResume) {
|
22
|
-
this.bind(BookReader.eventNames.fragmentChange, () => {
|
23
|
-
const params = this.paramsFromCurrent();
|
24
|
-
this.updateResumeValue(params.index);
|
25
|
-
});
|
26
|
-
}
|
27
|
-
};
|
28
|
-
})(BookReader.prototype.init);
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Gets page resume value, for remembering reader's page
|
32
|
-
* Can be overridden for different implementation
|
33
|
-
*
|
34
|
-
* @return {number|null}
|
35
|
-
*/
|
36
|
-
BookReader.prototype.getResumeValue = function() {
|
37
|
-
const val = BookReader.docCookies.getItem('br-resume');
|
38
|
-
if (val !== null) return parseInt(val);
|
39
|
-
else return null;
|
40
|
-
};
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Return cookie path using pathname up to /page/... or /mode/...
|
44
|
-
* using window.location.pathname for urlPathPart:
|
45
|
-
* - matches encoding
|
46
|
-
* - ignores querystring part
|
47
|
-
* - ignores fragment part (after #)
|
48
|
-
* @param {string} urlPathPart - window.location.pathname
|
49
|
-
*/
|
50
|
-
BookReader.prototype.getCookiePath = function(urlPathPart) {
|
51
|
-
return urlPathPart.match('.+?(?=/page/|/mode/|$)')[0];
|
52
|
-
};
|
53
|
-
|
54
|
-
/**
|
55
|
-
* Sets page resume value, for remembering reader's page
|
56
|
-
* Can be overridden for different implementation
|
57
|
-
*
|
58
|
-
* @param {Number} index leaf index
|
59
|
-
* @param {string} [cookieName]
|
60
|
-
*/
|
61
|
-
BookReader.prototype.updateResumeValue = function(index, cookieName) {
|
62
|
-
const ttl = new Date(+new Date + 12096e5); // 2 weeks
|
63
|
-
// For multiple files in item, leave resumeCookiePath blank
|
64
|
-
// It's likely we can remove resumeCookiePath using getCookiePath()
|
65
|
-
const path = this.options.resumeCookiePath
|
66
|
-
|| this.getCookiePath(window.location.pathname);
|
67
|
-
BookReader.docCookies.setItem(cookieName || 'br-resume', index, ttl, path, null, false);
|
68
|
-
};
|