1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Trigger chatInput keyup event on submit and insertText

Also check if appended text would be longer than allowed maximum, if so return and focus chatInput
This commit is contained in:
max-m 2011-12-19 13:58:40 +01:00
parent bc01d0380e
commit fc16da5acd

View File

@ -160,8 +160,13 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {};
if (options.append) { if (options.append) {
text = $('#chatInput').val() + text; text = $('#chatInput').val() + text;
if(text.length > this.config.maxTextLength) {
$('#chatInput').focus();
return;
}
} }
$('#chatInput').val(text); $('#chatInput').val(text);
$('#chatInput').trigger('keyup');
if (options.submit) $('#chatForm').submit(); if (options.submit) $('#chatForm').submit();
else $('#chatInput').focus(); else $('#chatInput').focus();
@ -207,7 +212,7 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {};
success: $.proxy(function (data, textStatus, jqXHR) { success: $.proxy(function (data, textStatus, jqXHR) {
this.getMessages(); this.getMessages();
$('#chatInput').val('').focus(); $('#chatInput').val('').focus();
$('#chatForm .counter').text(this.config.maxTextLength); $('#chatInput').trigger('keyup');
}, this), }, this),
complete: function() { complete: function() {
$('#chatInput').removeClass('ajaxLoad'); $('#chatInput').removeClass('ajaxLoad');