/** * Ouvre la popup d'inscription */ function openpopupInscription() { $(".popup-inscription").show(); $.cookie('popup_status', '1', {expires: 30}); } /** * Ferme la popup d'inscription */ function closepopupInscription() { $(".popup-inscription").hide(); $("#outputInscription").html(''); } /** * Ouvre la popup de chargement * * @param parentClass */ function openPopupLoading(parentClass) { $(parentClass + " .loading-box").show(); } /** * Ferme la popup de chargement * * @param parentClass */ function closePopupLoading(parentClass) { $(parentClass + " .loading-box").hide(); } /** * Ouvre la fenêtre d'acception des cookies */ function openCookiesInfo() { $("#cookies-info").show(); } /** * Ferme la fenêtre d'acception des cookies */ function closeCookiesInfo() { $("#cookies-info").hide(); $.cookie('accept', '1', {expires: 30}); ga('create', 'UA-74379017-1', 'auto', { 'anonymizeIp': true, 'cookieExpires': 395 * 24 * 60 * 60 }); ga('send', 'pageview'); } /** * Ouverture, au démarrage, de la popup informant de l'utilisation des cookies */ function openStartingCookiesBanner() { // L'utilisation des cookies n'a pas encore été acceptée if (typeof $.cookie('token') === 'undefined') { if ($.cookie('accept') != '1') { openCookiesInfo(); } } } /** * Remet à zéro le formulaire */ function eraseForm() { $('input[type=text]').each(function () { $(this).val(''); }); $('input[type=email]').each(function () { $(this).val(''); }); $('textarea').each(function () { $(this).val(''); }); } /** * Permet le smooth scrolling * @param element * @returns {boolean} */ function smoothScrolling(element) { if (location.pathname.replace(/^\//, '') == element.pathname.replace(/^\//, '') && location.hostname == element.hostname) { var target = $(element.hash); target = target.length ? target : $('[name=' + element.hash.slice(1) + ']'); if (target.length) { $('html, body').animate({ scrollTop: target.offset().top }, 1000); return false; } } } /** * Handle clicks */ $(function () { $(".open-popup-inscription").click(function () { openpopupInscription(); return false; }); $(".close-popup-inscription").click(function () { closepopupInscription(); eraseForm(); return false; }); $("#accept-cookies").click(function () { closeCookiesInfo(); return false; }); $("#refuse-cookies").click(function () { $("#cookies-info").hide(); $.cookie('accept', '1', {expires: 30}); ga('create', 'UA-74379017-1', 'auto', { 'anonymizeIp': true, 'storage': 'none' }); ga('send', 'pageview'); }); // Smooth scrolling $('a[href*="#"]:not([href="#"])').click(function () { smoothScrolling(this); }); }); var demoSubmit = $('#demo-form-submit'); var fieldDemoLastName = $('#demo_last_name'); var fieldDemoFirstName = $('#demo_first_name'); var fieldDemoEmail = $('#demo_email_address'); var demoPhoneNumber = $('#demo_phone-tel'); var fieldDemoZipCode = $('#demo_zip_code'); var fieldDemoZip = $('#demo_zip'); var fieldDemoCity = $('#demo_city'); var fieldDemoCompany = $('#demo_company'); var demoWrapper = $('#demo-preloader-wrapper'); var demoChecked = $('#accept_mail'); demoSubmit.on('click', function () { sendEmailDemo(fieldDemoFirstName, fieldDemoLastName, fieldDemoEmail, demoPhoneNumber, fieldDemoCompany, fieldDemoZipCode, demoChecked.is(':checked'), fieldDemoZip, fieldDemoCity, $('#sell_type_input')); }) /** * Send email to Jonathan when click on demo */ function sendEmailDemo(firstName, lastName, email, phone, company, zipCode, checkedDemo, zipDemo, zipCity, sellTypeInput) { demoSubmit.hide(); demoWrapper.show(); //Get fields value var demoFirstName = firstName.val(); var demoLastName = lastName.val(); var demoCompany = company.val(); var demoZipCode = zipCode.val(); var demoPhone = phone.val(); var demoMail = email.val(); var demoZip = zipDemo.val(); var demoCity = zipCity.val(); var demoCheck = checkedDemo; var sellType = sellTypeInput.val(); $.ajax({ url: 'controller/contact-demo.php', type: 'POST', data: {email: demoMail, phone: demoPhone, lastName: demoLastName, firstName: demoFirstName, company: demoCompany, zipCode: demoZipCode, checkedDemo: demoCheck, lang: locale, demoZip: demoZip, demoCity: demoCity, sellType: sellType}, /** * @return integer */ success: function (result) { console.log(result); if (result == -1) { let translation = "Veuillez renseigner les champs obligatoires"; if (locale === "en") { translation = "Please fill in the required fields"; } if (locale === 'ar') { translation = "يرجى ملء الحقول المطلوبة"; } M.toast({html: translation}, 4000); } else if (result == -2) { let translation = "Format de l'adresse email non valide"; if (locale === "en") { translation = "Invalid email address format"; } if (locale === 'ar') { translation = "تنسيق عنوان البريد الإلكتروني غير صالح"; } M.toast({html: translation}, 4000); } else if (result == -3) { let translation = "Vous devez acceptez la confirmation"; if (locale === "en") { translation = "You must accept the confirmation"; } if (locale === 'ar') { translation = "يجب عليك قبول التأكيد"; } M.toast({html: translation}, 4000); } else if (result == -4) { let translation = "Numéro de téléphone non valide"; if (locale === "en") { translation = "Invalid phone number"; } if (locale === 'ar') { translation = "رقم الهاتف غير صالح"; } M.toast({html: translation}, 4000); } else if (result == -7) { let translation = "Une erreur est survenue lors de l'envoi du mail"; if (locale === "en") { translation = "An error occurred while sending the email"; } if (locale === 'ar') { translation = "حدث خطأ أثناء إرسال البريد الإلكتروني"; } M.toast({html: translation}, 4000); } else if (result == 1) { let translation = "Votre demande de démonstration a bien été prise en compte. Nous vous recontacterons très rapidement."; if (locale === "en") { translation = "Your demo request has been taken into account. We will contact you very soon."; } if (locale === 'ar') { translation = "تم اتخاذ طلب العرض التوضيحي الخاص بك بعين الاعتبار. سنتصل بك قريبا جدا."; } eraseFormFields(email, firstName, lastName, company, zipCode, phone, zipDemo, zipCity, sellTypeInput); hideOverlay() $('#popup-demo').hide(); M.toast({html: translation}, 4000); } }, error: function () { }, complete: function () { demoSubmit.show(); demoWrapper.hide(); if (typeof wrapperDemo !== 'undefined') { wrapperDemo.hide(); submitDemo.show(); } } }); } function eraseFormFields(demoEmail, demoFirstName, demoLastName, demoCompany, demoZipCode, demoPhoneNumber, demoZip, demoCity, sellType) { demoEmail.val(''); demoFirstName.val(''); demoLastName.val(''); demoCompany.val(''); demoZipCode.val(''); demoPhoneNumber.val(''); demoZip.val(''); demoCity.val(''); sellType.val(''); } $(document).ready(function() { openStartingCookiesBanner(); demoWrapper.hide(); }); /*$('.left-fixed img, .center-fixed .left').hover(function() { this.setAttribute('src', '/images/Fl%C3%A8che%20GW%20hover.svg'); }, function () { this.setAttribute('src', '/images/Fl%C3%A8che%20GW.svg?v=9.0'); }); $('.right-fixed img, .center-fixed .right').hover(function() { this.setAttribute('src', '/images/Fl%C3%A8che%20DW%20hover.svg'); }, function () { this.setAttribute('src', '/images/Fl%C3%A8che%20DW.svg?v=9.0'); });*/