Commit c2536e09

mo k <mo@mokhan.ca>
2012-09-18 21:55:45
extract function to add a new tag.
1 parent c5fa883
Changed files (1)
app
assets
javascripts
app/assets/javascripts/presenters/new_tutorial_presenter.js.coffee
@@ -3,14 +3,15 @@ class window.NewTutorialPresenter
 
   present:() ->
     @view.add_tag_button.bind 'click', (event) =>
-      new_tag = @view.tag_input.val()
-      @view.tag_list.append(this.create_list_item_for(new_tag))
-      current = @view.hidden_tag_list.val()
-      if current == ''
-        @view.hidden_tag_list.val( new_tag)
-      else
-        @view.hidden_tag_list.val( current + ', ' + new_tag)
+      this.add_tag(@view.tag_input.val())
 
   create_list_item_for:(tag) ->
     '<li><a href="#" class="label">'+tag+'</a></li>'
 
+  add_tag:(new_tag) ->
+    @view.tag_list.append(this.create_list_item_for(new_tag))
+    if @view.hidden_tag_list.val() == ''
+      @view.hidden_tag_list.val(new_tag)
+    else
+      @view.hidden_tag_list.val( @view.hidden_tag_list.val() + ', ' + new_tag)
+