diff --git a/src/pyj/book_list/views.pyj b/src/pyj/book_list/views.pyj index 1143c1a711..d0b73b612e 100644 --- a/src/pyj/book_list/views.pyj +++ b/src/pyj/book_list/views.pyj @@ -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)