summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-12-24 15:58:32 +0000
committerValery Sizov <valery@gitlab.com>2015-12-24 15:58:32 +0000
commite1a47bd1232a1463b8d5d95b8fd624bb969f7de7 (patch)
treed68c3267281664faba516ca5833f4dba158431d3 /app
parent1a23af485cd755738f4051e04132b1eb93fc3fab (diff)
parent355e62eb498de90f91ac129af94d4a0f2ec6b129 (diff)
downloadgitlab-ce-e1a47bd1232a1463b8d5d95b8fd624bb969f7de7.tar.gz
Merge branch 'emoji_picker_frequently_used' into 'master'
Emoji picker: add "frequently used" category depend on !2172 ![Screen_Shot_2015-12-24_at_16.39.04](/uploads/7117173c6f519282054bcb1b7ba248f4/Screen_Shot_2015-12-24_at_16.39.04.png) See merge request !2180
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/awards_handler.coffee28
1 files changed, 27 insertions, 1 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee
index 392440a2b00..04bf5cc7bb5 100644
--- a/app/assets/javascripts/awards_handler.coffee
+++ b/app/assets/javascripts/awards_handler.coffee
@@ -10,6 +10,7 @@ class @AwardsHandler
if $(".emoji-menu").is(":visible")
$(".emoji-menu").hide()
+ @renderFrequentlyUsedBlock()
@setupSearch()
addAward: (emoji) ->
@@ -20,6 +21,8 @@ class @AwardsHandler
$(".emoji-menu").hide()
addAwardToEmojiBar: (emoji) ->
+ @addEmojiToFrequentlyUsedList(emoji)
+
emoji = @normilizeEmojiName(emoji)
if @exist(emoji)
if @isActive(emoji)
@@ -117,6 +120,29 @@ class @AwardsHandler
normilizeEmojiName: (emoji) ->
@aliases[emoji] || emoji
+ addEmojiToFrequentlyUsedList: (emoji) ->
+ frequently_used_emojis = @getFrequentlyUsedEmojis()
+ frequently_used_emojis.push(emoji)
+ $.cookie('frequently_used_emojis', frequently_used_emojis.join(","), { expires: 365 })
+
+ getFrequentlyUsedEmojis: ->
+ frequently_used_emojis = ($.cookie('frequently_used_emojis') || "").split(",")
+
+ frequently_used_emojis = ["thumbsup", "thumbsdown"].concat(frequently_used_emojis)
+
+ _.compact(_.uniq(frequently_used_emojis))
+
+ renderFrequentlyUsedBlock: ->
+ frequently_used_emojis = @getFrequentlyUsedEmojis()
+
+ ul = $("<ul>")
+
+ for emoji in frequently_used_emojis
+ do (emoji) ->
+ $(".emoji-menu-content [data-emoji='#{emoji}']").closest("li").clone().appendTo(ul)
+
+ $("input.emoji-search").after(ul).after($("<h5>").text("Frequently used"))
+
setupSearch: ->
$("input.emoji-search").keyup (ev) =>
term = $(ev.target).val()
@@ -125,7 +151,7 @@ class @AwardsHandler
$("ul.emoji-search,h5.emoji-search").remove()
if term
- # Generate search result block
+ # Generate a search result block
h5 = $("<h5>").text("Search results").addClass("emoji-search")
found_emojis = @searchEmojis(term).show()
ul = $("<ul>").addClass("emoji-search").append(found_emojis)