summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJacob Schatz <jschatz1@gmail.com>2016-04-01 13:59:08 +0000
committerJacob Schatz <jschatz1@gmail.com>2016-04-01 13:59:08 +0000
commite3f0bef5ee8ece2e949239c5c43a30477431681b (patch)
treecdcdcc6ad7be4a715f1a83e87dbcf7b7eebc77f6 /app
parent71d0ef5bd7df917f02ec22616e3699b32f31da7e (diff)
parentb676cc31f763a4ea496ff206ed6cd6576cbbe0e9 (diff)
downloadgitlab-ce-e3f0bef5ee8ece2e949239c5c43a30477431681b.tar.gz
Merge branch 'users_should_not_be_able_upvote_downvote' into 'master'
Prevent users from being able to both upvote and downvote closes #14480 ![thumbs](/uploads/d0d64f08dbf271fe969b44c68f424123/thumbs.gif) See merge request !3406
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/awards_handler.coffee15
-rw-r--r--app/views/votes/_votes_block.html.haml2
2 files changed, 14 insertions, 3 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index 47b080406d4..e7ed4605c2c 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -22,8 +22,19 @@ class @AwardsHandler
emoji = $(this)
.find(".icon")
.data "emoji"
+
+ if emoji is "thumbsup" and awards_handler.didUserClickEmoji $(this), "thumbsdown"
+ awards_handler.decrementCounter "thumbsdown"
+
+ else if emoji is "thumbsdown" and awards_handler.didUserClickEmoji $(this), "thumbsup"
+ awards_handler.decrementCounter "thumbsup"
+
awards_handler.addAward emoji
+ didUserClickEmoji: (that, emoji) ->
+ if $(that).siblings("button:has([data-emoji=#{emoji}])").attr("data-original-title")
+ $(that).siblings("button:has([data-emoji=#{emoji}])").attr("data-original-title").indexOf('me') > -1
+
showEmojiMenu: ->
if $(".emoji-menu").length
if $(".emoji-menu").is ".is-visible"
@@ -105,7 +116,7 @@ class @AwardsHandler
if origTitle
authors = origTitle.split(', ')
authors.push("me")
- award_block.attr("title", authors.join(", "))
+ award_block.attr("data-original-title", authors.join(", "))
@resetTooltip(award_block)
resetTooltip: (award) ->
@@ -122,7 +133,7 @@ class @AwardsHandler
nodes = []
nodes.push(
- "<button class='btn award-control js-emoji-btn has-tooltip active' title='me'>",
+ "<button class='btn award-control js-emoji-btn has-tooltip active' data-original-title='me'>",
"<div class='icon emoji-icon #{emojiCssClass}' data-emoji='#{emoji}'></div>",
"<span class='award-control-text js-counter'>1</span>",
"</button>"
diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml
index 02647229776..06023f2b2d2 100644
--- a/app/views/votes/_votes_block.html.haml
+++ b/app/views/votes/_votes_block.html.haml
@@ -1,6 +1,6 @@
.awards.votes-block
- awards_sort(votable.notes.awards.grouped_awards).each do |emoji, notes|
- %button.btn.award-control.js-emoji-btn.has-tooltip{class: (note_active_class(notes, current_user)), title: emoji_author_list(notes, current_user), data: {placement: "top"}}
+ %button.btn.award-control.js-emoji-btn.has-tooltip{class: (note_active_class(notes, current_user)), data: {placement: "top", original_title: emoji_author_list(notes, current_user)}}
= emoji_icon(emoji)
%span.award-control-text.js-counter
= notes.count