From b8bc6427146980e45149b2a10967912203bf1d41 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Tue, 29 Apr 2014 22:04:52 +0200 Subject: [PATCH] Don't insert text if the allowed length would be exceeded --- file/js/be.bastelstu.Chat.litcoffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/file/js/be.bastelstu.Chat.litcoffee b/file/js/be.bastelstu.Chat.litcoffee index e11e9bc..a8c1fcd 100644 --- a/file/js/be.bastelstu.Chat.litcoffee +++ b/file/js/be.bastelstu.Chat.litcoffee @@ -767,9 +767,13 @@ the existing text. If `options.submit` is true the message will be sent to the s text = text + $('#timsChatInput').val() if options.prepend text = $('#timsChatInput').val() + text if options.append + # do not insert text if it would exceed the allowed length + maxLength = $('#timsChatInput').attr 'maxlength' + return if maxLength? and text.length > maxLength + $('#timsChatInput').val text $('#timsChatInput').trigger 'change' - + if options.submit do $('#timsChatForm').submit else