Create and show emoji loader on the fly.

This commit is contained in:
Fatih Acet 2016-05-30 20:04:08 +03:00 committed by Z.J. van de Weg
parent f1d74ccc8c
commit 63a5402182
2 changed files with 21 additions and 6 deletions

View file

@ -100,12 +100,13 @@ class @AwardsHandler
$menu.css(css)
addAward: (votesBlock, awardUrl, emoji, checkMutuality = yes) ->
addAward: (votesBlock, awardUrl, emoji, checkMutuality = yes, callback) ->
emoji = @normilizeEmojiName emoji
@postEmoji awardUrl, emoji, =>
@addAwardToEmojiBar votesBlock, emoji, checkMutuality
callback?()
$('.emoji-menu').removeClass 'is-visible'
@ -146,11 +147,24 @@ class @AwardsHandler
awardUrl = @getAwardUrl()
if emoji in [ 'thumbsup', 'thumbsdown' ]
mutualVote = if emoji is 'thumbsup' then 'thumbsdown' else 'thumbsup'
selector = "[data-emoji=#{mutualVote}]"
mutualVote = if emoji is 'thumbsup' then 'thumbsdown' else 'thumbsup'
$emojiButton = votesBlock.find("[data-emoji=#{mutualVote}]").parent()
isAlreadyVoted = $emojiButton.hasClass 'active'
isAlreadyVoted = votesBlock.find(selector).parent().hasClass 'active'
@addAward votesBlock, awardUrl, mutualVote, no if isAlreadyVoted
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'

View file

@ -109,7 +109,8 @@
}
&.is-loading {
.award-control-icon-normal {
.award-control-icon-normal,
.emoji-icon {
display: none;
}