From cdf4e5188ab93ddbb59caad7a5276781608bb53e Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 18 Jun 2026 16:36:43 -0400 Subject: [PATCH] Refactor mobile registration status management; enhance AJAX handling and update version code This commit encapsulates the refactoring of the mobile registration status management by encapsulating the logic within an immediately invoked function expression (IIFE) for better organization. The AJAX handling for status changes has been improved, ensuring smoother user interactions and error handling. The version code is incremented to 4.72.675 to reflect these updates, further enhancing the mobile user experience. --- inc_footer_scripts.php | 110 +++++++++++++++++++++-------------------- php/inc_settings.php | 2 +- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/inc_footer_scripts.php b/inc_footer_scripts.php index 6de23ed..f679373 100644 --- a/inc_footer_scripts.php +++ b/inc_footer_scripts.php @@ -1187,6 +1187,62 @@ if ($strLangue == 'fr') { break; } }); + + (function () { + var pendingStatutXhr = null; + var lastStatutParId = null; + + $('.inscr-mobile-statut-select').each(function () { + $(this).data('prev', $(this).val()); + }); + + $body.on('change', '.inscr-mobile-statut-select', function () { + var $select = $(this); + var $block = $select.closest('.inscr-mobile-field-block--statut'); + var intParId = $select.data('par_id'); + var strCode = $select.val(); + var strPrev = $select.data('prev'); + + if (!intParId || !strCode) { + return; + } + + if (pendingStatutXhr && lastStatutParId === intParId) { + pendingStatutXhr.abort(); + } + lastStatutParId = intParId; + $block.removeClass('inscr-mobile-statut--saved inscr-mobile-statut--error'); + + $preloader_text.html(''); + $preloader.show(); + + pendingStatutXhr = $.post('/ajax_promoteur.php', { + a: 'par_statut_course', + par_id: intParId, + par_statut_course: strCode, + lang: '' + }, function (result) { + pendingStatutXhr = null; + $preloader.fadeOut('slow'); + if (result && result.state === 'success') { + $select.data('prev', strCode); + $block.addClass('inscr-mobile-statut--saved'); + window.setTimeout(function () { + $block.removeClass('inscr-mobile-statut--saved'); + }, 1200); + } else { + $select.val(strPrev); + $block.addClass('inscr-mobile-statut--error'); + } + }, 'json').fail(function () { + pendingStatutXhr = null; + $preloader.fadeOut('slow'); + $select.val(strPrev); + $block.addClass('inscr-mobile-statut--error'); + }); + }); + })(); + $('#modal_teammates').on('show.bs.modal', function (event) { var button = $(event.relatedTarget); var modal = $(this); @@ -3454,60 +3510,6 @@ if ($strLangue == 'fr') { return; } - var $body = $('body'); - var pendingStatutXhr = null; - var lastStatutParId = null; - - $body.on('change', '.inscr-mobile-statut-select', function () { - var $select = $(this); - var $block = $select.closest('.inscr-mobile-field-block--statut'); - var intParId = $select.data('par_id'); - var strCode = $select.val(); - var strPrev = $select.data('prev'); - - if (!intParId || !strCode) { - return; - } - - if (pendingStatutXhr && lastStatutParId === intParId) { - pendingStatutXhr.abort(); - } - lastStatutParId = intParId; - $block.removeClass('inscr-mobile-statut--saved inscr-mobile-statut--error'); - - $preloader_text.html(''); - $preloader.show(); - - pendingStatutXhr = $.post('/ajax_promoteur.php', { - a: 'par_statut_course', - par_id: intParId, - par_statut_course: strCode, - lang: '' - }, function (result) { - pendingStatutXhr = null; - $preloader.fadeOut('slow'); - if (result && result.state === 'success') { - $select.data('prev', strCode); - $block.addClass('inscr-mobile-statut--saved'); - window.setTimeout(function () { - $block.removeClass('inscr-mobile-statut--saved'); - }, 1200); - } else { - $select.val(strPrev); - $block.addClass('inscr-mobile-statut--error'); - } - }, 'json').fail(function () { - pendingStatutXhr = null; - $preloader.fadeOut('slow'); - $select.val(strPrev); - $block.addClass('inscr-mobile-statut--error'); - }); - }); - - moduleInscr.querySelectorAll('.inscr-mobile-statut-select').forEach(function (el) { - el.dataset.prev = el.value; - }); - var params = new URLSearchParams(window.location.search); if (params.get('pec_id')) { moduleInscr.scrollIntoView({block: 'start'}); diff --git a/php/inc_settings.php b/php/inc_settings.php index 8493dfc..94fb1bd 100644 --- a/php/inc_settings.php +++ b/php/inc_settings.php @@ -7,7 +7,7 @@ * Constantes * * **************/ -define('_VERSION_CODE', '4.72.674'); +define('_VERSION_CODE', '4.72.675'); define('_DATE_CODE', '2026-06-18'); //MSIN-4290 define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');