Commit 23df515f authored by Valery Sizov's avatar Valery Sizov

Emoji: fix image of emoji when it is submitted via comment

parent d8676f18
...@@ -5,7 +5,7 @@ class @AwardsHandler ...@@ -5,7 +5,7 @@ class @AwardsHandler
@postEmoji emoji, => @postEmoji emoji, =>
@addAwardToEmojiBar(emoji) @addAwardToEmojiBar(emoji)
addAwardToEmojiBar: (emoji) -> addAwardToEmojiBar: (emoji, custom_path = '') ->
if @exist(emoji) if @exist(emoji)
if @isActive(emoji) if @isActive(emoji)
@decrementCounter(emoji) @decrementCounter(emoji)
...@@ -15,7 +15,7 @@ class @AwardsHandler ...@@ -15,7 +15,7 @@ class @AwardsHandler
counter.parent().addClass("active") counter.parent().addClass("active")
@addMeToAuthorList(emoji) @addMeToAuthorList(emoji)
else else
@createEmoji(emoji) @createEmoji(emoji, custom_path)
exist: (emoji) -> exist: (emoji) ->
@findEmojiIcon(emoji).length > 0 @findEmojiIcon(emoji).length > 0
...@@ -58,11 +58,11 @@ class @AwardsHandler ...@@ -58,11 +58,11 @@ class @AwardsHandler
), 200 ), 200
createEmoji: (emoji) -> createEmoji: (emoji, custom_path) ->
nodes = [] nodes = []
nodes.push("<div class='award active' title='me'>") 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, custom_path))
nodes.push("</div>") nodes.push("</div>")
nodes.push("<div class='counter'>1") nodes.push("<div class='counter'>1")
nodes.push("</div></div>") nodes.push("</div></div>")
...@@ -71,9 +71,13 @@ class @AwardsHandler ...@@ -71,9 +71,13 @@ class @AwardsHandler
$(".award").tooltip() $(".award").tooltip()
getImage: (emoji) -> getImage: (emoji, custom_path) ->
if custom_path
$(".awards-menu li").first().html().replace(/emoji\/.*\.png/, custom_path)
else
$("li[data-emoji='" + emoji + "'").html() $("li[data-emoji='" + emoji + "'").html()
postEmoji: (emoji, callback) -> postEmoji: (emoji, callback) ->
$.post @post_emoji_url, { $.post @post_emoji_url, {
emoji: emoji emoji: emoji
......
...@@ -121,7 +121,7 @@ class @Notes ...@@ -121,7 +121,7 @@ class @Notes
@initTaskList() @initTaskList()
if note.award if note.award
awards_handler.addAwardToEmojiBar(note.note) awards_handler.addAwardToEmojiBar(note.note, note.emoji_path)
### ###
Check if note does not exists on page Check if note does not exists on page
......
...@@ -133,6 +133,7 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -133,6 +133,7 @@ class Projects::NotesController < Projects::ApplicationController
discussion_id: note.discussion_id, discussion_id: note.discussion_id,
html: note_to_html(note), html: note_to_html(note),
award: note.is_award, award: note.is_award,
emoji_path: note.is_award ? ::AwardEmoji.path_to_emoji_image(note.note) : "",
note: note.note, note: note.note,
discussion_html: note_to_discussion_html(note), discussion_html: note_to_discussion_html(note),
discussion_with_diff_html: note_to_discussion_with_diff_html(note) discussion_with_diff_html: note_to_discussion_with_diff_html(note)
......
...@@ -88,7 +88,7 @@ module IssuesHelper ...@@ -88,7 +88,7 @@ module IssuesHelper
end end
def url_to_emoji(name) def url_to_emoji(name)
emoji_path = "emoji/#{Emoji.emoji_filename(name)}.png" emoji_path = ::AwardEmoji.path_to_emoji_image(name)
url_to_image(emoji_path) url_to_image(emoji_path)
end end
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
- emoji_list.each do |emoji| - emoji_list.each do |emoji|
%li{"data-emoji" => "#{emoji}"}= image_tag url_to_emoji(emoji), height: "20px", width: "20px" %li{"data-emoji" => "#{emoji}"}= image_tag url_to_emoji(emoji), height: "20px", width: "20px"
:coffeescript :coffeescript
post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}" post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}"
noteable_type = "#{votable.class}" noteable_type = "#{votable.class}"
......
...@@ -3,4 +3,8 @@ class AwardEmoji ...@@ -3,4 +3,8 @@ class AwardEmoji
"beers", "disappointed", "ok_hand", "beers", "disappointed", "ok_hand",
"helicopter", "shit", "airplane", "alarm_clock", "helicopter", "shit", "airplane", "alarm_clock",
"ambulance", "anguished", "two_hearts", "wink"] "ambulance", "anguished", "two_hearts", "wink"]
def self.path_to_emoji_image(name)
"emoji/#{Emoji.emoji_filename(name)}.png"
end
end end
\ 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