diff --git a/clientapp/app.js b/clientapp/app.js index 1543202..da07a5e 100644 --- a/clientapp/app.js +++ b/clientapp/app.js @@ -46,6 +46,7 @@ module.exports = { app.cache = new AppCache(); app.storage = new Storage(); app.storage.open(cb); + app.composing = {}; app.mucInfos = []; }, function (cb) { diff --git a/clientapp/pages/chat.js b/clientapp/pages/chat.js index e5a060a..86a69e4 100644 --- a/clientapp/pages/chat.js +++ b/clientapp/pages/chat.js @@ -52,6 +52,7 @@ module.exports = BasePage.extend({ show: function (animation) { BasePage.prototype.show.apply(this, [animation]); this.sendChatState('active'); + this.$chatInput.focus(); }, hide: function () { BasePage.prototype.hide.apply(this); @@ -66,6 +67,7 @@ module.exports = BasePage.extend({ this.renderAndBind(); this.$chatInput = this.$('.chatBox textarea'); + this.$chatInput.val(app.composing[this.model.jid] || ''); this.$chatBox = this.$('.chatBox'); this.$messageList = this.$('.messages'); @@ -105,6 +107,7 @@ module.exports = BasePage.extend({ }, handleKeyDown: function (e) { if (e.which === 13 && !e.shiftKey) { + app.composing[this.model.jid] = ''; this.sendChat(); e.preventDefault(); return false; @@ -130,6 +133,7 @@ module.exports = BasePage.extend({ }, handleKeyUp: function (e) { //this.resizeInput(); + app.composing[this.model.jid] = this.$chatInput.val(); if (this.typing && this.$chatInput.val().length === 0) { this.typing = false; this.$chatInput.removeClass('typing'); diff --git a/clientapp/pages/groupchat.js b/clientapp/pages/groupchat.js index 8c3248e..2faad15 100644 --- a/clientapp/pages/groupchat.js +++ b/clientapp/pages/groupchat.js @@ -48,6 +48,7 @@ module.exports = BasePage.extend({ to: this.model.jid, chatState: 'active' }); + this.$chatInput.focus(); }, hide: function () { BasePage.prototype.hide.apply(this); @@ -63,6 +64,7 @@ module.exports = BasePage.extend({ this.renderAndBind(); this.$chatInput = this.$('.chatBox textarea'); + this.$chatInput.val(app.composing[this.model.jid] || ''); this.$chatBox = this.$('.chatBox'); this.$messageList = this.$('.messages'); @@ -96,6 +98,7 @@ module.exports = BasePage.extend({ }, handleKeyDown: function (e) { if (e.which === 13 && !e.shiftKey) { + app.composing[this.model.jid] = ''; this.sendChat(); e.preventDefault(); return false; @@ -124,6 +127,7 @@ module.exports = BasePage.extend({ }, handleKeyUp: function (e) { //this.resizeInput(); + app.composing[this.model.jid] = this.$chatInput.val(); if (this.typing && this.$chatInput.val().length === 0) { this.typing = false; this.paused = false;