mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix examples link not working in user stylesheets prefs
This commit is contained in:
parent
d35e5c78ed
commit
15cb1aaccc
@ -1,43 +1,41 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
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'
|
||||
' <a class="{cls}" href="{url}" target="{target}" title="Examples of user style sheets">here</a>.'
|
||||
).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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user