@internetarchive/bookreader 5.0.0-6-multiple-files → 5.0.0-60
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/.eslintrc.js +17 -15
- package/.github/workflows/node.js.yml +77 -6
- package/.github/workflows/npm-publish.yml +6 -20
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +241 -377
- package/BookReader/BookReader.js +2 -21564
- package/BookReader/BookReader.js.LICENSE.txt +24 -20
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1519 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +17 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -12
- package/BookReader/icons/2up.svg +1 -15
- package/BookReader/icons/advance.svg +3 -26
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +1 -17
- package/BookReader/icons/fullscreen_exit.svg +1 -17
- package/BookReader/icons/hamburger.svg +1 -15
- package/BookReader/icons/left-arrow.svg +1 -12
- package/BookReader/icons/magnify-minus.svg +1 -16
- package/BookReader/icons/magnify-plus.svg +1 -17
- package/BookReader/icons/magnify.svg +1 -15
- package/BookReader/icons/pause.svg +1 -23
- package/BookReader/icons/play.svg +1 -22
- package/BookReader/icons/playback-speed.svg +1 -34
- package/BookReader/icons/read-aloud.svg +1 -22
- package/BookReader/icons/review.svg +3 -22
- package/BookReader/icons/thumbnails.svg +1 -17
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -22
- package/BookReader/images/BRicons.svg +5 -94
- package/BookReader/images/books_graphic.svg +1 -177
- package/BookReader/images/icon_book.svg +1 -12
- package/BookReader/images/icon_bookmark.svg +1 -12
- package/BookReader/images/icon_gear.svg +1 -14
- package/BookReader/images/icon_hamburger.svg +1 -20
- package/BookReader/images/icon_home.svg +1 -21
- package/BookReader/images/icon_info.svg +1 -11
- package/BookReader/images/icon_one_page.svg +1 -8
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -15
- package/BookReader/images/icon_search_button.svg +1 -8
- package/BookReader/images/icon_share.svg +1 -9
- package/BookReader/images/icon_skip-ahead.svg +1 -6
- package/BookReader/images/icon_skip-back.svg +2 -13
- package/BookReader/images/icon_speaker.svg +1 -18
- package/BookReader/images/icon_speaker_open.svg +1 -10
- package/BookReader/images/icon_thumbnails.svg +1 -12
- package/BookReader/images/icon_toc.svg +1 -5
- package/BookReader/images/icon_two_pages.svg +1 -9
- package/BookReader/images/marker_chap-off.svg +1 -11
- package/BookReader/images/marker_chap-on.svg +1 -11
- package/BookReader/images/marker_srch-on.svg +1 -11
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +1 -172
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -165
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -304
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -74
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +1 -334
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -368
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1420
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1080
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +2 -9193
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -269
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -379
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +14 -1
- package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
- package/BookReaderDemo/BookReaderJSSimple.js +1 -0
- package/BookReaderDemo/IADemoBr.js +147 -0
- package/BookReaderDemo/demo-advanced.html +2 -2
- package/BookReaderDemo/demo-autoplay.html +2 -1
- package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
- package/BookReaderDemo/demo-fullscreen-mobile.html +2 -1
- package/BookReaderDemo/demo-fullscreen.html +2 -1
- package/BookReaderDemo/demo-iiif.html +2 -1
- package/BookReaderDemo/demo-internetarchive.html +84 -17
- package/BookReaderDemo/demo-multiple.html +2 -1
- package/BookReaderDemo/demo-preview-pages.html +2 -1
- package/BookReaderDemo/demo-simple.html +2 -1
- package/BookReaderDemo/demo-vendor-fullscreen.html +2 -1
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
- package/BookReaderDemo/immersion-1up.html +2 -1
- package/BookReaderDemo/immersion-mode.html +2 -1
- package/BookReaderDemo/toggle_controls.html +2 -1
- package/BookReaderDemo/view_mode.html +2 -1
- package/BookReaderDemo/viewmode-cycle.html +2 -3
- package/CHANGELOG.md +246 -0
- package/README.md +14 -1
- package/babel.config.js +19 -0
- package/codecov.yml +6 -0
- package/index.html +3 -0
- package/jsconfig.json +19 -0
- package/netlify.toml +5 -0
- package/package.json +70 -59
- package/renovate.json +52 -0
- package/scripts/preversion.js +4 -1
- package/src/BookNavigator/assets/bookmark-colors.js +1 -1
- package/src/BookNavigator/assets/button-base.js +9 -2
- package/src/BookNavigator/assets/ia-logo.js +17 -0
- package/src/BookNavigator/assets/icon_checkmark.js +1 -1
- package/src/BookNavigator/assets/icon_close.js +1 -1
- package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
- package/src/BookNavigator/assets/{icon_sort_ascending.js → icon_sort_desc.js} +2 -2
- package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
- package/src/BookNavigator/assets/icon_volumes.js +11 -0
- package/src/BookNavigator/book-navigator.js +585 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
- package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
- package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
- package/src/BookNavigator/delete-modal-actions.js +1 -1
- package/src/BookNavigator/downloads/downloads-provider.js +36 -21
- package/src/BookNavigator/downloads/downloads.js +41 -25
- package/src/BookNavigator/search/search-provider.js +80 -28
- package/src/BookNavigator/search/search-results.js +34 -25
- package/src/BookNavigator/sharing.js +27 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
- package/src/BookNavigator/volumes/volumes-provider.js +88 -53
- package/src/BookNavigator/volumes/volumes.js +41 -14
- package/src/BookReader/BookModel.js +59 -30
- package/src/BookReader/DebugConsole.js +3 -3
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +56 -351
- package/src/BookReader/Mode1UpLit.js +391 -0
- package/src/BookReader/Mode2Up.js +73 -1318
- package/src/BookReader/Mode2UpLit.js +781 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +211 -0
- package/src/BookReader/ModeThumb.js +17 -11
- package/src/BookReader/Navbar/Navbar.js +10 -36
- package/src/BookReader/PageContainer.js +69 -6
- package/src/BookReader/ReduceSet.js +1 -1
- package/src/BookReader/Toolbar/Toolbar.js +10 -37
- package/src/BookReader/events.js +2 -0
- package/src/BookReader/options.js +24 -2
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils.js +108 -13
- package/src/BookReader.js +480 -825
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/assets/icons/voice.svg +1 -0
- package/src/css/BookReader.scss +0 -12
- package/src/css/_BRBookmarks.scss +1 -1
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +33 -24
- package/src/css/_BRnav.scss +4 -26
- package/src/css/_BRpages.scss +147 -40
- package/src/css/_BRsearch.scss +25 -216
- package/src/css/_TextSelection.scss +16 -17
- package/src/css/_colorbox.scss +2 -2
- package/src/css/_controls.scss +17 -5
- package/src/css/_icons.scss +7 -1
- package/src/ia-bookreader/ia-bookreader.js +224 -0
- package/src/plugins/plugin.archive_analytics.js +3 -3
- package/src/plugins/plugin.autoplay.js +4 -9
- package/src/plugins/plugin.chapters.js +28 -35
- package/src/plugins/plugin.mobile_nav.js +11 -10
- package/src/plugins/plugin.resume.js +3 -3
- package/src/plugins/plugin.text_selection.js +32 -41
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +179 -116
- package/src/plugins/search/view.js +63 -179
- package/src/plugins/tts/AbstractTTSEngine.js +46 -37
- package/src/plugins/tts/FestivalTTSEngine.js +13 -14
- package/src/plugins/tts/PageChunk.js +15 -21
- package/src/plugins/tts/PageChunkIterator.js +8 -12
- package/src/plugins/tts/WebTTSEngine.js +87 -71
- package/src/plugins/tts/plugin.tts.js +94 -125
- package/src/plugins/tts/utils.js +0 -25
- package/src/plugins/url/UrlPlugin.js +193 -0
- package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
- package/src/util/docCookies.js +21 -2
- package/tests/e2e/README.md +37 -0
- package/tests/e2e/autoplay.test.js +2 -2
- package/tests/e2e/base.test.js +7 -7
- package/tests/e2e/helpers/base.js +28 -23
- package/tests/e2e/helpers/debug.js +1 -1
- package/tests/e2e/helpers/desktopSearch.js +14 -13
- package/tests/e2e/helpers/mobileSearch.js +3 -3
- package/tests/e2e/helpers/params.js +17 -0
- package/tests/e2e/helpers/rightToLeft.js +4 -10
- package/tests/e2e/models/Navigation.js +13 -4
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +40 -33
- package/tests/jest/BookNavigator/book-navigator.test.js +658 -0
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
- package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
- package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
- package/tests/{karma/BookNavigator → jest/BookNavigator/search}/search-results.test.js +104 -60
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/jest/BookNavigator/volumes/volumes-provider.test.js +184 -0
- package/tests/jest/BookNavigator/volumes/volumes.test.js +97 -0
- package/tests/{BookReader → jest/BookReader}/BookModel.test.js +59 -14
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
- package/tests/{BookReader → jest/BookReader}/DebugConsole.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
- package/tests/jest/BookReader/Mode2Up.test.js +98 -0
- package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
- package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +175 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
- package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
- package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
- package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
- package/tests/jest/BookReader/utils.test.js +217 -0
- package/tests/jest/BookReader.keyboard.test.js +190 -0
- package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
- package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
- package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
- package/tests/{plugins → jest/plugins}/plugin.chapters.test.js +10 -11
- package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.mobile_nav.test.js +5 -5
- package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
- package/tests/{plugins → jest/plugins}/plugin.text_selection.test.js +39 -47
- package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
- package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +63 -47
- package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +35 -6
- package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +9 -9
- package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
- package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
- package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
- package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
- package/tests/jest/plugins/url/UrlPlugin.test.js +190 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
- package/tests/jest/setup.js +3 -0
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/jest/util/docCookies.test.js +24 -0
- package/tests/{util → jest/util}/strings.test.js +1 -1
- package/tests/{utils.js → jest/utils.js} +38 -0
- package/webpack.config.js +11 -5
- package/.babelrc +0 -12
- package/.dependabot/config.yml +0 -6
- package/.testcaferc.json +0 -5
- package/BookReader/bookreader-component-bundle.js +0 -14312
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/icons/sort-ascending.svg +0 -1
- package/BookReader/icons/sort-descending.svg +0 -1
- package/BookReader/jquery-1.10.1.js +0 -108
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -369
- package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
- package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
- package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
- package/karma.conf.js +0 -23
- package/src/BookNavigator/BookModel.js +0 -14
- package/src/BookNavigator/BookNavigator.js +0 -452
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/BookNavigator/assets/icon_sort_descending.js +0 -5
- package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
- package/src/BookNavigator/search/a-search-result.js +0 -55
- package/src/BookReaderComponent/BookReaderComponent.js +0 -112
- package/src/ItemNavigator/ItemNavigator.js +0 -372
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/assets/icons/sort-ascending.svg +0 -1
- package/src/assets/icons/sort-descending.svg +0 -1
- package/src/dragscrollable-br.js +0 -261
- package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
- package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
- package/tests/BookReader/Mode1Up.test.js +0 -164
- package/tests/BookReader/Mode2Up.test.js +0 -247
- package/tests/BookReader/utils.test.js +0 -109
- package/tests/e2e/ia-production/ia-prod-base.js +0 -17
- package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
- package/tests/karma/BookNavigator/volumes.test.js +0 -101
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
- package/tests/util/docCookies.test.js +0 -15
|
@@ -36,14 +36,12 @@ BookReader.prototype.init = (function(super_) {
|
|
|
36
36
|
this.updateTOCState(this.firstIndex, this._tocEntries);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
)
|
|
40
|
-
$(".BRmobileMenu__tableContents").click(
|
|
41
|
-
() => {
|
|
42
|
-
this.updateTOCState(this.firstIndex, this._tocEntries);
|
|
43
|
-
}
|
|
44
39
|
);
|
|
40
|
+
$(".BRmobileMenu__tableContents").on("click", () => {
|
|
41
|
+
this.updateTOCState(this.firstIndex, this._tocEntries);
|
|
42
|
+
});
|
|
45
43
|
}
|
|
46
|
-
}
|
|
44
|
+
};
|
|
47
45
|
})(BookReader.prototype.init);
|
|
48
46
|
|
|
49
47
|
/**
|
|
@@ -55,12 +53,12 @@ BookReader.prototype.init = (function(super_) {
|
|
|
55
53
|
*/
|
|
56
54
|
BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex) {
|
|
57
55
|
const uiStringPage = 'Page'; // i18n
|
|
58
|
-
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.getNumLeafs() - 1);
|
|
56
|
+
const percentThrough = BookReader.util.cssPercentage(pageIndex, this.book.getNumLeafs() - 1);
|
|
59
57
|
const jumpToChapter = (event) => {
|
|
60
58
|
this.jumpToIndex($(event.delegateTarget).data('pageIndex'));
|
|
61
59
|
$('.current-chapter').removeClass('current-chapter');
|
|
62
60
|
$(event.delegateTarget).addClass('current-chapter');
|
|
63
|
-
}
|
|
61
|
+
};
|
|
64
62
|
const title = `${chapterTitle} | `;
|
|
65
63
|
const pageStr = `${uiStringPage} ${pageNumber}`;
|
|
66
64
|
|
|
@@ -79,7 +77,7 @@ BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex)
|
|
|
79
77
|
.css({ left: percentThrough })
|
|
80
78
|
.appendTo(this.$('.BRnavline'))
|
|
81
79
|
.data({ pageIndex })
|
|
82
|
-
.
|
|
80
|
+
.on("mouseenter", event => {
|
|
83
81
|
// remove hover effect from other markers then turn on just for this
|
|
84
82
|
const marker = event.currentTarget;
|
|
85
83
|
const tooltip = marker.querySelector('div');
|
|
@@ -91,9 +89,8 @@ BookReader.prototype.addChapter = function(chapterTitle, pageNumber, pageIndex)
|
|
|
91
89
|
}
|
|
92
90
|
this.$('.BRsearch,.BRchapter').removeClass('front');
|
|
93
91
|
$(event.target).addClass('front');
|
|
94
|
-
}
|
|
95
|
-
event => $(event.target).removeClass('front')
|
|
96
|
-
)
|
|
92
|
+
})
|
|
93
|
+
.on("mouseleave", event => $(event.target).removeClass('front'))
|
|
97
94
|
.on('click', jumpToChapter);
|
|
98
95
|
|
|
99
96
|
//adding clickable properties to mobile chapters
|
|
@@ -126,7 +123,7 @@ BookReader.prototype.updateTOC = function(tocEntries) {
|
|
|
126
123
|
this._tocEntries = tocEntries;
|
|
127
124
|
$('.table-contents-list').children().each((i, el) => {
|
|
128
125
|
tocEntries[i].mobileHTML = el;
|
|
129
|
-
})
|
|
126
|
+
});
|
|
130
127
|
};
|
|
131
128
|
|
|
132
129
|
/**
|
|
@@ -154,7 +151,7 @@ BookReader.prototype.updateTOC = function(tocEntries) {
|
|
|
154
151
|
* @param {TocEntry} tocEntryObject
|
|
155
152
|
*/
|
|
156
153
|
BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
|
157
|
-
tocEntryObject.pageIndex = this.getPageIndex(tocEntryObject['pagenum']);
|
|
154
|
+
tocEntryObject.pageIndex = this.book.getPageIndex(tocEntryObject['pagenum']);
|
|
158
155
|
//creates a string with non-void tocEntryObject.label and tocEntryObject.title
|
|
159
156
|
const chapterStr = [tocEntryObject.label, tocEntryObject.title]
|
|
160
157
|
.filter(x => x)
|
|
@@ -162,9 +159,9 @@ BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
|
|
162
159
|
this.addChapter(chapterStr, tocEntryObject['pagenum'], tocEntryObject.pageIndex);
|
|
163
160
|
this.$('.BRchapter, .BRsearch').each((i, el) => {
|
|
164
161
|
const $el = $(el);
|
|
165
|
-
$el
|
|
166
|
-
() => $el.addClass('front')
|
|
167
|
-
() => $el.removeClass('front'));
|
|
162
|
+
$el
|
|
163
|
+
.on("mouseenter", () => $el.addClass('front'))
|
|
164
|
+
.on("mouseleave", () => $el.removeClass('front'));
|
|
168
165
|
});
|
|
169
166
|
};
|
|
170
167
|
|
|
@@ -177,7 +174,7 @@ BookReader.prototype.addChapterFromEntry = function(tocEntryObject) {
|
|
|
177
174
|
* This makes a call to OL API and calls the given callback function with the
|
|
178
175
|
* response from the API.
|
|
179
176
|
*/
|
|
180
|
-
BookReader.prototype.getOpenLibraryRecord = function () {
|
|
177
|
+
BookReader.prototype.getOpenLibraryRecord = async function () {
|
|
181
178
|
// Try looking up by ocaid first, then by source_record
|
|
182
179
|
const baseURL = `${this.olHost}/query.json?type=/type/edition&*=`;
|
|
183
180
|
const fetchUrlByBookId = `${baseURL}&ocaid=${this.bookId}`;
|
|
@@ -193,21 +190,17 @@ BookReader.prototype.getOpenLibraryRecord = function () {
|
|
|
193
190
|
}
|
|
194
191
|
};
|
|
195
192
|
|
|
196
|
-
$.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' })
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
setUpChapterMarkers(data[0]);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
193
|
+
let data = await $.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' });
|
|
194
|
+
|
|
195
|
+
if (!data || !data.length) {
|
|
196
|
+
// try sourceid
|
|
197
|
+
data = await $.ajax({ url: `${baseURL}&source_records=ia:${this.bookId}`, dataType: 'jsonp' });
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (data && data.length > 0) {
|
|
201
|
+
setUpChapterMarkers(data[0]);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
211
204
|
|
|
212
205
|
// Extend buildMobileDrawerElement with table of contents list
|
|
213
206
|
BookReader.prototype.buildMobileDrawerElement = (function (super_) {
|
|
@@ -240,7 +233,7 @@ BookReader.prototype.buildMobileDrawerElement = (function (super_) {
|
|
|
240
233
|
*/
|
|
241
234
|
BookReader.prototype.updateTOCState = function(currIndex, tocEntries) {
|
|
242
235
|
//this function won't have any effects if called before OpenLibrary request is finished
|
|
243
|
-
if (!tocEntries) {return}
|
|
236
|
+
if (!tocEntries) {return;}
|
|
244
237
|
$('.current-chapter').removeClass('current-chapter');
|
|
245
238
|
const tocEntriesIndexed = tocEntries.filter((el) => el.pageIndex != undefined).reverse();
|
|
246
239
|
const currChapter = tocEntriesIndexed[tocEntriesIndexed.findIndex(
|
|
@@ -248,4 +241,4 @@ BookReader.prototype.updateTOCState = function(currIndex, tocEntries) {
|
|
|
248
241
|
if (currChapter != undefined) {
|
|
249
242
|
$(currChapter.mobileHTML).addClass('current-chapter');
|
|
250
243
|
}
|
|
251
|
-
}
|
|
244
|
+
};
|
|
@@ -25,7 +25,7 @@ const FILTERLIST = [
|
|
|
25
25
|
filter: "contrast(120%)",
|
|
26
26
|
label: "High contrast"
|
|
27
27
|
},
|
|
28
|
-
]
|
|
28
|
+
];
|
|
29
29
|
|
|
30
30
|
jQuery.extend(BookReader.defaultOptions, {
|
|
31
31
|
enableMobileNav: true,
|
|
@@ -86,15 +86,16 @@ BookReader.prototype.initToolbar = (function (super_) {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
//apply filters when checkboxs clicked
|
|
89
|
-
$drawerEl.find('.BRcheckbox-filters')
|
|
89
|
+
$drawerEl.find('.BRcheckbox-filters')
|
|
90
|
+
.on("click", () => applyFilters($drawerEl, this));
|
|
90
91
|
|
|
91
92
|
// Bind mobile switch buttons
|
|
92
|
-
$drawerEl.find('.DrawerLayoutButton.one_page_mode')
|
|
93
|
-
() => this.switchMode(this.constMode1up));
|
|
94
|
-
$drawerEl.find('.DrawerLayoutButton.two_page_mode')
|
|
95
|
-
() => this.switchMode(this.constMode2up));
|
|
96
|
-
$drawerEl.find('.DrawerLayoutButton.thumbnail_mode')
|
|
97
|
-
() => this.switchMode(this.constModeThumb));
|
|
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));
|
|
98
99
|
|
|
99
100
|
if (this.mobileNavFullscreenOnly) {
|
|
100
101
|
$(document.body).addClass('BRbodyMobileNavEnabledFullscreen');
|
|
@@ -178,7 +179,7 @@ BookReader.prototype.buildMobileDrawerElement = function() {
|
|
|
178
179
|
|
|
179
180
|
`;
|
|
180
181
|
experimentalHtml = experimentalHtml.concat(checkboxHtml);
|
|
181
|
-
})
|
|
182
|
+
});
|
|
182
183
|
experimentalHtml = experimentalHtml.concat("</div>");
|
|
183
184
|
}
|
|
184
185
|
|
|
@@ -284,4 +285,4 @@ const applyFilters = (drawerEl, br) => {
|
|
|
284
285
|
filter: ${filterStr};
|
|
285
286
|
-webkit-filter: ${filterStr};}`;
|
|
286
287
|
document.body.appendChild(filtersSheet);
|
|
287
|
-
}
|
|
288
|
+
};
|
|
@@ -37,7 +37,7 @@ BookReader.prototype.getResumeValue = function() {
|
|
|
37
37
|
const val = BookReader.docCookies.getItem('br-resume');
|
|
38
38
|
if (val !== null) return parseInt(val);
|
|
39
39
|
else return null;
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Return cookie path using pathname up to /page/... or /mode/...
|
|
@@ -49,7 +49,7 @@ BookReader.prototype.getResumeValue = function() {
|
|
|
49
49
|
*/
|
|
50
50
|
BookReader.prototype.getCookiePath = function(urlPathPart) {
|
|
51
51
|
return urlPathPart.match('.+?(?=/page/|/mode/|$)')[0];
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Sets page resume value, for remembering reader's page
|
|
@@ -65,4 +65,4 @@ BookReader.prototype.updateResumeValue = function(index, cookieName) {
|
|
|
65
65
|
const path = this.options.resumeCookiePath
|
|
66
66
|
|| this.getCookiePath(window.location.pathname);
|
|
67
67
|
BookReader.docCookies.setItem(cookieName || 'br-resume', index, ttl, path, null, false);
|
|
68
|
-
}
|
|
68
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
+
import { createSVGPageLayer } from '../BookReader/PageContainer.js';
|
|
2
3
|
import { isFirefox, isSafari } from '../util/browserSniffing.js';
|
|
3
4
|
import { applyVariables } from '../util/strings.js';
|
|
4
5
|
/** @typedef {import('../util/strings.js').StringWithVars} StringWithVars */
|
|
6
|
+
/** @typedef {import('../BookReader/PageContainer.js').PageContainer} PageContainer */
|
|
5
7
|
|
|
6
8
|
const BookReader = /** @type {typeof import('../BookReader').default} */(window.BookReader);
|
|
7
9
|
|
|
@@ -11,6 +13,8 @@ export const DEFAULT_OPTIONS = {
|
|
|
11
13
|
fullDjvuXmlUrl: null,
|
|
12
14
|
/** @type {StringWithVars} The URL to fetch a single page of the DJVU xml. Supports options.vars. Also has {{pageIndex}} */
|
|
13
15
|
singlePageDjvuXmlUrl: null,
|
|
16
|
+
/** Whether to fetch the XML as a jsonp */
|
|
17
|
+
jsonp: false,
|
|
14
18
|
};
|
|
15
19
|
/** @typedef {typeof DEFAULT_OPTIONS} TextSelectionPluginOptions */
|
|
16
20
|
|
|
@@ -46,7 +50,7 @@ export class TextSelectionPlugin {
|
|
|
46
50
|
// Tspans are necessary on Chrome because they prevent newline character after every word when copying
|
|
47
51
|
this.svgParagraphElement = "text";
|
|
48
52
|
this.svgWordElement = "tspan";
|
|
49
|
-
this.insertNewlines = avoidTspans
|
|
53
|
+
this.insertNewlines = avoidTspans;
|
|
50
54
|
// Safari has a bug where `pointer-events` doesn't work on `<tspans>`. So
|
|
51
55
|
// there we will set `pointer-events: all` on the paragraph element. We don't
|
|
52
56
|
// do this everywhere, because it's a worse experience. Thanks Safari :/
|
|
@@ -72,7 +76,8 @@ export class TextSelectionPlugin {
|
|
|
72
76
|
this.djvuPagesPromise = $.ajax({
|
|
73
77
|
type: "GET",
|
|
74
78
|
url: applyVariables(this.options.fullDjvuXmlUrl, this.optionVariables),
|
|
75
|
-
dataType: "html",
|
|
79
|
+
dataType: this.options.jsonp ? "jsonp" : "html",
|
|
80
|
+
cache: true,
|
|
76
81
|
error: (e) => undefined
|
|
77
82
|
}).then((res) => {
|
|
78
83
|
try {
|
|
@@ -94,21 +99,21 @@ export class TextSelectionPlugin {
|
|
|
94
99
|
if (cachedEntry) {
|
|
95
100
|
return cachedEntry.response;
|
|
96
101
|
}
|
|
97
|
-
|
|
102
|
+
const res = await $.ajax({
|
|
98
103
|
type: "GET",
|
|
99
104
|
url: applyVariables(this.options.singlePageDjvuXmlUrl, this.optionVariables, { pageIndex: index }),
|
|
100
|
-
dataType: "html",
|
|
105
|
+
dataType: this.options.jsonp ? "jsonp" : "html",
|
|
106
|
+
cache: true,
|
|
101
107
|
error: (e) => undefined,
|
|
102
|
-
}).then((res) => {
|
|
103
|
-
try {
|
|
104
|
-
const xmlDoc = $.parseXML(res);
|
|
105
|
-
const result = xmlDoc && $(xmlDoc).find("OBJECT")[0];
|
|
106
|
-
this.pageTextCache.add({ index, response: result });
|
|
107
|
-
return result;
|
|
108
|
-
} catch (e) {
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
108
|
});
|
|
109
|
+
try {
|
|
110
|
+
const xmlDoc = $.parseXML(res);
|
|
111
|
+
const result = xmlDoc && $(xmlDoc).find("OBJECT")[0];
|
|
112
|
+
this.pageTextCache.add({ index, response: result });
|
|
113
|
+
return result;
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
112
117
|
} else {
|
|
113
118
|
const XMLpagesArr = await this.djvuPagesPromise;
|
|
114
119
|
if (XMLpagesArr) return XMLpagesArr[index];
|
|
@@ -144,8 +149,8 @@ export class TextSelectionPlugin {
|
|
|
144
149
|
this.textSelectingMode(svg);
|
|
145
150
|
}
|
|
146
151
|
else svg.classList.remove("selectingSVG");
|
|
147
|
-
})
|
|
148
|
-
})
|
|
152
|
+
});
|
|
153
|
+
});
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
/**
|
|
@@ -158,13 +163,13 @@ export class TextSelectionPlugin {
|
|
|
158
163
|
if (window.getSelection().toString() != "") window.getSelection().removeAllRanges();
|
|
159
164
|
}
|
|
160
165
|
event.stopPropagation();
|
|
161
|
-
})
|
|
166
|
+
});
|
|
162
167
|
$(svg).on('mouseup.textSelectPluginHandler', (event) => {
|
|
163
168
|
event.stopPropagation();
|
|
164
169
|
if (window.getSelection().toString() == "") {
|
|
165
170
|
$(svg).off(".textSelectPluginHandler");
|
|
166
171
|
this.defaultMode(svg); }
|
|
167
|
-
})
|
|
172
|
+
});
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
/**
|
|
@@ -175,21 +180,20 @@ export class TextSelectionPlugin {
|
|
|
175
180
|
/** @type {JQuery<SVGElement>} */
|
|
176
181
|
const $svg = $container.find('svg.textSelectionSVG');
|
|
177
182
|
if (!$svg.length) return;
|
|
178
|
-
$svg.each((i, s) => this.defaultMode(s))
|
|
183
|
+
$svg.each((i, s) => this.defaultMode(s));
|
|
179
184
|
this.interceptCopy($container);
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
/**
|
|
183
|
-
* @param {
|
|
184
|
-
* @param {JQuery} $container
|
|
188
|
+
* @param {PageContainer} pageContainer
|
|
185
189
|
*/
|
|
186
|
-
async createTextLayer(
|
|
190
|
+
async createTextLayer(pageContainer) {
|
|
191
|
+
const pageIndex = pageContainer.page.index;
|
|
192
|
+
const $container = pageContainer.$container;
|
|
187
193
|
const $svgLayers = $container.find('.textSelectionSVG');
|
|
188
194
|
if ($svgLayers.length) return;
|
|
189
195
|
const XMLpage = await this.getPageText(pageIndex);
|
|
190
196
|
if (!XMLpage) return;
|
|
191
|
-
const XMLwidth = $(XMLpage).attr("width");
|
|
192
|
-
const XMLheight = $(XMLpage).attr("height");
|
|
193
197
|
|
|
194
198
|
const totalWords = $(XMLpage).find("WORD").length;
|
|
195
199
|
if (totalWords > this.maxWordRendered) {
|
|
@@ -197,19 +201,8 @@ export class TextSelectionPlugin {
|
|
|
197
201
|
return;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
const svg =
|
|
201
|
-
svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
202
|
-
svg.setAttribute("viewBox", `0 0 ${XMLwidth} ${XMLheight}`);
|
|
204
|
+
const svg = createSVGPageLayer(pageContainer.page, 'textSelectionSVG');
|
|
203
205
|
$container.append(svg);
|
|
204
|
-
svg.setAttribute('class', 'textSelectionSVG');
|
|
205
|
-
svg.setAttribute('preserveAspectRatio', 'none');
|
|
206
|
-
$(svg).css({
|
|
207
|
-
"width": "100%",
|
|
208
|
-
"position": "absolute",
|
|
209
|
-
"height": "100%",
|
|
210
|
-
"top": "0",
|
|
211
|
-
"left": "0",
|
|
212
|
-
});
|
|
213
206
|
|
|
214
207
|
$(XMLpage).find("PARAGRAPH").each((i, paragraph) => {
|
|
215
208
|
// Adding text element for each paragraph in the page
|
|
@@ -266,7 +259,7 @@ export class TextSelectionPlugin {
|
|
|
266
259
|
const paragWordHeight = wordHeightArr[Math.floor(wordHeightArr.length * 0.85)];
|
|
267
260
|
paragSvg.setAttribute("font-size", paragWordHeight.toString());
|
|
268
261
|
svg.appendChild(paragSvg);
|
|
269
|
-
})
|
|
262
|
+
});
|
|
270
263
|
this.stopPageFlip($container);
|
|
271
264
|
}
|
|
272
265
|
}
|
|
@@ -290,11 +283,9 @@ export class BookreaderWithTextSelection extends BookReader {
|
|
|
290
283
|
_createPageContainer(index) {
|
|
291
284
|
const pageContainer = super._createPageContainer(index);
|
|
292
285
|
// Disable if thumb mode; it's too janky
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (this.mode !== this.constModeThumb && (index >= 0 && index <= lastPageIndex)) {
|
|
297
|
-
this.textSelectionPlugin?.createTextLayer(index, pageContainer.$container);
|
|
286
|
+
// .page can be null for "pre-cover" region
|
|
287
|
+
if (this.mode !== this.constModeThumb && pageContainer.page) {
|
|
288
|
+
this.textSelectionPlugin?.createTextLayer(pageContainer);
|
|
298
289
|
}
|
|
299
290
|
return pageContainer;
|
|
300
291
|
}
|
|
@@ -56,7 +56,7 @@ if (!isMobile()) {
|
|
|
56
56
|
$(document.body).append(cboxOverlay).append(cbox);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
60
|
})(BookReader.prototype.init);
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -92,7 +92,7 @@ if (!isMobile()) {
|
|
|
92
92
|
$(document).off('keyup' + EVENT_NAMESPACE);
|
|
93
93
|
|
|
94
94
|
this.isFullscreenActive = false;
|
|
95
|
-
this.updateBrClasses()
|
|
95
|
+
this.updateBrClasses();
|
|
96
96
|
|
|
97
97
|
this.resize();
|
|
98
98
|
this.refs.$brContainer.animate({ opacity: 1 }, 400, 'linear');
|
|
@@ -233,8 +233,8 @@ export function bindFullscreenChangeListener(
|
|
|
233
233
|
'moz',
|
|
234
234
|
'ms'
|
|
235
235
|
];
|
|
236
|
-
const all_events =
|
|
237
|
-
$(document).
|
|
236
|
+
const all_events = (event + vendor_prefixes.join(event) + event).trim();
|
|
237
|
+
$(document).on(all_events, data, fullscreenchangeListener);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|