|
@@ -157,6 +157,17 @@ function resizeChatConversation() {
|
157
|
157
|
chat.height(window.innerHeight - 15 - msgareaHeight);
|
158
|
158
|
}
|
159
|
159
|
|
|
160
|
+/**
|
|
161
|
+ * Focus input after 400 ms
|
|
162
|
+ * Found input by id
|
|
163
|
+ *
|
|
164
|
+ * @param id {string} input id
|
|
165
|
+ */
|
|
166
|
+function deferredFocus(id){
|
|
167
|
+ setTimeout(function (){
|
|
168
|
+ $(`#${id}`).focus();
|
|
169
|
+ }, 400);
|
|
170
|
+}
|
160
|
171
|
/**
|
161
|
172
|
* Chat related user interface.
|
162
|
173
|
*/
|
|
@@ -180,6 +191,7 @@ var Chat = {
|
180
|
191
|
let val = this.value;
|
181
|
192
|
this.value = '';
|
182
|
193
|
eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
|
|
194
|
+ deferredFocus('usermsg');
|
183
|
195
|
}
|
184
|
196
|
});
|
185
|
197
|
|
|
@@ -223,9 +235,9 @@ var Chat = {
|
223
|
235
|
// if we are in conversation mode focus on the text input
|
224
|
236
|
// if we are not, focus on the display name input
|
225
|
237
|
if (APP.settings.getDisplayName())
|
226
|
|
- $('#usermsg').focus();
|
|
238
|
+ deferredFocus('usermsg');
|
227
|
239
|
else
|
228
|
|
- $('#nickinput').focus();
|
|
240
|
+ deferredFocus('nickinput');
|
229
|
241
|
});
|
230
|
242
|
|
231
|
243
|
addSmileys();
|
|
@@ -318,13 +330,6 @@ var Chat = {
|
318
|
330
|
setChatConversationMode (isConversationMode) {
|
319
|
331
|
$('#' + CHAT_CONTAINER_ID)
|
320
|
332
|
.toggleClass('is-conversation-mode', isConversationMode);
|
321
|
|
-
|
322
|
|
- // this is needed when we transition from no conversation mode to
|
323
|
|
- // conversation mode. When user enters his nickname and hits enter,
|
324
|
|
- // to focus on the write area.
|
325
|
|
- if (isConversationMode) {
|
326
|
|
- $('#usermsg').focus();
|
327
|
|
- }
|
328
|
333
|
},
|
329
|
334
|
|
330
|
335
|
/**
|