summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-13 14:44:44 +0300
committerAndrew Dolgov <[email protected]>2020-09-13 14:44:44 +0300
commitd3da50c11bf1b9ab6b1868e0a727f5d3a5c07c10 (patch)
tree684c93cd5248c0dbd0ab90327c4d37647acd1560 /js
parent102e14b21140e5073e407cfd9d6d764707ad011d (diff)
force-justify longer paragraphs
Diffstat (limited to 'js')
-rw-r--r--js/reader.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/js/reader.js b/js/reader.js
index 7cfb2ad..ff7c3e3 100644
--- a/js/reader.js
+++ b/js/reader.js
@@ -5,6 +5,7 @@
const DEFAULT_FONT_SIZE = 16;
const DEFAULT_FONT_FAMILY = "Georgia";
const DEFAULT_LINE_HEIGHT = 140;
+const MIN_LENGTH_TO_JUSTIFY = 32; /* characters */
const Reader = {
init: function() {
@@ -706,9 +707,13 @@ const Reader = {
//$($("#reader iframe")[0].contentDocument).find("#theme_css").text(Reader.Loader._res_data[theme_url])
$.each(window.book.rendition.getContents(), function(i, c) {
- console.log('applying rendition theme', theme);
+ console.log('applying rendition theme', theme, 'to', c, c.document);
$(c.document).find("#theme_css").text(Reader.Loader._res_data[theme_url])
+
+ $(c.document).find("p")
+ .filter((i, e) => { if ($(e).text().length >= MIN_LENGTH_TO_JUSTIFY) return e; })
+ .css("text-align", "justify");
});
});