diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-12-24 12:28:51 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-12-24 12:28:55 +0300 |
commit | b6de0d28303a12c76847f1137e672aa60ae174ac (patch) | |
tree | 11ff97f14046b8d6445a6695fea00ab7c3e158e2 /app | |
parent | 2803b6e84e94bb3a8d85ea9e29aeade450c842a7 (diff) |
Emoji picker: better alias handling
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 16 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 3 | ||||
-rw-r--r-- | app/views/votes/_votes_block.html.haml | 4 |
3 files changed, 15 insertions, 8 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 84e7287e48d..b5432773713 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -76,7 +76,7 @@ class @AwardsHandler nodes = [] nodes.push("<div class='award active' title='me'>") - nodes.push("<div class='icon emoji-icon " + emojiCssClass + "' data-emoji='" + emoji + "'></div>") + nodes.push("<div class='icon emoji-icon #{emojiCssClass}' data-emoji='#{emoji}'></div>") nodes.push("<div class='counter'>1</div>") nodes.push("</div>") @@ -85,13 +85,19 @@ class @AwardsHandler $(".award").tooltip() resolveNameToCssClass: (emoji) -> - unicodeName = $(".emoji-menu-content [data-emoji='?']".replace("?", emoji)).data("unicode-name") + emoji_icon = $(".emoji-menu-content [data-emoji='#{emoji}']") - "emoji-" + unicodeName + 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}" postEmoji: (emoji, callback) -> $.post @post_emoji_url, { note: { - note: ":" + emoji + ":" + note: ":#{emoji}:" noteable_type: @noteable_type noteable_id: @noteable_id }},(data) -> @@ -99,7 +105,7 @@ class @AwardsHandler callback.call() findEmojiIcon: (emoji) -> - $(".award [data-emoji='" + emoji + "']") + $(".award [data-emoji='#{emoji}']") scrollToAwards: -> $('body, html').animate({ diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 2bcde9c2ba3..4fe84322199 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -94,12 +94,13 @@ module IssuesHelper end.sort.to_sentence(last_word_connector: ', or ') end - def emoji_icon(name, unicode = nil) + def emoji_icon(name, unicode = nil, aliases = []) unicode ||= Emoji.emoji_filename(name) content_tag :div, "", class: "icon emoji-icon emoji-#{unicode}", "data-emoji" => name, + "data-aliases" => aliases.join(" "), "data-unicode-name" => unicode end diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml index 8c660ba16cc..829f1664fba 100644 --- a/app/views/votes/_votes_block.html.haml +++ b/app/views/votes/_votes_block.html.haml @@ -16,14 +16,14 @@ %ul - emojis.each do |emoji| %li - = emoji_icon(emoji["name"], emoji["unicode"]) + = emoji_icon(emoji["name"], emoji["unicode"], emoji["aliases"]) - if current_user :coffeescript post_emoji_url = "#{award_toggle_namespace_project_notes_path(@project.namespace, @project)}" noteable_type = "#{votable.class.name.underscore}" noteable_id = "#{votable.id}" - aliases = #{AwardEmoji::ALIASES.to_json} + aliases = #{AwardEmoji.aliases.to_json} window.awards_handler = new AwardsHandler( post_emoji_url, |