1function updateLinkedOptions(parent, emptyVal) { 2 3 var tag = parent.prop("type"); 4 var name = parent.attr("name"); 5 var linkedIds = parent.attr("attrlinked"); 6 7 if (!linkedIds) return; 8 linkedIds = linkedIds.split(","); 9 10 // Get selected parent values 11 var selectedVals = []; 12 if (tag === "radio") { 13 var checked = $("input[name='" + name + "']:checked"); 14 if (checked.length) selectedVals.push(checked.val()); 15 } else if (tag === "checkbox") { 16 $("input[name='" + name + "']:checked").each(function () { 17 selectedVals.push($(this).val()); 18 }); 19 } else { 20 var val = parent.val(); 21 if (val) selectedVals.push(val); 22 } 23 24 var timeout_await = 250; 25 26 linkedIds.forEach(function (childId) { 27 setTimeout(function (childId) { 28 var childSelect = $("#field_" + childId); 29 if (childSelect.length && childSelect.is("select")) { 30 // Handle select children 31 childSelect.find("option").each(function () { 32 var parentVal = $(this).data("parent"); 33 if (!parentVal) return; 34 35 if (selectedVals.length === 0) { 36 $(this).hide(); 37 38 } else if (selectedVals.includes(parentVal.toString())) { 39 $(this).show(); 40 41 } else { 42 $(this).hide(); 43 44 if ($(this).is(":selected")) childSelect.val(""); 45 } 46 }); 47 childSelect.prop("disabled", false).removeClass("disabled-by-link"); 48 } else { 49 // Handle radio/checkbox children 50 var childInputs = $("input[name^='custom_form[radio_" + childId + "]'], input[name^='custom_form[checkbox_" + childId + "]']"); 51 if (!childInputs.length) return; 52 53 childInputs.each(function () { 54 var parentVal = $(this).data("parent"); 55 parentVal = parentVal ? parentVal.toString() : ""; 56 57 if (selectedVals.length === 0) { 58 $(this).closest(".table-row").hide(); 59 $(this).prop("disabled", true); 60 $(this).prop("checked", false).trigger("change"); 61 62 return; 63 } 64 65 if (selectedVals.includes(parentVal)) { 66 $(this).closest(".table-row").show(); 67 $(this).prop("disabled", false); 68 69 } else { 70 $(this).closest(".table-row").hide(); 71 $(this).prop("disabled", true); 72 $(this).prop("checked", false).trigger("change"); 73 74 } 75 }); 76 } 77 78 // Reset child select value if emptyVal=1 79 if (emptyVal == 1 && childSelect.length) { 80 childSelect.val(""); 81 setTimeout(function () { 82 childSelect.trigger("change"); 83 }, 100); 84 } 85 }, timeout_await, childId); 86 87 timeout_await += 350; // c'est le timeout le plus bas que j'ai reussi a atteindre pour plusieurs 88 89 }); 90} 91 92// Refresh all linked options on page load 93function refreshLinkedOptions() { 94 $(".check_link").each(function () { 95 updateLinkedOptions($(this), 0); 96 }); 97} 98refreshLinkedOptions(); 99 100// Run when parent changes 101$(document).on("change", ".check_link", function () { 102 updateLinkedOptions($(this), 1); 103}); 104 105 106/* 107VG-078350-6 108lors de ledition du profil cote site , on verifie les champs obligatoires non remplies à chaque fois qu'on clique sur une tab 109si des champs obligatoires sont vides on clone ces champs dans une modale bootstrap et on laffiche , 110on supprime les champs originaux du formulaire pour eviter les doublons 111on affiche la modale bootstrap avec les champs vides à remplir 112l'utilisateur peut fermer la modale en cliquant sur le bouton fermer qui recharge la page 113si il a rempli tous les champs obligatoires dans la modale on recharge la page avec la tab courante ouverte 114*/ 115function checkRequiredFields(tabContentId = null) { 116 let requiredFields = document.querySelectorAll( 117 "#" + tabContentId + " [required]", 118 ); 119 let modalBody = document.getElementById("modalBody"); 120 let missingFields = []; 121 let array_items_required = []; 122 requiredFields.forEach((field) => { 123 let tableName = field.getAttribute("table_name"); 124 let field_value = field.value; 125 if(field.type === "file"){ 126 let fieldIdParts = field.id.split("_"); 127 if(fieldIdParts.length > 1){ 128 let actualFieldId = "field_" + fieldIdParts[1]; 129 let hiddenInput = document.querySelector("input[type='hidden'][field_name='" + actualFieldId + "']"); 130 let valueHiddenInput = hiddenInput ? hiddenInput.value : null; 131 if (hiddenInput && (valueHiddenInput.trim() == "" || valueHiddenInput == null)) { 132 tableName = hiddenInput.getAttribute("table_name"); 133 let approbationElement = document.getElementById("field_for_field_" + fieldIdParts[1]); 134 if(approbationElement){ 135 field_value = approbationElement.getAttribute("new_value"); 136 } 137 } 138 } 139 } 140 else 141 { 142 //if table name is z_custom_field_data_approb , get value from element with id field_for_+field id 143 if(tableName === "z_custom_field_data_approb") 144 { 145 let approbationElement = document.getElementById("field_for_" + field.id); 146 if(approbationElement){ 147 field_value = approbationElement.getAttribute("new_value"); 148 } 149 } 150 } 151 152 if ( 153 field.type === "hidden" || 154 field.type === "password" || 155 (tableName === "z_custom_field_data_approb" && (field_value.trim() !== "")) || 156 field.name === "std[customers_gender_autre]" || 157 field.getAttribute("readonly") !== null 158 ) { 159 return; 160 } 161 162 let enter_check = false;
163 if ( 164 field.type === "radio" || 165 (field.type === "checkbox" && !field.disabled) 166 ) { 167 let item_check = document.getElementsByName(field.name); 168 let itemChecked = false; 169 item_check.forEach((item) => { 170 if (item.checked) { 171 itemChecked = true; 172 } 173 }); 174 if (!itemChecked) { 175 if (!array_items_required.includes(field.name)) { 176 array_items_required.push(field.name); 177 enter_check = true; 178 if (field.classList.contains("required")) { 179 field.setAttribute("required", "required"); 180 } 181 } 182 } 183 } 184 if ( 185 (((!field.value || field.value.trim() === "") && 186 field.type !== "radio" && 187 field.type !== "checkbox") || 188 (enter_check === true && 189 (field.type === "radio" || field.type === "checkbox"))) && 190 field.getAttribute("required") == "required" && 191 !field.disabled 192 ) { 193 let fieldClone = null; 194 if (field.closest(".row")) { 195 fieldClone = field.closest(".row").cloneNode(true); 196 } 197 // if the name of the field has custom_form in it then instead of closest row do closest <tr> 198 // or if field type is file 199 if (field.name.includes("custom_form") || field.type === "file") { 200 fieldClone = field.closest("tr").cloneNode(true); 201 // remove origin <tr> 202 field.closest("tr").remove(); 203 } 204 if (field.name.includes("std") || field.name.includes("addr")) { 205 fieldClone = field.closest(".form-group").cloneNode(true); 206 if (field.name.includes("addr")) { 207 // find closest h3 208 // find the parent 'section' of the field not just the closest 209 let addressHeader = field 210 .closest(".sectionAddrInscrip") 211 .querySelector("h3"); 212 // add this header inside the <label> of the fieldClone 213 if (addressHeader && fieldClone) { 214 let label = fieldClone.querySelector("label"); 215 if (label) { 216 label.innerHTML = 217 addressHeader.innerText + " - " + label.innerHTML; 218 } 219 } 220 // also in the class of .form-group add 'col-12' to make it full width 221 fieldClone.classList.add("col-md-12"); 222 fieldClone.classList.add("d-flex"); 223 fieldClone.classList.add("px-0"); 224 // find .form-cintrol inside fieldClone and add class flex-grow-1 225 let formControl = fieldClone.querySelector(".form-control"); 226 if (formControl) { 227 formControl.classList.add("w-50"); 228 } 229 // same thing with labels 230 let label = fieldClone.querySelector("label"); 231 if (label) { 232 label.classList.add("w-50"); 233 } 234 } 235 236 field.closest(".form-group").remove(); 237 } 238 239 if (fieldClone) { 240 missingFields.push(fieldClone); 241 } 242 } 243 }); 244 245 // If any required fields are missing, show the modal 246 if (missingFields.length > 0) { 247 missingFields.forEach((field) => modalBody.appendChild(field)); 248 // Show the modal 249 var modalEl = document.getElementById("missingFieldsModal"); 250 var modalOptions = { 251 backdrop: "static", 252 keyboard: false 253 }; 254 255 if (typeof bootstrap !== 'undefined' && bootstrap.Modal) { 256 // Version compatible Bootstrap 5 257 var missingFieldsModal = new bootstrap.Modal(modalEl, modalOptions); 258 missingFieldsModal.show(); 259 } 260 else if (typeof jQuery !== 'undefined' && jQuery.fn.modal) { 261 // Version compatible Bootstrap 3 (et 4) 262 jQuery(modalEl).modal(modalOptions); 263 $(modalEl).modal('show').css('display', 'block').addClass('in'); 264 } 265 else { 266 console.error("Bootstrap n'est pas défini. Vérifiez l'ordre de chargement de vos scripts."); 267 } 268 } 269} 270window.addEventListener("DOMContentLoaded", function () { 271 checkRequiredFields("modal_org_custom_fields"); 272}); 273//on click on #reloadiframe reload the current frame 274$("#reloadiframe").on("click", function () { 275 location.reload(); 276}); 277var tooltipTriggerList_modal = [].slice.call( 278 document.querySelectorAll('[data-bs-toggle="tooltip"]') //data-bs-toggle="tooltip" bootstrap V5 279); 280 281/* //-------------------- ne fonctionne qu'avec bootstrap 5 --- code compatible plus bas------------------ 282var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { 283 return new bootstrap.Tooltip(tooltipTriggerEl); 284});*/ 285var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-toggle="tooltip"], [data-bs-toggle="tooltip"]')); 286var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { 287 if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) { 288 // Logique Bootstrap 5 289 return new bootstrap.Tooltip(tooltipTriggerEl); 290 } 291 else if (typeof jQuery !== 'undefined' && jQuery.fn.tooltip) { 292 // Logique Bootstrap 3 293 // On initialise et on retourne l'élément jQuery 294 return jQuery(tooltipTriggerEl).tooltip(); 295 } 296 return null; 297}); 298 299$('[data-toggle="tooltip"]').tooltip();
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.