DOn't use deprecated (and slow) selectors

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

@ -59,7 +59,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
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() {
var opt = this, input = $('#enigma' + opt + 'opt');

@ -980,7 +980,7 @@ function sieve_form_init()
parent.rcmail.managesieve_dialog_resize(form);
}
$('input[type="text"]:first', form).focus();
$('input[type="text"]', form).first().focus();
// initialize smart list inputs
$('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,
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(),
w = win.width(), h = win.height();

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

@ -2967,7 +2967,7 @@ function rcube_webmail()
r.parent_uid = 0;
if (r.has_children) {
// replace 'leaf' with 'collapsed'
$('#'+r.id+' .leaf:first')
$('#' + r.id + ' .leaf').first()
.attr('id', 'rcmexpando' + r.id)
.attr('class', (r.obj.style.display != 'none' ? 'expanded' : 'collapsed'))
.mousedown({uid: r.uid}, function(e) {
@ -4327,7 +4327,7 @@ function rcube_webmail()
});
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'),
function() {
@ -5697,7 +5697,7 @@ function rcube_webmail()
if (this.import_dialog) {
this.import_state = 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
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());
if (input.is('div'))
input.find('input:first').focus();
input.find('input').first().focus();
else
input.first().focus();
@ -7424,10 +7424,10 @@ function rcube_webmail()
}
// set folder name
$('a:first', row).text(display_name).removeAttr('title');
$('a', row).first().text(display_name).removeAttr('title');
// 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});
// add to folder/row-ID map
@ -7517,7 +7517,7 @@ function rcube_webmail()
}
if (parent && n == parent) {
$('ul:first', parent).append(row);
$('ul', parent).first().append(row);
}
else {
while (p = $(n).parent().parent().get(0)) {
@ -7578,7 +7578,7 @@ function rcube_webmail()
old_folder = this.env.subscriptionrows[oldid],
prefix_len_id = oldid.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
if (oldid == id) {
@ -7593,7 +7593,7 @@ function rcube_webmail()
newid = id + fname.slice(prefix_len_id);
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);
subfolders[newid] = folder;
@ -7678,7 +7678,7 @@ function rcube_webmail()
{
var row = this.subscription_list.get_item(folder, true);
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)
@ -7686,7 +7686,7 @@ function rcube_webmail()
{
var row = this.subscription_list.get_item(folder, true);
if (row)
$('input[name="_subscribed[]"]:first', row).prop('checked', state);
$('input[name="_subscribed[]"]', row).first().prop('checked', state);
};
this.folder_size = function(folder)

@ -174,7 +174,7 @@ function rcube_text_editor(config, id)
if (rcmail.env.action == 'compose') {
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
// 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
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) {
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();
}
@ -720,7 +720,7 @@ function rcube_text_editor(config, id)
cancel.keydown(function(e) {
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();
}

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

@ -22,7 +22,7 @@
function rcube_init_settings_tabs()
{
var el, cl, container = $('#tabsbar'),
last_tab = $('span:last', container),
last_tab = $('span', container).last(),
tab = '#settingstabpreferences',
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)
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);
}
}
else if (!is_framed) {
title = $('.boxtitle:first', layout.content).detach().text();
title = $('.boxtitle', layout.content).first().detach().text();
if (!title) {
title = $('h1.voice:first').text();
title = $('h1.voice').first().text();
}
if (title) {
@ -861,7 +861,7 @@ function rcube_elastic_ui()
// Special input + anything entry
$('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
@ -946,7 +946,7 @@ function rcube_elastic_ui()
tab = $('<li>').addClass('nav-item').append(
$('<a>').addClass('nav-link' + (tab_class ? ' ' + tab_class : ''))
.attr({role: 'tab', 'href': '#' + id})
.text($('legend:first', fieldset).text())
.text($('legend', fieldset).first().text())
.click(function(e) {
$(this).tab('show');
// 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);
});
// create the navigation bar
nav.append(tabs).insertBefore(item);
// 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() {
@ -1015,7 +1015,7 @@ function rcube_elastic_ui()
// 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
// 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),
fn = function() {
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]) {
@ -2425,7 +2425,7 @@ function rcube_elastic_ui()
}
else if (p.event == 'menu-open') {
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;
if ($(target).is('span')) {
@ -3001,7 +3001,7 @@ function rcube_elastic_ui()
},
open: function() {
// 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() {
dialog.appendTo(parent);
@ -3132,7 +3132,7 @@ function rcube_elastic_ui()
keydown_func = function(e) {
// On Backspace remove the last recipient
if (e.keyCode == 8 && !input.val().length) {
list.children('li.recipient:last').remove();
list.children('li.recipient').first().remove();
apply_func();
return false;
}
@ -3519,7 +3519,7 @@ function rcube_elastic_ui()
// focus first active element on the list
if (rcube_event.is_keyboard(e)) {
list.find('a.active:first').focus();
list.find('a.active').first().focus();
}
// don't propagate mousedown event

Loading…
Cancel
Save