| 1 |
# vim:fileencoding=utf-8 |
| 2 |
# License: GPL v3 Copyright: 2026 |
| 3 |
from __python__ import hash_literals |
| 4 |
|
| 5 |
from elementmaker import E |
| 6 |
from gettext import gettext as _ |
| 7 |
|
| 8 |
from ajax import ajax |
| 9 |
from book_list.globals import get_session_data |
| 10 |
from book_list.item_list import create_item, create_item_list |
| 11 |
from book_list.library_data import browse_field_for, url_books_query, cover_url, current_library_id |
| 12 |
from book_list.router import back, update_window_title |
| 13 |
from book_list.theme import get_color |
| 14 |
from book_list.top_bar import create_top_bar |
| 15 |
from book_list.ui import set_panel_handler, show_panel |
| 16 |
from dom import add_extra_css, build_rule, clear, svgicon |
| 17 |
from session import get_interface_data |
| 18 |
from utils import parse_url_params |
| 19 |
from widgets import create_pager_widget, create_button |
| 20 |
|
| 21 |
|
| 22 |
def escape_for_search(x): |
| 23 |
# Minimal escaping for calibre search syntax |
| 24 |
return (x or '').replace('\\', '\\\\').replace('"', '\\"') |
| 25 |
|
| 26 |
|
| 27 |
def sync_cs_list_row_heights(list_root): |
| 28 |
"""Make all list rows the same height (max of siblings) so item-subtitle stacks don't vary row height.""" |
| 29 |
if not list_root: |
| 30 |
return |
| 31 |
ul = list_root.querySelector('ul') |
| 32 |
if not ul: |
| 33 |
return |
| 34 |
disp = (window.getComputedStyle(ul).display or '') + '' |
| 35 |
if disp.indexOf('flex') == -1: |
| 36 |
return |
| 37 |
ch = ul.children |
| 38 |
lis = [] |
| 39 |
for i in range(ch.length): |
| 40 |
node = ch[i] |
| 41 |
if node.tagName.toLowerCase() is 'li': |
| 42 |
lis.push(node) |
| 43 |
if lis.length is 0: |
| 44 |
return |
| 45 |
for i in range(lis.length): |
| 46 |
lis[i].style.minHeight = '' |
| 47 |
max_h = 0 |
| 48 |
for i in range(lis.length): |
| 49 |
h = lis[i].offsetHeight |
| 50 |
if h > max_h: |
| 51 |
max_h = h |
| 52 |
if max_h <= 0: |
| 53 |
return |
| 54 |
mh = str(max_h) + 'px' |
| 55 |
for i in range(lis.length): |
| 56 |
lis[i].style.minHeight = mh |
| 57 |
|
| 58 |
|
| 59 |
def title_for_field(field): |
| 60 |
info = browse_field_for(field) |
| 61 |
return info?.name or field or '' |
| 62 |
|
| 63 |
|
| 64 |
def subtitle_for_field(field): |
| 65 |
return browse_field_for(field)?.description or '' |
| 66 |
|
| 67 |
|
| 68 |
def rating_search_query_from_display_name(label): |
| 69 |
"""Map tag-browser rating label (e.g. ★★★) to calibre search rating:N with N in 1..5.""" |
| 70 |
s = (label or '') + '' |
| 71 |
n = 0 |
| 72 |
for i in range(s.length): |
| 73 |
if s[i] is '★': |
| 74 |
n += 1 |
| 75 |
if n >= 1 and n <= 5: |
| 76 |
return n |
| 77 |
try: |
| 78 |
v = int(Math.round(parseFloat(s))) |
| 79 |
if v >= 1 and v <= 5: |
| 80 |
return v |
| 81 |
except Exception: |
| 82 |
pass |
| 83 |
return 1 |
| 84 |
|
| 85 |
|
| 86 |
def make_search(field, label): |
| 87 |
label = label or '' |
| 88 |
field = field or '' |
| 89 |
if not field: |
| 90 |
return {'search': ''} |
| 91 |
if field is 'rating': |
| 92 |
n = rating_search_query_from_display_name(label) |
| 93 |
return {'search': 'rating:' + str(n)} |
| 94 |
return {'search': f'{field}:"={escape_for_search(label)}"'} |
| 95 |
|
| 96 |
|
| 97 |
def stars_for_rating(label): |
| 98 |
try: |
| 99 |
n = int(label) |
| 100 |
except Exception: |
| 101 |
n = 0 |
| 102 |
n = max(1, min(5, n)) |
| 103 |
return '★' * n |
| 104 |
|
| 105 |
|
| 106 |
def parse_rating_from_api(avg_rating): |
| 107 |
if avg_rating is None or str(avg_rating).strip() == '': |
| 108 |
return None |
| 109 |
try: |
| 110 |
r = float(avg_rating) |
| 111 |
except Exception: |
| 112 |
return None |
| 113 |
if not isFinite(r): |
| 114 |
return None |
| 115 |
r = clamp(r, 0, 5) |
| 116 |
# Keep one decimal as requested for display/tooltip. |
| 117 |
text = '{:.1f}'.format(r) |
| 118 |
return {'value': r, 'text': text} |
| 119 |
|
| 120 |
|
| 121 |
def create_fractional_rating_stars(avg_rating): |
| 122 |
info = parse_rating_from_api(avg_rating) |
| 123 |
if not info: |
| 124 |
return None |
| 125 |
percent = (info.value / 5.0) * 100.0 |
| 126 |
root = E.span(class_='cs-rating-stars', title=info.text) |
| 127 |
root.appendChild(E.span('★★★★★', class_='cs-rating-stars-base')) |
| 128 |
fill = E.span('★★★★★', class_='cs-rating-stars-fill') |
| 129 |
fill.style.width = '{:.1f}%'.format(percent) |
| 130 |
root.appendChild(fill) |
| 131 |
return root |
| 132 |
|
| 133 |
|
| 134 |
def tags_cache_key(): |
| 135 |
q = parse_url_params() |
| 136 |
sd = get_session_data() |
| 137 |
return '|'.join([ |
| 138 |
current_library_id() or '', |
| 139 |
q.vl or '', |
| 140 |
q.search or '', |
| 141 |
sd.get('sort_tags_by') + '', |
| 142 |
sd.get('partition_method') + '', |
| 143 |
sd.get('collapse_at') + '', |
| 144 |
sd.get('dont_collapse') + '', |
| 145 |
sd.get('hide_empty_categories') + '', |
| 146 |
]) |
| 147 |
|
| 148 |
|
| 149 |
cached_names = {} |
| 150 |
series_cover_cache = {} |
| 151 |
series_cover_inflight = {} |
| 152 |
SERIES_COVER_CLASSES = ['covers-0', 'covers-1', 'covers-2', 'covers-3', 'covers-4', 'covers-5'] |
| 153 |
|
| 154 |
|
| 155 |
def series_cover_key(library_id, series_name): |
| 156 |
return JSON.stringify([(library_id or '') + '', (series_name or '') + '']) |
| 157 |
|
| 158 |
|
| 159 |
def series_stack_cover_count(total): |
| 160 |
try: |
| 161 |
n = int(total) |
| 162 |
except Exception: |
| 163 |
return 0 |
| 164 |
if n < 1: |
| 165 |
return 0 |
| 166 |
n = min(5, n) |
| 167 |
if n > 1 and n % 2 == 0: |
| 168 |
n -= 1 |
| 169 |
return n |
| 170 |
|
| 171 |
|
| 172 |
def set_series_stack_cover_count(div, total): |
| 173 |
count = series_stack_cover_count(total) |
| 174 |
for cls in SERIES_COVER_CLASSES: |
| 175 |
div.classList.remove(cls) |
| 176 |
div.classList.add('covers-' + str(count)) |
| 177 |
return count |
| 178 |
|
| 179 |
|
| 180 |
def series_stack_cover_urls(urls): |
| 181 |
actual = [] |
| 182 |
for u in urls or []: |
| 183 |
if u: |
| 184 |
actual.push(u) |
| 185 |
return actual.slice(0, series_stack_cover_count(actual.length)) |
| 186 |
|
| 187 |
|
| 188 |
def render_series_stack_covers(div, urls): |
| 189 |
actual = series_stack_cover_urls(urls) |
| 190 |
while div.firstChild: |
| 191 |
div.removeChild(div.firstChild) |
| 192 |
count = set_series_stack_cover_count(div, actual.length) |
| 193 |
for i, u in enumerate(actual): |
| 194 |
img = E.img(src=u, class_='cover-img cover-' + str(i)) |
| 195 |
div.appendChild(img) |
| 196 |
return count |
| 197 |
|
| 198 |
add_extra_css(def (): |
| 199 |
sel = '.cs-nav-list ' |
| 200 |
style = '' |
| 201 |
# Unified nav subtitle (so "Browse all ..." looks consistent across fields) |
| 202 |
style += build_rule(sel + '.cs-nav-subtitle', |
| 203 |
margin='0', |
| 204 |
padding='0.9rem 1rem 0 1rem', |
| 205 |
opacity='0.8' |
| 206 |
) |
| 207 |
for fld in ('authors', 'publisher', 'series', 'formats'): |
| 208 |
style += build_rule(sel + f'[data-field="{fld}"] .generic-items-list > p', |
| 209 |
margin='0', |
| 210 |
padding='0.9rem 1rem 0 1rem', |
| 211 |
border='none', |
| 212 |
background='none', |
| 213 |
border_radius='0', |
| 214 |
font_style='normal', |
| 215 |
opacity='0.8' |
| 216 |
) |
| 217 |
# Tags: render as bubbles with incremental "show more" |
| 218 |
style += build_rule(sel + '.cs-tag-bubbles', |
| 219 |
padding='0.75rem 1rem', |
| 220 |
display='flex', |
| 221 |
flex_wrap='wrap', |
| 222 |
gap='0.55rem 0.55rem', |
| 223 |
align_content='flex-start' |
| 224 |
) |
| 225 |
style += build_rule(sel + 'a.cs-tag-bubble', |
| 226 |
display='inline-flex', |
| 227 |
align_items='center', |
| 228 |
max_width='100%', |
| 229 |
padding='0.45rem 0.75rem', |
| 230 |
border_radius='999px', |
| 231 |
border='var(--calibre-border-style-subtle)', |
| 232 |
background_color=get_color('window-background'), |
| 233 |
color=get_color('window-foreground'), |
| 234 |
text_decoration='none', |
| 235 |
cursor='pointer', |
| 236 |
user_select='none', |
| 237 |
white_space='nowrap', |
| 238 |
overflow='hidden', |
| 239 |
text_overflow='ellipsis', |
| 240 |
) |
| 241 |
style += build_rule(sel + 'a.cs-tag-bubble:hover', background_color='var(--calibre-color-primary-light)') |
| 242 |
style += build_rule(sel + 'a.cs-tag-bubble:active', transform='scale(0.99)') |
| 243 |
style += build_rule(sel + 'a.cs-tag-bubble:focus', outline='none', box_shadow='var(--calibre-focus-ring)') |
| 244 |
style += build_rule(sel + 'a.cs-tag-bubble .cs-tag-meta', font_size='0.85em', opacity='0.78') |
| 245 |
style += build_rule(sel + '.cs-show-more-wrap', |
| 246 |
padding='0.25rem 1rem 1rem 1rem', |
| 247 |
display='flex', |
| 248 |
justify_content='center' |
| 249 |
) |
| 250 |
style += build_rule(sel + 'a.cs-show-more', |
| 251 |
display='inline-flex', |
| 252 |
align_items='center', |
| 253 |
gap='0.35rem', |
| 254 |
padding='0.55rem 0.9rem', |
| 255 |
border_radius='999px', |
| 256 |
border='var(--calibre-border-style-subtle)', |
| 257 |
background_color='rgba(0,0,0,0.02)', |
| 258 |
color=get_color('window-foreground'), |
| 259 |
text_decoration='none', |
| 260 |
cursor='pointer', |
| 261 |
user_select='none' |
| 262 |
) |
| 263 |
style += build_rule(sel + 'a.cs-show-more:hover', background_color='var(--calibre-color-primary-light)') |
| 264 |
# Fractional rating stars (5 base stars + themed fill overlay) |
| 265 |
style += build_rule(sel + '.cs-rating-stars', |
| 266 |
position='relative', |
| 267 |
display='inline-block', |
| 268 |
line_height='1', |
| 269 |
letter_spacing='0.06em', |
| 270 |
white_space='nowrap', |
| 271 |
user_select='none' |
| 272 |
) |
| 273 |
style += build_rule(sel + '.cs-rating-stars-base', |
| 274 |
color='rgba(0,0,0,0.18)' |
| 275 |
) |
| 276 |
style += build_rule(sel + '.cs-rating-stars-fill', |
| 277 |
position='absolute', |
| 278 |
left='0', |
| 279 |
top='0', |
| 280 |
overflow='hidden', |
| 281 |
white_space='nowrap', |
| 282 |
color='var(--calibre-color-primary)', |
| 283 |
pointer_events='none' |
| 284 |
) |
| 285 |
# Toggle (segmented) control |
| 286 |
style += build_rule(sel + '.cs-toggle', |
| 287 |
display='inline-flex', |
| 288 |
align_items='stretch', |
| 289 |
border='var(--calibre-border-style-subtle)', |
| 290 |
border_radius='999px', |
| 291 |
overflow='hidden', |
| 292 |
) |
| 293 |
style += build_rule(sel + 'a.cs-toggle-btn', |
| 294 |
display='inline-flex', align_items='center', gap='0.35rem', |
| 295 |
padding='0.45rem 0.7rem', |
| 296 |
color=get_color('window-foreground'), |
| 297 |
cursor='pointer', user_select='none', text_decoration='none', |
| 298 |
border_right='var(--calibre-border-style-subtle)' |
| 299 |
) |
| 300 |
style += build_rule(sel + 'a.cs-toggle-btn:last-child', border_right='none') |
| 301 |
style += build_rule(sel + 'a.cs-toggle-btn[aria-pressed="true"]', |
| 302 |
background_color='var(--calibre-color-primary-light-2)', |
| 303 |
font_weight='700' |
| 304 |
) |
| 305 |
style += build_rule(sel + 'a.cs-toggle-btn:hover', background_color='var(--calibre-color-primary-light)') |
| 306 |
# Series stack-cover mode: isolated classes to avoid conflicts with list mode selectors. |
| 307 |
style += build_rule( |
| 308 |
'.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-row', |
| 309 |
display='flex', |
| 310 |
flex_direction='column', |
| 311 |
align_items='center', |
| 312 |
justify_content='center', |
| 313 |
gap='0.55rem', |
| 314 |
min_width='0', |
| 315 |
width='100%', |
| 316 |
flex='1 1 auto' |
| 317 |
) |
| 318 |
style += build_rule( |
| 319 |
'.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers', |
| 320 |
position='relative', |
| 321 |
width='min(100%, var(--cs-series-stack-width, 220px))', |
| 322 |
height='var(--cs-series-stack-height, 204px)', |
| 323 |
box_sizing='border-box', |
| 324 |
margin_left='auto', |
| 325 |
margin_right='auto', |
| 326 |
flex='0 0 auto', |
| 327 |
overflow='visible', |
| 328 |
border_radius='14px' |
| 329 |
) |
| 330 |
style += build_rule('.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers img.cover-img', |
| 331 |
position='absolute', |
| 332 |
left='50%', |
| 333 |
bottom='12px', |
| 334 |
width='112px', |
| 335 |
height='168px', |
| 336 |
object_fit='cover', |
| 337 |
border_radius='12px', |
| 338 |
border='var(--calibre-border-style-subtle)', |
| 339 |
background_color='rgba(0,0,0,0.05)', |
| 340 |
box_shadow='0 12px 32px rgba(0,0,0,0.16)', |
| 341 |
transition='transform 200ms ease, box-shadow 200ms ease' |
| 342 |
) |
| 343 |
style += build_rule('.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers img.cover-img:hover', |
| 344 |
box_shadow='0 26px 64px rgba(0,0,0,0.22)' |
| 345 |
) |
| 346 |
# Per-count sizing/positioning: odd stacks only (1 / 3 / 5). |
| 347 |
style += r''' |
| 348 |
.cs-nav-list .cs-series-stack-covers.covers-0 { |
| 349 |
display: none; |
| 350 |
} |
| 351 |
|
| 352 |
.cs-nav-list .cs-series-stack-covers.covers-1 { |
| 353 |
--cs-series-stack-width: 132px; |
| 354 |
--cs-series-stack-height: 188px; |
| 355 |
} |
| 356 |
.cs-nav-list .cs-series-stack-covers.covers-1 .cover-0 { |
| 357 |
transform: translate(-50%, 0) rotate(0deg) scale(1); |
| 358 |
z-index: 3; |
| 359 |
} |
| 360 |
|
| 361 |
.cs-nav-list .cs-series-stack-covers.covers-3 { |
| 362 |
--cs-series-stack-width: 192px; |
| 363 |
--cs-series-stack-height: 200px; |
| 364 |
} |
| 365 |
.cs-nav-list .cs-series-stack-covers.covers-3 .cover-0 { |
| 366 |
transform: translate(calc(-50% - 28px), -12px) rotate(-6deg) scale(0.90); |
| 367 |
z-index: 1; |
| 368 |
} |
| 369 |
.cs-nav-list .cs-series-stack-covers.covers-3 .cover-1 { |
| 370 |
transform: translate(calc(-50% + 28px), -12px) rotate(6deg) scale(0.90); |
| 371 |
z-index: 1; |
| 372 |
} |
| 373 |
.cs-nav-list .cs-series-stack-covers.covers-3 .cover-2 { |
| 374 |
transform: translate(-50%, 0) rotate(0deg) scale(1); |
| 375 |
z-index: 3; |
| 376 |
} |
| 377 |
|
| 378 |
.cs-nav-list .cs-series-stack-covers.covers-5 { |
| 379 |
--cs-series-stack-width: 220px; |
| 380 |
--cs-series-stack-height: 204px; |
| 381 |
} |
| 382 |
.cs-nav-list .cs-series-stack-covers.covers-5 .cover-0 { |
| 383 |
transform: translate(calc(-50% - 42px), -14px) rotate(-7deg) scale(0.84); |
| 384 |
z-index: 1; |
| 385 |
} |
| 386 |
.cs-nav-list .cs-series-stack-covers.covers-5 .cover-1 { |
| 387 |
transform: translate(calc(-50% + 42px), -14px) rotate(7deg) scale(0.84); |
| 388 |
z-index: 1; |
| 389 |
} |
| 390 |
.cs-nav-list .cs-series-stack-covers.covers-5 .cover-2 { |
| 391 |
transform: translate(calc(-50% - 20px), -6px) rotate(-3.5deg) scale(0.93); |
| 392 |
z-index: 2; |
| 393 |
} |
| 394 |
.cs-nav-list .cs-series-stack-covers.covers-5 .cover-3 { |
| 395 |
transform: translate(calc(-50% + 20px), -6px) rotate(3.5deg) scale(0.93); |
| 396 |
z-index: 2; |
| 397 |
} |
| 398 |
.cs-nav-list .cs-series-stack-covers.covers-5 .cover-4 { |
| 399 |
transform: translate(-50%, 0) rotate(0deg) scale(1); |
| 400 |
z-index: 3; |
| 401 |
} |
| 402 |
''' |
| 403 |
# Loading overlay (prevents flash/flicker on updates) |
| 404 |
style += build_rule(sel + '.cs-list-wrap', position='relative', flex='1 1 auto', min_height='0') |
| 405 |
style += build_rule(sel + '.cs-loading-overlay', |
| 406 |
position='absolute', left='0', top='0', right='0', bottom='0', |
| 407 |
display='flex', align_items='center', justify_content='center', |
| 408 |
background_color=get_color('window-background'), |
| 409 |
opacity='0', |
| 410 |
pointer_events='none', |
| 411 |
transition='opacity 160ms ease' |
| 412 |
) |
| 413 |
style += build_rule(sel + '.cs-list-content', |
| 414 |
transition='opacity 160ms ease', |
| 415 |
will_change='opacity' |
| 416 |
) |
| 417 |
# Nav browse list: rating/count column absolutely positioned right. Row uses flex + align center so |
| 418 |
# item-title-body stays vertically centered when subtitle stack is taller (after li min-height sync). |
| 419 |
nav_flex_li = ( |
| 420 |
'.cs-nav-list:not([data-field="series"]) .cs-list-content.generic-items-list > ul > li:not(:has(> div:nth-child(2))), ' + |
| 421 |
'.cs-nav-list[data-field="series"][data-series-display="list"] .cs-list-content.generic-items-list > ul > li:not(:has(> div:nth-child(2)))' |
| 422 |
) |
| 423 |
style += build_rule(nav_flex_li, |
| 424 |
display='flex', |
| 425 |
flex_direction='column', |
| 426 |
) |
| 427 |
nav_flex_li_cell = ( |
| 428 |
'.cs-nav-list:not([data-field="series"]) .cs-list-content.generic-items-list > ul > li:not(:has(> div:nth-child(2))) > div:nth-child(1), ' |
| 429 |
'.cs-nav-list[data-field="series"][data-series-display="list"]' |
| 430 |
' .cs-list-content.generic-items-list > ul > li:not(:has(> div:nth-child(2))) > div:nth-child(1)' |
| 431 |
) |
| 432 |
style += build_rule(nav_flex_li_cell, |
| 433 |
flex_grow='1', |
| 434 |
flex_shrink='0', |
| 435 |
width='100%', |
| 436 |
min_height='0', |
| 437 |
box_sizing='border-box', |
| 438 |
) |
| 439 |
style += build_rule(sel + '.cs-list-content.generic-items-list .item-first-row:not(:has(.item-subtitle-nav))', |
| 440 |
display='flex', |
| 441 |
) |
| 442 |
style += build_rule(sel + '.cs-list-content.generic-items-list .item-first-row:has(.item-subtitle-nav)', |
| 443 |
display='flex', |
| 444 |
align_items='center', |
| 445 |
) |
| 446 |
style += build_rule(sel + '.cs-list-content.generic-items-list .item-first-row:has(.item-subtitle-nav) .item-title-body', |
| 447 |
padding_right='9.5rem', |
| 448 |
box_sizing='border-box', |
| 449 |
) |
| 450 |
style += build_rule(sel + '.cs-list-content.generic-items-list .item-subtitle.item-subtitle-nav', |
| 451 |
position='absolute', |
| 452 |
right='0.95rem', |
| 453 |
top='0', |
| 454 |
bottom='0', |
| 455 |
margin_top='auto', |
| 456 |
margin_bottom='auto', |
| 457 |
height='fit-content', |
| 458 |
max_height='100%', |
| 459 |
width='max-content', |
| 460 |
max_width='min(9rem, calc(100% - 1rem))', |
| 461 |
margin_left='0', |
| 462 |
text_align='right', |
| 463 |
display='flex', |
| 464 |
flex_direction='column', |
| 465 |
align_items='flex_end', |
| 466 |
justify_content='center', |
| 467 |
gap='0.1rem', |
| 468 |
line_height='1.15', |
| 469 |
padding_top='0', |
| 470 |
overflow='hidden', |
| 471 |
box_sizing='border-box', |
| 472 |
) |
| 473 |
# Series card grid: same row has subtitle-nav but layout must stay columnar (not browse-row center). |
| 474 |
style += build_rule(sel + '.cs-loading .cs-loading-overlay', opacity='1') |
| 475 |
style += build_rule(sel + '.cs-loading .cs-list-content', opacity='0.45') |
| 476 |
style += r''' |
| 477 |
@keyframes cs_spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } |
| 478 |
.cs-nav-list .cs-loading-overlay svg { animation: cs_spin 1.2s linear infinite; opacity: 0.85; } |
| 479 |
''' |
| 480 |
# Series panel as grid (cards): stretch items in each row to the row's max height so tiles align. |
| 481 |
style += build_rule('.cs-nav-list[data-field="series"] .generic-items-list ul', |
| 482 |
display='grid', |
| 483 |
grid_template_columns='repeat(auto-fill, minmax(220px, 1fr))', |
| 484 |
gap='0.75rem', |
| 485 |
align_items='stretch', |
| 486 |
) |
| 487 |
style += build_rule('.cs-nav-list[data-field="series"] .generic-items-list li', |
| 488 |
display='flex', |
| 489 |
flex_direction='column', |
| 490 |
align_items='stretch', |
| 491 |
min_height='0', |
| 492 |
height='100%', |
| 493 |
) |
| 494 |
style += build_rule('.cs-nav-list[data-field="series"] .generic-items-list li > div:nth-child(1)', |
| 495 |
flex='1 1 auto', |
| 496 |
width='100%', |
| 497 |
min_height='0', |
| 498 |
display='flex', |
| 499 |
flex_direction='column', |
| 500 |
justify_content='flex-start', |
| 501 |
align_items='center' |
| 502 |
) |
| 503 |
style += build_rule('.cs-nav-list[data-field="series"] .generic-items-list li:hover', |
| 504 |
transform='translateY(-1px)' |
| 505 |
) |
| 506 |
style += build_rule('.cs-nav-list[data-field="series"] .generic-items-list li > div:nth-child(1)', |
| 507 |
padding='0.95rem 0.95rem 0.9rem 0.95rem' |
| 508 |
) |
| 509 |
# Keep series stack fully inside the card; no overflow outside list item. |
| 510 |
style += build_rule('.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .generic-items-list li.cs-series-stack-item', |
| 511 |
overflow='hidden') |
| 512 |
style += build_rule('.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .generic-items-list .cs-series-stack-item-row', |
| 513 |
flex_direction='column', |
| 514 |
align_items='stretch') |
| 515 |
# Disable hover "lift" animation for series items (prevents cover zoom feel) |
| 516 |
style += build_rule('.generic-items-list li.cs-series-stack-item:hover', transform='none') |
| 517 |
style += build_rule('.generic-items-list li.cs-series-stack-item:active', transform='none') |
| 518 |
# Series list mode: same layout as authors/publisher (no grid, no covers) |
| 519 |
style += build_rule('.cs-nav-list[data-field="series"][data-series-display="list"] .generic-items-list ul', |
| 520 |
display='flex', |
| 521 |
flex_direction='column', |
| 522 |
gap='0.5rem' |
| 523 |
) |
| 524 |
style += build_rule('.cs-nav-list[data-field="series"][data-series-display="list"] .generic-items-list li', |
| 525 |
aspect_ratio='auto', |
| 526 |
display='block' |
| 527 |
) |
| 528 |
style += build_rule('.cs-nav-list[data-field="series"][data-series-display="list"] .generic-items-list li > div:nth-child(1)', |
| 529 |
display='block', |
| 530 |
position='relative', |
| 531 |
padding='0.85rem 0.95rem' |
| 532 |
) |
| 533 |
style += build_rule('.cs-nav-list[data-field="series"][data-series-display="list"] .item-title-body', |
| 534 |
text_align='left' |
| 535 |
) |
| 536 |
# Series stack mode: same layout as authors/publisher (no grid, no covers) |
| 537 |
style += build_rule('.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .generic-items-list li.cs-series-stack-item .item-title-body', |
| 538 |
padding_right='0', |
| 539 |
) |
| 540 |
style += build_rule( |
| 541 |
'.cs-nav-list[data-field="series"]:not([data-series-display="list"])' |
| 542 |
' .generic-items-list li.cs-series-stack-item .item-subtitle.item-subtitle-nav', |
| 543 |
position='relative', |
| 544 |
right='0', |
| 545 |
top='0', |
| 546 |
bottom='0', |
| 547 |
margin_top='auto', |
| 548 |
margin_bottom='auto', |
| 549 |
height='fit-content', |
| 550 |
max_height='100%', |
| 551 |
width='max-content', |
| 552 |
) |
| 553 |
style += build_rule(sel + 'input.cs-filter', |
| 554 |
flex='1 1 auto', |
| 555 |
width='0', |
| 556 |
min_width='9em' |
| 557 |
) |
| 558 |
style += r''' |
| 559 |
@media (max-width: 420px) { |
| 560 |
.cs-nav-list[data-field="series"] .generic-items-list ul { |
| 561 |
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); |
| 562 |
gap: 0.55rem; |
| 563 |
} |
| 564 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers { |
| 565 |
--cs-series-stack-width: 190px; |
| 566 |
--cs-series-stack-height: 168px; |
| 567 |
} |
| 568 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers.covers-1 { |
| 569 |
--cs-series-stack-width: 108px; |
| 570 |
--cs-series-stack-height: 150px; |
| 571 |
} |
| 572 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers.covers-3 { |
| 573 |
--cs-series-stack-width: 160px; |
| 574 |
--cs-series-stack-height: 162px; |
| 575 |
} |
| 576 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers img.cover-img { |
| 577 |
width: 88px; |
| 578 |
height: 132px; |
| 579 |
bottom: 10px; |
| 580 |
} |
| 581 |
} |
| 582 |
@media (max-width: 360px) { |
| 583 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers { |
| 584 |
--cs-series-stack-width: 170px; |
| 585 |
--cs-series-stack-height: 152px; |
| 586 |
} |
| 587 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers.covers-1 { |
| 588 |
--cs-series-stack-width: 98px; |
| 589 |
--cs-series-stack-height: 137px; |
| 590 |
} |
| 591 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers.covers-3 { |
| 592 |
--cs-series-stack-width: 148px; |
| 593 |
--cs-series-stack-height: 149px; |
| 594 |
} |
| 595 |
.cs-nav-list[data-field="series"]:not([data-series-display="list"]) .cs-series-stack-covers img.cover-img { |
| 596 |
width: 80px; |
| 597 |
height: 120px; |
| 598 |
bottom: 9px; |
| 599 |
} |
| 600 |
} |
| 601 |
''' |
| 602 |
return style |
| 603 |
) |
| 604 |
|
| 605 |
|
| 606 |
def parse_int(x, default_value): |
| 607 |
try: |
| 608 |
x = int(x) |
| 609 |
except Exception: |
| 610 |
x = default_value |
| 611 |
return x |
| 612 |
|
| 613 |
|
| 614 |
def clamp(n, lo, hi): |
| 615 |
return max(lo, min(hi, n)) |
| 616 |
|
| 617 |
|
| 618 |
def update_nav_list_url(field, offset, num, query_text=None, replace=True, g=None): |
| 619 |
q = {'field': field, 'offset': str(offset), 'num': str(num)} |
| 620 |
if query_text: |
| 621 |
q.q = query_text |
| 622 |
g = g or parse_url_params().g |
| 623 |
if g: |
| 624 |
q.g = g |
| 625 |
show_panel('nav_list', q, replace=replace) |
| 626 |
|
| 627 |
|
| 628 |
def create_nav_list_panel(container_id): |
| 629 |
interface_data = get_interface_data() |
| 630 |
lid = url_books_query().library_id |
| 631 |
title = interface_data.library_map[lid] |
| 632 |
update_window_title(title) |
| 633 |
container = document.getElementById(container_id) |
| 634 |
clear(container) |
| 635 |
q = parse_url_params() |
| 636 |
field = q.field or '' |
| 637 |
field_info = browse_field_for(field) or {'kind': 'category'} |
| 638 |
num = clamp(parse_int(q.num, 15), 5, 100) |
| 639 |
offset = max(0, parse_int(q.offset, 0)) |
| 640 |
query_text = (q.q or '').toString() |
| 641 |
group_mode = (q.g or 'y').toString() |
| 642 |
if field_info.kind is 'date': |
| 643 |
query_text = '' |
| 644 |
# Tags panel: render all tags progressively on one page (no paging) |
| 645 |
visible_tags = 50 |
| 646 |
title = title_for_field(field) |
| 647 |
create_top_bar(container, title=title, action=back, icon='back') |
| 648 |
container.appendChild(E.div()) |
| 649 |
body = container.lastChild |
| 650 |
body.classList.add('cs-nav-list') |
| 651 |
body.dataset.field = field |
| 652 |
if field is 'series': |
| 653 |
sd = get_session_data() |
| 654 |
series_mode = sd.get('series_nav_display_mode', 'stack') or 'stack' |
| 655 |
body.dataset.seriesDisplay = series_mode |
| 656 |
|
| 657 |
top_pager_widget = create_pager_widget( |
| 658 |
def (): update_nav_list_url(field, max(0, offset - num), num, query_text, replace=True);, |
| 659 |
def (): update_nav_list_url(field, offset + num, num, query_text, replace=True);, |
| 660 |
) |
| 661 |
body.appendChild(E.div(top_pager_widget.container, style='margin: 0 0.75rem')) |
| 662 |
status = top_pager_widget.count_msg |
| 663 |
if field_info.kind is not 'date': |
| 664 |
search_inp = E.input( |
| 665 |
type='search', |
| 666 |
placeholder=_('Filter…'), |
| 667 |
value=query_text, |
| 668 |
class_='cs-filter' |
| 669 |
) |
| 670 |
search_inp.addEventListener('keydown', def (ev): |
| 671 |
if ev.key is 'Enter': |
| 672 |
ev.preventDefault() |
| 673 |
apply_btn.click() |
| 674 |
) |
| 675 |
apply_btn = create_button(_('Apply'), icons='search', action=def (): |
| 676 |
nonlocal query_text |
| 677 |
query_text = search_inp.value or '' |
| 678 |
update_nav_list_url(field, 0, num, query_text, replace=True) |
| 679 |
) |
| 680 |
top_pager_widget.middle_row.appendChild(search_inp) |
| 681 |
top_pager_widget.middle_row.appendChild(apply_btn) |
| 682 |
|
| 683 |
def toggle_btn(label, mode): |
| 684 |
a = E.a(href='#', class_='cs-toggle-btn') |
| 685 |
a.setAttribute('aria-pressed', 'true' if group_mode is mode else 'false') |
| 686 |
a.appendChild(E.span(label)) |
| 687 |
a.addEventListener('click', def (evt): |
| 688 |
evt.preventDefault() |
| 689 |
update_nav_list_url(field, 0, num, None, replace=True, g=mode) |
| 690 |
) |
| 691 |
return a |
| 692 |
|
| 693 |
if field_info.kind is 'date': |
| 694 |
group_toggle = E.div(style='display:flex; gap:0.5rem; align-items:center; flex-wrap:wrap') |
| 695 |
group_toggle.appendChild(E.span(_('Group:'), style='opacity:0.75')) |
| 696 |
seg = E.div(class_='cs-toggle') |
| 697 |
|
| 698 |
seg.appendChild(toggle_btn(_('Year'), 'y')) |
| 699 |
seg.appendChild(toggle_btn(_('Year & Month'), 'ym')) |
| 700 |
group_toggle.appendChild(seg) |
| 701 |
top_pager_widget.middle_row.appendChild(group_toggle) |
| 702 |
|
| 703 |
top_pager_widget.set_middle_row_visibility(True) |
| 704 |
list_wrap = E.div(class_='cs-list-wrap') |
| 705 |
body.appendChild(list_wrap) |
| 706 |
nav_subtitle = E.p('', class_='cs-nav-subtitle') |
| 707 |
nav_subtitle.style.display = 'none' |
| 708 |
list_container = E.div(class_='cs-list-content') |
| 709 |
bottom_pager = E.div(style='display:none; margin: 0 0.75rem') |
| 710 |
overlay = E.div(class_='cs-loading-overlay', svgicon('cog'), E.span('\xa0' + _('Loading…'))) |
| 711 |
list_wrap.appendChild(nav_subtitle) |
| 712 |
list_wrap.appendChild(list_container) |
| 713 |
list_wrap.appendChild(bottom_pager) |
| 714 |
list_wrap.appendChild(overlay) |
| 715 |
list_wrap.classList.add('cs-loading') |
| 716 |
|
| 717 |
def set_loading(is_loading): |
| 718 |
if is_loading: |
| 719 |
list_wrap.classList.add('cs-loading') |
| 720 |
else: |
| 721 |
# Delay removal slightly to avoid a flash on very fast responses |
| 722 |
setTimeout(def (): |
| 723 |
list_wrap.classList.remove('cs-loading') |
| 724 |
, 60) |
| 725 |
|
| 726 |
def norm(x): |
| 727 |
return (x or '').toString().toLowerCase() |
| 728 |
|
| 729 |
def to_item(x): |
| 730 |
if x and jstype(x) is 'object' and 'name' in x: |
| 731 |
return x |
| 732 |
s = (x or '') + '' |
| 733 |
return {'name': s, 'count': None, 'avg_rating': None, 'search_name': s} |
| 734 |
|
| 735 |
def filtered(items): |
| 736 |
if not query_text: |
| 737 |
return items |
| 738 |
nq = norm(query_text) |
| 739 |
ans = [] |
| 740 |
for x in items: |
| 741 |
n = (x.name if (x and jstype(x) is 'object') else x) + '' |
| 742 |
if n and norm(n).indexOf(nq) != -1: |
| 743 |
ans.push(x) |
| 744 |
return ans |
| 745 |
|
| 746 |
series_cover_targets = {} |
| 747 |
|
| 748 |
def nav_list_rating_count_parts(count, avg_rating): |
| 749 |
sd = get_session_data() |
| 750 |
show_count = sd.get('show_nav_list_book_count', True) |
| 751 |
show_rating = sd.get('show_nav_list_avg_rating', True) |
| 752 |
count_s = None |
| 753 |
rating_s = None |
| 754 |
if show_count and count is not None and str(count).strip() != '': |
| 755 |
n = int(count) |
| 756 |
count_s = _('{} books').format(n) |
| 757 |
if show_rating and avg_rating is not None and str(avg_rating).strip() != '': |
| 758 |
info = parse_rating_from_api(avg_rating) |
| 759 |
if info and info.value > 0: |
| 760 |
rating_s = create_fractional_rating_stars(info.value) |
| 761 |
if not count_s and not rating_s: |
| 762 |
return None |
| 763 |
return {'rating': rating_s, 'count': count_s} |
| 764 |
|
| 765 |
def format_count_rating(count, avg_rating): |
| 766 |
p = nav_list_rating_count_parts(count, avg_rating) |
| 767 |
if not p: |
| 768 |
return '' |
| 769 |
parts = [] |
| 770 |
if p.count: |
| 771 |
parts.push(p.count) |
| 772 |
if p.rating: |
| 773 |
info = parse_rating_from_api(avg_rating) |
| 774 |
if info: |
| 775 |
parts.push(info.text) |
| 776 |
return ' · '.join(parts) |
| 777 |
|
| 778 |
def browse_cache_key(): |
| 779 |
return tags_cache_key() + '|' + field + '|' + group_mode |
| 780 |
|
| 781 |
def fetch_browse_items(proceed): |
| 782 |
q = parse_url_params() |
| 783 |
sd = get_session_data() |
| 784 |
query = {'library_id': current_library_id(), 'vl': q.vl or '', 'date_group': group_mode} |
| 785 |
if q.search: |
| 786 |
query.search = q.search |
| 787 |
for k in 'sort_tags_by partition_method collapse_at dont_collapse hide_empty_categories'.split(' '): |
| 788 |
query[k] = sd.get(k) + '' |
| 789 |
|
| 790 |
def done(end_type, xhr, ev): |
| 791 |
if end_type is not 'load': |
| 792 |
proceed(False, xhr.error_html) |
| 793 |
return |
| 794 |
try: |
| 795 |
data = JSON.parse(xhr.responseText) |
| 796 |
except Exception: |
| 797 |
proceed(False, 'Invalid JSON from server') |
| 798 |
return |
| 799 |
proceed(True, data.items or []) |
| 800 |
|
| 801 |
ajax(f'interface-data/browse-field/{encodeURIComponent(field)}', done, query=query, bypass_cache=False).send() |
| 802 |
|
| 803 |
def ensure_series_covers(series_name, target_div): |
| 804 |
if not series_name: |
| 805 |
return |
| 806 |
lid = current_library_id() |
| 807 |
key = series_cover_key(lid, series_name) |
| 808 |
series_cover_targets[key] = (series_cover_targets[key] or []) |
| 809 |
series_cover_targets[key].push(target_div) |
| 810 |
cached = series_cover_cache[key] |
| 811 |
if cached: |
| 812 |
apply_series_covers(key, cached) |
| 813 |
return |
| 814 |
if series_cover_inflight[key]: |
| 815 |
return |
| 816 |
series_cover_inflight[key] = True |
| 817 |
query = { |
| 818 |
'library_id': lid, |
| 819 |
'num': '5', |
| 820 |
'search': f'series:"={escape_for_search(series_name)}"' |
| 821 |
} |
| 822 |
|
| 823 |
def done(end_type, xhr, ev): |
| 824 |
series_cover_inflight[key] = False |
| 825 |
if end_type is not 'load': |
| 826 |
return |
| 827 |
try: |
| 828 |
data = JSON.parse(xhr.responseText) |
| 829 |
except Exception: |
| 830 |
return |
| 831 |
ids = data.search_result?.book_ids or [] |
| 832 |
urls = [] |
| 833 |
for bid in ids.slice(0, 5): |
| 834 |
urls.push(cover_url(bid)) |
| 835 |
series_cover_cache[key] = urls |
| 836 |
apply_series_covers(key, urls) |
| 837 |
|
| 838 |
ajax('interface-data/get-books', done, query=query).send() |
| 839 |
|
| 840 |
def apply_series_covers(key, urls): |
| 841 |
targets = series_cover_targets[key] or [] |
| 842 |
for div in targets: |
| 843 |
render_series_stack_covers(div, urls) |
| 844 |
|
| 845 |
def render_page(data): |
| 846 |
nonlocal series_cover_targets |
| 847 |
set_loading(False) |
| 848 |
series_cover_targets = {} |
| 849 |
raw = data or [] |
| 850 |
items = [to_item(x) for x in raw] |
| 851 |
items = filtered(items) |
| 852 |
total = items.length or 0 |
| 853 |
|
| 854 |
def make_action(search_query): |
| 855 |
return def (ev): |
| 856 |
if ev: |
| 857 |
ev.preventDefault() |
| 858 |
show_panel('book_list', query=search_query, replace=False) |
| 859 |
|
| 860 |
if field is 'tags': |
| 861 |
shown = min(total, visible_tags) |
| 862 |
status.textContent = _('{0} of {1}').format(shown, total) |
| 863 |
top_pager_widget.set_enabled(False, False) |
| 864 |
|
| 865 |
clear(list_container) |
| 866 |
subtitle = subtitle_for_field(field) |
| 867 |
if subtitle: |
| 868 |
list_container.appendChild(E.p(subtitle, class_='cs-nav-subtitle')) |
| 869 |
|
| 870 |
bubbles = E.div(class_='cs-tag-bubbles') |
| 871 |
list_container.appendChild(bubbles) |
| 872 |
|
| 873 |
for it in items.slice(0, shown): |
| 874 |
if not it or not it.name: |
| 875 |
continue |
| 876 |
meta = format_count_rating(it.count, it.avg_rating) |
| 877 |
label = it.name + '' |
| 878 |
inner = E.span(label) |
| 879 |
if meta: |
| 880 |
inner = E.span(E.span(label), E.span(' ' + meta, class_='cs-tag-meta')) |
| 881 |
search_query = {'search': it.search or make_search(field, it.search_name or label).search} |
| 882 |
bubbles.appendChild(E.a( |
| 883 |
href='#', |
| 884 |
class_='cs-tag-bubble', |
| 885 |
onclick=make_action(search_query), |
| 886 |
title=label, |
| 887 |
inner |
| 888 |
)) |
| 889 |
|
| 890 |
if shown < total: |
| 891 |
wrap = E.div(class_='cs-show-more-wrap') |
| 892 |
list_container.appendChild(wrap) |
| 893 |
a = E.a(href='#', class_='cs-show-more') |
| 894 |
a.appendChild(svgicon('plus')) |
| 895 |
a.appendChild(E.span(_('Show more'))) |
| 896 |
a.addEventListener('click', def (ev): |
| 897 |
nonlocal visible_tags |
| 898 |
ev.preventDefault() |
| 899 |
visible_tags = min(total, visible_tags + 50) |
| 900 |
render_page(data) |
| 901 |
) |
| 902 |
wrap.appendChild(a) |
| 903 |
bottom_pager.style.display = 'none' |
| 904 |
return |
| 905 |
if offset >= total and total > 0: |
| 906 |
# Clamp to last page |
| 907 |
new_offset = max(0, (Math.floor((total - 1) / num) * num)) |
| 908 |
if new_offset is not offset: |
| 909 |
update_nav_list_url(field, new_offset, num, query_text, replace=True) |
| 910 |
return |
| 911 |
end = min(total, offset + num) |
| 912 |
status.textContent = _('{0}–{1} of {2}').format((offset + 1) if total else 0, end, total) |
| 913 |
top_pager_widget.set_enabled(offset > 0, end < total) |
| 914 |
|
| 915 |
list_items = [] |
| 916 |
|
| 917 |
def make_action(search_query): |
| 918 |
return def (ev): |
| 919 |
if ev: |
| 920 |
ev.preventDefault() |
| 921 |
show_panel('book_list', query=search_query, replace=False) |
| 922 |
|
| 923 |
for it in items.slice(offset, offset + num): |
| 924 |
if not it or not it.name: |
| 925 |
continue |
| 926 |
label = it.name + '' |
| 927 |
search_val = it.search_name or label |
| 928 |
search_query = {'search': it.search or make_search(field, search_val).search} |
| 929 |
meta = nav_list_rating_count_parts(it.count, it.avg_rating) |
| 930 |
if field is 'series': |
| 931 |
series_mode = body.dataset.seriesDisplay or 'stack' |
| 932 |
if series_mode is 'list': |
| 933 |
list_items.push(create_item(label, action=make_action(search_query), nav_list_meta=meta)) |
| 934 |
else: |
| 935 |
covers = E.div(class_='cs-series-stack-covers') |
| 936 |
set_series_stack_cover_count(covers, it.count) |
| 937 |
stack = E.div(class_='cs-series-stack-row', covers, E.div(label, class_='cs-series-stack-name')) |
| 938 |
stack.dataset.seriesName = label |
| 939 |
list_items.push(create_item( |
| 940 |
stack, action=make_action(search_query), nav_list_meta=meta, |
| 941 |
li_class='cs-series-stack-item', row_class='cs-series-stack-item-row' |
| 942 |
)) |
| 943 |
elif field is 'rating': |
| 944 |
# Use server-provided display name (tag-browser item.name); do not parse as int — names are localized. |
| 945 |
list_items.push(create_item(label, action=make_action(search_query), nav_list_meta=meta)) |
| 946 |
else: |
| 947 |
list_items.push(create_item(label, action=make_action(search_query), nav_list_meta=meta)) |
| 948 |
subtitle = subtitle_for_field(field) |
| 949 |
nav_subtitle.textContent = subtitle or '' |
| 950 |
nav_subtitle.style.display = 'block' if subtitle else 'none' |
| 951 |
create_item_list(list_container, list_items) |
| 952 |
|
| 953 |
def flush_row_heights(): |
| 954 |
sync_cs_list_row_heights(list_container) |
| 955 |
|
| 956 |
flush_row_heights() |
| 957 |
raf = window.requestAnimationFrame |
| 958 |
if raf: |
| 959 |
raf(flush_row_heights) |
| 960 |
|
| 961 |
if field is 'series': |
| 962 |
# After rendering, lazily fetch covers for visible series |
| 963 |
for srow in list_container.querySelectorAll('[data-series-name]'): |
| 964 |
sname = srow.dataset.seriesName |
| 965 |
cdiv = srow.querySelector('.cs-series-stack-covers') |
| 966 |
if cdiv: |
| 967 |
ensure_series_covers(sname, cdiv) |
| 968 |
|
| 969 |
# Bottom prev/next mirrors top pager state |
| 970 |
clear(bottom_pager) |
| 971 |
bot_widget = create_pager_widget( |
| 972 |
def (): update_nav_list_url(field, max(0, offset - num), num, query_text, replace=True);, |
| 973 |
def (): update_nav_list_url(field, offset + num, num, query_text, replace=True);, |
| 974 |
) |
| 975 |
bot_widget.set_enabled(offset > 0, end < total) |
| 976 |
bottom_pager.appendChild(bot_widget.container) |
| 977 |
bottom_pager.style.display = '' |
| 978 |
|
| 979 |
def render(ok, payload): |
| 980 |
set_loading(False) |
| 981 |
if not ok: |
| 982 |
clear(list_container) |
| 983 |
list_container.appendChild(E.div(_('Failed to load list'), style='opacity:0.9; padding: 1rem')) |
| 984 |
list_container.appendChild(E.div(payload or '', style='opacity:0.8; padding: 0 1rem 1rem 1rem; font-size: smaller')) |
| 985 |
return |
| 986 |
# Update without flashing: create_item_list will clear content itself |
| 987 |
names = payload or [] |
| 988 |
cached_names[browse_cache_key()] = names |
| 989 |
render_page(names) |
| 990 |
|
| 991 |
cached = cached_names[browse_cache_key()] |
| 992 |
if cached: |
| 993 |
render_page(cached) |
| 994 |
else: |
| 995 |
set_loading(True) |
| 996 |
fetch_browse_items(render) |
| 997 |
|
| 998 |
|
| 999 |
def set_panel_handlers(): |
| 1000 |
set_panel_handler('nav_list', create_nav_list_panel) |