Commit 3b850c77 authored by JC Brand's avatar JC Brand

Move `focus` method into ChatBoxMessageForm

parent 7ee0b194
...@@ -319,6 +319,15 @@ ...@@ -319,6 +319,15 @@
}); });
}, },
focus () {
const textarea_el = this.el.querySelector('.chat-textarea');
if (!_.isNull(textarea_el)) {
textarea_el.focus();
_converse.emit('chatBoxFocused', this.parent);
}
return this;
},
toggleEditSpoilerMessage () { toggleEditSpoilerMessage () {
const { __ } = _converse, const { __ } = _converse,
text_area = this.el.querySelector('.chat-textarea'), text_area = this.el.querySelector('.chat-textarea'),
...@@ -335,7 +344,7 @@ ...@@ -335,7 +344,7 @@
this.model.toJSON(), {'title': spoiler_title}) this.model.toJSON(), {'title': spoiler_title})
) )
this.render(); this.render();
this.parent.focus(); this.focus();
} }
}); });
...@@ -663,7 +672,6 @@ ...@@ -663,7 +672,6 @@
messageContent.textContent = ""; messageContent.textContent = "";
messageContent.append(document.createElement("br")); messageContent.append(document.createElement("br"));
messageContent.append(container); messageContent.append(container);
return msg;
}, },
renderMessage (attrs) { renderMessage (attrs) {
...@@ -712,11 +720,11 @@ ...@@ -712,11 +720,11 @@
msg_content.innerHTML = u.addEmoji( msg_content.innerHTML = u.addEmoji(
_converse, emojione, u.addHyperlinks(xss.filterXSS(text, {'whiteList': {}})) _converse, emojione, u.addHyperlinks(xss.filterXSS(text, {'whiteList': {}}))
); );
u.renderImageURLs(msg_content).then(this.scrollDown.bind(this));
if (attrs.is_spoiler) { if (attrs.is_spoiler) {
return this.renderSpoilerMessage(msg, attrs) this.renderSpoilerMessage(msg, attrs)
} }
u.renderImageURLs(msg_content).then(this.scrollDown.bind(this));
return msg; return msg;
}, },
...@@ -1106,12 +1114,7 @@ ...@@ -1106,12 +1114,7 @@
}, },
focus () { focus () {
const textarea_el = this.el.querySelector('.chat-textarea'); this.message_form_view.focus();
if (!_.isNull(textarea_el)) {
textarea_el.focus();
_converse.emit('chatBoxFocused', this);
}
return this;
}, },
hide () { hide () {
......
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