diff options
author | Phil Hughes <me@iamphill.com> | 2016-03-31 10:55:37 +0100 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-05-19 14:07:27 -0500 |
commit | 0b45cf55dddb66b7c6328bc6d5233d023c031e5c (patch) | |
tree | 9f55bf0b91bfcbfa44af03a89896d6abf0477432 /app/assets/javascripts | |
parent | 4caf38a1d583f1561affc278ff0ddc0174e47b72 (diff) | |
download | gitlab-ce-0b45cf55dddb66b7c6328bc6d5233d023c031e5c.tar.gz |
Uses the same emoji-menu and just moves it around depending where it should be viewed
# Conflicts:
# app/assets/javascripts/awards_handler.coffee
# app/assets/stylesheets/pages/notes.scss
# app/helpers/issues_helper.rb
# app/views/projects/notes/_note.html.haml
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 41 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 2 | ||||
-rw-r--r-- | app/assets/javascripts/lib/emoji_aliases.js.coffee.erb | 2 |
3 files changed, 27 insertions, 18 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 105b0c34e95..9e3d9f09126 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -1,23 +1,23 @@ class @AwardsHandler - constructor: (@aliases) -> - $(".js-add-award").on "click", (event) => + constructor: -> + @aliases = emojiAliases() + + $(document).on "click", ".js-add-award", (event) => event.stopPropagation() event.preventDefault() - @showEmojiMenu() + @showEmojiMenu $(event.currentTarget) $("html").on 'click', (event) -> if !$(event.target).closest(".emoji-menu").length if $(".emoji-menu").is(":visible") $(".emoji-menu").removeClass "is-visible" - $(".awards") - .off "click" + $(document) + .off "click", ".js-emoji-btn" .on "click", ".js-emoji-btn", @handleClick - @renderFrequentlyUsedBlock() - - handleClick: (e) -> + handleClick: (e) => e.preventDefault() $emojiBtn = $(e.currentTarget) awardUrl = $emojiBtn.closest('.js-votes-block').data 'award-url' @@ -26,8 +26,13 @@ class @AwardsHandler .data "emoji" @addAward awardUrl, emoji - showEmojiMenu: -> + showEmojiMenu: ($addBtn) -> if $(".emoji-menu").length + $holder = $addBtn.closest('.js-award-holder') + + if $holder.find('.emoji-menu').length is 0 + $(".emoji-menu").detach().appendTo $holder + if $(".emoji-menu").is ".is-visible" $(".emoji-menu").removeClass "is-visible" $("#emoji_search").blur() @@ -35,10 +40,11 @@ class @AwardsHandler $(".emoji-menu").addClass "is-visible" $("#emoji_search").focus() else - $('.js-add-award').addClass "is-loading" - $.get "/emojis", (response) => - $('.js-add-award').removeClass "is-loading" - $(".js-award-holder").append response + $addBtn.addClass "is-loading" + $.get $addBtn.data('award-menu-url'), (response) => + $addBtn.removeClass "is-loading" + $addBtn.closest('.js-award-holder').append response + @renderFrequentlyUsedBlock() setTimeout => $(".emoji-menu").addClass "is-visible" $("#emoji_search").focus() @@ -128,7 +134,7 @@ class @AwardsHandler </button>" emoji_node = $(buttonHtml) - .insertBefore(".js-award-holder") + .insertBefore(".js-award-holder:not(.js-award-action-btn)") .find(".emoji-icon") .data("emoji", emoji) $('.award-control').tooltip() @@ -173,16 +179,15 @@ class @AwardsHandler if $.cookie('frequently_used_emojis') frequently_used_emojis = @getFrequentlyUsedEmojis() - ul = $("<ul>") + ul = $("<ul class='clearfix emoji-menu-list'>") for emoji in frequently_used_emojis - do (emoji) -> - $(".emoji-menu-content [data-emoji='#{emoji}']").closest("li").clone().appendTo(ul) + $(".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) => + $("input.emoji-search").on 'keyup', (ev) => term = $(ev.target).val() # Clean previous search results diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index f91aa3c5ad7..ff8bcf89918 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -23,6 +23,7 @@ class Dispatcher new Issue() shortcut_handler = new ShortcutsIssuable() new ZenMode() + window.awards_handler = new AwardsHandler() when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show' new Milestone() when 'dashboard:todos:index' @@ -53,6 +54,7 @@ class Dispatcher new Diff() shortcut_handler = new ShortcutsIssuable(true) new ZenMode() + window.awards_handler = new AwardsHandler() when "projects:merge_requests:diffs" new Diff() new ZenMode() diff --git a/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb b/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb new file mode 100644 index 00000000000..66f640a3cb7 --- /dev/null +++ b/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb @@ -0,0 +1,2 @@ +window.emojiAliases = -> + JSON.parse('<%= AwardEmoji.aliases.to_json %>') |