Create and show emoji loader on the fly.
This commit is contained in:
parent
f1d74ccc8c
commit
63a5402182
2 changed files with 21 additions and 6 deletions
|
@ -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'
|
||||||
|
|
||||||
|
@ -146,11 +147,24 @@ class @AwardsHandler
|
||||||
awardUrl = @getAwardUrl()
|
awardUrl = @getAwardUrl()
|
||||||
|
|
||||||
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 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-loading {
|
&.is-loading {
|
||||||
.award-control-icon-normal {
|
.award-control-icon-normal,
|
||||||
|
.emoji-icon {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue