Merge pull request #97 from nforro/master
Fix handling newlines in messages
This commit is contained in:
commit
a692904516
@ -78,6 +78,8 @@ class MessagingInterface {
|
|||||||
|
|
||||||
this.inputChangeUserName.addEventListener('keydown', this.handleUsernameKeydown.bind(this));
|
this.inputChangeUserName.addEventListener('keydown', this.handleUsernameKeydown.bind(this));
|
||||||
this.formMessageInput.addEventListener('keydown', this.handleMessageInputKeydown.bind(this));
|
this.formMessageInput.addEventListener('keydown', this.handleMessageInputKeydown.bind(this));
|
||||||
|
this.formMessageInput.addEventListener('keyup', this.handleMessageInputKeyup.bind(this));
|
||||||
|
this.formMessageInput.addEventListener('blur', this.handleMessageInputBlur.bind(this));
|
||||||
this.btnSubmitMessage.addEventListener('click', this.handleSubmitChatButton.bind(this));
|
this.btnSubmitMessage.addEventListener('click', this.handleSubmitChatButton.bind(this));
|
||||||
|
|
||||||
this.initLocalStates();
|
this.initLocalStates();
|
||||||
@ -199,12 +201,10 @@ class MessagingInterface {
|
|||||||
if (!this.prepNewLine) {
|
if (!this.prepNewLine) {
|
||||||
this.submitChat(value);
|
this.submitChat(value);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
this.prepNewLine = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.prepNewLine = false;
|
|
||||||
} else {
|
|
||||||
this.prepNewLine = false;
|
|
||||||
}
|
}
|
||||||
if (event.keyCode === 16 || event.keyCode === 17) { // ctrl, shift
|
if (event.keyCode === 16 || event.keyCode === 17) { // ctrl, shift
|
||||||
this.prepNewLine = true;
|
this.prepNewLine = true;
|
||||||
@ -221,6 +221,16 @@ class MessagingInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMessageInputKeyup(event) {
|
||||||
|
if (event.keyCode === 16 || event.keyCode === 17) { // ctrl, shift
|
||||||
|
this.prepNewLine = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMessageInputBlur(event) {
|
||||||
|
this.prepNewLine = false;
|
||||||
|
}
|
||||||
|
|
||||||
handleSubmitChatButton(event) {
|
handleSubmitChatButton(event) {
|
||||||
var value = this.formMessageInput.value.trim();
|
var value = this.formMessageInput.value.trim();
|
||||||
if (value) {
|
if (value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user