Commit 15ed3e6e authored by Rebecca Blundell's avatar Rebecca Blundell Committed by Cecilia Vela Gurovic
Browse files

Bug 1843357: Remove deprecated jquery selectors

These are:
:first -> .first() or css first-child
:last -> .last() or css last-child
:eq -> .eq() or css nth-of-type(n)
:even -> css nth-child(odd) (odd because we're
  going from 0->1 based indexing)
And these which were not found in Mahara:
:odd
:gt
:lt

Change-Id: I512db61de687f9ea3d7a31b1514f4aa962bcb1b0
parent 851f592a
......@@ -336,12 +336,6 @@ var clearPasswords = (function($) {
jQuery('#accountprefs_password1').val('');
jQuery('#accountprefs_password2').val('');
}
if (data.username) {
var username = $('#profile-sideblock-username a:first');
if (username) {
$(username).empty().append(data.username);
}
}
}
}(jQuery))
......
......@@ -171,7 +171,7 @@ var installplugin = (function($) {
// move the whole thing into the list of installed plugins
// new parent node
var bits = name.split('\.');
$("ul[id='" + bits[0] + ".installed'] li:eq(0)").after($('[id="' + name + '"]'));
$("ul[id='" + bits[0] + ".installed'] li").eq(0).after($('[id="' + name + '"]'));
var oldlist = $("ul[id='" + bits[0] + ".notinstalled']").find('li:not(:has(h3))');
if (oldlist.length == 0) {
$("ul[id='" + bits[0] + ".notinstalled']").hide();
......
......@@ -159,7 +159,7 @@ EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('#fontlist').length) {
$('#fontlist a:first').trigger("focus");
$('#fontlist a').first().trigger("focus");
}
EOF;
}
......
......@@ -39,10 +39,11 @@ jQuery(function() {
{$pagination['javascript']}
showmatchall();
EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('#myviews')) {
$('#myviews a:first').trigger("focus");
$('#myviews a').first().trigger("focus");
}
EOF;
}
......
......@@ -226,7 +226,7 @@ jQuery(function ($) {
var filteroptid = filteropt.prop('id');
sendjsonrequest(config['wwwroot'] + 'json/stats_setting.php', {'setting':filteroptid}, 'POST', function(data) {
filteropt.parent().hide();
$('#statistics_table th a:first').trigger('click');
$('#statistics_table th a').first().trigger('click');
});
});
......
......@@ -1186,8 +1186,8 @@ EOF;
}
],
{
focusElement: 'a:first'
}
focusElement: 'a'
},
);
tableRenderers.{$compositetype}.type = '{$compositetype}';
......
......@@ -138,5 +138,5 @@ jQuery(function($) {
});
});
checkboxHelperDiv.insertBefore($(containers.views.container).find('div:first'));
checkboxHelperDiv.insertBefore($(containers.views.container).find('div').first());
});
......@@ -10,4 +10,9 @@ Installation:
Changes:
* None
replaced deprecated jquery selectors
:first -> .first()
These are not updated in the most recent version of fancybox
and there is an open issue (https://github.com/fancyapps/fancybox/issues/1346), which looks like they are at least intending to drop support for jquery, so it
seems like we may as well update these manually for now.
This diff is collapsed.
......@@ -6,9 +6,16 @@ This javascript library is required for the flexible page layout feature develop
Website: http://jqueryui.com/
Version: 1.12.1
Note that the last commit to this code was June 2017
Changes:
* Fixed deprecated .unique to .uniqueSort
* Fixed jquery 3.4.0 deprecations:
:first -> .first()
:last -> .last()
:even -> :nth-child(odd) - odd because css is 1-based; jquery is 0-based
Notes:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1147,11 +1147,11 @@ jQuery(function($) {
var parent = $(this);
if (!$(e.target).hasClass('child-nav collapse show')) {
$(this).find('ul li:first a').focus();
$(this).find('ul li').first().find('a').focus();
}
// Return focus to menu button from last submenu button
$($(this).find('button.navbar-showchildren:last')).on('blur', function() {
$($(this).find('button.navbar-showchildren').last()).on('blur', function() {
if ($(this).hasClass('collapsed')) {
var id = $(parent).attr('id');
$('button[aria-controls="' + id + '"]').focus();
......@@ -1159,8 +1159,8 @@ jQuery(function($) {
}
});
// Return focus to menu button from last element in menu when tabbing away
$(this).find('ul li:last a').on('blur', function() {
// Return focus to menu button from last element in last submenu when tabbing away
$(this).find('ul li').last().find('a').on('blur', function() {
var id = $(parent).attr('id');
$('button[aria-controls="' + id + '"]').focus();
$(parent).collapse('hide');
......
......@@ -155,7 +155,7 @@ return function(id, list, heading, script, extradata) {
var temp = $('<div>', {'id':'ie-workaround'});
if (container.tagName == 'TBODY') {
temp.html('<table><tbody>' + listdata + '</tbody></table>');
$(container).replaceWith(temp.find('table tbody:first'));
$(container).replaceWith(temp.find('table tbody').first());
}
else {
temp.html(listdata);
......
......@@ -113,7 +113,7 @@ return function (target, source, columns, options) {
self.tbody.append(tr);
if (options && row.id == options.focusid && self.options.focusElement) {
if (tr.find(self.options.focusElement).length) {
tr.find(self.options.focusElement).trigger("focus");
tr.find(self.options.focusElement).first().trigger("focus");
}
}
});
......
......@@ -137,7 +137,7 @@ function pieform_element_artefactchooser_views_js(Pieform $form, $element) {
}
$pagination_js .= <<<EOF
jQuery(function($) {
var ul = $('#{$form->get_name()}_{$element['name']}_container ul.artefactchooser-tabs:first');
var ul = $('#{$form->get_name()}_{$element['name']}_container ul.artefactchooser-tabs').first();
var doneBrowse = false;
var browseA = null;
var searchA = null;
......
......@@ -172,8 +172,9 @@ var Pieform = (function($) {
// Ensure the iframe exists and make sure the form targets it
// self.data.newIframes = true;
var iframeName = self.setupIframe();
$('#' + self.data.name)[0].target = iframeName;
if ($('#' + self.data.name).length) { // In case we close a modal as form is submitting
$('#' + self.data.name)[0].target = iframeName;
}
$('#' + self.data.name).append($('<input>', {
'type': 'hidden',
'name': 'pieform_jssubmission',
......
......@@ -90,7 +90,7 @@ jQuery(function($) {
if (confirm === null || confirm === true) {
// Rebuild the form so that data doesn't get added to existing
$("#copy option:eq(0)").prop('selected', true); // Reset copy
$("#copy option").eq(0).prop('selected', true); // Reset copy
editor.destroy();
refresh_editor();
var index = $('#edit').val();
......@@ -122,7 +122,7 @@ jQuery(function($) {
if (formchangemanager.checkDirtyChanges()) {
formchangemanager.confirmLeavingForm();
}
$("#edit option:eq(0)").prop('selected', true); // Reset edit
$("#edit option").eq(0).prop('selected', true); // Reset edit
editor.destroy();
refresh_editor();
edit = false;
......@@ -175,7 +175,7 @@ jQuery(function($) {
edit = true;
// Reset the "Copy" dropdown
$("#copy option:eq(0)").prop('selected', true);
$("#copy option").eq(0).prop('selected', true);
});
window.scrollTo(0,0);
});
......
......@@ -104,7 +104,7 @@ jQuery(function($) {
}
hide_dock();
//focus on matrix annotation
$('#tablematrix tr:eq(' + celly + ') td:eq(' + cellx + ') span.icon').find('a').trigger("focus");
$('#tablematrix tr').eq(celly).find('td').eq(cellx).find('span.icon a').trigger("focus");
}
});
cancelbutton = newpagemodal.find('.submitcancel.cancel');
......@@ -131,7 +131,7 @@ jQuery(function($) {
}
hide_dock();
//focus on matrix annotation
$('#tablematrix tr:eq(' + celly + ') td:eq(' + cellx + ') span.icon').find('a').trigger("focus");
$('#tablematrix tr').eq(celly).find('td').eq(cellx).find('span.icon a').trigger("focus");
}
});
if (hastinymce) {
......@@ -192,7 +192,7 @@ jQuery(function($) {
editmatrix_update(values);
hide_dock();
//focus on matrix annotation
$('#tablematrix tr:eq(' + celly + ') td:eq(' + cellx + ') span.icon').find('a').trigger("focus");
$('#tablematrix tr').eq(celly).find('td').eq(cellx).find('span.icon a').trigger("focus");
}
});
// When we are saving the annotation feedback form - changing the evidence status
......@@ -222,7 +222,7 @@ jQuery(function($) {
}
hide_dock();
//focus on matrix annotation
$('#tablematrix tr:eq(' + celly + ') td:eq(' + cellx + ') span.icon').find('a').trigger("focus");
$('#tablematrix tr').eq(celly).find('td').eq(cellx).find('span.icon a').trigger("focus");
}
else {
se.stopPropagation();
......@@ -292,26 +292,30 @@ jQuery(function($) {
hastinymce = true;
}
if (results.data.class) {
$('#tablematrix tr:eq(' + celly + ') td:eq(' + cellx + ') span.icon')
$('#tablematrix tr').eq(celly).find('td').eq(cellx).find('span.icon')
.attr('class', results.data.class)
.attr('title', results.data.title)
.data('option', results.data.option)
.data('view', results.data.view).empty();
if (results.data.readyforassessment) {
var readyforassessment = parseInt($('#tablematrix tr:eq(' + celly + ') td.completedcount.readyforassessment span:nth-child(2)').text(), 10);
$('#tablematrix tr:eq(' + celly + ') td.completedcount.readyforassessment span:nth-child(2)').text(readyforassessment + results.data.readyforassessment);
var readyforassessment = parseInt($('#tablematrix tr').eq(celly).find('td.completedcount.readyforassessment span:nth-child(2)').text(), 10);
$('#tablematrix tr').eq(celly).find('td.completedcount.readyforassessment span:nth-child(2)')
.text(readyforassessment + results.data.readyforassessment);
}
if (results.data.dontmatch) {
var dontmatch = parseInt($('#tablematrix tr:eq(' + celly + ') td.completedcount.dontmatch span:nth-child(2)').text(), 10);
$('#tablematrix tr:eq(' + celly + ') td.completedcount.dontmatch span:nth-child(2)').text(dontmatch + results.data.dontmatch);
var dontmatch = parseInt($('#tablematrix tr').eq(celly).find('td.completedcount.dontmatch span:nth-child(2)').text(), 10);
$('#tablematrix tr').eq(celly).find('td.completedcount.dontmatch span:nth-child(2)')
.text(dontmatch + results.data.dontmatch);
}
if (results.data.partiallycomplete) {
var partiallycomplete = parseInt($('#tablematrix tr:eq(' + celly + ') td.completedcount.partiallycomplete span:nth-child(2)').text(), 10);
$('#tablematrix tr:eq(' + celly + ') td.completedcount.partiallycomplete span:nth-child(2)').text(partiallycomplete + results.data.partiallycomplete);
var partiallycomplete = parseInt($('#tablematrix tr').eq(celly).find('td.completedcount.partiallycomplete span:nth-child(2)').text(), 10);
$('#tablematrix tr').eq(celly).find('td.completedcount.partiallycomplete span:nth-child(2)')
.text(partiallycomplete + results.data.partiallycomplete);
}
if (results.data.completed) {
var completed = parseInt($('#tablematrix tr:eq(' + celly + ') td.completedcount.completed span:nth-child(2)').text(), 10);
$('#tablematrix tr:eq(' + celly + ') td.completedcount.completed span:nth-child(2)').text(completed + results.data.completed);
var completed = parseInt($('#tablematrix tr').eq(celly).find('td.completedcount.completed span:nth-child(2)').text(), 10);
$('#tablematrix tr').eq(celly).find('td.completedcount.completed span:nth-child(2)')
.text(completed + results.data.completed);
}
}
......
......@@ -131,7 +131,7 @@ jQuery(function ($) {
.trigger("focus");
}
else {
$('#universalsearchresults a:first').trigger("focus");
$('#universalsearchresults a').first().trigger("focus");
}
});
}
......
......@@ -748,7 +748,6 @@ EOF;
/**
* Click a matrix point by being given a column,row pair
* NOTE: column and row start from number '0' so the first cell in a table is (0,0)
*
* @When I click on the matrix point :matrix_point
* @param string $matrix_point a column,row value
......@@ -771,7 +770,7 @@ EOF;
// For some reasons, the Mink function click() and check() do not work
// Using jQuery as a workaround
$jscode = "jQuery(\".tablematrix tr:eq('" . $point[1] . "') td:eq('" . $point[0] . "') span\").trigger('click');";
$jscode = "jQuery(\".tablematrix tr:nth-of-type(" . $point[1] . ") td:nth-of-type(" . $point[0] . ") span\").trigger('click');";
$this->getSession()->executeScript($jscode);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment