1/* ========================================================================== 2 Functions 3 ========================================================================== */ 4 5 function openPopup(popup) { 6 $('body').addClass('no-scroll'); 7 $('.popup').removeClass('popup--visible'); 8 $('.popup[data-popup='+popup+']').addClass('popup--visible'); 9 }; 10 11 function closePopup(popup) { 12 $('body').removeClass('no-scroll'); 13 $('.popup[data-popup='+popup+']').removeClass('popup--visible'); 14 }; 15 16 $(document).ready(function() { 17 18 /* ========================================================================== 19 Global 20 ========================================================================== */ 21 22 var siteUrl = $('body').data('siteurl'); 23 var baseUrl = $('body').data('baseurl'); 24 25 /* ========================================================================== 26 Scroll to 27 ========================================================================== */ 28 29 $('.js-scroll-to').on('click', function(e) { 30 e.preventDefault(); 31 scrollto = $(this).data('scrollto'); 32 $('html, body').animate({scrollTop: $(scrollto).offset().top - 150}, 400); 33 }); 34 35 /* ========================================================================== 36 Cookies 37 ========================================================================== */ 38
39 $('.js-close-cookies').click(function(e){ 40 e.preventDefault(); 41 $('body').addClass('cookies-close'); 42 $.ajax({ 43 type :"POST", 44 url :baseUrl+"/data/accept_cookies.php", 45 }); 46 }); 47 48 /* ========================================================================== 49 Scroll Up or Down 50 ========================================================================== */ 51 52 var last_scroll_position = 0; 53 54 $(window).scroll(function(e){ 55 56 var scroll_position = $(this).scrollTop(); 57 58 if (scroll_position < 100) { 59 $('body').addClass('scroll-up'); 60 $('body').removeClass('scroll-down'); 61 } else if(scroll_position > $(document).height() - $(window).height() - 100) { 62 $('body').addClass('scroll-up'); 63 $('body').removeClass('scroll-down'); 64 } else { 65 if (scroll_position > last_scroll_position){ 66 $('body').addClass('scroll-down'); 67 $('body').removeClass('scroll-up'); 68 69 } else { 70 $('body').addClass('scroll-up'); 71 $('body').removeClass('scroll-down'); 72 } 73 } 74 75 last_scroll_position = scroll_position; 76 }); 77 78 /* ========================================================================== 79 Navigation 80 ========================================================================== */ 81 82 /* Active nav link on scroll 83 ---------------------------------- */ 84 85 function activeNav() { 86 var scroll_position = $(document).scrollTop(); 87 $('.nav__link:not(.nav__link--btn)').each(function() { 88 var id_block = $(this).attr('href').replace('#', ''); 89 var reference_block = $('.js-nav-section[id=' + id_block + ']'); 90 if (!reference_block.length) return; 91 if (reference_block.position().top - 300 <= scroll_position && reference_block.position().top + reference_block.height() > scroll_position) { 92 $('.nav__link').removeClass('nav__link--active'); 93 $(this).addClass('nav__link--active'); 94 } else { 95 $(this).removeClass('nav__link--active'); 96 } 97 }); 98 } 99 100 $(window).scroll(function() { 101 activeNav(); 102 }); 103 104 /* Shrink navigation on scroll 105 ---------------------------------- */ 106 107 function shrinkNav(){ 108 $(window).scroll(function(){ 109 if($(window).scrollTop() > 100){ 110 $('body').addClass('shrink-nav'); 111 } 112 else{ 113 $('body').removeClass('shrink-nav'); 114 } 115 }) 116 } 117 shrinkNav(); 118 119 $(window).on('resize',function(){ 120 shrinkNav(); 121 }); 122 123 /* Toggle mobile nav 124 ---------------------------------- */ 125 126 $('.js-mobile-nav').click(function(e) { 127 $body=$('body'); 128 if ($body.hasClass('nav-is-open')) { 129 $body.removeClass('nav-is-open'); 130 $body.removeClass('no-scroll'); 131 } else { 132 $body.addClass('nav-is-open'); 133 $body.addClass('no-scroll'); 134 } 135 }) 136 137 $('.js-close-nav').click(function(e) { 138 $body=$('body'); 139 if ($body.hasClass('nav-is-open')) { 140 $body.removeClass('nav-is-open'); 141 $body.removeClass('no-scroll'); 142 } else { 143 $body.removeClass('nav-is-open'); 144 $body.removeClass('no-scroll'); 145 } 146 }) 147 148 /* ========================================================================== 149 Video 150 ========================================================================== */ 151 152 const videoPlayTriggers = document.querySelectorAll('.js-video-play'); 153 154 for (const videoPlayTrigger of videoPlayTriggers) { 155 videoPlayTrigger.addEventListener('click', () => { 156 const videoTarget = videoPlayTrigger.closest('.video')?.querySelector('video'); 157 if(videoTarget) { 158 videoPlayTrigger.style.display = 'none'; 159 videoTarget.play(); 160 videoTarget.setAttribute('controls', 'true'); 161 } 162 }); 163 } 164 165 /* ========================================================================== 166 Checkbox 167 ========================================================================== */ 168 169 $('.checkbox__box, .checkbox__label-click').on('click', function(e){
170 if ($(this).parents('.checkbox').hasClass('active')) { 171 $(this).parents('.checkbox').removeClass('active'); 172 $(this).parents('.checkbox').find('.checkbox__input').val('0'); 173 } else { 174 $(this).parents('.checkbox').addClass('active'); 175 $(this).parents('.checkbox').find('.checkbox__input').val('1'); 176 } 177 }); 178 179 /* ========================================================================== 180 Radio 181 ========================================================================== */ 182 183 $('.radio__item').on('click', function(e){ 184 e.preventDefault(); 185 var radio = $(this).data('radio'); 186 $(this).parent().find('.radio__item').removeClass('active'); 187 $(this).addClass('active'); 188 $(this).parent().find('.radio__input').val(radio); 189 }); 190 191 /* ========================================================================== 192 Phone number 193 ========================================================================== */ 194 195 $('body').on('keyup keypress keydown focusout blur', '.js-input-phone', function () { 196 if (this.value != this.value.replace(/[^0-9+]/g, '')) { 197 this.value = this.value.replace(/[^0-9+]/g, ''); 198 } 199 }); 200 201 /* ========================================================================== 202 Zip code 203 ========================================================================== */ 204 205 $('body').on('keyup keypress keydown focusout blur', '.js-input-zip', function () { 206 if (this.value != this.value.replace(/[^0-9]/g, '')) { 207 this.value = this.value.replace(/[^0-9]/g, ''); 208 } 209 }); 210 211 /* ========================================================================== 212 Check forms 213 ========================================================================== */ 214 215 var verifmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 216 217 function checkForm(form, btn, url) { 218 219 var erreur = 0; 220 var form = $(form); 221 var id_form = form.data('form'); 222 var is_custom = form.data('custom'); 223 var btn = $(btn); 224 225 form.find('.required').not('.radio, .checkbox').each(function () { 226 if ($(this).is(':visible')) { 227 if ($(this).val() == '' || $(this).val() == null) { 228 $(this).addClass('error'); 229 erreur++; 230 } else { 231 $(this).removeClass('error'); 232 } 233 } 234 form.find('.js-input-email').each(function () { 235 if ($(this).is(':visible')) { 236 if (verifmail.exec($(this).val()) == null) { 237 $(this).addClass('error'); 238 erreur++; 239 } else { 240 $(this).removeClass('error'); 241 } 242 } 243 }); 244 }); 245 246 form.find('.checkbox.required').each(function () { 247 if ($(this).is(':visible')) { 248 if ($(this).hasClass('active')) { 249 $(this).removeClass('error'); 250 } else { 251 $(this).addClass('error'); 252 erreur++; 253 } 254 } 255 }); 256 257 form.find('.radio.required').each(function () { 258 if ($(this).is(':visible')) { 259 if (!$(this).find('.radio__item.active').length) { 260 $(this).addClass('error'); 261 erreur++; 262 } else { 263 $(this).removeClass('error'); 264 } 265 } 266 }); 267 268 form.find('.required').not('.radio, .checkbox').focusout(function () { 269 if ($(this).is(':visible')) { 270 if ($(this).val() == '' || $(this).val() == null) { 271 $(this).addClass('error'); 272 erreur++; 273 } 274 else { 275 $(this).removeClass('error'); 276 } 277 } 278 }); 279 280 if (is_custom) { 281 erreur = erreur + parseInt(checkCustom(id_form)); 282 } 283 284 if (erreur == 0 && !btn.hasClass('disabled')) { 285 ajaxForm(form, btn, url); 286 } else { 287 $('html, body').animate({ scrollTop: $(".error").offset().top - 150 }, 450); 288 $('.error:text:visible:first').focus(); 289 } 290 291 } 292 293 function ajaxForm(form, btn, url) { 294 295 var form = $(form); 296 var id_form = form.data('form'); 297 var btn = $(btn); 298 btn.addClass('disabled'); 299 btn.addClass('loading'); 300 301 var fields = form.serialize(); 302 $.ajax({
303 type: 'POST', 304 data: fields, 305 url: url, 306 success: function (response) { 307 $('.loading').removeClass('loading'); 308 if(response=='ok'){ 309 afterSendOk(id_form); 310 }else if(response=='ko'){ 311 afterSendNotOk(errors, id_form); 312 }else{ 313 var errors = error.hasOwnProperty('responseJSON') ? error.responseJSON : []; 314 afterSendNotOk(errors, id_form); 315 } 316 }, 317 error: function (error) { 318 var errors = error.hasOwnProperty('responseJSON') ? error.responseJSON : []; 319 afterSendNotOk(errors, id_form); 320 if(error.status === 500) { 321 // Server error 322 } 323 } 324 }); 325 } 326 327 $('.js-verif').click(function (e) { 328 e.preventDefault(); 329 var id = $(this).data('form'); 330 var form = $('form[data-form=' + id + ']'); 331 var url = form.attr('action'); 332 var btn = $(this); 333 checkForm(form, btn, url); 334 }); 335 336 /* ========================================================================== 337 After send 338 ========================================================================== */ 339 340 function afterSendOk(form) { 341 switch (form) { 342 343 // form 344 case 'form': 345 openPopup('form_ok'); 346 break; 347 348 } 349 } 350 351 function afterSendNotOk(retour, form) { 352 switch (form) { 353 354 // form 355 case 'form': 356 openPopup('form_ko'); 357 break; 358 359 } 360 } 361 362 /* ========================================================================== 363 Trigger enter 364 ========================================================================== */ 365 366 $("form input, form select").on('keyup keypress', function(e) { 367 var keyCode = e.keyCode || e.which; 368 var id = $(this).parents("form").data("form"); 369 var form = $("form[data-form="+id+"]"); 370 var url = form.attr("action"); 371 var btn = form.find(".js-verif"); 372 373 if (keyCode == 13) { 374 e.preventDefault(); 375 checkForm(form,btn,url); 376 return false; 377 } 378 379 }); 380 381 /* ========================================================================== 382 Popup 383 ========================================================================== */ 384 385 $('.js-open-popup').on('click', function(e){ 386 e.preventDefault(); 387 var popup = $(this).data('popup'); 388 openPopup(popup); 389 }); 390 391 $('.js-close-popup').on('click', function(e){ 392 e.preventDefault(); 393 var popup = $(this).data('popup'); 394 closePopup(popup); 395 }); 396 397 /* ========================================================================== 398 Lang 399 ========================================================================== */ 400 401 $('.js-lang').on('click', function(){ 402 $(this).toggleClass('lang--active'); 403 }); 404 405 /* ========================================================================== 406 Countdown 407 ========================================================================== */ 408 409 $('.countdown').each(function() { 410 var $countdown = $(this); 411 var parts = $countdown.data('countdown').split('/'); 412 var target = new Date(Date.UTC(parts[2], parts[1] - 1, parts[0]) - 2 * 3600000); 413 var $values = $countdown.find('.countdown__value'); 414 415 function updateCountdown() { 416 var diff = target - new Date(); 417 if (diff <= 0) { 418 $values.eq(0).text('00'); 419 $values.eq(1).text('00'); 420 $values.eq(2).text('00'); 421 $values.eq(3).text('00'); 422 return; 423 } 424 var days = Math.floor(diff / 86400000); 425 var hours = Math.floor((diff % 86400000) / 3600000); 426 var minutes = Math.floor((diff % 3600000) / 60000); 427 var seconds = Math.floor((diff % 60000) / 1000); 428 $values.eq(0).text(String(days).padStart(2, '0')); 429 $values.eq(1).text(String(hours).padStart(2, '0')); 430 $values.eq(2).text(String(minutes).padStart(2, '0')); 431 $values.eq(3).text(String(seconds).padStart(2, '0')); 432 } 433 434 updateCountdown(); 435 setInterval(updateCountdown, 1000); 436 }); 437 438 /* ========================================================================== 439 Subscription filter 440 ========================================================================== */ 441 442 $('.subscription__filter-item').on('click', function() { 443 var id = $(this).data('id'); 444 var subscription = $(this).closest('.subscription'); 445 subscription.find('.subscription__filter-item').removeClass('subscription__filter-item--active'); 446 $(this).addClass('subscription__filter-item--active'); 447 subscription.find('.subscription__price-item').removeClass('subscription__price-item--visible'); 448 subscription.find('.subscription__price-item[data-id="' + id + '"]').addClass('subscription__price-item--visible'); 449 }); 450 451 /* ========================================================================== 452 Accordion 453 ========================================================================== */ 454 455 $('.accordion__primary').on('click', function(e){
456 e.preventDefault(); 457 console.log('click'); 458 459 if ($(this).parents('.accordion__item').hasClass('accordion__item--active')) { 460 $(this).parents('.accordion__item').removeClass('accordion__item--active'); 461 $('.accordion__item').find('.accordion__secondary').stop().slideUp(); 462 } else { 463 $('.accordion__item').removeClass('accordion__item--active'); 464 $('.accordion__item').find('.accordion__secondary').stop().slideUp(); 465 $(this).parents('.accordion__item').addClass('accordion__item--active'); 466 $(this).parents('.accordion__item').find('.accordion__secondary').stop().slideDown(); 467 } 468 469 }); 470 471 });
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.