chat interface: autofocus on first new chat input

This commit is contained in:
Felix Niklas 2015-11-12 15:54:30 +01:00
parent 2b8bd3a87c
commit e73d8e76db

View file

@ -12,12 +12,7 @@ class App.CustomerChat extends App.Controller
return if !@isRole('Chat') return if !@isRole('Chat')
@i = 0
@chatWindows = {} @chatWindows = {}
@totalQuestions = 7
@answered = 0
@correct = 0
@wrong = 0
@maxChats = 4 @maxChats = 4
@messageCounter = 0 @messageCounter = 0
@ -132,6 +127,17 @@ class App.CustomerChat extends App.Controller
chat.render() chat.render()
@chatWindows[session.session_id] = chat @chatWindows[session.session_id] = chat
if @windowCount() is 1
chat.focus()
windowCount: =>
count = 0
for chat of @chatWindows
count++
return count
removeChat: (session_id) => removeChat: (session_id) =>
delete @chatWindows[session_id] delete @chatWindows[session_id]
@ -237,8 +243,8 @@ class chatWindow extends App.Controller
else else
@addMessage message.content, 'customer' @addMessage message.content, 'customer'
# set focus focus: =>
#@input.get(0).focus() @input.focus()
onTransitionend: (event) => onTransitionend: (event) =>
# chat window is done with animation - adjust scroll-bars # chat window is done with animation - adjust scroll-bars