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