mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement show/hide for results in a chapter
This commit is contained in:
parent
2b34c68901
commit
29f5e40104
@ -202,7 +202,12 @@ class SearchOverlay:
|
|||||||
group = E.div(
|
group = E.div(
|
||||||
data_toc_node_id=toc_node_id + '',
|
data_toc_node_id=toc_node_id + '',
|
||||||
data_spine_index=result.spine_idx + '',
|
data_spine_index=result.spine_idx + '',
|
||||||
E.div(toc_node?.title or _('Unknown')),
|
E.div(
|
||||||
|
toc_node?.title or _('Unknown'),
|
||||||
|
title=_('Click to show/hide the results in this chapter'),
|
||||||
|
onclick=def(ev):
|
||||||
|
ev.target.parentNode.classList.toggle('collapsed')
|
||||||
|
),
|
||||||
E.ul()
|
E.ul()
|
||||||
)
|
)
|
||||||
appended = False
|
appended = False
|
||||||
@ -226,7 +231,7 @@ class SearchOverlay:
|
|||||||
|
|
||||||
if result.before:
|
if result.before:
|
||||||
entry.appendChild(E.span('…' + result.before + ' '))
|
entry.appendChild(E.span('…' + result.before + ' '))
|
||||||
entry.appendChild(E.b(result.text))
|
entry.appendChild(E.strong(result.text))
|
||||||
if result.after:
|
if result.after:
|
||||||
entry.appendChild(E.span(' ' + result.after + '…'))
|
entry.appendChild(E.span(' ' + result.after + '…'))
|
||||||
ul.appendChild(entry)
|
ul.appendChild(entry)
|
||||||
@ -293,8 +298,10 @@ add_extra_css(def():
|
|||||||
sel = f'#{SearchOverlay.CONTAINER_ID} '
|
sel = f'#{SearchOverlay.CONTAINER_ID} '
|
||||||
sel += ' div[data-toc-node-id]'
|
sel += ' div[data-toc-node-id]'
|
||||||
css += build_rule(sel, margin='1rem')
|
css += build_rule(sel, margin='1rem')
|
||||||
|
css += build_rule(sel + '.collapsed ul', display='none')
|
||||||
css += build_rule(sel + ' > div', font_style='italic', font_weight='bold', cursor='pointer')
|
css += build_rule(sel + ' > div', font_style='italic', font_weight='bold', cursor='pointer')
|
||||||
css += build_rule(sel + ' li', list_style_type='none', margin='1rem', margin_right='0')
|
css += build_rule(sel + ' li', list_style_type='none', margin='1rem', margin_right='0', cursor='pointer')
|
||||||
|
css += build_rule(sel + ' li strong', color=get_color('link-foreground'), font_style='italic')
|
||||||
return css
|
return css
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user