From 8c53305a4c96f55e02c8a2aa15adc17d885a2bd9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 27 Dec 2019 15:21:32 +0530 Subject: [PATCH] Server viewer: Make exit fullscreen action available in viewer controls. Fixes #1857677 [Add Exit full screen option in Content server controls](https://bugs.launchpad.net/calibre/+bug/1857677) --- src/pyj/read_book/overlay.pyj | 9 ++++++--- src/pyj/utils.pyj | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index 5957255f3f..30f05e6c56 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -19,7 +19,9 @@ from read_book.prefs.main import create_prefs_panel from read_book.toc import create_toc_panel from read_book.word_actions import create_word_actions_panel from session import get_device_uuid -from utils import full_screen_element, is_ios, safe_set_inner_html +from utils import ( + full_screen_element, full_screen_supported, is_ios, safe_set_inner_html +) from widgets import create_button, create_spinner @@ -288,10 +290,11 @@ class MainOverlay: # {{{ full_screen_actions.push( ac(_('Print'), _('Print book to PDF'), def(): self.overlay.hide(), ui_operations.print_book();, 'print')) else: - if not full_screen_element() and not is_ios: + if not is_ios and full_screen_supported(): + text = _('Exit full screen') if full_screen_element() else _('Enter full screen') # No fullscreen on iOS, see http://caniuse.com/#search=fullscreen full_screen_actions.push( - ac(_('Toggle full screen'), _('Toggle full screen mode'), def(): self.overlay.hide(), ui_operations.toggle_full_screen();, 'full-screen') + ac(text, _('Toggle full screen mode'), def(): self.overlay.hide(), ui_operations.toggle_full_screen();, 'full-screen') ) if full_screen_actions.length: actions_div.appendChild(E.ul(*full_screen_actions)) diff --git a/src/pyj/utils.pyj b/src/pyj/utils.pyj index e277b066e7..93e1747e10 100644 --- a/src/pyj/utils.pyj +++ b/src/pyj/utils.pyj @@ -75,6 +75,13 @@ def encode_query_with_path(query, path): return path + encode_query(query, '#') +def full_screen_supported(elem): + elem = elem or document.documentElement + if elem.requestFullScreen or elem.webkitRequestFullScreen or elem.mozRequestFullScreen: + return True + return False + + def request_full_screen(elem): elem = elem or document.documentElement options = {'navigationUI': 'hide'}