New configuration setting: auto_focus

This commit is contained in:
JC Brand 2019-06-18 14:04:26 +02:00
parent 536b42697c
commit b2553a44e1
4 changed files with 28 additions and 4 deletions

View File

@ -18,6 +18,7 @@
- Message deduplication bugfixes and improvements
- Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure
- Replace `moment` with [DayJS](https://github.com/iamkun/dayjs).
- New config option [auto_focus](https://conversejs.org/docs/html/configuration.html#auto-focus).
- New config option [enable_smacks](https://conversejs.org/docs/html/configuration.html#enable-smacks).
- New config option [muc_show_join_leave_status](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave-status)
- New config option [message_limit](https://conversejs.org/docs/html/configuration.html#message-limit)

View File

@ -231,6 +231,20 @@ autocomplete_add_contact
Determines whether search suggestions are shown in the "Add Contact" modal.
auto_focus
----------
* Default: ``true``
If set to ``true``, the textarea for composing chat messages will automatically
become focused as soon as a chat is opened. This means you don't need to click
the textarea first before starting to type a message.
For applications where chat is not the main feature, automatic focus of the
chat box might be undesired.
auto_list_rooms
---------------

View File

@ -56,6 +56,7 @@ converse.plugins.add('converse-chatview', {
{ __ } = _converse;
_converse.api.settings.update({
'auto_focus': true,
'emoji_image_path': twemoji.default.base,
'message_limit': 0,
'show_send_button': false,
@ -1290,13 +1291,17 @@ converse.plugins.add('converse-chatview', {
this.model.clearUnreadMsgCounter();
this.setChatState(_converse.ACTIVE);
this.scrollDown();
this.focus();
if (_converse.auto_focus) {
this.focus();
}
},
_show () {
/* Inner show method that gets debounced */
if (u.isVisible(this.el)) {
this.focus();
if (_converse.auto_focus) {
this.focus();
}
return;
}
u.fadeIn(this.el, _.bind(this.afterShown, this));

View File

@ -684,7 +684,9 @@ converse.plugins.add('converse-muc-views', {
show () {
if (u.isVisible(this.el)) {
this.focus();
if (_converse.auto_focus) {
this.focus();
}
return;
}
// Override from converse-chatview in order to not use
@ -704,7 +706,9 @@ converse.plugins.add('converse-muc-views', {
} else if (conn_status === converse.ROOMSTATUS.ENTERED) {
this.hideSpinner();
this.setChatState(_converse.ACTIVE);
this.focus();
if (_converse.auto_focus) {
this.focus();
}
} else if (conn_status === converse.ROOMSTATUS.DISCONNECTED) {
this.showDisconnectMessage();
} else if (conn_status === converse.ROOMSTATUS.DESTROYED) {