DOn't use deprecated (and slow) selectors

pull/6724/head
Aleksander Machniak 6 years ago
parent 0c419e4dd1
commit f0811f6f50

@ -59,7 +59,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
e.stopPropagation(); e.stopPropagation();
}); });
$('a.button.enigma').prop('tabindex', $('#messagetoolbar > a:first').prop('tabindex')); $('a.button.enigma').prop('tabindex', $('#messagetoolbar > a').first().prop('tabindex'));
$.each(['encrypt', 'sign'], function() { $.each(['encrypt', 'sign'], function() {
var opt = this, input = $('#enigma' + opt + 'opt'); var opt = this, input = $('#enigma' + opt + 'opt');

@ -980,7 +980,7 @@ function sieve_form_init()
parent.rcmail.managesieve_dialog_resize(form); parent.rcmail.managesieve_dialog_resize(form);
} }
$('input[type="text"]:first', form).focus(); $('input[type="text"]', form).first().focus();
// initialize smart list inputs // initialize smart list inputs
$('textarea[data-type="list"]', form).each(function() { $('textarea[data-type="list"]', form).each(function() {
@ -1189,7 +1189,7 @@ rcube_webmail.prototype.managesieve_dialog_resize = function(o)
{ {
var dialog = this.env.managesieve_dialog, var dialog = this.env.managesieve_dialog,
win = $(window), form = $(o); win = $(window), form = $(o);
width = $('fieldset:first', o).width(), // fieldset width is more appropriate here width = $('fieldset', o).first().width(), // fieldset width is more appropriate here
height = form.height(), height = form.height(),
w = win.width(), h = win.height(); w = win.width(), h = win.height();

@ -58,5 +58,5 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
} }
}, true); }, true);
$('input:not(:hidden):first').focus(); $('input:not(:hidden)').first().focus();
}); });

