Fixes #2258 - In some situations the chat button is visible without a active websocket connection.
This commit is contained in:
parent
fc393e452e
commit
aaa17d72e0
11 changed files with 332 additions and 234 deletions
|
@ -1272,6 +1272,12 @@ do(window) ->
|
||||||
if params.remove && @el
|
if params.remove && @el
|
||||||
@el.remove()
|
@el.remove()
|
||||||
|
|
||||||
|
# Remove button, because it can no longer be used.
|
||||||
|
btn = document.querySelector(".#{ @options.buttonClass }")
|
||||||
|
if btn
|
||||||
|
btn.classList.add @options.inactiveClass
|
||||||
|
btn.style.display = 'none';
|
||||||
|
|
||||||
# stop all timer
|
# stop all timer
|
||||||
if @waitingListTimeout
|
if @waitingListTimeout
|
||||||
@waitingListTimeout.stop()
|
@waitingListTimeout.stop()
|
||||||
|
|
|
@ -1804,6 +1804,7 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
|
||||||
};
|
};
|
||||||
|
|
||||||
ZammadChat.prototype.destroy = function(params) {
|
ZammadChat.prototype.destroy = function(params) {
|
||||||
|
var btn;
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = {};
|
params = {};
|
||||||
}
|
}
|
||||||
|
@ -1811,6 +1812,11 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
|
||||||
this.setAgentOnlineState('offline');
|
this.setAgentOnlineState('offline');
|
||||||
if (params.remove && this.el) {
|
if (params.remove && this.el) {
|
||||||
this.el.remove();
|
this.el.remove();
|
||||||
|
btn = document.querySelector("." + this.options.buttonClass);
|
||||||
|
if (btn) {
|
||||||
|
btn.classList.add(this.options.inactiveClass);
|
||||||
|
btn.style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this.waitingListTimeout) {
|
if (this.waitingListTimeout) {
|
||||||
this.waitingListTimeout.stop();
|
this.waitingListTimeout.stop();
|
||||||
|
|
2
public/assets/chat/chat-no-jquery.min.js
vendored
2
public/assets/chat/chat-no-jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1278,6 +1278,9 @@ do($ = window.jQuery, window) ->
|
||||||
|
|
||||||
if params.remove && @el
|
if params.remove && @el
|
||||||
@el.remove()
|
@el.remove()
|
||||||
|
# Remove button, because it can no longer be used.
|
||||||
|
$(".#{ @options.buttonClass }").hide()
|
||||||
|
|
||||||
|
|
||||||
# stop all timer
|
# stop all timer
|
||||||
if @waitingListTimeout
|
if @waitingListTimeout
|
||||||
|
|
|
@ -1,3 +1,228 @@
|
||||||
|
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, '>')
|
||||||
|
.replace(/"/g, '"');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(function() {
|
||||||
|
(function() {
|
||||||
|
if (this.agent.avatar) {
|
||||||
|
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
|
||||||
|
__out.push(__sanitize(this.agent.avatar));
|
||||||
|
__out.push('">\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
|
||||||
|
|
||||||
|
__out.push(__sanitize(this.agent.name));
|
||||||
|
|
||||||
|
__out.push('</span>\n</span>');
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
|
||||||
|
}).call(__obj);
|
||||||
|
__obj.safe = __objSafe, __obj.escape = __escape;
|
||||||
|
return __out.join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
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, '>')
|
||||||
|
.replace(/"/g, '"');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(function() {
|
||||||
|
(function() {
|
||||||
|
__out.push('<div class="zammad-chat');
|
||||||
|
|
||||||
|
if (this.flat) {
|
||||||
|
__out.push(__sanitize(' zammad-chat--flat'));
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('"');
|
||||||
|
|
||||||
|
if (this.fontSize) {
|
||||||
|
__out.push(__sanitize(" style='font-size: " + this.fontSize + "'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('>\n <div class="zammad-chat-header js-chat-open"');
|
||||||
|
|
||||||
|
if (this.background) {
|
||||||
|
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('>\n <div class="zammad-chat-header-controls js-chat-toggle">\n <span class="zammad-chat-agent-status zammad-chat-is-hidden js-chat-status" data-status="online"></span>\n <span class="zammad-chat-header-icon">\n <svg class="zammad-chat-header-icon-open" width="13" height="7" viewBox="0 0 13 7"><path d="M10.807 7l1.4-1.428-5-4.9L6.5-.02l-.7.7-4.9 4.9 1.414 1.413L6.5 2.886 10.807 7z" fill-rule="evenodd"/></svg>\n <svg class="zammad-chat-header-icon-close" width="13" height="13" viewBox="0 0 13 13"><path d="m2.241.12l-2.121 2.121 4.243 4.243-4.243 4.243 2.121 2.121 4.243-4.243 4.243 4.243 2.121-2.121-4.243-4.243 4.243-4.243-2.121-2.121-4.243 4.243-4.243-4.243" fill-rule="evenodd"/></svg>\n </span>\n </div>\n <div class="zammad-chat-agent zammad-chat-is-hidden">\n </div>\n <div class="zammad-chat-welcome">\n <svg class="zammad-chat-icon" viewBox="0 0 24 24" width="24" height="24"><path d="M2 5C2 4 3 3 4 3h16c1 0 2 1 2 2v10C22 16 21 17 20 17H4C3 17 2 16 2 15V5zM12 17l6 4v-4h-6z"/></svg>\n <span class="zammad-chat-welcome-text">');
|
||||||
|
|
||||||
|
__out.push(this.T(this.title));
|
||||||
|
|
||||||
|
__out.push('</span>\n </div>\n </div>\n <div class="zammad-chat-modal"></div>\n <div class="zammad-scroll-hint is-hidden">\n <svg class="zammad-scroll-hint-icon" width="20" height="18" viewBox="0 0 20 18"><path d="M0,2.00585866 C0,0.898053512 0.898212381,0 1.99079514,0 L18.0092049,0 C19.1086907,0 20,0.897060126 20,2.00585866 L20,11.9941413 C20,13.1019465 19.1017876,14 18.0092049,14 L1.99079514,14 C0.891309342,14 0,13.1029399 0,11.9941413 L0,2.00585866 Z M10,14 L16,18 L16,14 L10,14 Z" fill-rule="evenodd"/></svg>\n ');
|
||||||
|
|
||||||
|
__out.push(this.T(this.scrollHint));
|
||||||
|
|
||||||
|
__out.push('\n </div>\n <div class="zammad-chat-body"></div>\n <form class="zammad-chat-controls">\n <div class="zammad-chat-input" rows="1" placeholder="');
|
||||||
|
|
||||||
|
__out.push(this.T('Compose your message...'));
|
||||||
|
|
||||||
|
__out.push('" contenteditable="true"></div>\n <button type="submit" class="zammad-chat-button zammad-chat-send"');
|
||||||
|
|
||||||
|
if (this.background) {
|
||||||
|
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('>');
|
||||||
|
|
||||||
|
__out.push(this.T('Send'));
|
||||||
|
|
||||||
|
__out.push('</button>\n </form>\n</div>');
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
|
||||||
|
}).call(__obj);
|
||||||
|
__obj.safe = __objSafe, __obj.escape = __escape;
|
||||||
|
return __out.join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!window.zammadChatTemplates) {
|
||||||
|
window.zammadChatTemplates = {};
|
||||||
|
}
|
||||||
|
window.zammadChatTemplates["customer_timeout"] = 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, '>')
|
||||||
|
.replace(/"/g, '"');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(function() {
|
||||||
|
(function() {
|
||||||
|
__out.push('<div class="zammad-chat-modal-text">\n ');
|
||||||
|
|
||||||
|
if (this.agent) {
|
||||||
|
__out.push('\n ');
|
||||||
|
__out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> got closed.', this.delay, this.agent));
|
||||||
|
__out.push('\n ');
|
||||||
|
} else {
|
||||||
|
__out.push('\n ');
|
||||||
|
__out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation got closed.', this.delay));
|
||||||
|
__out.push('\n ');
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('\n <br>\n <div class="zammad-chat-button js-restart"');
|
||||||
|
|
||||||
|
if (this.background) {
|
||||||
|
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
__out.push('>');
|
||||||
|
|
||||||
|
__out.push(this.T('Start new conversation'));
|
||||||
|
|
||||||
|
__out.push('</div>\n</div>');
|
||||||
|
|
||||||
|
}).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); }; },
|
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||||
slice = [].slice,
|
slice = [].slice,
|
||||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||||
|
@ -1555,6 +1780,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
||||||
this.setAgentOnlineState('offline');
|
this.setAgentOnlineState('offline');
|
||||||
if (params.remove && this.el) {
|
if (params.remove && this.el) {
|
||||||
this.el.remove();
|
this.el.remove();
|
||||||
|
$("." + this.options.buttonClass).hide();
|
||||||
}
|
}
|
||||||
if (this.waitingListTimeout) {
|
if (this.waitingListTimeout) {
|
||||||
this.waitingListTimeout.stop();
|
this.waitingListTimeout.stop();
|
||||||
|
@ -2040,231 +2266,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
||||||
return window.ZammadChat = ZammadChat;
|
return window.ZammadChat = ZammadChat;
|
||||||
})(window.jQuery, window);
|
})(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, '>')
|
|
||||||
.replace(/"/g, '"');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
(function() {
|
|
||||||
(function() {
|
|
||||||
if (this.agent.avatar) {
|
|
||||||
__out.push('\n<img class="zammad-chat-agent-avatar" src="');
|
|
||||||
__out.push(__sanitize(this.agent.avatar));
|
|
||||||
__out.push('">\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('\n<span class="zammad-chat-agent-sentence">\n <span class="zammad-chat-agent-name">');
|
|
||||||
|
|
||||||
__out.push(__sanitize(this.agent.name));
|
|
||||||
|
|
||||||
__out.push('</span>\n</span>');
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
|
|
||||||
}).call(__obj);
|
|
||||||
__obj.safe = __objSafe, __obj.escape = __escape;
|
|
||||||
return __out.join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
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, '>')
|
|
||||||
.replace(/"/g, '"');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
(function() {
|
|
||||||
(function() {
|
|
||||||
__out.push('<div class="zammad-chat');
|
|
||||||
|
|
||||||
if (this.flat) {
|
|
||||||
__out.push(__sanitize(' zammad-chat--flat'));
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('"');
|
|
||||||
|
|
||||||
if (this.fontSize) {
|
|
||||||
__out.push(__sanitize(" style='font-size: " + this.fontSize + "'"));
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('>\n <div class="zammad-chat-header js-chat-open"');
|
|
||||||
|
|
||||||
if (this.background) {
|
|
||||||
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('>\n <div class="zammad-chat-header-controls js-chat-toggle">\n <span class="zammad-chat-agent-status zammad-chat-is-hidden js-chat-status" data-status="online"></span>\n <span class="zammad-chat-header-icon">\n <svg class="zammad-chat-header-icon-open" width="13" height="7" viewBox="0 0 13 7"><path d="M10.807 7l1.4-1.428-5-4.9L6.5-.02l-.7.7-4.9 4.9 1.414 1.413L6.5 2.886 10.807 7z" fill-rule="evenodd"/></svg>\n <svg class="zammad-chat-header-icon-close" width="13" height="13" viewBox="0 0 13 13"><path d="m2.241.12l-2.121 2.121 4.243 4.243-4.243 4.243 2.121 2.121 4.243-4.243 4.243 4.243 2.121-2.121-4.243-4.243 4.243-4.243-2.121-2.121-4.243 4.243-4.243-4.243" fill-rule="evenodd"/></svg>\n </span>\n </div>\n <div class="zammad-chat-agent zammad-chat-is-hidden">\n </div>\n <div class="zammad-chat-welcome">\n <svg class="zammad-chat-icon" viewBox="0 0 24 24" width="24" height="24"><path d="M2 5C2 4 3 3 4 3h16c1 0 2 1 2 2v10C22 16 21 17 20 17H4C3 17 2 16 2 15V5zM12 17l6 4v-4h-6z"/></svg>\n <span class="zammad-chat-welcome-text">');
|
|
||||||
|
|
||||||
__out.push(this.T(this.title));
|
|
||||||
|
|
||||||
__out.push('</span>\n </div>\n </div>\n <div class="zammad-chat-modal"></div>\n <div class="zammad-scroll-hint is-hidden">\n <svg class="zammad-scroll-hint-icon" width="20" height="18" viewBox="0 0 20 18"><path d="M0,2.00585866 C0,0.898053512 0.898212381,0 1.99079514,0 L18.0092049,0 C19.1086907,0 20,0.897060126 20,2.00585866 L20,11.9941413 C20,13.1019465 19.1017876,14 18.0092049,14 L1.99079514,14 C0.891309342,14 0,13.1029399 0,11.9941413 L0,2.00585866 Z M10,14 L16,18 L16,14 L10,14 Z" fill-rule="evenodd"/></svg>\n ');
|
|
||||||
|
|
||||||
__out.push(this.T(this.scrollHint));
|
|
||||||
|
|
||||||
__out.push('\n </div>\n <div class="zammad-chat-body"></div>\n <form class="zammad-chat-controls">\n <div class="zammad-chat-input" rows="1" placeholder="');
|
|
||||||
|
|
||||||
__out.push(this.T('Compose your message...'));
|
|
||||||
|
|
||||||
__out.push('" contenteditable="true"></div>\n <button type="submit" class="zammad-chat-button zammad-chat-send"');
|
|
||||||
|
|
||||||
if (this.background) {
|
|
||||||
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('>');
|
|
||||||
|
|
||||||
__out.push(this.T('Send'));
|
|
||||||
|
|
||||||
__out.push('</button>\n </form>\n</div>');
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
|
|
||||||
}).call(__obj);
|
|
||||||
__obj.safe = __objSafe, __obj.escape = __escape;
|
|
||||||
return __out.join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!window.zammadChatTemplates) {
|
|
||||||
window.zammadChatTemplates = {};
|
|
||||||
}
|
|
||||||
window.zammadChatTemplates["customer_timeout"] = 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, '>')
|
|
||||||
.replace(/"/g, '"');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
(function() {
|
|
||||||
(function() {
|
|
||||||
__out.push('<div class="zammad-chat-modal-text">\n ');
|
|
||||||
|
|
||||||
if (this.agent) {
|
|
||||||
__out.push('\n ');
|
|
||||||
__out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation with <strong>%s</strong> got closed.', this.delay, this.agent));
|
|
||||||
__out.push('\n ');
|
|
||||||
} else {
|
|
||||||
__out.push('\n ');
|
|
||||||
__out.push(this.T('Since you didn\'t respond in the last %s minutes your conversation got closed.', this.delay));
|
|
||||||
__out.push('\n ');
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('\n <br>\n <div class="zammad-chat-button js-restart"');
|
|
||||||
|
|
||||||
if (this.background) {
|
|
||||||
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
|
||||||
}
|
|
||||||
|
|
||||||
__out.push('>');
|
|
||||||
|
|
||||||
__out.push(this.T('Start new conversation'));
|
|
||||||
|
|
||||||
__out.push('</div>\n</div>');
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
|
|
||||||
}).call(__obj);
|
|
||||||
__obj.safe = __objSafe, __obj.escape = __escape;
|
|
||||||
return __out.join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!window.zammadChatTemplates) {
|
if (!window.zammadChatTemplates) {
|
||||||
window.zammadChatTemplates = {};
|
window.zammadChatTemplates = {};
|
||||||
}
|
}
|
||||||
|
|
2
public/assets/chat/chat.min.js
vendored
2
public/assets/chat/chat.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -151,8 +151,8 @@
|
||||||
background: '#494d52',
|
background: '#494d52',
|
||||||
flat: true,
|
flat: true,
|
||||||
show: false,
|
show: false,
|
||||||
idleTimeout: 1,
|
idleTimeout: 0.2,
|
||||||
idleTimeoutIntervallCheck: 0.5,
|
idleTimeoutIntervallCheck: 0.2,
|
||||||
inactiveTimeout: 2,
|
inactiveTimeout: 2,
|
||||||
inactiveTimeoutIntervallCheck: 0.5,
|
inactiveTimeoutIntervallCheck: 0.5,
|
||||||
waitingListTimeout: 1.2,
|
waitingListTimeout: 1.2,
|
||||||
|
|
|
@ -158,8 +158,8 @@
|
||||||
background: '#494d52',
|
background: '#494d52',
|
||||||
flat: true,
|
flat: true,
|
||||||
show: false,
|
show: false,
|
||||||
idleTimeout: 1,
|
idleTimeout: 0.2,
|
||||||
idleTimeoutIntervallCheck: 0.5,
|
idleTimeoutIntervallCheck: 0.2,
|
||||||
inactiveTimeout: 2,
|
inactiveTimeout: 2,
|
||||||
inactiveTimeoutIntervallCheck: 0.5,
|
inactiveTimeoutIntervallCheck: 0.5,
|
||||||
waitingListTimeout: 1.2,
|
waitingListTimeout: 1.2,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
module EnsureWebsocket
|
module EnsureWebsocket
|
||||||
# Ensures that websocket is connectged
|
# Ensures that websocket is connected
|
||||||
#
|
#
|
||||||
# @param timeout [Integer] seconds to wait
|
# @param timeout [Integer] seconds to wait
|
||||||
# @param check_if_pinged [Boolean] checks if was pinged to prevent stale connections
|
# @param check_if_pinged [Boolean] checks if was pinged to prevent stale connections
|
||||||
|
|
52
spec/support/capybara/window_actions.rb
Normal file
52
spec/support/capybara/window_actions.rb
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
module WindowActions
|
||||||
|
|
||||||
|
delegate :app_host, to: Capybara
|
||||||
|
|
||||||
|
# This is a convenient wrapper method around #switch_to_window
|
||||||
|
# which switch to an given window index if exists.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# switch_to_window_index(2)
|
||||||
|
# => switch to window index 2
|
||||||
|
#
|
||||||
|
def switch_to_window_index(index)
|
||||||
|
return false if !windows[index - 1]
|
||||||
|
|
||||||
|
switch_to_window(windows[index - 1])
|
||||||
|
end
|
||||||
|
|
||||||
|
# This is a convenient wrapper method around #close window
|
||||||
|
# which will close the given window index if it exists.
|
||||||
|
# If only one window is still open afterwards it will switch to it.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# close_window_index(2)
|
||||||
|
# => close window with index 2
|
||||||
|
#
|
||||||
|
def close_window_index(index)
|
||||||
|
return false if !windows[index - 1]
|
||||||
|
|
||||||
|
windows[index - 1].close
|
||||||
|
|
||||||
|
switch_to_window(windows[0]) if windows.length == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# This is a convenient wrapper method around #open_new_window
|
||||||
|
# which open a new window and switched directly to it
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# open_window_and_switch
|
||||||
|
# => open new window and switch to this window
|
||||||
|
#
|
||||||
|
def open_window_and_switch
|
||||||
|
window = open_new_window
|
||||||
|
|
||||||
|
switch_to_window(window)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.include WindowActions, type: :system
|
||||||
|
end
|
30
spec/system/chat_spec.rb
Normal file
30
spec/system/chat_spec.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Chat Handling', type: :system do
|
||||||
|
let(:agent_chat_switch_selector) { '#navigation .js-chatMenuItem .js-switch' }
|
||||||
|
|
||||||
|
def authenticate
|
||||||
|
Setting.set('chat', true)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Check that button is hidden after idle timeout (JQuery and without JQuery variant)', authenticated_as: :authenticate do
|
||||||
|
click agent_chat_switch_selector
|
||||||
|
|
||||||
|
open_window_and_switch
|
||||||
|
|
||||||
|
visit "/assets/chat/znuny_open_by_button.html?port=#{ENV['WS_PORT']}"
|
||||||
|
|
||||||
|
expect(page).to have_css('.zammad-chat', visible: :all)
|
||||||
|
expect(page).to have_css('.zammad-chat-is-hidden', visible: :all)
|
||||||
|
expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', visible: :all)
|
||||||
|
|
||||||
|
visit "/assets/chat/znuny-no-jquery-open_by_button.html?port=#{ENV['WS_PORT']}"
|
||||||
|
|
||||||
|
expect(page).to have_css('.zammad-chat', visible: :all)
|
||||||
|
expect(page).to have_css('.zammad-chat-is-hidden', visible: :all)
|
||||||
|
expect(page).to have_no_css('.open-zammad-chat:not([style*="display: none"]', visible: :all)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue