mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Also preserve scroll position when using the home button
This commit is contained in:
parent
55414ba6fa
commit
740ab016fc
@ -23,7 +23,7 @@ from book_list.library_data import (
|
||||
ensure_current_library_data, library_data, load_status, loaded_books_query,
|
||||
thumbnail_cache, url_books_query
|
||||
)
|
||||
from book_list.router import back, update_window_title, push_state
|
||||
from book_list.router import back, update_window_title, push_state, home
|
||||
from book_list.search import (
|
||||
init as init_search_panel, set_apply_search, tb_config_panel_handler
|
||||
)
|
||||
@ -73,7 +73,7 @@ def has_parent_with_class(elem, cls):
|
||||
elem = elem.parentNode
|
||||
|
||||
|
||||
def show_subsequent_panel(name, query=None, replace=False):
|
||||
def save_scroll_position():
|
||||
container = document.getElementById(book_list_data.container_id)
|
||||
if container:
|
||||
left, top = container.offsetLeft, container.offsetTop
|
||||
@ -85,6 +85,10 @@ def show_subsequent_panel(name, query=None, replace=False):
|
||||
q = parse_url_params()
|
||||
q.book_id = p.dataset.bookId
|
||||
push_state(q, replace=True, call_handler=False)
|
||||
|
||||
|
||||
def show_subsequent_panel(name, query=None, replace=False):
|
||||
save_scroll_position()
|
||||
show_panel(name, query, replace)
|
||||
|
||||
|
||||
@ -265,7 +269,7 @@ def check_for_books_loaded():
|
||||
err,
|
||||
E.div(
|
||||
style='margin-top: 1em; border-top: solid 1px currentColor; padding-top: 1ex;',
|
||||
E.a(onclick=back, href='javascript: void(0)', style='color: blue', _('Go back to the home page')))
|
||||
E.a(onclick=home, href='javascript: void(0)', style='color: blue', _('Go back to the home page')))
|
||||
),
|
||||
)
|
||||
return
|
||||
@ -279,7 +283,7 @@ def init(container_id):
|
||||
lid = container.dataset.library_id = url_books_query().library_id
|
||||
title = interface_data.library_map[lid]
|
||||
update_window_title(title)
|
||||
create_top_bar(container, title=title, action=back, icon='home')
|
||||
create_top_bar(container, title=title, action=def(): save_scroll_position(), home();, icon='home')
|
||||
container.appendChild(E.div(class_=CLASS_NAME))
|
||||
container.lastChild.appendChild(E.div(_('Loading books from the {} calibre library, please wait...').format(title), style='margin: 1ex 1em'))
|
||||
conditional_timeout(container_id, 5, check_for_books_loaded)
|
||||
|
Loading…
x
Reference in New Issue
Block a user