Use the same code to add comments and replies

This commit is contained in:
Javi Martín
2020-05-10 20:47:35 +02:00
parent 4627372a62
commit faefb52972
2 changed files with 16 additions and 25 deletions

View File

@@ -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();