From 77aeb271f8644c3d3375b40a653caba0dd25cee0 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Thu, 12 Nov 2015 15:05:43 +0100 Subject: [PATCH] chat client: fix merge --- public/assets/chat/chat.coffee | 27 +- public/assets/chat/chat.js | 1075 +++++++++++++++++--------------- public/assets/chat/chat.min.js | 2 +- 3 files changed, 600 insertions(+), 504 deletions(-) diff --git a/public/assets/chat/chat.coffee b/public/assets/chat/chat.coffee index caba4c73b..8171d2e34 100644 --- a/public/assets/chat/chat.coffee +++ b/public/assets/chat/chat.coffee @@ -133,6 +133,8 @@ do($ = window.jQuery, window) -> @show() openSession: (session) => + unfinishedMessage = sessionStorage.getItem 'unfinished_message' + for message in session console.log "message in session", message @renderMessage @@ -140,14 +142,17 @@ do($ = window.jQuery, window) -> id: message.id from: if message.created_by_id then 'agent' else 'customer' - if sessionStorage.getItem 'unfinished_message' - @input.val( sessionStorage.getItem('unfinished_message') ).focus() + if unfinishedMessage + @input.val unfinishedMessage @show() @open showLoader: false animate: false + if unfinishedMessage + @input.focus() + onInput: => # remove unread-state from messages @el.find('.zammad-chat-message--unread') @@ -199,7 +204,7 @@ do($ = window.jQuery, window) -> @lastAddedType = 'message--customer' @el.find('.zammad-chat-body').append messageElement - @el.find('.zammad-chat-input').val('') + @input.val('') @scrollToBottom() @isTyping = false @@ -283,15 +288,15 @@ do($ = window.jQuery, window) -> @el.css 'bottom', -remainerHeight - @el.find('.zammad-chat-input').autoGrow + @input.autoGrow extraLine: false disableInput: -> - @el.find('.zammad-chat-input').prop('disabled', true) + @input.prop('disabled', true) @el.find('.zammad-chat-send').prop('disabled', true) enableInput: -> - @el.find('.zammad-chat-input').prop('disabled', false) + @input.prop('disabled', false) @el.find('.zammad-chat-send').prop('disabled', false) onQueueScreen: (data) => @@ -423,11 +428,15 @@ do($ = window.jQuery, window) -> @el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden') @el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden') - onConnectionEstablished: (agent) => + setSessionId: (id) => + @sessionId = id + sessionStorage.setItem 'sessionId', id + + onConnectionEstablished: (data) => # stop delay of initial queue position if @onInitialQueueDelayId - clearTimeout(@onInitialQueueDelayId) + clearTimeout @onInitialQueueDelayId @inQueue = false @agent = data.agent @@ -442,7 +451,7 @@ do($ = window.jQuery, window) -> @el.find('.zammad-chat-welcome').addClass('zammad-chat-is-hidden') @el.find('.zammad-chat-agent').removeClass('zammad-chat-is-hidden') @el.find('.zammad-chat-agent-status').removeClass('zammad-chat-is-hidden') - @el.find('.zammad-chat-input').focus() + @input.focus() showLoader: -> @el.find('.zammad-chat-body').html @view('loader')() diff --git a/public/assets/chat/chat.js b/public/assets/chat/chat.js index 7772596ad..78401e3c4 100644 --- a/public/assets/chat/chat.js +++ b/public/assets/chat/chat.js @@ -1,497 +1,3 @@ -var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - slice = [].slice; - -(function($, window) { - var ZammadChat; - ZammadChat = (function() { - ZammadChat.prototype.defaults = { - invitationPhrase: 'Chat with us!', - agentPhrase: ' is helping you', - show: true, - target: $('body') - }; - - ZammadChat.prototype._messageCount = 0; - - ZammadChat.prototype.isOpen = false; - - ZammadChat.prototype.blinkOnlineInterval = null; - - ZammadChat.prototype.stopBlinOnlineStateTimeout = null; - - ZammadChat.prototype.showTimeEveryXMinutes = 1; - - ZammadChat.prototype.lastTimestamp = null; - - ZammadChat.prototype.lastAddedType = null; - - ZammadChat.prototype.inputTimeout = null; - - ZammadChat.prototype.isTyping = false; - - ZammadChat.prototype.isOnline = true; - - ZammadChat.prototype.debug = true; - - ZammadChat.prototype.host = 'ws://localhost:6042'; - - ZammadChat.prototype.strings = { - 'Online': 'Online', - 'Offline': 'Offline', - 'Connecting': 'Verbinden', - 'Connection re-established': 'Connection re-established', - '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.', - '': '', - '': '', - '': '' - }; - - ZammadChat.prototype.sessionId = void 0; - - ZammadChat.prototype.T = function() { - var i, item, items, len, string, translation; - string = arguments[0], items = 2 <= arguments.length ? slice.call(arguments, 1) : []; - if (!this.strings[string]) { - this.log('notice', "Translation needed for '" + string + "'"); - } - translation = this.strings[string] || string; - if (items) { - for (i = 0, len = items.length; i < len; i++) { - item = items[i]; - translation = translation.replace(/%s/, item); - } - } - return translation; - }; - - ZammadChat.prototype.log = function() { - var level, string; - level = arguments[0], string = 2 <= arguments.length ? slice.call(arguments, 1) : []; - if (!this.debug && level === 'debug') { - return; - } - return console.log(level, string); - }; - - ZammadChat.prototype.view = function(name) { - return (function(_this) { - return function(options) { - if (!options) { - options = {}; - } - options.T = _this.T; - return window.zammadChatTemplates[name](options); - }; - })(this); - }; - - function ZammadChat(el, options) { - this.setAgentOnlineState = bind(this.setAgentOnlineState, this); - this.onConnectionEstablished = bind(this.onConnectionEstablished, this); - this.onConnectionReestablished = bind(this.onConnectionReestablished, this); - this.reconnect = bind(this.reconnect, this); - this.connect = bind(this.connect, this); - this.onAgentTypingEnd = bind(this.onAgentTypingEnd, this); - this.onAgentTypingStart = bind(this.onAgentTypingStart, this); - this.onQueue = bind(this.onQueue, this); - this.onCloseAnimationEnd = bind(this.onCloseAnimationEnd, this); - this.close = bind(this.close, this); - this.onOpenAnimationEnd = bind(this.onOpenAnimationEnd, this); - this.open = bind(this.open, this); - this.receiveMessage = bind(this.receiveMessage, this); - this.onSubmit = bind(this.onSubmit, this); - this.onTypingEnd = bind(this.onTypingEnd, this); - this.onInput = bind(this.onInput, 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 = $.extend({}, this.defaults, options); - this.el = $(this.view('chat')(this.options)); - this.options.target.append(this.el); - 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.el.find('.zammad-chat-input').on({ - keydown: this.checkForEnter, - input: this.onInput - }); - if (!window.WebSocket) { - this.log('notice', 'Chat: Browser not supported!'); - return; - } - this.connect(); - this.onReady(); - } - - ZammadChat.prototype.checkForEnter = function(event) { - if (!event.shiftKey && event.keyCode === 13) { - event.preventDefault(); - return this.sendMessage(); - } - }; - - ZammadChat.prototype.send = function(event, data) { - var pipe; - this.log('debug', 'ws:send', event, data); - pipe = JSON.stringify({ - event: event, - data: data - }); - return this.ws.send(pipe); - }; - - ZammadChat.prototype.onWebSocketMessage = function(e) { - var i, len, pipe, pipes; - pipes = JSON.parse(e.data); - this.log('debug', 'ws:onmessage', pipes); - for (i = 0, len = pipes.length; i < len; i++) { - pipe = pipes[i]; - switch (pipe.event) { - case 'chat_session_message': - if (pipe.data.self_written) { - return; - } - this.receiveMessage(pipe.data); - break; - case 'chat_session_typing': - if (pipe.data.self_written) { - return; - } - this.onAgentTypingStart(); - break; - case 'chat_session_start': - this.onConnectionEstablished(pipe.data.agent); - this.sessionId = pipe.data.session_id; - break; - case 'chat_session_queue': - this.onQueue(pipe.data.position); - this.sessionId = pipe.data.session_id; - break; - case 'chat_session_closed': - this.onSessionClosed(pipe.data); - break; - case 'chat_session_left': - this.onSessionClosed(pipe.data); - break; - case 'chat_status_customer': - switch (pipe.data.state) { - case 'online': - this.onReady(); - this.log('debug', 'Zammad Chat: ready'); - break; - case 'offline': - this.log('debug', 'Zammad Chat: No agent online'); - break; - case 'chat_disabled': - this.log('debug', 'Zammad Chat: Chat is disabled'); - break; - case 'no_seats_available': - this.log('debug', 'Zammad Chat: Too many clients in queue. Clients in queue: ', pipe.data.queue); - break; - case 'reconnect': - this.log('debug', 'old messages', pipe.data.session); - } - } - } - }; - - ZammadChat.prototype.onReady = function() { - if (this.options.show) { - this.show(); - return this.el.find('.zammad-chat-input').autoGrow({ - extraLine: false - }); - } - }; - - ZammadChat.prototype.onInput = function() { - this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread'); - return this.onTypingStart(); - }; - - ZammadChat.prototype.onTypingStart = function() { - if (this.isTypingTimeout) { - clearTimeout(this.isTypingTimeout); - } - this.isTypingTimeout = setTimeout(this.onTypingEnd, 1500); - if (!this.isTyping) { - this.isTyping = true; - return this.send('chat_session_typing', { - session_id: this.sessionId - }); - } - }; - - ZammadChat.prototype.onTypingEnd = function() { - return this.isTyping = false; - }; - - ZammadChat.prototype.onSubmit = function(event) { - event.preventDefault(); - return this.sendMessage(); - }; - - ZammadChat.prototype.sendMessage = function() { - var message, messageElement; - message = this.el.find('.zammad-chat-input').val(); - if (!message) { - return; - } - messageElement = this.view('message')({ - message: message, - from: 'customer', - id: this._messageCount++ - }); - this.maybeAddTimestamp(); - if (this.el.find('.zammad-chat-message--typing').size()) { - this.lastAddedType = 'typing-placeholder'; - this.el.find('.zammad-chat-message--typing').before(messageElement); - } else { - this.lastAddedType = 'message--customer'; - this.el.find('.zammad-chat-body').append(messageElement); - } - this.el.find('.zammad-chat-input').val(''); - this.scrollToBottom(); - this.isTyping = false; - return this.send('chat_session_message', { - content: message, - id: this._messageCount, - session_id: this.sessionId - }); - }; - - ZammadChat.prototype.receiveMessage = function(data) { - var ref, unread; - this.onAgentTypingEnd(); - this.maybeAddTimestamp(); - this.lastAddedType = 'message--agent'; - unread = (ref = document.hidden) != null ? ref : { - " zammad-chat-message--unread": "" - }; - this.el.find('.zammad-chat-body').append(this.view('message')({ - message: data.message.content, - id: data.id, - from: 'agent' - })); - return this.scrollToBottom(); - }; - - ZammadChat.prototype.open = function() { - if (this.isOpen) { - return; - } - this.showLoader(); - this.el.addClass('zammad-chat-is-open').animate({ - bottom: 0 - }, 500, this.onOpenAnimationEnd); - return this.isOpen = true; - }; - - ZammadChat.prototype.onOpenAnimationEnd = function() { - return this.session_init(); - }; - - ZammadChat.prototype.close = function(event) { - var remainerHeight; - if (event) { - event.stopPropagation(); - } - remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight(); - return this.el.animate({ - bottom: -remainerHeight - }, 500, this.onCloseAnimationEnd); - }; - - ZammadChat.prototype.onCloseAnimationEnd = function() { - this.el.removeClass('zammad-chat-is-open'); - this.disconnect(); - this.isOpen = false; - return this.send('chat_session_close', { - session_id: this.sessionId - }); - }; - - ZammadChat.prototype.hide = function() { - return this.el.removeClass('zammad-chat-is-visible'); - }; - - ZammadChat.prototype.show = function() { - var remainerHeight; - this.el.addClass('zammad-chat-is-visible'); - remainerHeight = this.el.outerHeight() - this.el.find('.zammad-chat-header').outerHeight(); - return this.el.css('bottom', -remainerHeight); - }; - - ZammadChat.prototype.disableInput = function() { - this.el.find('.zammad-chat-input').prop('disabled', true); - return this.el.find('.zammad-chat-send').prop('disabled', true); - }; - - ZammadChat.prototype.enableInput = function() { - this.el.find('.zammad-chat-input').prop('disabled', false); - return this.el.find('.zammad-chat-send').prop('disabled', false); - }; - - ZammadChat.prototype.onQueue = function(position) { - this.log('notice', 'onQueue', position); - this.inQueue = true; - return this.el.find('.zammad-chat-body').html(this.view('waiting')({ - position: position - })); - }; - - ZammadChat.prototype.onAgentTypingStart = function() { - if (this.stopTypingId) { - clearTimeout(this.stopTypingId); - } - this.stopTypingId = setTimeout(this.onAgentTypingEnd, 3000); - if (this.el.find('.zammad-chat-message--typing').size()) { - return; - } - this.maybeAddTimestamp(); - this.el.find('.zammad-chat-body').append(this.view('typingIndicator')()); - return this.scrollToBottom(); - }; - - ZammadChat.prototype.onAgentTypingEnd = function() { - return this.el.find('.zammad-chat-message--typing').remove(); - }; - - ZammadChat.prototype.maybeAddTimestamp = function() { - var label, time, timestamp; - timestamp = Date.now(); - if (!this.lastTimestamp || (timestamp - this.lastTimestamp) > this.showTimeEveryXMinutes * 60000) { - label = this.T('Today'); - time = new Date().toTimeString().substr(0, 5); - if (this.lastAddedType === 'timestamp') { - this.updateLastTimestamp(label, time); - return this.lastTimestamp = timestamp; - } else { - this.addStatus(label, time); - this.lastTimestamp = timestamp; - return this.lastAddedType = 'timestamp'; - } - } - }; - - ZammadChat.prototype.updateLastTimestamp = function(label, time) { - return this.el.find('.zammad-chat-body').find('.zammad-chat-status').last().replaceWith(this.view('status')({ - label: label, - time: time - })); - }; - - ZammadChat.prototype.addStatus = function(label, time) { - return this.el.find('.zammad-chat-body').append(this.view('status')({ - label: label, - time: time - })); - }; - - ZammadChat.prototype.scrollToBottom = function() { - return this.el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight')); - }; - - ZammadChat.prototype.session_init = function() { - return this.send('chat_session_init'); - }; - - ZammadChat.prototype.connect = function() { - this.log('notice', "Connecting to " + this.host); - this.ws = new window.WebSocket(this.host); - this.ws.onopen = (function(_this) { - return function() { - _this.log('debug', 'ws connected'); - _this.send('chat_status_customer', { - session_id: _this.sessionId - }); - return _this.setAgentOnlineState(true); - }; - })(this); - this.ws.onmessage = this.onWebSocketMessage; - this.ws.onclose = (function(_this) { - return function(e) { - _this.log('debug', 'close websocket connection'); - _this.reconnect(); - return _this.setAgentOnlineState(false); - }; - })(this); - return this.ws.onerror = (function(_this) { - return function(e) { - return _this.log('debug', 'ws:onerror', e); - }; - })(this); - }; - - ZammadChat.prototype.reconnect = function() { - this.log('notice', 'reconnecting'); - this.disableInput(); - this.lastAddedType = 'status'; - this.el.find('.zammad-chat-agent-status').attr('data-status', 'connecting').text(this.T('Reconnecting')); - this.addStatus(this.T('Connection lost')); - if (this.reconnectDelayId) { - clearTimeout(this.reconnectDelayId); - } - return this.reconnectDelayId = setTimeout(this.connect, 5000); - }; - - ZammadChat.prototype.onConnectionReestablished = function() { - this.lastAddedType = 'status'; - this.el.find('.zammad-chat-agent-status').attr('data-status', 'online').text(this.T('Online')); - return this.addStatus(this.T('Connection re-established')); - }; - - ZammadChat.prototype.onSessionClosed = function(data) { - this.addStatus(this.T('Chat closed by %s', data.realname)); - return this.disableInput(); - }; - - ZammadChat.prototype.disconnect = function() { - this.showLoader(); - this.el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden'); - this.el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden'); - return this.el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden'); - }; - - ZammadChat.prototype.onConnectionEstablished = function(agent) { - this.inQueue = false; - this.agent = agent; - this.el.find('.zammad-chat-agent').html(this.view('agent')({ - agent: 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'); - return this.el.find('.zammad-chat-input').focus(); - }; - - ZammadChat.prototype.showLoader = function() { - return this.el.find('.zammad-chat-body').html(this.view('loader')()); - }; - - ZammadChat.prototype.setAgentOnlineState = function(state) { - this.isOnline = state; - return this.el.find('.zammad-chat-agent-status').toggleClass('zammad-chat-is-online', state).text(state ? this.T('Online') : this.T('Offline')); - }; - - return ZammadChat; - - })(); - return $(document).ready(function() { - return window.zammadChat = new ZammadChat(); - }); -})(window.jQuery, window); - if (!window.zammadChatTemplates) { window.zammadChatTemplates = {}; } @@ -557,6 +63,587 @@ window.zammadChatTemplates["agent"] = function (__obj) { return __out.join(''); }; +var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + slice = [].slice; + +(function($, window) { + var ZammadChat; + ZammadChat = (function() { + ZammadChat.prototype.defaults = { + invitationPhrase: 'Chat with us!', + agentPhrase: ' is helping you', + show: true, + target: $('body') + }; + + ZammadChat.prototype._messageCount = 0; + + ZammadChat.prototype.isOpen = false; + + ZammadChat.prototype.blinkOnlineInterval = null; + + ZammadChat.prototype.stopBlinOnlineStateTimeout = null; + + ZammadChat.prototype.showTimeEveryXMinutes = 1; + + ZammadChat.prototype.lastTimestamp = null; + + ZammadChat.prototype.lastAddedType = null; + + ZammadChat.prototype.inputTimeout = null; + + ZammadChat.prototype.isTyping = false; + + ZammadChat.prototype.isOnline = true; + + ZammadChat.prototype.initialQueueDelay = 10000; + + ZammadChat.prototype.debug = true; + + ZammadChat.prototype.host = 'ws://localhost:6042'; + + ZammadChat.prototype.strings = { + 'Online': 'Online', + 'Offline': 'Offline', + 'Connecting': 'Verbinden', + 'Connection re-established': 'Connection re-established', + '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.', + '': '', + '': '', + '': '' + }; + + ZammadChat.prototype.sessionId = void 0; + + ZammadChat.prototype.T = function() { + var i, item, items, len, string, translation; + string = arguments[0], items = 2 <= arguments.length ? slice.call(arguments, 1) : []; + if (!this.strings[string]) { + this.log('notice', "Translation needed for '" + string + "'"); + } + translation = this.strings[string] || string; + if (items) { + for (i = 0, len = items.length; i < len; i++) { + item = items[i]; + translation = translation.replace(/%s/, item); + } + } + return translation; + }; + + ZammadChat.prototype.log = function() { + var level, string; + level = arguments[0], string = 2 <= arguments.length ? slice.call(arguments, 1) : []; + if (!this.debug && level === 'debug') { + return; + } + return console.log(level, string); + }; + + ZammadChat.prototype.view = function(name) { + return (function(_this) { + return function(options) { + if (!options) { + options = {}; + } + options.T = _this.T; + return window.zammadChatTemplates[name](options); + }; + })(this); + }; + + function ZammadChat(el, options) { + 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.connect = bind(this.connect, 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.onTypingEnd = bind(this.onTypingEnd, this); + this.onInput = bind(this.onInput, this); + this.openSession = bind(this.openSession, 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 = $.extend({}, this.defaults, options); + this.el = $(this.view('chat')(this.options)); + this.options.target.append(this.el); + this.input = this.el.find('.zammad-chat-input'); + 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 + }); + if (!window.WebSocket || !sessionStorage) { + this.log('notice', 'Chat: Browser not supported!'); + return; + } + this.connect(); + } + + ZammadChat.prototype.checkForEnter = function(event) { + if (!event.shiftKey && event.keyCode === 13) { + event.preventDefault(); + return this.sendMessage(); + } + }; + + ZammadChat.prototype.send = function(event, data) { + var pipe; + this.log('debug', 'ws:send', event, data); + pipe = JSON.stringify({ + event: event, + data: data + }); + return this.ws.send(pipe); + }; + + ZammadChat.prototype.onWebSocketMessage = function(e) { + var i, len, pipe, pipes; + pipes = JSON.parse(e.data); + for (i = 0, len = pipes.length; i < len; i++) { + pipe = pipes[i]; + this.log('debug', 'ws:onmessage', pipe); + switch (pipe.event) { + case 'chat_session_message': + if (pipe.data.self_written) { + return; + } + this.receiveMessage(pipe.data); + break; + case 'chat_session_typing': + if (pipe.data.self_written) { + return; + } + this.onAgentTypingStart(); + break; + case 'chat_session_start': + this.onConnectionEstablished(pipe.data); + break; + case 'chat_session_queue': + this.onQueue(pipe.data); + break; + case 'chat_session_closed': + this.onSessionClosed(pipe.data); + break; + case 'chat_session_left': + this.onSessionClosed(pipe.data); + break; + case 'chat_status_customer': + switch (pipe.data.state) { + case 'online': + this.onReady(); + this.log('debug', 'Zammad Chat: ready'); + break; + case 'offline': + this.log('debug', 'Zammad Chat: No agent online'); + break; + case 'chat_disabled': + this.log('debug', 'Zammad Chat: Chat is disabled'); + break; + case 'no_seats_available': + this.log('debug', 'Zammad Chat: Too many clients in queue. Clients in queue: ', pipe.data.queue); + break; + case 'reconnect': + this.log('debug', 'old messages', pipe.data.session); + this.openSession(pipe.data.session); + } + } + } + }; + + ZammadChat.prototype.onReady = function() { + if (this.options.show) { + return this.show(); + } + }; + + ZammadChat.prototype.openSession = function(session) { + var i, len, message, unfinishedMessage; + unfinishedMessage = sessionStorage.getItem('unfinished_message'); + for (i = 0, len = session.length; i < len; i++) { + message = session[i]; + console.log("message in session", message); + this.renderMessage({ + message: message.content, + id: message.id, + from: message.created_by_id ? 'agent' : 'customer' + }); + } + if (unfinishedMessage) { + this.input.val(unfinishedMessage); + } + this.show(); + this.open({ + showLoader: false, + animate: false + }); + if (unfinishedMessage) { + return this.input.focus(); + } + }; + + ZammadChat.prototype.onInput = function() { + this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread'); + sessionStorage.setItem('unfinished_message', this.input.val()); + return this.onTypingStart(); + }; + + ZammadChat.prototype.onTypingStart = function() { + if (this.isTypingTimeout) { + clearTimeout(this.isTypingTimeout); + } + this.isTypingTimeout = setTimeout(this.onTypingEnd, 1500); + if (!this.isTyping) { + this.isTyping = true; + return this.send('chat_session_typing', { + session_id: this.sessionId + }); + } + }; + + ZammadChat.prototype.onTypingEnd = function() { + return this.isTyping = false; + }; + + ZammadChat.prototype.onSubmit = function(event) { + event.preventDefault(); + return this.sendMessage(); + }; + + ZammadChat.prototype.sendMessage = function() { + var message, messageElement; + message = this.input.val(); + if (!message) { + return; + } + sessionStorage.removeItem('unfinished_message'); + messageElement = this.view('message')({ + message: message, + from: 'customer', + id: this._messageCount++ + }); + this.maybeAddTimestamp(); + if (this.el.find('.zammad-chat-message--typing').size()) { + this.lastAddedType = 'typing-placeholder'; + this.el.find('.zammad-chat-message--typing').before(messageElement); + } else { + this.lastAddedType = 'message--customer'; + this.el.find('.zammad-chat-body').append(messageElement); + } + this.input.val(''); + this.scrollToBottom(); + this.isTyping = false; + return this.send('chat_session_message', { + content: message, + id: this._messageCount, + session_id: this.sessionId + }); + }; + + ZammadChat.prototype.receiveMessage = function(data) { + this.onAgentTypingEnd(); + this.maybeAddTimestamp(); + return this.renderMessage({ + message: data.message.content, + id: data.id, + from: 'agent' + }); + }; + + ZammadChat.prototype.renderMessage = function(data) { + var ref, unread; + this.lastAddedType = "message--" + data.from; + unread = (ref = document.hidden) != null ? ref : { + " zammad-chat-message--unread": "" + }; + this.el.find('.zammad-chat-body').append(this.view('message')(data)); + return this.scrollToBottom(); + }; + + ZammadChat.prototype.open = function(options) { + if (options == null) { + options = { + showLoader: true, + animate: true + }; + } + if (this.isOpen) { + return; + } + if (options.showLoader) { + this.showLoader(); + } + this.el.addClass('zammad-chat-is-open'); + if (options.animate) { + this.el.animate({ + bottom: 0 + }, 500, this.onOpenAnimationEnd); + } else { + this.el.css('bottom', 0); + this.onOpenAnimationEnd(); + } + return this.isOpen = true; + }; + + ZammadChat.prototype.onOpenAnimationEnd = function() { + return this.session_init(); + }; + + ZammadChat.prototype.close = function(event) { + if (event) { + event.stopPropagation(); + } + this.ws.close(); + sessionStorage.removeItem('sessionId'); + sessionStorage.removeItem('unfinished_message'); + return this.closeWindow(); + }; + + ZammadChat.prototype.closeWindow = function() { + var remainerHeight; + remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight(); + return this.el.animate({ + bottom: -remainerHeight + }, 500, this.onCloseAnimationEnd); + }; + + ZammadChat.prototype.onCloseAnimationEnd = function() { + this.el.removeClass('zammad-chat-is-open'); + this.disconnect(); + this.isOpen = false; + return this.send('chat_session_close', { + session_id: this.sessionId + }); + }; + + ZammadChat.prototype.hide = function() { + return this.el.removeClass('zammad-chat-is-visible'); + }; + + ZammadChat.prototype.show = function() { + var remainerHeight; + this.el.addClass('zammad-chat-is-visible'); + remainerHeight = this.el.outerHeight() - this.el.find('.zammad-chat-header').outerHeight(); + this.el.css('bottom', -remainerHeight); + return this.input.autoGrow({ + extraLine: false + }); + }; + + ZammadChat.prototype.disableInput = function() { + this.input.prop('disabled', true); + return this.el.find('.zammad-chat-send').prop('disabled', true); + }; + + ZammadChat.prototype.enableInput = function() { + this.input.prop('disabled', false); + return this.el.find('.zammad-chat-send').prop('disabled', false); + }; + + ZammadChat.prototype.onQueueScreen = function(data) { + var show; + show = (function(_this) { + return function() { + return _this.onQueue(data.position); + }; + })(this); + if (this.initialQueueDelay && !this.onInitialQueueDelayId) { + this.onInitialQueueDelayId = setTimeout(show, this.initialQueueDelay); + return; + } + if (this.onInitialQueueDelayId) { + clearTimeout(this.onInitialQueueDelayId); + } + return show(); + }; + + ZammadChat.prototype.onQueue = function(position) { + this.log('notice', 'onQueue', position); + this.inQueue = true; + this.setSessionId(data.session_id); + return this.el.find('.zammad-chat-body').html(this.view('waiting')({ + position: data.position + })); + }; + + ZammadChat.prototype.onAgentTypingStart = function() { + if (this.stopTypingId) { + clearTimeout(this.stopTypingId); + } + this.stopTypingId = setTimeout(this.onAgentTypingEnd, 3000); + if (this.el.find('.zammad-chat-message--typing').size()) { + return; + } + this.maybeAddTimestamp(); + this.el.find('.zammad-chat-body').append(this.view('typingIndicator')()); + return this.scrollToBottom(); + }; + + ZammadChat.prototype.onAgentTypingEnd = function() { + return this.el.find('.zammad-chat-message--typing').remove(); + }; + + ZammadChat.prototype.maybeAddTimestamp = function() { + var label, time, timestamp; + timestamp = Date.now(); + if (!this.lastTimestamp || (timestamp - this.lastTimestamp) > this.showTimeEveryXMinutes * 60000) { + label = this.T('Today'); + time = new Date().toTimeString().substr(0, 5); + if (this.lastAddedType === 'timestamp') { + this.updateLastTimestamp(label, time); + return this.lastTimestamp = timestamp; + } else { + this.addStatus(label, time); + this.lastTimestamp = timestamp; + return this.lastAddedType = 'timestamp'; + } + } + }; + + ZammadChat.prototype.updateLastTimestamp = function(label, time) { + return this.el.find('.zammad-chat-body').find('.zammad-chat-status').last().replaceWith(this.view('status')({ + label: label, + time: time + })); + }; + + ZammadChat.prototype.addStatus = function(label, time) { + return this.el.find('.zammad-chat-body').append(this.view('status')({ + label: label, + time: time + })); + }; + + ZammadChat.prototype.scrollToBottom = function() { + return this.el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight')); + }; + + ZammadChat.prototype.session_init = function() { + return this.send('chat_session_init'); + }; + + ZammadChat.prototype.connect = function() { + this.log('notice', "Connecting to " + this.host); + this.ws = new window.WebSocket(this.host); + this.ws.onopen = this.onWebSocketOpen; + this.ws.onmessage = this.onWebSocketMessage; + this.ws.onclose = (function(_this) { + return function(e) { + _this.log('debug', 'close websocket connection'); + _this.reconnect(); + return _this.setAgentOnlineState(false); + }; + })(this); + return this.ws.onerror = (function(_this) { + return function(e) { + return _this.log('debug', 'ws:onerror', e); + }; + })(this); + }; + + ZammadChat.prototype.onWebSocketOpen = function() { + this.sessionId = sessionStorage.getItem('sessionId'); + this.log('debug', 'ws connected'); + this.send('chat_status_customer', { + session_id: this.sessionId + }); + return this.setAgentOnlineState(true); + }; + + ZammadChat.prototype.reconnect = function() { + this.log('notice', 'reconnecting'); + this.disableInput(); + this.lastAddedType = 'status'; + this.el.find('.zammad-chat-agent-status').attr('data-status', 'connecting').text(this.T('Reconnecting')); + this.addStatus(this.T('Connection lost')); + if (this.reconnectDelayId) { + clearTimeout(this.reconnectDelayId); + } + return this.reconnectDelayId = setTimeout(this.connect, 5000); + }; + + ZammadChat.prototype.onConnectionReestablished = function() { + this.lastAddedType = 'status'; + this.el.find('.zammad-chat-agent-status').attr('data-status', 'online').text(this.T('Online')); + return this.addStatus(this.T('Connection re-established')); + }; + + ZammadChat.prototype.onSessionClosed = function(data) { + this.addStatus(this.T('Chat closed by %s', data.realname)); + return this.disableInput(); + }; + + ZammadChat.prototype.disconnect = function() { + this.showLoader(); + this.el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden'); + this.el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden'); + return this.el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden'); + }; + + ZammadChat.prototype.setSessionId = function(id) { + this.sessionId = id; + return sessionStorage.setItem('sessionId', id); + }; + + ZammadChat.prototype.onConnectionEstablished = function(data) { + if (this.onInitialQueueDelayId) { + clearTimeout(this.onInitialQueueDelayId); + } + this.inQueue = false; + this.agent = data.agent; + this.setSessionId(data.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'); + return this.input.focus(); + }; + + ZammadChat.prototype.showLoader = function() { + return this.el.find('.zammad-chat-body').html(this.view('loader')()); + }; + + ZammadChat.prototype.setAgentOnlineState = function(state) { + this.isOnline = state; + return this.el.find('.zammad-chat-agent-status').toggleClass('zammad-chat-is-online', state).text(state ? this.T('Online') : this.T('Offline')); + }; + + return ZammadChat; + + })(); + return $(document).ready(function() { + return window.zammadChat = new ZammadChat(); + }); +})(window.jQuery, window); + /*! * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): diff --git a/public/assets/chat/chat.min.js b/public/assets/chat/chat.min.js index 6ff1e597e..7d6972ccf 100644 --- a/public/assets/chat/chat.min.js +++ b/public/assets/chat/chat.min.js @@ -1 +1 @@ -var bind=function(t,e){return function(){return t.apply(e,arguments)}},slice=[].slice;!function(t,e){var n;return n=function(){function n(n,s){return this.setAgentOnlineState=bind(this.setAgentOnlineState,this),this.onConnectionEstablished=bind(this.onConnectionEstablished,this),this.onConnectionReestablished=bind(this.onConnectionReestablished,this),this.reconnect=bind(this.reconnect,this),this.connect=bind(this.connect,this),this.onAgentTypingEnd=bind(this.onAgentTypingEnd,this),this.onAgentTypingStart=bind(this.onAgentTypingStart,this),this.onQueue=bind(this.onQueue,this),this.onCloseAnimationEnd=bind(this.onCloseAnimationEnd,this),this.close=bind(this.close,this),this.onOpenAnimationEnd=bind(this.onOpenAnimationEnd,this),this.open=bind(this.open,this),this.receiveMessage=bind(this.receiveMessage,this),this.onSubmit=bind(this.onSubmit,this),this.onTypingEnd=bind(this.onTypingEnd,this),this.onInput=bind(this.onInput,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),this.el=t(this.view("chat")(this.options)),this.options.target.append(this.el),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.el.find(".zammad-chat-input").on({keydown:this.checkForEnter,input:this.onInput}),e.WebSocket?(this.connect(),void this.onReady()):void this.log("notice","Chat: Browser not supported!")}return n.prototype.defaults={invitationPhrase:"Chat with us!",agentPhrase:" is helping you",show:!0,target:t("body")},n.prototype._messageCount=0,n.prototype.isOpen=!1,n.prototype.blinkOnlineInterval=null,n.prototype.stopBlinOnlineStateTimeout=null,n.prototype.showTimeEveryXMinutes=1,n.prototype.lastTimestamp=null,n.prototype.lastAddedType=null,n.prototype.inputTimeout=null,n.prototype.isTyping=!1,n.prototype.isOnline=!0,n.prototype.debug=!0,n.prototype.host="ws://localhost:6042",n.prototype.strings={Online:"Online",Offline:"Offline",Connecting:"Verbinden","Connection re-established":"Connection re-established",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.","":"","":"","":""},n.prototype.sessionId=void 0,n.prototype.T=function(){var t,e,n,s,a,i;if(a=arguments[0],n=2<=arguments.length?slice.call(arguments,1):[],this.strings[a]||this.log("notice","Translation needed for '"+a+"'"),i=this.strings[a]||a,n)for(t=0,s=n.length;s>t;t++)e=n[t],i=i.replace(/%s/,e);return i},n.prototype.log=function(){var t,e;return t=arguments[0],e=2<=arguments.length?slice.call(arguments,1):[],this.debug||"debug"!==t?console.log(t,e):void 0},n.prototype.view=function(t){return function(n){return function(s){return s||(s={}),s.T=n.T,e.zammadChatTemplates[t](s)}}(this)},n.prototype.checkForEnter=function(t){return t.shiftKey||13!==t.keyCode?void 0:(t.preventDefault(),this.sendMessage())},n.prototype.send=function(t,e){var n;return this.log("debug","ws:send",t,e),n=JSON.stringify({event:t,data:e}),this.ws.send(n)},n.prototype.onWebSocketMessage=function(t){var e,n,s,a;for(a=JSON.parse(t.data),this.log("debug","ws:onmessage",a),e=0,n=a.length;n>e;e++)switch(s=a[e],s.event){case"chat_session_message":if(s.data.self_written)return;this.receiveMessage(s.data);break;case"chat_session_typing":if(s.data.self_written)return;this.onAgentTypingStart();break;case"chat_session_start":this.onConnectionEstablished(s.data.agent),this.sessionId=s.data.session_id;break;case"chat_session_queue":this.onQueue(s.data.position),this.sessionId=s.data.session_id;break;case"chat_session_closed":this.onSessionClosed(s.data);break;case"chat_session_left":this.onSessionClosed(s.data);break;case"chat_status_customer":switch(s.data.state){case"online":this.onReady(),this.log("debug","Zammad Chat: ready");break;case"offline":this.log("debug","Zammad Chat: No agent online");break;case"chat_disabled":this.log("debug","Zammad Chat: Chat is disabled");break;case"no_seats_available":this.log("debug","Zammad Chat: Too many clients in queue. Clients in queue: ",s.data.queue);break;case"reconnect":this.log("debug","old messages",s.data.session)}}},n.prototype.onReady=function(){return this.options.show?(this.show(),this.el.find(".zammad-chat-input").autoGrow({extraLine:!1})):void 0},n.prototype.onInput=function(){return this.el.find(".zammad-chat-message--unread").removeClass("zammad-chat-message--unread"),this.onTypingStart()},n.prototype.onTypingStart=function(){return this.isTypingTimeout&&clearTimeout(this.isTypingTimeout),this.isTypingTimeout=setTimeout(this.onTypingEnd,1500),this.isTyping?void 0:(this.isTyping=!0,this.send("chat_session_typing",{session_id:this.sessionId}))},n.prototype.onTypingEnd=function(){return this.isTyping=!1},n.prototype.onSubmit=function(t){return t.preventDefault(),this.sendMessage()},n.prototype.sendMessage=function(){var t,e;return(t=this.el.find(".zammad-chat-input").val())?(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.el.find(".zammad-chat-input").val(""),this.scrollToBottom(),this.isTyping=!1,this.send("chat_session_message",{content:t,id:this._messageCount,session_id:this.sessionId})):void 0},n.prototype.receiveMessage=function(t){var e,n;return this.onAgentTypingEnd(),this.maybeAddTimestamp(),this.lastAddedType="message--agent",n=null!=(e=document.hidden)?e:{" zammad-chat-message--unread":""},this.el.find(".zammad-chat-body").append(this.view("message")({message:t.message.content,id:t.id,from:"agent"})),this.scrollToBottom()},n.prototype.open=function(){return this.isOpen?void 0:(this.showLoader(),this.el.addClass("zammad-chat-is-open").animate({bottom:0},500,this.onOpenAnimationEnd),this.isOpen=!0)},n.prototype.onOpenAnimationEnd=function(){return this.session_init()},n.prototype.close=function(t){var e;return t&&t.stopPropagation(),e=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-e},500,this.onCloseAnimationEnd)},n.prototype.onCloseAnimationEnd=function(){return this.el.removeClass("zammad-chat-is-open"),this.disconnect(),this.isOpen=!1,this.send("chat_session_close",{session_id:this.sessionId})},n.prototype.hide=function(){return this.el.removeClass("zammad-chat-is-visible")},n.prototype.show=function(){var t;return this.el.addClass("zammad-chat-is-visible"),t=this.el.outerHeight()-this.el.find(".zammad-chat-header").outerHeight(),this.el.css("bottom",-t)},n.prototype.disableInput=function(){return this.el.find(".zammad-chat-input").prop("disabled",!0),this.el.find(".zammad-chat-send").prop("disabled",!0)},n.prototype.enableInput=function(){return this.el.find(".zammad-chat-input").prop("disabled",!1),this.el.find(".zammad-chat-send").prop("disabled",!1)},n.prototype.onQueue=function(t){return this.log("notice","onQueue",t),this.inQueue=!0,this.el.find(".zammad-chat-body").html(this.view("waiting")({position:t}))},n.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())},n.prototype.onAgentTypingEnd=function(){return this.el.find(".zammad-chat-message--typing").remove()},n.prototype.maybeAddTimestamp=function(){var t,e,n;return n=Date.now(),!this.lastTimestamp||n-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=n):(this.addStatus(t,e),this.lastTimestamp=n,this.lastAddedType="timestamp")):void 0},n.prototype.updateLastTimestamp=function(t,e){return this.el.find(".zammad-chat-body").find(".zammad-chat-status").last().replaceWith(this.view("status")({label:t,time:e}))},n.prototype.addStatus=function(t,e){return this.el.find(".zammad-chat-body").append(this.view("status")({label:t,time:e}))},n.prototype.scrollToBottom=function(){return this.el.find(".zammad-chat-body").scrollTop(t(".zammad-chat-body").prop("scrollHeight"))},n.prototype.session_init=function(){return this.send("chat_session_init")},n.prototype.connect=function(){return this.log("notice","Connecting to "+this.host),this.ws=new e.WebSocket(this.host),this.ws.onopen=function(t){return function(){return t.log("debug","ws connected"),t.send("chat_status_customer",{session_id:t.sessionId}),t.setAgentOnlineState(!0)}}(this),this.ws.onmessage=this.onWebSocketMessage,this.ws.onclose=function(t){return function(e){return t.log("debug","close websocket connection"),t.reconnect(),t.setAgentOnlineState(!1)}}(this),this.ws.onerror=function(t){return function(e){return t.log("debug","ws:onerror",e)}}(this)},n.prototype.reconnect=function(){return this.log("notice","reconnecting"),this.disableInput(),this.lastAddedType="status",this.el.find(".zammad-chat-agent-status").attr("data-status","connecting").text(this.T("Reconnecting")),this.addStatus(this.T("Connection lost")),this.reconnectDelayId&&clearTimeout(this.reconnectDelayId),this.reconnectDelayId=setTimeout(this.connect,5e3)},n.prototype.onConnectionReestablished=function(){return this.lastAddedType="status",this.el.find(".zammad-chat-agent-status").attr("data-status","online").text(this.T("Online")),this.addStatus(this.T("Connection re-established"))},n.prototype.onSessionClosed=function(t){return this.addStatus(this.T("Chat closed by %s",t.realname)),this.disableInput()},n.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")},n.prototype.onConnectionEstablished=function(t){return this.inQueue=!1,this.agent=t,this.el.find(".zammad-chat-agent").html(this.view("agent")({agent:t})),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.el.find(".zammad-chat-input").focus()},n.prototype.showLoader=function(){return this.el.find(".zammad-chat-body").html(this.view("loader")())},n.prototype.setAgentOnlineState=function(t){return this.isOnline=t,this.el.find(".zammad-chat-agent-status").toggleClass("zammad-chat-is-online",t).text(t?this.T("Online"):this.T("Offline"))},n}(),t(document).ready(function(){return e.zammadChat=new n})}(window.jQuery,window),window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.agent=function(t){t||(t={});var e,n=[],s=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},a=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){this.agent.avatar&&(n.push('\n\n')),n.push('\n\n '),n.push(s(this.agent.name)),n.push(" "),n.push(this.agentPhrase),n.push("\n")}).call(this)}.call(t),t.safe=a,t.escape=i,n.join("")},jQuery.fn.autoGrow=function(t){return this.each(function(){var e=jQuery.extend({extraLine:!0},t),n=function(t){return jQuery(t).after('
'),jQuery(t).next(".autogrow-textarea-mirror")[0]},s=function(t){i.innerHTML=String(t.value).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/ /g," ").replace(/\n/g,"
")+(e.extraLine?".
.":""),jQuery(t).height()!=jQuery(i).height()&&jQuery(t).height(jQuery(i).height())},a=function(){s(this)},i=n(this);i.style.display="none",i.style.wordWrap="break-word",i.style.whiteSpace="normal",i.style.padding=jQuery(this).css("paddingTop")+" "+jQuery(this).css("paddingRight")+" "+jQuery(this).css("paddingBottom")+" "+jQuery(this).css("paddingLeft"),i.style.width=jQuery(this).css("width"),i.style.fontFamily=jQuery(this).css("font-family"),i.style.fontSize=jQuery(this).css("font-size"),i.style.lineHeight=jQuery(this).css("line-height"),this.style.overflow="hidden",this.style.minHeight=this.rows+"em",this.onkeyup=a,s(this)})},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.chat=function(t){t||(t={});var e,n=[],s=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(){n.push('
\n
\n
\n Online\n \n \n \n \n
\n
\n
\n
\n \n '),n.push(this.invitationPhrase),n.push('\n
\n
\n
\n
\n \n \n
\n
")}).call(this)}.call(t),t.safe=s,t.escape=a,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.loader=function(t){t||(t={});var e,n=[],s=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},a=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){n.push('
\n \n \n \n \n \n '),n.push(s(this.T("Connecting"))),n.push("\n
")}).call(this)}.call(t),t.safe=a,t.escape=i,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=function(t){t||(t={});var e,n=[],s=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},a=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){n.push('
\n '),n.push(this.message),n.push("\n
")}).call(this)}.call(t),t.safe=a,t.escape=i,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=function(t){t||(t={});var e,n=[],s=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},a=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){n.push('
'),n.push(s(this.label)),n.push(" "),n.push(s(this.time)),n.push("
")}).call(this)}.call(t),t.safe=a,t.escape=i,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(t){t||(t={});var e,n=[],s=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(){n.push('
\n \n \n \n \n \n \n \n
')}).call(this)}.call(t),t.safe=s,t.escape=a,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting=function(t){t||(t={});var e,n=[],s=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(){n.push('
\n
\n \n \n \n \n \n '),n.push(this.T("All colleges are busy.")),n.push("
\n "),n.push(this.T("You are on waiting list position %s.",this.position)),n.push("\n
\n
")}).call(this)}.call(t),t.safe=s,t.escape=a,n.join("")}; \ No newline at end of file +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(" "),s.push(this.agentPhrase),s.push("\n")}).call(this)}.call(t),t.safe=i,t.escape=a,s.join("")};var bind=function(t,e){return function(){return t.apply(e,arguments)}},slice=[].slice;!function(t,e){var s;return s=function(){function s(s,n){return 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.connect=bind(this.connect,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.onTypingEnd=bind(this.onTypingEnd,this),this.onInput=bind(this.onInput,this),this.openSession=bind(this.openSession,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,n),this.el=t(this.view("chat")(this.options)),this.options.target.append(this.el),this.input=this.el.find(".zammad-chat-input"),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}),e.WebSocket&&sessionStorage?void this.connect():void this.log("notice","Chat: Browser not supported!")}return s.prototype.defaults={invitationPhrase:"Chat with us!",agentPhrase:" is helping you",show:!0,target:t("body")},s.prototype._messageCount=0,s.prototype.isOpen=!1,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.isOnline=!0,s.prototype.initialQueueDelay=1e4,s.prototype.debug=!0,s.prototype.host="ws://localhost:6042",s.prototype.strings={Online:"Online",Offline:"Offline",Connecting:"Verbinden","Connection re-established":"Connection re-established",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.","":"","":"","":""},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.strings[i]||this.log("notice","Translation needed for '"+i+"'"),a=this.strings[i]||i,s)for(t=0,n=s.length;n>t;t++)e=s[t],a=a.replace(/%s/,e);return a},s.prototype.log=function(){var t,e;return t=arguments[0],e=2<=arguments.length?slice.call(arguments,1):[],this.debug||"debug"!==t?console.log(t,e):void 0},s.prototype.view=function(t){return function(s){return function(n){return n||(n={}),n.T=s.T,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 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_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.onQueue(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.onReady(),this.log("debug","Zammad Chat: ready");break;case"offline":this.log("debug","Zammad Chat: No agent online");break;case"chat_disabled":this.log("debug","Zammad Chat: Chat is disabled");break;case"no_seats_available":this.log("debug","Zammad Chat: Too many clients in queue. Clients in queue: ",n.data.queue);break;case"reconnect":this.log("debug","old messages",n.data.session),this.openSession(n.data.session)}}},s.prototype.onReady=function(){return this.options.show?this.show():void 0},s.prototype.openSession=function(t){var e,s,n,i;for(i=sessionStorage.getItem("unfinished_message"),e=0,s=t.length;s>e;e++)n=t[e],console.log("message in session",n),this.renderMessage({message:n.content,id:n.id,from:n.created_by_id?"agent":"customer"});return i&&this.input.val(i),this.show(),this.open({showLoader:!1,animate:!1}),i?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.onTypingStart()},s.prototype.onTypingStart=function(){return this.isTypingTimeout&&clearTimeout(this.isTypingTimeout),this.isTypingTimeout=setTimeout(this.onTypingEnd,1500),this.isTyping?void 0:(this.isTyping=!0,this.send("chat_session_typing",{session_id:this.sessionId}))},s.prototype.onTypingEnd=function(){return this.isTyping=!1},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.isTyping=!1,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(t){return null==t&&(t={showLoader:!0,animate:!0}),this.isOpen?void 0:(t.showLoader&&this.showLoader(),this.el.addClass("zammad-chat-is-open"),t.animate?this.el.animate({bottom:0},500,this.onOpenAnimationEnd):(this.el.css("bottom",0),this.onOpenAnimationEnd()),this.isOpen=!0)},s.prototype.onOpenAnimationEnd=function(){return this.session_init()},s.prototype.close=function(t){return t&&t.stopPropagation(),this.ws.close(),sessionStorage.removeItem("sessionId"),sessionStorage.removeItem("unfinished_message"),this.closeWindow()},s.prototype.closeWindow=function(){var t;return 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-open"),this.disconnect(),this.isOpen=!1,this.send("chat_session_close",{session_id:this.sessionId})},s.prototype.hide=function(){return this.el.removeClass("zammad-chat-is-visible")},s.prototype.show=function(){var t;return this.el.addClass("zammad-chat-is-visible"),t=this.el.outerHeight()-this.el.find(".zammad-chat-header").outerHeight(),this.el.css("bottom",-t),this.input.autoGrow({extraLine:!1})},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 e=function(e){return function(){return e.onQueue(t.position)}}(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),this.inQueue=!0,this.setSessionId(data.session_id),this.el.find(".zammad-chat-body").html(this.view("waiting")({position:data.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.addStatus(t,e),this.lastTimestamp=s,this.lastAddedType="timestamp")):void 0},s.prototype.updateLastTimestamp=function(t,e){return this.el.find(".zammad-chat-body").find(".zammad-chat-status").last().replaceWith(this.view("status")({label:t,time:e}))},s.prototype.addStatus=function(t,e){return this.el.find(".zammad-chat-body").append(this.view("status")({label:t,time:e}))},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.connect=function(){return this.log("notice","Connecting to "+this.host),this.ws=new e.WebSocket(this.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.reconnect(),t.setAgentOnlineState(!1)}}(this),this.ws.onerror=function(t){return function(e){return t.log("debug","ws:onerror",e)}}(this)},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(!0)},s.prototype.reconnect=function(){return this.log("notice","reconnecting"),this.disableInput(),this.lastAddedType="status",this.el.find(".zammad-chat-agent-status").attr("data-status","connecting").text(this.T("Reconnecting")),this.addStatus(this.T("Connection lost")),this.reconnectDelayId&&clearTimeout(this.reconnectDelayId),this.reconnectDelayId=setTimeout(this.connect,5e3)},s.prototype.onConnectionReestablished=function(){return this.lastAddedType="status",this.el.find(".zammad-chat-agent-status").attr("data-status","online").text(this.T("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()},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,sessionStorage.setItem("sessionId",t)},s.prototype.onConnectionEstablished=function(t){return this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.inQueue=!1,this.agent=t.agent,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()},s.prototype.showLoader=function(){return this.el.find(".zammad-chat-body").html(this.view("loader")())},s.prototype.setAgentOnlineState=function(t){return this.isOnline=t,this.el.find(".zammad-chat-agent-status").toggleClass("zammad-chat-is-online",t).text(t?this.T("Online"):this.T("Offline"))},s}(),t(document).ready(function(){return e.zammadChat=new s})}(window.jQuery,window),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=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\n
\n Online\n \n \n \n \n
\n
\n
\n
\n \n '),s.push(this.invitationPhrase),s.push('\n
\n
\n
\n
\n \n \n
\n
")}).call(this)}.call(t),t.safe=n,t.escape=i,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.loader=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(n(this.T("Connecting"))),s.push("\n
")}).call(this)}.call(t),t.safe=i,t.escape=a,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=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 '),s.push(this.message),s.push("\n
")}).call(this)}.call(t),t.safe=i,t.escape=a,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=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('
'),s.push(n(this.label)),s.push(" "),s.push(n(this.time)),s.push("
")}).call(this)}.call(t),t.safe=i,t.escape=a,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(t){t||(t={});var e,s=[],n=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n \n \n \n \n \n \n \n
')}).call(this)}.call(t),t.safe=n,t.escape=i,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting=function(t){t||(t={});var e,s=[],n=t.safe,i=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},i||(i=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\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