Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-11-25 15:48:58 +01:00
commit e54fe496f2
2 changed files with 13 additions and 18 deletions

View file

@ -233,6 +233,7 @@ class ChatWindow extends App.Controller
@lastTimestamp
@lastAddedType
@isTyping = false
@isAgentTyping = false
@resetUnreadMessages()
@on 'layout-change', @scrollToBottom
@ -319,6 +320,10 @@ class ChatWindow extends App.Controller
ENTERKEY = 13
if event.keyCode isnt TABKEY && event.keyCode isnt ENTERKEY
# send typing start event only every 1.4 seconds
return if @isAgentTyping && @isAgentTyping > new Date(new Date().getTime() - 1400)
@isAgentTyping = new Date()
App.WebSocket.send(
event:'chat_session_typing'
data:
@ -413,7 +418,7 @@ class ChatWindow extends App.Controller
@scrollToBottom()
# clear old delay, set new
@delay(@removeWritingLoader, 1800, 'typing')
@delay(@removeWritingLoader, 2000, 'typing')
removeWritingLoader: =>
@isTyping = false

View file

@ -209,23 +209,15 @@ do($ = window.jQuery, window) ->
sessionStorage.setItem 'unfinished_message', @input.val()
@onTypingStart()
@onTyping()
onTypingStart: ->
onTyping: ->
clearTimeout(@isTypingTimeout) if @isTypingTimeout
# fire typingEnd after 5 seconds
@isTypingTimeout = setTimeout @onTypingEnd, 1500
# send typing start event
if !@isTyping
@isTyping = true
@send 'chat_session_typing',
session_id: @sessionId
onTypingEnd: =>
@isTyping = false
# send typing start event only every 1.5 seconds
return if @isTyping && @isTyping > new Date(new Date().getTime() - 1500)
@isTyping = new Date()
@send 'chat_session_typing',
session_id: @sessionId
onSubmit: (event) =>
event.preventDefault()
@ -256,8 +248,6 @@ do($ = window.jQuery, window) ->
@input.val('')
@scrollToBottom()
@isTyping = false
# send message event
@send 'chat_session_message',
content: message