Commit 63a54021 authored by Fatih Acet's avatar Fatih Acet Committed by Z.J. van de Weg

Create and show emoji loader on the fly.

parent f1d74ccc
...@@ -100,12 +100,13 @@ class @AwardsHandler ...@@ -100,12 +100,13 @@ class @AwardsHandler
$menu.css(css) $menu.css(css)
addAward: (votesBlock, awardUrl, emoji, checkMutuality = yes) -> addAward: (votesBlock, awardUrl, emoji, checkMutuality = yes, callback) ->
emoji = @normilizeEmojiName emoji emoji = @normilizeEmojiName emoji
@postEmoji awardUrl, emoji, => @postEmoji awardUrl, emoji, =>
@addAwardToEmojiBar votesBlock, emoji, checkMutuality @addAwardToEmojiBar votesBlock, emoji, checkMutuality
callback?()
$('.emoji-menu').removeClass 'is-visible' $('.emoji-menu').removeClass 'is-visible'
...@@ -147,10 +148,23 @@ class @AwardsHandler ...@@ -147,10 +148,23 @@ class @AwardsHandler
if emoji in [ 'thumbsup', 'thumbsdown' ] if emoji in [ 'thumbsup', 'thumbsdown' ]
mutualVote = if emoji is 'thumbsup' then 'thumbsdown' else 'thumbsup' mutualVote = if emoji is 'thumbsup' then 'thumbsdown' else 'thumbsup'
selector = "[data-emoji=#{mutualVote}]" $emojiButton = votesBlock.find("[data-emoji=#{mutualVote}]").parent()
isAlreadyVoted = $emojiButton.hasClass 'active'
isAlreadyVoted = votesBlock.find(selector).parent().hasClass 'active' if isAlreadyVoted
@addAward votesBlock, awardUrl, mutualVote, no if isAlreadyVoted @showEmojiLoader $emojiButton
@addAward votesBlock, awardUrl, mutualVote, no, ->
$emojiButton.removeClass 'is-loading'
showEmojiLoader: ($emojiButton) ->
$loader = $emojiButton.find '.fa-spinner'
unless $loader.length
$emojiButton.append '<i class="fa fa-spinner fa-spin award-control-icon award-control-icon-loading"></i>'
$emojiButton.addClass 'is-loading'
isActive: ($emojiButton) -> $emojiButton.hasClass 'active' isActive: ($emojiButton) -> $emojiButton.hasClass 'active'
......
...@@ -109,7 +109,8 @@ ...@@ -109,7 +109,8 @@
} }
&.is-loading { &.is-loading {
.award-control-icon-normal { .award-control-icon-normal,
.emoji-icon {
display: none; display: none;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment