Content server: Add button to return to books page at top level of controls

This commit is contained in:
Kovid Goyal 2023-11-08 09:05:41 +05:30
parent 512c1e34b3
commit 896df3daf9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 5 deletions

View File

@ -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))

View File

@ -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 = {}