diff --git a/app/assets/javascripts/legislation_annotatable.js b/app/assets/javascripts/legislation_annotatable.js index 9ab0f6d6e..1b0c91ca7 100644 --- a/app/assets/javascripts/legislation_annotatable.js +++ b/app/assets/javascripts/legislation_annotatable.js @@ -186,6 +186,15 @@ } }; }, + initCommentFormToggler: function() { + $("body").on("click", ".comment-box a.publish-comment", function(e) { + e.preventDefault(); + var annotation_id = $(this).closest(".comment-box").data("id"); + $("a.publish-comment").hide(); + $("#js-comment-form-annotation-" + annotation_id).toggle(); + $("#js-comment-form-annotation-" + annotation_id + " textarea").trigger("focus"); + }); + }, initialize: function() { var current_user_id; $("body").on("renderLegislationAnnotation", App.LegislationAnnotatable.renderAnnotationComments); @@ -226,6 +235,8 @@ }); }); }); + + App.LegislationAnnotatable.initCommentFormToggler(); }, destroy: function() { if ($(".legislation-annotatable").length > 0) { diff --git a/app/views/legislation/annotations/_comments_box.html.erb b/app/views/legislation/annotations/_comments_box.html.erb index c1d1f24fd..6d5661622 100644 --- a/app/views/legislation/annotations/_comments_box.html.erb +++ b/app/views/legislation/annotations/_comments_box.html.erb @@ -1,4 +1,4 @@ -