Skip to content
Snippets Groups Projects
Commit 1edd1e80 authored by Valery Sizov's avatar Valery Sizov Committed by Rubén Dávila
Browse files

add stats on hover

parent 27b78480
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -13,6 +13,7 @@ class @AwardsHandler
counter = @findEmojiIcon(emoji).siblings(".counter")
counter.text(parseInt(counter.text()) + 1)
counter.parent().addClass("active")
@addMeToAuthorList(emoji)
else
@createEmoji(emoji)
 
Loading
Loading
@@ -28,13 +29,38 @@ class @AwardsHandler
if parseInt(counter.text()) > 1
counter.text(parseInt(counter.text()) - 1)
counter.parent().removeClass("active")
@removeMeFromAuthorList(emoji)
else
counter.parent().remove()
award = counter.parent()
award.tooltip("destroy")
award.remove()
 
removeMeFromAuthorList: (emoji) ->
award_block = @findEmojiIcon(emoji).parent()
authors = award_block.attr("data-original-title").split(", ")
authors = _.without(authors, "me").join(", ")
award_block.attr("title", authors)
@resetTooltip(award_block)
addMeToAuthorList: (emoji) ->
award_block = @findEmojiIcon(emoji).parent()
authors = award_block.attr("data-original-title").split(", ")
authors.push("me")
award_block.attr("title", authors.join(", "))
@resetTooltip(award_block)
resetTooltip: (award) ->
award.tooltip("destroy")
# "destroy" call is asynchronous, this is why we need to set timeout.
setTimeout (->
award.tooltip()
), 200
 
createEmoji: (emoji) ->
nodes = []
nodes.push("<div class='award active'>")
nodes.push("<div class='award active' title='me'>")
nodes.push("<div class='icon' data-emoji='" + emoji + "'>")
nodes.push(@getImage(emoji))
nodes.push("</div>")
Loading
Loading
@@ -43,6 +69,8 @@ class @AwardsHandler
 
$(".awards-controls").before(nodes.join("\n"))
 
$(".award").tooltip()
getImage: (emoji) ->
$("li[data-emoji='" + emoji + "'").html()
 
Loading
Loading
Loading
Loading
@@ -92,6 +92,14 @@ module IssuesHelper
url_to_image(emoji_path)
end
 
def emoji_author_list(notes, current_user)
list = notes.map do |note|
note.author == current_user ? "me" : note.author.username
end
list.join(", ")
end
# Required for Gitlab::Markdown::IssueReferenceFilter
module_function :url_for_issue
end
.awards.votes-block
- votable.notes.awards.grouped_awards.each do | vote |
.award{class: ("active" if vote.last.pluck(:author_id).include?(current_user.id))}
.award{class: ("active" if vote.last.pluck(:author_id).include?(current_user.id)), title: emoji_author_list(vote.last, current_user)}
.icon{"data-emoji" => "#{vote.first}"}
= image_tag url_to_emoji(vote.first), height: "20px", width: "20px"
.counter
Loading
Loading
@@ -28,6 +28,8 @@
emoji = $(this).find(".icon").data("emoji")
awards_handler.addAward(emoji)
 
$(".award").tooltip()
 
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment