From e73d8e76db08b1abfdcf21c2d807c6386685bff5 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Thu, 12 Nov 2015 15:54:30 +0100 Subject: [PATCH] chat interface: autofocus on first new chat input --- .../javascripts/app/controllers/chat.coffee | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index a75f10345..913287675 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -12,12 +12,7 @@ class App.CustomerChat extends App.Controller return if !@isRole('Chat') - @i = 0 @chatWindows = {} - @totalQuestions = 7 - @answered = 0 - @correct = 0 - @wrong = 0 @maxChats = 4 @messageCounter = 0 @@ -132,6 +127,17 @@ class App.CustomerChat extends App.Controller chat.render() @chatWindows[session.session_id] = chat + if @windowCount() is 1 + chat.focus() + + windowCount: => + count = 0 + + for chat of @chatWindows + count++ + + return count + removeChat: (session_id) => delete @chatWindows[session_id] @@ -237,8 +243,8 @@ class chatWindow extends App.Controller else @addMessage message.content, 'customer' - # set focus - #@input.get(0).focus() + focus: => + @input.focus() onTransitionend: (event) => # chat window is done with animation - adjust scroll-bars