Commit 48233d84 authored by Randall Leeds's avatar Randall Leeds

Merge pull request #2079 from hypothesis/simplify-code

Simplify code
parents 20822425 f848fe44
......@@ -9,12 +9,6 @@ Util = Annotator.Util
delete Annotator.prototype.events[".annotator-hl mouseover"]
delete Annotator.prototype.events[".annotator-hl mouseout"]
# Add createHighlight
Annotator.prototype.createHighlight = ->
annotation = {$highlight: true}
this.publish('beforeAnnotationCreated', [annotation])
annotation
# Override setupAnnotation
Annotator.prototype.setupAnnotation = (annotation) ->
# If this is a new annotation, we might have to add the targets
......
......@@ -55,7 +55,7 @@ class Annotator.Plugin.Toolbar extends Annotator.Plugin
"click": (event) =>
event.preventDefault()
event.stopPropagation()
@annotator.addComment()
@annotator.onAdderClick target: dataset: action: "comment"
]
@buttons = $(makeButton(item) for item in items)
......
......@@ -244,7 +244,8 @@ module.exports = class Annotator.Guest extends Annotator
annotation
createHighlight: ->
annotation = super
annotation = $highlight: true
this.publish 'beforeAnnotationCreated', [annotation]
this.plugins.CrossFrame.sync([annotation])
annotation
......@@ -368,13 +369,6 @@ module.exports = class Annotator.Guest extends Annotator
@visibleHighlights = shouldShowHighlights
# Might not be needed anymore. Perhaps should just use on adderclick or perhaps new note?
addComment: ->
@adder.hide()
this.setupAnnotation(this.createAnnotation())
Annotator.Util.getGlobal().getSelection().removeAllRanges()
this.triggerShowFrame()
# Open the sidebar
triggerShowFrame: ->
@crossframe?.notify method: 'open'
......@@ -395,8 +389,8 @@ module.exports = class Annotator.Guest extends Annotator
onAdderMousedown: ->
onAdderClick: (event) =>
event.preventDefault()
event.stopPropagation()
event.preventDefault?()
event.stopPropagation?()
@adder.hide()
switch event.target.dataset.action
when 'highlight'
......
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