Commit 94fab35f

mo k <mo@mokhan.ca>
2012-10-02 13:17:51
move form page javascript bootstrap to it's on page initialization class.
1 parent 5fa2d27
Changed files (2)
app
assets
javascripts
views
app/assets/javascripts/presenters/new_tutorial_form.js.coffee
@@ -0,0 +1,18 @@
+class window.TutorialForm
+  initialize:($) ->
+    view = {
+      add_tag_button: $('#add-tag-button'),
+      tag_list: $('#tag-list'),
+      tag_input: $('#tags'),
+      hidden_tag_list: $('#hidden_tags'),
+      url_input: $('#tutorial_url'),
+      preview: {
+        heading: $('.tutorial-heading'),
+        description: $('.tutorial-description'),
+        image: $('img.embed-thumb'),
+        hidden_image_url: $('#tutorial_image_url'),
+        author: $('.tutorial-author'),
+        author_url: $('.tutorial-author-url'),
+      }
+    }
+    new NewTutorialPresenter(view, new EmbedlyService($)).present()
app/views/tutorials/_form.html.erb
@@ -1,22 +1,7 @@
 <% content_for :javascript do %>
 <script type="text/javascript" charset="utf-8">
 $(function(){
-  var view = {
-    add_tag_button: $('#add-tag-button'),
-    tag_list: $('#tag-list'),
-    tag_input: $('#tags'),
-    hidden_tag_list: $('#hidden_tags'),
-    url_input: $('#tutorial_url'),
-    preview: {
-      heading: $('.tutorial-heading'),
-      description: $('.tutorial-description'),
-      image: $('img.embed-thumb'),
-      hidden_image_url: $('#tutorial_image_url'),
-      author: $('.tutorial-author'),
-      author_url: $('.tutorial-author-url'),
-    }
-  };
-  new NewTutorialPresenter(view, new EmbedlyService($)).present();
+  new TutorialForm().initialize($);
 });
 </script>
 <% end %>