diff --git a/app/javascript/src/javascripts/favorites.js b/app/javascript/src/javascripts/favorites.js
index ef6d2d44a..17b563566 100644
--- a/app/javascript/src/javascripts/favorites.js
+++ b/app/javascript/src/javascripts/favorites.js
@@ -3,30 +3,6 @@ import Utility from './utility'
let Favorite = {}
-Favorite.initialize_all = function() {
- if ($("#c-posts").length) {
- this.hide_or_show_add_to_favorites_link();
- }
-}
-
-Favorite.hide_or_show_add_to_favorites_link = function() {
- var current_user_id = Utility.meta("current-user-id");
- if (current_user_id === "") {
- $("#add-to-favorites").hide();
- $("#remove-from-favorites").hide();
- $("#add-fav-button").hide();
- $("#remove-fav-button").hide();
- return;
- }
- if ($("#image-container").length && $("#image-container").data("is-favorited") === true) {
- $("#add-to-favorites").hide();
- $("#add-fav-button").hide();
- } else {
- $("#remove-from-favorites").hide();
- $("#remove-fav-button").hide();
- }
-}
-
Favorite.create = function(post_id) {
Post.notice_update("inc");
@@ -57,9 +33,5 @@ Favorite.destroy = function(post_id) {
});
}
-$(document).ready(function() {
- Favorite.initialize_all();
-});
-
export default Favorite
diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb
index 1a646b189..59545f93b 100644
--- a/app/views/posts/partials/show/_options.html.erb
+++ b/app/views/posts/partials/show/_options.html.erb
@@ -2,8 +2,8 @@
<%= link_to "Resize to window", "#", :id => "image-resize-to-window-link" %>
<% if CurrentUser.is_member? %>
- <%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites", :"data-shortcut" => "f" %>
- <%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites", :"data-shortcut" => "shift+f" %>
+ <%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites", :"data-shortcut" => "f", style: ("display: none;" if @post.is_favorited?) %>
+ <%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites", :"data-shortcut" => "shift+f", style: ("display: none;" if !@post.is_favorited?) %>
<%= link_to_if post.visible?, "Download", post.tagged_file_url + "?download=1", download: post.presenter.filename_for_download %>
<%= link_to "Add to pool", "#", :id => "pool" %>
<% if post.is_note_locked? %>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb
index b6c02c7c8..d7576b106 100644
--- a/app/views/posts/show.html.erb
+++ b/app/views/posts/show.html.erb
@@ -48,10 +48,12 @@
<%= @post.presenter.image_html(self) %>
-
- <%= button_to "Favorite", favorites_path(post_id: @post.id), remote: true, method: :post, form: {id: "add-fav-button"}, class: "ui-button ui-widget ui-corner-all gradient", data: {disable_with: "Favoriting..."} %>
- <%= button_to "Unfavorite", favorite_path(@post), remote: true, method: :delete, form: {id: "remove-fav-button"}, class: "ui-button ui-widget ui-corner-all gradient", data: {disable_with: "Unfavoriting..."} %>
-
+ <% if CurrentUser.is_member? %>
+
+ <%= button_to "Favorite", favorites_path(post_id: @post.id), remote: true, method: :post, form: {id: "add-fav-button", style: ("display: none;" if @post.is_favorited?)}, class: "ui-button ui-widget ui-corner-all gradient", data: {disable_with: "Favoriting..."} %>
+ <%= button_to "Unfavorite", favorite_path(@post), remote: true, method: :delete, form: {id: "remove-fav-button", style: ("display: none;" if !@post.is_favorited?)}, class: "ui-button ui-widget ui-corner-all gradient", data: {disable_with: "Unfavoriting..."} %>
+
+ <% end %>
<%= form_tag(mark_as_translated_post_path(@post), :class => "simple_form", :method => :put) do |f| %>