mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make resize event available to the read book widget as well
This commit is contained in:
parent
9235097db2
commit
a067cd6b64
@ -7,7 +7,7 @@ from elementmaker import E
|
|||||||
from modals import error_dialog, create_modal_container
|
from modals import error_dialog, create_modal_container
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from widgets import get_widget_css
|
from widgets import get_widget_css
|
||||||
from utils import parse_url_params
|
from utils import parse_url_params, debounce
|
||||||
|
|
||||||
from book_list.globals import get_session_data, set_boss, set_current_query
|
from book_list.globals import get_session_data, set_boss, set_current_query
|
||||||
from book_list.theme import get_color
|
from book_list.theme import get_color
|
||||||
@ -47,6 +47,11 @@ class Boss:
|
|||||||
setTimeout(def():
|
setTimeout(def():
|
||||||
window.onpopstate = self.onpopstate.bind(self)
|
window.onpopstate = self.onpopstate.bind(self)
|
||||||
, 0) # We do this after event loop ticks over to avoid catching popstate events that some browsers send on page load
|
, 0) # We do this after event loop ticks over to avoid catching popstate events that some browsers send on page load
|
||||||
|
window.addEventListener('resize', debounce(self.on_resize.bind(self), 250))
|
||||||
|
|
||||||
|
def on_resize(self):
|
||||||
|
self.ui.on_resize()
|
||||||
|
self.read_ui.on_resize()
|
||||||
|
|
||||||
def apply_mode(self, mode):
|
def apply_mode(self, mode):
|
||||||
mode = mode or self.current_mode
|
mode = mode or self.current_mode
|
||||||
|
@ -9,7 +9,6 @@ from book_list.item_list import ItemsView, create_item
|
|||||||
from book_list.prefs import PrefsPanel
|
from book_list.prefs import PrefsPanel
|
||||||
from book_list.book_details import BookDetailsPanel
|
from book_list.book_details import BookDetailsPanel
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from utils import debounce
|
|
||||||
from modals import error_dialog, ajax_progress_dialog
|
from modals import error_dialog, ajax_progress_dialog
|
||||||
|
|
||||||
class BarState:
|
class BarState:
|
||||||
@ -96,7 +95,6 @@ class UI:
|
|||||||
self.panels = [self.books_view, self.items_view, self.search_panel, self.prefs_panel, self.book_details_panel]
|
self.panels = [self.books_view, self.items_view, self.search_panel, self.prefs_panel, self.book_details_panel]
|
||||||
self.panel_map = {self.ROOT_PANEL: UIState(create_book_view_top_bar_state(self.books_view), main_panel=self.books_view)}
|
self.panel_map = {self.ROOT_PANEL: UIState(create_book_view_top_bar_state(self.books_view), main_panel=self.books_view)}
|
||||||
self.current_panel = self.ROOT_PANEL
|
self.current_panel = self.ROOT_PANEL
|
||||||
window.addEventListener('resize', debounce(self.on_resize.bind(self), 250))
|
|
||||||
|
|
||||||
num_of_libraries = len(interface_data.library_map)
|
num_of_libraries = len(interface_data.library_map)
|
||||||
actions = [
|
actions = [
|
||||||
|
@ -47,6 +47,9 @@ class ReadUI:
|
|||||||
))
|
))
|
||||||
self.view = View(container.lastChild, self)
|
self.view = View(container.lastChild, self)
|
||||||
|
|
||||||
|
def on_resize(self):
|
||||||
|
self.view.on_resize()
|
||||||
|
|
||||||
def show_stack(self, name):
|
def show_stack(self, name):
|
||||||
ans = None
|
ans = None
|
||||||
for w in self.stacked_widgets:
|
for w in self.stacked_widgets:
|
||||||
|
@ -28,10 +28,15 @@ class View:
|
|||||||
self.ui = ui
|
self.ui = ui
|
||||||
self.loaded_resources = {}
|
self.loaded_resources = {}
|
||||||
container.appendChild(
|
container.appendChild(
|
||||||
E.iframe(
|
E.div(style='width: 100vw; height: 100vh; overflow: hidden; display: flex; align-items: stretch',
|
||||||
id=iframe_id,
|
E.div(style='display: flex; flex-direction: column; align-items: stretch; flex-grow:2',
|
||||||
seamless=True,
|
E.iframe(
|
||||||
sandbox='allow-popups allow-scripts',
|
id=iframe_id,
|
||||||
|
seamless=True,
|
||||||
|
sandbox='allow-popups allow-scripts',
|
||||||
|
style='flex-grow: 2',
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.src_doc = None
|
self.src_doc = None
|
||||||
@ -94,6 +99,9 @@ class View:
|
|||||||
def on_iframe_error(self, data):
|
def on_iframe_error(self, data):
|
||||||
self.ui.show_error((data.title or _('There was an error processing the book')), data.msg, data.details)
|
self.ui.show_error((data.title or _('There was an error processing the book')), data.msg, data.details)
|
||||||
|
|
||||||
|
def on_resize(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def show_loading(self, title):
|
def show_loading(self, title):
|
||||||
return # TODO: Implement this
|
return # TODO: Implement this
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user