posts/show: fix flickering favlist show/hide buttons.

This commit is contained in:
evazion
2018-08-13 03:50:35 -05:00
parent 72a37c2f94
commit 0c49b162f0
2 changed files with 4 additions and 20 deletions

View File

@@ -310,24 +310,8 @@ Post.toggle_relationship_preview = function(preview, preview_link) {
}
Post.initialize_favlist = function() {
$("#favlist").hide();
$("#hide-favlist-link").hide();
var fav_count = $("#show-favlist-link").prev().text();
if (fav_count === "0") {
$("#show-favlist-link").hide();
}
$("#show-favlist-link").click(function(e) {
$("#favlist").show();
$(this).hide();
$("#hide-favlist-link").show();
e.preventDefault();
});
$("#hide-favlist-link").click(function(e) {
$("#favlist").hide();
$(this).hide();
$("#show-favlist-link").show();
$("#show-favlist-link, #hide-favlist-link").click(function(e) {
$("#favlist, #show-favlist-link, #hide-favlist-link").toggle();
e.preventDefault();
});
}

View File

@@ -22,8 +22,8 @@
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_voter? %>(<span id="vote-links-for-post-<%= post.id %>">vote <%= link_to content_tag("i", nil, class: "far fa-thumbs-up"), post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %> <%= link_to content_tag("i", nil, class: "far fa-thumbs-down"), post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %></span><%= link_to "undo vote", post_votes_path(post), :remote => true, :method => :delete, :id => "unvote-link-for-post-#{post.id}", :class => "unvote-post-link" %>)<% end %></li>
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
<% if CurrentUser.is_gold? %>
<%= link_to "Show &raquo;".html_safe, "#", :id => "show-favlist-link" %>
<%= link_to "&laquo; Hide".html_safe, "#", :id => "hide-favlist-link", :style => "display: none;" %>
<%= link_to "Show »", "#", id: "show-favlist-link", style: ("display: none;" if post.fav_count == 0) %>
<%= link_to "« Hide", "#", id: "hide-favlist-link", style: "display: none;" %>
<div id="favlist" style="display: none;"><%= post_favlist(post) %></div>
<% end %></li>
<li>