Commit 305d94e7 authored by Randall Leeds's avatar Randall Leeds

Make the toolbar a plugin

parent 904addb8
......@@ -25,12 +25,7 @@ class Annotator.Guest extends Annotator
.appendTo(@wrapper)
.addClass('annotator-frame annotator-outer annotator-collapsed')
unless @options.light
@toolbar = new Annotator.Toolbar()
@toolbar.element.appendTo(@frame)
delete @options.app
delete @options.light
this.addPlugin 'Bridge',
formatter: (annotation) =>
......
......@@ -26,11 +26,11 @@ class Annotator.Host extends Annotator.Guest
app.appendTo(@frame)
if @toolbar
@toolbar.hide()
if @toolbar?
@toolbar.addClass 'annotator-hide'
app
.on('mouseenter', => @toolbar.show())
.on('mouseleave', => @toolbar.hide())
.on('mouseenter', => @toolbar.removeClass 'annotator-hide')
.on('mouseleave', => @toolbar.addClass 'annotator-hide')
if @plugins.Heatmap?
this._setupDragEvents()
......
$ = Annotator.$
class Annotator.Toolbar extends Annotator.Widget
class Annotator.Plugin.Toolbar extends Annotator.Plugin
html: '<div class="annotator-toolbar"></div>'
options:
......@@ -49,8 +50,13 @@ class Annotator.Toolbar extends Annotator.Widget
window.annotator.addComment()
]
constructor: (options) ->
super $(@html)[0], options
pluginInit: ->
@annotator.toolbar = @toolbar = $(@html)
if @options.container?
$(@options.container).append @toolbar
else
$(@element).append @toolbar
@buttons = @options.items.reduce (buttons, item) =>
button = $('<a></a>')
.attr('href', '')
......@@ -60,15 +66,5 @@ class Annotator.Toolbar extends Annotator.Widget
.data('state', false)
buttons.add button
, $()
@element
.append(@buttons)
.wrapInner('<ul></ul>')
@toolbar.append(@buttons).wrapInner('<ul></ul>')
@buttons.wrap('<li></li>')
show: ->
@element.removeClass @classes.hide
this
hide: ->
@element.addClass @classes.hide
this
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