diff --git a/public/assets/chat/chat.coffee b/public/assets/chat/chat.coffee index 52a6255dd..2180d921d 100644 --- a/public/assets/chat/chat.coffee +++ b/public/assets/chat/chat.coffee @@ -13,6 +13,7 @@ do($ = window.jQuery, window) -> host: '' port: 6042 debug: false + fontSize: undefined buttonSelector: '.open-zammad-chat' _messageCount: 0 @@ -66,6 +67,7 @@ do($ = window.jQuery, window) -> options.T = @T options.background = @options.background options.flat = @options.flat + options.fontSize = @options.fontSize return window.zammadChatTemplates[name](options) constructor: (options) -> diff --git a/public/assets/chat/chat.js b/public/assets/chat/chat.js index 11a96fe29..449ce17c7 100644 --- a/public/assets/chat/chat.js +++ b/public/assets/chat/chat.js @@ -1,64 +1,3 @@ -if (!window.zammadChatTemplates) { - window.zammadChatTemplates = {}; -} -window.zammadChatTemplates["agent"] = 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() { - if (this.agent.avatar) { - __out.push('\n\n'); - } - - __out.push('\n\n '); - - __out.push(__sanitize(this.agent.name)); - - __out.push('\n'); - - }).call(this); - - }).call(__obj); - __obj.safe = __objSafe, __obj.escape = __escape; - return __out.join(''); -}; - var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, slice = [].slice; @@ -74,6 +13,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); host: '', port: 6042, debug: false, + fontSize: void 0, buttonSelector: '.open-zammad-chat' }; @@ -154,6 +94,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); options.T = _this.T; options.background = _this.options.background; options.flat = _this.options.flat; + options.fontSize = _this.options.fontSize; return window.zammadChatTemplates[name](options); }; })(this); @@ -268,14 +209,17 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); break; case 'offline': this.onError('Zammad Chat: No agent online'); + this.hide(); this.wsClose(); break; case 'chat_disabled': this.onError('Zammad Chat: Chat is disabled'); + this.hide(); this.wsClose(); break; case 'no_seats_available': this.onError('Zammad Chat: Too many clients in queue. Clients in queue: ', pipe.data.queue); + this.hide(); this.wsClose(); break; case 'reconnect': @@ -438,8 +382,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); if (this.onInitialQueueDelayId) { clearTimeout(this.onInitialQueueDelayId); } - sessionStorage.removeItem('sessionId'); - sessionStorage.removeItem('unfinished_message'); return this.closeWindow(); }; @@ -458,7 +400,9 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); this.send('chat_session_close', { session_id: this.sessionId }); - return this.setSessionId(void 0); + this.setSessionId(void 0); + sessionStorage.removeItem('unfinished_message'); + return this.onWebSocketOpen(); }; ZammadChat.prototype.hide = function() { @@ -703,6 +647,67 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); return window.ZammadChat = ZammadChat; })(window.jQuery, window); +if (!window.zammadChatTemplates) { + window.zammadChatTemplates = {}; +} +window.zammadChatTemplates["agent"] = 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() { + if (this.agent.avatar) { + __out.push('\n\n'); + } + + __out.push('\n\n '); + + __out.push(__sanitize(this.agent.name)); + + __out.push('\n'); + + }).call(this); + + }).call(__obj); + __obj.safe = __objSafe, __obj.escape = __escape; + return __out.join(''); +}; + /*! * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): @@ -767,6 +772,7 @@ jQuery.fn.autoGrow = function(options) { mirror.style.fontFamily = jQuery(this).css('font-family'); mirror.style.fontSize = jQuery(this).css('font-size'); mirror.style.lineHeight = jQuery(this).css('line-height'); + mirror.style.boxSizing = jQuery(this).css('box-sizing'); // Style the textarea this.style.overflow = "hidden"; @@ -828,7 +834,13 @@ window.zammadChatTemplates["chat"] = function (__obj) { __out.push(__sanitize(' zammad-chat--flat')); } - __out.push('">\n