diff options
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 16 | ||||
-rw-r--r-- | app/controllers/emojis_controller.rb | 6 | ||||
-rw-r--r-- | app/views/emojis/index.html.haml | 9 | ||||
-rw-r--r-- | app/views/votes/_votes_block.html.haml | 9 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | features/steps/project/issues/award_emoji.rb | 3 |
6 files changed, 32 insertions, 13 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 360acb864f6..8f89d3e61a2 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -1,10 +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() - $("#emoji_search").focus() + + @showEmojiMenu() $("html").on 'click', (event) -> if !$(event.target).closest(".emoji-menu").length @@ -14,6 +14,16 @@ class @AwardsHandler @renderFrequentlyUsedBlock() @setupSearch() + showEmojiMenu: -> + if $(".emoji-menu").length + $(".emoji-menu").show() + $("#emoji_search").focus() + else + $.get "/emojis", (response) -> + $(".add-award").after response + $(".emoji-menu").show() + $("#emoji_search").focus() + addAward: (emoji) -> emoji = @normilizeEmojiName(emoji) @postEmoji emoji, => diff --git a/app/controllers/emojis_controller.rb b/app/controllers/emojis_controller.rb new file mode 100644 index 00000000000..1bec5a7d27f --- /dev/null +++ b/app/controllers/emojis_controller.rb @@ -0,0 +1,6 @@ +class EmojisController < ApplicationController + layout false + + def index + end +end diff --git a/app/views/emojis/index.html.haml b/app/views/emojis/index.html.haml new file mode 100644 index 00000000000..b66e513e4d2 --- /dev/null +++ b/app/views/emojis/index.html.haml @@ -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"])
\ No newline at end of file diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml index 91c5b7eac5e..176fd29cb57 100644 --- a/app/views/votes/_votes_block.html.haml +++ b/app/views/votes/_votes_block.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 30681356c5f..1485b64da19 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,6 +43,8 @@ Rails.application.routes.draw do get '/autocomplete/users' => 'autocomplete#users' get '/autocomplete/users/:id' => 'autocomplete#user' + # Emojis + resources :emojis, only: :index # Search get 'search' => 'search#show' diff --git a/features/steps/project/issues/award_emoji.rb b/features/steps/project/issues/award_emoji.rb index 93cf608cc62..277c63914d1 100644 --- a/features/steps/project/issues/award_emoji.rb +++ b/features/steps/project/issues/award_emoji.rb @@ -96,6 +96,7 @@ class Spinach::Features::AwardEmoji < Spinach::FeatureSteps end step 'The search field is focused' do - page.evaluate_script("document.activeElement.id").should eq "emoji_search" + expect(page).to have_selector('#emoji_search') + expect(page.evaluate_script('document.activeElement.id')).to eq('emoji_search') end end |