diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-11-18 23:59:58 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-11-19 01:26:00 +0200 |
commit | 23df515fd09661a690c0c0a651e131bc3a6d0191 (patch) | |
tree | a8583bef6f0c96c3c99d8b141d00a5638035b008 | |
parent | d8676f18fcbd6b78af472b8b00c29f20820a74a9 (diff) | |
download | gitlab-ce-23df515fd09661a690c0c0a651e131bc3a6d0191.tar.gz |
Emoji: fix image of emoji when it is submitted via comment
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 16 | ||||
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 2 | ||||
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 1 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 2 | ||||
-rw-r--r-- | app/views/votes/_votes_block.html.haml | 1 | ||||
-rw-r--r-- | lib/award_emoji.rb | 4 |
6 files changed, 17 insertions, 9 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 29b11b0cc58..cac9c10332a 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -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,8 +71,12 @@ class @AwardsHandler $(".award").tooltip() - getImage: (emoji) -> - $("li[data-emoji='" + emoji + "'").html() + 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, { diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 73a95c455e8..7de7632201d 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -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 diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 357b292980d..98bf056a605 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -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) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index bca32322096..bf289c6db14 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -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 diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml index afd1c2745a1..5392915b4dd 100644 --- a/app/views/votes/_votes_block.html.haml +++ b/app/views/votes/_votes_block.html.haml @@ -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}" diff --git a/lib/award_emoji.rb b/lib/award_emoji.rb index 95b9c8f921a..9e296f0bc3c 100644 --- a/lib/award_emoji.rb +++ b/lib/award_emoji.rb @@ -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 |