Fixes #2881: Chat button is no longer optional in no jQuery version. Thanks to @ma-jahn ❤️

This commit is contained in:
Thorsten Eckel 2020-01-13 10:58:16 +01:00
parent 3bd3eeb163
commit 44806e79e5
3 changed files with 28 additions and 15 deletions

View file

@ -467,7 +467,9 @@ do(window) ->
@renderBase() @renderBase()
# disable open button # disable open button
document.querySelector(".#{ @options.buttonClass }").classList.add @inactiveClass btn = document.querySelector(".#{ @options.buttonClass }")
if btn
btn.classList.add @inactiveClass
@setAgentOnlineState 'online' @setAgentOnlineState 'online'
@ -770,7 +772,10 @@ do(window) ->
onError: (message) => onError: (message) =>
@log.debug message @log.debug message
@addStatus(message) @addStatus(message)
document.querySelector(".#{ @options.buttonClass }").classList.add('zammad-chat-is-hidden') btn = document.querySelector(".#{ @options.buttonClass }")
if btn
btn.classList.add('zammad-chat-is-hidden')
if @isOpen if @isOpen
@disableInput() @disableInput()
@destroy(remove: false) @destroy(remove: false)

View file

@ -739,10 +739,14 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
}; };
ZammadChat.prototype.render = function() { ZammadChat.prototype.render = function() {
var btn;
if (!this.el || !document.querySelector('.zammad-chat')) { if (!this.el || !document.querySelector('.zammad-chat')) {
this.renderBase(); this.renderBase();
} }
document.querySelector("." + this.options.buttonClass).classList.add(this.inactiveClass); btn = document.querySelector("." + this.options.buttonClass);
if (btn) {
btn.classList.add(this.inactiveClass);
}
this.setAgentOnlineState('online'); this.setAgentOnlineState('online');
this.log.debug('widget rendered'); this.log.debug('widget rendered');
this.startTimeoutObservers(); this.startTimeoutObservers();
@ -1088,9 +1092,13 @@ var extend = function(child, parent) { for (var key in parent) { if (hasProp.cal
}; };
ZammadChat.prototype.onError = function(message) { ZammadChat.prototype.onError = function(message) {
var btn;
this.log.debug(message); this.log.debug(message);
this.addStatus(message); this.addStatus(message);
document.querySelector("." + this.options.buttonClass).classList.add('zammad-chat-is-hidden'); btn = document.querySelector("." + this.options.buttonClass);
if (btn) {
btn.classList.add('zammad-chat-is-hidden');
}
if (this.isOpen) { if (this.isOpen) {
this.disableInput(); this.disableInput();
return this.destroy({ return this.destroy({

File diff suppressed because one or more lines are too long