diff options
author | Aleksander Machniak <alec@alec.pl> | 2019-10-07 17:11:41 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2019-10-07 17:12:06 +0300 |
commit | a3c491d5cb2d8ec64bdc5cb6eb67960e7ec563c0 (patch) | |
tree | 41d10397496c923d824889b89b127c4bdcb0df27 /skins | |
parent | 66fab8cdb2b7160a34ed7d8074c7e8f413f21e91 (diff) |
Elastic: Fix initial focus on recipients input in mail compose screen
Also remove some redundant duplicated code
Diffstat (limited to 'skins')
-rw-r--r-- | skins/elastic/ui.js | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js index 199073fb8..f8d71ed33 100644 --- a/skins/elastic/ui.js +++ b/skins/elastic/ui.js @@ -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); }; /** |