Commit e1a47bd1 authored by Valery Sizov's avatar Valery Sizov

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
parents 1a23af48 355e62eb
...@@ -5,6 +5,8 @@ v 8.4.0 (unreleased) ...@@ -5,6 +5,8 @@ v 8.4.0 (unreleased)
- Implement new UI for group page - Implement new UI for group page
- Implement search inside emoji picker - Implement search inside emoji picker
- Add project permissions to all project API endpoints (Stan Hu) - Add project permissions to all project API endpoints (Stan Hu)
- Add "Frequently used" category to emoji picker
v 8.3.1 (unreleased) v 8.3.1 (unreleased)
- Fix Error 500 when global milestones have slashes (Stan Hu) - Fix Error 500 when global milestones have slashes (Stan Hu)
......
...@@ -10,6 +10,7 @@ class @AwardsHandler ...@@ -10,6 +10,7 @@ class @AwardsHandler
if $(".emoji-menu").is(":visible") if $(".emoji-menu").is(":visible")
$(".emoji-menu").hide() $(".emoji-menu").hide()
@renderFrequentlyUsedBlock()
@setupSearch() @setupSearch()
addAward: (emoji) -> addAward: (emoji) ->
...@@ -20,6 +21,8 @@ class @AwardsHandler ...@@ -20,6 +21,8 @@ class @AwardsHandler
$(".emoji-menu").hide() $(".emoji-menu").hide()
addAwardToEmojiBar: (emoji) -> addAwardToEmojiBar: (emoji) ->
@addEmojiToFrequentlyUsedList(emoji)
emoji = @normilizeEmojiName(emoji) emoji = @normilizeEmojiName(emoji)
if @exist(emoji) if @exist(emoji)
if @isActive(emoji) if @isActive(emoji)
...@@ -117,6 +120,29 @@ class @AwardsHandler ...@@ -117,6 +120,29 @@ class @AwardsHandler
normilizeEmojiName: (emoji) -> normilizeEmojiName: (emoji) ->
@aliases[emoji] || 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: -> setupSearch: ->
$("input.emoji-search").keyup (ev) => $("input.emoji-search").keyup (ev) =>
term = $(ev.target).val() term = $(ev.target).val()
...@@ -125,7 +151,7 @@ class @AwardsHandler ...@@ -125,7 +151,7 @@ class @AwardsHandler
$("ul.emoji-search,h5.emoji-search").remove() $("ul.emoji-search,h5.emoji-search").remove()
if term if term
# Generate search result block # Generate a search result block
h5 = $("<h5>").text("Search results").addClass("emoji-search") h5 = $("<h5>").text("Search results").addClass("emoji-search")
found_emojis = @searchEmojis(term).show() found_emojis = @searchEmojis(term).show()
ul = $("<ul>").addClass("emoji-search").append(found_emojis) ul = $("<ul>").addClass("emoji-search").append(found_emojis)
......
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