diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-05-24 03:44:19 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-05-24 03:44:19 +0300 |
commit | c697c9601d921b841fe791c4ea96a68aa6de0001 (patch) | |
tree | a27f01ac11ecc470048bf5c9b21bdf84c2e1215c /app/assets/javascripts/awards_handler.coffee | |
parent | 1d7c3c79b1060e62ee1aa8a0e173334bb9180706 (diff) |
Fix award tooltip after voting.
Diffstat (limited to 'app/assets/javascripts/awards_handler.coffee')
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 7235ec57851..e535bd525b8 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -156,26 +156,46 @@ class @AwardsHandler $emojiBtn.removeClass("active") + + getAwardTooltip: ($awardBlock) -> + + return $awardBlock.attr('data-original-title') or $awardBlock.attr('data-title') + + removeMeFromUserList: ($emojiBtn, emoji) -> - award_block = $emojiBtn - authors = award_block - .attr("data-original-title") - .split(", ") - authors.splice(authors.indexOf("me"),1) - award_block - .closest(".js-emoji-btn") - .attr("data-original-title", authors.join(", ")) - @resetTooltip(award_block) + + awardBlock = $emojiBtn + originalTitle = @getAwardTooltip awardBlock + + authors = originalTitle.split ', ' + authors.splice authors.indexOf('me'), 1 + + newAuthors = authors.join ', ' + + awardBlock + .closest '.js-emoji-btn' + .removeData 'original-title' + .removeData 'title' + .attr 'data-original-title', newAuthors + .attr 'data-title', newAuthors + + @resetTooltip(awardBlock) + addMeToUserList: (emoji) -> - award_block = @findEmojiIcon(emoji).parent() - origTitle = award_block.attr("data-original-title").trim() - users = [] + + awardBlock = @findEmojiIcon(emoji).parent() + origTitle = @getAwardTooltip awardBlock + users = [] + if origTitle - users = origTitle.split(', ') - users.push("me") - award_block.attr("title", users.join(", ")) - @resetTooltip(award_block) + users = origTitle.trim().split(', ') + + users.push('me') + awardBlock.attr('title', users.join(", ")) + + @resetTooltip(awardBlock) + resetTooltip: (award) -> award.tooltip("destroy") |