Commit 94fab35f
Changed files (2)
app
assets
javascripts
presenters
views
tutorials
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 %>