Refactoring : sécurité (XSS), découpage en modules inc/* et js/admin/*, IDs résolus par slug, perf (caches, cron Gravatar, assets auto-hébergés), tests

This commit is contained in:
2026-06-10 21:30:25 +02:00
parent e6b73df516
commit 9280c3b9ce
44 changed files with 3209 additions and 2907 deletions

View File

@@ -0,0 +1,49 @@
/**
* Modale Pods de création de séance (URL contenant pods_modal) :
* verrouille la catégorie sur « Séance de séminaire ».
* Dépend de admin-base.js (window.ThalimAdmin) — enqueue conditionnel.
*/
(function($) {
'use strict';
var TA = window.ThalimAdmin;
var CONFIG = TA.CONFIG;
var safeRun = TA.safeRun;
$(document).ready(function() {
if (!TA.isPodsModal()) return;
var lockSeanceCategory = function() {
var seanceCat = CONFIG.seanceCategoryId;
var itemId = $('#post_ID').val();
if (window.PodsDFV && itemId) {
window.PodsDFV.setFieldValue('post', itemId, 'categorie', seanceCat, 0);
}
// Lock category select to the séance category in iframe —
// delay to run after Pods React re-render
setTimeout(function() {
var $select = $(CONFIG.categorySelect);
if ($select.length) {
$select.find('option').each(function() {
this.disabled = this.value !== seanceCat;
});
$select.val(seanceCat);
}
safeRun('updatePostboxVisibility', TA.updatePostboxVisibility);
}, 200);
};
// Dans l'iframe de la modale, window.load peut déjà être passé au moment
// où ce code s'exécute : s'abonner à un load déjà émis ne rejoue rien.
// On exécute donc tout de suite si la page est déjà chargée.
if (document.readyState === 'complete') {
safeRun('lockSeanceCategory', lockSeanceCategory);
} else {
$(window).on('load', function() {
safeRun('lockSeanceCategory', lockSeanceCategory);
});
}
});
})(jQuery);