diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-05-24 03:10:38 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-05-24 03:10:38 +0300 |
commit | 1d7c3c79b1060e62ee1aa8a0e173334bb9180706 (patch) | |
tree | b8530ec7cd78c4602cd35572dfeb2ec1e0bbb82c | |
parent | 5b046f8571ba360ec7b87d01db7b0933ab4388bf (diff) | |
download | gitlab-ce-1d7c3c79b1060e62ee1aa8a0e173334bb9180706.tar.gz |
Handle thumbsup and thumbsdown mutuality.
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 0ab3796118e..7235ec57851 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -24,6 +24,7 @@ class @AwardsHandler handleClick: (e) => e.preventDefault() + $emojiBtn = $(e.currentTarget) $addAwardBtn = $('.js-add-award.is-active') $votesBlock = $($addAwardBtn.closest('.js-award-holder').data('target')) @@ -36,6 +37,13 @@ class @AwardsHandler $votesBlock.addClass 'js-awards-block' awardUrl = $votesBlock.data 'award-url' emoji = $emojiBtn.find('.icon').data('emoji') + + if emoji in [ 'thumbsup', 'thumbsdown' ] + mutualVote = if emoji is 'thumbsup' then 'thumbsdown' else 'thumbsup' + + isAlreadyVoted = $("[data-emoji=#{mutualVote}]").parent().hasClass 'active' + @addAward awardUrl, mutualVote if isAlreadyVoted + @addAward awardUrl, emoji |