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
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) ->
......
......@@ -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()
......
window.emojiAliases = ->
gl.emojiAliases = ->
JSON.parse('<%= Gitlab::AwardEmoji.aliases.to_json %>')
......@@ -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
......
......@@ -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
......
......@@ -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) ->
......
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