Commit 1d7c3c79 authored by Fatih Acet's avatar Fatih Acet

Handle thumbsup and thumbsdown mutuality.

parent 5b046f85
......@@ -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
......
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