1// hCaptcha callback for newsletter 2function recaptcha_callback(res) { 3 $('#sendNewsletters') 4 .attr('disabled', false) 5 .removeClass('disabled'); 6} 7 8 9$(function () { 10 /* ********************************** 11 * Gestion des groupes de newsletter 12 ********************************* */ 13 const newsletterGroups = $('#newsgroup'); 14 const newsletterButtonName = newsletterGroups.data('button'); 15 if (newsletterGroups.length) { 16 newsletterGroups.multiselect({ 17 buttonText: function (options) { 18 if (options.length === 0) { 19 return newsletterButtonName; 20 } else if (options.length > 3) { 21 return 'Plus de 3 groupes sélectionés'; 22 } else { 23 let labels = []; 24 options.each(function () { 25 if ($(this).attr('label') !== undefined) { 26 labels.push($(this).attr('label')); 27 } else { 28 labels.push($(this).html()); 29 } 30 }); 31 return labels.join(', ') + ''; 32 } 33 } 34 }); 35 } 36 /* ********************************** 37 * Soumission du form 38 ********************************* */ 39 $('#newsletters-form').on('submit', function (e) { 40 e.preventDefault(); 41 42 let form = $(this); 43 44 $.ajax({ 45 type: "POST", 46 url: form.attr('action'), 47 data: new FormData(form[0]), 48 contentType: false, 49 processData: false, 50 beforeSend: function () { 51 form.find('.form-error').hide(); 52 $('#sendNewsletters') 53 .attr('disabled', true) 54 .addClass('disabled'); 55 }, 56 success: function (response) { 57 hcaptcha.reset(); 58 if (response.status === 'KO') { 59 let errors = response.errors; 60 for (let index in errors) { 61 if (errors.hasOwnProperty(index)) { 62 let attr = errors[index]; 63 let error = attr[Object.keys(attr)[0]]; 64 form.find('#' + index + '-error').text(error).show(); 65 } 66 } 67 } else if (response.status === 'WRONG' || response.status === 'SUB' || response.status === 'WAIT') { 68 form.find('#email-error').text(response.text).show(); 69 } else { 70 $('#newsletters-form').css('display', 'none'); 71 $('#messageSendedFormNewsletter').css('display', ''); 72 form[0].reset(); 73 } 74 }, 75 complete: function () { 76 $('#sendNewsletters') 77 .attr('disabled', false) 78 .removeClass('disabled'); 79 } 80 }); 81 }); 82 83 /* ********************************** 84 * Soumission des diaporamas 85 ********************************* */ 86 // Splide type : simple 87 $('.simpleSplide').each(function () { 88 const id = $(this).attr('id'); 89 90 new Splide('#' + id, { 91 lazyLoad: 'nearby', 92 height: '40vh', 93 }).mount(); 94 }); 95 96 // Splide type : multiple 97 $('.multipleSplide').each(function () { 98 const id = $(this).attr('id'); 99 100 new Splide('#' + id, { 101 type: 'loop', 102 perPage: 3, 103 perMove: 1, 104 lazyLoad: 'nearby', 105 height: '40vh', 106 breakpoints: { 107 992: { 108 perPage: 1, 109 }, 110 } 111 }).mount(); 112 }); 113 114 // Splide type : responsive 115 $('.responsiveSplide').each(function () { 116 const id = $(this).attr('id'); 117 118 new Splide('#' + id, { 119 type: 'loop', 120 height: '20rem', 121 focus: 'center', 122 autoWidth: true, 123 lazyLoad: 'nearby', 124 }).mount(); 125 }); 126 127 // Splide type : center 128 $('.centerSplide').each(function () { 129 const id = $(this).attr('id'); 130 131 new Splide('#' + id, { 132 type: 'loop', 133 drag: 'free', 134 focus: 'center', 135 perPage: 3, 136 autoScroll: { 137 speed: 1, 138 }, 139 lazyLoad: 'nearby', 140 height: '40vh', 141 }).mount(window.splide.Extensions); 142 }); 143 144 // Splide type : fade 145 $('.fadeSplide').each(function () { 146 const id = $(this).attr('id'); 147 148 new Splide('#' + id, { 149 type: 'fade', 150 rewind: true, 151 lazyLoad: 'nearby', 152 height: '60vh', 153 }).mount(); 154 }); 155 156 // Splide type : thumbnail 157 $('.thumbnailSplide').each(function () { 158 const id = $(this).attr('id'); 159 160 const thumbnailSlider = buildThumbnailSlider($(this)); 161 thumbnailSlider.insertAfter($(this)); 162 163 const slideshowThumbnails = new Splide('#' + thumbnailSlider.attr('id'), { 164 fixedWidth: 100, 165 fixedHeight: 60, 166 gap: 10, 167 rewind: true, 168 pagination: false, 169 isNavigation: true, 170 lazyLoad: 'nearby', 171 breakpoints: { 172 600: { 173 fixedWidth: 60, 174 fixedHeight: 44, 175 }, 176 }, 177 }).mount(); 178 179 new Splide('#' + id, { 180 type: 'fade', 181 rewind: true, 182 pagination: false, 183 focus: 'center',
184 arrows: false, 185 height: '25rem', 186 autoWidth: true, 187 lazyLoad: 'nearby', 188 cover: false, 189 }).sync(slideshowThumbnails).mount(); 190 }); 191 192 function buildThumbnailSlider(slider) { 193 const sliderThumbnail = $('<div class="splide"></div>'); 194 sliderThumbnail.attr('id', slider.attr('id') + '-thumbnail'); 195 196 const sliderTrack = $('<div class="splide__track"></div>'); 197 const sliderList = $('<ul class="splide__list"></ul>'); 198 199 slider.find('.splide__slide').each(function () { 200 const cloneSlide = $(this).clone(true); 201 cloneSlide.removeAttr('id'); 202 cloneSlide.appendTo(sliderList); 203 }) 204 205 sliderList.appendTo(sliderTrack); 206 sliderTrack.appendTo(sliderThumbnail); 207 208 return sliderThumbnail; 209 } 210 211 /* ********************************** 212 * Fix CKEditor - Anchor link 213 ********************************* */ 214 $(document).ready(function() { 215 $("img[data-cke-realelement]").each(function (e, v) { 216 const x = $(decodeURIComponent(v.attributes['data-cke-realelement'].value)); 217 $(this).attr('id', x[0].id); 218 $(x).remove(); 219 }); 220 }); 221});
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.