diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 980ddd049..fef5bd3bb 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -170,6 +170,10 @@ Danbooru.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(); diff --git a/app/views/favorites/create.js.erb b/app/views/favorites/create.js.erb index 6a0cc2912..01958716b 100644 --- a/app/views/favorites/create.js.erb +++ b/app/views/favorites/create.js.erb @@ -5,5 +5,11 @@ $("a#remove-from-favorites").show(); $("#score-for-post-<%= @post.id %>").html(<%= @post.score %>); $("#favcount-for-post-<%= @post.id %>").html(<%= @post.fav_count %>); + <% if CurrentUser.is_gold? %> + $("#favlist").html("<%= escape_javascript(post_favlist(@post)) %>"); + if (!$("#favlist").is(":visible")) { + $("#show-favlist-link").show(); + } + <% end %> Danbooru.notice("You have favorited this post"); <% end %> diff --git a/app/views/favorites/destroy.js.erb b/app/views/favorites/destroy.js.erb index 2ece21748..47b6a8003 100644 --- a/app/views/favorites/destroy.js.erb +++ b/app/views/favorites/destroy.js.erb @@ -2,4 +2,10 @@ $("a#add-to-favorites").show(); $("a#remove-from-favorites").hide(); $("#score-for-post-<%= @post.id %>").html(<%= @post.score %>); $("#favcount-for-post-<%= @post.id %>").html(<%= @post.fav_count %>); +<% if CurrentUser.is_gold? %> + $("#favlist").html("<%= escape_javascript(post_favlist(@post)) %>"); + <% if @post.fav_count == 0 %> + $("#show-favlist-link, #hide-favlist-link, #favlist").hide(); + <% end %> +<% end %> Danbooru.notice("You have unfavorited this post"); diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index 957e6c3e2..df06402a1 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -15,7 +15,7 @@
  • Rating: <%= post.pretty_rating %>
  • Score: <%= post.score %> <% if CurrentUser.is_gold? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %>
  • Favorites: <%= post.fav_count %> - <% if CurrentUser.is_gold? && post.fav_count > 0 %> + <% if CurrentUser.is_gold? %> <%= link_to "»".html_safe, "#", :id => "show-favlist-link" %> <%= link_to "«".html_safe, "#", :id => "hide-favlist-link" %>
    <%= post_favlist(post) %>