diff options
author | Andrew Dolgov <[email protected]> | 2018-02-01 15:22:59 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-02-01 15:22:59 +0300 |
commit | 47568440c08487f804b6eee47e1a4023529dea9f (patch) | |
tree | ab97384d3cbb372239d16a25a510a4b9d0696836 /read.html | |
parent | 7767c37aeacef72929f8b13e2bd8b974d15424a9 (diff) |
another take on overriding inline epub styles
Diffstat (limited to 'read.html')
-rw-r--r-- | read.html | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -411,14 +411,18 @@ }); } + var fontSize; + var fontFamily; + var lineHeight; + Promise.all([ localforage.getItem("epube.fontSize"), localforage.getItem("epube.fontFamily"), localforage.getItem("epube.lineHeight") ]).then(function(res) { - 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 + "%"; + fontSize = res[0] ? res[0] + "px" : DEFAULT_FONT_SIZE + "px"; + fontFamily = res[1] ? res[1] : DEFAULT_FONT_FAMILY; + lineHeight = res[2] ? res[2] + "%" : DEFAULT_LINE_HEIGHT + "%"; book.setStyle("fontSize", fontSize); book.setStyle("fontFamily", fontFamily); @@ -428,9 +432,6 @@ }); - - //styles: { fontSize: '24px', lineHeight: '130%', fontFamily: 'Georgia' } - window.book = book; var rendered = book.renderTo("reader"); @@ -650,15 +651,12 @@ book.on("renderer:chapterDisplayed", function() { // cleanup possibly interfering styles - var c = $("#reader iframe").contents(); - - c.find("p") - .removeAttr("style") - .removeAttr("class") - .css("margin", "0px"); + // variables defined above after reading from localforage - c.find("*") - .removeAttr("class"); + $("#reader iframe").contents().find("*") + .css("font-family", fontFamily) + .css("font-size", fontSize) + .css("line-height", lineHeight); }); |