comments.js: clean up comment quoting.
Replace Comment.quote with a remote new.js.erb call.
This commit is contained in:
@@ -2,31 +2,11 @@ let Comment = {};
|
||||
|
||||
Comment.initialize_all = function() {
|
||||
if ($("#c-posts").length || $("#c-comments").length) {
|
||||
$(document).on("click.danbooru.comment", ".reply-link", Comment.quote);
|
||||
$(document).on("click.danbooru.comment", ".edit_comment_link", Comment.show_edit_form);
|
||||
$(document).on("click.danbooru.comment", ".expand-comment-response", Comment.show_new_comment_form);
|
||||
}
|
||||
}
|
||||
|
||||
Comment.quote = function(e) {
|
||||
$.get(
|
||||
"/comments/" + $(e.target).data('comment-id') + ".json",
|
||||
function(data) {
|
||||
var $link = $(e.target);
|
||||
var $div = $link.closest("div.comments-for-post").find(".new-comment");
|
||||
var $textarea = $div.find("textarea");
|
||||
var msg = data.quoted_response;
|
||||
if ($textarea.val().length > 0) {
|
||||
msg = $textarea.val() + "\n\n" + msg;
|
||||
}
|
||||
$textarea.val(msg);
|
||||
$div.find("a.expand-comment-response").trigger("click");
|
||||
$textarea.selectEnd();
|
||||
}
|
||||
);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
Comment.show_new_comment_form = function(e) {
|
||||
$(e.target).hide();
|
||||
var $form = $(e.target).closest("div.new-comment").find("form");
|
||||
@@ -45,4 +25,3 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
export default Comment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user