diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 022818608..1cb1197c7 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -18,6 +18,7 @@ if ($("#c-posts").length && $("#a-show").length) { this.initialize_links(); + this.initialize_favlist(); this.initialize_post_sections(); this.initialize_post_image_resize_links(); this.initialize_post_image_resize_to_window_link(); @@ -134,6 +135,25 @@ }); } + Danbooru.Post.initialize_favlist = function() { + $("#favlist").hide(); + $("#hide-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(); + e.preventDefault(); + }); + } + Danbooru.Post.initialize_titles = function() { $(".post-preview").each(function(i, v) { Danbooru.Post.initialize_title_for(v); diff --git a/app/views/favorites/_favorited_users_list.html.erb b/app/views/favorites/_favorited_users_list.html.erb index 5ac0ef596..dbbd57ea2 100644 --- a/app/views/favorites/_favorited_users_list.html.erb +++ b/app/views/favorites/_favorited_users_list.html.erb @@ -1 +1 @@ -
<%= post.favorited_users.reverse_each.map{|user| link_to_user(user)}.join(", ").html_safe %> \ No newline at end of file +<%= post.favorited_users.reverse_each.map{|user| link_to_user(user)}.join(", ").html_safe %> \ No newline at end of file diff --git a/app/views/favorites/list_favorited_users.js.erb b/app/views/favorites/list_favorited_users.js.erb index f6529cadb..e4268ad21 100644 --- a/app/views/favorites/list_favorited_users.js.erb +++ b/app/views/favorites/list_favorited_users.js.erb @@ -1 +1,3 @@ -$("span#favlist-for-post-<%= @post.id %>").html("<%= j(render(:partial => "favorites/favorited_users_list", :locals => { :post => @post }))%>"); \ No newline at end of file +$("#favlist").html("<%= j(render(:partial => "favorites/favorited_users_list", :locals => { :post => @post }))%>"); + +$("#show-favlist-link").attr("href", "#").removeAttr("data-remote"); diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index c95d411e6..bf01f250f 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -14,7 +14,12 @@
  • Source: <%= post_source_tag(post) %>
  • Rating: <%= post.pretty_rating %>
  • Score: <%= post.score %> <% if CurrentUser.is_privileged? %>(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_privileged? && post.fav_count > 0 %><%= link_to "»".html_safe, favorites_path(:post_id => post.id), :remote => true %><% end %>
  • +
  • Favorites: <%= post.fav_count %> + <% if CurrentUser.is_privileged? && post.fav_count > 0 %> + <%= link_to "»".html_safe, favorites_path(:post_id => post.id), :remote => true, :id => "show-favlist-link" %> + <%= link_to "«".html_safe, "#", :id => "hide-favlist-link" %> +
    + <% end %>
  • Status: <% if post.is_pending? %>