Moved to contenteditable for chat widget.
This commit is contained in:
parent
7cb212832e
commit
10dca43432
4 changed files with 74 additions and 74 deletions
|
@ -471,7 +471,7 @@ do($ = window.jQuery, window) ->
|
||||||
from: if message.created_by_id then 'agent' else 'customer'
|
from: if message.created_by_id then 'agent' else 'customer'
|
||||||
|
|
||||||
if unfinishedMessage
|
if unfinishedMessage
|
||||||
@input.val unfinishedMessage
|
@input.html(unfinishedMessage)
|
||||||
|
|
||||||
# show wait list
|
# show wait list
|
||||||
if data.position
|
if data.position
|
||||||
|
@ -489,7 +489,7 @@ do($ = window.jQuery, window) ->
|
||||||
@el.find('.zammad-chat-message--unread')
|
@el.find('.zammad-chat-message--unread')
|
||||||
.removeClass 'zammad-chat-message--unread'
|
.removeClass 'zammad-chat-message--unread'
|
||||||
|
|
||||||
sessionStorage.setItem 'unfinished_message', @input.val()
|
sessionStorage.setItem 'unfinished_message', @input.html()
|
||||||
|
|
||||||
@onTyping()
|
@onTyping()
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ do($ = window.jQuery, window) ->
|
||||||
@sendMessage()
|
@sendMessage()
|
||||||
|
|
||||||
sendMessage: ->
|
sendMessage: ->
|
||||||
message = @input.val()
|
message = @input.html()
|
||||||
return if !message
|
return if !message
|
||||||
|
|
||||||
@inactiveTimeout.start()
|
@inactiveTimeout.start()
|
||||||
|
@ -543,7 +543,7 @@ do($ = window.jQuery, window) ->
|
||||||
@lastAddedType = 'message--customer'
|
@lastAddedType = 'message--customer'
|
||||||
@el.find('.zammad-chat-body').append messageElement
|
@el.find('.zammad-chat-body').append messageElement
|
||||||
|
|
||||||
@input.val('')
|
@input.html('')
|
||||||
@scrollToBottom()
|
@scrollToBottom()
|
||||||
|
|
||||||
# send message event
|
# send message event
|
||||||
|
|
|
@ -1,3 +1,64 @@
|
||||||
|
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('');
|
||||||
|
};
|
||||||
|
|
||||||
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; },
|
||||||
|
@ -699,7 +760,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (unfinishedMessage) {
|
if (unfinishedMessage) {
|
||||||
this.input.val(unfinishedMessage);
|
this.input.html(unfinishedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.position) {
|
if (data.position) {
|
||||||
|
@ -715,7 +776,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
||||||
|
|
||||||
ZammadChat.prototype.onInput = function() {
|
ZammadChat.prototype.onInput = function() {
|
||||||
this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread');
|
this.el.find('.zammad-chat-message--unread').removeClass('zammad-chat-message--unread');
|
||||||
sessionStorage.setItem('unfinished_message', this.input.val());
|
sessionStorage.setItem('unfinished_message', this.input.html());
|
||||||
return this.onTyping();
|
return this.onTyping();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -749,7 +810,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
||||||
|
|
||||||
ZammadChat.prototype.sendMessage = function() {
|
ZammadChat.prototype.sendMessage = function() {
|
||||||
var message, messageElement;
|
var message, messageElement;
|
||||||
message = this.input.val();
|
message = this.input.html();
|
||||||
if (!message) {
|
if (!message) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -769,7 +830,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
|
||||||
this.lastAddedType = 'message--customer';
|
this.lastAddedType = 'message--customer';
|
||||||
this.el.find('.zammad-chat-body').append(messageElement);
|
this.el.find('.zammad-chat-body').append(messageElement);
|
||||||
}
|
}
|
||||||
this.input.val('');
|
this.input.html('');
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
return this.send('chat_session_message', {
|
return this.send('chat_session_message', {
|
||||||
content: message,
|
content: message,
|
||||||
|
@ -1334,67 +1395,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('');
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||||
|
@ -1555,11 +1555,11 @@ window.zammadChatTemplates["chat"] = function (__obj) {
|
||||||
|
|
||||||
__out.push(this.T(this.scrollHint));
|
__out.push(this.T(this.scrollHint));
|
||||||
|
|
||||||
__out.push('\n </div>\n <div class="zammad-chat-body"></div>\n <form class="zammad-chat-controls">\n <textarea class="zammad-chat-input" rows="1" placeholder="');
|
__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(this.T('Compose your message...'));
|
||||||
|
|
||||||
__out.push('"></textarea>\n <button type="submit" class="zammad-chat-button zammad-chat-send"');
|
__out.push('" contenteditable="true"></div>\n <button type="submit" class="zammad-chat-button zammad-chat-send"');
|
||||||
|
|
||||||
if (this.background) {
|
if (this.background) {
|
||||||
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
__out.push(__sanitize(" style='background: " + this.background + "'"));
|
||||||
|
|
4
public/assets/chat/chat.min.js
vendored
4
public/assets/chat/chat.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="zammad-chat-body"></div>
|
<div class="zammad-chat-body"></div>
|
||||||
<form class="zammad-chat-controls">
|
<form class="zammad-chat-controls">
|
||||||
<textarea class="zammad-chat-input" rows="1" placeholder="<%- @T('Compose your message...') %>"></textarea>
|
<div class="zammad-chat-input" rows="1" placeholder="<%- @T('Compose your message...') %>" contenteditable="true"></div>
|
||||||
<button type="submit" class="zammad-chat-button zammad-chat-send"<%= " style='background: #{ @background }'" if @background %>><%- @T('Send') %></button>
|
<button type="submit" class="zammad-chat-button zammad-chat-send"<%= " style='background: #{ @background }'" if @background %>><%- @T('Send') %></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue