Commit a7ddb6d6 authored by Randall Leeds's avatar Randall Leeds

Sync toolbar button state to sidebar truth

parent 32aa6eaa
......@@ -109,10 +109,14 @@ class Annotator.Guest extends Annotator
}
)
.bind('setTool', (ctx, name) => this.setTool name)
.bind('setTool', (ctx, name) =>
this.setTool name
this.publish 'setTool', name
)
.bind('setVisibleHighlights', (ctx, state) =>
this.setVisibleHighlights state
this.publish 'setVisibleHighlights', state
)
scanDocument: (reason = "something happened") =>
......
......@@ -3,6 +3,8 @@ $ = Annotator.$
class Annotator.Plugin.Toolbar extends Annotator.Plugin
events:
'updateNotificationCounter': 'onUpdateNotificationCounter'
'setTool': 'onSetTool'
'setVisibleHighlights': 'onSetVisibleHighlights'
html:
element: '<div class="annotator-toolbar"></div>'
......@@ -28,10 +30,6 @@ class Annotator.Plugin.Toolbar extends Annotator.Plugin
event.stopPropagation()
state = not window.annotator.visibleHighlights
window.annotator.setVisibleHighlights state
if state
$(event.target).addClass('pushed')
else
$(event.target).removeClass('pushed')
,
"title": "Highlighting Mode"
"class": "highlighter-icon"
......@@ -41,10 +39,6 @@ class Annotator.Plugin.Toolbar extends Annotator.Plugin
state = not (window.annotator.tool is 'highlight')
tool = if state then 'highlight' else 'comment'
window.annotator.setTool tool
if state
$(event.target).addClass('pushed')
else
$(event.target).removeClass('pushed')
,
"title": "New Comment"
"class": "commenter-icon"
......@@ -93,3 +87,15 @@ class Annotator.Plugin.Toolbar extends Annotator.Plugin
@notificationCounter.text("+#{count}")
else
@notificationCounter.text('')
onSetTool: (name) ->
if name is 'highlight'
$(@buttons[2]).addClass('pushed')
else
$(@buttons[2]).removeClass('pushed')
onSetVisibleHighlights: (state) ->
if state
$(@buttons[1]).addClass('pushed')
else
$(@buttons[1]).removeClass('pushed')
......@@ -450,6 +450,7 @@ class Hypothesis extends Annotator
setTool: (name) =>
return if name is @tool
@tool = name
this.publish 'setTool', name
for p in @providers
p.channel.notify
method: 'setTool'
......@@ -458,6 +459,7 @@ class Hypothesis extends Annotator
setVisibleHighlights: (state) =>
return if state is @visibleHighlights
@visibleHighlights = state
this.publish 'setVisibleHighlights', state
for p in @providers
p.channel.notify
method: 'setVisibleHighlights'
......
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