diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index 71e853e3b..388e3e21e 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -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(); }); } diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index b7013146a..4eff6d98c 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -22,8 +22,8 @@
  • Score: <%= post.score %> <% if CurrentUser.is_voter? %>(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 %><%= link_to "undo vote", post_votes_path(post), :remote => true, :method => :delete, :id => "unvote-link-for-post-#{post.id}", :class => "unvote-post-link" %>)<% end %>
  • Favorites: <%= post.fav_count %> <% if CurrentUser.is_gold? %> - <%= link_to "Show »".html_safe, "#", :id => "show-favlist-link" %> - <%= link_to "« 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;" %> <% end %>