diff --git a/public/assets/chat/chat.coffee b/public/assets/chat/chat.coffee index 48e12b724..9f8243705 100644 --- a/public/assets/chat/chat.coffee +++ b/public/assets/chat/chat.coffee @@ -224,6 +224,10 @@ do($ = window.jQuery, window) -> @options = $.extend {}, @defaults, options super(@options) + # fullscreen + @isFullscreen = (window.matchMedia and window.matchMedia('(max-width: 768px)').matches) + @scrollRoot = $(@getScrollRoot()) + # check prerequisites if !$ @state = 'unsupported' @@ -259,29 +263,18 @@ do($ = window.jQuery, window) -> ) @io.connect() + getScrollRoot: -> + return document.scrollingElement if 'scrollingElement' of document + html = document.documentElement + start = html.scrollTop + html.scrollTop = start + 1 + end = html.scrollTop + html.scrollTop = start + return if end > start then html else document.body + render: => if !@el || !$('.zammad-chat').get(0) - @el = $(@view('chat')( - title: @options.title - )) - @options.target.append @el - - @input = @el.find('.zammad-chat-input') - - # start bindings - @el.find('.js-chat-open').click @open - @el.find('.js-chat-close').click @close - @el.find('.zammad-chat-controls').on 'submit', @onSubmit - @input.on - keydown: @checkForEnter - input: @onInput - $(window).on('beforeunload', => - @onLeaveTemporary() - ) - $(window).bind('hashchange', => - return if @isOpen - @idleTimeout.start() - ) + @renderBase() # disable open button $(".#{ @options.buttonClass }").addClass @inactiveClass @@ -298,6 +291,34 @@ do($ = window.jQuery, window) -> @send 'chat_status_customer', session_id: @sessionId + renderBase: -> + @el = $(@view('chat')( + title: @options.title + )) + @options.target.append @el + + @input = @el.find('.zammad-chat-input') + + # start bindings + @el.find('.js-chat-open').click @open + @el.find('.js-chat-toggle').click @toggle + @el.find('.zammad-chat-controls').on 'submit', @onSubmit + @input.on + keydown: @checkForEnter + input: @onInput + $(window).on('beforeunload', => + @onLeaveTemporary() + ) + $(window).bind('hashchange', => + return if @isOpen + @idleTimeout.start() + ) + + if @isFullscreen + @input.on + focus: @onFocus + focusout: @onFocusOut + checkForEnter: (event) => if not event.shiftKey and event.keyCode is 13 event.preventDefault() @@ -399,6 +420,19 @@ do($ = window.jQuery, window) -> @onTyping() + onFocus: => + $(window).scrollTop(10) + keyboardShown = $(window).scrollTop() > 0 + $(window).scrollTop(0) + + if keyboardShown + @log.notice 'virtual keyboard shown' + # on keyboard shown + # can't measure visible area height :( + + onFocusOut: -> + # on keyboard hidden + onTyping: -> # send typing start event only every 1.5 seconds @@ -487,6 +521,9 @@ do($ = window.jQuery, window) -> onOpenAnimationEnd: => @idleTimeout.stop() + if @isFullscreen + @disableScrollOnRoot() + sessionClose: => # send close @send 'chat_session_close', @@ -505,6 +542,12 @@ do($ = window.jQuery, window) -> @setSessionId undefined + toggle: (event) => + if @isOpen + @close(event) + else + @open(event) + close: (event) => if !@isOpen @log.debug 'can\'t close widget, it\'s not open' @@ -519,6 +562,9 @@ do($ = window.jQuery, window) -> @sessionClose() + if @isFullscreen + @enableScrollOnRoot() + # close window @el.removeClass('zammad-chat-is-open') remainerHeight = @el.height() - @el.find('.zammad-chat-header').outerHeight() @@ -563,6 +609,9 @@ do($ = window.jQuery, window) -> @input.prop('disabled', false) @el.find('.zammad-chat-send').prop('disabled', false) + hideModal: -> + @el.find('.zammad-chat-modal').html '' + onQueueScreen: (data) => @setSessionId data.session_id @@ -586,7 +635,7 @@ do($ = window.jQuery, window) -> @log.notice 'onQueue', data.position @inQueue = true - @el.find('.zammad-chat-body').html @view('waiting') + @el.find('.zammad-chat-modal').html @view('waiting') position: data.position onAgentTypingStart: => @@ -713,11 +762,12 @@ do($ = window.jQuery, window) -> @enableInput() - @el.find('.zammad-chat-body').empty() + @hideModal() @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') - @input.focus() + + @input.focus() if not @isFullscreen @setAgentOnlineState 'online' @@ -726,7 +776,7 @@ do($ = window.jQuery, window) -> @inactiveTimeout.start() showCustomerTimeout: -> - @el.find('.zammad-chat-body').html @view('customer_timeout') + @el.find('.zammad-chat-modal').html @view('customer_timeout') agent: @agent.name delay: @options.inactiveTimeout reload = -> @@ -735,7 +785,7 @@ do($ = window.jQuery, window) -> @sessionClose() showWaitingListTimeout: -> - @el.find('.zammad-chat-body').html @view('waiting_list_timeout') + @el.find('.zammad-chat-modal').html @view('waiting_list_timeout') delay: @options.watingListTimeout reload = -> location.reload() @@ -743,7 +793,7 @@ do($ = window.jQuery, window) -> @sessionClose() showLoader: -> - @el.find('.zammad-chat-body').html @view('loader')() + @el.find('.zammad-chat-modal').html @view('loader')() setAgentOnlineState: (state) => @state = state @@ -808,4 +858,16 @@ do($ = window.jQuery, window) -> @destroy(remove: false) ) + disableScrollOnRoot: -> + @rootScrollOffset = @scrollRoot.scrollTop() + @scrollRoot.css + overflow: 'hidden' + position: 'fixed' + + enableScrollOnRoot: -> + @scrollRoot.scrollTop @rootScrollOffset + @scrollRoot.css + overflow: '' + position: '' + window.ZammadChat = ZammadChat diff --git a/public/assets/chat/chat.css b/public/assets/chat/chat.css index 612420152..aa119ac5f 100644 --- a/public/assets/chat/chat.css +++ b/public/assets/chat/chat.css @@ -23,8 +23,9 @@ .zammad-chat { right: 0; width: 100%; - height: 100vh; - border-radius: 0 !important; } } + height: 100%; + border-radius: 0 !important; + font-size: 16px; } } .zammad-chat.zammad-chat-is-shown { display: -webkit-flex; @@ -172,6 +173,8 @@ -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; } + .zammad-chat-modal:empty { + display: none; } .zammad-chat-modal-text { font-size: 1.3em; @@ -192,7 +195,8 @@ background: white; -webkit-flex: 1; -ms-flex: 1; - flex: 1; } + flex: 1; + -webkit-overflow-scrolling: touch; } @media only screen and (max-width: 768px) { .zammad-chat-body { height: auto; diff --git a/public/assets/chat/chat.js b/public/assets/chat/chat.js index 120a27f4e..c45c8222f 100644 --- a/public/assets/chat/chat.js +++ b/public/assets/chat/chat.js @@ -378,12 +378,15 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); this.onWebSocketClose = bind(this.onWebSocketClose, this); this.onCloseAnimationEnd = bind(this.onCloseAnimationEnd, this); this.close = bind(this.close, this); + this.toggle = bind(this.toggle, this); this.sessionClose = bind(this.sessionClose, 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.onFocusOut = bind(this.onFocusOut, this); + this.onFocus = bind(this.onFocus, this); this.onInput = bind(this.onInput, this); this.onReopenSession = bind(this.onReopenSession, this); this.onError = bind(this.onError, this); @@ -391,10 +394,13 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); this.send = bind(this.send, this); this.checkForEnter = bind(this.checkForEnter, this); this.render = bind(this.render, this); + this.getScrollRoot = bind(this.getScrollRoot, this); this.view = bind(this.view, this); this.T = bind(this.T, this); this.options = $.extend({}, this.defaults, options); ZammadChat.__super__.constructor.call(this, this.options); + this.isFullscreen = window.matchMedia && window.matchMedia('(max-width: 768px)').matches; + this.scrollRoot = $(this.getScrollRoot()); if (!$) { this.state = 'unsupported'; this.log.notice('Chat: no jquery found!'); @@ -431,33 +437,26 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); this.io.connect(); } + ZammadChat.prototype.getScrollRoot = function() { + var end, html, start; + if ("scrollingElement" in document) { + return document.scrollingElement; + } + html = document.documentElement; + start = html.scrollTop; + html.scrollTop = start + 1; + end = html.scrollTop; + html.scrollTop = start; + if (end > start) { + return html; + } else { + return document.body; + } + }; + ZammadChat.prototype.render = function() { if (!this.el || !$('.zammad-chat').get(0)) { - this.el = $(this.view('chat')({ - title: this.options.title - })); - 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 - }); - $(window).on('beforeunload', (function(_this) { - return function() { - return _this.onLeaveTemporary(); - }; - })(this)); - $(window).bind('hashchange', (function(_this) { - return function() { - if (_this.isOpen) { - return; - } - return _this.idleTimeout.start(); - }; - })(this)); + this.renderBase(); } $("." + this.options.buttonClass).addClass(this.inactiveClass); this.setAgentOnlineState('online'); @@ -470,6 +469,40 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }); }; + ZammadChat.prototype.renderBase = function() { + this.el = $(this.view('chat')({ + title: this.options.title + })); + 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-toggle').click(this.toggle); + this.el.find('.zammad-chat-controls').on('submit', this.onSubmit); + this.input.on({ + keydown: this.checkForEnter, + input: this.onInput + }); + $(window).on('beforeunload', (function(_this) { + return function() { + return _this.onLeaveTemporary(); + }; + })(this)); + $(window).bind('hashchange', (function(_this) { + return function() { + if (_this.isOpen) { + return; + } + return _this.idleTimeout.start(); + }; + })(this)); + if (this.isFullscreen) { + return this.input.on({ + focus: this.onFocus, + focusout: this.onFocusOut + }); + } + }; + ZammadChat.prototype.checkForEnter = function(event) { if (!event.shiftKey && event.keyCode === 13) { event.preventDefault(); @@ -606,6 +639,18 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); return this.onTyping(); }; + ZammadChat.prototype.onFocus = function() { + var keyboardShown; + $(window).scrollTop(10); + keyboardShown = $(window).scrollTop() > 0; + $(window).scrollTop(0); + if (keyboardShown) { + return this.log.notice("virtual keyboard shown"); + } + }; + + ZammadChat.prototype.onFocusOut = function() {}; + ZammadChat.prototype.onTyping = function() { if (this.isTyping && this.isTyping > new Date(new Date().getTime() - 1500)) { return; @@ -694,7 +739,10 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; ZammadChat.prototype.onOpenAnimationEnd = function() { - return this.idleTimeout.stop(); + this.idleTimeout.stop(); + if (this.isFullscreen) { + return this.disableScrollOnRoot(); + } }; ZammadChat.prototype.sessionClose = function() { @@ -710,6 +758,14 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); return this.setSessionId(void 0); }; + ZammadChat.prototype.toggle = function(event) { + if (this.isOpen) { + return this.close(event); + } else { + return this.open(event); + } + }; + ZammadChat.prototype.close = function(event) { var remainerHeight; if (!this.isOpen) { @@ -725,6 +781,9 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); event.stopPropagation(); } this.sessionClose(); + if (this.isFullscreen) { + this.enableScrollOnRoot(); + } this.el.removeClass('zammad-chat-is-open'); remainerHeight = this.el.height() - this.el.find('.zammad-chat-header').outerHeight(); return this.el.animate({ @@ -777,6 +836,10 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); return this.el.find('.zammad-chat-send').prop('disabled', false); }; + ZammadChat.prototype.hideModal = function() { + return this.el.find('.zammad-chat-modal').html(''); + }; + ZammadChat.prototype.onQueueScreen = function(data) { var show; this.setSessionId(data.session_id); @@ -799,7 +862,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); ZammadChat.prototype.onQueue = function(data) { this.log.notice('onQueue', data.position); this.inQueue = true; - return this.el.find('.zammad-chat-body').html(this.view('waiting')({ + return this.el.find('.zammad-chat-modal').html(this.view('waiting')({ position: data.position })); }; @@ -942,11 +1005,13 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); agent: this.agent })); this.enableInput(); - this.el.find('.zammad-chat-body').empty(); + this.hideModal(); 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(); + if (!this.isFullscreen) { + this.input.focus(); + } this.setAgentOnlineState('online'); this.waitingListTimeout.stop(); this.idleTimeout.stop(); @@ -955,7 +1020,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); ZammadChat.prototype.showCustomerTimeout = function() { var reload; - this.el.find('.zammad-chat-body').html(this.view('customer_timeout')({ + this.el.find('.zammad-chat-modal').html(this.view('customer_timeout')({ agent: this.agent.name, delay: this.options.inactiveTimeout })); @@ -968,7 +1033,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); ZammadChat.prototype.showWaitingListTimeout = function() { var reload; - this.el.find('.zammad-chat-body').html(this.view('waiting_list_timeout')({ + this.el.find('.zammad-chat-modal').html(this.view('waiting_list_timeout')({ delay: this.options.watingListTimeout })); reload = function() { @@ -979,7 +1044,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; ZammadChat.prototype.showLoader = function() { - return this.el.find('.zammad-chat-body').html(this.view('loader')()); + return this.el.find('.zammad-chat-modal').html(this.view('loader')()); }; ZammadChat.prototype.setAgentOnlineState = function(state) { @@ -1066,6 +1131,22 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }); }; + ZammadChat.prototype.disableScrollOnRoot = function() { + this.rootScrollOffset = this.scrollRoot.scrollTop(); + return this.scrollRoot.css({ + overflow: 'hidden', + position: 'fixed' + }); + }; + + ZammadChat.prototype.enableScrollOnRoot = function() { + this.scrollRoot.scrollTop(this.rootScrollOffset); + return this.scrollRoot.css({ + overflow: '', + position: '' + }); + }; + return ZammadChat; })(Base); @@ -1278,11 +1359,11 @@ window.zammadChatTemplates["chat"] = function (__obj) { __out.push(__sanitize(" style='background: " + this.background + "'")); } - __out.push('>\n
\n \n \n \n \n \n
\n
\n
\n
\n \n '); + __out.push('>\n
\n \n \n \n \n \n
\n
\n
\n
\n \n '); __out.push(this.T(this.title)); - __out.push('\n
\n
\n
\n
\n \n \n
\n")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.customer_timeout=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\n '),this.agent?(s.push("\n "),s.push(this.T("Since you didn't respond in the last %s minutes your conversation with %s got closed.",this.delay,this.agent)),s.push("\n ")):(s.push("\n "),s.push(this.T("Since you didn't respond in the last %s minutes your conversation got closed.",this.delay)),s.push("\n ")),s.push('\n
\n
"),s.push(this.T("Start new conversation")),s.push("
\n
\n
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.loader=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n \n \n \n \n \n '),s.push(this.T("Connecting")),s.push("\n
")}).call(this)}.call(t),t.safe=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=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=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\n '),s.push(this.status),s.push("\n
\n
")}).call(this)}.call(t),t.safe=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.timestamp=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
'),s.push(i(this.label)),s.push(" "),s.push(i(this.time)),s.push("
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=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=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}), -window.zammadChatTemplates.waiting=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=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 colleagues 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=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting_list_timeout=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\n '),s.push(this.T("We are sorry, it takes longer as expected to get an empty slot. Please try again later or send us an email. Thank you!")),s.push('\n
\n
"),s.push(this.T("Start new conversation")),s.push("
\n
\n
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")}; \ No newline at end of file +var bind=function(t,e){return function(){return t.apply(e,arguments)}},slice=[].slice,extend=function(t,e){function s(){this.constructor=t}for(var i in e)hasProp.call(e,i)&&(t[i]=e[i]);return s.prototype=e.prototype,t.prototype=new s,t.__super__=e.prototype,t},hasProp={}.hasOwnProperty;!function(t,e){var s,i,n,o,a,r,h,l;return l=document.getElementsByTagName("script"),r=l[l.length-1],h=r.src.match(".*://([^:/]*).*")[1],s=function(){function e(e){this.options=t.extend({},this.defaults,e),this.log=new n({debug:this.options.debug,logPrefix:this.options.logPrefix||this.logPrefix})}return e.prototype.defaults={debug:!1},e}(),n=function(){function e(e){this.log=bind(this.log,this),this.error=bind(this.error,this),this.notice=bind(this.notice,this),this.debug=bind(this.debug,this),this.options=t.extend({},this.defaults,e)}return e.prototype.defaults={debug:!1},e.prototype.debug=function(){var t;return t=1<=arguments.length?slice.call(arguments,0):[],this.options.debug?this.log("debug",t):void 0},e.prototype.notice=function(){var t;return t=1<=arguments.length?slice.call(arguments,0):[],this.log("notice",t)},e.prototype.error=function(){var t;return t=1<=arguments.length?slice.call(arguments,0):[],this.log("error",t)},e.prototype.log=function(e,s){var i,n,o,a;if(s.unshift("||"),s.unshift(e),s.unshift(this.options.logPrefix),console.log.apply(console,s),this.options.debug){for(a="",i=0,o=s.length;o>i;i++)n=s[i],a+=" ",a+="object"==typeof n?JSON.stringify(n):n&&n.toString?n.toString():n;return t(".js-chatLogDisplay").prepend("
"+a+"
")}},e}(),o=function(t){function e(t){this.stop=bind(this.stop,this),this.start=bind(this.start,this),e.__super__.constructor.call(this,t)}return extend(e,t),e.prototype.timeoutStartedAt=null,e.prototype.logPrefix="timeout",e.prototype.defaults={debug:!1,timeout:4,timeoutIntervallCheck:.5},e.prototype.start=function(){var t,e;return this.stop(),e=new Date,t=function(t){return function(){var s;return s=new Date-new Date(e.getTime()+1e3*t.options.timeout*60),t.log.debug("Timeout check for "+t.options.timeout+" minutes (left "+s/1e3+" sec.)"),0>s?void 0:(t.stop(),t.options.callback())}}(this),this.log.debug("Start timeout in "+this.options.timeout+" minutes"),this.intervallId=setInterval(t,1e3*this.options.timeoutIntervallCheck*60)},e.prototype.stop=function(){return this.intervallId?(this.log.debug("Stop timeout of "+this.options.timeout+" minutes"),clearInterval(this.intervallId)):void 0},e}(s),i=function(t){function s(t){this.ping=bind(this.ping,this),this.send=bind(this.send,this),this.reconnect=bind(this.reconnect,this),this.close=bind(this.close,this),this.connect=bind(this.connect,this),this.set=bind(this.set,this),s.__super__.constructor.call(this,t)}return extend(s,t),s.prototype.logPrefix="io",s.prototype.set=function(t){var e,s,i;s=[];for(e in t)i=t[e],s.push(this.options[e]=i);return s},s.prototype.connect=function(){return this.log.debug("Connecting to "+this.options.host),this.ws=new e.WebSocket(""+this.options.host),this.ws.onopen=function(t){return function(e){return t.log.debug("onOpen",e),t.options.onOpen(e),t.ping()}}(this),this.ws.onmessage=function(t){return function(e){var s,i,n,o;for(o=JSON.parse(e.data),t.log.debug("onMessage",e.data),s=0,i=o.length;i>s;s++)n=o[s],"pong"===n.event&&t.ping();return t.options.onMessage?t.options.onMessage(o):void 0}}(this),this.ws.onclose=function(t){return function(e){if(t.log.debug("close websocket connection",e),t.pingDelayId&&clearTimeout(t.pingDelayId),t.manualClose){if(t.log.debug("manual close, onClose callback"),t.manualClose=!1,t.options.onClose)return t.options.onClose(e)}else if(t.log.debug("error close, onError callback"),t.options.onError)return t.options.onError("Connection lost...")}}(this),this.ws.onerror=function(t){return function(e){return t.log.debug("onError",e),t.options.onError?t.options.onError(e):void 0}}(this)},s.prototype.close=function(){return this.log.debug("close websocket manually"),this.manualClose=!0,this.ws.close()},s.prototype.reconnect=function(){return this.log.debug("reconnect"),this.close(),this.connect()},s.prototype.send=function(t,e){var s;return null==e&&(e={}),this.log.debug("send",t,e),s=JSON.stringify({event:t,data:e}),this.ws.send(s)},s.prototype.ping=function(){var t;return t=function(t){return function(){return t.send("ping")}}(this),this.pingDelayId=setTimeout(t,29e3)},s}(s),a=function(s){function n(s){return this.startTimeoutObservers=bind(this.startTimeoutObservers,this),this.setAgentOnlineState=bind(this.setAgentOnlineState,this),this.onConnectionEstablished=bind(this.onConnectionEstablished,this),this.setSessionId=bind(this.setSessionId,this),this.onConnectionReestablished=bind(this.onConnectionReestablished,this),this.reconnect=bind(this.reconnect,this),this.destroy=bind(this.destroy,this),this.onLeaveTemporary=bind(this.onLeaveTemporary,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.onWebSocketClose=bind(this.onWebSocketClose,this),this.onCloseAnimationEnd=bind(this.onCloseAnimationEnd,this),this.close=bind(this.close,this),this.toggle=bind(this.toggle,this),this.sessionClose=bind(this.sessionClose,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.onFocusOut=bind(this.onFocusOut,this),this.onFocus=bind(this.onFocus,this),this.onInput=bind(this.onInput,this),this.onReopenSession=bind(this.onReopenSession,this),this.onError=bind(this.onError,this),this.onWebSocketMessage=bind(this.onWebSocketMessage,this),this.send=bind(this.send,this),this.checkForEnter=bind(this.checkForEnter,this),this.render=bind(this.render,this),this.getScrollRoot=bind(this.getScrollRoot,this),this.view=bind(this.view,this),this.T=bind(this.T,this),this.options=t.extend({},this.defaults,s),n.__super__.constructor.call(this,this.options),this.isFullscreen=e.matchMedia&&e.matchMedia("(max-width: 768px)").matches,this.scrollRoot=t(this.getScrollRoot()),t?e.WebSocket&&sessionStorage?this.options.chatId?(this.options.lang||(this.options.lang=t("html").attr("lang")),this.options.lang&&(this.options.lang=this.options.lang.replace(/-.+?$/,""),this.log.debug("lang: "+this.options.lang)),this.options.host||this.detectHost(),this.loadCss(),this.io=new i(this.options),this.io.set({onOpen:this.render,onClose:this.onWebSocketClose,onMessage:this.onWebSocketMessage,onError:this.onError}),void this.io.connect()):(this.state="unsupported",void this.log.error("Chat: need chatId as option!")):(this.state="unsupported",void this.log.notice("Chat: Browser not supported!")):(this.state="unsupported",void this.log.notice("Chat: no jquery found!"))}return extend(n,s),n.prototype.defaults={chatId:void 0,show:!0,target:t("body"),host:"",debug:!1,flat:!1,lang:void 0,cssAutoload:!0,cssUrl:void 0,fontSize:void 0,buttonClass:"open-zammad-chat",inactiveClass:"is-inactive",title:"Chat with us!",idleTimeout:6,idleTimeoutIntervallCheck:.5,inactiveTimeout:8,inactiveTimeoutIntervallCheck:.5,waitingListTimeout:4,waitingListTimeoutIntervallCheck:.5},n.prototype.logPrefix="chat",n.prototype._messageCount=0,n.prototype.isOpen=!1,n.prototype.blinkOnlineInterval=null,n.prototype.stopBlinOnlineStateTimeout=null,n.prototype.showTimeEveryXMinutes=2,n.prototype.lastTimestamp=null,n.prototype.lastAddedType=null,n.prototype.inputTimeout=null,n.prototype.isTyping=!1,n.prototype.state="offline",n.prototype.initialQueueDelay=1e4,n.prototype.translations={de:{"Chat with us!":"Chatte mit uns!",Online:"Online",Online:"Online",Offline:"Offline",Connecting:"Verbinden","Connection re-established":"Verbindung wiederhergestellt",Today:"Heute",Send:"Senden","Compose your message...":"Ihre Nachricht...","All colleagues are busy.":"Alle Kollegen sind belegt.","You are on waiting list position %s.":"Sie sind in der Warteliste an der Position %s.","Start new conversation":"Neue Konversation starten","Since you didn't respond in the last %s minutes your conversation with %s got closed.":"Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation mit %s geschlossen.","Since you didn't respond in the last %s minutes your conversation got closed.":"Da Sie in den letzten %s Minuten nichts geschrieben haben wurde Ihre Konversation geschlossen."}},n.prototype.sessionId=void 0,n.prototype.T=function(){var t,e,s,i,n,o;if(n=arguments[0],s=2<=arguments.length?slice.call(arguments,1):[],this.options.lang&&"en"!==this.options.lang&&(this.translations[this.options.lang]?(o=this.translations[this.options.lang],o[n]||this.log.notice("Translation needed for '"+n+"'"),n=o[n]||n):this.log.notice("Translation '"+this.options.lang+"' needed!")),s)for(t=0,i=s.length;i>t;t++)e=s[t],n=n.replace(/%s/,e);return n},n.prototype.view=function(t){return function(s){return function(i){return i||(i={}),i.T=s.T,i.background=s.options.background,i.flat=s.options.flat,i.fontSize=s.options.fontSize,e.zammadChatTemplates[t](i)}}(this)},n.prototype.getScrollRoot=function(){var t,e,s;return"scrollingElement"in document?document.scrollingElement:(e=document.documentElement,s=e.scrollTop,e.scrollTop=s+1,t=e.scrollTop,e.scrollTop=s,t>s?e:document.body)},n.prototype.render=function(){return this.el&&t(".zammad-chat").get(0)||this.renderBase(),t("."+this.options.buttonClass).addClass(this.inactiveClass),this.setAgentOnlineState("online"),this.log.debug("widget rendered"),this.startTimeoutObservers(),this.idleTimeout.start(),this.sessionId=sessionStorage.getItem("sessionId"),this.send("chat_status_customer",{session_id:this.sessionId})},n.prototype.renderBase=function(){return this.el=t(this.view("chat")({title:this.options.title})),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-toggle").click(this.toggle),this.el.find(".zammad-chat-controls").on("submit",this.onSubmit),this.input.on({keydown:this.checkForEnter,input:this.onInput}),t(e).on("beforeunload",function(t){return function(){return t.onLeaveTemporary()}}(this)),t(e).bind("hashchange",function(t){return function(){return t.isOpen?void 0:t.idleTimeout.start()}}(this)),this.isFullscreen?this.input.on({focus:this.onFocus,focusout:this.onFocusOut}):void 0},n.prototype.checkForEnter=function(t){return t.shiftKey||13!==t.keyCode?void 0:(t.preventDefault(),this.sendMessage())},n.prototype.send=function(t,e){return null==e&&(e={}),e.chat_id=this.options.chatId,this.io.send(t,e)},n.prototype.onWebSocketMessage=function(t){var e,s,i;for(e=0,s=t.length;s>e;e++)switch(i=t[e],this.log.debug("ws:onmessage",i),i.event){case"chat_error":this.log.notice(i.data),i.data&&"chat_disabled"===i.data.state&&this.destroy({remove:!0});break;case"chat_session_message":if(i.data.self_written)return;this.receiveMessage(i.data);break;case"chat_session_typing":if(i.data.self_written)return;this.onAgentTypingStart();break;case"chat_session_start":this.onConnectionEstablished(i.data);break;case"chat_session_queue":this.onQueueScreen(i.data);break;case"chat_session_closed":this.onSessionClosed(i.data);break;case"chat_session_left":this.onSessionClosed(i.data);break;case"chat_status_customer":switch(i.data.state){case"online":this.sessionId=void 0,this.onReady();break;case"offline":this.onError("Zammad Chat: No agent online");break;case"chat_disabled":this.onError("Zammad Chat: Chat is disabled");break;case"no_seats_available":this.onError("Zammad Chat: Too many clients in queue. Clients in queue: "+i.data.queue);break;case"reconnect":this.onReopenSession(i.data)}}},n.prototype.onReady=function(){return this.log.debug("widget ready for use"),t("."+this.options.buttonClass).click(this.open).removeClass(this.inactiveClass),this.options.show?this.show():void 0},n.prototype.onError=function(e){return this.log.debug(e),this.addStatus(e),t("."+this.options.buttonClass).hide(),this.isOpen?(this.disableInput(),this.destroy({remove:!1})):this.destroy({remove:!0})},n.prototype.onReopenSession=function(t){var e,s,i,n,o;if(this.log.debug("old messages",t.session),this.inactiveTimeout.start(),o=sessionStorage.getItem("unfinished_message"),t.agent){for(this.onConnectionEstablished(t),n=t.session,e=0,s=n.length;s>e;e++)i=n[e],this.renderMessage({message:i.content,id:i.id,from:i.created_by_id?"agent":"customer"});o&&this.input.val(o)}return t.position&&this.onQueue(t),this.show(),this.open(),this.scrollToBottom(),o?this.input.focus():void 0},n.prototype.onInput=function(){return this.el.find(".zammad-chat-message--unread").removeClass("zammad-chat-message--unread"),sessionStorage.setItem("unfinished_message",this.input.val()),this.onTyping()},n.prototype.onFocus=function(){var s;return t(e).scrollTop(10),s=t(e).scrollTop()>0,t(e).scrollTop(0),s?this.log.notice("virtual keyboard shown"):void 0},n.prototype.onFocusOut=function(){},n.prototype.onTyping=function(){return this.isTyping&&this.isTyping>new Date((new Date).getTime()-1500)?void 0:(this.isTyping=new Date,this.send("chat_session_typing",{session_id:this.sessionId}),this.inactiveTimeout.start())},n.prototype.onSubmit=function(t){return t.preventDefault(),this.sendMessage()},n.prototype.sendMessage=function(){var t,e;return(t=this.input.val())?(this.inactiveTimeout.start(),sessionStorage.removeItem("unfinished_message"),e=this.view("message")({message:t,from:"customer",id:this._messageCount++,unreadClass:""}),this.maybeAddTimestamp(),this.el.find(".zammad-chat-message--typing").size()?(this.lastAddedType="typing-placeholder",this.el.find(".zammad-chat-message--typing").before(e)):(this.lastAddedType="message--customer",this.el.find(".zammad-chat-body").append(e)),this.input.val(""),this.scrollToBottom(),this.send("chat_session_message",{content:t,id:this._messageCount,session_id:this.sessionId})):void 0},n.prototype.receiveMessage=function(t){return this.inactiveTimeout.start(),this.onAgentTypingEnd(),this.maybeAddTimestamp(),this.renderMessage({message:t.message.content,id:t.id,from:"agent"})},n.prototype.renderMessage=function(t){return this.lastAddedType="message--"+t.from,t.unreadClass=document.hidden?" zammad-chat-message--unread":"",this.el.find(".zammad-chat-body").append(this.view("message")(t)),this.scrollToBottom()},n.prototype.open=function(){return this.isOpen?void this.log.debug("widget already open, block"):(this.isOpen=!0,this.log.debug("open widget"),this.sessionId||this.showLoader(),this.el.addClass("zammad-chat-is-open"),this.sessionId?(this.el.css("bottom",0),this.onOpenAnimationEnd()):(this.el.animate({bottom:0},500,this.onOpenAnimationEnd),this.send("chat_session_init")))},n.prototype.onOpenAnimationEnd=function(){return this.idleTimeout.stop(),this.isFullscreen?this.disableScrollOnRoot():void 0},n.prototype.sessionClose=function(){return this.send("chat_session_close",{session_id:this.sessionId}),this.inactiveTimeout.stop(),this.waitingListTimeout.stop(),sessionStorage.removeItem("unfinished_message"),this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.setSessionId(void 0)},n.prototype.toggle=function(t){return this.isOpen?this.close(t):this.open(t)},n.prototype.close=function(t){var e;return this.isOpen?this.sessionId?(this.log.debug("close widget"),t&&t.stopPropagation(),this.sessionClose(),this.isFullscreen&&this.enableScrollOnRoot(),this.el.removeClass("zammad-chat-is-open"),e=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-e},500,this.onCloseAnimationEnd)):void this.log.debug("can't close widget without sessionId"):void this.log.debug("can't close widget, it's not open")},n.prototype.onCloseAnimationEnd=function(){return this.el.removeClass("zammad-chat-is-visible"),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"),this.isOpen=!1,this.io.reconnect()},n.prototype.onWebSocketClose=function(){return this.isOpen?void 0:this.el?this.el.removeClass("zammad-chat-is-shown"):void 0},n.prototype.show=function(){var t;if("offline"!==this.state)return this.el.addClass("zammad-chat-is-shown"),this.inputInitialized||(this.inputInitialized=!0,this.input.autoGrow({extraLine:!1})),t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.css("bottom",-t)},n.prototype.disableInput=function(){return this.input.prop("disabled",!0),this.el.find(".zammad-chat-send").prop("disabled",!0)},n.prototype.enableInput=function(){return this.input.prop("disabled",!1),this.el.find(".zammad-chat-send").prop("disabled",!1)},n.prototype.hideModal=function(){return this.el.find(".zammad-chat-modal").html("")},n.prototype.onQueueScreen=function(t){var e;return this.setSessionId(t.session_id),e=function(e){return function(){return e.onQueue(t),e.waitingListTimeout.start()}}(this),this.initialQueueDelay&&!this.onInitialQueueDelayId?void(this.onInitialQueueDelayId=setTimeout(e,this.initialQueueDelay)):(this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),e())},n.prototype.onQueue=function(t){return this.log.notice("onQueue",t.position),this.inQueue=!0,this.el.find(".zammad-chat-modal").html(this.view("waiting")({position:t.position}))},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.onLeaveTemporary=function(){return this.sessionId?this.send("chat_session_leave_temporary",{session_id:this.sessionId}):void 0},n.prototype.maybeAddTimestamp=function(){var t,e,s;return s=Date.now(),!this.lastTimestamp||s-this.lastTimestamp>6e4*this.showTimeEveryXMinutes?(t=this.T("Today"),e=(new Date).toTimeString().substr(0,5),"timestamp"===this.lastAddedType?(this.updateLastTimestamp(t,e),this.lastTimestamp=s):(this.el.find(".zammad-chat-body").append(this.view("timestamp")({label:t,time:e})),this.lastTimestamp=s,this.lastAddedType="timestamp",this.scrollToBottom())):void 0},n.prototype.updateLastTimestamp=function(t,e){return this.el?this.el.find(".zammad-chat-body").find(".zammad-chat-timestamp").last().replaceWith(this.view("timestamp")({label:t,time:e})):void 0},n.prototype.addStatus=function(t){return this.el?(this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("status")({status:t})),this.scrollToBottom()):void 0},n.prototype.scrollToBottom=function(){return this.el.find(".zammad-chat-body").scrollTop(t(".zammad-chat-body").prop("scrollHeight"))},n.prototype.destroy=function(t){return null==t&&(t={}),this.log.debug("destroy widget",t),this.setAgentOnlineState("offline"),t.remove&&this.el&&this.el.remove(),this.waitingListTimeout&&this.waitingListTimeout.stop(),this.inactiveTimeout&&this.inactiveTimeout.stop(),this.idleTimeout&&this.idleTimeout.stop(),this.io.close()},n.prototype.reconnect=function(){return this.log.notice("reconnecting"),this.disableInput(),this.lastAddedType="status",this.setAgentOnlineState("connecting"),this.addStatus(this.T("Connection lost"))},n.prototype.onConnectionReestablished=function(){return this.lastAddedType="status",this.setAgentOnlineState("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(),this.setAgentOnlineState("offline"),this.inactiveTimeout.stop()},n.prototype.setSessionId=function(t){return this.sessionId=t,void 0===t?sessionStorage.removeItem("sessionId"):sessionStorage.setItem("sessionId",t)},n.prototype.onConnectionEstablished=function(t){return this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.inQueue=!1,t.agent&&(this.agent=t.agent),t.session_id&&this.setSessionId(t.session_id),this.el.find(".zammad-chat-agent").html(this.view("agent")({agent:this.agent})),this.enableInput(),this.hideModal(),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.isFullscreen||this.input.focus(),this.setAgentOnlineState("online"),this.waitingListTimeout.stop(),this.idleTimeout.stop(),this.inactiveTimeout.start()},n.prototype.showCustomerTimeout=function(){var t;return this.el.find(".zammad-chat-modal").html(this.view("customer_timeout")({agent:this.agent.name,delay:this.options.inactiveTimeout})),t=function(){return location.reload()},this.el.find(".js-restart").click(t),this.sessionClose()},n.prototype.showWaitingListTimeout=function(){var t;return this.el.find(".zammad-chat-modal").html(this.view("waiting_list_timeout")({delay:this.options.watingListTimeout})),t=function(){return location.reload()},this.el.find(".js-restart").click(t),this.sessionClose()},n.prototype.showLoader=function(){return this.el.find(".zammad-chat-modal").html(this.view("loader")())},n.prototype.setAgentOnlineState=function(t){var e;return this.state=t,this.el?(e=t.charAt(0).toUpperCase()+t.slice(1),this.el.find(".zammad-chat-agent-status").attr("data-status",t).text(this.T(e))):void 0},n.prototype.detectHost=function(){var t;return t="ws://","https:"===e.location.protocol&&(t="wss://"),this.options.host=""+t+h+"/ws"},n.prototype.loadCss=function(){var t,e,s;if(this.options.cssAutoload)return s=this.options.cssUrl,s||(s=this.options.host.replace(/^wss/i,"https").replace(/^ws/i,"http").replace(/\/ws/i,""),s+="/assets/chat/chat.css"),this.log.debug("load css from '"+s+"'"),e="@import url('"+s+"');",t=document.createElement("link"),t.rel="stylesheet",t.href="data:text/css,"+escape(e),document.getElementsByTagName("head")[0].appendChild(t)},n.prototype.startTimeoutObservers=function(){return this.idleTimeout=new o({logPrefix:"idleTimeout",debug:this.options.debug,timeout:this.options.idleTimeout,timeoutIntervallCheck:this.options.idleTimeoutIntervallCheck,callback:function(t){return function(){return t.log.debug("Idle timeout reached, hide widget",new Date),t.destroy({remove:!0})}}(this)}),this.inactiveTimeout=new o({logPrefix:"inactiveTimeout",debug:this.options.debug,timeout:this.options.inactiveTimeout,timeoutIntervallCheck:this.options.inactiveTimeoutIntervallCheck,callback:function(t){return function(){return t.log.debug("Inactive timeout reached, show timeout screen.",new Date),t.showCustomerTimeout(),t.destroy({remove:!1})}}(this)}),this.waitingListTimeout=new o({logPrefix:"waitingListTimeout",debug:this.options.debug,timeout:this.options.waitingListTimeout,timeoutIntervallCheck:this.options.waitingListTimeoutIntervallCheck,callback:function(t){return function(){return t.log.debug("Waiting list timeout reached, show timeout screen.",new Date),t.showWaitingListTimeout(),t.destroy({remove:!1})}}(this)})},n.prototype.disableScrollOnRoot=function(){return this.rootScrollOffset=this.scrollRoot.scrollTop(),this.scrollRoot.css({overflow:"hidden",position:"fixed"})},n.prototype.enableScrollOnRoot=function(){return this.scrollRoot.scrollTop(this.rootScrollOffset),this.scrollRoot.css({overflow:"",position:""})},n}(s),e.ZammadChat=a}(window.jQuery,window),window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.agent=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=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(i(this.agent.name)),s.push("\n")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},jQuery.fn.autoGrow=function(t){return this.each(function(){var e=jQuery.extend({extraLine:!0},t),s=function(t){return jQuery(t).after('
'),jQuery(t).next(".autogrow-textarea-mirror")[0]},i=function(t){if(o.innerHTML=String(t.value).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/ /g," ").replace(/\n/g,"
")+(e.extraLine?".
.":""),jQuery(t).height()!=jQuery(o).height()){jQuery(t).height(jQuery(o).height());var s=parseInt(jQuery(t).css("max-height"),10),i=jQuery(o).height()>s?"":"hidden";jQuery(t).css("overflow",i)}},n=function(){i(this)},o=s(this);o.style.display="none",o.style.wordWrap="break-word",o.style.whiteSpace="normal",o.style.padding=jQuery(this).css("paddingTop")+" "+jQuery(this).css("paddingRight")+" "+jQuery(this).css("paddingBottom")+" "+jQuery(this).css("paddingLeft"),o.style.width=jQuery(this).css("width"),o.style.fontFamily=jQuery(this).css("font-family"),o.style.fontSize=jQuery(this).css("font-size"),o.style.lineHeight=jQuery(this).css("line-height"),this.style.overflow="hidden",this.style.minHeight=this.rows+"em",this.onkeyup=n,i(this)})},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.chat=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\n
\n \n \n \n \n \n
\n
\n
\n
\n \n '),s.push(this.T(this.title)),s.push('\n
\n
\n
\n
\n
\n \n \n
\n
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.customer_timeout=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n '),this.agent?(s.push("\n "),s.push(this.T("Since you didn't respond in the last %s minutes your conversation with %s got closed.",this.delay,this.agent)),s.push("\n ")):(s.push("\n "),s.push(this.T("Since you didn't respond in the last %s minutes your conversation got closed.",this.delay)),s.push("\n ")),s.push('\n
\n
"),s.push(this.T("Start new conversation")),s.push("
\n
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.loader=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('\n \n \n \n\n'),s.push(this.T("Connecting")),s.push("")}).call(this)}.call(t),t.safe=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=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=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n
\n '),s.push(this.status),s.push("\n
\n
")}).call(this)}.call(t),t.safe=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.timestamp=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
'),s.push(i(this.label)),s.push(" "),s.push(i(this.time)),s.push("
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=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=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting=function(t){t||(t={});var e,s=[],i=t.safe,n=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},n||(n=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n \n \n \n \n \n '),s.push(this.T("All colleagues are busy.")),s.push("
\n "),s.push(this.T("You are on waiting list position %s.",this.position)),s.push("\n
")}).call(this)}.call(t),t.safe=i,t.escape=n,s.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting_list_timeout=function(t){t||(t={});var e,s=[],i=function(t){return t&&t.ecoSafe?t:"undefined"!=typeof t&&null!=t?o(t):""},n=t.safe,o=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},o||(o=t.escape=function(t){return(""+t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){s.push('
\n '),s.push(this.T("We are sorry, it takes longer as expected to get an empty slot. Please try again later or send us an email. Thank you!")),s.push('\n
\n
"),s.push(this.T("Start new conversation")),s.push("
\n
")}).call(this)}.call(t),t.safe=n,t.escape=o,s.join("")}; \ No newline at end of file diff --git a/public/assets/chat/chat.scss b/public/assets/chat/chat.scss index 6c21f163d..066795376 100644 --- a/public/assets/chat/chat.scss +++ b/public/assets/chat/chat.scss @@ -23,8 +23,9 @@ @media only screen and (max-width: 768px) { right: 0; width: 100%; - height: 100vh; + height: 100%; border-radius: 0 !important; + font-size: 16px; } } .zammad-chat.zammad-chat-is-shown { @@ -173,6 +174,10 @@ display: flex; align-items: center; justify-content: center; + + &:empty { + display: none; + } } .zammad-chat-modal-text { @@ -199,6 +204,7 @@ overflow: auto; background: white; flex: 1; + -webkit-overflow-scrolling: touch; @media only screen and (max-width: 768px) { height: auto; diff --git a/public/assets/chat/views/chat.eco b/public/assets/chat/views/chat.eco index ddbbad0f7..d617eef03 100644 --- a/public/assets/chat/views/chat.eco +++ b/public/assets/chat/views/chat.eco @@ -1,10 +1,10 @@
>
> -
+
- +
@@ -14,6 +14,7 @@ <%- @T(@title) %>
+
diff --git a/public/assets/chat/views/customer_timeout.eco b/public/assets/chat/views/customer_timeout.eco index b66dbc836..161ab894d 100644 --- a/public/assets/chat/views/customer_timeout.eco +++ b/public/assets/chat/views/customer_timeout.eco @@ -1,11 +1,9 @@ -
-
- <% if @agent: %> - <%- @T('Since you didn\'t respond in the last %s minutes your conversation with %s got closed.', @delay, @agent) %> - <% else: %> - <%- @T('Since you didn\'t respond in the last %s minutes your conversation got closed.', @delay) %> - <% end %> -
-
><%- @T('Start new conversation') %>
-
+
+ <% if @agent: %> + <%- @T('Since you didn\'t respond in the last %s minutes your conversation with %s got closed.', @delay, @agent) %> + <% else: %> + <%- @T('Since you didn\'t respond in the last %s minutes your conversation got closed.', @delay) %> + <% end %> +
+
><%- @T('Start new conversation') %>
\ No newline at end of file diff --git a/public/assets/chat/views/loader.eco b/public/assets/chat/views/loader.eco index 24b8d458f..0cc23e909 100644 --- a/public/assets/chat/views/loader.eco +++ b/public/assets/chat/views/loader.eco @@ -1,8 +1,6 @@ -
- - - - - - <%- @T('Connecting') %> -
\ No newline at end of file + + + + + +<%- @T('Connecting') %> \ No newline at end of file diff --git a/public/assets/chat/views/waiting.eco b/public/assets/chat/views/waiting.eco index c04edf069..98c90df0a 100644 --- a/public/assets/chat/views/waiting.eco +++ b/public/assets/chat/views/waiting.eco @@ -1,11 +1,9 @@ -
-
- - - - - - <%- @T('All colleagues are busy.') %>
- <%- @T('You are on waiting list position %s.', @position) %> -
+
+ + + + + + <%- @T('All colleagues are busy.') %>
+ <%- @T('You are on waiting list position %s.', @position) %>
\ No newline at end of file diff --git a/public/assets/chat/views/waiting_list_timeout.eco b/public/assets/chat/views/waiting_list_timeout.eco index 9370bfcb0..2532578f4 100644 --- a/public/assets/chat/views/waiting_list_timeout.eco +++ b/public/assets/chat/views/waiting_list_timeout.eco @@ -1,7 +1,5 @@ -
-
- <%- @T('We are sorry, it takes longer as expected to get an empty slot. Please try again later or send us an email. Thank you!') %> -
-
><%- @T('Start new conversation') %>
-
+
+ <%- @T('We are sorry, it takes longer as expected to get an empty slot. Please try again later or send us an email. Thank you!') %> +
+
><%- @T('Start new conversation') %>
\ No newline at end of file diff --git a/public/assets/chat/znuny.html b/public/assets/chat/znuny.html index 2dcd1541d..a8bb7a575 100644 --- a/public/assets/chat/znuny.html +++ b/public/assets/chat/znuny.html @@ -76,6 +76,17 @@ + + + + + + + + + + +
@@ -144,7 +155,7 @@ chatId: 1, host: host, cssUrl: cssUrl, - debug: true, + debug: false, background: '#494d52', flat: true, shown: false,