$(document).ready(function () { initFbTracking() initCheckMobile(); initScrollTo(); initCustSelect(); initTwoBlkSwiper(); /* initThreeBlkSwiper(); */ initFourBlkSwiper(); initThreeType(); initTabSwiper(); initTab(); initFold(); initFormLabel(); initTrialForm(); initMobileMenu(); $(window).scroll(); $(window).resize(); }); $(window).scroll(function () { fixedHeader(); }); $(window).resize(function () { removeMobileStyle(); getFixedHeaderHeight(); setProductVsHeight(); }); function initFbTracking() { if(thisType == "Product") { thisPage = $(".free-trial__course-name").html().split("
")[0] } //fbq('track', 'ViewContent', {content_type: thisType, content_name: thisPage}); $("a[href^='tel:'], .footer__social-item").click(function(){ //fbq('track', 'Contact'); }) $("body").on("click", "#easychat-floating-button", function(){ //fbq('track', 'Contact'); }) } function initCheckMobile() { if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { $("body").addClass("mobile-device") } } var fixedHeaderHeight = 55, twoBlkSwiper = [], threeBlkSwiper = [], fourBlkSwiper = [], tabSwiper = []; function fixedHeader() { if ($(window).scrollTop() > 50) { $(".header").addClass("fixed"); } else { $(".header").removeClass("fixed"); } } function getFixedHeaderHeight() { var windowWidth = $(window).width(); if (windowWidth <= 479) { fixedHeaderHeight = 45; } else if (fixedHeaderHeight <= 991) { fixedHeaderHeight = 50; } else { fixedHeaderHeight = 55; } } function initCustSelect() { $(".cust-select select").change(function () { var text = $(this).find("option:checked").text(); $(this).siblings(".cust-select__mask").text(text); if ($(this).val() == "") { $(this).parents(".free-trial__form-col").removeClass("has-val"); } else { $(this).parents(".free-trial__form-col").addClass("has-val"); } }); $(".cust-select select").change(); } function initScrollTo() { $(".scroll-to").click(function (e) { e.preventDefault(); var target = $(this).attr("data-target"); if ($(target).length > 0) { $("html,body").animate({ scrollTop: $(target).offset().top - fixedHeaderHeight, }); } }); // scroll to form var totalImg = $("img").length, loadedImg = 0; $("img").one("load", function() { loadedImg++ if(loadedImg == totalImg) { initScrollToFrom() } }).each(function() { if(this.complete) { $(this).trigger('load'); } }); } function initTwoBlkSwiper() { $(".two-blk-slider__container:not(.product-case__swiper)").each(function ( index ) { var $nextBtn = $(this).find(".swiper-button-next")[0], $prevBtn = $(this).find(".swiper-button-prev")[0], $thisPagination = $(this).find(".swiper-pagination")[0]; twoBlkSwiper[index] = new Swiper(this, { slidesPerView: "auto", centeredSlides: true, loop: true, loopedSlides: 2, loopedSlidesLimit: false, navigation: { nextEl: $nextBtn, prevEl: $prevBtn, }, pagination: { el: $thisPagination, clickable: true, }, breakpoints: { 992: { slidesPerView: 1, }, }, }); }); $(".two-blk-slider__item-img-container").on('touchstart', function(){ $(this).addClass("mobile-hover") }).on('touchend touchcancel', function(){ $(this).removeClass("mobile-hover") }) } function initThreeBlkSwiper() { $(".three-blk-slider__swiper").each(function (index) { var $thisHolder = $(this).parents(".three-blk-slider"), totalSlide = $(this).find(".swiper-slide").length; switch (totalSlide) { case 1: $($thisHolder).addClass("hide-arrow"); break; case 2: $($thisHolder).addClass("hide-arrow--min-480"); break; case 3: $($thisHolder).addClass("hide-arrow--min-992"); break; default: } var $nextBtn = $($thisHolder).find(".swiper-button-next")[0], $prevBtn = $($thisHolder).find(".swiper-button-prev")[0], $thisPagination = $($thisHolder).find(".swiper-pagination")[0]; threeBlkSwiper[index] = new Swiper(this, { slidesPerView: 1, spaceBetween: 24, navigation: { nextEl: $nextBtn, prevEl: $prevBtn, }, pagination: { el: $thisPagination, clickable: true, }, breakpoints: { 480: { slidesPerView: 2, }, 992: { slidesPerView: 3, }, }, }); }); } function initFourBlkSwiper() { $(".four-blk-slider__swiper").each(function (index) { var $thisHolder = $(this).parents(".four-blk-slider"), totalSlide = $(this).find(".swiper-slide").length; switch (totalSlide) { case 1: $($thisHolder).addClass("hide-arrow"); break; case 2: $($thisHolder).addClass("hide-arrow--min-561"); break; case 3: $($thisHolder).addClass("hide-arrow--min-992"); case 4: $($thisHolder).addClass("hide-arrow--min-1280"); break; default: } var $nextBtn = $($thisHolder).find(".swiper-button-next")[0], $prevBtn = $($thisHolder).find(".swiper-button-prev")[0], $thisPagination = $($thisHolder).find(".swiper-pagination")[0]; fourBlkSwiper[index] = new Swiper(this, { slidesPerView: 1, spaceBetween: 24, navigation: { nextEl: $nextBtn, prevEl: $prevBtn, }, pagination: { el: $thisPagination, clickable: true, }, breakpoints: { 561: { slidesPerView: 2, }, 992: { slidesPerView: 3, }, 1280: { slidesPerView: 4, }, }, }); }); } var test function initThreeType() { $(".three-type__item") .mouseenter(function () { if ($(window).width() <= 991) { return false; } $(this).find(".three-type__item-detail").slideDown(300); }) .mouseleave(function () { if ($(window).width() <= 991) { return false; } $(this).find(".three-type__item-detail").slideUp(300); }) .click(function (e) { var $thisEl = e.target if( !$($thisEl).is("a") && $($thisEl).parents("a").length < 1) { e.preventDefault(); if ($(window).width() <= 991) { var content = $(this).html(); $(".three-type__popup-textarea").html(content); $("body").addClass("three-type-popup-open"); $(".three-type__popup").fadeIn(300); } } }); $(".three-type__popup-close-btn").click(function (e) { e.preventDefault(); $(".three-type__popup").fadeOut(300); $("body").removeClass("three-type-popup-open"); }); } function initFormLabel() { $(".free-trial__form-input") .focus(function () { $(this).parent(".free-trial__form-col").addClass("focus"); }) .blur(function () { $(this).parent(".free-trial__form-col").removeClass("focus"); }) .change(function () { if ($(this).val() == "") { $(this).parent(".free-trial__form-col").removeClass("has-val"); } else { $(this).parent(".free-trial__form-col").addClass("has-val"); } }); } function initTrialForm() { $("#bookingDate").datepicker({ minDate: +5, maxDate: "+3m", beforeShowDay: function(date) { var day = date.getDay(); return [(day != 0), '']; } }); $("#bookingDate").change(function(){ var option, selectedDate = $(this).val(); if(selectedDate == "") { option = `` } else { var newDate = new Date(selectedDate); var day = newDate.getDay(); if(day == 0) { // Sunday option = `` } else if(day == 6) { // Saturday option = ` ` } else { option = ` ` } } $("#bookingTime").html(option) }) $(".free-trial__next-btn").click(function (e) { e.preventDefault(); $(".free-trial__form-step-2").slideDown(300); $(".free-trial__next-btn").hide(); $(".free-trial__form-step-2-btn").show(); }); $(".free-trial__form").submit(function (e) { e.preventDefault(); if (!trialFormCheck() || $(".free-trial__submit").is(":disabled")) { return false } $(".free-trial__submit").attr("disabled", true) $.ajax({ type: 'POST', url: "/register", /* cache: false, contentType: false, processData: false, */ data: $(".free-trial__form").serialize(), success: function (data) { if(data["status"] == "1") { $(".free-trial__body").hide(); $(".free-trial__thank").show(); //fbq('track', 'CompleteRegistration', {content_name: $(".free-trial__course-name").html().split("
")[0]}); //fbq('track', 'Lead', {content_name: $(".free-trial__course-name").html().split("
")[0]}); //fbq('track', 'Schedule'); //fbq('track', 'SubmitApplication'); } else { alert("Error") } $(".free-trial__submit").removeAttr("disabled") } }) }); } function trialFormCheck() { var noError = true; $(".free-trial__form input").each(function () { if ($(this).is("[type=checkbox]")) { if (!$(this).prop("checked")) { noError = false; $(this).parents(".free-trial__checkbox").addClass("error"); } else { $(this).parents(".free-trial__checkbox").removeClass("error"); } } if ($(this).val() == "" && $(this).attr("data-null") != 1) { $(this).parents(".free-trial__form-col").addClass("error"); noError = false; } else { $(this).parents(".free-trial__form-col").removeClass("error"); } }); $(".free-trial__form select").each(function () { if ($(this).val() == "") { $(this).parents(".free-trial__form-col").addClass("error"); noError = false; } else { $(this).parents(".free-trial__form-col").removeClass("error"); } }); return noError; } function initMobileMenu() { $(".header__show-menu-btn").click(function (e) { e.preventDefault(); $(".header-menu").fadeIn(300); $("body").addClass("mb-menu-open"); }); $(".header-menu__close-btn").click(function (e) { e.preventDefault(); $(".header-menu").fadeOut(300); $("body").removeClass("mb-menu-open"); }); $(".header-menu__main-btn").click(function (e) { e.preventDefault(); if ($(window).width() > 991) { return false; } $(this).siblings(".header-submenu").slideToggle(300); }); } function initTab() { $(".product-case__btn").click(function (e) { e.preventDefault(); if ($(this).hasClass("active")) { return false; } var holder = $(this).parents(".section-tab"), contentHolder = $(holder).find(".section-tab__body"), target = $(this).attr("data-target"), targetEl = $(contentHolder).find( ".section-tab__body-item[data-target=" + target + "]" ); $(this).siblings(".product-case__btn").removeClass("active"); $(this).addClass("active"); $(targetEl) .siblings(".section-tab__body-item") .removeClass("active") .hide(); $(targetEl).addClass("active").show(); if ( $(this).hasClass("has-swiper") && typeof tabSwiper[target] != "undefined" ) { tabSwiper[target].update(); } }); $(".section-tab").each(function () { $(this).find(".section-tab__btn").eq(0).click(); }); } function initTabSwiper() { $(".section-tab .two-blk-slider__container").each(function () { var $nextBtn = $(this).find(".two-blk-slider__next")[0], $prevBtn = $(this).find(".two-blk-slider__prev")[0], $thisPagination = $(this).find(".two-blk-slider__pagination")[0], thisKey = $(this).attr("data-swiper-name"); if ($(this).find(".swiper-slide").length < 2) { $(this).addClass("hide-arrow"); return; } tabSwiper[thisKey] = new Swiper(this, { slidesPerView: "auto", centeredSlides: true, loop: true, loopedSlides: 2, loopedSlidesLimit: false, navigation: { nextEl: $nextBtn, prevEl: $prevBtn, }, pagination: { el: $thisPagination, clickable: true, }, breakpoints: { 992: { slidesPerView: 1, }, }, }); }); } function initFold() { $(".fold__toggle-btn").click(function (e) { e.preventDefault(); $(this).toggleClass("active"); $(this).siblings(".fold__textarea").slideToggle(300); }); } function setProductVsHeight() { var heightArray = []; $(".product-vs__col").each(function () { $(this) .find(".product-vs__col-item") .each(function (index) { var thisHeight = $(this).height(); if ( thisHeight > heightArray[index] || typeof heightArray[index] == "undefined" ) { heightArray[index] = thisHeight; } }); }); $.each(heightArray, function (index, value) { var thisIndex = index + 1; $(".product-vs__col-item:nth-child(" + thisIndex + ")").height(value); }); } function removeMobileStyle() { if ($(window).width() > 991) { $(".header-menu").removeAttr("style"); $(".header-submenu").removeAttr("style"); } } function initScrollToFrom() { if(window.location.hash == "#free-trial") { if($(".free-trial").length < 1) {return false} $("html,body").animate({ scrollTop: $(".free-trial").offset().top - fixedHeaderHeight, }); } }