Commit 2d08916c authored by JC Brand's avatar JC Brand

Remove the keyPressed method from ChatRoomView and reuse the one on ChatBoxView

parent 337a3c2b
...@@ -425,10 +425,16 @@ ...@@ -425,10 +425,16 @@
message = $textarea.val(); message = $textarea.val();
$textarea.val('').focus(); $textarea.val('').focus();
if (message !== '') { if (message !== '') {
this.sendMessage(message); if (this.model.get('chatroom')) {
this.sendChatRoomMessage(message);
} else {
this.sendMessage(message);
}
} }
this.$el.data('composing', false); this.$el.data('composing', false);
} else {
} else if (!this.model.get('chatroom')) {
// composing data is only for single user chat
composing = this.$el.data('composing'); composing = this.$el.data('composing');
if (!composing) { if (!composing) {
if (ev.keyCode != 47) { if (ev.keyCode != 47) {
...@@ -814,20 +820,6 @@ ...@@ -814,20 +820,6 @@
this.remove(); this.remove();
}, },
keyPressed: function (ev) {
var $textarea = $(ev.target),
message;
if (ev.keyCode == 13) {
ev.preventDefault();
message = $textarea.val();
message = message.replace(/^\s+|\s+jQuery/g,"");
$textarea.val('').focus();
if (message !== '') {
this.sendChatRoomMessage(message);
}
}
},
sendChatRoomMessage: function (body) { sendChatRoomMessage: function (body) {
this.appendMessage(body); this.appendMessage(body);
var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false], var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment