Load award emoji picker with ajax request
This commit is contained in:
parent
66c03e0e29
commit
074fa8f2b9
5 changed files with 25 additions and 11 deletions
|
@ -1,9 +1,10 @@
|
|||
class @AwardsHandler
|
||||
constructor: (@post_emoji_url, @noteable_type, @noteable_id, @aliases) ->
|
||||
$(".add-award").click (event)->
|
||||
$(".add-award").click (event) =>
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
$(".emoji-menu").show()
|
||||
|
||||
@showEmojiMenu()
|
||||
$("#emoji_search").focus()
|
||||
|
||||
$("html").on 'click', (event) ->
|
||||
|
@ -14,6 +15,14 @@ class @AwardsHandler
|
|||
@renderFrequentlyUsedBlock()
|
||||
@setupSearch()
|
||||
|
||||
showEmojiMenu: ->
|
||||
if $(".emoji-menu").length
|
||||
$(".emoji-menu").show()
|
||||
else
|
||||
$.get "/emoji_menu", (response) ->
|
||||
$(".add-award").after response
|
||||
$(".emoji-menu").show()
|
||||
|
||||
addAward: (emoji) ->
|
||||
emoji = @normilizeEmojiName(emoji)
|
||||
@postEmoji emoji, =>
|
||||
|
|
|
@ -24,6 +24,10 @@ class AutocompleteController < ApplicationController
|
|||
render json: @user, only: [:name, :username, :id], methods: [:avatar_url]
|
||||
end
|
||||
|
||||
def emoji_menu
|
||||
render 'shared/emoji_menu', layout: false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_users
|
||||
|
|
9
app/views/shared/emoji_menu.html.haml
Normal file
9
app/views/shared/emoji_menu.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
.emoji-menu
|
||||
.emoji-menu-content
|
||||
= text_field_tag :emoji_search, "", class: "emoji-search search-input form-control"
|
||||
- AwardEmoji.emoji_by_category.each do |category, emojis|
|
||||
%h5= AwardEmoji::CATEGORIES[category]
|
||||
%ul
|
||||
- emojis.each do |emoji|
|
||||
%li
|
||||
= emoji_icon(emoji["name"], emoji["unicode"], emoji["aliases"])
|
|
@ -9,15 +9,6 @@
|
|||
.awards-controls
|
||||
%a.add-award{"href" => "#"}
|
||||
= icon('smile-o')
|
||||
.emoji-menu
|
||||
.emoji-menu-content
|
||||
= text_field_tag :emoji_search, "", class: "emoji-search search-input form-control"
|
||||
- AwardEmoji.emoji_by_category.each do |category, emojis|
|
||||
%h5= AwardEmoji::CATEGORIES[category]
|
||||
%ul
|
||||
- emojis.each do |emoji|
|
||||
%li
|
||||
= emoji_icon(emoji["name"], emoji["unicode"], emoji["aliases"])
|
||||
|
||||
- if current_user
|
||||
:javascript
|
||||
|
|
|
@ -42,6 +42,7 @@ Rails.application.routes.draw do
|
|||
# Autocomplete
|
||||
get '/autocomplete/users' => 'autocomplete#users'
|
||||
get '/autocomplete/users/:id' => 'autocomplete#user'
|
||||
get '/emoji_menu' => 'autocomplete#emoji_menu'
|
||||
|
||||
|
||||
# Search
|
||||
|
|
Loading…
Reference in a new issue