diff --git a/app/assets/javascripts/favorites.js b/app/assets/javascripts/favorites.js index fb3703574..4a46a8bf2 100644 --- a/app/assets/javascripts/favorites.js +++ b/app/assets/javascripts/favorites.js @@ -13,13 +13,17 @@ if (current_user_id == "") { $("#add-to-favorites").hide(); $("#remove-from-favorites").hide(); + $("#add-fav-button").hide(); + $("#remove-fav-button").hide(); return; } var regexp = new RegExp("\\bfav:" + current_user_id + "\\b"); if ((favorites != undefined) && (favorites.match(regexp))) { $("#add-to-favorites").hide(); + $("#add-fav-button").hide(); } else { $("#remove-from-favorites").hide(); + $("#remove-fav-button").hide(); } } diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 304376a27..650a2d928 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -24,6 +24,7 @@ this.initialize_post_image_resize_to_window_link(); this.initialize_similar(); this.initialize_replace_image_dialog(); + this.initialize_fav_button(); if ((Danbooru.meta("always-resize-images") === "true") || ((Danbooru.Cookie.get("dm") != "1") && (window.innerWidth <= 660))) { $("#image-resize-to-window-link").click(); @@ -248,6 +249,9 @@ } } + Danbooru.Post.initialize_fav_button = function() { + } + Danbooru.Post.initialize_favlist = function() { $("#favlist").hide(); $("#hide-favlist-link").hide(); diff --git a/app/views/favorites/create.js.erb b/app/views/favorites/create.js.erb index 01958716b..2b7ad71e1 100644 --- a/app/views/favorites/create.js.erb +++ b/app/views/favorites/create.js.erb @@ -1,8 +1,10 @@ <% if @error_msg %> Danbooru.error("<%= @error_msg %>"); <% else %> - $("a#add-to-favorites").hide(); - $("a#remove-from-favorites").show(); + $("#add-to-favorites").hide(); + $("#add-fav-button").hide(); + $("#remove-from-favorites").show(); + $("#remove-fav-button").show(); $("#score-for-post-<%= @post.id %>").html(<%= @post.score %>); $("#favcount-for-post-<%= @post.id %>").html(<%= @post.fav_count %>); <% if CurrentUser.is_gold? %> diff --git a/app/views/favorites/destroy.js.erb b/app/views/favorites/destroy.js.erb index 47b6a8003..068e7cc24 100644 --- a/app/views/favorites/destroy.js.erb +++ b/app/views/favorites/destroy.js.erb @@ -1,5 +1,7 @@ -$("a#add-to-favorites").show(); -$("a#remove-from-favorites").hide(); +$("#add-to-favorites").show(); +$("#add-fav-button").show(); +$("#remove-from-favorites").hide(); +$("#remove-fav-button").hide(); $("#score-for-post-<%= @post.id %>").html(<%= @post.score %>); $("#favcount-for-post-<%= @post.id %>").html(<%= @post.fav_count %>); <% if CurrentUser.is_gold? %> diff --git a/app/views/posts/partials/show/_image.html.erb b/app/views/posts/partials/show/_image.html.erb index d94030a2f..0d7629b7a 100644 --- a/app/views/posts/partials/show/_image.html.erb +++ b/app/views/posts/partials/show/_image.html.erb @@ -1,4 +1,3 @@ <% if post.visible? %> <%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, :alt => post.presenter.humanized_essential_tag_string, "data-uploader" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-has-active-children" => post.has_active_children?, "data-score" => post.score, "data-fav-count" => post.fav_count, "itemprop" => "contentUrl") %> -
<%= post.presenter.humanized_essential_tag_string %>
<% end %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 48a633f96..e77db93b1 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -47,6 +47,8 @@ <%= @post.presenter.image_html(self) %> + <%= button_to "Favorite", favorites_path(post_id: @post.id), remote: true, method: :post, form: {id: "add-fav-button"} %> + <%= button_to "Unfavorite", favorite_path(@post), remote: true, method: :delete, form: {id: "remove-fav-button"} %>