From 15cb1aaccc69dfce8c783eb9fc8ff2d9e821d6c1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 24 Sep 2019 17:52:32 +0530 Subject: [PATCH] Fix examples link not working in user stylesheets prefs --- src/pyj/read_book/prefs/user_stylesheet.pyj | 44 ++++++++++----------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/pyj/read_book/prefs/user_stylesheet.pyj b/src/pyj/read_book/prefs/user_stylesheet.pyj index f661e6ff91..2ae54b30db 100644 --- a/src/pyj/read_book/prefs/user_stylesheet.pyj +++ b/src/pyj/read_book/prefs/user_stylesheet.pyj @@ -1,43 +1,41 @@ # vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2016, Kovid Goyal -from __python__ import hash_literals, bound_methods +from __python__ import bound_methods, hash_literals -from gettext import gettext as _ -from dom import add_extra_css, build_rule, unique_id -from book_list.globals import get_session_data from elementmaker import E +from gettext import gettext as _ -CONTAINER = unique_id('reader-us-prefs') +from book_list.globals import get_session_data +from read_book.globals import runtime -add_extra_css(def(): - sel = '#' + CONTAINER - style = '' - style += build_rule(sel, display="flex", flex_direction="column") - style += build_rule(sel + ' textarea', margin_left='1em', margin_right='1em', min_height='75vh') - style += build_rule(sel + ' .simple-link', color='blue') - return style -) def create_user_stylesheet_panel(container): - container.appendChild(E.div(id=CONTAINER)) - container = container.lastChild sd = get_session_data() - container.appendChild(E.div(style='margin:1ex 1rem; padding: 1ex 0')) - container.firstChild.innerHTML = _( - 'A CSS style sheet that can be used to control the look and feel of books. For examples, click' - ' here.' - ).format(url='https://www.mobileread.com/forums/showthread.php?t=51500', target="_blank", cls="simple-link") - container.appendChild(E.textarea(style="flex-grow: 10")) + container.appendChild( + E.div( + style='min-height: 80vh; display: flex; flex-flow: column; margin: 1ex 1rem; padding: 1ex 0', + E.div( + style='flex-grow: 10; display: flex; flex-flow: column', + E.div( + _('A CSS style sheet that can be used to control the look and feel of books. For examples, click'), ' ', + E.a(class_='simple-link', style='color: blue', title=_("Examples of user style sheets"), + target=('_self' if runtime.is_standalone_viewer else '_blank'), + href='https://www.mobileread.com/forums/showthread.php?t=51500', _('here')) + ), + E.textarea(name='user-stylesheet', style='width: 100%; margin-top: 1ex; box-sizing: border-box; flex-grow: 10') + ) + ) + ) val = sd.get('user_stylesheet') if val: - container.lastChild.value = val + container.querySelector('[name=user-stylesheet]').value = val develop = create_user_stylesheet_panel def commit_user_stylesheet(onchange, container): sd = get_session_data() - ta = document.getElementById(CONTAINER).querySelector('textarea') + ta = container.querySelector('[name=user-stylesheet]') val = ta.value or '' old = sd.get('user_stylesheet') if old is not val: