Skip to content
Permalink
Browse files

Replace deprecated jQuery methods

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
mauriciofauth committed Jan 14, 2020
1 parent c5481ac commit e6bfc68649533baf60b0a52bd289279680c59b69
@@ -34,9 +34,7 @@
"new-cap": "error",
"no-array-constructor": "error",
"no-eval": "error",
"no-jquery/no-event-shorthand": "off",
"no-jquery/no-is-array": "off",
"no-jquery/no-sizzle": "off",
"no-jquery/no-sizzle": "warn",
"no-loop-func": "error",
"no-multiple-empty-lines": "error",
"no-new-func": "error",
@@ -935,7 +935,7 @@ $(document).on('submit', 'form', AJAX.requestHandler);
* Gracefully handle fatal server errors
* (e.g: 500 - Internal server error)
*/
$(document).ajaxError(function (event, request) {
$(document).on('ajaxError', function (event, request) {
if (AJAX.debug) {
// eslint-disable-next-line no-console
console.log('AJAX error: status=' + request.status + ', text=' + request.statusText);
@@ -770,7 +770,7 @@ AJAX.registerOnload('config.js', function () {
disabled = true;
}
$form.find('input[type=submit]').prop('disabled', disabled);
}).submit(function (e) {
}).on('submit', function (e) {
var $form = $(this);
if ($form.attr('name') === 'prefs_export' && $('#export_local_storage')[0].checked) {
e.preventDefault();
@@ -170,7 +170,7 @@ var Console = {
ConsoleMessages.showInstructions(Console.config.EnterExecutes);
});

$(document).ajaxComplete(function (event, xhr, ajaxOptions) {
$(document).on('ajaxComplete', function (event, xhr, ajaxOptions) {
if (ajaxOptions.dataType && ajaxOptions.dataType.indexOf('json') !== -1) {
return;
}
@@ -1117,7 +1117,7 @@ var ConsoleDebug = {
},
initialize: function () {
// Try to get debug info after every AJAX request
$(document).ajaxSuccess(function (event, xhr, settings, data) {
$(document).on('ajaxSuccess', function (event, xhr, settings, data) {
if (data.debug) {
ConsoleDebug.showLog(data.debug, settings.url);
}
@@ -69,7 +69,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
AJAX.source = $(this);
$.post('index.php?route=/database/central-columns', editColumnData, AJAX.responseHandler);
});
$('#multi_edit_central_columns').submit(function (event) {
$('#multi_edit_central_columns').on('submit', function (event) {
event.preventDefault();
event.stopPropagation();
var argsep = CommonParams.get('arg_separator');
@@ -209,7 +209,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
});
}
});
$('#add_column').submit(function (e) {
$('#add_column').on('submit', function (e) {
var selectvalue = $('#column-select').val();
if (selectvalue === '') {
e.preventDefault();
@@ -225,7 +225,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
$addColDivLinkSpan.html('+');
}
});
$('#add_new').submit(function () {
$('#add_new').on('submit', function () {
$('#add_new').toggle();
});
$('#tableslistcontainer').find('select.default_type').on('change', function () {
@@ -31,7 +31,7 @@ AJAX.registerOnload('database/qbe.js', function () {

$('#tblQbe').width($('#tblQbe').parent().width());
$('#tblQbeFooters').width($('#tblQbeFooters').parent().width());
$('#tblQbe').resize(function () {
$('#tblQbe').on('resize', function () {
var newWidthTblQbe = $('#textSqlquery').next().width();
$('#tblQbe').width(newWidthTblQbe);
$('#tblQbeFooters').width(newWidthTblQbe);
@@ -552,13 +552,13 @@ DesignerMove.addTableToTablesList = function (index, tableDom) {
' designer_url_table_name="' + dbEncoded + '.' + tableEncoded + '">' + $('<div/>').text(db + '.' + table).html() + '</td>' +
'</tr>');
$('#id_scroll_tab table').first().append($newTableLine);
$($newTableLine).find('.scroll_tab_struct').click(function () {
$($newTableLine).find('.scroll_tab_struct').on('click', function () {
DesignerMove.startTabUpd(db, table);
});
$($newTableLine).on('click', '.designer_Tabs2,.designer_Tabs', function () {
DesignerMove.selectTab($(this).attr('designer_url_table_name'));
});
$($newTableLine).find('.scroll_tab_checkbox').click(function () {
$($newTableLine).find('.scroll_tab_checkbox').on('click', function () {
DesignerMove.visibleTab(this,$(this).val());
});
var $tablesCounter = $('#tables_counter');
@@ -682,7 +682,7 @@ DesignerMove.save = function (url) {
document.getElementById('t_h_' + key + '_').value = document.getElementById('check_vis_' + key).checked ? 1 : 0;
}
document.getElementById('container-form').action = url;
$('#container-form').submit();
$('#container-form').trigger('submit');
};

DesignerMove.getUrlPos = function (forceString) {
@@ -2016,16 +2016,16 @@ DesignerMove.enableTableEvents = function (index, element) {
DesignerMove.clickField(params[3], params[0], params[1], params[2]);
});

$(element).find('.tab_zag_noquery').mouseover(function () {
$(element).find('.tab_zag_noquery').on('mouseover', function () {
DesignerMove.tableOnOver($(this).attr('table_name'),0, $(this).attr('query_set'));
});
$(element).find('.tab_zag_noquery').mouseout(function () {
$(element).find('.tab_zag_noquery').on('mouseout', function () {
DesignerMove.tableOnOver($(this).attr('table_name'),1, $(this).attr('query_set'));
});
$(element).find('.tab_zag_query').mouseover(function () {
$(element).find('.tab_zag_query').on('mouseover', function () {
DesignerMove.tableOnOver($(this).attr('table_name'),0, 1);
});
$(element).find('.tab_zag_query').mouseout(function () {
$(element).find('.tab_zag_query').on('mouseout', function () {
DesignerMove.tableOnOver($(this).attr('table_name'),1, 1);
});

@@ -2161,7 +2161,7 @@ AJAX.registerOnload('designer/move.js', function () {
DesignerMove.sideMenuRight(this);
return false;
});
$('#side_menu').hover(function () {
$('#side_menu').on('hover', function () {
DesignerMove.showText();
return false;
}, function () {
@@ -2187,7 +2187,7 @@ AJAX.registerOnload('designer/move.js', function () {
$('.designer_tab').each(DesignerMove.enableTableEvents);
$('.designer_tab').each(DesignerMove.addTableToTablesList);

$('input#del_button').click(function () {
$('input#del_button').on('click', function () {
DesignerMove.updRelation();
});
$('input#cancel_button').on('click', function () {
@@ -311,7 +311,7 @@ AJAX.registerOnload('export.js', function () {
});

// When MS Excel is selected as the Format automatically Switch to Character Set as windows-1252
$('#plugins').change(function () {
$('#plugins').on('change', function () {
var selectedPluginName = $('#plugins').find('option:selected').val();
if (selectedPluginName === 'excel') {
$('#select_charset').val('windows-1252');
@@ -431,7 +431,7 @@ Functions.sprintf = function () {
*/
Functions.hideShowDefaultValue = function ($defaultType) {
if ($defaultType.val() === 'USER_DEFINED') {
$defaultType.siblings('.default_value').show().focus();
$defaultType.siblings('.default_value').show().trigger('focus');
} else {
$defaultType.siblings('.default_value').hide();
if ($defaultType.val() === 'NULL') {
@@ -956,7 +956,7 @@ Functions.checkTableEditForm = function (theForm, fieldsCnt) {
var $input = $('input.textfield[name=\'table\']');
if ($input.val() === '') {
alert(Messages.strFormEmpty);
$input.focus();
$input.trigger('focus');
return false;
}

@@ -3051,7 +3051,7 @@ AJAX.registerOnload('functions.js', function () {
if ($form.is('.create_table_form.ajax')) {
submitChangesInCreateTableForm('submit_partition_change=1');
} else {
$form.submit();
$form.trigger('submit');
}
});

@@ -3145,7 +3145,7 @@ AJAX.registerOnload('functions.js', function () {
$('#pma_username').val('').prop('required', false);
$('#user_exists_warning').css('display', 'none');
} else if (this.value === 'userdefined') {
$('#pma_username').trigger('focus').select().prop('required', true);
$('#pma_username').trigger('focus').trigger('select').prop('required', true);
}
});

@@ -3162,7 +3162,7 @@ AJAX.registerOnload('functions.js', function () {
$('#text_pma_pw').prop('required', false).val('');
} else if (this.value === 'userdefined') {
$('#text_pma_pw2').prop('required', true);
$('#text_pma_pw').prop('required', true).trigger('focus').select();
$('#text_pma_pw').prop('required', true).trigger('focus').trigger('select');
} else {
$('#text_pma_pw2').prop('required', false);
$('#text_pma_pw').prop('required', false);
@@ -4158,7 +4158,7 @@ AJAX.registerOnload('functions.js', function () {
// Check where to load the new content
if ($(this).closest('#pma_navigation').length === 0) {
// For the main page we don't need to do anything,
$(this).closest('form').submit();
$(this).closest('form').trigger('submit');
} else {
// but for the navigation we need to manually replace the content
Navigation.treePagination($(this));
@@ -4781,7 +4781,7 @@ AJAX.registerOnload('functions.js', function () {
/* Trigger filtering of the list based on incoming database name */
var $filter = $('#filterText');
if ($filter.val()) {
$filter.trigger('keyup').select();
$filter.trigger('keyup').trigger('select');
}
});

@@ -4895,7 +4895,7 @@ Functions.ignorePhpErrors = function (clearPrevErrors) {
if (clearPrevious) {
var $pmaReportErrorsForm = $('#pma_report_errors_form');
$pmaReportErrorsForm.find('input[name="send_error_report"]').val(0); // change send_error_report to '0'
$pmaReportErrorsForm.submit();
$pmaReportErrorsForm.trigger('submit');
}

// remove displayed errors
@@ -1696,7 +1696,7 @@ Navigation.showFullName = function ($containerELem) {
var $fullNameLayer = $('#full_name_layer');
if ($fullNameLayer.length === 0) {
$('body').append('<div id="full_name_layer" class="hide"></div>');
$('#full_name_layer').mouseleave(function () {
$('#full_name_layer').on('mouseleave', function () {
/** mouseleave */
$(this).addClass('hide')
.removeClass('hovering');
@@ -102,7 +102,7 @@ function ajaxValidate (parent, id, values) {
} else {
for (var key in response) {
var value = response[key];
error[key] = jQuery.isArray(value) ? value : [value];
error[key] = Array.isArray(value) ? value : [value];
}
}
displayErrors(error);
@@ -360,7 +360,7 @@ AJAX.registerOnload('table/chart.js', function () {
});

// handler for ajax form submission
$('#tblchartform').submit(function () {
$('#tblchartform').on('submit', function () {
var $form = $(this);
if (codeMirrorEditor) {
$form[0].elements.sql_query.value = codeMirrorEditor.getValue();
@@ -27,7 +27,7 @@ AJAX.registerOnload('table/find_replace.js', function () {
return false;
});

$('#find_replace_form').submit(function (e) {
$('#find_replace_form').on('submit', function (e) {
e.preventDefault();
var findReplaceForm = $('#find_replace_form');
Functions.prepareForAjaxRequest(findReplaceForm);

0 comments on commit e6bfc68

Please sign in to comment.
You can’t perform that action at this time.