Skip to content
Snippets Groups Projects
Commit a797b7e8 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Complete username with tab. Close #159

parent 6ba5c3c7
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,17 @@ class @ChatMessages
postGrowCallback: =>
this.resize()
tryCompletion: (input) ->
value = input.value.match(/[^\s]+$/)
if value?.length > 0
value = value[0]
re = new RegExp value, 'i'
user = Meteor.users.findOne username: re
if user?
input.value = input.value.replace value, '@' + user.username
keyup: (rid, event) ->
input = event.currentTarget
k = event.which
......@@ -148,6 +159,12 @@ class @ChatMessages
else
this.send(rid, input)
return
if k is 9
event.preventDefault()
event.stopPropagation()
@tryCompletion input
if k is 27
if this.editing.id
event.preventDefault()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment