Commit 3f7254f9 authored by Randall Leeds's avatar Randall Leeds

Clean up adder events

Better to use data attributes for signaling the intent than to
be overloading the CSS class.
parent 090221f5
...@@ -35,7 +35,12 @@ module.exports = class Annotator.Guest extends Annotator ...@@ -35,7 +35,12 @@ module.exports = class Annotator.Guest extends Annotator
visibleHighlights: false visibleHighlights: false
html: jQuery.extend {}, Annotator::html, html: jQuery.extend {}, Annotator::html,
adder: '<div class="annotator-adder"><button class="h-icon-mode-comment"></button><button class="h-icon-border-color annotator-highlighter"></button></div>' adder: '''
<div class="annotator-adder">
<button class="h-icon-mode-comment" data-action="comment"></button>
<button class="h-icon-border-color" data-action="highlight"></button>
</div>
'''
constructor: (element, options, config = {}) -> constructor: (element, options, config = {}) ->
options.noScan = true options.noScan = true
...@@ -392,11 +397,11 @@ module.exports = class Annotator.Guest extends Annotator ...@@ -392,11 +397,11 @@ module.exports = class Annotator.Guest extends Annotator
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
@adder.hide() @adder.hide()
# Check to see if the highlight or note button was pushed. switch event.target.dataset.action
if event.target.className == "h-icon-border-color annotator-highlighter" when 'highlight'
this.setVisibleHighlights true this.setVisibleHighlights true
annotation = this.setupAnnotation(this.createHighlight()) annotation = this.setupAnnotation(this.createHighlight())
else when 'comment'
annotation = this.setupAnnotation(this.createAnnotation()) annotation = this.setupAnnotation(this.createAnnotation())
this.showEditor(annotation) this.showEditor(annotation)
Annotator.Util.getGlobal().getSelection().removeAllRanges() Annotator.Util.getGlobal().getSelection().removeAllRanges()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment