Commit 8dc1fa0d authored by Fatih Acet's avatar Fatih Acet Committed by Z.J. van de Weg

Updated MR notes.

parent 7d3f8f54
...@@ -2,7 +2,7 @@ class @AwardsHandler ...@@ -2,7 +2,7 @@ class @AwardsHandler
constructor: -> constructor: ->
@aliases = emojiAliases() @aliases = gl.emojiAliases()
$(document) $(document)
.off 'click', '.js-add-award' .off 'click', '.js-add-award'
...@@ -172,7 +172,7 @@ class @AwardsHandler ...@@ -172,7 +172,7 @@ class @AwardsHandler
decrementCounter: ($emojiButton, emoji) -> decrementCounter: ($emojiButton, emoji) ->
counter = $('.js-counter', $emojiButton) counter = $ '.js-counter', $emojiButton
counterNumber = parseInt counter.text(), 10 counterNumber = parseInt counter.text(), 10
if counterNumber > 1 if counterNumber > 1
...@@ -218,9 +218,7 @@ class @AwardsHandler ...@@ -218,9 +218,7 @@ class @AwardsHandler
awardBlock awardBlock
.closest '.js-emoji-btn' .closest '.js-emoji-btn'
.removeData 'original-title' .removeData 'original-title'
.removeData 'title'
.attr 'data-original-title', newAuthors .attr 'data-original-title', newAuthors
.attr 'data-title', newAuthors
@resetTooltip awardBlock @resetTooltip awardBlock
...@@ -258,8 +256,8 @@ class @AwardsHandler ...@@ -258,8 +256,8 @@ class @AwardsHandler
</button>" </button>"
$emojiButton = $ buttonHtml $emojiButton = $ buttonHtml
emoji_node = $emojiButton $emojiButton
.insertBefore votesBlock.find '.js-award-holder:not(.js-award-action-btn)' .insertBefore votesBlock.find '.js-award-holder'
.find '.emoji-icon' .find '.emoji-icon'
.data 'emoji', emoji .data 'emoji', emoji
...@@ -281,21 +279,21 @@ class @AwardsHandler ...@@ -281,21 +279,21 @@ class @AwardsHandler
if $('.emoji-menu').length if $('.emoji-menu').length
return @createEmoji_ votesBlock, emoji 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) -> resolveNameToCssClass: (emoji) ->
emoji_icon = $(".emoji-menu-content [data-emoji='#{emoji}']") emojiIcon = $ ".emoji-menu-content [data-emoji='#{emoji}']"
if emoji_icon.length > 0 if emojiIcon.length > 0
unicodeName = emoji_icon.data('unicode-name') unicodeName = emojiIcon.data 'unicode-name'
else else
# Find by alias # 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}" return "emoji-#{unicodeName}"
...@@ -303,7 +301,7 @@ class @AwardsHandler ...@@ -303,7 +301,7 @@ class @AwardsHandler
postEmoji: (awardUrl, emoji, callback) -> postEmoji: (awardUrl, emoji, callback) ->
$.post awardUrl, { name: emoji }, (data) -> $.post awardUrl, { name: emoji }, (data) ->
callback.call() if data.ok callback() if data.ok
findEmojiIcon: (votesBlock, emoji) -> findEmojiIcon: (votesBlock, emoji) ->
......
...@@ -23,7 +23,7 @@ class Dispatcher ...@@ -23,7 +23,7 @@ class Dispatcher
new Issue() new Issue()
shortcut_handler = new ShortcutsIssuable() shortcut_handler = new ShortcutsIssuable()
new ZenMode() new ZenMode()
window.awardsHandler = new AwardsHandler() gl.awardsHandler = new AwardsHandler()
when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show' when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
new Milestone() new Milestone()
when 'dashboard:todos:index' when 'dashboard:todos:index'
...@@ -54,7 +54,7 @@ class Dispatcher ...@@ -54,7 +54,7 @@ class Dispatcher
new Diff() new Diff()
shortcut_handler = new ShortcutsIssuable(true) shortcut_handler = new ShortcutsIssuable(true)
new ZenMode() new ZenMode()
window.awardsHandler = new AwardsHandler() gl.awardsHandler = new AwardsHandler()
when "projects:merge_requests:diffs" when "projects:merge_requests:diffs"
new Diff() new Diff()
new ZenMode() new ZenMode()
......
window.emojiAliases = -> gl.emojiAliases = ->
JSON.parse('<%= Gitlab::AwardEmoji.aliases.to_json %>') JSON.parse('<%= Gitlab::AwardEmoji.aliases.to_json %>')
...@@ -168,8 +168,8 @@ class @Notes ...@@ -168,8 +168,8 @@ class @Notes
if note.award if note.award
votesBlock = $('.js-awards-block').eq 0 votesBlock = $('.js-awards-block').eq 0
awardsHandler.addAwardToEmojiBar votesBlock, note.name gl.awardsHandler.addAwardToEmojiBar votesBlock, note.name
awardsHandler.scrollToAwards() gl.awardsHandler.scrollToAwards()
# render note if it not present in loaded list # render note if it not present in loaded list
# or skip if rendered # or skip if rendered
......
...@@ -757,6 +757,7 @@ Rails.application.routes.draw do ...@@ -757,6 +757,7 @@ Rails.application.routes.draw do
resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
member do member do
post :toggle_award_emoji
delete :delete_attachment delete :delete_attachment
end end
end end
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
awardsHandler = null awardsHandler = null
window.gl or= {} window.gl or= {}
window.gl.awardMenuUrl = '/emojis' gl.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' }
window.emojiAliases = -> return { '+1': 'thumbsup', '-1': 'thumbsdown' } gl.awardMenuUrl = '/emojis'
lazyAssert = (done, assertFn) -> lazyAssert = (done, assertFn) ->
......
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