Simplify code to show/collapse comment replies
Tests are also a bit easier to read, even though we need to use the `text:` option to find links because otherwise the text in the hidden `<span>` tags will cause `click_link` to miss the link we want to click. Here's an explanation by one of Capybara's authors: https://github.com/teamcapybara/capybara/issues/2347#issuecomment-626373440
This commit is contained in:
@@ -39,9 +39,6 @@
|
||||
toggle_form: function(id) {
|
||||
$("#js-comment-form-" + id).toggle();
|
||||
},
|
||||
toggle_arrow: function(id) {
|
||||
$("span#" + id + "_arrow").toggleClass("fa-minus-square fa-plus-square");
|
||||
},
|
||||
initialize: function() {
|
||||
$("body").on("click", ".js-add-comment-link", function() {
|
||||
App.Comments.toggle_form($(this).data().id);
|
||||
@@ -49,10 +46,8 @@
|
||||
});
|
||||
|
||||
$("body").on("click", ".js-toggle-children", function() {
|
||||
var children_container_id;
|
||||
children_container_id = ($(this).data().id) + "_children";
|
||||
$("#" + children_container_id).toggle("slow");
|
||||
App.Comments.toggle_arrow(children_container_id);
|
||||
$("#" + $(this).data().id + "_children").toggle("slow");
|
||||
$(this).children(".far").toggleClass("fa-minus-square fa-plus-square");
|
||||
$(this).children(".js-child-toggle").toggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user