Commit 004f82a9 authored by Aron Carroll's avatar Aron Carroll

Guest#setVisibleHighlights will always toggle highlights

parent 3ee0db43
...@@ -3,13 +3,15 @@ $ = Annotator.$ ...@@ -3,13 +3,15 @@ $ = Annotator.$
class Annotator.Guest extends Annotator class Annotator.Guest extends Annotator
SHOW_HIGHLIGHTS_CLASS = 'annotator-highlights-always-on'
# Events to be bound on Annotator#element. # Events to be bound on Annotator#element.
events: events:
".annotator-adder button click": "onAdderClick" ".annotator-adder button click": "onAdderClick"
".annotator-adder button mousedown": "onAdderMousedown" ".annotator-adder button mousedown": "onAdderMousedown"
".annotator-adder button mouseup": "onAdderMouseup" ".annotator-adder button mouseup": "onAdderMouseup"
"setTool": "onSetTool" "setTool": "onSetTool"
"setVisibleHighlights": "onSetVisibleHighlights" "setVisibleHighlights": "setVisibleHighlights"
# Plugin configuration # Plugin configuration
options: options:
...@@ -314,10 +316,23 @@ class Annotator.Guest extends Annotator ...@@ -314,10 +316,23 @@ class Annotator.Guest extends Annotator
method: 'setTool' method: 'setTool'
params: name params: name
setVisibleHighlights: (state) -> # Pass true to show the highlights in the frame or false to disable.
setVisibleHighlights: (shouldShowHighlights) ->
return if @visibleHighlights == shouldShowHighlights
@panel?.notify @panel?.notify
method: 'setVisibleHighlights' method: 'setVisibleHighlights'
params: state params: shouldShowHighlights
this.toggleHighlightClass(shouldShowHighlights or @tool == 'highlight')
toggleHighlightClass: (shouldShowHighlights) ->
if shouldShowHighlights
@element.addClass(SHOW_HIGHLIGHTS_CLASS)
else
@element.removeClass(SHOW_HIGHLIGHTS_CLASS)
@visibleHighlights = shouldShowHighlights
addComment: -> addComment: ->
this.showEditor(this.createAnnotation()) this.showEditor(this.createAnnotation())
...@@ -355,11 +370,3 @@ class Annotator.Guest extends Annotator ...@@ -355,11 +370,3 @@ class Annotator.Guest extends Annotator
this.setVisibleHighlights this.visibleHighlights this.setVisibleHighlights this.visibleHighlights
when 'highlight' when 'highlight'
this.setVisibleHighlights true this.setVisibleHighlights true
onSetVisibleHighlights: (state) ->
markerClass = 'annotator-highlights-always-on'
if state or this.tool is 'highlight'
@element.addClass markerClass
else
@element.removeClass markerClass
this.visibleHighlights = state
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