Elastic: Fix initial focus on recipients input in mail compose screen

Also remove some redundant duplicated code
pull/6957/head
Aleksander Machniak 5 years ago
parent 66fab8cdb2
commit a3c491d5cb

@ -3,6 +3,7 @@ CHANGELOG Roundcube Webmail
- Elastic: Resizeable columns (#6929)
- Elastic: Fix position and style of auto-complete dropdown on small screens (#6951)
- Elastic: Fix initial focus on recipients input in mail compose screen
- Redis: Improve error handling and phpredis 5.X support (#6888)
- Fix bug where cache keys were not case-sensitive on MySQL/MSSQL (#6942)
- Fix so an error is loogged when encryption fails (#6948)

@ -4578,22 +4578,14 @@ function rcube_webmail()
// init autocomplete events on compose form inputs
this.init_messageform_inputs = function(focused)
{
var i, ac_props,
var i,
input_to = $("[name='_to']"),
ac_fields = ['cc', 'bcc', 'replyto', 'followupto'];
// configure parallel autocompletion
if (this.env.autocomplete_threads > 0) {
ac_props = {
threads: this.env.autocomplete_threads,
sources: this.env.autocomplete_sources
};
}
// init live search events
this.init_address_input_events(input_to, ac_props);
this.init_address_input_events(input_to);
for (i in ac_fields) {
this.init_address_input_events($("[name='_"+ac_fields[i]+"']"), ac_props);
this.init_address_input_events($("[name='_"+ac_fields[i]+"']"));
}
if (!focused)
@ -4674,6 +4666,14 @@ function rcube_webmail()
this.init_address_input_events = function(obj, props)
{
// configure parallel autocompletion
if (!props && this.env.autocomplete_threads > 0) {
props = {
threads: this.env.autocomplete_threads,
sources: this.env.autocomplete_sources
};
}
obj.keydown(function(e) { return ref.ksearch_keydown(e, this, props); })
.attr({autocomplete: 'off', 'aria-autocomplete': 'list', 'aria-expanded': 'false', role: 'combobox'});

@ -703,8 +703,8 @@ function rcube_elastic_ui()
}
}
// In compose/preview window we do not provide "Back' button, instead
// we modify the Mail button in the task menu to act like it (i.e. calls 'list' command)
// In compose/preview window we do not provide "Back" button, instead
// we modify the "Mail" button in the task menu to act like it (i.e. calls 'list' command)
if (!rcmail.env.extwin && (rcmail.env.action == 'compose' || rcmail.env.action == 'show')) {
$('a.mail', layout.menu).attr('onclick', "return rcmail.command('list','',this,event)");
}
@ -737,6 +737,10 @@ function rcube_elastic_ui()
if (rcmail.env.devel_mode && window.less) {
less.pageLoadFinished.then(function() {
resize();
// Re-focus the focused input field on mail compose
if (rcmail.env.compose_focus_elem) {
$(rcmail.env.compose_focus_elem).focus();
}
});
}
else {
@ -3091,7 +3095,7 @@ function rcube_elastic_ui()
*/
function recipient_input(obj)
{
var list, input, ac_props,
var list, input,
input_len_update = function() {
input.css('width', Math.max(40, input.val().length * 15 + 25));
},
@ -3182,7 +3186,7 @@ function rcube_elastic_ui()
.on('blur', function() { list.removeClass('focus'); })
.on('focus mousedown', function() { list.addClass('focus'); });
list = $('<ul>').addClass('form-control recipient-input ac-input')
list = $('<ul>').addClass('form-control recipient-input ac-input rounded-left')
.append($('<li>').append(input))
.on('click', function() { input.focus(); });
@ -3196,27 +3200,16 @@ function rcube_elastic_ui()
// some core code sometimes focuses or changes the original node
// in such cases we wan't to parse it's value and apply changes
// to the widget element
.on('focus', function(e) { input.focus(); })
.on('change', function(e) {
.on('focus', function(e) { input.focus(); e.preventDefault(); })
.on('change', function() {
$('li.recipient', list).remove();
input.val(this.value).change();
})
// copy and parse the value already set
.change();
// this one line is here to fix border of Bootstrap's input-group,
// input-group should not contain any hidden elements
$(obj).detach().insertBefore(list.parent());
if (rcmail.env.autocomplete_threads > 0) {
ac_props = {
threads: rcmail.env.autocomplete_threads,
sources: rcmail.env.autocomplete_sources
};
}
// Init autocompletion
rcmail.init_address_input_events(input, ac_props);
rcmail.init_address_input_events(input);
};
/**

Loading…
Cancel
Save