Skip to content

Commit

Permalink
SOC-5 #comment JS code was in wrong place and form had the wrong clas…
Browse files Browse the repository at this point in the history
…s name.
  • Loading branch information
witharmshigh committed Jul 14, 2013
1 parent 8a4feab commit 4d7101b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
25 changes: 3 additions & 22 deletions app/assets/javascripts/comments.js.coffee
@@ -1,22 +1,3 @@
# comments.js.coffee
jQuery ->
# Create a comment
$(".comment-form")
.on "ajax:beforeSend", (evt, xhr, settings) ->
$(this).find('textarea')
.addClass('uneditable-input')
.attr('disabled', 'disabled');
.on "ajax:success", (evt, data, status, xhr) ->
$(this).find('textarea')
.removeClass('uneditable-input')
.removeAttr('disabled', 'disabled')
.val('');
$(xhr.responseText).hide().insertAfter($(this)).show('slow')
# Delete a comment
$(document)
.on "ajax:beforeSend", ".comment", ->
$(this).fadeTo('fast', 0.5)
.on "ajax:success", ".comment", ->
$(this).hide('fast')
.on "ajax:error", ".comment", ->
$(this).fadeTo('fast', 1)
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
23 changes: 22 additions & 1 deletion app/assets/javascripts/topics.js.coffee
@@ -1,3 +1,24 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery ->
# Create a comment
$(".comment-form")
.on "ajax:beforeSend", (evt, xhr, settings) ->
$(this).find('textarea')
.addClass('uneditable-input')
.attr('disabled', 'disabled');
.on "ajax:success", (evt, data, status, xhr) ->
$(this).find('textarea')
.removeClass('uneditable-input')
.removeAttr('disabled', 'disabled')
.val('');
$(xhr.responseText).hide().insertAfter($(this)).show('slow')
# Delete a comment
$(document)
.on "ajax:beforeSend", ".comment", ->
$(this).fadeTo('fast', 0.5)
.on "ajax:success", ".comment", ->
$(this).hide('fast')
.on "ajax:error", ".comment", ->
$(this).fadeTo('fast', 1)
2 changes: 1 addition & 1 deletion app/views/comments/_form.html.erb
@@ -1,4 +1,4 @@
<div class="comments form">
<div class="comment-form">
<%= simple_form_for comment, :remote => true do |f| %>
<%= f.input :body, :input_html => { :rows => "2" }, :label => false %>
<%= f.input :commentable_id, :as => :hidden, :value => comment.commentable_id %>
Expand Down

0 comments on commit 4d7101b

Please sign in to comment.