diff --git a/public/assets/chat/chat.coffee b/public/assets/chat/chat.coffee
index 26ad26fec..239026c32 100644
--- a/public/assets/chat/chat.coffee
+++ b/public/assets/chat/chat.coffee
@@ -14,13 +14,15 @@ do($ = window.jQuery, window) ->
host: ''
debug: false
flat: false
- lang: undefined,
- cssAutoload: true,
- cssUrl: undefined,
+ lang: undefined
+ cssAutoload: true
+ cssUrl: undefined
fontSize: undefined
buttonClass: 'open-zammad-chat'
inactiveClass: 'is-inactive'
title: 'Chat with us!'
+ idleTimeout: 8
+ inactiveTimeout: 20
_messageCount: 0
isOpen: true
@@ -48,8 +50,8 @@ do($ = window.jQuery, window) ->
'All colleges are busy.': 'Alle Kollegen sind belegt.'
'You are on waiting list position %s.': 'Sie sind in der Warteliste an der Position %s.'
'Start new conversation': 'Neue Konversation starten'
- 'Since you didn\'t respond in the last %s your conversation with %s got closed.': 'Da sie in den letzten %s nichts geschrieben haben wurde ihre Konversation mit %s geschlossen.'
- 'minutes': 'Minuten'
+ 'Since you didn\'t respond in the last %s minutes your conversation with %s got closed.': 'Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation mit %s geschlossen.'
+ 'Since you didn\'t respond in the last %s minutes your conversation got closed.': 'Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation geschlossen.'
sessionId: undefined
T: (string, items...) =>
@@ -86,6 +88,10 @@ do($ = window.jQuery, window) ->
@options = $.extend {}, @defaults, options
# check prerequisites
+ if !$
+ @state = 'unsupported'
+ @log 'notice', 'Chat: no jquery found!'
+ return
if !window.WebSocket or !sessionStorage
@state = 'unsupported'
@log 'notice', 'Chat: Browser not supported!'
@@ -143,7 +149,9 @@ do($ = window.jQuery, window) ->
@log 'debug', 'ws:onmessage', pipe
switch pipe.event
when 'chat_error'
- @log 'error', pipe.data
+ @log 'notice', pipe.data
+ if pipe.data && pipe.data.state is 'chat_disabled'
+ @wsClose()
when 'chat_session_message'
return if pipe.data.self_written
@receiveMessage pipe.data
@@ -194,6 +202,8 @@ do($ = window.jQuery, window) ->
$(".#{ @options.buttonClass }").hide()
reopenSession: (data) =>
+ @inactiveTimeoutStart()
+
unfinishedMessage = sessionStorage.getItem 'unfinished_message'
# rerender chat history
@@ -236,6 +246,7 @@ do($ = window.jQuery, window) ->
@isTyping = new Date()
@send 'chat_session_typing',
session_id: @sessionId
+ @inactiveTimeoutStart()
onSubmit: (event) =>
event.preventDefault()
@@ -243,9 +254,10 @@ do($ = window.jQuery, window) ->
sendMessage: ->
message = @input.val()
-
return if !message
+ @inactiveTimeoutStart()
+
sessionStorage.removeItem 'unfinished_message'
messageElement = @view('message')
@@ -273,6 +285,8 @@ do($ = window.jQuery, window) ->
session_id: @sessionId
receiveMessage: (data) =>
+ @inactiveTimeoutStart()
+
# hide writing indicator
@onAgentTypingEnd()
@@ -307,10 +321,10 @@ do($ = window.jQuery, window) ->
@isOpen = true
if !@sessionId
- @session_init()
+ @sessionInit()
- onOpenAnimationEnd: ->
- #@showTimeout()
+ onOpenAnimationEnd: =>
+ @idleTimeoutStop()
close: (event) =>
return @state if @state is 'off' or @state is 'unsupported'
@@ -319,11 +333,24 @@ do($ = window.jQuery, window) ->
# only close if session_id exists
return if !@sessionId
+ # send close
+ @send 'chat_session_close',
+ session_id: @sessionId
+
+ # stop timer
+ @inactiveTimeoutStop()
+
+ # delete input store
+ sessionStorage.removeItem 'unfinished_message'
+
# stop delay of initial queue position
if @onInitialQueueDelayId
clearTimeout(@onInitialQueueDelayId)
- @closeWindow()
+ if event
+ @closeWindow()
+
+ @setSessionId undefined
closeWindow: =>
@el.removeClass('zammad-chat-is-open')
@@ -335,12 +362,6 @@ do($ = window.jQuery, window) ->
@disconnect()
@isOpen = false
- @send 'chat_session_close',
- session_id: @sessionId
-
- @setSessionId undefined
- sessionStorage.removeItem 'unfinished_message'
-
# restart connection
@onWebSocketOpen()
@@ -448,7 +469,7 @@ do($ = window.jQuery, window) ->
scrollToBottom: ->
@el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight'))
- session_init: ->
+ sessionInit: ->
@send('chat_session_init')
detectHost: ->
@@ -484,6 +505,7 @@ do($ = window.jQuery, window) ->
@reconnectDelayId = setTimeout(@wsConnect, 5000)
onWebSocketOpen: =>
+ @idleTimeoutStart()
@sessionId = sessionStorage.getItem('sessionId')
@log 'debug', 'ws connected'
@@ -511,6 +533,7 @@ do($ = window.jQuery, window) ->
@addStatus @T('Chat closed by %s', data.realname)
@disableInput()
@setAgentOnlineState 'offline'
+ @inactiveTimeoutStop()
disconnect: ->
@showLoader()
@@ -552,8 +575,11 @@ do($ = window.jQuery, window) ->
showTimeout: ->
@el.find('.zammad-chat-body').html @view('timeout')
agent: @agent.name
- delay: 10
- unit: @T('minutes')
+ delay: @options.inactiveTimeout
+ @close()
+ reload = ->
+ location.reload()
+ @el.find('.js-restart').click reload
showLoader: ->
@el.find('.zammad-chat-body').html @view('loader')()
@@ -583,4 +609,31 @@ do($ = window.jQuery, window) ->
newSS.href = 'data:text/css,' + escape(styles)
document.getElementsByTagName('head')[0].appendChild(newSS)
+ inactiveTimeoutStart: =>
+ @inactiveTimeoutStop()
+ delay = =>
+ @log 'debug', "Inactive timeout of #{@options.inactiveTimeout} minutes, show timeout screen."
+ @state = 'off'
+ @setAgentOnlineState 'offline'
+ @showTimeout()
+ @wsClose()
+ @inactiveTimeoutStopDelayId = setTimeout(delay, @options.inactiveTimeout * 1000 * 60)
+
+ inactiveTimeoutStop: =>
+ return if !@inactiveTimeoutStopDelayId
+ clearTimeout(@inactiveTimeoutStopDelayId)
+
+ idleTimeoutStart: =>
+ @idleTimeoutStop()
+ delay = =>
+ @log 'debug', "Idle timeout of #{@options.idleTimeout} minutes, hide widget"
+ @state = 'off'
+ @hide()
+ @wsClose()
+ @idleTimeoutStopDelayId = setTimeout(delay, @options.idleTimeout * 1000 * 60)
+
+ idleTimeoutStop: =>
+ return if !@idleTimeoutStopDelayId
+ clearTimeout(@idleTimeoutStopDelayId)
+
window.ZammadChat = ZammadChat
diff --git a/public/assets/chat/chat.js b/public/assets/chat/chat.js
index 8508350e5..c05b2f0c8 100644
--- a/public/assets/chat/chat.js
+++ b/public/assets/chat/chat.js
@@ -20,7 +20,9 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
fontSize: void 0,
buttonClass: 'open-zammad-chat',
inactiveClass: 'is-inactive',
- title: 'Chat with us!'
+ title: 'Chat with us!',
+ idleTimeout: 8,
+ inactiveTimeout: 20
};
ZammadChat.prototype._messageCount = 0;
@@ -61,8 +63,8 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
'All colleges are busy.': 'Alle Kollegen sind belegt.',
'You are on waiting list position %s.': 'Sie sind in der Warteliste an der Position %s.',
'Start new conversation': 'Neue Konversation starten',
- 'Since you didn\'t respond in the last %s your conversation with %s got closed.': 'Da sie in den letzten %s nichts geschrieben haben wurde ihre Konversation mit %s geschlossen.',
- 'minutes': 'Minuten'
+ 'Since you didn\'t respond in the last %s minutes your conversation with %s got closed.': 'Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation mit %s geschlossen.',
+ 'Since you didn\'t respond in the last %s minutes your conversation got closed.': 'Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation geschlossen.'
}
};
@@ -117,6 +119,10 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
};
function ZammadChat(options) {
+ this.idleTimeoutStop = bind(this.idleTimeoutStop, this);
+ this.idleTimeoutStart = bind(this.idleTimeoutStart, this);
+ this.inactiveTimeoutStop = bind(this.inactiveTimeoutStop, this);
+ this.inactiveTimeoutStart = bind(this.inactiveTimeoutStart, this);
this.setAgentOnlineState = bind(this.setAgentOnlineState, this);
this.onConnectionEstablished = bind(this.onConnectionEstablished, this);
this.setSessionId = bind(this.setSessionId, this);
@@ -133,6 +139,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.onCloseAnimationEnd = bind(this.onCloseAnimationEnd, this);
this.closeWindow = bind(this.closeWindow, this);
this.close = bind(this.close, this);
+ this.onOpenAnimationEnd = bind(this.onOpenAnimationEnd, this);
this.open = bind(this.open, this);
this.renderMessage = bind(this.renderMessage, this);
this.receiveMessage = bind(this.receiveMessage, this);
@@ -148,6 +155,11 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.log = bind(this.log, this);
this.T = bind(this.T, this);
this.options = $.extend({}, this.defaults, options);
+ if (!$) {
+ this.state = 'unsupported';
+ this.log('notice', 'Chat: no jquery found!');
+ return;
+ }
if (!window.WebSocket || !sessionStorage) {
this.state = 'unsupported';
this.log('notice', 'Chat: Browser not supported!');
@@ -211,7 +223,10 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.log('debug', 'ws:onmessage', pipe);
switch (pipe.event) {
case 'chat_error':
- this.log('error', pipe.data);
+ this.log('notice', pipe.data);
+ if (pipe.data && pipe.data.state === 'chat_disabled') {
+ this.wsClose();
+ }
break;
case 'chat_session_message':
if (pipe.data.self_written) {
@@ -284,6 +299,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
ZammadChat.prototype.reopenSession = function(data) {
var i, len, message, ref, unfinishedMessage;
+ this.inactiveTimeoutStart();
unfinishedMessage = sessionStorage.getItem('unfinished_message');
if (data.agent) {
this.onConnectionEstablished(data);
@@ -322,9 +338,10 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return;
}
this.isTyping = new Date();
- return this.send('chat_session_typing', {
+ this.send('chat_session_typing', {
session_id: this.sessionId
});
+ return this.inactiveTimeoutStart();
};
ZammadChat.prototype.onSubmit = function(event) {
@@ -338,6 +355,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
if (!message) {
return;
}
+ this.inactiveTimeoutStart();
sessionStorage.removeItem('unfinished_message');
messageElement = this.view('message')({
message: message,
@@ -362,6 +380,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
};
ZammadChat.prototype.receiveMessage = function(data) {
+ this.inactiveTimeoutStart();
this.onAgentTypingEnd();
this.maybeAddTimestamp();
return this.renderMessage({
@@ -399,11 +418,13 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
}
this.isOpen = true;
if (!this.sessionId) {
- return this.session_init();
+ return this.sessionInit();
}
};
- ZammadChat.prototype.onOpenAnimationEnd = function() {};
+ ZammadChat.prototype.onOpenAnimationEnd = function() {
+ return this.idleTimeoutStop();
+ };
ZammadChat.prototype.close = function(event) {
if (this.state === 'off' || this.state === 'unsupported') {
@@ -415,10 +436,18 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
if (!this.sessionId) {
return;
}
+ this.send('chat_session_close', {
+ session_id: this.sessionId
+ });
+ this.inactiveTimeoutStop();
+ sessionStorage.removeItem('unfinished_message');
if (this.onInitialQueueDelayId) {
clearTimeout(this.onInitialQueueDelayId);
}
- return this.closeWindow();
+ if (event) {
+ this.closeWindow();
+ }
+ return this.setSessionId(void 0);
};
ZammadChat.prototype.closeWindow = function() {
@@ -434,11 +463,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.el.removeClass('zammad-chat-is-visible');
this.disconnect();
this.isOpen = false;
- this.send('chat_session_close', {
- session_id: this.sessionId
- });
- this.setSessionId(void 0);
- sessionStorage.removeItem('unfinished_message');
return this.onWebSocketOpen();
};
@@ -555,7 +579,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return this.el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight'));
};
- ZammadChat.prototype.session_init = function() {
+ ZammadChat.prototype.sessionInit = function() {
return this.send('chat_session_init');
};
@@ -604,6 +628,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
};
ZammadChat.prototype.onWebSocketOpen = function() {
+ this.idleTimeoutStart();
this.sessionId = sessionStorage.getItem('sessionId');
this.log('debug', 'ws connected');
this.send('chat_status_customer', {
@@ -630,7 +655,8 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
ZammadChat.prototype.onSessionClosed = function(data) {
this.addStatus(this.T('Chat closed by %s', data.realname));
this.disableInput();
- return this.setAgentOnlineState('offline');
+ this.setAgentOnlineState('offline');
+ return this.inactiveTimeoutStop();
};
ZammadChat.prototype.disconnect = function() {
@@ -673,11 +699,16 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
};
ZammadChat.prototype.showTimeout = function() {
- return this.el.find('.zammad-chat-body').html(this.view('timeout')({
+ var reload;
+ this.el.find('.zammad-chat-body').html(this.view('timeout')({
agent: this.agent.name,
- delay: 10,
- unit: this.T('minutes')
+ delay: this.options.inactiveTimeout
}));
+ this.close();
+ reload = function() {
+ return location.reload();
+ };
+ return this.el.find('.js-restart').click(reload);
};
ZammadChat.prototype.showLoader = function() {
@@ -709,6 +740,49 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return document.getElementsByTagName('head')[0].appendChild(newSS);
};
+ ZammadChat.prototype.inactiveTimeoutStart = function() {
+ var delay;
+ this.inactiveTimeoutStop();
+ delay = (function(_this) {
+ return function() {
+ _this.log('debug', "Inactive timeout of " + _this.options.inactiveTimeout + " minutes, show timeout screen.");
+ _this.state = 'off';
+ _this.setAgentOnlineState('offline');
+ _this.showTimeout();
+ return _this.wsClose();
+ };
+ })(this);
+ return this.inactiveTimeoutStopDelayId = setTimeout(delay, this.options.inactiveTimeout * 1000 * 60);
+ };
+
+ ZammadChat.prototype.inactiveTimeoutStop = function() {
+ if (!this.inactiveTimeoutStopDelayId) {
+ return;
+ }
+ return clearTimeout(this.inactiveTimeoutStopDelayId);
+ };
+
+ ZammadChat.prototype.idleTimeoutStart = function() {
+ var delay;
+ this.idleTimeoutStop();
+ delay = (function(_this) {
+ return function() {
+ _this.log('debug', "Idle timeout of " + _this.options.idleTimeout + " minutes, hide widget");
+ _this.state = 'off';
+ _this.hide();
+ return _this.wsClose();
+ };
+ })(this);
+ return this.idleTimeoutStopDelayId = setTimeout(delay, this.options.idleTimeout * 1000 * 60);
+ };
+
+ ZammadChat.prototype.idleTimeoutStop = function() {
+ if (!this.idleTimeoutStopDelayId) {
+ return;
+ }
+ return clearTimeout(this.idleTimeoutStopDelayId);
+ };
+
return ZammadChat;
})();
@@ -1159,9 +1233,17 @@ window.zammadChatTemplates["timeout"] = function (__obj) {
(function() {
__out.push('
\n
\n ');
- __out.push(this.T('Since you didn\'t respond in the last %s your conversation with %s got closed.', this.delay + " " + this.unit, this.agent));
+ if (this.agent) {
+ __out.push('\n ');
+ __out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation with %s got closed.', this.delay, this.agent));
+ __out.push('\n ');
+ } else {
+ __out.push('\n ');
+ __out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation got closed.', this.delay));
+ __out.push('\n ');
+ }
- __out.push(' \n
\n
Chat with us!"},s.prototype._messageCount=0,s.prototype.isOpen=!0,s.prototype.blinkOnlineInterval=null,s.prototype.stopBlinOnlineStateTimeout=null,s.prototype.showTimeEveryXMinutes=1,s.prototype.lastTimestamp=null,s.prototype.lastAddedType=null,s.prototype.inputTimeout=null,s.prototype.isTyping=!1,s.prototype.state="offline",s.prototype.initialQueueDelay=1e4,s.prototype.wsReconnectEnable=!0,s.prototype.translations={de:{"Chat with us!":"Chat mit uns!",Online:"Online",Online:"Online",Offline:"Offline",Connecting:"Verbinden","Connection re-established":"Verbindung wiederhergestellt",Today:"Heute",Send:"Senden","Compose your message...":"Ihre Nachricht...","All colleges are busy.":"Alle Kollegen sind belegt.","You are on waiting list position %s.":"Sie sind in der Warteliste an der Position %s.","Start new conversation":"Neue Konversation starten","Since you didn't respond in the last %s your conversation with %s got closed.":"Da sie in den letzten %s nichts geschrieben haben wurde ihre Konversation mit %s geschlossen.",minutes:"Minuten"}},s.prototype.sessionId=void 0,s.prototype.T=function(){var t,e,s,n,i,a;if(i=arguments[0],s=2<=arguments.length?slice.call(arguments,1):[],this.options.lang&&"en"!==this.options.lang&&(this.translations[this.options.lang]?(a=this.translations[this.options.lang],a[i]||this.log("notice","Translation needed for '"+i+"'"),i=a[i]||i):this.log("notice","Translation '"+this.options.lang+"' needed!")),s)for(t=0,n=s.length;n>t;t++)e=s[t],i=i.replace(/%s/,e);return i},s.prototype.log=function(){var t,e;return t=arguments[0],e=2<=arguments.length?slice.call(arguments,1):[],this.options.debug||"debug"!==t?(e.unshift(t),console.log.apply(console,e)):void 0},s.prototype.view=function(t){return function(s){return function(n){return n||(n={}),n.T=s.T,n.background=s.options.background,n.flat=s.options.flat,n.fontSize=s.options.fontSize,e.zammadChatTemplates[t](n)}}(this)},s.prototype.checkForEnter=function(t){return t.shiftKey||13!==t.keyCode?void 0:(t.preventDefault(),this.sendMessage())},s.prototype.send=function(t,e){var s;return null==e&&(e={}),e.chat_id=this.options.chatId,this.log("debug","ws:send",t,e),s=JSON.stringify({event:t,data:e}),this.ws.send(s)},s.prototype.onWebSocketMessage=function(t){var e,s,n,i;for(i=JSON.parse(t.data),e=0,s=i.length;s>e;e++)switch(n=i[e],this.log("debug","ws:onmessage",n),n.event){case"chat_error":this.log("error",n.data);break;case"chat_session_message":if(n.data.self_written)return;this.receiveMessage(n.data);break;case"chat_session_typing":if(n.data.self_written)return;this.onAgentTypingStart();break;case"chat_session_start":this.onConnectionEstablished(n.data);break;case"chat_session_queue":this.onQueueScreen(n.data);break;case"chat_session_closed":this.onSessionClosed(n.data);break;case"chat_session_left":this.onSessionClosed(n.data);break;case"chat_status_customer":switch(n.data.state){case"online":this.sessionId=void 0,this.onReady(),this.log("debug","Zammad Chat: ready");break;case"offline":this.onError("Zammad Chat: No agent online"),this.state="off",this.hide(),this.wsClose();break;case"chat_disabled":this.onError("Zammad Chat: Chat is disabled"),this.state="off",this.hide(),this.wsClose();break;case"no_seats_available":this.onError("Zammad Chat: Too many clients in queue. Clients in queue: "+n.data.queue),this.state="off",this.hide(),this.wsClose();break;case"reconnect":this.log("debug","old messages",n.data.session),this.reopenSession(n.data)}}},s.prototype.onReady=function(){return t("."+this.options.buttonClass).click(this.open).removeClass(this.inactiveClass),this.options.show?this.show():void 0},s.prototype.onError=function(e){return this.log("debug",e),t("."+this.options.buttonClass).hide()},s.prototype.reopenSession=function(t){var e,s,n,i,a;if(a=sessionStorage.getItem("unfinished_message"),t.agent){for(this.onConnectionEstablished(t),i=t.session,e=0,s=i.length;s>e;e++)n=i[e],this.renderMessage({message:n.content,id:n.id,from:n.created_by_id?"agent":"customer"});a&&this.input.val(a)}return t.position&&this.onQueue(t),this.show(),this.open(),this.scrollToBottom(),a?this.input.focus():void 0},s.prototype.onInput=function(){return this.el.find(".zammad-chat-message--unread").removeClass("zammad-chat-message--unread"),sessionStorage.setItem("unfinished_message",this.input.val()),this.onTyping()},s.prototype.onTyping=function(){return this.isTyping&&this.isTyping>new Date((new Date).getTime()-1500)?void 0:(this.isTyping=new Date,this.send("chat_session_typing",{session_id:this.sessionId}))},s.prototype.onSubmit=function(t){return t.preventDefault(),this.sendMessage()},s.prototype.sendMessage=function(){var t,e;return(t=this.input.val())?(sessionStorage.removeItem("unfinished_message"),e=this.view("message")({message:t,from:"customer",id:this._messageCount++}),this.maybeAddTimestamp(),this.el.find(".zammad-chat-message--typing").size()?(this.lastAddedType="typing-placeholder",this.el.find(".zammad-chat-message--typing").before(e)):(this.lastAddedType="message--customer",this.el.find(".zammad-chat-body").append(e)),this.input.val(""),this.scrollToBottom(),this.send("chat_session_message",{content:t,id:this._messageCount,session_id:this.sessionId})):void 0},s.prototype.receiveMessage=function(t){return this.onAgentTypingEnd(),this.maybeAddTimestamp(),this.renderMessage({message:t.message.content,id:t.id,from:"agent"})},s.prototype.renderMessage=function(t){var e,s;return this.lastAddedType="message--"+t.from,s=null!=(e=document.hidden)?e:{" zammad-chat-message--unread":""},this.el.find(".zammad-chat-body").append(this.view("message")(t)),this.scrollToBottom()},s.prototype.open=function(){return this.isOpen&&this.show(),this.sessionId||this.showLoader(),this.el.addClass("zammad-chat-is-open"),this.sessionId?(this.el.css("bottom",0),this.onOpenAnimationEnd()):this.el.animate({bottom:0},500,this.onOpenAnimationEnd),this.isOpen=!0,this.sessionId?void 0:this.session_init()},s.prototype.onOpenAnimationEnd=function(){},s.prototype.close=function(t){return"off"===this.state||"unsupported"===this.state?this.state:(t&&t.stopPropagation(),this.sessionId?(this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.closeWindow()):void 0)},s.prototype.closeWindow=function(){var t;return this.el.removeClass("zammad-chat-is-open"),t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-t},500,this.onCloseAnimationEnd)},s.prototype.onCloseAnimationEnd=function(){return this.el.removeClass("zammad-chat-is-visible"),this.disconnect(),this.isOpen=!1,this.send("chat_session_close",{session_id:this.sessionId}),this.setSessionId(void 0),sessionStorage.removeItem("unfinished_message"),this.onWebSocketOpen()},s.prototype.hide=function(){return this.el.removeClass("zammad-chat-is-shown")},s.prototype.show=function(){var t;return"off"===this.state||"unsupported"===this.state?this.state:(this.el.addClass("zammad-chat-is-shown"),this.inputInitialized||(this.inputInitialized=!0,this.input.autoGrow({extraLine:!1})),t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.css("bottom",-t))},s.prototype.disableInput=function(){return this.input.prop("disabled",!0),this.el.find(".zammad-chat-send").prop("disabled",!0)},s.prototype.enableInput=function(){return this.input.prop("disabled",!1),this.el.find(".zammad-chat-send").prop("disabled",!1)},s.prototype.onQueueScreen=function(t){var e;return this.setSessionId(t.session_id),e=function(e){return function(){return e.onQueue(t)}}(this),this.initialQueueDelay&&!this.onInitialQueueDelayId?void(this.onInitialQueueDelayId=setTimeout(e,this.initialQueueDelay)):(this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),e())},s.prototype.onQueue=function(t){return this.log("notice","onQueue",t.position),this.inQueue=!0,this.el.find(".zammad-chat-body").html(this.view("waiting")({position:t.position}))},s.prototype.onAgentTypingStart=function(){return this.stopTypingId&&clearTimeout(this.stopTypingId),this.stopTypingId=setTimeout(this.onAgentTypingEnd,3e3),this.el.find(".zammad-chat-message--typing").size()?void 0:(this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("typingIndicator")()),this.scrollToBottom())},s.prototype.onAgentTypingEnd=function(){return this.el.find(".zammad-chat-message--typing").remove()},s.prototype.maybeAddTimestamp=function(){var t,e,s;return s=Date.now(),!this.lastTimestamp||s-this.lastTimestamp>6e4*this.showTimeEveryXMinutes?(t=this.T("Today"),e=(new Date).toTimeString().substr(0,5),"timestamp"===this.lastAddedType?(this.updateLastTimestamp(t,e),this.lastTimestamp=s):(this.el.find(".zammad-chat-body").append(this.view("timestamp")({label:t,time:e})),this.lastTimestamp=s,this.lastAddedType="timestamp",this.scrollToBottom())):void 0},s.prototype.updateLastTimestamp=function(t,e){return this.el.find(".zammad-chat-body").find(".zammad-chat-timestamp").last().replaceWith(this.view("timestamp")({label:t,time:e}))},s.prototype.addStatus=function(t){return this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("status")({status:t})),this.scrollToBottom()},s.prototype.scrollToBottom=function(){return this.el.find(".zammad-chat-body").scrollTop(t(".zammad-chat-body").prop("scrollHeight"))},s.prototype.session_init=function(){return this.send("chat_session_init")},s.prototype.detectHost=function(){var t;return t="ws://","https:"===e.location.protocol&&(t="wss://"),this.options.host=""+t+i+"/ws"},s.prototype.wsConnect=function(){return this.options.host||this.detectHost(),this.log("debug","Connecting to "+this.options.host),this.ws=new e.WebSocket(""+this.options.host),this.ws.onopen=this.onWebSocketOpen,this.ws.onmessage=this.onWebSocketMessage,this.ws.onclose=function(t){return function(e){return t.log("debug","close websocket connection"),t.wsReconnectEnable?t.reconnect():void 0}}(this),this.ws.onerror=function(t){return function(e){return t.log("debug","ws:onerror",e)}}(this)},s.prototype.wsClose=function(){return this.wsReconnectEnable=!1,this.ws.close()},s.prototype.wsReconnect=function(){return this.reconnectDelayId&&clearTimeout(this.reconnectDelayId),this.reconnectDelayId=setTimeout(this.wsConnect,5e3)},s.prototype.onWebSocketOpen=function(){return this.sessionId=sessionStorage.getItem("sessionId"),this.log("debug","ws connected"),this.send("chat_status_customer",{session_id:this.sessionId}),this.setAgentOnlineState("online")},s.prototype.reconnect=function(){return this.log("notice","reconnecting"),this.disableInput(),this.lastAddedType="status",this.setAgentOnlineState("connecting"),this.addStatus(this.T("Connection lost")),this.wsReconnect()},s.prototype.onConnectionReestablished=function(){return this.lastAddedType="status",this.setAgentOnlineState("online"),this.addStatus(this.T("Connection re-established"))},s.prototype.onSessionClosed=function(t){return this.addStatus(this.T("Chat closed by %s",t.realname)),this.disableInput(),this.setAgentOnlineState("offline")},s.prototype.disconnect=function(){return this.showLoader(),this.el.find(".zammad-chat-welcome").removeClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent").addClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent-status").addClass("zammad-chat-is-hidden")},s.prototype.setSessionId=function(t){return this.sessionId=t,void 0===t?sessionStorage.removeItem("sessionId"):sessionStorage.setItem("sessionId",t)},s.prototype.onConnectionEstablished=function(t){return this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.inQueue=!1,t.agent&&(this.agent=t.agent),t.session_id&&this.setSessionId(t.session_id),this.el.find(".zammad-chat-agent").html(this.view("agent")({agent:this.agent})),this.enableInput(),this.el.find(".zammad-chat-body").empty(),this.el.find(".zammad-chat-welcome").addClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent").removeClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent-status").removeClass("zammad-chat-is-hidden"),this.input.focus(),this.setAgentOnlineState("online")},s.prototype.showTimeout=function(){return this.el.find(".zammad-chat-body").html(this.view("timeout")({agent:this.agent.name,delay:10,unit:this.T("minutes")}))},s.prototype.showLoader=function(){return this.el.find(".zammad-chat-body").html(this.view("loader")())},s.prototype.setAgentOnlineState=function(t){var e;return this.state=t,e=t.charAt(0).toUpperCase()+t.slice(1),this.el.find(".zammad-chat-agent-status").attr("data-status",t).text(this.T(e))},s.prototype.loadCss=function(){var t,e,s;if(this.options.cssAutoload)return s=this.options.cssUrl,s||(s=this.options.host.replace(/^wss/i,"https").replace(/^ws/i,"http").replace(/\/ws/i,""),s+="/assets/chat/chat.css"),this.log("debug","load css from '"+s+"'"),e="@import url('"+s+"');",t=document.createElement("link"),t.rel="stylesheet",t.href="data:text/css,"+escape(e),document.getElementsByTagName("head")[0].appendChild(t)},s}(),e.ZammadChat=s}(window.jQuery,window),window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.agent=function(t){t||(t={});var e,s=[],n=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?a(t):""},i=t.safe,a=t.escape;return e=t.safe=function(t){if(t&&t.ecoSafe)return t;("undefined"==typeof t||null==t)&&(t="");var e=new String(t);return e.ecoSafe=!0,e},a||(a=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){this.agent.avatar&&(s.push('\n\n')),s.push('\n\n '),s.push(n(this.agent.name)),s.push("\n")}).call(this)}.call(t),t.safe=i,t.escape=a,s.join("")},jQuery.fn.autoGrow=function(t){return this.each(function(){var e=jQuery.extend({extraLine:!0},t),s=function(t){return jQuery(t).after(''),jQuery(t).next(".autogrow-textarea-mirror")[0]},n=function(t){a.innerHTML=String(t.value).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/ /g," ").replace(/\n/g," ")+(e.extraLine?". .":""),jQuery(t).height()!=jQuery(a).height()&&jQuery(t).height(jQuery(a).height())},i=function(){n(this)},a=s(this);a.style.display="none",a.style.wordWrap="break-word",a.style.whiteSpace="normal",a.style.padding=jQuery(this).css("paddingTop")+" "+jQuery(this).css("paddingRight")+" "+jQuery(this).css("paddingBottom")+" "+jQuery(this).css("paddingLeft"),a.style.width=jQuery(this).css("width"),a.style.fontFamily=jQuery(this).css("font-family"),a.style.fontSize=jQuery(this).css("font-size"),a.style.lineHeight=jQuery(this).css("line-height"),this.style.overflow="hidden",this.style.minHeight=this.rows+"em",this.onkeyup=i,n(this)})},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.chat=function(t){t||(t={});var e,s=[],n=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?a(t):""},i=t.safe,a=t.escape;return e=t.safe=function(t){if(t&&t.ecoSafe)return t;("undefined"==typeof t||null==t)&&(t="");var e=new String(t);return e.ecoSafe=!0,e},a||(a=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n \n \n \n \n \n '),s.push(this.T("All colleges are busy.")),s.push(" \n "),s.push(this.T("You are on waiting list position %s.",this.position)),s.push("\n
\n
")}).call(this)}.call(t),t.safe=n,t.escape=i,s.join("")};
\ No newline at end of file
+var bind=function(t,e){return function(){return t.apply(e,arguments)}},slice=[].slice;!function(t,e){var s,n,i,a;return a=document.getElementsByTagName("script"),n=a[a.length-1],i=n.src.match(".*://([^:/]*).*")[1],s=function(){function s(s){return this.idleTimeoutStop=bind(this.idleTimeoutStop,this),this.idleTimeoutStart=bind(this.idleTimeoutStart,this),this.inactiveTimeoutStop=bind(this.inactiveTimeoutStop,this),this.inactiveTimeoutStart=bind(this.inactiveTimeoutStart,this),this.setAgentOnlineState=bind(this.setAgentOnlineState,this),this.onConnectionEstablished=bind(this.onConnectionEstablished,this),this.setSessionId=bind(this.setSessionId,this),this.onConnectionReestablished=bind(this.onConnectionReestablished,this),this.reconnect=bind(this.reconnect,this),this.onWebSocketOpen=bind(this.onWebSocketOpen,this),this.wsReconnect=bind(this.wsReconnect,this),this.wsClose=bind(this.wsClose,this),this.wsConnect=bind(this.wsConnect,this),this.onAgentTypingEnd=bind(this.onAgentTypingEnd,this),this.onAgentTypingStart=bind(this.onAgentTypingStart,this),this.onQueue=bind(this.onQueue,this),this.onQueueScreen=bind(this.onQueueScreen,this),this.onCloseAnimationEnd=bind(this.onCloseAnimationEnd,this),this.closeWindow=bind(this.closeWindow,this),this.close=bind(this.close,this),this.onOpenAnimationEnd=bind(this.onOpenAnimationEnd,this),this.open=bind(this.open,this),this.renderMessage=bind(this.renderMessage,this),this.receiveMessage=bind(this.receiveMessage,this),this.onSubmit=bind(this.onSubmit,this),this.onInput=bind(this.onInput,this),this.reopenSession=bind(this.reopenSession,this),this.onError=bind(this.onError,this),this.onReady=bind(this.onReady,this),this.onWebSocketMessage=bind(this.onWebSocketMessage,this),this.send=bind(this.send,this),this.checkForEnter=bind(this.checkForEnter,this),this.view=bind(this.view,this),this.log=bind(this.log,this),this.T=bind(this.T,this),this.options=t.extend({},this.defaults,s),t?e.WebSocket&&sessionStorage?this.options.chatId?(this.options.lang||(this.options.lang=t("html").attr("lang")),this.options.lang&&(this.options.lang=this.options.lang.replace(/-.+?$/,""),this.log("debug","lang: "+this.options.lang)),this.el=t(this.view("chat")({title:this.options.title})),this.options.target.append(this.el),this.input=this.el.find(".zammad-chat-input"),t("."+this.options.buttonClass).addClass(this.inactiveClass),this.el.find(".js-chat-open").click(this.open),this.el.find(".js-chat-close").click(this.close),this.el.find(".zammad-chat-controls").on("submit",this.onSubmit),this.input.on({keydown:this.checkForEnter,input:this.onInput}),this.wsConnect(),void this.loadCss()):(this.state="unsupported",void this.log("error","Chat: need chatId as option!")):(this.state="unsupported",void this.log("notice","Chat: Browser not supported!")):(this.state="unsupported",void this.log("notice","Chat: no jquery found!"))}return s.prototype.defaults={chatId:void 0,show:!0,target:t("body"),host:"",debug:!1,flat:!1,lang:void 0,cssAutoload:!0,cssUrl:void 0,fontSize:void 0,buttonClass:"open-zammad-chat",inactiveClass:"is-inactive",title:"Chat with us!",idleTimeout:8,inactiveTimeout:20},s.prototype._messageCount=0,s.prototype.isOpen=!0,s.prototype.blinkOnlineInterval=null,s.prototype.stopBlinOnlineStateTimeout=null,s.prototype.showTimeEveryXMinutes=1,s.prototype.lastTimestamp=null,s.prototype.lastAddedType=null,s.prototype.inputTimeout=null,s.prototype.isTyping=!1,s.prototype.state="offline",s.prototype.initialQueueDelay=1e4,s.prototype.wsReconnectEnable=!0,s.prototype.translations={de:{"Chat with us!":"Chat mit uns!",Online:"Online",Online:"Online",Offline:"Offline",Connecting:"Verbinden","Connection re-established":"Verbindung wiederhergestellt",Today:"Heute",Send:"Senden","Compose your message...":"Ihre Nachricht...","All colleges are busy.":"Alle Kollegen sind belegt.","You are on waiting list position %s.":"Sie sind in der Warteliste an der Position %s.","Start new conversation":"Neue Konversation starten","Since you didn't respond in the last %s minutes your conversation with %s got closed.":"Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation mit %s geschlossen.","Since you didn't respond in the last %s minutes your conversation got closed.":"Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation geschlossen."}},s.prototype.sessionId=void 0,s.prototype.T=function(){var t,e,s,n,i,a;if(i=arguments[0],s=2<=arguments.length?slice.call(arguments,1):[],this.options.lang&&"en"!==this.options.lang&&(this.translations[this.options.lang]?(a=this.translations[this.options.lang],a[i]||this.log("notice","Translation needed for '"+i+"'"),i=a[i]||i):this.log("notice","Translation '"+this.options.lang+"' needed!")),s)for(t=0,n=s.length;n>t;t++)e=s[t],i=i.replace(/%s/,e);return i},s.prototype.log=function(){var t,e;return t=arguments[0],e=2<=arguments.length?slice.call(arguments,1):[],this.options.debug||"debug"!==t?(e.unshift(t),console.log.apply(console,e)):void 0},s.prototype.view=function(t){return function(s){return function(n){return n||(n={}),n.T=s.T,n.background=s.options.background,n.flat=s.options.flat,n.fontSize=s.options.fontSize,e.zammadChatTemplates[t](n)}}(this)},s.prototype.checkForEnter=function(t){return t.shiftKey||13!==t.keyCode?void 0:(t.preventDefault(),this.sendMessage())},s.prototype.send=function(t,e){var s;return null==e&&(e={}),e.chat_id=this.options.chatId,this.log("debug","ws:send",t,e),s=JSON.stringify({event:t,data:e}),this.ws.send(s)},s.prototype.onWebSocketMessage=function(t){var e,s,n,i;for(i=JSON.parse(t.data),e=0,s=i.length;s>e;e++)switch(n=i[e],this.log("debug","ws:onmessage",n),n.event){case"chat_error":this.log("notice",n.data),n.data&&"chat_disabled"===n.data.state&&this.wsClose();break;case"chat_session_message":if(n.data.self_written)return;this.receiveMessage(n.data);break;case"chat_session_typing":if(n.data.self_written)return;this.onAgentTypingStart();break;case"chat_session_start":this.onConnectionEstablished(n.data);break;case"chat_session_queue":this.onQueueScreen(n.data);break;case"chat_session_closed":this.onSessionClosed(n.data);break;case"chat_session_left":this.onSessionClosed(n.data);break;case"chat_status_customer":switch(n.data.state){case"online":this.sessionId=void 0,this.onReady(),this.log("debug","Zammad Chat: ready");break;case"offline":this.onError("Zammad Chat: No agent online"),this.state="off",this.hide(),this.wsClose();break;case"chat_disabled":this.onError("Zammad Chat: Chat is disabled"),this.state="off",this.hide(),this.wsClose();break;case"no_seats_available":this.onError("Zammad Chat: Too many clients in queue. Clients in queue: "+n.data.queue),this.state="off",this.hide(),this.wsClose();break;case"reconnect":this.log("debug","old messages",n.data.session),this.reopenSession(n.data)}}},s.prototype.onReady=function(){return t("."+this.options.buttonClass).click(this.open).removeClass(this.inactiveClass),this.options.show?this.show():void 0},s.prototype.onError=function(e){return this.log("debug",e),t("."+this.options.buttonClass).hide()},s.prototype.reopenSession=function(t){var e,s,n,i,a;if(this.inactiveTimeoutStart(),a=sessionStorage.getItem("unfinished_message"),t.agent){for(this.onConnectionEstablished(t),i=t.session,e=0,s=i.length;s>e;e++)n=i[e],this.renderMessage({message:n.content,id:n.id,from:n.created_by_id?"agent":"customer"});a&&this.input.val(a)}return t.position&&this.onQueue(t),this.show(),this.open(),this.scrollToBottom(),a?this.input.focus():void 0},s.prototype.onInput=function(){return this.el.find(".zammad-chat-message--unread").removeClass("zammad-chat-message--unread"),sessionStorage.setItem("unfinished_message",this.input.val()),this.onTyping()},s.prototype.onTyping=function(){return this.isTyping&&this.isTyping>new Date((new Date).getTime()-1500)?void 0:(this.isTyping=new Date,this.send("chat_session_typing",{session_id:this.sessionId}),this.inactiveTimeoutStart())},s.prototype.onSubmit=function(t){return t.preventDefault(),this.sendMessage()},s.prototype.sendMessage=function(){var t,e;return(t=this.input.val())?(this.inactiveTimeoutStart(),sessionStorage.removeItem("unfinished_message"),e=this.view("message")({message:t,from:"customer",id:this._messageCount++}),this.maybeAddTimestamp(),this.el.find(".zammad-chat-message--typing").size()?(this.lastAddedType="typing-placeholder",this.el.find(".zammad-chat-message--typing").before(e)):(this.lastAddedType="message--customer",this.el.find(".zammad-chat-body").append(e)),this.input.val(""),this.scrollToBottom(),this.send("chat_session_message",{content:t,id:this._messageCount,session_id:this.sessionId})):void 0},s.prototype.receiveMessage=function(t){return this.inactiveTimeoutStart(),this.onAgentTypingEnd(),this.maybeAddTimestamp(),this.renderMessage({message:t.message.content,id:t.id,from:"agent"})},s.prototype.renderMessage=function(t){var e,s;return this.lastAddedType="message--"+t.from,s=null!=(e=document.hidden)?e:{" zammad-chat-message--unread":""},this.el.find(".zammad-chat-body").append(this.view("message")(t)),this.scrollToBottom()},s.prototype.open=function(){return this.isOpen&&this.show(),this.sessionId||this.showLoader(),this.el.addClass("zammad-chat-is-open"),this.sessionId?(this.el.css("bottom",0),this.onOpenAnimationEnd()):this.el.animate({bottom:0},500,this.onOpenAnimationEnd),this.isOpen=!0,this.sessionId?void 0:this.sessionInit()},s.prototype.onOpenAnimationEnd=function(){return this.idleTimeoutStop()},s.prototype.close=function(t){return"off"===this.state||"unsupported"===this.state?this.state:(t&&t.stopPropagation(),this.sessionId?(this.send("chat_session_close",{session_id:this.sessionId}),this.inactiveTimeoutStop(),sessionStorage.removeItem("unfinished_message"),this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),t&&this.closeWindow(),this.setSessionId(void 0)):void 0)},s.prototype.closeWindow=function(){var t;return this.el.removeClass("zammad-chat-is-open"),t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-t},500,this.onCloseAnimationEnd)},s.prototype.onCloseAnimationEnd=function(){return this.el.removeClass("zammad-chat-is-visible"),this.disconnect(),this.isOpen=!1,this.onWebSocketOpen()},s.prototype.hide=function(){return this.el.removeClass("zammad-chat-is-shown")},s.prototype.show=function(){var t;return"off"===this.state||"unsupported"===this.state?this.state:(this.el.addClass("zammad-chat-is-shown"),this.inputInitialized||(this.inputInitialized=!0,this.input.autoGrow({extraLine:!1})),t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.css("bottom",-t))},s.prototype.disableInput=function(){return this.input.prop("disabled",!0),this.el.find(".zammad-chat-send").prop("disabled",!0)},s.prototype.enableInput=function(){return this.input.prop("disabled",!1),this.el.find(".zammad-chat-send").prop("disabled",!1)},s.prototype.onQueueScreen=function(t){var e;return this.setSessionId(t.session_id),e=function(e){return function(){return e.onQueue(t)}}(this),this.initialQueueDelay&&!this.onInitialQueueDelayId?void(this.onInitialQueueDelayId=setTimeout(e,this.initialQueueDelay)):(this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),e())},s.prototype.onQueue=function(t){return this.log("notice","onQueue",t.position),this.inQueue=!0,this.el.find(".zammad-chat-body").html(this.view("waiting")({position:t.position}))},s.prototype.onAgentTypingStart=function(){return this.stopTypingId&&clearTimeout(this.stopTypingId),this.stopTypingId=setTimeout(this.onAgentTypingEnd,3e3),this.el.find(".zammad-chat-message--typing").size()?void 0:(this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("typingIndicator")()),this.scrollToBottom())},s.prototype.onAgentTypingEnd=function(){return this.el.find(".zammad-chat-message--typing").remove()},s.prototype.maybeAddTimestamp=function(){var t,e,s;return s=Date.now(),!this.lastTimestamp||s-this.lastTimestamp>6e4*this.showTimeEveryXMinutes?(t=this.T("Today"),e=(new Date).toTimeString().substr(0,5),"timestamp"===this.lastAddedType?(this.updateLastTimestamp(t,e),this.lastTimestamp=s):(this.el.find(".zammad-chat-body").append(this.view("timestamp")({label:t,time:e})),this.lastTimestamp=s,this.lastAddedType="timestamp",this.scrollToBottom())):void 0},s.prototype.updateLastTimestamp=function(t,e){return this.el.find(".zammad-chat-body").find(".zammad-chat-timestamp").last().replaceWith(this.view("timestamp")({label:t,time:e}))},s.prototype.addStatus=function(t){return this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("status")({status:t})),this.scrollToBottom()},s.prototype.scrollToBottom=function(){return this.el.find(".zammad-chat-body").scrollTop(t(".zammad-chat-body").prop("scrollHeight"))},s.prototype.sessionInit=function(){return this.send("chat_session_init")},s.prototype.detectHost=function(){var t;return t="ws://","https:"===e.location.protocol&&(t="wss://"),this.options.host=""+t+i+"/ws"},s.prototype.wsConnect=function(){return this.options.host||this.detectHost(),this.log("debug","Connecting to "+this.options.host),this.ws=new e.WebSocket(""+this.options.host),this.ws.onopen=this.onWebSocketOpen,this.ws.onmessage=this.onWebSocketMessage,this.ws.onclose=function(t){return function(e){return t.log("debug","close websocket connection"),t.wsReconnectEnable?t.reconnect():void 0}}(this),this.ws.onerror=function(t){return function(e){return t.log("debug","ws:onerror",e)}}(this)},s.prototype.wsClose=function(){return this.wsReconnectEnable=!1,this.ws.close()},s.prototype.wsReconnect=function(){return this.reconnectDelayId&&clearTimeout(this.reconnectDelayId),this.reconnectDelayId=setTimeout(this.wsConnect,5e3)},s.prototype.onWebSocketOpen=function(){return this.idleTimeoutStart(),this.sessionId=sessionStorage.getItem("sessionId"),this.log("debug","ws connected"),this.send("chat_status_customer",{session_id:this.sessionId}),this.setAgentOnlineState("online")},s.prototype.reconnect=function(){return this.log("notice","reconnecting"),this.disableInput(),this.lastAddedType="status",this.setAgentOnlineState("connecting"),this.addStatus(this.T("Connection lost")),this.wsReconnect()},s.prototype.onConnectionReestablished=function(){return this.lastAddedType="status",this.setAgentOnlineState("online"),this.addStatus(this.T("Connection re-established"))},s.prototype.onSessionClosed=function(t){return this.addStatus(this.T("Chat closed by %s",t.realname)),this.disableInput(),this.setAgentOnlineState("offline"),this.inactiveTimeoutStop()},s.prototype.disconnect=function(){return this.showLoader(),this.el.find(".zammad-chat-welcome").removeClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent").addClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent-status").addClass("zammad-chat-is-hidden")},s.prototype.setSessionId=function(t){return this.sessionId=t,void 0===t?sessionStorage.removeItem("sessionId"):sessionStorage.setItem("sessionId",t)},s.prototype.onConnectionEstablished=function(t){return this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.inQueue=!1,t.agent&&(this.agent=t.agent),t.session_id&&this.setSessionId(t.session_id),this.el.find(".zammad-chat-agent").html(this.view("agent")({agent:this.agent})),this.enableInput(),this.el.find(".zammad-chat-body").empty(),this.el.find(".zammad-chat-welcome").addClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent").removeClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent-status").removeClass("zammad-chat-is-hidden"),this.input.focus(),this.setAgentOnlineState("online")},s.prototype.showTimeout=function(){var t;return this.el.find(".zammad-chat-body").html(this.view("timeout")({agent:this.agent.name,delay:this.options.inactiveTimeout})),this.close(),t=function(){return location.reload()},this.el.find(".js-restart").click(t)},s.prototype.showLoader=function(){return this.el.find(".zammad-chat-body").html(this.view("loader")())},s.prototype.setAgentOnlineState=function(t){var e;return this.state=t,e=t.charAt(0).toUpperCase()+t.slice(1),this.el.find(".zammad-chat-agent-status").attr("data-status",t).text(this.T(e))},s.prototype.loadCss=function(){var t,e,s;if(this.options.cssAutoload)return s=this.options.cssUrl,s||(s=this.options.host.replace(/^wss/i,"https").replace(/^ws/i,"http").replace(/\/ws/i,""),s+="/assets/chat/chat.css"),this.log("debug","load css from '"+s+"'"),e="@import url('"+s+"');",t=document.createElement("link"),t.rel="stylesheet",t.href="data:text/css,"+escape(e),document.getElementsByTagName("head")[0].appendChild(t)},s.prototype.inactiveTimeoutStart=function(){var t;return this.inactiveTimeoutStop(),t=function(t){return function(){return t.log("debug","Inactive timeout of "+t.options.inactiveTimeout+" minutes, show timeout screen."),t.state="off",t.setAgentOnlineState("offline"),t.showTimeout(),t.wsClose()}}(this),this.inactiveTimeoutStopDelayId=setTimeout(t,1e3*this.options.inactiveTimeout*60)},s.prototype.inactiveTimeoutStop=function(){return this.inactiveTimeoutStopDelayId?clearTimeout(this.inactiveTimeoutStopDelayId):void 0},s.prototype.idleTimeoutStart=function(){var t;return this.idleTimeoutStop(),t=function(t){return function(){return t.log("debug","Idle timeout of "+t.options.idleTimeout+" minutes, hide widget"),t.state="off",t.hide(),t.wsClose()}}(this),this.idleTimeoutStopDelayId=setTimeout(t,1e3*this.options.idleTimeout*60)},s.prototype.idleTimeoutStop=function(){return this.idleTimeoutStopDelayId?clearTimeout(this.idleTimeoutStopDelayId):void 0},s}(),e.ZammadChat=s}(window.jQuery,window),window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.agent=function(t){t||(t={});var e,s=[],n=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?a(t):""},i=t.safe,a=t.escape;return e=t.safe=function(t){if(t&&t.ecoSafe)return t;("undefined"==typeof t||null==t)&&(t="");var e=new String(t);return e.ecoSafe=!0,e},a||(a=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){this.agent.avatar&&(s.push('\n\n')),s.push('\n\n '),s.push(n(this.agent.name)),s.push("\n")}).call(this)}.call(t),t.safe=i,t.escape=a,s.join("")},jQuery.fn.autoGrow=function(t){return this.each(function(){var e=jQuery.extend({extraLine:!0},t),s=function(t){return jQuery(t).after(''),jQuery(t).next(".autogrow-textarea-mirror")[0]},n=function(t){a.innerHTML=String(t.value).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/ /g," ").replace(/\n/g," ")+(e.extraLine?". .":""),jQuery(t).height()!=jQuery(a).height()&&jQuery(t).height(jQuery(a).height())},i=function(){n(this)},a=s(this);a.style.display="none",a.style.wordWrap="break-word",a.style.whiteSpace="normal",a.style.padding=jQuery(this).css("paddingTop")+" "+jQuery(this).css("paddingRight")+" "+jQuery(this).css("paddingBottom")+" "+jQuery(this).css("paddingLeft"),a.style.width=jQuery(this).css("width"),a.style.fontFamily=jQuery(this).css("font-family"),a.style.fontSize=jQuery(this).css("font-size"),a.style.lineHeight=jQuery(this).css("line-height"),this.style.overflow="hidden",this.style.minHeight=this.rows+"em",this.onkeyup=i,n(this)})},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.chat=function(t){t||(t={});var e,s=[],n=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?a(t):""},i=t.safe,a=t.escape;return e=t.safe=function(t){if(t&&t.ecoSafe)return t;("undefined"==typeof t||null==t)&&(t="");var e=new String(t);return e.ecoSafe=!0,e},a||(a=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n '),this.agent?(s.push("\n "),s.push(this.T("Since you didn't respond in the last %s minutes your conversation with %s got closed.",this.delay,this.agent)),s.push("\n ")):(s.push("\n "),s.push(this.T("Since you didn't respond in the last %s minutes your conversation got closed.",this.delay)),s.push("\n ")),s.push('\n \n
"),s.push(this.T("Start new conversation")),s.push("
\n \n \n \n \n \n '),s.push(this.T("All colleges are busy.")),s.push(" \n "),s.push(this.T("You are on waiting list position %s.",this.position)),s.push("\n
\n
")}).call(this)}.call(t),t.safe=n,t.escape=i,s.join("")};
\ No newline at end of file
diff --git a/public/assets/chat/views/timeout.eco b/public/assets/chat/views/timeout.eco
index 7c6a45dda..b66dbc836 100644
--- a/public/assets/chat/views/timeout.eco
+++ b/public/assets/chat/views/timeout.eco
@@ -1,6 +1,11 @@
- <%- @T('Since you didn\'t respond in the last %s your conversation with %s got closed.', "#{ @delay } #{ @unit }", @agent) %>
-
><%- @T('Start new conversation') %>
+ <% if @agent: %>
+ <%- @T('Since you didn\'t respond in the last %s minutes your conversation with %s got closed.', @delay, @agent) %>
+ <% else: %>
+ <%- @T('Since you didn\'t respond in the last %s minutes your conversation got closed.', @delay) %>
+ <% end %>
+
+