Use the same code to add comments and replies
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
App.Comments = {
|
||||
add_comment: function(parent_id, response_html) {
|
||||
$(".comment-list:first").prepend($(response_html));
|
||||
this.update_comments_count();
|
||||
},
|
||||
add_reply: function(parent_id, response_html) {
|
||||
$("#" + parent_id + " .comment-list:first").prepend($(response_html));
|
||||
add_comment: function(parent_selector, response_html) {
|
||||
$(parent_selector + " .comment-list:first").prepend($(response_html));
|
||||
this.update_comments_count();
|
||||
},
|
||||
update_comments_count: function() {
|
||||
@@ -21,17 +17,15 @@
|
||||
display_error: function(field_with_errors, error_html) {
|
||||
$(error_html).insertAfter($("" + field_with_errors));
|
||||
},
|
||||
reset_and_hide_form: function(id) {
|
||||
var form_container, input;
|
||||
form_container = $("#js-comment-form-" + id);
|
||||
input = form_container.find("form textarea");
|
||||
input.val("");
|
||||
form_container.hide();
|
||||
},
|
||||
reset_form: function(id) {
|
||||
var input;
|
||||
input = $("#js-comment-form-" + id + " form textarea");
|
||||
input.val("");
|
||||
reset_form: function(parent_selector) {
|
||||
var form_container;
|
||||
|
||||
form_container = $(parent_selector + " .comment-form:first");
|
||||
form_container.find("textarea").val("");
|
||||
|
||||
if (parent_selector !== "") {
|
||||
form_container.hide();
|
||||
}
|
||||
},
|
||||
toggle_form: function(id) {
|
||||
$("#js-comment-form-" + id).toggle();
|
||||
|
||||
Reference in New Issue
Block a user