summaryrefslogtreecommitdiff
path: root/js/reader_iframe.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-04-21 10:51:19 +0300
committerAndrew Dolgov <[email protected]>2020-04-21 10:51:19 +0300
commitdcc41c8200af4ed95c281a604c33c631ca5ff01b (patch)
tree84a4000ce692aa26f2731f5e50458b4fc49382d5 /js/reader_iframe.js
parentd7b02e140e628fcb0ba838925ff0ad4237dbb6cd (diff)
rework reader to use global Reader object
various theme-related fixes
Diffstat (limited to 'js/reader_iframe.js')
-rw-r--r--js/reader_iframe.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/reader_iframe.js b/js/reader_iframe.js
new file mode 100644
index 0000000..a31b9ac
--- /dev/null
+++ b/js/reader_iframe.js
@@ -0,0 +1,61 @@
+'use strict';
+
+/* global EpubeApp */
+
+let Reader;
+
+function enable_swipes() {
+ $(window).off("swipeleft swiperight");
+
+ $(window).on("swipeleft", function() {
+ Reader.Page.next();
+ });
+
+ $(window).on("swiperight", function() {
+ Reader.Page.prev();
+ });
+}
+
+$(document).ready(function() {
+ Reader = parent.__get_reader();
+
+ $(window).on("doubletap", function(/* evt */) {
+ const sel = getSelection().toString().trim();
+
+ if (sel.match(/^$/)) {
+ Reader.toggleFullscreen();
+ }
+ });
+
+ $(window).on("click tap", function(evt) {
+ if (evt.button == 0) {
+
+ if ($(".modal").is(":visible"))
+ return;
+
+ if (typeof EpubeApp != "undefined")
+ EpubeApp.toggleActionBar();
+ else
+ Reader.showUI(true);
+ }
+ });
+
+ $(window).on("touchstart", function() {
+ enable_swipes();
+ });
+
+ $(window).on("mousedown", function() {
+ $(window).off("swipeleft swiperight");
+ });
+
+ $(window).on("wheel", function(evt) {
+ if (evt.originalEvent.deltaY > 0) {
+ Reader.Page.prev();
+ } else if (evt.originalEvent.deltaY < 0) {
+ Reader.Page.next();
+ }
+ });
+
+ enable_swipes();
+});
+