From 9047d0e3746820988f6a23ac1ca1f001f4c70c3e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 3 Mar 2017 13:32:59 +0300 Subject: settings: use dropdowns for font size/line height --- read.html | 62 +++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 15 deletions(-) (limited to 'read.html') diff --git a/read.html b/read.html index 749e26a..4f6be0d 100644 --- a/read.html +++ b/read.html @@ -44,20 +44,14 @@
-
- - -
+
- +
-
- - -
+
@@ -213,6 +207,10 @@ var _pagination_stored = 0; var _last_position_sync = 0; + const DEFAULT_FONT_SIZE = 16; + const DEFAULT_FONT_FAMILY = "Georgia"; + const DEFAULT_LINE_HEIGHT = 140; + function cacheId(suffix) { return "epube-book." + $.urlParam("b") + (suffix ? "." + suffix : ""); } @@ -331,9 +329,9 @@ localforage.getItem("epube.fontFamily"), localforage.getItem("epube.lineHeight") ]).then(function(res) { - var fontSize = res[0] ? res[0] + "px" : "16px"; - var fontFamily = res[1] ? res[1] : "Georgia"; - var lineHeight = res[2] ? res[2] + "%" : "140%"; + var fontSize = res[0] ? res[0] + "px" : DEFAULT_FONT_SIZE + "px"; + var fontFamily = res[1] ? res[1] : DEFAULT_FONT_FAMILY; + var lineHeight = res[2] ? res[2] + "%" : DEFAULT_LINE_HEIGHT + "%"; book.setStyle("fontSize", fontSize); book.setStyle("fontFamily", fontFamily); @@ -350,14 +348,48 @@ var rendered = book.renderTo("reader"); $('#settings-modal').on('shown.bs.modal', function() { - var font = book.settings.styles.fontFamily; - - $("select.font_family").val(font); $.post("backend.php", { op: "getlastread", id: $.urlParam("id") }, function(data) { $(".lastread_input").val(data.page); }); + localforage.getItem("epube.fontFamily").then(function(font) { + if (!font) font = DEFAULT_FONT_FAMILY; + + $(".font_family").val(font); + }); + + localforage.getItem("epube.fontSize").then(function(size) { + + if (!size) size = DEFAULT_FONT_SIZE; + + var zoom = $(".font_size").html(""); + + for (var i = 10; i <= 32; i++) { + var opt = $("