@ -2967,7 +2967,7 @@ function rcube_webmail()
r.parent_uid = 0; r.parent_uid = 0;
if (r.has_children) { if (r.has_children) {
// replace 'leaf' with 'collapsed' // replace 'leaf' with 'collapsed'
$('#'+r.id+' .leaf:first') $('#' + r.id + ' .leaf').first()
.attr('id', 'rcmexpando' + r.id) .attr('id', 'rcmexpando' + r.id)
.attr('class', (r.obj.style.display != 'none' ? 'expanded' : 'collapsed')) .attr('class', (r.obj.style.display != 'none' ? 'expanded' : 'collapsed'))
.mousedown({uid: r.uid}, function(e) { .mousedown({uid: r.uid}, function(e) {
@ -4327,7 +4327,7 @@ function rcube_webmail()
}); });
content = $('<ul class="proplist">').append(nodes); content = $('<ul class="proplist">').append(nodes);
$('input:not([disabled]):first', content).attr('checked', true); $('input:not([disabled])', content).first().attr('checked', true);
this.simple_dialog(content, this.get_label('markallread'), this.simple_dialog(content, this.get_label('markallread'),
function() { function() {
@ -5697,7 +5697,7 @@ function rcube_webmail()
if (this.import_dialog) { if (this.import_dialog) {
this.import_state = state; this.import_state = state;
// activate Import button depending on state // activate Import button depending on state
$(this.import_dialog).parent().find('.ui-dialog-buttonset > button:first').attr('disabled', state != 'error'); $(this.import_dialog).parent().find('.ui-dialog-buttonset > button').first().attr('disabled', state != 'error');
} }
}; };
@ -5985,7 +5985,7 @@ function rcube_webmail()
// select the first // select the first
if (!this.env.contacts.length) { if (!this.env.contacts.length) {
this.ksearch_select($('li:first', ul).get(0)); this.ksearch_select($('li', ul)[0]);
} }
} }
@ -6925,7 +6925,7 @@ function rcube_webmail()
row.appendTo(appendcontainer.show()); row.appendTo(appendcontainer.show());
if (input.is('div')) if (input.is('div'))
input.find('input:first').focus(); input.find('input').first().focus();
else else
input.first().focus(); input.first().focus();
@ -7424,10 +7424,10 @@ function rcube_webmail()
} }
// set folder name // set folder name
$('a:first', row).text(display_name).removeAttr('title'); $('a', row).first().text(display_name).removeAttr('title');
// update subscription checkbox // update subscription checkbox
$('input[name="_subscribed[]"]:first', row).val(id) $('input[name="_subscribed[]"]', row).first().val(id)
.prop({checked: subscribed ? true : false, disabled: is_protected ? true : false}); .prop({checked: subscribed ? true : false, disabled: is_protected ? true : false});
// add to folder/row-ID map // add to folder/row-ID map
@ -7517,7 +7517,7 @@ function rcube_webmail()
} }
if (parent && n == parent) { if (parent && n == parent) {
$('ul:first', parent).append(row); $('ul', parent).first().append(row);
} }
else { else {
while (p = $(n).parent().parent().get(0)) { while (p = $(n).parent().parent().get(0)) {
@ -7578,7 +7578,7 @@ function rcube_webmail()
old_folder = this.env.subscriptionrows[oldid], old_folder = this.env.subscriptionrows[oldid],
prefix_len_id = oldid.length, prefix_len_id = oldid.length,
prefix_len_name = old_folder[0].length, prefix_len_name = old_folder[0].length,
subscribed = $('input[name="_subscribed[]"]:first', row).prop('checked'); subscribed = $('input[name="_subscribed[]"]', row).first().prop('checked');
// no renaming, only update class_name // no renaming, only update class_name
if (oldid == id) { if (oldid == id) {
@ -7593,7 +7593,7 @@ function rcube_webmail()
newid = id + fname.slice(prefix_len_id); newid = id + fname.slice(prefix_len_id);
this.id = 'rcmli' + ref.html_identifier_encode(newid); this.id = 'rcmli' + ref.html_identifier_encode(newid);
$('input[name="_subscribed[]"]:first', this).val(newid); $('input[name="_subscribed[]"]', this).first().val(newid);
folder[0] = name + folder[0].slice(prefix_len_name); folder[0] = name + folder[0].slice(prefix_len_name);
subfolders[newid] = folder; subfolders[newid] = folder;
@ -7678,7 +7678,7 @@ function rcube_webmail()
{ {
var row = this.subscription_list.get_item(folder, true); var row = this.subscription_list.get_item(folder, true);
if (row) if (row)
$('input[name="_subscribed[]"]:first', row).prop('disabled', true); $('input[name="_subscribed[]"]', row).first().prop('disabled', true);
}; };
// resets state of subscription checkbox (e.g. on error) // resets state of subscription checkbox (e.g. on error)
@ -7686,7 +7686,7 @@ function rcube_webmail()
{ {
var row = this.subscription_list.get_item(folder, true); var row = this.subscription_list.get_item(folder, true);
if (row) if (row)
$('input[name="_subscribed[]"]:first', row).prop('checked', state); $('input[name="_subscribed[]"]', row).first().prop('checked', state);
}; };
this.folder_size = function(folder) this.folder_size = function(folder)

@ -174,7 +174,7 @@ function rcube_text_editor(config, id)
if (rcmail.env.action == 'compose') { if (rcmail.env.action == 'compose') {
var area = $('#' + this.id), var area = $('#' + this.id),
height = $('div.mce-toolbar-grp:first', area.parent()).height(); height = $('div.mce-toolbar-grp', area.parent()).first().height();
// the editor might be still not fully loaded, making the editing area // the editor might be still not fully loaded, making the editing area
// inaccessible, wait and try again (#1490310) // inaccessible, wait and try again (#1490310)
@ -686,7 +686,7 @@ function rcube_text_editor(config, id)
} }
} }
cancel = dialog.parent().parent().find('button:last').parent(); cancel = dialog.parent().parent().find('button').last().parent();
// Add custom Tab key handlers, tabindex does not work // Add custom Tab key handlers, tabindex does not work
list = $('#image-selector-list').append(list).on('keydown', 'li', function(e) { list = $('#image-selector-list').append(list).on('keydown', 'li', function(e) {
@ -706,7 +706,7 @@ function rcube_text_editor(config, id)
button.keydown(function(e) { button.keydown(function(e) {
if (e.which == 9) { // Tab if (e.which == 9) { // Tab
if (rcube_event.get_modifier(e) == SHIFT_KEY || !list.find('li:first').focus().length) { if (rcube_event.get_modifier(e) == SHIFT_KEY || !list.find('li').first().focus().length) {
cancel.focus(); cancel.focus();
} }
@ -720,7 +720,7 @@ function rcube_text_editor(config, id)
cancel.keydown(function(e) { cancel.keydown(function(e) {
if (e.which == 9) { if (e.which == 9) {
if (rcube_event.get_modifier(e) != SHIFT_KEY || !list.find('li:last').focus().length) { if (rcube_event.get_modifier(e) != SHIFT_KEY || !list.find('li').last().focus().length) {
button.focus(); button.focus();
} }

@ -757,7 +757,7 @@ function rcube_treelist_widget(node, p)
// allow virtual nodes to receive focus // allow virtual nodes to receive focus
if (node.virtual) { if (node.virtual) {
li.children('a:first').attr('tabindex', '0'); li.children('a').first().attr('tabindex', '0');
} }
result.push(node); result.push(node);
@ -899,19 +899,19 @@ function rcube_treelist_widget(node, p)
next = li[mod](), limit, parent; next = li[mod](), limit, parent;
if (dir > 0 && !from_child && li.children('ul[role=group]:visible').length) { if (dir > 0 && !from_child && li.children('ul[role=group]:visible').length) {
li.children('ul').children('li:first').find('a:first').focus(); li.children('ul').children('li').first().find('a').first().focus();
} }
else if (dir < 0 && !from_child && next.children('ul[role=group]:visible').length) { else if (dir < 0 && !from_child && next.children('ul[role=group]:visible').length) {
next.children('ul').children('li:last').find('a:first').focus(); next.children('ul').children('li').last().find('a').first().focus();
} }
else if (next.length && next.find('a:first').focus().length) { else if (next.length && next.find('a').first().focus().length) {
// focused // focused
} }
else { else {
parent = li.parent().closest('li[role=treeitem]'); parent = li.parent().closest('li[role=treeitem]');
if (parent.length) if (parent.length)
if (dir < 0) { if (dir < 0) {
parent.find('a:first').focus(); parent.find('a').first().focus();
} }
else { else {
focus_next(parent, dir, true); focus_next(parent, dir, true);
@ -937,7 +937,7 @@ function rcube_treelist_widget(node, p)
{ {
var node, child; var node, child;
if (selection && (node = id2dom(selection))) { if (selection && (node = id2dom(selection))) {
child = node.children('ul').children('li:first'); child = node.children('ul').children('li').first();
if (child.length) { if (child.length) {
return dom2id(child); return dom2id(child);
} }
@ -961,7 +961,7 @@ function rcube_treelist_widget(node, p)
var node, prev, child; var node, prev, child;
if (selection && (node = id2dom(selection))) { if (selection && (node = id2dom(selection))) {
prev = node.prev(); prev = node.prev();
child = prev.find('li:last'); child = prev.find('li').last();
if (child.length) { if (child.length) {
return dom2id(child); return dom2id(child);

@ -22,7 +22,7 @@
function rcube_init_settings_tabs() function rcube_init_settings_tabs()
{ {
var el, cl, container = $('#tabsbar'), var el, cl, container = $('#tabsbar'),
last_tab = $('span:last', container), last_tab = $('span', container).last(),
tab = '#settingstabpreferences', tab = '#settingstabpreferences',
action = window.rcmail && rcmail.env.action ? rcmail.env.action : null; action = window.rcmail && rcmail.env.action ? rcmail.env.action : null;

@ -147,15 +147,15 @@ function rcube_elastic_ui()
// Set content frame title in parent window (exclude ext-windows and dialog frames) // Set content frame title in parent window (exclude ext-windows and dialog frames)
if (is_framed && !rcmail.env.extwin && !parent.$('.ui-dialog:visible').length) { if (is_framed && !rcmail.env.extwin && !parent.$('.ui-dialog:visible').length) {
if (title = $('h1.voice:first').text()) { if (title = $('h1.voice').first().text()) {
parent.$('#layout > .content > .header > .header-title:not(.constant)').text(title); parent.$('#layout > .content > .header > .header-title:not(.constant)').text(title);
} }
} }
else if (!is_framed) { else if (!is_framed) {
title = $('.boxtitle:first', layout.content).detach().text(); title = $('.boxtitle', layout.content).first().detach().text();
if (!title) { if (!title) {
title = $('h1.voice:first').text(); title = $('h1.voice').first().text();
} }
if (title) { if (title) {
@ -861,7 +861,7 @@ function rcube_elastic_ui()
// Special input + anything entry // Special input + anything entry
$('td.input-group', context).each(function() { $('td.input-group', context).each(function() {
$(this).children(':not(:first)').addClass('input-group-append'); $(this).children().slice(1).addClass('input-group-append');
}); });
// Other forms, e.g. Contact advanced search // Other forms, e.g. Contact advanced search
@ -946,7 +946,7 @@ function rcube_elastic_ui()
tab = $('<li>').addClass('nav-item').append( tab = $('<li>').addClass('nav-item').append(
$('<a>').addClass('nav-link' + (tab_class ? ' ' + tab_class : '')) $('<a>').addClass('nav-link' + (tab_class ? ' ' + tab_class : ''))
.attr({role: 'tab', 'href': '#' + id}) .attr({role: 'tab', 'href': '#' + id})
.text($('legend:first', fieldset).text()) .text($('legend', fieldset).first().text())
.click(function(e) { .click(function(e) {
$(this).tab('show'); $(this).tab('show');
// Because we return false we have to close popups // Because we return false we have to close popups
@ -957,14 +957,14 @@ function rcube_elastic_ui()
}) })
); );
$('legend:first', fieldset).hide(); $('legend', fieldset).first().hide();
tabs.push(tab); tabs.push(tab);
}); });
// create the navigation bar // create the navigation bar
nav.append(tabs).insertBefore(item); nav.append(tabs).insertBefore(item);
// activate the first tab // activate the first tab
$('a.nav-link:first', nav).click(); $('a.nav-link', nav).first().click();
}); });
$('input[type=file]:not(.custom-file-input)', context).each(function() { $('input[type=file]:not(.custom-file-input)', context).each(function() {
@ -1015,7 +1015,7 @@ function rcube_elastic_ui()
// Input-group combo is an element with a select field on the left // Input-group combo is an element with a select field on the left
// and input(s) on right, and where the whole right side can be hidden // and input(s) on right, and where the whole right side can be hidden
// depending on the select position. This code fixes border radius on select // depending on the select position. This code fixes border radius on select
$('.input-group-combo > select:first', context).on('change', function() { $('.input-group-combo > select', context).first().on('change', function() {
var select = $(this), var select = $(this),
fn = function() { fn = function() {
select[select.next().is(':visible') ? 'removeClass' : 'addClass']('alone'); select[select.next().is(':visible') ? 'removeClass' : 'addClass']('alone');
@ -2297,7 +2297,7 @@ function rcube_elastic_ui()
} }
}); });
popover.find('a.active:first').focus(); popover.find('a.active').first().focus();
} }
if (popup_id && menus[popup_id]) { if (popup_id && menus[popup_id]) {
@ -2425,7 +2425,7 @@ function rcube_elastic_ui()
} }
else if (p.event == 'menu-open') { else if (p.event == 'menu-open') {
var fn, pos, var fn, pos,
content = $('ul:first', p.obj), content = $('ul', p.obj).first(),
target = p.props && p.props.link ? p.props.link : p.originalEvent.target; target = p.props && p.props.link ? p.props.link : p.originalEvent.target;
if ($(target).is('span')) { if ($(target).is('span')) {
@ -3001,7 +3001,7 @@ function rcube_elastic_ui()
}, },
open: function() { open: function() {
// Don't want focus in the search field, we focus first contacts source record instead // Don't want focus in the search field, we focus first contacts source record instead
$('#directorylist a:first').focus(); $('#directorylist a').first().focus();
}, },
close: function() { close: function() {
dialog.appendTo(parent); dialog.appendTo(parent);
@ -3132,7 +3132,7 @@ function rcube_elastic_ui()
keydown_func = function(e) { keydown_func = function(e) {
// On Backspace remove the last recipient // On Backspace remove the last recipient
if (e.keyCode == 8 && !input.val().length) { if (e.keyCode == 8 && !input.val().length) {
list.children('li.recipient:last').remove(); list.children('li.recipient').first().remove();
apply_func(); apply_func();
return false; return false;
} }
@ -3519,7 +3519,7 @@ function rcube_elastic_ui()
// focus first active element on the list // focus first active element on the list
if (rcube_event.is_keyboard(e)) { if (rcube_event.is_keyboard(e)) {
list.find('a.active:first').focus(); list.find('a.active').first().focus();
} }
// don't propagate mousedown event // don't propagate mousedown event

Loading…
Cancel
Save