diff --git a/cps/static/js/reading/epub.js b/cps/static/js/reading/epub.js index 8908a3263..21663a6ab 100644 --- a/cps/static/js/reading/epub.js +++ b/cps/static/js/reading/epub.js @@ -123,11 +123,7 @@ var reader; reader.book.ready.then(() => { const savedFontSize = localStorage.getItem("calibre.reader.fontSize"); if (savedFontSize) { - const fontSizeFader = document.getElementById("fontSizeFader"); - if (fontSizeFader) { - fontSizeFader.value = savedFontSize; - reader.rendition.themes.fontSize(`${savedFontSize}%`); - } + reader.rendition.themes.fontSize(`${savedFontSize}%`); } }); })(); diff --git a/cps/templates/read.html b/cps/templates/read.html index 28f931935..f31b97141 100644 --- a/cps/templates/read.html +++ b/cps/templates/read.html @@ -158,16 +158,40 @@

-
- - + +
+ + 100% +
@@ -273,13 +297,40 @@ } // font size settings logic - let fontSizeFader = document.getElementById("fontSizeFader"); + let currentFontSize = 100; // default 100% + const minFontSize = 50; + const maxFontSize = 300; + const stepSize = 5; - // Save font size when changed - fontSizeFader.addEventListener("change", function () { - const fontSize = this.value; - localStorage.setItem("calibre.reader.fontSize", fontSize); - reader.rendition.themes.fontSize(`${fontSize}%`); + const fontSizeDisplay = document.getElementById("fontSizeDisplay"); + const fontSizeDecrease = document.getElementById("fontSizeDecrease"); + const fontSizeIncrease = document.getElementById("fontSizeIncrease"); + + function updateFontSize(newSize) { + if (newSize < minFontSize) newSize = minFontSize; + if (newSize > maxFontSize) newSize = maxFontSize; + + currentFontSize = newSize; + fontSizeDisplay.textContent = newSize + "%"; + localStorage.setItem("calibre.reader.fontSize", newSize); + if (reader && reader.rendition) { + reader.rendition.themes.fontSize(`${newSize}%`); + } + } + + // Restore saved font size on load + const savedFontSize = localStorage.getItem("calibre.reader.fontSize"); + if (savedFontSize) { + currentFontSize = parseInt(savedFontSize); + fontSizeDisplay.textContent = savedFontSize + "%"; + } + + fontSizeDecrease.addEventListener("click", function () { + updateFontSize(currentFontSize - stepSize); + }); + + fontSizeIncrease.addEventListener("click", function () { + updateFontSize(currentFontSize + stepSize); }); let defaultFont;