mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 12:03:38 +02:00
Content server: Fix Esc ky not working in several views. Fixes #1849958 [[Enhancement] Go back by clicking Esc on server](https://bugs.launchpad.net/calibre/+bug/1849958)
This commit is contained in:
parent
12e64d6e8b
commit
ff67af8312
5 changed files with 22 additions and 6 deletions
|
|
@ -16,7 +16,7 @@
|
|||
)
|
||||
from session import get_interface_data
|
||||
from utils import safe_set_inner_html
|
||||
from widgets import create_button
|
||||
from widgets import create_button, enable_escape_key
|
||||
|
||||
state = {
|
||||
'in_progress': False,
|
||||
|
|
@ -175,6 +175,7 @@ def add_books_panel(container_id):
|
|||
state.in_progress = True
|
||||
state.container_id = container_id
|
||||
state.fake_send = False
|
||||
enable_escape_key(container, on_close)
|
||||
return upload_files_widget(container, files_chosen)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
from dom import add_extra_css, build_rule, clear
|
||||
from modals import error_dialog
|
||||
from utils import conditional_timeout, human_readable, parse_url_params
|
||||
from widgets import create_button
|
||||
from widgets import create_button, enable_escape_key
|
||||
|
||||
CLASS_NAME = 'convert-book-panel'
|
||||
current_state = 'initializing'
|
||||
|
|
@ -243,6 +243,7 @@ def show_group(ev):
|
|||
conversion_data.configuring_group_title = group_title
|
||||
current_state = 'configure-group'
|
||||
apply_state_to_markup()
|
||||
document.getElementById(overall_container_id).focus()
|
||||
|
||||
def is_group_configurable(name):
|
||||
if entry_points[name]:
|
||||
|
|
@ -475,6 +476,7 @@ def init(container_id):
|
|||
conditional_timeout(container_id, 5, check_for_data_loaded)
|
||||
q = parse_url_params()
|
||||
fetch_conversion_data(q.book_id)
|
||||
enable_escape_key(container, on_close.bind(None, container_id))
|
||||
|
||||
|
||||
set_panel_handler('convert_book', init)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
from dom import clear, ensure_id
|
||||
from modals import create_custom_dialog, error_dialog
|
||||
from utils import conditional_timeout, safe_set_inner_html
|
||||
from widgets import create_button
|
||||
from widgets import create_button, enable_escape_key
|
||||
|
||||
CLASS_NAME = 'local-books-list'
|
||||
|
||||
|
|
@ -221,7 +221,8 @@ def show_recent():
|
|||
|
||||
def init(container_id):
|
||||
container = document.getElementById(container_id)
|
||||
create_top_bar(container, title=_('Downloaded books'), action=home, icon='home')
|
||||
on_close = home
|
||||
create_top_bar(container, title=_('Downloaded books'), action=on_close, icon='home')
|
||||
add_button(container, 'trash', confirm_delete_all, _('Delete all downloaded books'))
|
||||
# book list
|
||||
recent = E.div(class_=CLASS_NAME)
|
||||
|
|
@ -232,6 +233,7 @@ def init(container_id):
|
|||
_('Loading downloaded books from local storage, please wait...')
|
||||
))
|
||||
conditional_timeout(recent_container_id, 5, show_recent)
|
||||
enable_escape_key(container, on_close)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
from modals import error_dialog
|
||||
from session import get_interface_data
|
||||
from utils import conditional_timeout, parse_url_params, safe_set_inner_html
|
||||
from widgets import create_button, create_spinner
|
||||
from widgets import create_button, create_spinner, enable_escape_key
|
||||
|
||||
CLASS_NAME = 'book-list-container'
|
||||
ITEM_CLASS_NAME = 'book-list-item'
|
||||
|
|
@ -377,6 +377,7 @@ def create_sort_panel(container_id):
|
|||
items.push(create_item(name, subtitle=subtitle, icon=icon_name, action=action))
|
||||
container.appendChild(E.div())
|
||||
create_item_list(container.lastChild, items, _('Change how the list of books is sorted'))
|
||||
enable_escape_key(container, close_action)
|
||||
# }}}
|
||||
|
||||
# Searching {{{
|
||||
|
|
@ -468,7 +469,7 @@ def create_more_actions_panel(container_id):
|
|||
))
|
||||
container.appendChild(E.div())
|
||||
create_item_list(container.lastChild, items)
|
||||
|
||||
enable_escape_key(container, back)
|
||||
# }}}
|
||||
|
||||
# Adding books {{{
|
||||
|
|
|
|||
|
|
@ -216,3 +216,13 @@ def scroll_tree_item_into_view(item):
|
|||
ans += Breadcrumbs.STYLE_RULES + '\n'
|
||||
return ans
|
||||
)
|
||||
|
||||
|
||||
def enable_escape_key(container, action):
|
||||
container.setAttribute('tabindex', '0')
|
||||
container.addEventListener('keydown', def(ev):
|
||||
if ev.key is 'Escape':
|
||||
ev.stopPropagation(), ev.preventDefault()
|
||||
action()
|
||||
, {'passive': False})
|
||||
container.focus()
|
||||
|
|
|
|||
Loading…
Reference in a new issue