From 896df3daf9c55dbbeef58a2cf4472f00a08f224a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 8 Nov 2023 09:05:41 +0530 Subject: [PATCH] Content server: Add button to return to books page at top level of controls --- src/pyj/read_book/overlay.pyj | 8 +++++++- src/pyj/read_book/view.pyj | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index a3e4bcb1a0..da5efbbb5c 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -319,7 +319,8 @@ class MainOverlay: # {{{ ui_operations.close_book() , 'home') library_action = ac(_('Library'), _('Return to the library page'), self.overlay.show_library, 'library') - actions_div.insertBefore(E.ul(home_action, library_action), actions_div.firstChild) + book_action = ac(_('Book'), _('Return to the book\'s page'), self.overlay.show_book_page, 'book') + actions_div.insertBefore(E.ul(home_action, library_action, book_action), actions_div.firstChild) full_screen_actions = [] if runtime.is_standalone_viewer: text = _('Exit full screen') if runtime.viewer_in_full_screen else _('Enter full screen') @@ -848,6 +849,11 @@ class Overlay: show_panel('book_list', {'library_id': book.key[0], 'book_id': book.key[1] + ''}, replace=False) ui_operations.close_book() + def show_book_page(self): + self.hide_current_panel() + self.view.open_book_page() + ui_operations.close_book() + def show_font_size_chooser(self): self.hide_current_panel() self.panels.push(FontSizeOverlay(self)) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 81b245eca2..b6359e73e3 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -9,7 +9,7 @@ from ajax import ajax_send from book_list.globals import get_session_data from book_list.home import update_book_in_recently_read_by_user_on_home_page from book_list.theme import cached_color_to_rgba, get_color, set_ui_colors -from book_list.ui import query_as_href +from book_list.ui import show_panel from dom import add_extra_css, build_rule, clear, set_css, svgicon, unique_id from gettext import gettext as _ from iframe_comm import create_wrapped_iframe @@ -915,9 +915,7 @@ class View: def open_book_page(self): # Open the page for the current book in a new tab if self.book and self.book.key: - window.open(query_as_href({ - 'library_id': self.book.key[0], 'book_id': self.book.key[1] + '', 'close_action': 'book_list', - }, 'book_details')) + show_panel('book_details', {'library_id': self.book.key[0], 'book_id': self.book.key[1] + ''}, replace=False) def clear_book_resource_caches(self): self.loaded_resources = {}