summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/index.css5
-rw-r--r--css/read.css7
-rw-r--r--index.php12
-rw-r--r--js/common.js23
-rw-r--r--js/read.js53
-rw-r--r--js/reader.js8
-rw-r--r--offline.html9
7 files changed, 101 insertions, 16 deletions
diff --git a/css/index.css b/css/index.css
index b1a200d..144d5e0 100644
--- a/css/index.css
+++ b/css/index.css
@@ -26,6 +26,11 @@
filter : grayscale(100%);
}
+.epube-app-filler {
+ height : 60px;
+ display : none;
+}
+
.in_progress {
font-style : italic;
}
diff --git a/css/read.css b/css/read.css
index 364e22b..2b8153e 100644
--- a/css/read.css
+++ b/css/read.css
@@ -163,3 +163,10 @@
background-color:rgba(0,0,0,0.1);
}
+body.is-epube-app .header {
+ display : none ! important;
+}
+
+body.is-epube-app #reader {
+ top : 0px;
+} \ No newline at end of file
diff --git a/index.php b/index.php
index c6c5306..bc9419c 100644
--- a/index.php
+++ b/index.php
@@ -131,12 +131,24 @@
</div>
</div>
+<div class="epube-app-filler"></div>
+
<script type="text/javascript">
var index_mode = "<?php echo $mode ?>";
$(document).ready(function() {
let refreshed_files = 0;
+ if (typeof EpubeApp != "undefined") {
+ $(".navbar").hide();
+ $(".epube-app-filler").show();
+
+ if ($.urlParam("mode") == "favorites")
+ EpubeApp.setPage("PAGE_FAVORITES");
+ else
+ EpubeApp.setPage("PAGE_LIBRARY");
+ }
+
init_night_mode();
if ('serviceWorker' in navigator) {
diff --git a/js/common.js b/js/common.js
index ecc8206..45851a7 100644
--- a/js/common.js
+++ b/js/common.js
@@ -50,3 +50,26 @@ function apply_night_mode(is_night) {
$("#theme_css").attr("href",
"lib/bootstrap/v3/css/" + (is_night ? "theme-dark.min.css" : "bootstrap-theme.min.css"));
}
+
+const Cookie = {
+ set: function (name, value, lifetime) {
+ const d = new Date();
+ d.setTime(d.getTime() + lifetime * 1000);
+ const expires = "expires=" + d.toUTCString();
+ document.cookie = name + "=" + encodeURIComponent(value) + "; " + expires;
+ },
+ get: function (name) {
+ name = name + "=";
+ const ca = document.cookie.split(';');
+ for (let i=0; i < ca.length; i++) {
+ let c = ca[i];
+ while (c.charAt(0) == ' ') c = c.substring(1);
+ if (c.indexOf(name) == 0) return decodeURIComponent(c.substring(name.length, c.length));
+ }
+ return "";
+ },
+ delete: function(name) {
+ const expires = "expires=Thu, 01-Jan-1970 00:00:01 GMT";
+ document.cookie = name + "=" + "" + "; " + expires;
+ }
+};
diff --git a/js/read.js b/js/read.js
index 86a630f..c22b4d0 100644
--- a/js/read.js
+++ b/js/read.js
@@ -1,6 +1,6 @@
'use strict';
-/* globals ePub, localforage, book, cacheId */
+/* globals ePub, localforage, book, cacheId, EpubeApp */
let _pagination_stored = 0;
let _last_position_sync = 0;
@@ -62,8 +62,18 @@ function check_resource_load(res_names, res_data, attempt) {
}
function init_reader() {
+ if (typeof EpubeApp != "undefined") {
+ EpubeApp.setPage("PAGE_READER");
+ }
+
apply_theme();
+ /* global Cookie */
+
+ if (Cookie.get("is-epube-app") == "true") {
+ $("body").addClass("is-epube-app");
+ }
+
$(window).on('online', function() {
console.log("we're online, storing lastread");
@@ -471,6 +481,11 @@ function init_reader() {
document.title = meta.title + " – " + meta.creator + " – The Epube";
$(".title").text(meta.title);
+ if (typeof EpubeApp != "undefined") {
+ EpubeApp.setTitle(meta.title);
+ EpubeApp.showActionBar(false);
+ }
+
return localforage.getItem(cacheId("locations")).then(function(locations) {
console.log('stored pagination', locations != null);
@@ -664,16 +679,20 @@ function init_reader() {
/* exported toggle_fullscreen */
function toggle_fullscreen() {
- const element = document.documentElement;
- const isFullscreen = document.webkitIsFullScreen || document.mozFullScreen || false;
+ if (typeof EpubeApp != "undefined") {
+ EpubeApp.toggleSystemUI();
+ } else {
+ const element = document.documentElement;
+ const isFullscreen = document.webkitIsFullScreen || document.mozFullScreen || false;
- element.requestFullScreen = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen ||
- function () { return false; };
+ element.requestFullScreen = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen ||
+ function () { return false; };
- document.cancelFullScreen = document.cancelFullScreen || document.webkitCancelFullScreen || document.mozCancelFullScreen ||
- function () { return false; };
+ document.cancelFullScreen = document.cancelFullScreen || document.webkitCancelFullScreen || document.mozCancelFullScreen ||
+ function () { return false; };
- isFullscreen ? document.cancelFullScreen() : element.requestFullScreen();
+ isFullscreen ? document.cancelFullScreen() : element.requestFullScreen();
+ }
}
function show_ui(show) {
@@ -746,17 +765,23 @@ function next_page() {
window.book.rendition.next();
- localforage.getItem("epube.keep-ui-visible").then(function(keep) {
- if (!keep) show_ui(false);
- });
+ if (typeof EpubeApp != "undefined")
+ EpubeApp.showActionBar(false);
+ else
+ localforage.getItem("epube.keep-ui-visible").then(function(keep) {
+ if (!keep) show_ui(false);
+ });
}
function prev_page() {
window.book.rendition.prev();
- localforage.getItem("epube.keep-ui-visible").then(function(keep) {
- if (!keep) show_ui(false);
- });
+ if (typeof EpubeApp != "undefined")
+ EpubeApp.showActionBar(false);
+ else
+ localforage.getItem("epube.keep-ui-visible").then(function(keep) {
+ if (!keep) show_ui(false);
+ });
}
function hotkey_handler(e) {
diff --git a/js/reader.js b/js/reader.js
index 537835a..1f6509a 100644
--- a/js/reader.js
+++ b/js/reader.js
@@ -1,5 +1,7 @@
'use strict';
+/* global EpubeApp */
+
function enable_swipes() {
$(window).off("swipeleft swiperight");
@@ -15,7 +17,6 @@ function enable_swipes() {
$(document).ready(function() {
$(window).on("doubletap", function(/* evt */) {
-
const sel = getSelection().toString().trim();
if (sel.match(/^$/)) {
@@ -29,7 +30,10 @@ $(document).ready(function() {
if ($(".modal").is(":visible"))
return;
- parent.show_ui(true);
+ if (typeof EpubeApp != "undefined")
+ EpubeApp.toggleActionBar();
+ else
+ parent.show_ui(true);
}
});
diff --git a/offline.html b/offline.html
index 7a25051..6d315b5 100644
--- a/offline.html
+++ b/offline.html
@@ -62,11 +62,20 @@
</div>
</div>
+<div class="epube-app-filler"></div>
+
<script type="text/javascript">
'use strict';
$(document).ready(function() {
+ if (typeof EpubeApp != "undefined") {
+ $(".navbar").hide();
+ $(".epube-app-filler").show();
+
+ EpubeApp.setPage("PAGE_OFFLINE");
+ }
+
init_night_mode();
if ('serviceWorker' in navigator) {