2015-11-11 20:44:54 +00:00
var bind = function ( fn , me ) { return function ( ) { return fn . apply ( me , arguments ) ; } ; } ,
slice = [ ] . slice ;
2015-10-15 09:26:56 +00:00
( function ( $ , window ) {
var ZammadChat ;
ZammadChat = ( function ( ) {
ZammadChat . prototype . defaults = {
invitationPhrase : '<strong>Chat</strong> with us!' ,
2015-11-02 15:48:16 +00:00
agentPhrase : ' is helping you' ,
2015-10-15 09:26:56 +00:00
show : true ,
target : $ ( 'body' )
} ;
2015-11-02 15:48:16 +00:00
ZammadChat . prototype . _messageCount = 0 ;
2015-10-15 09:26:56 +00:00
ZammadChat . prototype . isOpen = false ;
ZammadChat . prototype . blinkOnlineInterval = null ;
ZammadChat . prototype . stopBlinOnlineStateTimeout = null ;
ZammadChat . prototype . showTimeEveryXMinutes = 1 ;
ZammadChat . prototype . lastTimestamp = null ;
ZammadChat . prototype . lastAddedType = null ;
ZammadChat . prototype . inputTimeout = null ;
ZammadChat . prototype . isTyping = false ;
ZammadChat . prototype . isOnline = true ;
2015-11-12 14:05:43 +00:00
ZammadChat . prototype . initialQueueDelay = 10000 ;
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . debug = true ;
ZammadChat . prototype . host = 'ws://localhost:6042' ;
2015-10-15 09:26:56 +00:00
ZammadChat . prototype . strings = {
'Online' : 'Online' ,
'Offline' : 'Offline' ,
2015-11-11 20:44:54 +00:00
'Connecting' : 'Verbinden' ,
2015-10-15 09:26:56 +00:00
'Connection re-established' : 'Connection re-established' ,
2015-11-11 20:44:54 +00:00
'Today' : 'Heute' ,
'Send' : 'Senden' ,
'Compose your message...' : 'Ihre Nachricht...' ,
'All colleges are busy.' : 'Alle Kollegen sind belegt.' ,
'You are on waiting list position <strong>%s</strong>.' : 'Sie sind in der Warteliste an der Position <strong>%s</strong>.' ,
2015-11-12 16:32:11 +00:00
'Start new conversation' : 'Neue Konversation starten' ,
'Since you didn\'t respond in the last %s your conversation with <strong>%s</strong> got closed.' : 'Da sie in den letzten %s nichts geschrieben haben wurde ihre Konversation mit <strong>%s</strong> geschlossen.' ,
'minutes' : 'Minuten'
2015-11-11 20:44:54 +00:00
} ;
2015-11-12 10:44:37 +00:00
ZammadChat . prototype . sessionId = void 0 ;
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . T = function ( ) {
var i , item , items , len , string , translation ;
string = arguments [ 0 ] , items = 2 <= arguments . length ? slice . call ( arguments , 1 ) : [ ] ;
if ( ! this . strings [ string ] ) {
this . log ( 'notice' , "Translation needed for '" + string + "'" ) ;
}
translation = this . strings [ string ] || string ;
if ( items ) {
for ( i = 0 , len = items . length ; i < len ; i ++ ) {
item = items [ i ] ;
translation = translation . replace ( /%s/ , item ) ;
}
}
return translation ;
2015-10-15 09:26:56 +00:00
} ;
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . log = function ( ) {
var level , string ;
level = arguments [ 0 ] , string = 2 <= arguments . length ? slice . call ( arguments , 1 ) : [ ] ;
if ( ! this . debug && level === 'debug' ) {
return ;
}
return console . log ( level , string ) ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . view = function ( name ) {
2015-11-02 15:48:16 +00:00
return ( function ( _this ) {
return function ( options ) {
if ( ! options ) {
options = { } ;
}
options . T = _this . T ;
return window . zammadChatTemplates [ name ] ( options ) ;
} ;
} ) ( this ) ;
2015-10-15 09:26:56 +00:00
} ;
function ZammadChat ( el , options ) {
this . setAgentOnlineState = bind ( this . setAgentOnlineState , this ) ;
this . onConnectionEstablished = bind ( this . onConnectionEstablished , this ) ;
2015-11-12 14:05:43 +00:00
this . setSessionId = bind ( this . setSessionId , this ) ;
2015-10-15 09:26:56 +00:00
this . onConnectionReestablished = bind ( this . onConnectionReestablished , this ) ;
this . reconnect = bind ( this . reconnect , this ) ;
2015-11-12 14:05:43 +00:00
this . onWebSocketOpen = bind ( this . onWebSocketOpen , this ) ;
2015-11-11 20:44:54 +00:00
this . connect = bind ( this . connect , this ) ;
2015-10-15 09:26:56 +00:00
this . onAgentTypingEnd = bind ( this . onAgentTypingEnd , this ) ;
this . onAgentTypingStart = bind ( this . onAgentTypingStart , this ) ;
2015-11-02 15:48:16 +00:00
this . onQueue = bind ( this . onQueue , this ) ;
2015-11-12 14:05:43 +00:00
this . onQueueScreen = bind ( this . onQueueScreen , this ) ;
2015-10-15 09:26:56 +00:00
this . onCloseAnimationEnd = bind ( this . onCloseAnimationEnd , this ) ;
2015-11-12 14:05:43 +00:00
this . closeWindow = bind ( this . closeWindow , this ) ;
2015-11-11 10:44:10 +00:00
this . close = bind ( this . close , this ) ;
2015-10-15 09:26:56 +00:00
this . onOpenAnimationEnd = bind ( this . onOpenAnimationEnd , this ) ;
2015-11-11 10:44:10 +00:00
this . open = bind ( this . open , this ) ;
2015-11-12 14:05:43 +00:00
this . renderMessage = bind ( this . renderMessage , this ) ;
2015-10-15 09:26:56 +00:00
this . receiveMessage = bind ( this . receiveMessage , this ) ;
this . onSubmit = bind ( this . onSubmit , this ) ;
this . onTypingEnd = bind ( this . onTypingEnd , this ) ;
this . onInput = bind ( this . onInput , this ) ;
2015-11-12 16:32:11 +00:00
this . reopenSession = bind ( this . reopenSession , this ) ;
2015-11-02 15:48:16 +00:00
this . onReady = bind ( this . onReady , this ) ;
this . onWebSocketMessage = bind ( this . onWebSocketMessage , this ) ;
this . send = bind ( this . send , this ) ;
2015-10-15 09:26:56 +00:00
this . checkForEnter = bind ( this . checkForEnter , this ) ;
2015-11-02 15:48:16 +00:00
this . view = bind ( this . view , this ) ;
2015-11-11 20:44:54 +00:00
this . log = bind ( this . log , this ) ;
2015-11-02 15:48:16 +00:00
this . T = bind ( this . T , this ) ;
2015-10-15 09:26:56 +00:00
this . options = $ . extend ( { } , this . defaults , options ) ;
2015-11-02 15:48:16 +00:00
this . el = $ ( this . view ( 'chat' ) ( this . options ) ) ;
2015-10-15 09:26:56 +00:00
this . options . target . append ( this . el ) ;
2015-11-12 14:05:43 +00:00
this . input = this . el . find ( '.zammad-chat-input' ) ;
2015-11-12 15:19:47 +00:00
this . el . find ( '.js-chat-open' ) . click ( ( function ( _this ) {
return function ( ) {
return _this . open ( ) ;
} ;
} ) ( this ) ) ;
2015-11-11 10:44:10 +00:00
this . el . find ( '.js-chat-close' ) . click ( this . close ) ;
2015-10-15 09:26:56 +00:00
this . el . find ( '.zammad-chat-controls' ) . on ( 'submit' , this . onSubmit ) ;
2015-11-12 14:05:43 +00:00
this . input . on ( {
2015-10-15 09:26:56 +00:00
keydown : this . checkForEnter ,
input : this . onInput
} ) ;
2015-11-12 14:05:43 +00:00
if ( ! window . WebSocket || ! sessionStorage ) {
2015-11-11 20:44:54 +00:00
this . log ( 'notice' , 'Chat: Browser not supported!' ) ;
2015-11-02 15:48:16 +00:00
return ;
}
2015-11-11 20:44:54 +00:00
this . connect ( ) ;
2015-10-15 09:26:56 +00:00
}
ZammadChat . prototype . checkForEnter = function ( event ) {
if ( ! event . shiftKey && event . keyCode === 13 ) {
event . preventDefault ( ) ;
return this . sendMessage ( ) ;
}
} ;
2015-11-10 14:01:04 +00:00
ZammadChat . prototype . send = function ( event , data ) {
2015-11-02 15:48:16 +00:00
var pipe ;
2015-11-11 20:44:54 +00:00
this . log ( 'debug' , 'ws:send' , event , data ) ;
2015-11-02 15:48:16 +00:00
pipe = JSON . stringify ( {
2015-11-10 14:01:04 +00:00
event : event ,
2015-11-02 15:48:16 +00:00
data : data
} ) ;
return this . ws . send ( pipe ) ;
} ;
ZammadChat . prototype . onWebSocketMessage = function ( e ) {
2015-11-11 13:10:26 +00:00
var i , len , pipe , pipes ;
2015-11-10 14:01:04 +00:00
pipes = JSON . parse ( e . data ) ;
for ( i = 0 , len = pipes . length ; i < len ; i ++ ) {
pipe = pipes [ i ] ;
2015-11-12 14:05:43 +00:00
this . log ( 'debug' , 'ws:onmessage' , pipe ) ;
2015-11-10 14:01:04 +00:00
switch ( pipe . event ) {
case 'chat_session_message' :
if ( pipe . data . self _written ) {
return ;
}
this . receiveMessage ( pipe . data ) ;
break ;
case 'chat_session_typing' :
if ( pipe . data . self _written ) {
return ;
}
this . onAgentTypingStart ( ) ;
break ;
case 'chat_session_start' :
2015-11-12 14:05:43 +00:00
this . onConnectionEstablished ( pipe . data ) ;
2015-11-10 14:01:04 +00:00
break ;
2015-11-12 10:44:37 +00:00
case 'chat_session_queue' :
2015-11-12 16:32:11 +00:00
this . onQueueScreen ( pipe . data ) ;
2015-11-10 14:01:04 +00:00
break ;
2015-11-11 20:44:54 +00:00
case 'chat_session_closed' :
this . onSessionClosed ( pipe . data ) ;
break ;
case 'chat_session_left' :
this . onSessionClosed ( pipe . data ) ;
break ;
2015-11-11 13:10:26 +00:00
case 'chat_status_customer' :
2015-11-10 14:01:04 +00:00
switch ( pipe . data . state ) {
case 'online' :
this . onReady ( ) ;
2015-11-11 20:44:54 +00:00
this . log ( 'debug' , 'Zammad Chat: ready' ) ;
2015-11-10 14:01:04 +00:00
break ;
case 'offline' :
2015-11-11 20:44:54 +00:00
this . log ( 'debug' , 'Zammad Chat: No agent online' ) ;
2015-11-10 14:01:04 +00:00
break ;
case 'chat_disabled' :
2015-11-11 20:44:54 +00:00
this . log ( 'debug' , 'Zammad Chat: Chat is disabled' ) ;
2015-11-10 14:01:04 +00:00
break ;
case 'no_seats_available' :
2015-11-11 20:44:54 +00:00
this . log ( 'debug' , 'Zammad Chat: Too many clients in queue. Clients in queue: ' , pipe . data . queue ) ;
2015-11-12 09:39:14 +00:00
break ;
case 'reconnect' :
this . log ( 'debug' , 'old messages' , pipe . data . session ) ;
2015-11-12 16:32:11 +00:00
this . reopenSession ( pipe . data ) ;
2015-11-10 14:01:04 +00:00
}
}
2015-11-02 15:48:16 +00:00
}
} ;
ZammadChat . prototype . onReady = function ( ) {
if ( this . options . show ) {
2015-11-12 14:05:43 +00:00
return this . show ( ) ;
}
} ;
2015-11-12 16:32:11 +00:00
ZammadChat . prototype . reopenSession = function ( data ) {
var i , len , message , ref , unfinishedMessage ;
2015-11-12 14:05:43 +00:00
unfinishedMessage = sessionStorage . getItem ( 'unfinished_message' ) ;
2015-11-12 16:32:11 +00:00
this . onConnectionEstablished ( data ) ;
ref = data . session ;
for ( i = 0 , len = ref . length ; i < len ; i ++ ) {
message = ref [ i ] ;
2015-11-12 14:05:43 +00:00
this . renderMessage ( {
message : message . content ,
id : message . id ,
from : message . created _by _id ? 'agent' : 'customer'
2015-11-11 09:48:54 +00:00
} ) ;
2015-11-02 15:48:16 +00:00
}
2015-11-12 14:05:43 +00:00
if ( unfinishedMessage ) {
this . input . val ( unfinishedMessage ) ;
}
this . show ( ) ;
2015-11-12 15:19:47 +00:00
this . open ( ) ;
2015-11-12 16:32:11 +00:00
this . scrollToBottom ( ) ;
2015-11-12 14:05:43 +00:00
if ( unfinishedMessage ) {
return this . input . focus ( ) ;
}
2015-11-02 15:48:16 +00:00
} ;
2015-10-15 09:26:56 +00:00
ZammadChat . prototype . onInput = function ( ) {
this . el . find ( '.zammad-chat-message--unread' ) . removeClass ( 'zammad-chat-message--unread' ) ;
2015-11-12 14:05:43 +00:00
sessionStorage . setItem ( 'unfinished_message' , this . input . val ( ) ) ;
2015-11-10 14:01:04 +00:00
return this . onTypingStart ( ) ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . onTypingStart = function ( ) {
2015-11-10 14:01:04 +00:00
if ( this . isTypingTimeout ) {
clearTimeout ( this . isTypingTimeout ) ;
}
this . isTypingTimeout = setTimeout ( this . onTypingEnd , 1500 ) ;
if ( ! this . isTyping ) {
this . isTyping = true ;
return this . send ( 'chat_session_typing' , {
2015-11-12 10:44:37 +00:00
session _id : this . sessionId
2015-11-10 14:01:04 +00:00
} ) ;
}
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . onTypingEnd = function ( ) {
2015-11-10 14:01:04 +00:00
return this . isTyping = false ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . onSubmit = function ( event ) {
event . preventDefault ( ) ;
return this . sendMessage ( ) ;
} ;
ZammadChat . prototype . sendMessage = function ( ) {
var message , messageElement ;
2015-11-12 14:05:43 +00:00
message = this . input . val ( ) ;
2015-11-02 15:48:16 +00:00
if ( ! message ) {
return ;
}
2015-11-12 14:05:43 +00:00
sessionStorage . removeItem ( 'unfinished_message' ) ;
2015-11-02 15:48:16 +00:00
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 ) ;
2015-10-15 09:26:56 +00:00
}
2015-11-12 14:05:43 +00:00
this . input . val ( '' ) ;
2015-11-02 15:48:16 +00:00
this . scrollToBottom ( ) ;
this . isTyping = false ;
2015-11-10 14:01:04 +00:00
return this . send ( 'chat_session_message' , {
content : message ,
id : this . _messageCount ,
2015-11-12 10:44:37 +00:00
session _id : this . sessionId
2015-11-02 15:48:16 +00:00
} ) ;
2015-10-15 09:26:56 +00:00
} ;
2015-11-02 15:48:16 +00:00
ZammadChat . prototype . receiveMessage = function ( data ) {
2015-10-15 09:26:56 +00:00
this . onAgentTypingEnd ( ) ;
this . maybeAddTimestamp ( ) ;
2015-11-12 14:05:43 +00:00
return this . renderMessage ( {
2015-11-10 14:01:04 +00:00
message : data . message . content ,
2015-11-02 15:48:16 +00:00
id : data . id ,
2015-10-15 09:26:56 +00:00
from : 'agent'
2015-11-12 14:05:43 +00:00
} ) ;
} ;
ZammadChat . prototype . renderMessage = function ( data ) {
var ref , unread ;
this . lastAddedType = "message--" + data . from ;
unread = ( ref = document . hidden ) != null ? ref : {
" zammad-chat-message--unread" : ""
} ;
this . el . find ( '.zammad-chat-body' ) . append ( this . view ( 'message' ) ( data ) ) ;
2015-10-15 09:26:56 +00:00
return this . scrollToBottom ( ) ;
} ;
2015-11-12 15:19:47 +00:00
ZammadChat . prototype . open = function ( ) {
2015-10-15 09:26:56 +00:00
if ( this . isOpen ) {
2015-11-12 16:32:11 +00:00
this . show ( ) ;
2015-10-15 09:26:56 +00:00
}
2015-11-12 15:19:47 +00:00
if ( ! this . sessionId ) {
2015-11-12 14:05:43 +00:00
this . showLoader ( ) ;
}
this . el . addClass ( 'zammad-chat-is-open' ) ;
2015-11-12 15:19:47 +00:00
if ( ! this . sessionId ) {
2015-11-12 14:05:43 +00:00
this . el . animate ( {
bottom : 0
} , 500 , this . onOpenAnimationEnd ) ;
} else {
this . el . css ( 'bottom' , 0 ) ;
this . onOpenAnimationEnd ( ) ;
}
2015-11-11 10:44:10 +00:00
return this . isOpen = true ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . onOpenAnimationEnd = function ( ) {
2015-11-12 15:19:47 +00:00
if ( ! this . sessionId ) {
return this . session _init ( ) ;
}
2015-10-15 09:26:56 +00:00
} ;
2015-11-11 10:44:10 +00:00
ZammadChat . prototype . close = function ( event ) {
if ( event ) {
event . stopPropagation ( ) ;
}
2015-11-12 14:05:43 +00:00
sessionStorage . removeItem ( 'sessionId' ) ;
sessionStorage . removeItem ( 'unfinished_message' ) ;
return this . closeWindow ( ) ;
} ;
ZammadChat . prototype . closeWindow = function ( ) {
var remainerHeight ;
2015-10-15 09:26:56 +00:00
remainerHeight = this . el . height ( ) - this . el . find ( '.zammad-chat-header' ) . outerHeight ( ) ;
return this . el . animate ( {
bottom : - remainerHeight
2015-10-15 13:28:30 +00:00
} , 500 , this . onCloseAnimationEnd ) ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . onCloseAnimationEnd = function ( ) {
this . el . removeClass ( 'zammad-chat-is-open' ) ;
this . disconnect ( ) ;
2015-11-11 20:44:54 +00:00
this . isOpen = false ;
2015-11-12 16:32:11 +00:00
this . send ( 'chat_session_close' , {
2015-11-12 10:44:37 +00:00
session _id : this . sessionId
2015-11-11 20:44:54 +00:00
} ) ;
2015-11-12 16:32:11 +00:00
return this . setSessionId ( void 0 ) ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . hide = function ( ) {
return this . el . removeClass ( 'zammad-chat-is-visible' ) ;
} ;
ZammadChat . prototype . show = function ( ) {
var remainerHeight ;
this . el . addClass ( 'zammad-chat-is-visible' ) ;
2015-10-15 13:28:30 +00:00
remainerHeight = this . el . outerHeight ( ) - this . el . find ( '.zammad-chat-header' ) . outerHeight ( ) ;
2015-11-12 14:05:43 +00:00
this . el . css ( 'bottom' , - remainerHeight ) ;
return this . input . autoGrow ( {
extraLine : false
} ) ;
2015-10-15 09:26:56 +00:00
} ;
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . disableInput = function ( ) {
2015-11-12 14:05:43 +00:00
this . input . prop ( 'disabled' , true ) ;
2015-11-11 20:44:54 +00:00
return this . el . find ( '.zammad-chat-send' ) . prop ( 'disabled' , true ) ;
} ;
ZammadChat . prototype . enableInput = function ( ) {
2015-11-12 14:05:43 +00:00
this . input . prop ( 'disabled' , false ) ;
2015-11-11 20:44:54 +00:00
return this . el . find ( '.zammad-chat-send' ) . prop ( 'disabled' , false ) ;
} ;
2015-11-12 14:05:43 +00:00
ZammadChat . prototype . onQueueScreen = function ( data ) {
var show ;
show = ( function ( _this ) {
return function ( ) {
2015-11-12 15:19:47 +00:00
return _this . onQueue ( data ) ;
2015-11-12 14:05:43 +00:00
} ;
} ) ( this ) ;
if ( this . initialQueueDelay && ! this . onInitialQueueDelayId ) {
this . onInitialQueueDelayId = setTimeout ( show , this . initialQueueDelay ) ;
return ;
}
if ( this . onInitialQueueDelayId ) {
clearTimeout ( this . onInitialQueueDelayId ) ;
}
return show ( ) ;
} ;
2015-11-12 15:19:47 +00:00
ZammadChat . prototype . onQueue = function ( data ) {
this . log ( 'notice' , 'onQueue' , data . position ) ;
2015-11-02 15:48:16 +00:00
this . inQueue = true ;
2015-11-12 14:05:43 +00:00
this . setSessionId ( data . session _id ) ;
2015-11-02 15:48:16 +00:00
return this . el . find ( '.zammad-chat-body' ) . html ( this . view ( 'waiting' ) ( {
2015-11-12 14:05:43 +00:00
position : data . position
2015-11-02 15:48:16 +00:00
} ) ) ;
} ;
2015-10-15 09:26:56 +00:00
ZammadChat . prototype . onAgentTypingStart = function ( ) {
2015-11-11 13:10:26 +00:00
if ( this . stopTypingId ) {
clearTimeout ( this . stopTypingId ) ;
}
this . stopTypingId = setTimeout ( this . onAgentTypingEnd , 3000 ) ;
2015-10-15 09:26:56 +00:00
if ( this . el . find ( '.zammad-chat-message--typing' ) . size ( ) ) {
return ;
}
this . maybeAddTimestamp ( ) ;
this . el . find ( '.zammad-chat-body' ) . append ( this . view ( 'typingIndicator' ) ( ) ) ;
return this . scrollToBottom ( ) ;
} ;
ZammadChat . prototype . onAgentTypingEnd = function ( ) {
return this . el . find ( '.zammad-chat-message--typing' ) . remove ( ) ;
} ;
ZammadChat . prototype . maybeAddTimestamp = function ( ) {
var label , time , timestamp ;
timestamp = Date . now ( ) ;
if ( ! this . lastTimestamp || ( timestamp - this . lastTimestamp ) > this . showTimeEveryXMinutes * 60000 ) {
label = this . T ( 'Today' ) ;
time = new Date ( ) . toTimeString ( ) . substr ( 0 , 5 ) ;
if ( this . lastAddedType === 'timestamp' ) {
this . updateLastTimestamp ( label , time ) ;
return this . lastTimestamp = timestamp ;
} else {
2015-11-12 15:19:47 +00:00
this . el . find ( '.zammad-chat-body' ) . append ( this . view ( 'timestamp' ) ( {
label : label ,
time : time
} ) ) ;
2015-10-15 09:26:56 +00:00
this . lastTimestamp = timestamp ;
2015-11-12 15:19:47 +00:00
this . lastAddedType = 'timestamp' ;
return this . scrollToBottom ( ) ;
2015-10-15 09:26:56 +00:00
}
}
} ;
ZammadChat . prototype . updateLastTimestamp = function ( label , time ) {
2015-11-12 15:19:47 +00:00
return this . el . find ( '.zammad-chat-body' ) . find ( '.zammad-chat-timestamp' ) . last ( ) . replaceWith ( this . view ( 'timestamp' ) ( {
2015-10-15 09:26:56 +00:00
label : label ,
time : time
} ) ) ;
} ;
2015-11-12 15:19:47 +00:00
ZammadChat . prototype . addStatus = function ( status ) {
2015-11-12 16:32:11 +00:00
this . maybeAddTimestamp ( ) ;
2015-11-12 15:19:47 +00:00
this . el . find ( '.zammad-chat-body' ) . append ( this . view ( 'status' ) ( {
status : status
2015-10-15 09:26:56 +00:00
} ) ) ;
2015-11-12 15:19:47 +00:00
return this . scrollToBottom ( ) ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . scrollToBottom = function ( ) {
return this . el . find ( '.zammad-chat-body' ) . scrollTop ( $ ( '.zammad-chat-body' ) . prop ( 'scrollHeight' ) ) ;
} ;
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . session _init = function ( ) {
2015-11-10 14:01:04 +00:00
return this . send ( 'chat_session_init' ) ;
2015-11-02 15:48:16 +00:00
} ;
2015-10-15 09:26:56 +00:00
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . connect = function ( ) {
this . log ( 'notice' , "Connecting to " + this . host ) ;
this . ws = new window . WebSocket ( this . host ) ;
2015-11-12 14:05:43 +00:00
this . ws . onopen = this . onWebSocketOpen ;
2015-11-11 20:44:54 +00:00
this . ws . onmessage = this . onWebSocketMessage ;
this . ws . onclose = ( function ( _this ) {
return function ( e ) {
_this . log ( 'debug' , 'close websocket connection' ) ;
_this . reconnect ( ) ;
return _this . setAgentOnlineState ( false ) ;
} ;
} ) ( this ) ;
return this . ws . onerror = ( function ( _this ) {
return function ( e ) {
return _this . log ( 'debug' , 'ws:onerror' , e ) ;
} ;
} ) ( this ) ;
} ;
2015-11-12 14:05:43 +00:00
ZammadChat . prototype . onWebSocketOpen = function ( ) {
this . sessionId = sessionStorage . getItem ( 'sessionId' ) ;
this . log ( 'debug' , 'ws connected' ) ;
this . send ( 'chat_status_customer' , {
session _id : this . sessionId
} ) ;
return this . setAgentOnlineState ( true ) ;
} ;
2015-10-15 09:26:56 +00:00
ZammadChat . prototype . reconnect = function ( ) {
2015-11-11 20:44:54 +00:00
this . log ( 'notice' , 'reconnecting' ) ;
this . disableInput ( ) ;
2015-10-15 09:26:56 +00:00
this . lastAddedType = 'status' ;
2015-11-11 20:44:54 +00:00
this . el . find ( '.zammad-chat-agent-status' ) . attr ( 'data-status' , 'connecting' ) . text ( this . T ( 'Reconnecting' ) ) ;
this . addStatus ( this . T ( 'Connection lost' ) ) ;
if ( this . reconnectDelayId ) {
clearTimeout ( this . reconnectDelayId ) ;
}
return this . reconnectDelayId = setTimeout ( this . connect , 5000 ) ;
2015-10-15 09:26:56 +00:00
} ;
ZammadChat . prototype . onConnectionReestablished = function ( ) {
this . lastAddedType = 'status' ;
this . el . find ( '.zammad-chat-agent-status' ) . attr ( 'data-status' , 'online' ) . text ( this . T ( 'Online' ) ) ;
return this . addStatus ( this . T ( 'Connection re-established' ) ) ;
} ;
2015-11-11 20:44:54 +00:00
ZammadChat . prototype . onSessionClosed = function ( data ) {
this . addStatus ( this . T ( 'Chat closed by %s' , data . realname ) ) ;
return this . disableInput ( ) ;
} ;
2015-10-15 09:26:56 +00:00
ZammadChat . prototype . disconnect = function ( ) {
2015-11-02 15:48:16 +00:00
this . showLoader ( ) ;
2015-10-15 09:26:56 +00:00
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' ) ;
} ;
2015-11-12 14:05:43 +00:00
ZammadChat . prototype . setSessionId = function ( id ) {
this . sessionId = id ;
2015-11-12 16:32:11 +00:00
if ( id === void 0 ) {
return sessionStorage . removeItem ( 'sessionId' ) ;
} else {
return sessionStorage . setItem ( 'sessionId' , id ) ;
}
2015-11-12 14:05:43 +00:00
} ;
ZammadChat . prototype . onConnectionEstablished = function ( data ) {
if ( this . onInitialQueueDelayId ) {
clearTimeout ( this . onInitialQueueDelayId ) ;
}
2015-11-02 15:48:16 +00:00
this . inQueue = false ;
2015-11-12 16:32:11 +00:00
if ( data . agent ) {
this . agent = data . agent ;
}
if ( data . session _id ) {
this . setSessionId ( data . session _id ) ;
}
2015-11-02 15:48:16 +00:00
this . el . find ( '.zammad-chat-agent' ) . html ( this . view ( 'agent' ) ( {
2015-11-12 14:05:43 +00:00
agent : this . agent
2015-11-02 15:48:16 +00:00
} ) ) ;
2015-11-11 20:44:54 +00:00
this . enableInput ( ) ;
2015-11-02 15:48:16 +00:00
this . el . find ( '.zammad-chat-body' ) . empty ( ) ;
2015-10-15 09:26:56 +00:00
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' ) ;
2015-11-12 14:05:43 +00:00
return this . input . focus ( ) ;
2015-10-15 09:26:56 +00:00
} ;
2015-11-12 16:32:11 +00:00
ZammadChat . prototype . showTimeout = function ( ) {
return this . el . find ( '.zammad-chat-body' ) . html ( this . view ( 'timeout' ) ( {
agent : this . agent . name ,
delay : 10 ,
unit : this . T ( 'minutes' )
} ) ) ;
} ;
2015-11-02 15:48:16 +00:00
ZammadChat . prototype . showLoader = function ( ) {
return this . el . find ( '.zammad-chat-body' ) . html ( this . view ( 'loader' ) ( ) ) ;
} ;
2015-10-15 09:26:56 +00:00
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' ) ) ;
} ;
return ZammadChat ;
} ) ( ) ;
return $ ( document ) . ready ( function ( ) {
return window . zammadChat = new ZammadChat ( ) ;
} ) ;
} ) ( window . jQuery , window ) ;
2015-11-12 16:32:11 +00:00
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> ' ) ;
_ _out . push ( this . agentPhrase ) ;
_ _out . push ( '\n</span>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
2015-10-15 09:14:19 +00:00
/ * !
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
* "THE BEER-WARE LICENSE" ( Revision 42 ) :
* < jevin9 @ gmail . com > wrote this file . As long as you retain this notice you
* can do whatever you want with this stuff . If we meet some day , and you think
* this stuff is worth it , you can buy me a beer in return . Jevin O . Sewaruth
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
*
* Autogrow Textarea Plugin Version v3 . 0
* http : //www.technoreply.com/autogrow-textarea-plugin-3-0
*
* THIS PLUGIN IS DELIVERD ON A PAY WHAT YOU WHANT BASIS . IF THE PLUGIN WAS USEFUL TO YOU , PLEASE CONSIDER BUYING THE PLUGIN HERE :
* https : //sites.fastspring.com/technoreply/instant/autogrowtextareaplugin
*
* Date : October 15 , 2012
* /
jQuery . fn . autoGrow = function ( options ) {
return this . each ( function ( ) {
var settings = jQuery . extend ( {
extraLine : true ,
} , options ) ;
var createMirror = function ( textarea ) {
jQuery ( textarea ) . after ( '<div class="autogrow-textarea-mirror"></div>' ) ;
return jQuery ( textarea ) . next ( '.autogrow-textarea-mirror' ) [ 0 ] ;
}
var sendContentToMirror = function ( textarea ) {
mirror . innerHTML = String ( textarea . value )
. replace ( /&/g , '&' )
. replace ( /"/g , '"' )
. replace ( /'/g , ''' )
. replace ( /</g , '<' )
. replace ( />/g , '>' )
. replace ( / /g , ' ' )
. replace ( /\n/g , '<br />' ) +
( settings . extraLine ? '.<br/>.' : '' )
;
if ( jQuery ( textarea ) . height ( ) != jQuery ( mirror ) . height ( ) )
jQuery ( textarea ) . height ( jQuery ( mirror ) . height ( ) ) ;
}
var growTextarea = function ( ) {
sendContentToMirror ( this ) ;
}
// Create a mirror
var mirror = createMirror ( this ) ;
// Style the mirror
mirror . style . display = 'none' ;
mirror . style . wordWrap = 'break-word' ;
mirror . style . whiteSpace = 'normal' ;
mirror . style . padding = jQuery ( this ) . css ( 'paddingTop' ) + ' ' +
jQuery ( this ) . css ( 'paddingRight' ) + ' ' +
jQuery ( this ) . css ( 'paddingBottom' ) + ' ' +
jQuery ( this ) . css ( 'paddingLeft' ) ;
mirror . style . width = jQuery ( this ) . css ( 'width' ) ;
mirror . style . fontFamily = jQuery ( this ) . css ( 'font-family' ) ;
mirror . style . fontSize = jQuery ( this ) . css ( 'font-size' ) ;
mirror . style . lineHeight = jQuery ( this ) . css ( 'line-height' ) ;
// Style the textarea
this . style . overflow = "hidden" ;
this . style . minHeight = this . rows + "em" ;
// Bind the textarea's event
this . onkeyup = growTextarea ;
// Fire the event for text already present
sendContentToMirror ( this ) ;
} ) ;
} ;
2015-11-12 15:19:47 +00:00
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
2015-11-12 16:32:11 +00:00
window . zammadChatTemplates [ "chat" ] = function ( _ _obj ) {
2015-11-12 15:19:47 +00:00
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 ( ) {
2015-11-12 16:32:11 +00:00
_ _out . push ( '<div class="zammad-chat">\n <div class="zammad-chat-header js-chat-open">\n <div class="zammad-chat-header-controls">\n <span class="zammad-chat-agent-status zammad-chat-is-hidden" data-status="online">Online</span>\n <span class="zammad-chat-header-icon">\n <svg class="zammad-chat-header-icon-open" 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 js-chat-close" 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"><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" fill-rule="evenodd"/></svg>\n <span class="zammad-chat-welcome-text">' ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( this . invitationPhrase ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( '</span>\n </div>\n </div>\n <div class="zammad-chat-body"></div>\n <form class="zammad-chat-controls">\n <textarea class="zammad-chat-input" rows="1" placeholder="' ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( this . T ( 'Compose your message...' ) ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( '"></textarea>\n <button type="submit" class="zammad-chat-button zammad-chat-send">' ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( this . T ( 'Send' ) ) ;
_ _out . push ( '</button>\n </form>\n</div>' ) ;
2015-11-12 15:19:47 +00:00
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
2015-11-11 10:44:10 +00:00
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
2015-11-12 16:32:11 +00:00
window . zammadChatTemplates [ "loader" ] = function ( _ _obj ) {
2015-11-11 10:44:10 +00:00
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 ( ) {
2015-11-12 16:32:11 +00:00
_ _out . push ( '<div class="zammad-chat-modal">\n <span class="zammad-chat-loading-animation">\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n </span>\n <span class="zammad-chat-modal-text">' ) ;
2015-11-11 10:44:10 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( _ _sanitize ( this . T ( 'Connecting' ) ) ) ;
2015-11-11 10:44:10 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( '</span>\n</div>' ) ;
2015-11-02 15:48:16 +00:00
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
2015-11-12 16:32:11 +00:00
window . zammadChatTemplates [ "message" ] = function ( _ _obj ) {
2015-11-02 15:48:16 +00:00
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 ( ) {
2015-11-12 16:32:11 +00:00
_ _out . push ( '<div class="zammad-chat-message zammad-chat-message--' ) ;
2015-11-02 15:48:16 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( _ _sanitize ( this . from ) ) ;
_ _out . push ( '">\n <span class="zammad-chat-message-body">' ) ;
_ _out . push ( this . message ) ;
2015-11-02 15:48:16 +00:00
_ _out . push ( '</span>\n</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
2015-10-15 09:14:19 +00:00
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
2015-11-12 16:32:11 +00:00
window . zammadChatTemplates [ "status" ] = function ( _ _obj ) {
2015-10-15 09:14:19 +00:00
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 ( ) {
2015-11-12 16:32:11 +00:00
_ _out . push ( '<div class="zammad-chat-status">' ) ;
2015-10-15 09:14:19 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( this . status ) ;
2015-10-15 09:14:19 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( '</div>' ) ;
2015-10-15 09:14:19 +00:00
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
2015-11-12 16:32:11 +00:00
window . zammadChatTemplates [ "timeout" ] = function ( _ _obj ) {
2015-10-15 09:14:19 +00:00
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 ( ) {
2015-11-12 16:32:11 +00:00
_ _out . push ( '<div class="zammad-chat-modal">\n <div class="zammad-chat-modal-text">\n ' ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( this . T ( 'Since you didn\'t respond in the last %s your conversation with <strong>%s</strong> got closed.' , this . delay + " " + this . unit , this . agent ) ) ;
2015-11-12 15:19:47 +00:00
2015-11-12 16:32:11 +00:00
_ _out . push ( '<br>\n <div class="zammad-chat-button">' ) ;
_ _out . push ( _ _sanitize ( this . T ( 'Start new conversation' ) ) ) ;
_ _out . push ( '</div>\n </div>\n</div>' ) ;
2015-11-12 15:19:47 +00:00
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
window . zammadChatTemplates [ "timestamp" ] = 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-timestamp"><strong>' ) ;
2015-10-15 09:14:19 +00:00
2015-10-15 09:26:56 +00:00
_ _out . push ( _ _sanitize ( this . label ) ) ;
2015-10-15 09:14:19 +00:00
2015-11-11 09:37:34 +00:00
_ _out . push ( '</strong> ' ) ;
2015-10-15 09:14:19 +00:00
2015-10-15 09:26:56 +00:00
_ _out . push ( _ _sanitize ( this . time ) ) ;
2015-10-15 09:14:19 +00:00
_ _out . push ( '</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
if ( ! window . zammadChatTemplates ) {
window . zammadChatTemplates = { } ;
}
window . zammadChatTemplates [ "typingIndicator" ] = 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-message zammad-chat-message--typing zammad-chat-message--agent">\n <span class="zammad-chat-message-body">\n <span class="zammad-chat-loading-animation">\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n </span>\n </span>\n</div>' ) ;
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;
2015-11-02 15:48:16 +00:00
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 , '>' )
. replace ( /"/g , '"' ) ;
} ;
}
( function ( ) {
( function ( ) {
2015-11-11 20:44:54 +00:00
_ _out . push ( '<div class="zammad-chat-modal">\n <div class="zammad-chat-modal-text">\n <span class="zammad-chat-loading-animation">\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n <span class="zammad-chat-loading-circle"></span>\n </span>\n ' ) ;
_ _out . push ( this . T ( 'All colleges are busy.' ) ) ;
_ _out . push ( '<br>\n ' ) ;
2015-11-02 15:48:16 +00:00
2015-11-11 20:44:54 +00:00
_ _out . push ( this . T ( 'You are on waiting list position <strong>%s</strong>.' , this . position ) ) ;
2015-11-02 15:48:16 +00:00
2015-11-11 20:44:54 +00:00
_ _out . push ( '\n </div>\n</div>' ) ;
2015-11-02 15:48:16 +00:00
} ) . call ( this ) ;
} ) . call ( _ _obj ) ;
_ _obj . safe = _ _objSafe , _ _obj . escape = _ _escape ;
return _ _out . join ( '' ) ;
} ;