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.
This commit is contained in:
2026-06-18 16:36:43 -04:00
parent 514fae950c
commit cdf4e5188a
2 changed files with 57 additions and 55 deletions

View File

@ -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('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
$preloader.show();
pendingStatutXhr = $.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', {
a: 'par_statut_course',
par_id: intParId,
par_statut_course: strCode,
lang: '<?php echo $strLangue; ?>'
}, 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('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
$preloader.show();
pendingStatutXhr = $.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', {
a: 'par_statut_course',
par_id: intParId,
par_statut_course: strCode,
lang: '<?php echo $strLangue; ?>'
}, 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'});

View File

@ -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');