Skip to content

Commit

Permalink
Update disowning comments to remove jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
ymeynot45 committed Jun 30, 2022
1 parent 769e136 commit bb4492c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions app/assets/javascripts/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,6 @@ $(document).ready(function() {
return false;
});

$(document).on("click", "a.comment_disownor", function() {
if (confirm("Are you sure you want to disown this comment?")) {
var li = $(this).closest(".comment");
$.post("/comments/" + $(li).attr("data-shortid") + "/disown",
function(d) {
$(li).replaceWith(d);
});
}
});

Lobsters.runSelect2();

$(document).on("blur", "#story_url", function() {
Expand Down Expand Up @@ -589,6 +579,17 @@ onPageLoad(() => {

// Comment Related Functions

on('click', 'a.comment-disowner', (event) => {
if (confirm("Are you sure you want to disown this comment?")) {
let li = parentSelector(event.target, '.comment');
fetchWithCSRF('/comments/' + li.getAttribute('data-shortid') + '/disown', {
method: 'post'
})
.then(response => response.text())
.then(text => replace(li, text));
}
});

on('click', '.comment a.flagger', (event) => {
event.preventDefault();
Lobster.flagComment(event.target);
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_comment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<% end %>
<% elsif !comment.is_gone? && comment.is_disownable_by_user?(@user) %>
|
<a tabindex="0" class="comment_disownor" href="#">disown</a>
<a tabindex="0" class="comment-disowner" href="#">disown</a>
<% end %>

<% if can_flag && !flagged %>
Expand Down

0 comments on commit bb4492c

Please sign in to comment.