activate highlighter on pickColor

This commit is contained in:
Felix Niklas 2015-06-08 12:36:11 +02:00
parent 10a87d72a1
commit 12ea7db7d0

View file

@ -872,33 +872,41 @@ class highlightRef extends App.ControllerContent
toggleHighlight: (e) => toggleHighlight: (e) =>
if @isActive if @isActive
@highlightIcon.css('fill', '') @deactivate()
@isActive = false
@articles.off('mouseup', @onMouseUp)
@articles.removeAttr('data-highlightcolor')
else else
selection = rangy.getSelection() @activate()
# if there's already something selected,
# don't go into highlight mode
# just toggle the selected
if !selection.isCollapsed
@toggleHighlightAtSelection $(selection.anchorNode).closest @articles.selector
else
# show color
@highlightIcon.css('fill', @colors[@activeColorIndex].color)
# activate selection background deactivate: ->
@articles.attr('data-highlightcolor', @colors[@activeColorIndex].name) @highlightIcon.css('fill', '')
@isActive = false
@articles.off('mouseup', @onMouseUp)
@articles.removeAttr('data-highlightcolor')
@isActive = true activate: ->
@articles.on('mouseup', @onMouseUp) #future: touchend selection = rangy.getSelection()
# if there's already something selected,
# don't go into highlight mode
# just toggle the selected
if !selection.isCollapsed
@toggleHighlightAtSelection $(selection.anchorNode).closest @articles.selector
else
# show color
@highlightIcon.css('fill', @colors[@activeColorIndex].color)
# activate selection background
@articles.attr('data-highlightcolor', @colors[@activeColorIndex].name)
@isActive = true
@articles.on('mouseup', @onMouseUp) #future: touchend
pickColor: (e) => pickColor: (e) =>
@$('.js-highlightColor .visibility-change.is-active').removeClass('is-active') @$('.js-highlightColor .visibility-change.is-active').removeClass('is-active')
$(e.currentTarget).find('.visibility-change').addClass('is-active') $(e.currentTarget).find('.visibility-change').addClass('is-active')
@activeColorIndex = $(e.currentTarget).attr('data-key') @activeColorIndex = $(e.currentTarget).attr('data-key')
if @isActive if not @isActive
@activate()
else
@highlightIcon.css('fill', @colors[@activeColorIndex].color) @highlightIcon.css('fill', @colors[@activeColorIndex].color)
@setColor() @setColor()