From e2ded283903d66c02bfa9ac3f8088059d27e51eb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 Oct 2019 13:06:14 +0530 Subject: [PATCH] Viewer: Set the classes calibre-viewer-paginated and calibre-viewer-scrolling on the tag in Paged and Flow modes. This allows the User styles to target these modes, if needed. Fixes #1847427 [Request New Feature](https://bugs.launchpad.net/calibre/+bug/1847427) --- src/pyj/read_book/iframe.pyj | 1 + src/pyj/read_book/prefs/user_stylesheet.pyj | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 328a175550..3f10483545 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -251,6 +251,7 @@ class IframeBoss: document.documentElement.style.overflow = 'hidden' if self.is_titlepage and not opts.cover_preserve_aspect_ratio: document.body.classList.add('cover-fill') + document.body.classList.add(f'calibre-viewer-{window.navigator.epubReadingSystem.layoutStyle}') self.last_window_width, self.last_window_height = scroll_viewport.width(), scroll_viewport.height() apply_settings() self.fix_fullscreen_svg_images() diff --git a/src/pyj/read_book/prefs/user_stylesheet.pyj b/src/pyj/read_book/prefs/user_stylesheet.pyj index b51dbfdd31..24be315e00 100644 --- a/src/pyj/read_book/prefs/user_stylesheet.pyj +++ b/src/pyj/read_book/prefs/user_stylesheet.pyj @@ -103,9 +103,12 @@ def create_user_stylesheet_panel(container, apply_func, cancel_func): _('A CSS style sheet that can be used to control the look and feel of the text. For examples, click'), ' ', E.a(class_='blue-link', title=_("Examples of user style sheets"), target=('_self' if runtime.is_standalone_viewer else '_blank'), - href='https://www.mobileread.com/forums/showthread.php?t=51500', _('here')) + href='https://www.mobileread.com/forums/showthread.php?t=51500', _('here.')), + ' ', _( + 'Note that you can use the selectors body.calibre-viewer-paginated and body.calibre-viewer-scrolling' + ' to target the Paged and Flow modes.') ), - E.textarea(name='user-stylesheet', style='width: 100%; margin-top: 1ex; box-sizing: border-box; flex-grow: 10') + E.textarea(name='user-stylesheet', style='width: 100%; margin-top: 1ex; box-sizing: border-box; flex-grow: 10'), ) ) )