Commit 46f0ef99

mo khan <mo@mokhan.ca>
2014-08-28 03:05:02
remove unused javascript.
1 parent c6324be
Changed files (3)
app/assets/javascripts/presenters/new_tutorial_form.js.coffee
@@ -1,18 +0,0 @@
-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/assets/javascripts/presenters/new_tutorial_presenter.js.coffee
@@ -1,27 +0,0 @@
-class window.NewTutorialPresenter
-  constructor:(@view, @service) ->
-
-  present:() ->
-    @view.add_tag_button.bind 'click', (event) =>
-      this.add_tag(@view.tag_input.val())
-    @view.url_input.bind 'change', (event) =>
-      @service.retrieve_info_on(@view.url_input.val(), this.display_url_info)
-
-  create_list_item_for:(tag) ->
-    '<a href="tags/"><span class="label">'+tag+'</span></a>'
-
-  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)
-
-  display_url_info:(data) =>
-    @view.preview.heading.val(data.title)
-    @view.preview.heading.text(data.title)
-    @view.preview.description.text(data.description)
-    @view.preview.image.attr('src', data.thumbnail_url)
-    @view.preview.hidden_image_url.val(data.thumbnail_url)
-    @view.preview.author.val(data.provider_name)
-    @view.preview.author_url.val(data.provider_url)
spec/javascripts/presenters/new_tutorial_presenter_spec.js
@@ -1,95 +0,0 @@
-describe ("NewTutorialPresenter", function() {
-  beforeEach (function() {
-    view = {
-      add_tag_button: $('<button id="add-tag-button">'),
-      tag_list: $('<ul id="tag-list">'),
-      tag_input: $('<input type="text" />'),
-      hidden_tag_list: $('<input type="hidden" />'),
-      url_input: $('<input type="text" />'),
-      preview: {
-        heading: $('<h3>'),
-        description: $('<p>'),
-        image: $('<img>'),
-        hidden_image_url: $('<input type="hidden">'),
-        author: $('<input type="text">'),
-        author_url: $('<input type="text">'),
-      }
-    };
-    service = {
-      retrieve_info_on:null
-    };
-    sut = new NewTutorialPresenter(view, service);
-  });
-  var sut;
-  var view;
-  var service;
-
-  describe ("when the add tag button is clicked", function() {
-    it ("should add the new tag to the list of tags", function() {
-      expect(view.tag_list.html()).toEqual('<a href="tags/"><span class="label">ruby</span></a>');
-    });
-    it ("should add the new tag to the hidden list of tags", function() {
-      expect(view.hidden_tag_list.val()).toEqual('ruby');
-    });
-    beforeEach (function() {
-      sut.present();
-      view.tag_input.val('ruby');
-      view.add_tag_button.trigger('click');
-    });
-  });
-  describe ("when multiple tags are added", function() {
-    it ("should add each one to the hidden list", function() {
-      expect(view.hidden_tag_list.val()).toEqual('ruby, javascript');
-    });
-    beforeEach (function() {
-      sut.present();
-      view.tag_input.val('ruby');
-      view.add_tag_button.trigger('click');
-      view.tag_input.val('javascript');
-      view.add_tag_button.trigger('click');
-    });
-  });
-  describe ("when a url is entered", function() {
-    it ("should connect to embedly to retrieve information about the url", function() {
-      expect(service.retrieve_info_on).toHaveBeenCalledWith(url, sut.display_url_info);
-    });
-    beforeEach (function() {
-      spyOn(service, 'retrieve_info_on');
-      sut.present();
-      url = 'http://mokhan.ca/';
-      view.url_input.val(url);
-      view.url_input.trigger('change');
-    });
-    var url;
-  });
-  describe ("when information is received about a url", function() {
-    it ("should update the preview heading", function() {
-      expect(view.preview.heading.text()).toEqual('the title');
-    });
-    it ("should update the preview description", function() {
-      expect(view.preview.description.text()).toEqual('the description');
-    });
-    it ("should update the preview image", function() {
-      expect(view.preview.image.attr('src')).toEqual('http://');
-    });
-    it ("should update the hidden input image url", function() {
-      expect(view.preview.hidden_image_url.val()).toEqual('http://');
-    });
-    it ("should display the author name", function() {
-      expect(view.preview.author.val()).toEqual('superman');
-    });
-    it ("should display the author url", function() {
-      expect(view.preview.author_url.val()).toEqual('http://www.superman.com');
-    });
-    beforeEach (function() {
-      var payload = {
-        title: 'the title',
-        description: 'the description',
-        thumbnail_url: 'http://',
-        provider_url: 'http://www.superman.com',
-        provider_name: 'superman'
-      };
-      sut.display_url_info(payload);
-    });
-  });
-});