Commit a797b7e 1 parent 6ba5c3c commit a797b7e Copy full SHA for a797b7e
File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,17 @@ class @ChatMessages
110
110
postGrowCallback : =>
111
111
this .resize ()
112
112
113
+ tryCompletion : (input ) ->
114
+ value = input .value .match (/ [^ \s ] + $ / )
115
+ if value ? .length > 0
116
+ value = value[0 ]
117
+
118
+ re = new RegExp value, ' i'
119
+
120
+ user = Meteor .users .findOne username : re
121
+ if user?
122
+ input .value = input .value .replace value, ' @' + user .username
123
+
113
124
keyup : (rid , event ) ->
114
125
input = event .currentTarget
115
126
k = event .which
@@ -148,6 +159,12 @@ class @ChatMessages
148
159
else
149
160
this .send (rid, input)
150
161
return
162
+
163
+ if k is 9
164
+ event .preventDefault ()
165
+ event .stopPropagation ()
166
+ @ tryCompletion input
167
+
151
168
if k is 27
152
169
if this .editing .id
153
170
event .preventDefault ()
You can’t perform that action at this time.
0 commit comments