Commit f021bc5c authored by Valery Sizov's avatar Valery Sizov Committed by Valery Sizov

add stats on hover

parent 36d0442e
...@@ -13,6 +13,7 @@ class @AwardsHandler ...@@ -13,6 +13,7 @@ class @AwardsHandler
counter = @findEmojiIcon(emoji).siblings(".counter") counter = @findEmojiIcon(emoji).siblings(".counter")
counter.text(parseInt(counter.text()) + 1) counter.text(parseInt(counter.text()) + 1)
counter.parent().addClass("active") counter.parent().addClass("active")
@addMeToAuthorList(emoji)
else else
@createEmoji(emoji) @createEmoji(emoji)
...@@ -28,13 +29,38 @@ class @AwardsHandler ...@@ -28,13 +29,38 @@ class @AwardsHandler
if parseInt(counter.text()) > 1 if parseInt(counter.text()) > 1
counter.text(parseInt(counter.text()) - 1) counter.text(parseInt(counter.text()) - 1)
counter.parent().removeClass("active") counter.parent().removeClass("active")
@removeMeFromAuthorList(emoji)
else 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) -> createEmoji: (emoji) ->
nodes = [] 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("<div class='icon' data-emoji='" + emoji + "'>")
nodes.push(@getImage(emoji)) nodes.push(@getImage(emoji))
nodes.push("</div>") nodes.push("</div>")
...@@ -43,6 +69,8 @@ class @AwardsHandler ...@@ -43,6 +69,8 @@ class @AwardsHandler
$(".awards-controls").before(nodes.join("\n")) $(".awards-controls").before(nodes.join("\n"))
$(".award").tooltip()
getImage: (emoji) -> getImage: (emoji) ->
$("li[data-emoji='" + emoji + "'").html() $("li[data-emoji='" + emoji + "'").html()
......
...@@ -92,6 +92,14 @@ module IssuesHelper ...@@ -92,6 +92,14 @@ module IssuesHelper
url_to_image(emoji_path) url_to_image(emoji_path)
end 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 # Required for Gitlab::Markdown::IssueReferenceFilter
module_function :url_for_issue module_function :url_for_issue
end end
.awards.votes-block .awards.votes-block
- votable.notes.awards.grouped_awards.each do | vote | - 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}"} .icon{"data-emoji" => "#{vote.first}"}
= image_tag url_to_emoji(vote.first), height: "20px", width: "20px" = image_tag url_to_emoji(vote.first), height: "20px", width: "20px"
.counter .counter
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
emoji = $(this).find(".icon").data("emoji") emoji = $(this).find(".icon").data("emoji")
awards_handler.addAward(emoji) awards_handler.addAward(emoji)
$(".award").tooltip()
\ No newline at end of file
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