+
+ tool_buttons =
+ tutorial: default: true, factory: TutorialTool
+ draw: button_text: 'draw', factory: DrawTool
+ edit: button_text: 'edit', factory: EditTool
+ delete: button_text: 'delete', factory: DeleteTool
+ for k, t of tool_buttons
+ if t.button_text?
+ t.button = $ "<span class=\"button\"></span>"
+ t.button.text t.button_text
+ $toolbar.append t.button
+ do (k, t) ->
+ activate = ->
+ if cur_tool?
+ cur_tool.disable()
+ $container.removeClass "#{cur_tool_name}_tool"
+ ($toolbar.find '.button').removeClass 'disabled'
+ cur_tool_name = k
+ $container.addClass "#{cur_tool_name}_tool"
+ $tool_options.empty()
+ cur_tool = new t.factory button: t.button, tool_options: $tool_options
+ if t.button?
+ t.button.click activate
+ if t.default
+ activate()
+