Improve the way to toggle comment responses

Co-Authored-By: Javi Martín <javim@elretirao.net>
This commit is contained in:
Senén Rodero Rodríguez
2020-05-15 17:09:02 +02:00
parent dcff7e8a33
commit 31c0b4360d
4 changed files with 37 additions and 21 deletions

View File

@@ -2,11 +2,8 @@
"use strict";
App.Comments = {
add_comment: function(parent_selector, response_html) {
$(parent_selector + " .comment-list:first").prepend($(response_html));
var hidden_responses = $(parent_selector + " .comment-list:first").is(":hidden");
if (parent_selector && hidden_responses) {
$(parent_selector).find(".comment-list:first").toggle("slow");
}
$(parent_selector + " .comment-list:first").prepend($(response_html)).show("slow");
$(parent_selector + " .responses-count:first").removeClass("collapsed");
this.update_comments_count();
},
update_comments_count: function() {
@@ -45,8 +42,7 @@
$("body").on("click", ".js-toggle-children", function() {
$(this).closest(".comment").find(".comment-list:first").toggle("slow");
$(this).children(".far").toggleClass("fa-minus-square fa-plus-square");
$(this).children(".js-child-toggle").toggle();
$(this).closest(".responses-count").toggleClass("collapsed");
return false;
});
}