diff --git a/public/assets/chat/chat.coffee b/public/assets/chat/chat.coffee index 9c7ee77c3..1252fb3d7 100644 --- a/public/assets/chat/chat.coffee +++ b/public/assets/chat/chat.coffee @@ -5,10 +5,11 @@ do($ = window.jQuery, window) -> defaults: invitationPhrase: 'Chat with us!' - agentPhrase: '%%agent%% is helping you' + agentPhrase: ' is helping you' show: true target: $('body') + _messageCount: 0 isOpen: false blinkOnlineInterval: null stopBlinOnlineStateTimeout: null @@ -25,15 +26,20 @@ do($ = window.jQuery, window) -> 'Connection re-established': 'Connection re-established' 'Today': 'Today' - T: (string) -> + T: (string) => return @strings[string] - view: (name) -> - return window.zammadChatTemplates[name] + view: (name) => + return (options) => + if !options + options = {} + + options.T = @T + return window.zammadChatTemplates[name](options) constructor: (el, options) -> @options = $.extend {}, @defaults, options - @el = $(@view('chat')()) + @el = $(@view('chat')(@options)) @options.target.append @el @setAgentOnlineState @isOnline @@ -46,19 +52,18 @@ do($ = window.jQuery, window) -> ).autoGrow { extraLine: false } if !window.WebSocket - console.log('no websockets available') + console.log('Zammad Chat: Browser not supported') return zammad_host = 'ws://localhost:6042' @ws = new window.WebSocket(zammad_host) - console.log("connecting ws #{zammad_host}") + console.log("Connecting to #{zammad_host}") @ws.onopen = => console.log('ws connected') + @send "chat_status" - @ws.onmessage = (e) => - pipe = JSON.parse( e.data ) - console.log 'debug', 'ws:onmessage', pipe + @ws.onmessage = @onWebSocketMessage @ws.onclose = (e) => console.log 'debug', 'close websocket connection' @@ -71,6 +76,44 @@ do($ = window.jQuery, window) -> event.preventDefault() @sendMessage() + send: (action, data) => + pipe = JSON.stringify + action: action + data: data + + @ws.send pipe + + onWebSocketMessage: (e) => + pipe = JSON.parse( e.data ) + console.log 'debug', 'ws:onmessage', pipe + + switch pipe.action + when 'message' + @receiveMessage pipe.data + when 'typing_start' + @onAgentTypingStart() + when 'typing_end' + @onAgentTypingEnd() + when 'chat_init' + switch pipe.data.state + when 'ok' + @onConnectionEstablished pipe.data.agent + when 'queue' + @onQueue pipe.data.position + when 'chat_status' + switch pipe.data.state + when 'ok' + @onReady() + when 'offline' + console.log 'Zammad Chat: No agent online' + when 'chat_disabled' + console.log 'Zammad Chat: Chat is disabled' + when 'no_seats_available' + console.log 'Zammad Chat: Too many clients in queue. Clients in queue: ', pipe.data.queue + + onReady: => + @show() if @options.show + onInput: => # remove unread-state from messages @el.find('.zammad-chat-message--unread') @@ -86,10 +129,12 @@ do($ = window.jQuery, window) -> onTypingStart: -> # send typing start event @isTyping = true + @send 'typing_start' onTypingEnd: => # send typing end event @isTyping = false + @send 'typing_end' onSubmit: (event) => event.preventDefault() @@ -98,28 +143,35 @@ do($ = window.jQuery, window) -> sendMessage: -> message = @el.find('.zammad-chat-input').val() - if message - messageElement = @view('message') - message: message - from: 'customer' + if !message + return - @maybeAddTimestamp() + messageElement = @view('message') + message: message + from: 'customer' + id: @_messageCount++ - # add message before message typing loader - if @el.find('.zammad-chat-message--typing').size() - @lastAddedType = 'typing-placeholder' - @el.find('.zammad-chat-message--typing').before messageElement - else - @lastAddedType = 'message--customer' - @el.find('.zammad-chat-body').append messageElement + @maybeAddTimestamp() - @el.find('.zammad-chat-input').val('') - @scrollToBottom() + # add message before message typing loader + if @el.find('.zammad-chat-message--typing').size() + @lastAddedType = 'typing-placeholder' + @el.find('.zammad-chat-message--typing').before messageElement + else + @lastAddedType = 'message--customer' + @el.find('.zammad-chat-body').append messageElement - @isTyping = false - # send message event + @el.find('.zammad-chat-input').val('') + @scrollToBottom() - receiveMessage: (message) => + @isTyping = false + + # send message event + @send 'message', + body: message + id: @_messageCount + + receiveMessage: (data) => # hide writing indicator @onAgentTypingEnd() @@ -128,7 +180,8 @@ do($ = window.jQuery, window) -> @lastAddedType = 'message--agent' unread = document.hidden ? " zammad-chat-message--unread" : "" @el.find('.zammad-chat-body').append @view('message') - message: message + message: data.body + id: data.id from: 'agent' @scrollToBottom() @@ -136,15 +189,18 @@ do($ = window.jQuery, window) -> if @isOpen then @close() else @open() open: -> + @showLoader() + @el .addClass('zammad-chat-is-open') .animate { bottom: 0 }, 500, @onOpenAnimationEnd onOpenAnimationEnd: => @isOpen = true - setTimeout @onConnectionEstablished, 1180 - setTimeout @onAgentTypingStart, 2000 - setTimeout @receiveMessage, 5000, "Hello! How can I help you?" + #setTimeout @onQueue, 1180 + # setTimeout @onConnectionEstablished, 1180 + # setTimeout @onAgentTypingStart, 2000 + # setTimeout @receiveMessage, 5000, "Hello! How can I help you?" @connect() close: -> @@ -166,8 +222,15 @@ do($ = window.jQuery, window) -> @el.css 'bottom', -remainerHeight + onQueue: (position) => + console.log "onQueue", position + @inQueue = true + + @el.find('.zammad-chat-body').html @view('waiting') + position: position + onAgentTypingStart: => - # never display two loaders + # never display two typing indicators return if @el.find('.zammad-chat-message--typing').size() @maybeAddTimestamp() @@ -212,7 +275,7 @@ do($ = window.jQuery, window) -> @el.find('.zammad-chat-body').scrollTop($('.zammad-chat-body').prop('scrollHeight')) connect: -> - + @send('chat_init') reconnect: => # set status to connecting @@ -227,17 +290,26 @@ do($ = window.jQuery, window) -> @addStatus @T('Connection re-established') disconnect: -> - @el.find('.zammad-chat-loader').removeClass('zammad-chat-is-hidden'); - @el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden'); - @el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden'); - @el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden'); + @showLoader() + @el.find('.zammad-chat-welcome').removeClass('zammad-chat-is-hidden') + @el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden') + @el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden') - onConnectionEstablished: => - @el.find('.zammad-chat-loader').addClass('zammad-chat-is-hidden'); - @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(); + onConnectionEstablished: (agent) => + @inQueue = false + @agent = agent + + @el.find('.zammad-chat-agent').html @view('agent') + agent: agent + + @el.find('.zammad-chat-body').empty() + @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() + + showLoader: -> + @el.find('.zammad-chat-body').html @view('loader')() setAgentOnlineState: (state) => @isOnline = state diff --git a/public/assets/chat/chat.js b/public/assets/chat/chat.js index f96f7baad..9b8a125ab 100644 --- a/public/assets/chat/chat.js +++ b/public/assets/chat/chat.js @@ -1,7 +1,7 @@ if (!window.zammadChatTemplates) { window.zammadChatTemplates = {}; } -window.zammadChatTemplates["chat"] = function (__obj) { +window.zammadChatTemplates["agent"] = function (__obj) { if (!__obj) __obj = {}; var __out = [], __capture = function(callback) { var out = __out, result; @@ -40,7 +40,19 @@ window.zammadChatTemplates["chat"] = function (__obj) { } (function() { (function() { - __out.push('
\n
\n
\n Online\n \n \n \n \n
\n
\n \n \n Adam is helping you.\n \n
\n
\n \n Chat with us!\n
\n
\n
\n \n \n \n \n \n Connecting\n
\n
\n
\n \n \n
\n
'); + __out.push('\n\n '); + + __out.push(__sanitize(this.agent.name)); + + __out.push(' '); + + __out.push(this.agentPhrase); + + __out.push('\n'); }).call(this); @@ -56,11 +68,13 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); ZammadChat = (function() { ZammadChat.prototype.defaults = { invitationPhrase: 'Chat with us!', - agentPhrase: '%%agent%% is helping you', + agentPhrase: ' is helping you', show: true, target: $('body') }; + ZammadChat.prototype._messageCount = 0; + ZammadChat.prototype.isOpen = false; ZammadChat.prototype.blinkOnlineInterval = null; @@ -92,7 +106,15 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; ZammadChat.prototype.view = function(name) { - return window.zammadChatTemplates[name]; + return (function(_this) { + return function(options) { + if (!options) { + options = {}; + } + options.T = _this.T; + return window.zammadChatTemplates[name](options); + }; + })(this); }; function ZammadChat(el, options) { @@ -102,6 +124,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); this.reconnect = bind(this.reconnect, 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.onOpenAnimationEnd = bind(this.onOpenAnimationEnd, this); this.toggle = bind(this.toggle, this); @@ -109,9 +132,15 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); 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.T = bind(this.T, this); + var zammad_host; this.options = $.extend({}, this.defaults, options); - this.el = $(this.view('chat')()); + this.el = $(this.view('chat')(this.options)); this.options.target.append(this.el); this.setAgentOnlineState(this.isOnline); this.el.find('.zammad-chat-header').click(this.toggle); @@ -122,6 +151,30 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }).autoGrow({ extraLine: false }); + if (!window.WebSocket) { + console.log('Zammad Chat: Browser not supported'); + return; + } + zammad_host = 'ws://localhost:6042'; + this.ws = new window.WebSocket(zammad_host); + console.log("Connecting to " + zammad_host); + this.ws.onopen = (function(_this) { + return function() { + console.log('ws connected'); + return _this.send("chat_status"); + }; + })(this); + this.ws.onmessage = this.onWebSocketMessage; + this.ws.onclose = (function(_this) { + return function(e) { + return console.log('debug', 'close websocket connection'); + }; + })(this); + this.ws.onerror = (function(_this) { + return function(e) { + return console.log('debug', 'ws:onerror', e); + }; + })(this); } ZammadChat.prototype.checkForEnter = function(event) { @@ -131,6 +184,54 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); } }; + ZammadChat.prototype.send = function(action, data) { + var pipe; + pipe = JSON.stringify({ + action: action, + data: data + }); + return this.ws.send(pipe); + }; + + ZammadChat.prototype.onWebSocketMessage = function(e) { + var pipe; + pipe = JSON.parse(e.data); + console.log('debug', 'ws:onmessage', pipe); + switch (pipe.action) { + case 'message': + return this.receiveMessage(pipe.data); + case 'typing_start': + return this.onAgentTypingStart(); + case 'typing_end': + return this.onAgentTypingEnd(); + case 'chat_init': + switch (pipe.data.state) { + case 'ok': + return this.onConnectionEstablished(pipe.data.agent); + case 'queue': + return this.onQueue(pipe.data.position); + } + break; + case 'chat_status': + switch (pipe.data.state) { + case 'ok': + return this.onReady(); + case 'offline': + return console.log('Zammad Chat: No agent online'); + case 'chat_disabled': + return console.log('Zammad Chat: Chat is disabled'); + case 'no_seats_available': + return console.log('Zammad Chat: Too many clients in queue. Clients in queue: ', pipe.data.queue); + } + } + }; + + ZammadChat.prototype.onReady = function() { + if (this.options.show) { + return this.show(); + } + }; + ZammadChat.prototype.onInput = function() { this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread'); if (this.inputTimeout) { @@ -143,11 +244,13 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; ZammadChat.prototype.onTypingStart = function() { - return this.isTyping = true; + this.isTyping = true; + return this.send('typing_start'); }; ZammadChat.prototype.onTypingEnd = function() { - return this.isTyping = false; + this.isTyping = false; + return this.send('typing_end'); }; ZammadChat.prototype.onSubmit = function(event) { @@ -158,26 +261,32 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); ZammadChat.prototype.sendMessage = function() { var message, messageElement; message = this.el.find('.zammad-chat-input').val(); - if (message) { - messageElement = this.view('message')({ - message: message, - from: 'customer' - }); - 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(); - return this.isTyping = false; + 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('message', { + body: message, + id: this._messageCount + }); }; - ZammadChat.prototype.receiveMessage = function(message) { + ZammadChat.prototype.receiveMessage = function(data) { var ref, unread; this.onAgentTypingEnd(); this.maybeAddTimestamp(); @@ -186,7 +295,8 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); " zammad-chat-message--unread": "" }; this.el.find('.zammad-chat-body').append(this.view('message')({ - message: message, + message: data.body, + id: data.id, from: 'agent' })); return this.scrollToBottom(); @@ -201,6 +311,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; ZammadChat.prototype.open = function() { + this.showLoader(); return this.el.addClass('zammad-chat-is-open').animate({ bottom: 0 }, 500, this.onOpenAnimationEnd); @@ -208,9 +319,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); ZammadChat.prototype.onOpenAnimationEnd = function() { this.isOpen = true; - setTimeout(this.onConnectionEstablished, 1180); - setTimeout(this.onAgentTypingStart, 2000); - setTimeout(this.receiveMessage, 5000, "Hello! How can I help you?"); return this.connect(); }; @@ -239,6 +347,14 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); return this.el.css('bottom', -remainerHeight); }; + ZammadChat.prototype.onQueue = function(position) { + console.log("onQueue", position); + this.inQueue = true; + return this.el.find('.zammad-chat-body').html(this.view('waiting')({ + position: position + })); + }; + ZammadChat.prototype.onAgentTypingStart = function() { if (this.el.find('.zammad-chat-message--typing').size()) { return; @@ -287,7 +403,9 @@ 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.connect = function() {}; + ZammadChat.prototype.connect = function() { + return this.send('chat_init'); + }; ZammadChat.prototype.reconnect = function() { this.lastAddedType = 'status'; @@ -302,20 +420,29 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; ZammadChat.prototype.disconnect = function() { - this.el.find('.zammad-chat-loader').removeClass('zammad-chat-is-hidden'); + 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() { - this.el.find('.zammad-chat-loader').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.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')); @@ -406,6 +533,116 @@ jQuery.fn.autoGrow = function(options) { }); }; +if (!window.zammadChatTemplates) { + window.zammadChatTemplates = {}; +} +window.zammadChatTemplates["chat"] = function (__obj) { + if (!__obj) __obj = {}; + var __out = [], __capture = function(callback) { + var out = __out, result; + __out = []; + callback.call(this); + result = __out.join(''); + __out = out; + return __safe(result); + }, __sanitize = function(value) { + if (value && value.ecoSafe) { + return value; + } else if (typeof value !== 'undefined' && value != null) { + return __escape(value); + } else { + return ''; + } + }, __safe, __objSafe = __obj.safe, __escape = __obj.escape; + __safe = __obj.safe = function(value) { + if (value && value.ecoSafe) { + return value; + } else { + if (!(typeof value !== 'undefined' && value != null)) value = ''; + var result = new String(value); + result.ecoSafe = true; + return result; + } + }; + if (!__escape) { + __escape = __obj.escape = function(value) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + }; + } + (function() { + (function() { + __out.push('
\n
\n
\n Online\n \n \n \n \n
\n
\n \n
\n
\n \n '); + + __out.push(this.invitationPhrase); + + __out.push('\n
\n
\n
\n
\n \n \n
\n
'); + + }).call(this); + + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +}; + +if (!window.zammadChatTemplates) { + window.zammadChatTemplates = {}; +} +window.zammadChatTemplates["loader"] = function (__obj) { + if (!__obj) __obj = {}; + var __out = [], __capture = function(callback) { + var out = __out, result; + __out = []; + callback.call(this); + result = __out.join(''); + __out = out; + return __safe(result); + }, __sanitize = function(value) { + if (value && value.ecoSafe) { + return value; + } else if (typeof value !== 'undefined' && value != null) { + return __escape(value); + } else { + return ''; + } + }, __safe, __objSafe = __obj.safe, __escape = __obj.escape; + __safe = __obj.safe = function(value) { + if (value && value.ecoSafe) { + return value; + } else { + if (!(typeof value !== 'undefined' && value != null)) value = ''; + var result = new String(value); + result.ecoSafe = true; + return result; + } + }; + if (!__escape) { + __escape = __obj.escape = function(value) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + }; + } + (function() { + (function() { + __out.push('
\n \n \n \n \n \n '); + + __out.push(__sanitize(this.T('Connecting'))); + + __out.push('\n
'); + + }).call(this); + + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +}; + if (!window.zammadChatTemplates) { window.zammadChatTemplates = {}; } @@ -574,3 +811,58 @@ window.zammadChatTemplates["typingIndicator"] = function (__obj) { __obj.safe = __objSafe, __obj.escape = __escape; return __out.join(''); }; + +if (!window.zammadChatTemplates) { + window.zammadChatTemplates = {}; +} +window.zammadChatTemplates["waiting"] = function (__obj) { + if (!__obj) __obj = {}; + var __out = [], __capture = function(callback) { + var out = __out, result; + __out = []; + callback.call(this); + result = __out.join(''); + __out = out; + return __safe(result); + }, __sanitize = function(value) { + if (value && value.ecoSafe) { + return value; + } else if (typeof value !== 'undefined' && value != null) { + return __escape(value); + } else { + return ''; + } + }, __safe, __objSafe = __obj.safe, __escape = __obj.escape; + __safe = __obj.safe = function(value) { + if (value && value.ecoSafe) { + return value; + } else { + if (!(typeof value !== 'undefined' && value != null)) value = ''; + var result = new String(value); + result.ecoSafe = true; + return result; + } + }; + if (!__escape) { + __escape = __obj.escape = function(value) { + return ('' + value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + }; + } + (function() { + (function() { + __out.push('
\n
\n \n \n \n \n \n Leider sind gerade alle Mitarbeiter belegt.
\n Warteliste-Position: '); + + __out.push(__sanitize(this.position)); + + __out.push('\n
\n
'); + + }).call(this); + + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +}; diff --git a/public/assets/chat/chat.min.js b/public/assets/chat/chat.min.js index 7380da603..54ed788e2 100644 --- a/public/assets/chat/chat.min.js +++ b/public/assets/chat/chat.min.js @@ -1 +1 @@ -window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.chat=function(t){t||(t={});var e,a=[],n=t.safe,s=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},s||(s=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){a.push('
\n
\n
\n Online\n \n \n \n \n
\n
\n \n \n Adam is helping you.\n \n
\n
\n \n Chat with us!\n
\n
\n
\n \n \n \n \n \n Connecting\n
\n
\n
\n \n \n
\n
')}).call(this)}.call(t),t.safe=n,t.escape=s,a.join("")};var bind=function(t,e){return function(){return t.apply(e,arguments)}};!function(t,e){var a;return a=function(){function a(e,a){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.onAgentTypingEnd=bind(this.onAgentTypingEnd,this),this.onAgentTypingStart=bind(this.onAgentTypingStart,this),this.onCloseAnimationEnd=bind(this.onCloseAnimationEnd,this),this.onOpenAnimationEnd=bind(this.onOpenAnimationEnd,this),this.toggle=bind(this.toggle,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.checkForEnter=bind(this.checkForEnter,this),this.options=t.extend({},this.defaults,a),this.el=t(this.view("chat")()),this.options.target.append(this.el),this.setAgentOnlineState(this.isOnline),this.el.find(".zammad-chat-header").click(this.toggle),this.el.find(".zammad-chat-controls").on("submit",this.onSubmit),this.el.find(".zammad-chat-input").on({keydown:this.checkForEnter,input:this.onInput}).autoGrow({extraLine:!1})}return a.prototype.defaults={invitationPhrase:"Chat with us!",agentPhrase:"%%agent%% is helping you",show:!0,target:t("body")},a.prototype.isOpen=!1,a.prototype.blinkOnlineInterval=null,a.prototype.stopBlinOnlineStateTimeout=null,a.prototype.showTimeEveryXMinutes=1,a.prototype.lastTimestamp=null,a.prototype.lastAddedType=null,a.prototype.inputTimeout=null,a.prototype.isTyping=!1,a.prototype.isOnline=!0,a.prototype.strings={Online:"Online",Offline:"Offline",Connecting:"Connecting","Connection re-established":"Connection re-established",Today:"Today"},a.prototype.T=function(t){return this.strings[t]},a.prototype.view=function(t){return e.zammadChatTemplates[t]},a.prototype.checkForEnter=function(t){return t.shiftKey||13!==t.keyCode?void 0:(t.preventDefault(),this.sendMessage())},a.prototype.onInput=function(){return this.el.find(".zammad-chat-message--unread").removeClass("zammad-chat-message--unread"),this.inputTimeout&&clearTimeout(this.inputTimeout),this.inputTimeout=setTimeout(this.onTypingEnd,5e3),this.isTyping?this.onTypingStart():void 0},a.prototype.onTypingStart=function(){return this.isTyping=!0},a.prototype.onTypingEnd=function(){return this.isTyping=!1},a.prototype.onSubmit=function(t){return t.preventDefault(),this.sendMessage()},a.prototype.sendMessage=function(){var t,e;return t=this.el.find(".zammad-chat-input").val(),t?(e=this.view("message")({message:t,from:"customer"}),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):void 0},a.prototype.receiveMessage=function(t){var e,a;return this.onAgentTypingEnd(),this.maybeAddTimestamp(),this.lastAddedType="message--agent",a=null!=(e=document.hidden)?e:{" zammad-chat-message--unread":""},this.el.find(".zammad-chat-body").append(this.view("message")({message:t,from:"agent"})),this.scrollToBottom()},a.prototype.toggle=function(){return this.isOpen?this.close():this.open()},a.prototype.open=function(){return this.el.addClass("zammad-chat-is-open").animate({bottom:0},500,this.onOpenAnimationEnd)},a.prototype.onOpenAnimationEnd=function(){return this.isOpen=!0,setTimeout(this.onConnectionEstablished,1180),setTimeout(this.onAgentTypingStart,2e3),setTimeout(this.receiveMessage,5e3,"Hello! How can I help you?"),this.connect()},a.prototype.close=function(){var t;return t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-t},500,this.onCloseAnimationEnd)},a.prototype.onCloseAnimationEnd=function(){return this.el.removeClass("zammad-chat-is-open"),this.disconnect(),this.isOpen=!1},a.prototype.hide=function(){return this.el.removeClass("zammad-chat-is-visible")},a.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)},a.prototype.onAgentTypingStart=function(){return this.el.find(".zammad-chat-message--typing").size()?void 0:(this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("typingIndicator")()),this.scrollToBottom())},a.prototype.onAgentTypingEnd=function(){return this.el.find(".zammad-chat-message--typing").remove()},a.prototype.maybeAddTimestamp=function(){var t,e,a;return a=Date.now(),!this.lastTimestamp||a-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=a):(this.addStatus(t,e),this.lastTimestamp=a,this.lastAddedType="timestamp")):void 0},a.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}))},a.prototype.addStatus=function(t,e){return this.el.find(".zammad-chat-body").append(this.view("status")({label:t,time:e}))},a.prototype.scrollToBottom=function(){return this.el.find(".zammad-chat-body").scrollTop(t(".zammad-chat-body").prop("scrollHeight"))},a.prototype.connect=function(){},a.prototype.reconnect=function(){return this.lastAddedType="status",this.el.find(".zammad-chat-agent-status").attr("data-status","connecting").text(this.T("Connecting")),this.addStatus(this.T("Connection lost"))},a.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"))},a.prototype.disconnect=function(){return this.el.find(".zammad-chat-loader").removeClass("zammad-chat-is-hidden"),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")},a.prototype.onConnectionEstablished=function(){return this.el.find(".zammad-chat-loader").addClass("zammad-chat-is-hidden"),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()},a.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"))},a}(),t(document).ready(function(){return e.zammadChat=new a})}(window.jQuery,window),jQuery.fn.autoGrow=function(t){return this.each(function(){var e=jQuery.extend({extraLine:!0},t),a=function(t){return jQuery(t).after('
'),jQuery(t).next(".autogrow-textarea-mirror")[0]},n=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())},s=function(){n(this)},i=a(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=s,n(this)})},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=function(t){t||(t={});var e,a=[],n=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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(){a.push('
\n '),a.push(this.message),a.push("\n
")}).call(this)}.call(t),t.safe=s,t.escape=i,a.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=function(t){t||(t={});var e,a=[],n=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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(){a.push('
'),a.push(n(this.label)),a.push(""),a.push(n(this.time)),a.push("
")}).call(this)}.call(t),t.safe=s,t.escape=i,a.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(t){t||(t={});var e,a=[],n=t.safe,s=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},s||(s=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){a.push('
\n \n \n \n \n \n \n \n
')}).call(this)}.call(t),t.safe=n,t.escape=s,a.join("")}; \ No newline at end of file +window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.agent=function(t){t||(t={});var e,n=[],a=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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.push(a(this.agent.name)),n.push(" "),n.push(this.agentPhrase),n.push("\n")}).call(this)}.call(t),t.safe=s,t.escape=i,n.join("")};var bind=function(t,e){return function(){return t.apply(e,arguments)}};!function(t,e){var n;return n=function(){function n(n,a){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.onAgentTypingEnd=bind(this.onAgentTypingEnd,this),this.onAgentTypingStart=bind(this.onAgentTypingStart,this),this.onQueue=bind(this.onQueue,this),this.onCloseAnimationEnd=bind(this.onCloseAnimationEnd,this),this.onOpenAnimationEnd=bind(this.onOpenAnimationEnd,this),this.toggle=bind(this.toggle,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.T=bind(this.T,this);var s;return this.options=t.extend({},this.defaults,a),this.el=t(this.view("chat")(this.options)),this.options.target.append(this.el),this.setAgentOnlineState(this.isOnline),this.el.find(".zammad-chat-header").click(this.toggle),this.el.find(".zammad-chat-controls").on("submit",this.onSubmit),this.el.find(".zammad-chat-input").on({keydown:this.checkForEnter,input:this.onInput}).autoGrow({extraLine:!1}),e.WebSocket?(s="ws://localhost:6042",this.ws=new e.WebSocket(s),console.log("Connecting to "+s),this.ws.onopen=function(t){return function(){return console.log("ws connected"),t.send("chat_status")}}(this),this.ws.onmessage=this.onWebSocketMessage,this.ws.onclose=function(t){return function(t){return console.log("debug","close websocket connection")}}(this),void(this.ws.onerror=function(t){return function(t){return console.log("debug","ws:onerror",t)}}(this))):void console.log("Zammad 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.strings={Online:"Online",Offline:"Offline",Connecting:"Connecting","Connection re-established":"Connection re-established",Today:"Today"},n.prototype.T=function(t){return this.strings[t]},n.prototype.view=function(t){return function(n){return function(a){return a||(a={}),a.T=n.T,e.zammadChatTemplates[t](a)}}(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 n=JSON.stringify({action:t,data:e}),this.ws.send(n)},n.prototype.onWebSocketMessage=function(t){var e;switch(e=JSON.parse(t.data),console.log("debug","ws:onmessage",e),e.action){case"message":return this.receiveMessage(e.data);case"typing_start":return this.onAgentTypingStart();case"typing_end":return this.onAgentTypingEnd();case"chat_init":switch(e.data.state){case"ok":return this.onConnectionEstablished(e.data.agent);case"queue":return this.onQueue(e.data.position)}break;case"chat_status":switch(e.data.state){case"ok":return this.onReady();case"offline":return console.log("Zammad Chat: No agent online");case"chat_disabled":return console.log("Zammad Chat: Chat is disabled");case"no_seats_available":return console.log("Zammad Chat: Too many clients in queue. Clients in queue: ",e.data.queue)}}},n.prototype.onReady=function(){return this.options.show?this.show():void 0},n.prototype.onInput=function(){return this.el.find(".zammad-chat-message--unread").removeClass("zammad-chat-message--unread"),this.inputTimeout&&clearTimeout(this.inputTimeout),this.inputTimeout=setTimeout(this.onTypingEnd,5e3),this.isTyping?this.onTypingStart():void 0},n.prototype.onTypingStart=function(){return this.isTyping=!0,this.send("typing_start")},n.prototype.onTypingEnd=function(){return this.isTyping=!1,this.send("typing_end")},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("message",{body:t,id:this._messageCount})):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.body,id:t.id,from:"agent"})),this.scrollToBottom()},n.prototype.toggle=function(){return this.isOpen?this.close():this.open()},n.prototype.open=function(){return this.showLoader(),this.el.addClass("zammad-chat-is-open").animate({bottom:0},500,this.onOpenAnimationEnd)},n.prototype.onOpenAnimationEnd=function(){return this.isOpen=!0,this.connect()},n.prototype.close=function(){var t;return t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-t},500,this.onCloseAnimationEnd)},n.prototype.onCloseAnimationEnd=function(){return this.el.removeClass("zammad-chat-is-open"),this.disconnect(),this.isOpen=!1},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.onQueue=function(t){return console.log("onQueue",t),this.inQueue=!0,this.el.find(".zammad-chat-body").html(this.view("waiting")({position:t}))},n.prototype.onAgentTypingStart=function(){return 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.connect=function(){return this.send("chat_init")},n.prototype.reconnect=function(){return this.lastAddedType="status",this.el.find(".zammad-chat-agent-status").attr("data-status","connecting").text(this.T("Connecting")),this.addStatus(this.T("Connection lost"))},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.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.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),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]},a=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())},s=function(){a(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=s,a(this)})},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.chat=function(t){t||(t={});var e,n=[],a=t.safe,s=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},s||(s=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 '),n.push(this.invitationPhrase),n.push('\n
\n
\n
\n
\n \n \n
\n
')}).call(this)}.call(t),t.safe=a,t.escape=s,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.loader=function(t){t||(t={});var e,n=[],a=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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(a(this.T("Connecting"))),n.push("\n
")}).call(this)}.call(t),t.safe=s,t.escape=i,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=function(t){t||(t={});var e,n=[],a=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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=s,t.escape=i,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=function(t){t||(t={});var e,n=[],a=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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(a(this.label)),n.push(""),n.push(a(this.time)),n.push("
")}).call(this)}.call(t),t.safe=s,t.escape=i,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(t){t||(t={});var e,n=[],a=t.safe,s=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},s||(s=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=a,t.escape=s,n.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting=function(t){t||(t={});var e,n=[],a=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?i(t):""},s=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 Leider sind gerade alle Mitarbeiter belegt.
\n Warteliste-Position: '),n.push(a(this.position)),n.push("\n
\n
")}).call(this)}.call(t),t.safe=s,t.escape=i,n.join("")}; \ No newline at end of file diff --git a/public/assets/chat/style.css b/public/assets/chat/style.css index 0a7601e37..35d87a3f6 100644 --- a/public/assets/chat/style.css +++ b/public/assets/chat/style.css @@ -123,7 +123,7 @@ -webkit-transform: scale(1); transform: scale(1); } } -.zammad-chat-loader { +.zammad-chat-modal { position: absolute; left: 0; right: 0; @@ -144,12 +144,15 @@ -ms-flex-pack: center; justify-content: center; } -.zammad-chat-loader-text { - font-size: 1.3em; } +.zammad-chat-modal-text { + font-size: 1.3em; + line-height: 1.45; } + .zammad-chat-modal-text .zammad-chat-loading-animation { + font-size: 0.7em; } -.zammad-chat-loader .zammad-chat-loading-animation { +.zammad-chat-modal .zammad-chat-loading-animation { margin-right: 8px; - margin-left: -19px; } + vertical-align: middle; } .zammad-chat-body { padding: 0.5em 1em; @@ -192,6 +195,9 @@ .zammad-chat-message--typing .zammad-chat-message-body { white-space: normal; } +.zammad-chat-loading-animation { + display: inline-block; } + .zammad-chat-loading-circle { background: #c5dded; border-radius: 100%; diff --git a/public/assets/chat/style.scss b/public/assets/chat/style.scss index d4b9ed736..39be56372 100644 --- a/public/assets/chat/style.scss +++ b/public/assets/chat/style.scss @@ -154,7 +154,7 @@ $baseTextColor: if($luminance < 0.2, white, black); to { opacity: 1; transform: scale(1); } } -.zammad-chat-loader { +.zammad-chat-modal { position: absolute; left: 0; right: 0; @@ -170,13 +170,18 @@ $baseTextColor: if($luminance < 0.2, white, black); justify-content: center; } -.zammad-chat-loader-text { +.zammad-chat-modal-text { font-size: 1.3em; + line-height: 1.45; + + .zammad-chat-loading-animation { + font-size: 0.7em; + } } -.zammad-chat-loader .zammad-chat-loading-animation { +.zammad-chat-modal .zammad-chat-loading-animation { margin-right: 8px; - margin-left: -19px; + vertical-align: middle; } .zammad-chat-body { @@ -232,6 +237,10 @@ $baseTextColor: if($luminance < 0.2, white, black); white-space: normal; } +.zammad-chat-loading-animation { + display: inline-block; +} + .zammad-chat-loading-circle { background: desaturate(lightenMax($themeColor, 50%, 85%), 15%); border-radius: 100%; diff --git a/public/assets/chat/views/agent.eco b/public/assets/chat/views/agent.eco new file mode 100644 index 000000000..0ce307469 --- /dev/null +++ b/public/assets/chat/views/agent.eco @@ -0,0 +1,4 @@ + + + <%= @agent.name %> <%- @agentPhrase %> + \ No newline at end of file diff --git a/public/assets/chat/views/chat.eco b/public/assets/chat/views/chat.eco index ed76bb8fb..2fcbd8ea0 100644 --- a/public/assets/chat/views/chat.eco +++ b/public/assets/chat/views/chat.eco @@ -8,24 +8,13 @@
- - - Adam is helping you. - +
- Chat with us! + <%- @invitationPhrase %>
-
- - - - - - Connecting -
diff --git a/public/assets/chat/views/loader.eco b/public/assets/chat/views/loader.eco new file mode 100644 index 000000000..5350be7b0 --- /dev/null +++ b/public/assets/chat/views/loader.eco @@ -0,0 +1,8 @@ +
+ + + + + + <%= @T('Connecting') %> +
\ No newline at end of file diff --git a/public/assets/chat/views/waiting.eco b/public/assets/chat/views/waiting.eco new file mode 100644 index 000000000..b7513edc9 --- /dev/null +++ b/public/assets/chat/views/waiting.eco @@ -0,0 +1,11 @@ +
+
+ + + + + + Leider sind gerade alle Mitarbeiter belegt.
+ Warteliste-Position: <%= @position %> +
+
\ No newline at end of file