comments: show "undo vote" link by default on voted comments (fix #4143).
This commit is contained in:
@@ -15,6 +15,26 @@ div.comments-for-post {
|
||||
background: $menu_color;
|
||||
}
|
||||
|
||||
&[data-is-voted="true"] {
|
||||
.comment-vote-up-link, .comment-vote-down-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&[data-is-voted="false"] {
|
||||
.comment-unvote-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&[data-below-threshold="true"][data-is-sticky="false"] {
|
||||
opacity: 0.3;
|
||||
|
||||
&:hover {
|
||||
opacity: 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
div.author {
|
||||
width: 12em;
|
||||
float: left;
|
||||
@@ -38,14 +58,6 @@ div.comments-for-post {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
article.comment.below-threshold:not([data-is-sticky="true"]) {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
article.comment.below-threshold:hover {
|
||||
opacity: 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,14 +167,14 @@ class Comment < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def below_threshold?(user = CurrentUser.user)
|
||||
score < user.comment_threshold
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
creator_id == user.id || user.is_moderator?
|
||||
end
|
||||
|
||||
def voted_by?(user)
|
||||
user.id.in?(votes.map(&:user_id))
|
||||
end
|
||||
|
||||
def hidden_attributes
|
||||
super + [:body_index]
|
||||
end
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
<% if @comment_vote.is_negative? %>
|
||||
$(".comment[data-comment-id=<%= @comment.id %>]").remove();
|
||||
<% end %>
|
||||
|
||||
$("#comment-vote-up-link-for-<%= @comment.id %>").hide();
|
||||
$("#comment-vote-down-link-for-<%= @comment.id %>").hide();
|
||||
$("#comment-unvote-link-for-<%= @comment.id %>").show();
|
||||
Danbooru.Utility.notice("Vote saved");
|
||||
$(".comment[data-id=<%= @comment.id %>]").attr("data-is-voted", "true");
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
$("#comment-vote-up-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-vote-down-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-unvote-link-for-<%= @comment.id %>").hide();
|
||||
Danbooru.Utility.notice("Removed vote");
|
||||
$(".comment[data-id=<%= @comment.id %>]").attr("data-is-voted", "false");
|
||||
|
||||
@@ -1 +1 @@
|
||||
$(".comment[data-comment-id=<%= @comment.id %>] div.author h1").append(" (deleted)");
|
||||
$(".comment[data-id=<%= @comment.id %>] div.author h1").append(" (deleted)");
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
<% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %>
|
||||
<a name="comment-<%= comment.id %>"></a>
|
||||
<article class="comment <%= "below-threshold" if comment.below_threshold? %>" data-post-id="<%= comment.post_id %>" data-comment-id="<%= comment.id %>" data-score="<%= comment.score %>" data-creator="<%= comment.creator.name %>" data-is-sticky="<%= comment.is_sticky %>">
|
||||
<article class="comment"
|
||||
data-id="<%= comment.id %>"
|
||||
data-post-id="<%= comment.post_id %>"
|
||||
data-creator-id="<%= comment.creator_id %>"
|
||||
data-updater-id="<%= comment.updater_id %>"
|
||||
data-score="<%= comment.score %>"
|
||||
data-do-not-bump-post="<%= comment.do_not_bump_post? %>"
|
||||
data-is-deleted="<%= comment.is_deleted? %>"
|
||||
data-is-sticky="<%= comment.is_sticky? %>"
|
||||
data-below-threshold="<%= comment.score < CurrentUser.user.comment_threshold %>"
|
||||
data-is-voted="<%= comment.voted_by?(CurrentUser.user) %>">
|
||||
<div class="author">
|
||||
<h1>
|
||||
<%= link_to_user comment.creator %>
|
||||
@@ -31,9 +41,15 @@
|
||||
<% end %>
|
||||
<li><%= link_to "Edit", edit_comment_path(comment.id), :id => "edit_comment_link_#{comment.id}", :class => "edit_comment_link" %></li>
|
||||
<% end %>
|
||||
<li id="comment-vote-up-link-for-<%= comment.id %>"><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
||||
<li id="comment-vote-down-link-for-<%= comment.id %>"><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
|
||||
<li style="display: none;" id="comment-unvote-link-for-<%= comment.id %>" class="unvote-comment-link"><%= link_to "Unvote", comment_votes_path(:comment_id => comment.id), :method => :delete, :remote => true %></li>
|
||||
<li class="comment-vote-up-link">
|
||||
<%= link_to "Vote up", comment_votes_path(comment_id: comment.id, score: "up"), method: :post, remote: true %>
|
||||
</li>
|
||||
<li class="comment-vote-down-link">
|
||||
<%= link_to "Vote down", comment_votes_path(comment_id: comment.id, score: "down"), method: :post, remote: true %>
|
||||
</li>
|
||||
<li class="comment-unvote-link">
|
||||
<%= link_to "Unvote", comment_votes_path(comment_id: comment.id), method: :delete, remote: true %>
|
||||
</li>
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
<li>|</li>
|
||||
<li>
|
||||
|
||||
Reference in New Issue
Block a user