const swiper = new Swiper('.swiper.is--testimonials', { slidesPerView: 1, speed: 400, grabCursor: true, spaceBetween: 24, navigation: { nextEl: ".slider-nav__button-arrow.is--right", prevEl: ".slider-nav__button-arrow.is--left", disabledClass: "disable-slider-button" }, }); var screenSize = $(window).width(); if (screenSize < 768) { $("#formBtn").click(function() { $('html, body').animate({ scrollTop: $("#form-block").offset().top - 50 }, 500); }); } var form = $("#email-form"); var formName = $("#name"); var formEmail = $("#Email"); $("input").on("click focus", function(event) { $(".form-alert").hide(); }); const onSubmit = (data, url) => { let updatedData = data.reduce((obj, item) => ({...obj, ... { [item.name]: item.value } })); updatedData['Name'] = updatedData.value; delete updatedData.name; delete updatedData.value; console.log(updatedData); axios.post(url, updatedData) .then(function(response) { console.log('success'); console.log(response); if (response.data.result === "error") { document.getElementById('successMessage').style.display = "none"; document.getElementById('errorMessage').style.display = "block"; if ((formName.val().length == 0) & (formEmail.val().length == 0)) { $(".form-alert").css("display", "block"); return; } if ( (/.{2,}/.test(formName.val()) == false && formName.val().length > 0) || formName.val().length == 0 ) { $("#alert_name").css("display", "block"); } if ( (/^[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/.test( formEmail.val() ) == false && formEmail.val().length > 0) || formEmail.val().length == 0 ) { $("#alert_email").css("display", "block"); } } else { document.getElementById('successMessage').style.display = "block"; document.getElementById('errorMessage').style.display = "none"; document.querySelector('.contact-form').style.display = "none"; } return response; }) .catch(function(error) { console.log('error', error); document.getElementById('successMessage').style.display = "none"; document.getElementById('errorMessage').style.display = "block"; return error; }); return; } $("#email-form").submit(() => false); $('#formBtn').click(() => console.log($("#email-form").serializeArray())); $('#formBtn').click(() => onSubmit($("#email-form").serializeArray().filter((item, i) => item.name !== 'form-name'), 'https://form.accuraten.com/.netlify/functions/telegram')); var accordion = (function() { var $accordion = $('.js-accordion'); var $accordion_header = $accordion.find('.js-accordion-header'); var $accordion_item = $('.js-accordion-item'); // default settings var settings = { // animation speed speed: 400, // close all other accordion items if true oneOpen: false, }; return { // pass configurable object literal init: function($settings) { $accordion_header.on('click', function() { accordion.toggle($(this)); gsap.to('.vertical', { scaleY: '1' }); if ($(this).parents('.js-accordion-item').hasClass('active')) { gsap.to($(this).find('.vertical'), { scaleY: '0' }) return } gsap.to('.vertical', { scaleY: '1' }) }); $.extend(settings, $settings); // ensure only one accordion is active if oneOpen is true if (settings.oneOpen && $('.js-accordion-item.active').length > 1) { $('.js-accordion-item.active:not(:first)').removeClass('active'); } // reveal the active accordion bodies $('.js-accordion-item.active').find('> .js-accordion-body').show(); }, toggle: function($this) { if (settings.oneOpen && $this[0] != $this.closest('.js-accordion').find('> .js-accordion-item.active > .js-accordion-header')[0]) { $this.closest('.js-accordion') .find('> .js-accordion-item') .removeClass('active') .find('.js-accordion-body') .slideUp() } // show/hide the clicked accordion item $this.closest('.js-accordion-item').toggleClass('active'); $this.next().stop().slideToggle(settings.speed); } } })(); $(document).ready(function() { accordion.init({ speed: 300, oneOpen: true }); }); //#region [Menu] if (screenSize < 767) { // Menu var menuOpen = false; $(".mobile-menu-button, .header__nav-item").click(function() { if (menuOpen == false) { $("body").css("overflow", "hidden"); $('.menu-button__line.is--top').css({ "animation": "topLine 0.2s 1 normal forwards" }) $('.menu-button__line.is--bottom').css({ "animation": "bottomLine 0.2s 1 normal forwards" }) gsap.to('.header__nav', { display: "block", height: 'auto', duration: 0.3 }) gsap.fromTo('.header__nav-item', { autoAlpha: 0 }, { autoAlpha: 1, duration: 0.2 }) gsap.to('.container.is--header', { color: "#fff", backgroundColor: "#000", height: '100vh' }) menuOpen = true; } else { closeMenu() } }); function closeMenu() { $("body").css("overflow", ""); $('.menu-button__line.is--top').css({ "animation": "returnTopLine 0.2s 1 normal forwards" }) $('.menu-button__line.is--bottom').css({ "animation": "returnBottomLine 0.2s 1 normal forwards" }) gsap.to('.header__nav-item', { autoAlpha: 0, duration: 0.2 }) gsap.to('.header__nav', { display: "none", height: '0', duration: 0.3 }) gsap.to('.container.is--header', { color: "", backgroundColor: "", height: 'auto' }) menuOpen = false; } } // Show menu on scroll var actionNav = gsap.to(".container.is--header", { y: "-" + document.querySelector(".container.is--header").clientHeight, duration: 0.3, ease: "power2.in", paused: true }); var menuToggle = ScrollTrigger.create({ trigger: "body", start: "50px top", end: 99999, onUpdate: ({ progress, direction, isActive }) => { if (direction == -1) { actionNav.reverse(); } if (direction == 1) { actionNav.play(); } else if (direction == 1 && isActive == true) { actionNav.play(); } } }); // End Show menu on scroll