Skip to content

Commit

Permalink
Merge pull request #3109 from leifkb/develop
Browse files Browse the repository at this point in the history
Added quote button to messages.
  • Loading branch information
engelgabriel committed May 3, 2016
2 parents dd193b1 + 3ca1af8 commit dc5157e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/rocketchat-lib/client/MessageAction.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,40 @@ Meteor.startup ->
$(event.currentTarget).attr('data-clipboard-text', message)
toastr.success(TAPi18n.__('Copied'))
order: 4

RocketChat.MessageAction.addButton
id: 'quote-message'
icon: 'icon-quote-left'
i18nLabel: 'Quote'
context: [
'message'
'message-mobile'
]
action: (event, instance) ->
m = @_arguments[1]
message = m.msg
msg = $(event.currentTarget).closest('.message')[0]
$("\##{msg.id} .message-dropdown").hide()
zpad = (n) ->
result = n.toString()
if result.length > 1
return result
else
return '0' + result
ts = zpad(m.ts.getUTCHours()) + ':' + zpad(m.ts.getUTCMinutes()) + ' UTC'
now = new Date
if (now.getUTCFullYear() isnt m.ts.getUTCFullYear() or
now.getUTCMonth() isnt m.ts.getUTCMonth() or
now.getUTCDate() isnt m.ts.getUTCDate())
ts = m.ts.getUTCFullYear() + '-' + zpad(m.ts.getUTCMonth()) + '-' + zpad(m.ts.getUTCDate()) + ' ' + ts
input = instance.find('.input-message')
text = input.value
if text
text += '\n'
text += '@' + m.u.username + ' said (' + ts + '):\n'
for line in message.split(/\r\n|\r|\n/)
text += '> ' + line + '\n'
input.value = text
input.focus()
$(input).keyup()
order: 5

0 comments on commit dc5157e

Please sign in to comment.