/** * 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);