summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-04-25 20:04:35 +0000
committerJacob Schatz <jschatz@gitlab.com>2016-04-25 20:04:35 +0000
commit8fc0eed357342a887bdd80fffdf480a83d9fd65f (patch)
treea1db3222a60a93294872447cfefd8e5517a8295c
parent3d115d6748aff3888819b1bb4641e805a2ecd38b (diff)
parent13f7ba059e48ebf090d8f8ae440f277097494c52 (diff)
downloadgitlab-ce-8fc0eed357342a887bdd80fffdf480a83d9fd65f.tar.gz
Merge branch 'emoji-unicode-fix' into 'master'
Fixes issue with emoji comments not showing correct emoji image Previously it would look for the unicode character inside the award menu. But this menu might not always be there. Now, the unicode characters are loaded onto the page in an array which the award emoji that looks in to get the correct emoji unicode character Fixes #15512 See merge request !3885
-rw-r--r--app/assets/javascripts/awards_handler.coffee17
-rw-r--r--app/views/votes/_votes_block.html.haml4
-rw-r--r--lib/award_emoji.rb4
3 files changed, 8 insertions, 17 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index dcdf27d7bc0..fcba9818726 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -1,5 +1,5 @@
class @AwardsHandler
- constructor: (@get_emojis_url, @post_emoji_url, @noteable_type, @noteable_id, @aliases) ->
+ constructor: (@get_emojis_url, @post_emoji_url, @noteable_type, @noteable_id, @unicodes) ->
$(".js-add-award").on "click", (event) =>
event.stopPropagation()
event.preventDefault()
@@ -57,7 +57,6 @@ class @AwardsHandler
, 200
addAward: (emoji) ->
- emoji = @normilizeEmojiName(emoji)
@postEmoji emoji, =>
@addAwardToEmojiBar(emoji)
@@ -66,7 +65,6 @@ class @AwardsHandler
addAwardToEmojiBar: (emoji) ->
@addEmojiToFrequentlyUsedList(emoji)
- emoji = @normilizeEmojiName(emoji)
if @exist(emoji)
if @isActive(emoji)
@decrementCounter(emoji)
@@ -148,15 +146,7 @@ class @AwardsHandler
$('.award-control').tooltip()
resolveNameToCssClass: (emoji) ->
- emoji_icon = $(".emoji-menu-content [data-emoji='#{emoji}']")
-
- if emoji_icon.length > 0
- unicodeName = emoji_icon.data("unicode-name")
- else
- # Find by alias
- unicodeName = $(".emoji-menu-content [data-aliases*=':#{emoji}:']").data("unicode-name")
-
- "emoji-#{unicodeName}"
+ "emoji-#{@unicodes[emoji]}"
postEmoji: (emoji, callback) ->
$.post @post_emoji_url, { note: {
@@ -175,9 +165,6 @@ class @AwardsHandler
scrollTop: $('.awards').offset().top - 80
}, 200)
- normilizeEmojiName: (emoji) ->
- @aliases[emoji] || emoji
-
addEmojiToFrequentlyUsedList: (emoji) ->
frequently_used_emojis = @getFrequentlyUsedEmojis()
frequently_used_emojis.push(emoji)
diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml
index dc249155b92..59e12798691 100644
--- a/app/views/votes/_votes_block.html.haml
+++ b/app/views/votes/_votes_block.html.haml
@@ -19,12 +19,12 @@
var post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}";
var noteable_type = "#{votable.class.name.underscore}";
var noteable_id = "#{votable.id}";
- var aliases = #{AwardEmoji.aliases.to_json};
+ var unicodes = #{AwardEmoji.unicode.to_json};
window.awards_handler = new AwardsHandler(
get_emojis_url,
post_emoji_url,
noteable_type,
noteable_id,
- aliases
+ unicodes
);
diff --git a/lib/award_emoji.rb b/lib/award_emoji.rb
index 5f8ff01b0a9..b1aecc2e671 100644
--- a/lib/award_emoji.rb
+++ b/lib/award_emoji.rb
@@ -52,6 +52,10 @@ class AwardEmoji
end
end
+ def self.unicode
+ @unicode ||= emojis.map {|key, value| { key => emojis[key]["unicode"] } }.inject(:merge!)
+ end
+
def self.aliases
@aliases ||= begin
json_path = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json' )