Commit 94b5cf4d authored by Nick Stenning's avatar Nick Stenning

Move button construction out of pluginInit

parent e77c90a5
$ = Annotator.$
makeButton = (item) ->
anchor = $('<a></a>')
.attr('href', '')
.attr('title', item.title)
.on(item.on)
.addClass(item.class)
button = $('<li></li>').append(anchor)
return button[0]
class Annotator.Plugin.Toolbar extends Annotator.Plugin
PUSHED_CLASS = 'annotator-pushed'
......@@ -64,15 +73,7 @@ class Annotator.Plugin.Toolbar extends Annotator.Plugin
else
$(@element).append @toolbar
@buttons = @options.items.reduce (buttons, item) =>
anchor = $('<a></a>')
.attr('href', '')
.attr('title', item.title)
.on(item.on)
.addClass(item.class)
button = $('<li></li>').append(anchor)
buttons.add button
, $()
@buttons = $(makeButton(item) for item in @options.items)
list = $('<ul></ul>')
@buttons.appendTo(list)
......
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