Clean up button box

This commit is contained in:
Kovid Goyal 2020-08-04 13:08:31 +05:30
parent 16d241b9d2
commit fa13ee5943
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 15 deletions

View File

@ -137,6 +137,13 @@ class EditNotesAndColors: # {{{
remove_button = create_button(_('Remove style'), 'trash', self.remove_custom_color, _('Remove this custom highlight style'))
remove_button.classList.add('remove-custom-color')
apply_button = create_button(
_('Apply') if self.annot_id else _('Create'),
'check', finish,
(_('Finish editing highlight') if self.annot_id else _('Create highlight')) + ' [Ctrl+Enter]',
True
)
apply_button.style.marginLeft = apply_button.style.marginTop = 'auto'
c = E.div(
style=f'background: {get_color("window-background")}; margin: auto; text-align: center; padding: 1ex;',
@ -154,18 +161,11 @@ class EditNotesAndColors: # {{{
style=f'display: flex; flex-wrap: wrap; width: 100%; justify-content: center',
),
E.div(
style='width: 100%; display: flex; justify-content: space-between',
E.div(
create_button(_('Cancel'), 'close', abort, _('Abort') + ' [Esc]'),
E.span('\xa0'),
remove_button
),
create_button(
_('Apply') if self.annot_id else _('Create'),
'check', finish,
(_('Finish editing highlight') if self.annot_id else _('Create highlight')) + ' [Ctrl+Enter]', True),
)
style='width: 100%; display: flex; flex-wrap: wrap',
create_button(_('Cancel'), 'close', abort, _('Abort') + ' [Esc]'),
E.span('\xa0'),
remove_button, apply_button
),
)
self.container_id = c.id
container.appendChild(c)
@ -186,8 +186,7 @@ class EditNotesAndColors: # {{{
def set_visibility_of_remove_button(self):
c = self.container
item = c.querySelector('.current-swatch.custom-style')
visibility = 'unset' if item else 'hidden'
c.querySelector('.remove-custom-color').style.visibility = visibility
c.querySelector('.remove-custom-color').style.display = 'block' if item else 'none'
def add_color(self, hs, at_start):
if self.seen_colors[hs.key]:

View File

@ -743,7 +743,7 @@ class SelectionBar:
_('Failed to apply highlighting, try adjusting extent of highlight')
)
self.annotations_manager.add_highlight(msg, self.current_highlight_style.style, notes)
if msg.type is 'edit-highlight':
elif msg.type is 'edit-highlight':
if self.state is WAITING:
self.create_highlight()
else: