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