Use a URL for the web viewer background image setting

This commit is contained in:
Kovid Goyal 2019-09-25 10:34:40 +05:30
parent 3b1753f134
commit 7d6d5b71c6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -23,7 +23,7 @@ def clear_image(img_id):
document.getElementById(img_id).src = BLANK
def background_widget(sd):
def standalone_background_widget(sd):
if sd.get('background_image'):
src = READER_BACKGROUND_URL
else:
@ -40,6 +40,15 @@ def background_widget(sd):
)
def background_widget(sd):
if runtime.is_standalone_viewer:
return standalone_background_widget(sd)
return E.div(style='margin-bottom: 1ex', E.label(
_('Image URL') + ':\xa0',
E.input(type='url', name='background_image', value=sd.get('background_image') or '')
))
def background_style_widget(sd):
ans = E.div(E.label(
_('Background image style') + ':\xa0',
@ -91,9 +100,12 @@ def commit_user_stylesheet(onchange, container):
if old is not val:
sd.set('user_stylesheet', val)
changed = True
bg_image = container.querySelector('img.bg-image-preview').src
if bg_image is BLANK:
bg_image = None
if runtime.is_standalone_viewer:
bg_image = container.querySelector('img.bg-image-preview').src
if bg_image is BLANK:
bg_image = None
else:
bg_image = container.querySelector('input[name=background_image]').value
old = sd.get('background_image')
if old is not bg_image:
sd.set('background_image', bg_image)