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

Reformatting

This commit is contained in:
Tim Düsterhus 2011-12-13 21:50:28 +01:00
parent b73ba2168c
commit e0a7943c1c

View File

@ -54,17 +54,16 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {};
}, this)); }, this));
$('#chatForm').submit($.proxy(function (event) { $('#chatForm').submit($.proxy(function (event) {
// check the input, if not empty send it. // break if input contains only whitespace
if ($('#chatInput').val().trim().length === 0) return false; if ($('#chatInput').val().trim().length === 0) return false;
event.preventDefault(); event.preventDefault();
textInput = $(event.target).find('#chatInput');
submitButton = $(event.target).find('input[type=image]'); submitButton = $(event.target).find('input[type=image]');
$.ajax('index.php/Chat/Send/', { $.ajax('index.php/Chat/Send/', {
dataType: 'json', dataType: 'json',
data: { ajax: 1, data: {
text: textInput.val() text: $('#chatInput').val()
}, },
type: 'POST', type: 'POST',
beforeSend: $.proxy(function (jqXHR) { beforeSend: $.proxy(function (jqXHR) {
@ -72,7 +71,7 @@ if (typeof TimWolla.WCF == 'undefined') TimWolla.WCF = {};
}), }),
success: $.proxy(function (data, textStatus, jqXHR) { success: $.proxy(function (data, textStatus, jqXHR) {
this.getMessages(); this.getMessages();
textInput.val('').focus(); $('#chatInput').val('').focus();
}, this), }, this),
error: function() { error: function() {
// TODO: find a nicer solution. // TODO: find a nicer solution.