diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-06-04 00:16:13 +0300 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-06-06 17:02:11 +0300 |
commit | 8dc1fa0d8dc9106ab95a3039723e9013c4eed00c (patch) | |
tree | f41a60d994219e7c915428b1e3cd44a9843a8781 | |
parent | 7d3f8f542f0fe02ae27d5f527d578c19f47eec71 (diff) |
Updated MR notes.
-rw-r--r-- | app/assets/javascripts/awards_handler.coffee | 24 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.coffee | 4 | ||||
-rw-r--r-- | app/assets/javascripts/lib/emoji_aliases.js.coffee.erb | 2 | ||||
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 4 | ||||
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | spec/javascripts/awards_handler_spec.js.coffee | 8 |
6 files changed, 21 insertions, 22 deletions
diff --git a/app/assets/javascripts/awards_handler.coffee b/app/assets/javascripts/awards_handler.coffee index 4f4009e6db0..efa8f6cd010 100644 --- a/app/assets/javascripts/awards_handler.coffee +++ b/app/assets/javascripts/awards_handler.coffee @@ -2,7 +2,7 @@ class @AwardsHandler constructor: -> - @aliases = emojiAliases() + @aliases = gl.emojiAliases() $(document) .off 'click', '.js-add-award' @@ -172,7 +172,7 @@ class @AwardsHandler decrementCounter: ($emojiButton, emoji) -> - counter = $('.js-counter', $emojiButton) + counter = $ '.js-counter', $emojiButton counterNumber = parseInt counter.text(), 10 if counterNumber > 1 @@ -218,9 +218,7 @@ class @AwardsHandler awardBlock .closest '.js-emoji-btn' .removeData 'original-title' - .removeData 'title' .attr 'data-original-title', newAuthors - .attr 'data-title', newAuthors @resetTooltip awardBlock @@ -258,8 +256,8 @@ class @AwardsHandler </button>" $emojiButton = $ buttonHtml - emoji_node = $emojiButton - .insertBefore votesBlock.find '.js-award-holder:not(.js-award-action-btn)' + $emojiButton + .insertBefore votesBlock.find '.js-award-holder' .find '.emoji-icon' .data 'emoji', emoji @@ -281,21 +279,21 @@ class @AwardsHandler if $('.emoji-menu').length return @createEmoji_ votesBlock, emoji - @createEmojiMenu @getAwardMenuUrl(), => @createEmoji votesBlock, emoji + @createEmojiMenu @getAwardMenuUrl(), => @createEmoji_ votesBlock, emoji - getAwardMenuUrl: -> return gl.awardMenuUrl or '/emojis' + getAwardMenuUrl: -> return gl.awardMenuUrl resolveNameToCssClass: (emoji) -> - emoji_icon = $(".emoji-menu-content [data-emoji='#{emoji}']") + emojiIcon = $ ".emoji-menu-content [data-emoji='#{emoji}']" - if emoji_icon.length > 0 - unicodeName = emoji_icon.data('unicode-name') + if emojiIcon.length > 0 + unicodeName = emojiIcon.data 'unicode-name' else # Find by alias - unicodeName = $(".emoji-menu-content [data-aliases*=':#{emoji}:']").data('unicode-name') + unicodeName = $(".emoji-menu-content [data-aliases*=':#{emoji}:']").data 'unicode-name' return "emoji-#{unicodeName}" @@ -303,7 +301,7 @@ class @AwardsHandler postEmoji: (awardUrl, emoji, callback) -> $.post awardUrl, { name: emoji }, (data) -> - callback.call() if data.ok + callback() if data.ok findEmojiIcon: (votesBlock, emoji) -> diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index bae67a2ebaf..ec540060457 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -23,7 +23,7 @@ class Dispatcher new Issue() shortcut_handler = new ShortcutsIssuable() new ZenMode() - window.awardsHandler = new AwardsHandler() + gl.awardsHandler = new AwardsHandler() when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show' new Milestone() when 'dashboard:todos:index' @@ -54,7 +54,7 @@ class Dispatcher new Diff() shortcut_handler = new ShortcutsIssuable(true) new ZenMode() - window.awardsHandler = new AwardsHandler() + gl.awardsHandler = 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 index 97be65116e2..80f9936b9c2 100644 --- a/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb +++ b/app/assets/javascripts/lib/emoji_aliases.js.coffee.erb @@ -1,2 +1,2 @@ -window.emojiAliases = -> +gl.emojiAliases = -> JSON.parse('<%= Gitlab::AwardEmoji.aliases.to_json %>') diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 0fdbe55ea9c..8e33e915ba5 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -168,8 +168,8 @@ class @Notes if note.award votesBlock = $('.js-awards-block').eq 0 - awardsHandler.addAwardToEmojiBar votesBlock, note.name - awardsHandler.scrollToAwards() + gl.awardsHandler.addAwardToEmojiBar votesBlock, note.name + gl.awardsHandler.scrollToAwards() # render note if it not present in loaded list # or skip if rendered diff --git a/config/routes.rb b/config/routes.rb index 1fc7985136b..9b54b292845 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -757,6 +757,7 @@ Rails.application.routes.draw do resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do member do + post :toggle_award_emoji delete :delete_attachment end end diff --git a/spec/javascripts/awards_handler_spec.js.coffee b/spec/javascripts/awards_handler_spec.js.coffee index 5a95ae52dc8..0bd6d696387 100644 --- a/spec/javascripts/awards_handler_spec.js.coffee +++ b/spec/javascripts/awards_handler_spec.js.coffee @@ -3,10 +3,10 @@ #= require jquery.cookie #= require ./fixtures/emoji_menu -awardsHandler = null -window.gl or= {} -window.gl.awardMenuUrl = '/emojis' -window.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' } +awardsHandler = null +window.gl or= {} +gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' } +gl.awardMenuUrl = '/emojis' lazyAssert = (done, assertFn) -> |