mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1849958 [[Enhancement] Go back to book library by clicking Esc on server](https://bugs.launchpad.net/calibre/+bug/1849958)
This commit is contained in:
parent
89d5c1de22
commit
8723d0ee27
@ -605,7 +605,7 @@ def check_for_books_loaded():
|
||||
create_book_details(container)
|
||||
|
||||
|
||||
def onkeydown(container_id, ev):
|
||||
def onkeydown(container_id, close_action, ev):
|
||||
if render_book.book_id:
|
||||
if not ev.altKey and not ev.ctrlKey and not ev.metaKey and not ev.shiftKey:
|
||||
if ev.key is 'ArrowLeft':
|
||||
@ -614,6 +614,9 @@ def onkeydown(container_id, ev):
|
||||
elif ev.key is 'ArrowRight':
|
||||
next_book(render_book.book_id, 1)
|
||||
ev.preventDefault(), ev.stopPropagation()
|
||||
elif ev.key is 'Escape':
|
||||
ev.preventDefault(), ev.stopPropagation()
|
||||
close_action()
|
||||
|
||||
|
||||
def init(container_id):
|
||||
@ -629,7 +632,7 @@ def init(container_id):
|
||||
create_top_bar(container, title=_('Book details'), action=close_action, icon=close_icon)
|
||||
window.scrollTo(0, 0) # Ensure we are at the top of the window
|
||||
container.appendChild(E.div(class_=CLASS_NAME, tabindex='0'))
|
||||
container.lastChild.addEventListener('keydown', onkeydown.bind(None, container_id), {'passive': False, 'capture': True})
|
||||
container.lastChild.addEventListener('keydown', onkeydown.bind(None, container_id, close_action), {'passive': False, 'capture': True})
|
||||
container.lastChild.focus()
|
||||
container.lastChild.appendChild(E.div(_('Loading books from the calibre library, please wait...'), style='margin: 1ex 1em'))
|
||||
conditional_timeout(container_id, 5, check_for_books_loaded)
|
||||
|
@ -1040,10 +1040,18 @@ def check_for_books_loaded():
|
||||
create_edit_metadata(container)
|
||||
|
||||
|
||||
def handle_keypress(container_id, ev):
|
||||
if not ev.altKey and not ev.ctrlKey and not ev.metaKey and not ev.shiftKey:
|
||||
if ev.key is 'Escape':
|
||||
ev.preventDefault(), ev.stopPropagation()
|
||||
on_close(container_id)
|
||||
|
||||
|
||||
def init(container_id):
|
||||
container = document.getElementById(container_id)
|
||||
create_top_bar(container, title=_('Edit metadata'), action=on_close.bind(None, container_id), icon='close')
|
||||
container.appendChild(E.div(class_=CLASS_NAME))
|
||||
container.appendChild(E.div(class_=CLASS_NAME, tabindex='0', onkeydown=handle_keypress.bind(None, container_id)))
|
||||
container.lastChild.focus()
|
||||
container.lastChild.appendChild(E.div(_('Loading books from the calibre library, please wait...'), style='margin: 1ex 1em'))
|
||||
conditional_timeout(container_id, 5, check_for_books_loaded)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user