Add an All button

This commit is contained in:
Kovid Goyal 2021-02-05 20:53:20 +05:30
parent 7ecd365899
commit ccc1cad840
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -786,6 +786,11 @@ def clear_selection():
item_select_toggled() item_select_toggled()
def select_all():
for e in document.querySelectorAll('.highlight input'):
e.checked = True
def delete_selection(annotations_manager, view): def delete_selection(annotations_manager, view):
selected_highlight_items = all_selected_entries() selected_highlight_items = all_selected_entries()
if not selected_highlight_items.length: if not selected_highlight_items.length:
@ -854,6 +859,9 @@ def create_highlights_panel(annotations_manager, book, container, onclick):
delete_button = create_button( delete_button = create_button(
_('Remove'), 'trash', delete_selection.bind(None, annotations_manager, annotations_manager.view), _('Remove selected highlights'), _('Remove'), 'trash', delete_selection.bind(None, annotations_manager, annotations_manager.view), _('Remove selected highlights'),
class_='ac-button sel-button') class_='ac-button sel-button')
all_button = create_button(
_('All'), 'plus', select_all, _('Select all highlights'),
class_='ac-button sel-button')
export_button = create_button( export_button = create_button(
_('Export'), 'cloud-download', show_export_dialog.bind(None, annotations_manager), _('Export all or selected highlights'), _('Export'), 'cloud-download', show_export_dialog.bind(None, annotations_manager), _('Export all or selected highlights'),
class_='ac-button') class_='ac-button')
@ -862,7 +870,7 @@ def create_highlights_panel(annotations_manager, book, container, onclick):
id=get_container_id(), id=get_container_id(),
E.div( E.div(
style='display: flex; flex-wrap: wrap; margin-top: -1ex; align-items: center', style='display: flex; flex-wrap: wrap; margin-top: -1ex; align-items: center',
sb, next_button, prev_button, clear_button, delete_button, export_button sb, next_button, prev_button, clear_button, all_button, delete_button, export_button
), ),
) )
container.appendChild(c) container.appendChild(c)