From 035a0026cdb9ed58071969a7b6ba2ecd9425d083 Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Tue, 22 Jan 2019 15:07:36 -0800 Subject: [PATCH] fixes #4050 --- app/javascript/src/styles/specific/posts.scss | 18 +++++++++++++++++- app/views/favorites/_update.js.erb | 4 ++++ app/views/posts/show.html.erb | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/javascript/src/styles/specific/posts.scss b/app/javascript/src/styles/specific/posts.scss index 31c7c8afa..b29b73124 100644 --- a/app/javascript/src/styles/specific/posts.scss +++ b/app/javascript/src/styles/specific/posts.scss @@ -149,6 +149,18 @@ body[data-user-can-approve-posts="true"] .post-preview { color: red; } +@keyframes heartbeat { + 0% { + transform:scale(1); + } + 50% { + transform:scale(1.3); + } + 100% { + transform:scale(1); + } +} + div#c-posts { .fav-buttons { font-size: 14pt; @@ -163,10 +175,14 @@ div#c-posts { } } - #remove-fav-button i { + #remove-fav-button i.fa-heart { color: deeppink; } + #remove-fav-button.animate i { + animation: heartbeat 0.4s ease; + } + .fav-buttons-true #add-fav-button { display: none; } diff --git a/app/views/favorites/_update.js.erb b/app/views/favorites/_update.js.erb index 2f8475eb4..86f1c5bd1 100644 --- a/app/views/favorites/_update.js.erb +++ b/app/views/favorites/_update.js.erb @@ -1,4 +1,8 @@ $("#add-to-favorites, #add-fav-button, #remove-from-favorites, #remove-fav-button").toggle(); +$("#remove-fav-button").addClass("animate"); +$.timeout(30000, function() { + $("#remove-fav-button").removeClass("animate"); +}); $("#score-for-post-<%= @post.id %>").text(<%= @post.score %>); $("#favcount-for-post-<%= @post.id %>").text(<%= @post.fav_count %>); $(".fav-buttons").toggleClass("fav-buttons-false").toggleClass("fav-buttons-true"); diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 9314da41f..7c8a0b96c 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -56,11 +56,11 @@ <% if CurrentUser.is_member? %> <%= content_tag(:div, class: "fav-buttons fav-buttons-#{@post.is_favorited?}") do %> <%= form_tag(favorites_path(post_id: @post.id), method: "post", id: "add-fav-button", "data-remote": true) do %> - <%= button_tag tag.i(class: "far fa-heart"), class: "ui-button ui-widget ui-corner-all gradient", "data-disable-with": "..." %> + <%= button_tag tag.i(class: "far fa-heart"), class: "ui-button ui-widget ui-corner-all gradient", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %> <% end %> <%= form_tag(favorite_path(@post.id), method: "delete", id: "remove-fav-button", "data-remote": true) do %> - <%= button_tag tag.i(class: "fas fa-heart"), class: "ui-button ui-widget ui-corner-all gradient", "data-disable-with": "..." %> + <%= button_tag tag.i(class: "fas fa-heart"), class: "ui-button ui-widget ui-corner-all gradient", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %> <% end %> <% end %> <% end %>