From fc16da5acdde16dadb52e118b90fcb344fbc6605 Mon Sep 17 00:00:00 2001 From: max-m Date: Mon, 19 Dec 2011 13:58:40 +0100 Subject: [PATCH] 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 --- file/js/TimWolla.WCF.Chat.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/file/js/TimWolla.WCF.Chat.js b/file/js/TimWolla.WCF.Chat.js index 114492c..51ca812 100644 --- a/file/js/TimWolla.WCF.Chat.js +++ b/file/js/TimWolla.WCF.Chat.js @@ -160,8 +160,13 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; if (options.append) { text = $('#chatInput').val() + text; + if(text.length > this.config.maxTextLength) { + $('#chatInput').focus(); + return; + } } $('#chatInput').val(text); + $('#chatInput').trigger('keyup'); if (options.submit) $('#chatForm').submit(); else $('#chatInput').focus(); @@ -207,7 +212,7 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; success: $.proxy(function (data, textStatus, jqXHR) { this.getMessages(); $('#chatInput').val('').focus(); - $('#chatForm .counter').text(this.config.maxTextLength); + $('#chatInput').trigger('keyup'); }, this), complete: function() { $('#chatInput').removeClass('ajaxLoad');