1jQuery(function ($) { 2 'use strict'; 3 4 function initializeTooltips() { 5 const tooltipConfig = { 6 'add-layout': 'Ajouter un bloc au-dessus', 7 'duplicate-layout': 'Dupliquer le bloc', 8 'remove-layout': 'Enlever le bloc', 9 'collapse-layout': 'Ouvrir/Fermer' 10 }; 11 12 const flexibleContentField = '.acf-field[data-type="flexible_content"]'; 13 14 Object.entries(tooltipConfig).forEach(([dataName, title]) => { 15 $(`${flexibleContentField} .acf-js-tooltip[data-name="${dataName}"]`) 16 .attr('title', title); 17 }); 18 } 19 20 class DateController { 21 constructor() { 22 this.fields = { 23 publish: '.acf-field[data-name="publish_date"] .acf-date-picker input.input', 24 trash: '.acf-field[data-name="trash_date"] .acf-date-picker input.input', 25 startHome: '.acf-field[data-name="start_home_display"] .acf-date-picker input.input', 26 endHome: '.acf-field[data-name="end_home_display"] .acf-date-picker input.input' 27 }; 28 29 this.init(); 30 } 31 32 transformDate(dateString) { 33 if (!dateString) return null; 34 35 const [day, month, year] = dateString.split('/'); 36 return new Date(parseInt(year), parseInt(month) - 1, parseInt(day)); 37 } 38 39 addDays(date, days) { 40 const result = new Date(date); 41 result.setDate(result.getDate() + days); 42 return result; 43 } 44 45 setDateConstraints(selector, options) { 46 $(selector).datepicker('option', options); 47 } 48 49 updateFromPublishDate(publishDate) { 50 if (!publishDate) return; 51 52 const publishDateObj = this.transformDate(publishDate); 53 if (!publishDateObj) return; 54 55 this.setDateConstraints(this.fields.trash, { 56 minDate: this.addDays(publishDateObj, 1) 57 }); 58 59 this.setDateConstraints(this.fields.startHome, { 60 minDate: publishDateObj 61 }); 62 63 this.setDateConstraints(this.fields.endHome, { 64 minDate: this.addDays(publishDateObj, 1) 65 }); 66 } 67 68 updateFromTrashDate(trashDate) { 69 if (!trashDate) return; 70 71 const trashDateObj = this.transformDate(trashDate); 72 if (!trashDateObj) return; 73 74 this.setDateConstraints(this.fields.startHome, { 75 maxDate: this.addDays(trashDateObj, -1) 76 }); 77 78 this.setDateConstraints(this.fields.endHome, { 79 maxDate: trashDateObj 80 }); 81 } 82 83 updateFromStartHomeDate(startHomeDate) { 84 if (!startHomeDate) return; 85 86 const startHomeDateObj = this.transformDate(startHomeDate); 87 if (!startHomeDateObj) return; 88 89 this.setDateConstraints(this.fields.endHome, { 90 minDate: this.addDays(startHomeDateObj, 1) 91 }); 92 } 93 94 init() { 95 const publishDate = $(this.fields.publish).val(); 96 const trashDate = $(this.fields.trash).val(); 97 98 this.updateFromPublishDate(publishDate); 99 this.updateFromTrashDate(trashDate); 100 101 $(this.fields.publish).on('change', (e) => { 102 this.updateFromPublishDate(e.target.value); 103 }); 104 105 $(this.fields.trash).on('change', (e) => { 106 this.updateFromTrashDate(e.target.value); 107 }); 108 109 $(this.fields.startHome).on('change', (e) => { 110 this.updateFromStartHomeDate(e.target.value); 111 }); 112 } 113 } 114 115 initializeTooltips(); 116 new DateController(); 117}); 118 119function initializeCategoryHandler() { 120 const categoryField = document.querySelector('[data-key="field_5f6b1de7581ee"]'); 121 122 if (!categoryField) return; 123 124 function handleCategoryChange(event) { 125 const checkedCategories = event.currentTarget.querySelectorAll('ul.children [type="checkbox"]:checked'); 126 127 checkedCategories.forEach(selectedCategory => { 128 const parentCheckbox = selectedCategory 129 .closest('ul.children') 130 .closest('li') 131 .querySelector('[type="checkbox"]'); 132 133 if (parentCheckbox && !parentCheckbox.checked) { 134 parentCheckbox.checked = true; 135 136 const reloadContainer = parentCheckbox.closest('ul.acf-bl').closest('li'); 137 if (reloadContainer) { 138 categoryField.dispatchEvent(new Event('change')); 139 } 140 } 141 }); 142 } 143 144 categoryField.addEventListener('change', handleCategoryChange); 145} 146 147function ready(callback) { 148 if (document.readyState !== 'loading') { 149 callback(); 150 } else { 151 document.addEventListener('DOMContentLoaded', callback); 152 } 153} 154 155ready(initializeCategoryHandler); 156/** 157 * Gestion dynamique du choix "custom_filters" dans le radio content_choice 158 * selon le CPT sélectionné dans publications_type et les filtres custom disponibles. 159 */ 160(function () { 161 'use strict'; 162
163 const cptsWithFilters = (typeof ACFScriptParams !== 'undefined' && ACFScriptParams.cptsWithCustomFilters) 164 ? ACFScriptParams.cptsWithCustomFilters 165 : []; 166 167 function updateCustomFiltersRadio($select) { 168 const selectedValue = $select.val(); 169 const hasFilters = cptsWithFilters.includes(selectedValue); 170 171 // Remonter au groupe parent commun 172 const $group = $select.closest('.acf-fields'); 173 const $contentChoiceField = $group.find('[data-key="field_5e7b311144aff"]'); 174 if (!$contentChoiceField.length) return; 175 176 const $customFiltersLi = $contentChoiceField.find('input[value="custom_filters"]').closest('li'); 177 if (!$customFiltersLi.length) return; 178 179 if (hasFilters) { 180 $customFiltersLi.show(); 181 } else { 182 const $radio = $customFiltersLi.find('input[type="radio"]'); 183 if ($radio.prop('checked')) { 184 $contentChoiceField.find('input[value="terms"]').prop('checked', true).trigger('change'); 185 } 186 $customFiltersLi.hide(); 187 } 188 } 189 190 function initContext($context) { 191 $context.find('[data-name="publications_type"] select').each(function () { 192 const $select = jQuery(this); 193 updateCustomFiltersRadio($select); 194 $select.off('change.customFilters').on('change.customFilters', function () { 195 updateCustomFiltersRadio(jQuery(this)); 196 }); 197 }); 198 } 199 200 acf.addAction('ready', function () { 201 initContext(jQuery(document)); 202 }); 203 204 acf.addAction('append', function ($el) { 205 initContext($el); 206 }); 207 208}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.