From c7d867905f5100306cc8d3a2cd3ac4b69fcb40ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 12 Dec 2011 16:16:24 +0100 Subject: [PATCH] Adding options-object for insertText --- file/js/TimWolla.WCF.Chat.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.js b/file/js/TimWolla.WCF.Chat.js index 50e9dab..6d4de46 100644 --- a/file/js/TimWolla.WCF.Chat.js +++ b/file/js/TimWolla.WCF.Chat.js @@ -114,10 +114,18 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {}; } $('.chatMessageContainer').animate({scrollTop: $('.chatMessageContainer ul').height()}, 10000); }, - insertText: function (text) { - // TODO: Add options here - var input = $('#chatInput'); - input.val(input.val() + ' ' + text + ' '); + insertText: function (text, options) { + options = $.extend({ + append: true, + submit: false + }, options || {}); + + if (options.append) { + text = $('#chatInput').val() + text; + } + $('#chatInput').val(text); + + if (options.submit) $('#chatForm').submit(); }, toggleUserMenu: function (target) { liUserID = '#' + target.parent().parent().attr('id');