Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
Some more cleanup / simplification about the "Refresh UX" PR.
  • Loading branch information
csillag committed Mar 24, 2015
1 parent 18efb85 commit 25efdd6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
6 changes: 0 additions & 6 deletions h/static/scripts/annotator/monkey.coffee
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion h/static/scripts/annotator/plugin/toolbar.coffee
Expand Up @@ -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)

Expand Down
14 changes: 4 additions & 10 deletions h/static/scripts/guest.coffee
Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down

0 comments on commit 25efdd6

Please sign in to comment.