mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve rendering of item lists
This commit is contained in:
parent
eed56b0ee5
commit
75e71e34e9
@ -17,10 +17,10 @@ class ItemsView:
|
|||||||
style = ''
|
style = ''
|
||||||
cid = '#' + self.container_id
|
cid = '#' + self.container_id
|
||||||
style += build_rule(cid + ' li', padding='1em', border_bottom='solid 1px ' + get_color('window-foreground'), border_top='solid 1px ' + get_color('window-background'), cursor='pointer', list_style='none')
|
style += build_rule(cid + ' li', padding='1em', border_bottom='solid 1px ' + get_color('window-foreground'), border_top='solid 1px ' + get_color('window-background'), cursor='pointer', list_style='none')
|
||||||
style += build_rule(cid + ' .title', font_size=get_font_size('item-list-title'))
|
style += build_rule(cid + ' .item-title', font_size=get_font_size('item-list-title'))
|
||||||
style += build_rule(cid + ' .subtitle', font_size=get_font_size('item-list-subtitle'), font_style='italic')
|
style += build_rule(cid + ' .item-subtitle', font_size=get_font_size('item-list-subtitle'), font_style='italic')
|
||||||
style += build_rule(cid + ' li:hover', color=get_color('list-hover-foreground'), background_color=get_color('list-hover-background'), border_top_color=get_color('list-hover-foreground'))
|
style += build_rule(cid + ' li:hover', color=get_color('list-hover-foreground'), background_color=get_color('list-hover-background'), border_top_color=get_color('list-hover-foreground'))
|
||||||
style += build_rule(cid + ' li:active')
|
style += build_rule(cid + ' li:active', transform='scale(1, 1.5)')
|
||||||
self.base_style = style
|
self.base_style = style
|
||||||
div = E.div(
|
div = E.div(
|
||||||
id=self.container_id, style='display:none',
|
id=self.container_id, style='display:none',
|
||||||
@ -51,25 +51,28 @@ class ItemsView:
|
|||||||
subtitle = getattr(data, 'subtitle', None)
|
subtitle = getattr(data, 'subtitle', None)
|
||||||
c = self.clear()
|
c = self.clear()
|
||||||
if subtitle:
|
if subtitle:
|
||||||
c.appendChild(E.p(subtitle))
|
c.appendChild(E.p(subtitle, style="font-style:italic; padding: 1em 1ex; border-bottom: solid 1px currentColor"))
|
||||||
ul = E.ul()
|
ul = E.ul()
|
||||||
c.appendChild(ul)
|
c.appendChild(ul)
|
||||||
has_icons = has_subtitles = False
|
has_icons = False
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.icon_name:
|
if item.icon_name:
|
||||||
has_icons = True
|
has_icons = True
|
||||||
if item.subtitle:
|
|
||||||
has_subtitles = True
|
|
||||||
if has_icons and has_subtitles:
|
|
||||||
break
|
break
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
|
ic = ''
|
||||||
|
if has_icons:
|
||||||
|
ic = 'fa fa-fw '
|
||||||
|
if item.icon_name:
|
||||||
|
ic += ' fa-' + item.icon_name
|
||||||
|
ic = E.span('\xa0', class_=ic)
|
||||||
ul.appendChild(E.li(E.a(href='javascript:void(0)',
|
ul.appendChild(E.li(E.a(href='javascript:void(0)',
|
||||||
E.div(item.title, class_='title')
|
E.div(ic, item.title, class_='item-title')
|
||||||
)))
|
)))
|
||||||
a = ul.lastChild.firstChild
|
a = ul.lastChild.firstChild
|
||||||
if item.subtitle:
|
if item.subtitle:
|
||||||
a.appendChild(E.div(item.subtitle, class_='subtitle'))
|
a.appendChild(E.div(item.subtitle, class_='item-subtitle', style='padding-top:1ex'))
|
||||||
a.addEventListener('click', def(event): event.preventDefault();)
|
a.addEventListener('click', def(event): event.preventDefault();)
|
||||||
if item.action:
|
if item.action:
|
||||||
ul.lastChild.addEventListener('click', item.action)
|
ul.lastChild.addEventListener('click', item.action)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user