diff options
author | MaurĂcio Meneghini Fauth <mauricio@fauth.dev> | 2022-06-22 01:45:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-22 01:45:42 +0300 |
commit | 3b99d77d5e281081bc793568f00dc75ba34f8562 (patch) | |
tree | bc693f324823c17b548cfc864c29ce5751078d61 | |
parent | da7c7a84e194f4f964bd65fea5f7a0931caae033 (diff) | |
parent | 9ff5655f6e212cef6f006487f158244410c309fb (diff) |
Merge pull request #17614 from MauricioFauth/js-ajax-global
Assign `AJAX` to the `window` global object
65 files changed, 296 insertions, 297 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index 434ea753cb..ef2476ca38 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,7 +15,6 @@ "jquery": true }, "globals": { - "AJAX": "readonly", "bootstrap": "readonly", "CodeMirror": "readonly", "CommonActions": "readonly", diff --git a/js/src/ajax.js b/js/src/ajax.js index f939cce3b5..aad74855eb 100644 --- a/js/src/ajax.js +++ b/js/src/ajax.js @@ -4,7 +4,7 @@ * * @test-module AJAX */ -var AJAX = { +window.AJAX = { /** * @var {boolean} active Whether we are busy */ @@ -70,7 +70,7 @@ var AJAX = { * @return {self} For chaining */ registerOnload: function (file, func) { - var eventName = 'onload_' + AJAX.hash(file); + var eventName = 'onload_' + window.AJAX.hash(file); $(document).on(eventName, func); if (this.debug) { // eslint-disable-next-line no-console @@ -92,7 +92,7 @@ var AJAX = { * @return {self} For chaining */ registerTeardown: function (file, func) { - var eventName = 'teardown_' + AJAX.hash(file); + var eventName = 'teardown_' + window.AJAX.hash(file); $(document).on(eventName, func); if (this.debug) { // eslint-disable-next-line no-console @@ -112,7 +112,7 @@ var AJAX = { * @return {void} */ fireOnload: function (file) { - var eventName = 'onload_' + AJAX.hash(file); + var eventName = 'onload_' + window.AJAX.hash(file); $(document).trigger(eventName); if (this.debug) { // eslint-disable-next-line no-console @@ -131,7 +131,7 @@ var AJAX = { * @return {void} */ fireTeardown: function (file) { - var eventName = 'teardown_' + AJAX.hash(file); + var eventName = 'teardown_' + window.AJAX.hash(file); $(document).triggerHandler(eventName); if (this.debug) { // eslint-disable-next-line no-console @@ -179,22 +179,22 @@ var AJAX = { * in textarea, it returns only the change in content. */ if (event.data.value === 1) { - newHash = AJAX.hash($(this).val()); + newHash = window.AJAX.hash($(this).val()); } else { - newHash = AJAX.hash($(this).is(':checked')); + newHash = window.AJAX.hash($(this).is(':checked')); } oldHash = $(this).data('val-hash'); } // Set lock if old value !== new value // otherwise release lock if (oldHash !== newHash) { - AJAX.lockedTargets[lockId] = true; + window.AJAX.lockedTargets[lockId] = true; } else { - delete AJAX.lockedTargets[lockId]; + delete window.AJAX.lockedTargets[lockId]; } // Show lock icon if locked targets is not empty. // otherwise remove lock icon - if (!jQuery.isEmptyObject(AJAX.lockedTargets)) { + if (!jQuery.isEmptyObject(window.AJAX.lockedTargets)) { $('#lock_page_icon').html(Functions.getImage('s_lock', Messages.strLockToolTip).toString()); } else { $('#lock_page_icon').html(''); @@ -206,7 +206,7 @@ var AJAX = { * @return {void} */ resetLock: function () { - AJAX.lockedTargets = {}; + window.AJAX.lockedTargets = {}; $('#lock_page_icon').html(''); }, handleMenu: { @@ -236,7 +236,7 @@ var AJAX = { return true; } else if ($(this).hasClass('ajax') || $(this).hasClass('disableAjax')) { // reset the lockedTargets object, as specified AJAX operation has finished - AJAX.resetLock(); + window.AJAX.resetLock(); return true; } else if (href && href.match(/^#/)) { return true; @@ -259,27 +259,27 @@ var AJAX = { // the click event is not triggered by script if (typeof event !== 'undefined' && event.type === 'click' && event.isTrigger !== true && - !jQuery.isEmptyObject(AJAX.lockedTargets) && + !jQuery.isEmptyObject(window.AJAX.lockedTargets) && confirm(Messages.strConfirmNavigation) === false ) { return false; } - AJAX.resetLock(); + window.AJAX.resetLock(); var isLink = !! href || false; var previousLinkAborted = false; - if (AJAX.active === true) { + if (window.AJAX.active === true) { // Cancel the old request if abortable, when the user requests // something else. Otherwise silently bail out, as there is already // a request well in progress. - if (AJAX.xhr) { + if (window.AJAX.xhr) { // In case of a link request, attempt aborting - AJAX.xhr.abort(); - if (AJAX.xhr.status === 0 && AJAX.xhr.statusText === 'abort') { + window.AJAX.xhr.abort(); + if (window.AJAX.xhr.status === 0 && window.AJAX.xhr.statusText === 'abort') { // If aborted - AJAX.$msgbox = Functions.ajaxShowMessage(Messages.strAbortedRequest); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.$msgbox = Functions.ajaxShowMessage(Messages.strAbortedRequest); + window.AJAX.active = false; + window.AJAX.xhr = null; previousLinkAborted = true; } else { // If can't abort @@ -291,14 +291,14 @@ var AJAX = { } } - AJAX.source = $(this); + window.AJAX.source = $(this); $('html, body').animate({ scrollTop: 0 }, 'fast'); var url = isLink ? href : $(this).attr('action'); var argsep = CommonParams.get('arg_separator'); var params = 'ajax_request=true' + argsep + 'ajax_page_request=true'; - var dataPost = AJAX.source.getPostData(); + var dataPost = window.AJAX.source.getPostData(); if (! isLink) { params += argsep + $(this).serialize(); } else if (dataPost) { @@ -306,16 +306,16 @@ var AJAX = { isLink = false; } - if (AJAX.debug) { + if (window.AJAX.debug) { // eslint-disable-next-line no-console console.log('Loading: ' + url); // no need to translate } if (isLink) { - AJAX.active = true; - AJAX.$msgbox = Functions.ajaxShowMessage(); + window.AJAX.active = true; + window.AJAX.$msgbox = Functions.ajaxShowMessage(); // Save reference for the new link request - AJAX.xhr = $.get(url, params, AJAX.responseHandler); + window.AJAX.xhr = $.get(url, params, window.AJAX.responseHandler); var state = { url : href }; @@ -336,12 +336,12 @@ var AJAX = { // Submit the request if there is no onsubmit handler // or if it returns a value that evaluates to true if (typeof onsubmit !== 'function' || onsubmit.apply(this, [event])) { - AJAX.active = true; - AJAX.$msgbox = Functions.ajaxShowMessage(); + window.AJAX.active = true; + window.AJAX.$msgbox = Functions.ajaxShowMessage(); if ($(this).attr('id') === 'login_form') { - $.post(url, params, AJAX.loginResponseHandler); + $.post(url, params, window.AJAX.loginResponseHandler); } else { - $.post(url, params, AJAX.responseHandler); + $.post(url, params, window.AJAX.responseHandler); } } } @@ -349,7 +349,7 @@ var AJAX = { /** * Response handler to handle login request from login modal after session expiration * - * To refer to self use 'AJAX', instead of 'this' as this function + * To refer to self use 'window.AJAX', instead of 'this' as this function * is called in the jQuery context. * * @param {object} data Event data @@ -360,11 +360,11 @@ var AJAX = { if (typeof data === 'undefined' || data === null) { return; } - Functions.ajaxRemoveMessage(AJAX.$msgbox); + Functions.ajaxRemoveMessage(window.AJAX.$msgbox); CommonParams.set('token', data.new_token); - AJAX.scriptHandler.load([]); + window.AJAX.scriptHandler.load([]); if (data.displayMessage) { $('#page_content').prepend(data.displayMessage); @@ -420,8 +420,8 @@ var AJAX = { if (CommonParams.get('user') !== data.params.user) { window.location = 'index.php'; Functions.ajaxShowMessage(Messages.strLoading, false); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; return; } // remove the login modal if the login is successful otherwise show error. @@ -430,8 +430,8 @@ var AJAX = { $('#modalOverlay').remove(); } $('fieldset.disabled_for_expiration').removeAttr('disabled').removeClass('disabled_for_expiration'); - AJAX.fireTeardown('functions.js'); - AJAX.fireOnload('functions.js'); + window.AJAX.fireTeardown('functions.js'); + window.AJAX.fireOnload('functions.js'); } if (typeof data.new_token !== 'undefined') { $('input[name=token]').val(data.new_token); @@ -440,8 +440,8 @@ var AJAX = { $('#modalOverlay').replaceWith(data.error); } else { Functions.ajaxShowMessage(data.error, false); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; Functions.handleRedirectAndReload(data); if (data.fieldWithError) { $(':input.error').removeClass('error'); @@ -455,7 +455,7 @@ var AJAX = { * failed requests or requests with uncaught errors, see the .ajaxError * handler at the bottom of this file. * - * To refer to self use 'AJAX', instead of 'this' as this function + * To refer to self use 'window.AJAX', instead of 'this' as this function * is called in the jQuery context. * * @param {object} data Event data @@ -468,24 +468,24 @@ var AJAX = { } // Can be a string when an error occurred and only HTML was returned. if (typeof data === 'string') { - Functions.ajaxRemoveMessage(AJAX.$msgbox); + Functions.ajaxRemoveMessage(window.AJAX.$msgbox); Functions.ajaxShowMessage($(data).text(), false, 'error'); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; return; } if (typeof data.success !== 'undefined' && data.success) { $('html, body').animate({ scrollTop: 0 }, 'fast'); - Functions.ajaxRemoveMessage(AJAX.$msgbox); + Functions.ajaxRemoveMessage(window.AJAX.$msgbox); if (data.redirect) { Functions.ajaxShowMessage(data.redirect, false); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; return; } - AJAX.scriptHandler.reset(function () { + window.AJAX.scriptHandler.reset(function () { if (data.reloadNavigation) { Navigation.reload(); } @@ -498,7 +498,7 @@ var AJAX = { menu : data.menu }; history.replaceState(state, null); - AJAX.handleMenu.replace(data.menu); + window.AJAX.handleMenu.replace(data.menu); } if (data.disableNaviSettings) { Navigation.disableSettings(); @@ -547,7 +547,7 @@ var AJAX = { CommonParams.setAll(data.params); } if (data.scripts) { - AJAX.scriptHandler.load(data.scripts); + window.AJAX.scriptHandler.load(data.scripts); } if (data.displayMessage) { $('#page_content').prepend(data.displayMessage); @@ -597,21 +597,21 @@ var AJAX = { Functions.ignorePhpErrors(false); }); - if (typeof AJAX.callback === 'function') { - AJAX.callback.call(); + if (typeof window.AJAX.callback === 'function') { + window.AJAX.callback.call(); } - AJAX.callback = function () {}; + window.AJAX.callback = function () {}; }); } else { Functions.ajaxShowMessage(data.error, false); - Functions.ajaxRemoveMessage(AJAX.$msgbox); + Functions.ajaxRemoveMessage(window.AJAX.$msgbox); var $ajaxError = $('<div></div>'); $ajaxError.attr({ 'id': 'ajaxError' }); $('#page_content').append($ajaxError); $ajaxError.html(data.error); $('html, body').animate({ scrollTop: $(document).height() }, 200); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; Functions.handleRedirectAndReload(data); if (data.fieldWithError) { $(':input.error').removeClass('error'); @@ -717,7 +717,7 @@ var AJAX = { */ done: function (script, callback) { if ($.inArray(script, this.scriptsToBeFired)) { - AJAX.fireOnload(script); + window.AJAX.fireOnload(script); } if ($.inArray(script, this.scriptsToBeLoaded)) { this.scriptsToBeLoaded.splice($.inArray(script, this.scriptsToBeLoaded), 1); @@ -726,9 +726,9 @@ var AJAX = { this.scriptsCompleted = true; } /* We need to wait for last signal (with null) or last script load */ - AJAX.active = (this.scriptsToBeLoaded.length > 0) || ! this.scriptsCompleted; + window.AJAX.active = (this.scriptsToBeLoaded.length > 0) || ! this.scriptsCompleted; /* Run callback on last script */ - if (! AJAX.active && typeof callback === 'function') { + if (! window.AJAX.active && typeof callback === 'function') { callback(); } }, @@ -764,15 +764,15 @@ var AJAX = { */ reset: function (callback) { for (var i in this.scriptsToBeFired) { - AJAX.fireTeardown(this.scriptsToBeFired[i]); + window.AJAX.fireTeardown(this.scriptsToBeFired[i]); } this.scriptsToBeFired = []; /** * Re-attach a generic event handler to clicks * on pages and submissions of forms */ - $(document).off('click', 'a').on('click', 'a', AJAX.requestHandler); - $(document).off('submit', 'form').on('submit', 'form', AJAX.requestHandler); + $(document).off('click', 'a').on('click', 'a', window.AJAX.requestHandler); + $(document).off('submit', 'form').on('submit', 'form', window.AJAX.requestHandler); callback(); } } @@ -782,11 +782,11 @@ var AJAX = { * Here we register a function that will remove the onsubmit event from all * forms that will be handled by the generic page loader. We then save this * event handler in the "jQuery data", so that we can fire it up later in - * AJAX.requestHandler(). + * window.AJAX.requestHandler(). * * See bug #3583316 */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { // Registering the onload event for functions.js // ensures that it will be fired for all pages $('form').not('.ajax').not('.disableAjax').each(function () { @@ -823,14 +823,14 @@ AJAX.registerOnload('functions.js', function () { 'form.lock-page input[type="number"], ' + 'form.lock-page select', { value:1 }, - AJAX.lockPageHandler + window.AJAX.lockPageHandler ); $pageContent.on( 'change', 'form.lock-page input[type="checkbox"], ' + 'form.lock-page input[type="radio"]', { value:2 }, - AJAX.lockPageHandler + window.AJAX.lockPageHandler ); /** * Reset lock when lock-page form reset event is fired @@ -838,7 +838,7 @@ AJAX.registerOnload('functions.js', function () { * form directly. */ $('form.lock-page').on('reset', function () { - AJAX.resetLock(); + window.AJAX.resetLock(); }); }); @@ -869,15 +869,15 @@ $(function () { } var state = event.originalEvent.state; if (state && state.menu) { - AJAX.$msgbox = Functions.ajaxShowMessage(); + window.AJAX.$msgbox = Functions.ajaxShowMessage(); var params = 'ajax_request=true' + CommonParams.get('arg_separator') + 'ajax_page_request=true'; var url = state.url || location.href; - $.get(url, params, AJAX.responseHandler); + $.get(url, params, window.AJAX.responseHandler); // TODO: Check if sometimes menu is not retrieved from server, // Not sure but it seems menu was missing only for printview which // been removed lately, so if it's right some dead menu checks/fallbacks // may need to be removed from this file and Header.php - // AJAX.handleMenu.replace(event.originalEvent.state.menu); + // window.AJAX.handleMenu.replace(event.originalEvent.state.menu); } }); }); @@ -886,15 +886,15 @@ $(function () { * Attach a generic event handler to clicks * on pages and submissions of forms */ -$(document).on('click', 'a', AJAX.requestHandler); -$(document).on('submit', 'form', AJAX.requestHandler); +$(document).on('click', 'a', window.AJAX.requestHandler); +$(document).on('submit', 'form', window.AJAX.requestHandler); /** * Gracefully handle fatal server errors * (e.g: 500 - Internal server error) */ $(document).on('ajaxError', function (event, request) { - if (AJAX.debug) { + if (window.AJAX.debug) { // eslint-disable-next-line no-console console.log('AJAX error: status=' + request.status + ', text=' + request.statusText); } @@ -914,8 +914,8 @@ $(document).on('ajaxError', function (event, request) { '</div>', false ); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; return; } @@ -934,7 +934,7 @@ $(document).on('ajaxError', function (event, request) { '</div>', false ); - AJAX.active = false; - AJAX.xhr = null; + window.AJAX.active = false; + window.AJAX.xhr = null; } }); diff --git a/js/src/common.js b/js/src/common.js index d1b5808a0e..233e8284d7 100644 --- a/js/src/common.js +++ b/js/src/common.js @@ -167,7 +167,7 @@ var CommonActions = { .trigger('click') .remove(); if (typeof callback !== 'undefined') { - AJAX.callback = callback; + window.AJAX.callback = callback; } } }; diff --git a/js/src/config.js b/js/src/config.js index f42551ada6..a1e3ff6940 100644 --- a/js/src/config.js +++ b/js/src/config.js @@ -34,7 +34,7 @@ function isStorageSupported (type, warn = false) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('config.js', function () { +window.AJAX.registerTeardown('config.js', function () { $('.optbox input[id], .optbox select[id], .optbox textarea[id]').off('change').off('keyup'); $('.optbox input[type=button][name=submit_reset]').off('click'); $('div.tab-content').off(); @@ -44,7 +44,7 @@ AJAX.registerTeardown('config.js', function () { $('#prefs_autoload').find('a').off('click'); }); -AJAX.registerOnload('config.js', function () { +window.AJAX.registerOnload('config.js', function () { var $topmenuUpt = $('#user_prefs_tabs'); $topmenuUpt.find('a.active').attr('rel', 'samepage'); $topmenuUpt.find('a:not(.active)').attr('rel', 'newpage'); @@ -592,7 +592,7 @@ function setupValidation () { } } -AJAX.registerOnload('config.js', function () { +window.AJAX.registerOnload('config.js', function () { setupValidation(); }); @@ -610,7 +610,7 @@ function adjustPrefsNotification () { } } -AJAX.registerOnload('config.js', function () { +window.AJAX.registerOnload('config.js', function () { adjustPrefsNotification(); }); @@ -618,7 +618,7 @@ AJAX.registerOnload('config.js', function () { // Form reset buttons // -AJAX.registerOnload('config.js', function () { +window.AJAX.registerOnload('config.js', function () { $('.optbox input[type=button][name=submit_reset]').on('click', function () { var fields = $(this).closest('fieldset').find('input, select, textarea'); for (var i = 0, imax = fields.length; i < imax; i++) { @@ -678,7 +678,7 @@ function setupRestoreField () { .css({ display: 'inline-block', opacity: 0.25 }); } -AJAX.registerOnload('config.js', function () { +window.AJAX.registerOnload('config.js', function () { setupRestoreField(); }); @@ -690,7 +690,7 @@ AJAX.registerOnload('config.js', function () { // User preferences import/export // -AJAX.registerOnload('config.js', function () { +window.AJAX.registerOnload('config.js', function () { offerPrefsAutoimport(); var $radios = $('#import_local_storage, #export_local_storage'); if (!$radios.length) { diff --git a/js/src/database/central_columns.js b/js/src/database/central_columns.js index f31c832ae1..f9551e93cc 100644 --- a/js/src/database/central_columns.js +++ b/js/src/database/central_columns.js @@ -15,7 +15,7 @@ * */ -AJAX.registerTeardown('database/central_columns.js', function () { +window.AJAX.registerTeardown('database/central_columns.js', function () { $('.edit').off('click'); $('.edit_save_form').off('click'); $('.edit_cancel_form').off('click'); @@ -32,7 +32,7 @@ AJAX.registerTeardown('database/central_columns.js', function () { $('button[name=\'edit_central_columns\']').off('click'); }); -AJAX.registerOnload('database/central_columns.js', function () { +window.AJAX.registerOnload('database/central_columns.js', function () { $('#tableslistcontainer input,#tableslistcontainer select,#tableslistcontainer .default_value,#tableslistcontainer .open_enum_editor').hide(); $('#tableslistcontainer').find('.checkall').show(); $('#tableslistcontainer').find('.checkall_box').show(); @@ -66,8 +66,8 @@ AJAX.registerOnload('database/central_columns.js', function () { var argsep = CommonParams.get('arg_separator'); var editColumnData = editColumnList + '' + argsep + 'edit_central_columns_page=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server'); Functions.ajaxShowMessage(); - AJAX.source = $(this); - $.post('index.php?route=/database/central-columns', editColumnData, AJAX.responseHandler); + window.AJAX.source = $(this); + $.post('index.php?route=/database/central-columns', editColumnData, window.AJAX.responseHandler); }); $('#multi_edit_central_columns').on('submit', function (event) { event.preventDefault(); @@ -75,8 +75,8 @@ AJAX.registerOnload('database/central_columns.js', function () { var argsep = CommonParams.get('arg_separator'); var multiColumnEditData = $('#multi_edit_central_columns').serialize() + argsep + 'multi_edit_central_column_save=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server'); Functions.ajaxShowMessage(); - AJAX.source = $(this); - $.post('index.php?route=/database/central-columns', multiColumnEditData, AJAX.responseHandler); + window.AJAX.source = $(this); + $.post('index.php?route=/database/central-columns', multiColumnEditData, window.AJAX.responseHandler); }); $('#add_new').find('td').each(function () { if ($(this).attr('name') !== 'undefined') { diff --git a/js/src/database/events.js b/js/src/database/events.js index 3a6bb5d006..5b36753db1 100644 --- a/js/src/database/events.js +++ b/js/src/database/events.js @@ -1,4 +1,4 @@ -AJAX.registerTeardown('database/events.js', function () { +window.AJAX.registerTeardown('database/events.js', function () { $(document).off('click', 'a.ajax.add_anchor, a.ajax.edit_anchor'); $(document).off('click', 'a.ajax.export_anchor'); $(document).off('click', '#bulkActionExportButton'); @@ -509,7 +509,7 @@ const DatabaseEvents = { } }; -AJAX.registerOnload('database/events.js', function () { +window.AJAX.registerOnload('database/events.js', function () { /** * Attach Ajax event handlers for the Add/Edit functionality. */ diff --git a/js/src/database/multi_table_query.js b/js/src/database/multi_table_query.js index 890c4fc56c..c8e3088418 100644 --- a/js/src/database/multi_table_query.js +++ b/js/src/database/multi_table_query.js @@ -18,7 +18,7 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('database/multi_table_query.js', function () { +window.AJAX.registerTeardown('database/multi_table_query.js', function () { $('.tableNameSelect').each(function () { $(this).off('change'); }); @@ -26,7 +26,7 @@ AJAX.registerTeardown('database/multi_table_query.js', function () { $('#add_column_button').off('click'); }); -AJAX.registerOnload('database/multi_table_query.js', function () { +window.AJAX.registerOnload('database/multi_table_query.js', function () { var editor = Functions.getSqlEditor($('#MultiSqlquery'), {}, 'both'); $('.CodeMirror-line').css('text-align', 'left'); editor.setSize(-1, 50); diff --git a/js/src/database/operations.js b/js/src/database/operations.js index b68c5f2954..43b1f56205 100644 --- a/js/src/database/operations.js +++ b/js/src/database/operations.js @@ -21,14 +21,14 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('database/operations.js', function () { +window.AJAX.registerTeardown('database/operations.js', function () { $(document).off('submit', '#rename_db_form.ajax'); $(document).off('submit', '#copy_db_form.ajax'); $(document).off('submit', '#change_db_charset_form.ajax'); $(document).off('click', '#drop_db_anchor.ajax'); }); -AJAX.registerOnload('database/operations.js', function () { +window.AJAX.registerOnload('database/operations.js', function () { /** * Ajax event handlers for 'Rename Database' */ diff --git a/js/src/database/qbe.js b/js/src/database/qbe.js index 4fc508dd34..9a13693ca5 100644 --- a/js/src/database/qbe.js +++ b/js/src/database/qbe.js @@ -18,7 +18,7 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('database/qbe.js', function () { +window.AJAX.registerTeardown('database/qbe.js', function () { $(document).off('change', 'select[name^=criteriaColumn]'); $(document).off('change', '#searchId'); $(document).off('click', '#saveSearch'); @@ -26,7 +26,7 @@ AJAX.registerTeardown('database/qbe.js', function () { $(document).off('click', '#deleteSearch'); }); -AJAX.registerOnload('database/qbe.js', function () { +window.AJAX.registerOnload('database/qbe.js', function () { Functions.getSqlEditor($('#textSqlquery'), {}, 'none'); $('#tblQbe').width($('#tblQbe').parent().width()); diff --git a/js/src/database/routines.js b/js/src/database/routines.js index bb50a650c7..74ccf4b908 100644 --- a/js/src/database/routines.js +++ b/js/src/database/routines.js @@ -1,4 +1,4 @@ -AJAX.registerTeardown('database/routines.js', function () { +window.AJAX.registerTeardown('database/routines.js', function () { $(document).off('click', 'a.ajax.add_anchor'); $(document).off('click', 'a.ajax.edit_anchor'); $(document).off('click', 'a.ajax.exec_anchor'); @@ -838,7 +838,7 @@ const DatabaseRoutines = { } }; -AJAX.registerOnload('database/routines.js', function () { +window.AJAX.registerOnload('database/routines.js', function () { $(document).on('click', 'a.ajax.add_anchor', function (event) { event.preventDefault(); $.datepicker.initialized = false; diff --git a/js/src/database/search.js b/js/src/database/search.js index bcf5f4fbc3..d47a8bd960 100644 --- a/js/src/database/search.js +++ b/js/src/database/search.js @@ -19,7 +19,7 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('database/search.js', function () { +window.AJAX.registerTeardown('database/search.js', function () { $('a.browse_results').off('click'); $('a.delete_results').off('click'); $('#buttonGo').off('click'); @@ -31,7 +31,7 @@ AJAX.registerTeardown('database/search.js', function () { $(document).off('submit', '#db_search_form.ajax'); }); -AJAX.registerOnload('database/search.js', function () { +window.AJAX.registerOnload('database/search.js', function () { /** Hide the table link in the initial search result */ var icon = Functions.getImage('s_tbl', '', { 'id': 'table-image' }).toString(); $('#table-info').prepend(icon).hide(); diff --git a/js/src/database/structure.js b/js/src/database/structure.js index 6c27120998..b060888a69 100644 --- a/js/src/database/structure.js +++ b/js/src/database/structure.js @@ -22,7 +22,7 @@ var DatabaseStructure = {}; /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('database/structure.js', function () { +window.AJAX.registerTeardown('database/structure.js', function () { $(document).off('click', 'a.truncate_table_anchor.ajax'); $(document).off('click', 'a.drop_table_anchor.ajax'); $(document).off('click', '#real_end_input'); @@ -183,7 +183,7 @@ DatabaseStructure.fetchRealRowCount = function ($target) { }); }; -AJAX.registerOnload('database/structure.js', function () { +window.AJAX.registerOnload('database/structure.js', function () { /** * Event handler on select of "Make consistent with central list" */ @@ -202,12 +202,12 @@ AJAX.registerOnload('database/structure.js', function () { const data = $form.serialize() + argSep + 'ajax_request=true' + argSep + 'ajax_page_request=true'; Functions.ajaxShowMessage(); - AJAX.source = $form; + window.AJAX.source = $form; $.post( 'index.php?route=/database/structure/central-columns/make-consistent', data, - AJAX.responseHandler + window.AJAX.responseHandler ); $('#makeConsistentWithCentralListModal').modal('hide'); @@ -297,9 +297,9 @@ AJAX.registerOnload('database/structure.js', function () { var data = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; Functions.ajaxShowMessage(); - AJAX.source = $form; + window.AJAX.source = $form; - $.post(url, data, AJAX.responseHandler); + $.post(url, data, window.AJAX.responseHandler); }); /** diff --git a/js/src/database/tracking.js b/js/src/database/tracking.js index 53d2e3364b..8db279d6c9 100644 --- a/js/src/database/tracking.js +++ b/js/src/database/tracking.js @@ -1,7 +1,7 @@ /** * Unbind all event handlers before tearing down the page */ -AJAX.registerTeardown('database/tracking.js', function () { +window.AJAX.registerTeardown('database/tracking.js', function () { $('body').off('click', '#trackedForm.ajax button[name="submit_mult"], #trackedForm.ajax input[name="submit_mult"]'); $('body').off('click', '#untrackedForm.ajax button[name="submit_mult"], #untrackedForm.ajax input[name="submit_mult"]'); $('body').off('click', 'a.delete_tracking_anchor.ajax'); @@ -10,7 +10,7 @@ AJAX.registerTeardown('database/tracking.js', function () { /** * Bind event handlers */ -AJAX.registerOnload('database/tracking.js', function () { +window.AJAX.registerOnload('database/tracking.js', function () { var $versions = $('#versions'); $versions.find('tr').first().find('th').append($('<div class="sorticon"></div>')); $versions.tablesorter({ @@ -50,13 +50,13 @@ AJAX.registerOnload('database/tracking.js', function () { var question = Messages.strDeleteTrackingDataMultiple; $button.confirm(question, $form.attr('action'), function (url) { Functions.ajaxShowMessage(Messages.strDeletingTrackingData); - AJAX.source = $form; - $.post(url, submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post(url, submitData, window.AJAX.responseHandler); }); } else { Functions.ajaxShowMessage(); - AJAX.source = $form; - $.post($form.attr('action'), submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post($form.attr('action'), submitData, window.AJAX.responseHandler); } }); @@ -70,8 +70,8 @@ AJAX.registerOnload('database/tracking.js', function () { var argsep = CommonParams.get('arg_separator'); var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'submit_mult=' + $button.val(); Functions.ajaxShowMessage(); - AJAX.source = $form; - $.post($form.attr('action'), submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post($form.attr('action'), submitData, window.AJAX.responseHandler); }); /** @@ -83,11 +83,11 @@ AJAX.registerOnload('database/tracking.js', function () { var question = Messages.strDeleteTrackingData; $anchor.confirm(question, $anchor.attr('href'), function (url) { Functions.ajaxShowMessage(Messages.strDeletingTrackingData); - AJAX.source = $anchor; + window.AJAX.source = $anchor; var argSep = CommonParams.get('arg_separator'); var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData()); params += argSep + 'ajax_page_request=1'; - $.post(url, params, AJAX.responseHandler); + $.post(url, params, window.AJAX.responseHandler); }); }); }); diff --git a/js/src/database/triggers.js b/js/src/database/triggers.js index 5b1dc421ab..fcac6ad55b 100644 --- a/js/src/database/triggers.js +++ b/js/src/database/triggers.js @@ -1,4 +1,4 @@ -AJAX.registerTeardown('database/triggers.js', function () { +window.AJAX.registerTeardown('database/triggers.js', function () { $(document).off('click', 'a.ajax.add_anchor, a.ajax.edit_anchor'); $(document).off('click', 'a.ajax.export_anchor'); $(document).off('click', '#bulkActionExportButton'); @@ -488,7 +488,7 @@ const DatabaseTriggers = { } }; -AJAX.registerOnload('database/triggers.js', function () { +window.AJAX.registerOnload('database/triggers.js', function () { /** * Attach Ajax event handlers for the Add/Edit functionality. */ diff --git a/js/src/designer/history.js b/js/src/designer/history.js index 96bd705850..8bf57f4a56 100644 --- a/js/src/designer/history.js +++ b/js/src/designer/history.js @@ -806,7 +806,7 @@ DesignerHistory.buildQuery = function () { }); }; -AJAX.registerTeardown('designer/history.js', function () { +window.AJAX.registerTeardown('designer/history.js', function () { vqbEditor = null; historyArray = []; selectField = []; @@ -816,7 +816,7 @@ AJAX.registerTeardown('designer/history.js', function () { $('#ok_edit_where').off('click'); }); -AJAX.registerOnload('designer/history.js', function () { +window.AJAX.registerOnload('designer/history.js', function () { $('#ok_edit_rename').on('click', function () { DesignerHistory.edit('Rename'); }); diff --git a/js/src/designer/init.js b/js/src/designer/init.js index 07d070adc4..8334610a08 100644 --- a/js/src/designer/init.js +++ b/js/src/designer/init.js @@ -20,11 +20,11 @@ var selectedPage; var db; var designerTablesEnabled; -AJAX.registerTeardown('designer/init.js', function () { +window.AJAX.registerTeardown('designer/init.js', function () { $('.trigger').off('click'); }); -AJAX.registerOnload('designer/init.js', function () { +window.AJAX.registerOnload('designer/init.js', function () { $('.trigger').on('click', function () { $('.panel').toggle('fast'); $(this).toggleClass('active'); diff --git a/js/src/designer/move.js b/js/src/designer/move.js index 8f93e64516..b8954cef33 100644 --- a/js/src/designer/move.js +++ b/js/src/designer/move.js @@ -14,12 +14,12 @@ var change = 0; // variable to track any change in designer layout. var showRelationLines = true; var alwaysShowText = false; -AJAX.registerTeardown('designer/move.js', function () { +window.AJAX.registerTeardown('designer/move.js', function () { $(document).off('fullscreenchange'); $('#selflink').show(); }); -AJAX.registerOnload('designer/move.js', function () { +window.AJAX.registerOnload('designer/move.js', function () { var $content = $('#page_content'); var $img = $('#toggleFullscreen').find('img'); var $span = $img.siblings('span'); @@ -2013,7 +2013,7 @@ DesignerMove.enableTableEvents = function (index, element) { DesignerMove.enablePageContentEvents(); }; -AJAX.registerTeardown('designer/move.js', function () { +window.AJAX.registerTeardown('designer/move.js', function () { $('#side_menu').off('mouseenter mouseleave'); $('#key_Show_left_menu').off('click'); $('#toggleFullscreen').off('click'); @@ -2063,7 +2063,7 @@ AJAX.registerTeardown('designer/move.js', function () { $('#page_content').off('mousemove'); }); -AJAX.registerOnload('designer/move.js', function () { +window.AJAX.registerOnload('designer/move.js', function () { $('#key_Show_left_menu').on('click', function () { DesignerMove.showLeftMenu(this); return false; diff --git a/js/src/drag_drop_import.js b/js/src/drag_drop_import.js index 59c9d9252b..004b4fb560 100644 --- a/js/src/drag_drop_import.js +++ b/js/src/drag_drop_import.js @@ -294,7 +294,7 @@ var DragDropImport = { $('.pma_sql_import_status').slideDown(); for (var i = 0; i < files.length; i++) { var ext = (DragDropImport.getExtension(files[i].name)); - var hash = AJAX.hash(++DragDropImport.uploadCount); + var hash = window.AJAX.hash(++DragDropImport.uploadCount); var $sqlImportStatusDiv = $('.pma_sql_import_status div'); $sqlImportStatusDiv.append('<li data-hash="' + hash + '">' + diff --git a/js/src/error_report.js b/js/src/error_report.js index eafc2f1caa..b515dace17 100644 --- a/js/src/error_report.js +++ b/js/src/error_report.js @@ -224,8 +224,8 @@ var ErrorReport = { 'url': window.location.href, 'exception_type': 'js' }; - if (AJAX.scriptHandler.scripts.length > 0) { - reportData.scripts = AJAX.scriptHandler.scripts.map( + if (window.AJAX.scriptHandler.scripts.length > 0) { + reportData.scripts = window.AJAX.scriptHandler.scripts.map( function (script) { return script; } @@ -259,13 +259,13 @@ var ErrorReport = { } }, /** - * Automatically wraps the callback in AJAX.registerOnload + * Automatically wraps the callback in window.AJAX.registerOnload * * @return {void} */ wrapAjaxOnloadCallback: function () { - var oldOnload = AJAX.registerOnload; - AJAX.registerOnload = function (file, func) { + var oldOnload = window.AJAX.registerOnload; + window.AJAX.registerOnload = function (file, func) { var wrappedFunction = ErrorReport.wrapFunction(func); oldOnload.call(this, file, wrappedFunction); }; @@ -288,7 +288,7 @@ var ErrorReport = { }; }, /** - * Wraps the callback in AJAX.registerOnload automatically + * Wraps the callback in window.AJAX.registerOnload automatically * * @return {void} */ @@ -298,7 +298,7 @@ var ErrorReport = { } }; -AJAX.registerOnload('error_report.js', function () { +window.AJAX.registerOnload('error_report.js', function () { TraceKit.report.subscribe(ErrorReport.errorHandler); ErrorReport.setUpErrorReporting(); }); diff --git a/js/src/export.js b/js/src/export.js index 983c66d25a..89e4d80142 100644 --- a/js/src/export.js +++ b/js/src/export.js @@ -203,7 +203,7 @@ Export.deleteTemplate = function (id) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('export.js', function () { +window.AJAX.registerTeardown('export.js', function () { $('#plugins').off('change'); $('input[type=\'radio\'][name=\'sql_structure_or_data\']').off('change'); $('input[type=\'radio\'][name$=\'_structure_or_data\']').off('change'); @@ -227,7 +227,7 @@ AJAX.registerTeardown('export.js', function () { $('input[name="deleteTemplate"]').off('click'); }); -AJAX.registerOnload('export.js', function () { +window.AJAX.registerOnload('export.js', function () { $('#showsqlquery').on('click', function () { // Creating a dialog box similar to preview sql container to show sql query var modal = $('#showSqlQueryModal'); @@ -432,7 +432,7 @@ Export.toggleSaveToFile = function () { } }; -AJAX.registerOnload('export.js', function () { +window.AJAX.registerOnload('export.js', function () { Export.toggleSaveToFile(); $('input[type=\'radio\'][name=\'output_format\']').on('change', Export.toggleSaveToFile); }); @@ -578,7 +578,7 @@ Export.handleAddProcCheckbox = function () { } }; -AJAX.registerOnload('export.js', function () { +window.AJAX.registerOnload('export.js', function () { /** * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options */ @@ -832,7 +832,7 @@ Export.addAlias = function (type, name, field, value) { $('#alias_data tbody').append(row); }; -AJAX.registerOnload('export.js', function () { +window.AJAX.registerOnload('export.js', function () { $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', Export.toggleQuickOrCustom); $('#format_specific_opts').find('div.format_specific_options') diff --git a/js/src/export_output.js b/js/src/export_output.js index 965526a3b5..84d8431bbd 100644 --- a/js/src/export_output.js +++ b/js/src/export_output.js @@ -1,4 +1,4 @@ -AJAX.registerOnload('export_output.js', function () { +window.AJAX.registerOnload('export_output.js', function () { $(document).on('keydown', function (e) { if ((e.which || e.keyCode) === 116) { e.preventDefault(); diff --git a/js/src/functions.js b/js/src/functions.js index 868777463b..b77b2550c6 100644 --- a/js/src/functions.js +++ b/js/src/functions.js @@ -337,7 +337,7 @@ Functions.getSqlEditor = function ($textarea, options, resize, lintOptions) { value: 3, content: codemirrorEditor.isClean(), }; - AJAX.lockPageHandler(e); + window.AJAX.lockPageHandler(e); }); return codemirrorEditor; @@ -902,13 +902,13 @@ let incInterval; /** @type {number} */ let updateTimeout; -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { clearTimeout(updateTimeout); clearInterval(incInterval); $(document).off('mousemove'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { document.onclick = function () { idleSecondsCounter = 0; }; @@ -1010,11 +1010,11 @@ AJAX.registerOnload('functions.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('click', 'input:checkbox.checkall'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Row marking in horizontal mode (use "on" so that it works also for * next pages reached via AJAX); a tr may have the class noclick to remove @@ -1200,7 +1200,7 @@ Functions.getJsConfirmCommonParam = function (elem, parameters) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('click', 'a.inline_edit_sql'); $(document).off('click', 'input#sql_query_edit_save'); $(document).off('click', 'input#sql_query_edit_discard'); @@ -1228,7 +1228,7 @@ AJAX.registerTeardown('functions.js', function () { /** * Jquery Coding for inline editing SQL_QUERY */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { // If we are coming back to the page by clicking forward button // of the browser, bind the code mirror to inline query editor. Functions.bindCodeMirrorToInlineEditor(); @@ -1399,7 +1399,7 @@ Functions.codeMirrorAutoCompleteOnInputRead = function (instance) { /** * Remove autocomplete information before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { sqlAutoComplete = false; sqlAutoCompleteDefaultTable = ''; }); @@ -2257,7 +2257,7 @@ jQuery.fn.sortTable = Functions.sortTable; /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('submit', 'form.create_table_form.ajax'); $(document).off('click', 'form.create_table_form.ajax input[name=submit_num_fields]'); $(document).off('keyup', 'form.create_table_form.ajax input'); @@ -2271,7 +2271,7 @@ AJAX.registerTeardown('functions.js', function () { * * Attach Ajax Event handlers for Create Table */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Attach event handler for submission of create table form (save) */ @@ -2360,7 +2360,7 @@ AJAX.registerOnload('functions.js', function () { var tableStructureUrl = 'index.php?route=/table/structure' + argsep + 'server=' + data.params.server + argsep + 'db=' + data.params.db + argsep + 'token=' + data.params.token + argsep + 'goto=' + encodeURIComponent('index.php?route=/database/structure') + argsep + 'table=' + data.params.table + ''; - $.get(tableStructureUrl, params12, AJAX.responseHandler); + $.get(tableStructureUrl, params12, window.AJAX.responseHandler); } else { Functions.ajaxShowMessage( '<div class="alert alert-danger" role="alert">' + data.error + '</div>', @@ -2494,7 +2494,7 @@ Functions.checkPassword = function ($theForm) { /** * Attach Ajax event handlers for 'Change Password' on index.php */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /* Handler for hostname type */ $(document).on('change', '#select_pred_hostname', function () { var hostname = $('#pma_hostname'); @@ -2613,7 +2613,7 @@ AJAX.registerOnload('functions.js', function () { } if (data.scripts) { - AJAX.scriptHandler.load(data.scripts); + window.AJAX.scriptHandler.load(data.scripts); } // for this dialog, we remove the fieldset wrapping due to double headings @@ -2641,7 +2641,7 @@ AJAX.registerOnload('functions.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('change', 'select.column_type'); $(document).off('change', 'select.default_type'); $(document).off('change', 'select.virtuality'); @@ -2653,7 +2653,7 @@ AJAX.registerTeardown('functions.js', function () { * Toggle the hiding/showing of the "Open in ENUM/SET editor" message when * the page loads and when the selected data type changes */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { // is called here for normal page loads and also when opening // the Create table dialog Functions.verifyColumnsProperties(); @@ -2763,7 +2763,7 @@ Functions.autoPopulate = function (inputId, offset) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('click', 'a.open_enum_editor'); $(document).off('click', 'input.add_value'); $(document).off('click', '#enum_editor td.drop'); @@ -2773,7 +2773,7 @@ AJAX.registerTeardown('functions.js', function () { /** * Opens the ENUM/SET editor and controls its functions */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { $(document).on('click', 'a.open_enum_editor', function () { // Get the name of the column that is being edited var colname = $(this).closest('tr').find('input').first().val(); @@ -3096,11 +3096,11 @@ Functions.checkIndexName = function (formId) { return true; }; -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('click', '#index_frm input[type=submit]'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Handler for adding more columns to an index in the editor */ @@ -3319,7 +3319,7 @@ Functions.showHints = function ($div) { }); }; -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { Functions.showHints(); }); @@ -3471,14 +3471,14 @@ Functions.toggleButton = function ($obj) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $('div.toggle-container').off('click'); }); /** * Initialise all toggle buttons */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { $('div.toggleAjax').each(function () { var $button = $(this).show(); $button.find('img').each(function () { @@ -3496,13 +3496,13 @@ AJAX.registerOnload('functions.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('change', 'select.pageselector'); $('#update_recent_tables').off('ready'); $('#sync_favorite_tables').off('ready'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Autosubmit page selector */ @@ -3646,7 +3646,7 @@ Functions.slidingMessage = function (msg, $object) { /** * Attach CodeMirror2 editor to SQL edit area. */ -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { var $elm = $('#sqlquery'); if ($elm.siblings().filter('.CodeMirror').length > 0) { return; @@ -3664,7 +3664,7 @@ AJAX.registerOnload('functions.js', function () { Functions.highlightSql($('body')); }); -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { if (codeMirrorEditor) { $('#sqlquery').text(codeMirrorEditor.getValue()); codeMirrorEditor.toTextArea(); @@ -3672,7 +3672,7 @@ AJAX.registerTeardown('functions.js', function () { } }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { // initializes all lock-page elements lock-id and // val-hash data property $('#page_content form.lock-page textarea, ' + @@ -3683,7 +3683,7 @@ AJAX.registerOnload('functions.js', function () { // val-hash is the hash of default value of the field // so that it can be compared with new value hash // to check whether field was modified or not. - $(this).data('val-hash', AJAX.hash($(this).val())); + $(this).data('val-hash', window.AJAX.hash($(this).val())); }); // initializes lock-page elements (input types checkbox and radio buttons) @@ -3691,7 +3691,7 @@ AJAX.registerOnload('functions.js', function () { $('#page_content form.lock-page input[type="checkbox"], ' + '#page_content form.lock-page input[type="radio"]').each(function (i) { $(this).data('lock-id', i); - $(this).data('val-hash', AJAX.hash($(this).is(':checked'))); + $(this).data('val-hash', window.AJAX.hash($(this).is(':checked'))); }); }); @@ -3730,11 +3730,11 @@ Functions.getCellValue = function (td) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('change', '.autosubmit'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Automatic form submission on change. */ @@ -3755,7 +3755,7 @@ const PrintPage = { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { document.querySelectorAll('.jsPrintButton').forEach(item => { item.removeEventListener('click', PrintPage); }); @@ -3765,7 +3765,7 @@ AJAX.registerTeardown('functions.js', function () { $(document).off('change', '#fkc_checkbox'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { document.querySelectorAll('.jsPrintButton').forEach(item => { item.addEventListener('click', PrintPage); }); @@ -3985,7 +3985,7 @@ $(document).on('keyup', '#filterText', function () { $('#filter-rows-count').html(count); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /* Trigger filtering of the list based on incoming database name */ var $filter = $('#filterText'); if ($filter.val()) { @@ -4022,7 +4022,7 @@ Functions.formatBytes = function (bytesToFormat, subDecimals, pointChar) { return bytes + ' ' + units[i]; }; -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Reveal the login form to users with JS enabled * and focus the appropriate input field @@ -4158,11 +4158,11 @@ var recaptchaCallback = function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('keydown', 'form input, form textarea, form select'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /** * Handle 'Ctrl/Alt + Enter' form submits */ @@ -4184,13 +4184,13 @@ AJAX.registerOnload('functions.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('functions.js', function () { +window.AJAX.registerTeardown('functions.js', function () { $(document).off('change', 'input[type=radio][name="pw_hash"]'); $(document).off('mouseover', '.sortlink'); $(document).off('mouseout', '.sortlink'); }); -AJAX.registerOnload('functions.js', function () { +window.AJAX.registerOnload('functions.js', function () { /* * Display warning regarding SSL when sha256_password * method is selected diff --git a/js/src/gis_data_editor.js b/js/src/gis_data_editor.js index e927a32646..9e2f5b8d31 100644 --- a/js/src/gis_data_editor.js +++ b/js/src/gis_data_editor.js @@ -206,7 +206,7 @@ function insertDataAndClose () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('gis_data_editor.js', function () { +window.AJAX.registerTeardown('gis_data_editor.js', function () { $(document).off('click', '#gis_editor input[name=\'gis_data[save]\']'); $(document).off('submit', '#gis_editor'); $(document).off('change', '#gis_editor input[type=\'text\']'); @@ -218,7 +218,7 @@ AJAX.registerTeardown('gis_data_editor.js', function () { $(document).off('click', '#gis_editor a.addJs.addGeom'); }); -AJAX.registerOnload('gis_data_editor.js', function () { +window.AJAX.registerOnload('gis_data_editor.js', function () { /** * Prepares and insert the GIS data to the input field on clicking 'copy'. */ diff --git a/js/src/home.js b/js/src/home.js index 315e5ef966..43abd9df1f 100644 --- a/js/src/home.js +++ b/js/src/home.js @@ -154,11 +154,11 @@ const ThemesManager = { } }; -AJAX.registerTeardown('home.js', () => { +window.AJAX.registerTeardown('home.js', () => { $('#themesModal').off('show.bs.modal'); }); -AJAX.registerOnload('home.js', () => { +window.AJAX.registerOnload('home.js', () => { $('#themesModal').on('show.bs.modal', ThemesManager.handleEvent); GitInfo.showVersion(); diff --git a/js/src/import.js b/js/src/import.js index 989b35b51f..70c0e1d603 100644 --- a/js/src/import.js +++ b/js/src/import.js @@ -47,7 +47,7 @@ function matchFile (fname) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('import.js', function () { +window.AJAX.registerTeardown('import.js', function () { $('#plugins').off('change'); $('#input_import_file').off('change'); $('#select_local_import_file').off('change'); @@ -56,7 +56,7 @@ AJAX.registerTeardown('import.js', function () { $('#text_csv_enclosed').add('#text_csv_escaped').off('keyup'); }); -AJAX.registerOnload('import.js', function () { +window.AJAX.registerOnload('import.js', function () { // import_file_form validation. $(document).on('submit', '#import_file_form', function () { var radioLocalImport = $('#localFileTab'); diff --git a/js/src/indexes.js b/js/src/indexes.js index daee801fcf..05683b49c8 100644 --- a/js/src/indexes.js +++ b/js/src/indexes.js @@ -551,7 +551,7 @@ Indexes.indexTypeSelectionDialog = function (sourceArray, indexChoice, colIndex) /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('indexes.js', function () { +window.AJAX.registerTeardown('indexes.js', function () { $(document).off('click', '#save_index_frm'); $(document).off('click', '#preview_index_frm'); $(document).off('change', '#select_index_choice'); @@ -572,7 +572,7 @@ AJAX.registerTeardown('indexes.js', function () { * <li>create/edit/drop indexes</li> * </ul> */ -AJAX.registerOnload('indexes.js', function () { +window.AJAX.registerOnload('indexes.js', function () { // Re-initialize variables. primaryIndexes = []; uniqueIndexes = []; @@ -597,8 +597,8 @@ AJAX.registerOnload('indexes.js', function () { var argsep = CommonParams.get('arg_separator'); var submitData = $form.serialize() + argsep + 'do_save_data=1' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; Functions.ajaxShowMessage(Messages.strProcessingRequest); - AJAX.source = $form; - $.post($form.attr('action'), submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post($form.attr('action'), submitData, window.AJAX.responseHandler); }); $(document).on('click', '#preview_index_frm', function (event) { diff --git a/js/src/keyhandler.js b/js/src/keyhandler.js index 83d2a3dc07..5184964e38 100644 --- a/js/src/keyhandler.js +++ b/js/src/keyhandler.js @@ -125,12 +125,12 @@ function onKeyDownArrowsHandler (event) { e.returnValue = false; } -AJAX.registerTeardown('keyhandler.js', function () { +window.AJAX.registerTeardown('keyhandler.js', function () { $(document).off('keydown keyup', '#table_columns'); $(document).off('keydown keyup', 'table.insertRowTable'); }); -AJAX.registerOnload('keyhandler.js', function () { +window.AJAX.registerOnload('keyhandler.js', function () { $(document).on('keydown keyup', '#table_columns', function (event) { onKeyDownArrowsHandler(event.originalEvent); }); diff --git a/js/src/makegrid.js b/js/src/makegrid.js index 5740b3f166..131541fe9d 100644 --- a/js/src/makegrid.js +++ b/js/src/makegrid.js @@ -2059,7 +2059,7 @@ var makeGrid = function (t, enableResize, enableReorder, enableVisib, enableGrid // temporarily remove ajax class so the page loader will not handle it, // submit and then add it back $link.removeClass('ajax'); - AJAX.requestHandler.call($link[0]); + window.AJAX.requestHandler.call($link[0]); $link.addClass('ajax'); $cell.data('clicks', 0); }, 700); diff --git a/js/src/modules/console.js b/js/src/modules/console.js index f1221b0e41..db81814f0c 100644 --- a/js/src/modules/console.js +++ b/js/src/modules/console.js @@ -2,7 +2,7 @@ import $ from 'jquery'; import CodeMirror from 'codemirror'; import { Config } from './console/config.js'; -/* global AJAX, CommonParams, Functions, Messages, Navigation */ +/* global CommonParams, Functions, Messages, Navigation */ /** * Console object @@ -90,7 +90,7 @@ var Console = { '</form>' ); Console.$requestForm.children('[name=token]').val(CommonParams.get('token')); - Console.$requestForm.on('submit', AJAX.requestHandler); + Console.$requestForm.on('submit', window.AJAX.requestHandler); // Event binds shouldn't run again if (Console.isInitialized === false) { diff --git a/js/src/multi_column_sort.js b/js/src/multi_column_sort.js index 53e4d2bb3a..d01a36cd89 100644 --- a/js/src/multi_column_sort.js +++ b/js/src/multi_column_sort.js @@ -6,27 +6,27 @@ * @requires jQuery */ -AJAX.registerOnload('keyhandler.js', function () { +window.AJAX.registerOnload('keyhandler.js', function () { $('th.draggable.column_heading.pointer.marker a').on('click', function (event) { var orderUrlRemove = $(this).parent().find('input[name="url-remove-order"]').val(); var orderUrlAdd = $(this).parent().find('input[name="url-add-order"]').val(); var argsep = CommonParams.get('arg_separator'); if (event.ctrlKey || event.altKey) { event.preventDefault(); - AJAX.source = $(this); + window.AJAX.source = $(this); Functions.ajaxShowMessage(); orderUrlRemove += argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; - $.post('index.php?route=/sql', orderUrlRemove, AJAX.responseHandler); + $.post('index.php?route=/sql', orderUrlRemove, window.AJAX.responseHandler); } else if (event.shiftKey) { event.preventDefault(); - AJAX.source = $(this); + window.AJAX.source = $(this); Functions.ajaxShowMessage(); orderUrlAdd += argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; - $.post('index.php?route=/sql', orderUrlAdd, AJAX.responseHandler); + $.post('index.php?route=/sql', orderUrlAdd, window.AJAX.responseHandler); } }); }); -AJAX.registerTeardown('keyhandler.js', function () { +window.AJAX.registerTeardown('keyhandler.js', function () { $(document).off('click', 'th.draggable.column_heading.pointer.marker a'); }); diff --git a/js/src/normalization.js b/js/src/normalization.js index a8c794b6ff..bb86a0ff8e 100644 --- a/js/src/normalization.js +++ b/js/src/normalization.js @@ -487,7 +487,7 @@ function moveRepeatingGroup (repeatingCols) { } }); } -AJAX.registerTeardown('normalization.js', function () { +window.AJAX.registerTeardown('normalization.js', function () { $('#extra').off('click', '#selectNonAtomicCol'); $('#splitGo').off('click'); $('.tblFooters').off('click', '#saveSplit'); @@ -500,7 +500,7 @@ AJAX.registerTeardown('normalization.js', function () { $('#mainContent').off('click', '.pickPd'); }); -AJAX.registerOnload('normalization.js', function () { +window.AJAX.registerOnload('normalization.js', function () { var selectedCol; normalizeto = $('#mainContent').data('normalizeto'); $('#extra').on('click', '#selectNonAtomicCol', function () { diff --git a/js/src/page_settings.js b/js/src/page_settings.js index 4051455826..d65eb2eb4e 100644 --- a/js/src/page_settings.js +++ b/js/src/page_settings.js @@ -33,13 +33,13 @@ function showNaviSettings () { showSettings('#pma_navigation_settings'); } -AJAX.registerTeardown('page_settings.js', function () { +window.AJAX.registerTeardown('page_settings.js', function () { $('#page_settings_icon').css('display', 'none'); $('#page_settings_icon').off('click'); $('#pma_navigation_settings_icon').off('click'); }); -AJAX.registerOnload('page_settings.js', function () { +window.AJAX.registerOnload('page_settings.js', function () { if ($('#page_settings_modal').length) { $('#page_settings_icon').css('display', 'inline'); $('#page_settings_icon').on('click', showPageSettings); diff --git a/js/src/replication.js b/js/src/replication.js index 26b8437480..16a9bc6861 100644 --- a/js/src/replication.js +++ b/js/src/replication.js @@ -33,7 +33,7 @@ function updateConfig () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('replication.js', function () { +window.AJAX.registerTeardown('replication.js', function () { $('#db_type').off('change'); $('#db_select').off('change'); $('#primary_status_href').off('click'); @@ -47,7 +47,7 @@ AJAX.registerTeardown('replication.js', function () { $('#reset_replica').off('click'); }); -AJAX.registerOnload('replication.js', function () { +window.AJAX.registerOnload('replication.js', function () { $('#rep').text(confPrefix); $('#db_type').on('change', updateConfig); $('#db_select').on('change', updateConfig); @@ -84,12 +84,12 @@ AJAX.registerOnload('replication.js', function () { var question = Messages.strResetReplicaWarning; $anchor.confirm(question, $anchor.attr('href'), function (url) { Functions.ajaxShowMessage(); - AJAX.source = $anchor; + window.AJAX.source = $anchor; var params = Functions.getJsConfirmCommonParam({ 'ajax_page_request': true, 'ajax_request': true }, $anchor.getPostData()); - $.post(url, params, AJAX.responseHandler); + $.post(url, params, window.AJAX.responseHandler); }); }); $('#button_generate_password').on('click', function () { diff --git a/js/src/server/databases.js b/js/src/server/databases.js index 5c849676a2..679da51698 100644 --- a/js/src/server/databases.js +++ b/js/src/server/databases.js @@ -111,7 +111,7 @@ const CreateDatabase = { var dbStructUrl = data.url; dbStructUrl = dbStructUrl.replace(/amp;/ig, ''); var params = 'ajax_request=true' + CommonParams.get('arg_separator') + 'ajax_page_request=true'; - $.get(dbStructUrl, params, AJAX.responseHandler); + $.get(dbStructUrl, params, window.AJAX.responseHandler); } else { Functions.ajaxShowMessage(data.error, false); } @@ -128,12 +128,12 @@ function checkPrivilegesForDatabase () { }); } -AJAX.registerTeardown('server/databases.js', function () { +window.AJAX.registerTeardown('server/databases.js', function () { $(document).off('submit', '#dbStatsForm'); $(document).off('submit', '#create_database_form.ajax'); }); -AJAX.registerOnload('server/databases.js', function () { +window.AJAX.registerOnload('server/databases.js', function () { $(document).on('submit', '#dbStatsForm', DropDatabases.handleEvent); $(document).on('submit', '#create_database_form.ajax', CreateDatabase.handleEvent); checkPrivilegesForDatabase(); diff --git a/js/src/server/plugins.js b/js/src/server/plugins.js index 519808519d..4d9df6583b 100644 --- a/js/src/server/plugins.js +++ b/js/src/server/plugins.js @@ -13,6 +13,6 @@ function makeColumnsSortable () { .append('<div class="sorticon"></div>'); } -AJAX.registerOnload('server/plugins.js', function () { +window.AJAX.registerOnload('server/plugins.js', function () { makeColumnsSortable(); }); diff --git a/js/src/server/privileges.js b/js/src/server/privileges.js index 33e63ffb60..7ab20f6964 100644 --- a/js/src/server/privileges.js +++ b/js/src/server/privileges.js @@ -476,7 +476,7 @@ const CheckAddUser = { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/privileges.js', function () { +window.AJAX.registerTeardown('server/privileges.js', function () { $('#fieldset_add_user_login').off('change', 'input[name=\'username\']'); $(document).off('click', '#deleteUserCard .btn.ajax'); @@ -495,7 +495,7 @@ AJAX.registerTeardown('server/privileges.js', function () { $(document).off('change', '#select_authentication_plugin'); }); -AJAX.registerOnload('server/privileges.js', function () { +window.AJAX.registerOnload('server/privileges.js', function () { $('#fieldset_add_user_login').on('change', 'input[name=\'username\']', AddUserLoginCheckUsername.handleEvent); $('#text_pma_pw').on('keyup', PasswordStrength.handleEvent); $('#text_pma_pw').on('input', SwitchToUseTextField.handleEvent); diff --git a/js/src/server/status/monitor.js b/js/src/server/status/monitor.js index 2cae0927e6..a80857e9c1 100644 --- a/js/src/server/status/monitor.js +++ b/js/src/server/status/monitor.js @@ -63,7 +63,7 @@ function destroyGrid () { monitorSettings = null; } -AJAX.registerOnload('server/status/monitor.js', function () { +window.AJAX.registerOnload('server/status/monitor.js', function () { var $jsDataForm = $('#js_data'); serverTimeDiff = new Date().getTime() - $jsDataForm.find('input[name=server_time]').val(); serverOs = $jsDataForm.find('input[name=server_os]').val(); @@ -74,7 +74,7 @@ AJAX.registerOnload('server/status/monitor.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/status/monitor.js', function () { +window.AJAX.registerTeardown('server/status/monitor.js', function () { $('#emptyDialog').remove(); $('a.popupLink').off('click'); $('body').off('click'); @@ -82,7 +82,7 @@ AJAX.registerTeardown('server/status/monitor.js', function () { /** * Popup behaviour */ -AJAX.registerOnload('server/status/monitor.js', function () { +window.AJAX.registerOnload('server/status/monitor.js', function () { $('<div></div>') .attr('id', 'emptyDialog') .appendTo('#page_content'); @@ -110,7 +110,7 @@ AJAX.registerOnload('server/status/monitor.js', function () { }); }); -AJAX.registerTeardown('server/status/monitor.js', function () { +window.AJAX.registerTeardown('server/status/monitor.js', function () { $('a[href="#rearrangeCharts"], a[href="#endChartEditMode"]').off('click'); $('div.popupContent select[name="chartColumns"]').off('change'); $('div.popupContent select[name="gridChartRefresh"]').off('change'); @@ -134,7 +134,7 @@ AJAX.registerTeardown('server/status/monitor.js', function () { destroyGrid(); }); -AJAX.registerOnload('server/status/monitor.js', function () { +window.AJAX.registerOnload('server/status/monitor.js', function () { // Show tab links $('div.tabLinks').show(); $('#loadingMonitorIcon').remove(); @@ -2210,6 +2210,6 @@ AJAX.registerOnload('server/status/monitor.js', function () { }); // Run the monitor once loaded -AJAX.registerOnload('server/status/monitor.js', function () { +window.AJAX.registerOnload('server/status/monitor.js', function () { $('a[href="#pauseCharts"]').trigger('click'); }); diff --git a/js/src/server/status/processes.js b/js/src/server/status/processes.js index 3235fd8e99..28e27aa753 100644 --- a/js/src/server/status/processes.js +++ b/js/src/server/status/processes.js @@ -161,7 +161,7 @@ var processList = { } }; -AJAX.registerOnload('server/status/processes.js', function () { +window.AJAX.registerOnload('server/status/processes.js', function () { processList.init(); // Bind event handler for kill_process $('#tableprocesslist').on( @@ -189,7 +189,7 @@ AJAX.registerOnload('server/status/processes.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/status/processes.js', function () { +window.AJAX.registerTeardown('server/status/processes.js', function () { $('#tableprocesslist').off('click', 'a.kill_process'); $('a#toggleRefresh').off('click'); $('#id_refreshRate').off('change'); diff --git a/js/src/server/status/queries.js b/js/src/server/status/queries.js index e4c05038a1..c8e4f1ea73 100644 --- a/js/src/server/status/queries.js +++ b/js/src/server/status/queries.js @@ -12,7 +12,7 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/status/queries.js', function () { +window.AJAX.registerTeardown('server/status/queries.js', function () { if (document.getElementById('serverstatusquerieschart') !== null) { var queryPieChart = $('#serverstatusquerieschart').data('queryPieChart'); if (queryPieChart) { @@ -21,7 +21,7 @@ AJAX.registerTeardown('server/status/queries.js', function () { } }); -AJAX.registerOnload('server/status/queries.js', function () { +window.AJAX.registerOnload('server/status/queries.js', function () { // Build query statistics chart var cdata = []; try { diff --git a/js/src/server/status/variables.js b/js/src/server/status/variables.js index 5b22e2f176..981f755324 100644 --- a/js/src/server/status/variables.js +++ b/js/src/server/status/variables.js @@ -7,14 +7,14 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/status/variables.js', function () { +window.AJAX.registerTeardown('server/status/variables.js', function () { $('#filterAlert').off('change'); $('#filterText').off('keyup'); $('#filterCategory').off('change'); $('#dontFormat').off('change'); }); -AJAX.registerOnload('server/status/variables.js', function () { +window.AJAX.registerOnload('server/status/variables.js', function () { // Filters for status variables var textFilter = null; var alertFilter = $('#filterAlert').prop('checked'); diff --git a/js/src/server/user_groups.js b/js/src/server/user_groups.js index 3119e5ec66..aa1a00eb03 100644 --- a/js/src/server/user_groups.js +++ b/js/src/server/user_groups.js @@ -8,14 +8,14 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/user_groups.js', function () { +window.AJAX.registerTeardown('server/user_groups.js', function () { $('#deleteUserGroupModal').off('show.bs.modal'); }); /** * Bind event handlers */ -AJAX.registerOnload('server/user_groups.js', function () { +window.AJAX.registerOnload('server/user_groups.js', function () { const deleteUserGroupModal = $('#deleteUserGroupModal'); deleteUserGroupModal.on('show.bs.modal', function (event) { const userGroupName = $(event.relatedTarget).data('user-group'); @@ -34,7 +34,7 @@ AJAX.registerOnload('server/user_groups.js', function () { 'userGroup': userGroupName, 'ajax_request': true, }, - AJAX.responseHandler + window.AJAX.responseHandler ); $('#deleteUserGroupModal').modal('hide'); diff --git a/js/src/server/variables.js b/js/src/server/variables.js index 6dca0a210e..02f03bb276 100644 --- a/js/src/server/variables.js +++ b/js/src/server/variables.js @@ -9,12 +9,12 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server/variables.js', function () { +window.AJAX.registerTeardown('server/variables.js', function () { $(document).off('click', 'a.editLink'); $('#serverVariables').find('.var-name').find('a img').remove(); }); -AJAX.registerOnload('server/variables.js', function () { +window.AJAX.registerOnload('server/variables.js', function () { var $saveLink = $('a.saveLink'); var $cancelLink = $('a.cancelLink'); diff --git a/js/src/setup/ajax.js b/js/src/setup/ajax.js index ae27129e64..c3293a8b3b 100644 --- a/js/src/setup/ajax.js +++ b/js/src/setup/ajax.js @@ -2,7 +2,7 @@ /** * Dummy implementation of the ajax page loader */ -var AJAX = { +window.AJAX = { registerOnload: function (idx, func) { $(func); }, diff --git a/js/src/sql.js b/js/src/sql.js index bcd70ee9e9..d69c6a277c 100644 --- a/js/src/sql.js +++ b/js/src/sql.js @@ -401,7 +401,7 @@ const insertValueQuery = function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('sql.js', function () { +window.AJAX.registerTeardown('sql.js', function () { $(document).off('click', 'a.delete_row.ajax'); $(document).off('submit', '.bookmarkQueryForm'); $('input#bkm_label').off('input'); @@ -451,7 +451,7 @@ AJAX.registerTeardown('sql.js', function () { * @name document.ready * @memberOf jQuery */ -AJAX.registerOnload('sql.js', function () { +window.AJAX.registerOnload('sql.js', function () { if (codeMirrorEditor || document.sqlform) { Sql.setShowThisQuery(); } @@ -806,7 +806,7 @@ AJAX.registerOnload('sql.js', function () { }, null ); - AJAX.handleMenu.replace(data.menu); + window.AJAX.handleMenu.replace(data.menu); } if (data.params) { @@ -920,8 +920,8 @@ AJAX.registerOnload('sql.js', function () { var argsep = CommonParams.get('arg_separator'); var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; Functions.ajaxShowMessage(); - AJAX.source = $form; - $.post($form.attr('action'), submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post($form.attr('action'), submitData, window.AJAX.responseHandler); }; if (! $(this).is(':checked')) { // already showing all rows @@ -1017,7 +1017,7 @@ AJAX.registerOnload('sql.js', function () { var argsep = CommonParams.get('arg_separator'); var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep; Functions.ajaxShowMessage(); - AJAX.source = $form; + window.AJAX.source = $form; var url; if (action === 'edit') { @@ -1034,7 +1034,7 @@ AJAX.registerOnload('sql.js', function () { return; } - $.post(url, submitData, AJAX.responseHandler); + $.post(url, submitData, window.AJAX.responseHandler); }); $(document).on('submit', '.maxRowsForm', function () { @@ -1212,7 +1212,7 @@ Sql.checkSavedQuery = function () { } }; -AJAX.registerOnload('sql.js', function () { +window.AJAX.registerOnload('sql.js', function () { $('body').on('click', 'a.browse_foreign', function (e) { e.preventDefault(); Sql.browseForeignDialog($(this)); @@ -1312,7 +1312,7 @@ Sql.initProfilingTables = function () { }); }; -AJAX.registerOnload('sql.js', function () { +window.AJAX.registerOnload('sql.js', function () { Sql.makeProfilingChart(); Sql.initProfilingTables(); }); diff --git a/js/src/table/change.js b/js/src/table/change.js index 03473c9bff..652401752e 100644 --- a/js/src/table/change.js +++ b/js/src/table/change.js @@ -411,7 +411,7 @@ function verificationsAfterFieldChange (urlField, multiEdit, theType) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/change.js', function () { +window.AJAX.registerTeardown('table/change.js', function () { $(document).off('click', 'span.open_gis_editor'); $(document).off('click', 'input[name^=\'insert_ignore_\']'); $(document).off('click', 'input[name=\'gis_data[save]\']'); @@ -427,7 +427,7 @@ AJAX.registerTeardown('table/change.js', function () { * Submit Data to be inserted into the table. * Restart insertion with 'N' rows. */ -AJAX.registerOnload('table/change.js', function () { +window.AJAX.registerOnload('table/change.js', function () { if ($('#insertForm').length) { // validate the comment form when it is submitted $('#insertForm').validate(); @@ -827,7 +827,7 @@ function addNewContinueInsertionFields (event) { * Displays alert if data loss possible on decrease * of rows. */ - var checkLock = jQuery.isEmptyObject(AJAX.lockedTargets); + var checkLock = jQuery.isEmptyObject(window.AJAX.lockedTargets); if (checkLock || confirm(Messages.strConfirmRowChange) === true) { while (currRows > targetRows) { $('input[id^=insert_ignore]').last() diff --git a/js/src/table/chart.js b/js/src/table/chart.js index 8186958c88..3690a10d09 100644 --- a/js/src/table/chart.js +++ b/js/src/table/chart.js @@ -236,7 +236,7 @@ function onDataSeriesChange () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/chart.js', function () { +window.AJAX.registerTeardown('table/chart.js', function () { $('input[name="chartType"]').off('click'); $('#barStackedCheckbox').off('click'); $('#seriesColumnCheckbox').off('click'); @@ -251,7 +251,7 @@ AJAX.registerTeardown('table/chart.js', function () { $('#tblchartform').off('submit'); }); -AJAX.registerOnload('table/chart.js', function () { +window.AJAX.registerOnload('table/chart.js', function () { // handle manual resize $('#resizer').on('resizestop', function () { // make room so that the handle will still appear diff --git a/js/src/table/find_replace.js b/js/src/table/find_replace.js index 05cbc086b8..51895c0e5a 100644 --- a/js/src/table/find_replace.js +++ b/js/src/table/find_replace.js @@ -1,7 +1,7 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/find_replace.js', function () { +window.AJAX.registerTeardown('table/find_replace.js', function () { $('#find_replace_form').off('submit'); $('#toggle_find').off('click'); }); @@ -9,7 +9,7 @@ AJAX.registerTeardown('table/find_replace.js', function () { /** * Bind events */ -AJAX.registerOnload('table/find_replace.js', function () { +window.AJAX.registerOnload('table/find_replace.js', function () { $('<div id="toggle_find_div"><a id="toggle_find"></a></div>') .insertAfter('#find_replace_form') .hide(); diff --git a/js/src/table/gis_visualization.js b/js/src/table/gis_visualization.js index 072147b945..43d47d8159 100644 --- a/js/src/table/gis_visualization.js +++ b/js/src/table/gis_visualization.js @@ -182,7 +182,7 @@ function onGisMouseWheel (event) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/gis_visualization.js', function () { +window.AJAX.registerTeardown('table/gis_visualization.js', function () { $(document).off('click', '#choice'); $(document).off('dragstart', 'svg'); $(document).off('mouseup', 'svg'); @@ -204,7 +204,7 @@ AJAX.registerTeardown('table/gis_visualization.js', function () { } }); -AJAX.registerOnload('table/gis_visualization.js', function () { +window.AJAX.registerOnload('table/gis_visualization.js', function () { // If we are in GIS visualization, initialize it if ($('#gis_div').length > 0) { initGISVisualization(); diff --git a/js/src/table/operations.js b/js/src/table/operations.js index 981cac62cb..4085befd97 100644 --- a/js/src/table/operations.js +++ b/js/src/table/operations.js @@ -1,7 +1,7 @@ /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/operations.js', function () { +window.AJAX.registerTeardown('table/operations.js', function () { $(document).off('submit', '#copyTable.ajax'); $(document).off('submit', '#moveTableForm'); $(document).off('submit', '#tableOptionsForm'); @@ -61,7 +61,7 @@ var confirmAndPost = function (linkObject, action) { * jQuery coding for 'Table operations'. Used on /table/operations * Attach Ajax Event handlers for Table operations */ -AJAX.registerOnload('table/operations.js', function () { +window.AJAX.registerOnload('table/operations.js', function () { /** * Ajax action for submitting the "Copy table" */ @@ -241,8 +241,8 @@ AJAX.registerOnload('table/operations.js', function () { var argsep = CommonParams.get('arg_separator'); var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; Functions.ajaxShowMessage(Messages.strProcessingRequest); - AJAX.source = $form; - $.post($form.attr('action'), submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post($form.attr('action'), submitData, window.AJAX.responseHandler); } if ($('#partitionOperationRadioDrop').is(':checked')) { diff --git a/js/src/table/relation.js b/js/src/table/relation.js index ef1afcae5e..61b460b64c 100644 --- a/js/src/table/relation.js +++ b/js/src/table/relation.js @@ -126,7 +126,7 @@ TableRelation.getDropdownValues = function ($dropdown) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/relation.js', function () { +window.AJAX.registerTeardown('table/relation.js', function () { $('body').off('change', 'select[name^="destination_db"], ' + 'select[name^="destination_table"], ' + @@ -138,7 +138,7 @@ AJAX.registerTeardown('table/relation.js', function () { $('a.drop_foreign_key_anchor.ajax').off('click'); }); -AJAX.registerOnload('table/relation.js', function () { +window.AJAX.registerOnload('table/relation.js', function () { /** * Ajax event handler to fetch table/column dropdown values. */ diff --git a/js/src/table/select.js b/js/src/table/select.js index 0dc0946ce4..123df75d0c 100644 --- a/js/src/table/select.js +++ b/js/src/table/select.js @@ -45,7 +45,7 @@ TableSelect.checkIfDataTypeNumericOrDate = function (dataType) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/select.js', function () { +window.AJAX.registerTeardown('table/select.js', function () { $('#togglesearchformlink').off('click'); $(document).off('submit', '#tbl_search_form.ajax'); $('select.geom_func').off('change'); @@ -53,7 +53,7 @@ AJAX.registerTeardown('table/select.js', function () { $('body').off('change', 'select[name*="criteriaColumnOperators"]'); // Fix for bug #13778, changed 'click' to 'change' }); -AJAX.registerOnload('table/select.js', function () { +window.AJAX.registerOnload('table/select.js', function () { /** * Prepare a div containing a link, otherwise it's incorrectly displayed * after a couple of clicks diff --git a/js/src/table/structure.js b/js/src/table/structure.js index 3d98175e69..1e50a3d389 100644 --- a/js/src/table/structure.js +++ b/js/src/table/structure.js @@ -45,7 +45,7 @@ function checkFirst () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/structure.js', function () { +window.AJAX.registerTeardown('table/structure.js', function () { $(document).off('click', 'a.drop_column_anchor.ajax'); $(document).off('click', 'a.add_key.ajax'); $(document).off('click', '#move_columns_anchor'); @@ -55,7 +55,7 @@ AJAX.registerTeardown('table/structure.js', function () { $(document).off('click', '#remove_partitioning.ajax'); }); -AJAX.registerOnload('table/structure.js', function () { +window.AJAX.registerOnload('table/structure.js', function () { // Re-initialize variables. primaryIndexes = []; indexes = []; @@ -271,11 +271,11 @@ AJAX.registerOnload('table/structure.js', function () { $thisAnchor.confirm(question, $thisAnchor.attr('href'), function (url) { Functions.ajaxShowMessage(); - AJAX.source = $this; + window.AJAX.source = $this; var params = Functions.getJsConfirmCommonParam(this, $thisAnchor.getPostData()); params += CommonParams.get('arg_separator') + 'ajax_page_request=1'; - $.post(url, params, AJAX.responseHandler); + $.post(url, params, window.AJAX.responseHandler); }); }); // end Add key @@ -399,9 +399,9 @@ AJAX.registerOnload('table/structure.js', function () { var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true'; Functions.ajaxShowMessage(); - AJAX.source = $form; + window.AJAX.source = $form; - $.post(this.formAction, submitData, AJAX.responseHandler); + $.post(this.formAction, submitData, window.AJAX.responseHandler); }); /** @@ -414,8 +414,8 @@ AJAX.registerOnload('table/structure.js', function () { function submitPartitionAction (url) { var params = 'ajax_request=true&ajax_page_request=true&' + $link.getPostData(); Functions.ajaxShowMessage(); - AJAX.source = $link; - $.post(url, params, AJAX.responseHandler); + window.AJAX.source = $link; + $.post(url, params, window.AJAX.responseHandler); } if ($link.is('#partition_action_DROP')) { @@ -444,8 +444,8 @@ AJAX.registerOnload('table/structure.js', function () { 'ajax_page_request' : true }, $link.getPostData()); Functions.ajaxShowMessage(); - AJAX.source = $link; - $.post(url, params, AJAX.responseHandler); + window.AJAX.source = $link; + $.post(url, params, window.AJAX.responseHandler); }); }); diff --git a/js/src/table/tracking.js b/js/src/table/tracking.js index 2656015ab3..07b564df69 100644 --- a/js/src/table/tracking.js +++ b/js/src/table/tracking.js @@ -1,7 +1,7 @@ /** * Unbind all event handlers before tearing down the page */ -AJAX.registerTeardown('table/tracking.js', function () { +window.AJAX.registerTeardown('table/tracking.js', function () { $('body').off('click', '#versionsForm.ajax button[name="submit_mult"], #versionsForm.ajax input[name="submit_mult"]'); $('body').off('click', 'a.delete_version_anchor.ajax'); $('body').off('click', 'a.delete_entry_anchor.ajax'); @@ -10,7 +10,7 @@ AJAX.registerTeardown('table/tracking.js', function () { /** * Bind event handlers */ -AJAX.registerOnload('table/tracking.js', function () { +window.AJAX.registerOnload('table/tracking.js', function () { $('#versions tr').first().find('th').append($('<div class="sorticon"></div>')); $('#versions').tablesorter({ sortList: [[1, 0]], @@ -60,13 +60,13 @@ AJAX.registerOnload('table/tracking.js', function () { var question = Messages.strDeleteTrackingVersionMultiple; $button.confirm(question, $form.attr('action'), function (url) { Functions.ajaxShowMessage(); - AJAX.source = $form; - $.post(url, submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post(url, submitData, window.AJAX.responseHandler); }); } else { Functions.ajaxShowMessage(); - AJAX.source = $form; - $.post($form.attr('action'), submitData, AJAX.responseHandler); + window.AJAX.source = $form; + $.post($form.attr('action'), submitData, window.AJAX.responseHandler); } }); @@ -79,11 +79,11 @@ AJAX.registerOnload('table/tracking.js', function () { var question = Messages.strDeleteTrackingVersion; $anchor.confirm(question, $anchor.attr('href'), function (url) { Functions.ajaxShowMessage(); - AJAX.source = $anchor; + window.AJAX.source = $anchor; var argSep = CommonParams.get('arg_separator'); var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData()); params += argSep + 'ajax_page_request=1'; - $.post(url, params, AJAX.responseHandler); + $.post(url, params, window.AJAX.responseHandler); }); }); @@ -96,11 +96,11 @@ AJAX.registerOnload('table/tracking.js', function () { var question = Messages.strDeletingTrackingEntry; $anchor.confirm(question, $anchor.attr('href'), function (url) { Functions.ajaxShowMessage(); - AJAX.source = $anchor; + window.AJAX.source = $anchor; var argSep = CommonParams.get('arg_separator'); var params = Functions.getJsConfirmCommonParam(this, $anchor.getPostData()); params += argSep + 'ajax_page_request=1'; - $.post(url, params, AJAX.responseHandler); + $.post(url, params, window.AJAX.responseHandler); }); }); }); diff --git a/js/src/table/zoom_plot_jqplot.js b/js/src/table/zoom_plot_jqplot.js index b4ba935b48..04aa925578 100644 --- a/js/src/table/zoom_plot_jqplot.js +++ b/js/src/table/zoom_plot_jqplot.js @@ -101,7 +101,7 @@ function getType (field) { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('table/zoom_plot_jqplot.js', function () { +window.AJAX.registerTeardown('table/zoom_plot_jqplot.js', function () { $('#tableid_0').off('change'); $('#tableid_1').off('change'); $('#tableid_2').off('change'); @@ -114,7 +114,7 @@ AJAX.registerTeardown('table/zoom_plot_jqplot.js', function () { $('div#querychart').off('jqplotDataClick'); }); -AJAX.registerOnload('table/zoom_plot_jqplot.js', function () { +window.AJAX.registerOnload('table/zoom_plot_jqplot.js', function () { var currentChart = null; var searchedDataKey = null; var xLabel = $('#tableid_0').val(); diff --git a/js/src/transformations/image_upload.js b/js/src/transformations/image_upload.js index 54fbf14534..6bbe535f8b 100644 --- a/js/src/transformations/image_upload.js +++ b/js/src/transformations/image_upload.js @@ -4,7 +4,7 @@ * @package PhpMyAdmin */ -AJAX.registerOnload('transformations/image_upload.js', function () { +window.AJAX.registerOnload('transformations/image_upload.js', function () { // Change thumbnail when image file is selected // through file upload dialog $('input.image-upload').on('change', function () { @@ -22,6 +22,6 @@ AJAX.registerOnload('transformations/image_upload.js', function () { /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('transformations/image_upload.js', function () { +window.AJAX.registerTeardown('transformations/image_upload.js', function () { $('input.image-upload').off('change'); }); diff --git a/js/src/transformations/json.js b/js/src/transformations/json.js index 4326a2eda3..0a7f5b8221 100644 --- a/js/src/transformations/json.js +++ b/js/src/transformations/json.js @@ -1,7 +1,7 @@ /** * JSON syntax highlighting transformation plugin */ -AJAX.registerOnload('transformations/json.js', function () { +window.AJAX.registerOnload('transformations/json.js', function () { var $elm = $('#page_content').find('code.json'); $elm.each(function () { var $json = $(this); diff --git a/js/src/transformations/json_editor.js b/js/src/transformations/json_editor.js index 471049644e..53b6f45946 100644 --- a/js/src/transformations/json_editor.js +++ b/js/src/transformations/json_editor.js @@ -3,7 +3,7 @@ * * @package PhpMyAdmin */ -AJAX.registerOnload('transformations/json_editor.js', function () { +window.AJAX.registerOnload('transformations/json_editor.js', function () { $('textarea.transform_json_editor').each(function () { CodeMirror.fromTextArea(this, { lineNumbers: true, diff --git a/js/src/transformations/sql_editor.js b/js/src/transformations/sql_editor.js index 0e0f7fa2e7..17d38e3e26 100644 --- a/js/src/transformations/sql_editor.js +++ b/js/src/transformations/sql_editor.js @@ -3,7 +3,7 @@ * * @package PhpMyAdmin */ -AJAX.registerOnload('transformations/sql_editor.js', function () { +window.AJAX.registerOnload('transformations/sql_editor.js', function () { $('textarea.transform_sql_editor').each(function () { Functions.getSqlEditor($(this), {}, 'both'); }); diff --git a/js/src/transformations/xml.js b/js/src/transformations/xml.js index b354f0bd29..129044eeef 100644 --- a/js/src/transformations/xml.js +++ b/js/src/transformations/xml.js @@ -1,7 +1,7 @@ /** * XML syntax highlighting transformation plugin */ -AJAX.registerOnload('transformations/xml.js', function () { +window.AJAX.registerOnload('transformations/xml.js', function () { var $elm = $('#page_content').find('code.xml'); $elm.each(function () { var $json = $(this); diff --git a/js/src/transformations/xml_editor.js b/js/src/transformations/xml_editor.js index 35d8b59cab..e65476c590 100644 --- a/js/src/transformations/xml_editor.js +++ b/js/src/transformations/xml_editor.js @@ -3,7 +3,7 @@ * * @package PhpMyAdmin */ -AJAX.registerOnload('transformations/xml_editor.js', function () { +window.AJAX.registerOnload('transformations/xml_editor.js', function () { $('textarea.transform_xml_editor').each(function () { CodeMirror.fromTextArea(this, { lineNumbers: true, diff --git a/js/src/u2f.js b/js/src/u2f.js index 17af42f767..44655b14f6 100644 --- a/js/src/u2f.js +++ b/js/src/u2f.js @@ -1,6 +1,6 @@ /* global u2f */ // js/vendor/u2f-api-polyfill.js -AJAX.registerOnload('u2f.js', function () { +window.AJAX.registerOnload('u2f.js', function () { var $inputReg = $('#u2f_registration_response'); if ($inputReg.length > 0) { var $formReg = $inputReg.parents('form'); diff --git a/templates/scripts.twig b/templates/scripts.twig index 5574306b88..ddaf2748a9 100644 --- a/templates/scripts.twig +++ b/templates/scripts.twig @@ -8,7 +8,7 @@ // <![CDATA[ {{ code|raw }} {% if files is not empty %} -AJAX.scriptHandler +window.AJAX.scriptHandler {% for file in files %} .add('{{ file.filename|escape_js_string }}', {{ file.has_onload ? 1 : 0 }}) {% endfor %} @@ -16,7 +16,7 @@ AJAX.scriptHandler $(function() { {% for file in files %} {% if file.has_onload %} - AJAX.fireOnload('{{ file.filename|escape_js_string }}'); + window.AJAX.fireOnload('{{ file.filename|escape_js_string }}'); {% endif %} {% endfor %} }); diff --git a/templates/sql/profiling_chart.twig b/templates/sql/profiling_chart.twig index 188e731d01..a56d4d957f 100644 --- a/templates/sql/profiling_chart.twig +++ b/templates/sql/profiling_chart.twig @@ -92,7 +92,7 @@ <div id="profilingchart" class="hide"></div> <script type="text/javascript"> - AJAX.registerOnload('sql.js', function () { + window.AJAX.registerOnload('sql.js', function () { Sql.makeProfilingChart(); Sql.initProfilingTables(); }); diff --git a/test/classes/ScriptsTest.php b/test/classes/ScriptsTest.php index 30ad0a4578..37f5e838af 100644 --- a/test/classes/ScriptsTest.php +++ b/test/classes/ScriptsTest.php @@ -52,7 +52,7 @@ class ScriptsTest extends AbstractTestCase $actual ); $this->assertStringContainsString('.add(\'common.js\', 1)', $actual); - $this->assertStringContainsString('AJAX.fireOnload(\'common.js\')', $actual); + $this->assertStringContainsString('window.AJAX.fireOnload(\'common.js\')', $actual); } /** diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index f1d94b304e..3689609224 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -1073,7 +1073,7 @@ JS; $this->webDriver->executeAsyncScript( 'var callback = arguments[arguments.length - 1];' . 'function startWaitingForAjax() {' - . ' if (! AJAX.active) {' + . ' if (! window.AJAX.active) {' . ' callback();' . ' } else {' . ' setTimeout(startWaitingForAjax, 200);' |