Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /share/CACHEDEV1_DATA/Web/dev.rencontresmarches2027.fr/www/app/_config.php on line 50
Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /share/CACHEDEV1_DATA/Web/dev.rencontresmarches2027.fr/www/app/_config.php on line 50
Warning: Cannot modify header information - headers already sent by (output started at /share/CACHEDEV1_DATA/Web/dev.rencontresmarches2027.fr/www/app/_config.php:50) in /share/CACHEDEV1_DATA/Web/dev.rencontresmarches2027.fr/www/app/js/admin/myevent_modal.php on line 7
const myEventModal = new bootstrap.Modal(document.getElementById('myevent_modal'), {
keyboard: false, // Par défaut, Bootstrap gère la touche ESC
backdrop: 'static' // Empêche la fermeture en cliquant en dehors
});
function alertModal(titre, contenu, buttons = null, close = true) {
let $modal = $('#myevent_modal');
if ($modal.is(':visible')) {
$modal.trigger('hidden.bs.modal');
}
if (close === true && $modal.find('.modal-header .btn-close').length === 0) {
$modal.find('.modal-header').append('');
}
// Mise à jour du contenu
$modal.find('.modal-title').html(titre);
$modal.find('.modal-body').html(contenu);
//contenu.find('form input').first().focus();
// Affiche le modal s'il n'est pas déjà visible
if (!$modal.is(':visible')) {
myEventModal.show();
}
// Gestion des boutons
let $footer = $modal.find('.modal-footer').empty().toggle(!!buttons);
if (buttons) {
$.each(buttons, (_, btn) => $footer.append(modalButtons(btn)));
}
}
function modalButtons({ aspect, text, dismiss = null, classaction = '', action = null }) {
return ``;
}
$('#myevent_modal').on('hidden.bs.modal', function () {
let $modal = $(this);
let $body = $('body');
// Supprimer les data-* sauf ceux à conserver
console.log(!$modal.is(':visible'));
if (!$modal.is(':visible')) {
Object.keys($modal.data()).forEach(key => {
if (!['bsBackdrop', 'bsKeyboard'].includes(key)) {
$modal.removeData(key);
}
});
}
// Réinitialiser le contenu du modal
$modal.find('.modal-title, .modal-body, .modal-footer').empty();
$modal.find('.modal-header .btn-close').remove();
});
$('#myevent_modal').on('shown.bs.modal', function () {
let $modal = $(this);
$modal.find('.modal-body').find('form input').first().focus();
});