$( document ).ready(function() { // Подключаем функционал только для десктопа $(".listing-inner").click(function(event) { /* Act on the event */ url_top = $("#products").offset().top; $('html, body').stop().animate({ scrollTop: url_top }, 1000) }); var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i) ? true : false; }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i) ? true : false; }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false; }, Windows: function() { return navigator.userAgent.match(/IEMobile/i) ? true : false; }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows()); } }; if ( !isMobile.any() ) { // Код не для телефонов onlyDesctopFunctions(); }else { $(".section-1 .wow").css('visibility', 'visible'); } function onlyDesctopFunctions(){ new WOW().init(); // Анимация бликов $('.btn-orange').each(function() { var $this = $(this); var ink, d, x, y; setInterval(function() { if($this.find(".blick").length === 0){ $this.prepend(""); } ink = $this.find(".blick"); ink.removeClass("animate"); if(!ink.height() && !ink.width()){ d = Math.max($this.outerWidth(), $this.outerHeight()); ink.css({height: d, width: d}); } x = Math.round(Math.random()*ink.width() - ink.width()/2); y = Math.round(Math.random()*ink.height() - ink.height()/2); // y = 0; // x = e.pageX - $this.offset().left - ink.width()/2; // y = e.pageY - $this.offset().top - ink.height()/2; ink.css({top: y+'px', left: x+'px'}).addClass("animate"); }, 3000) }); // END if onlyDesctopFunctions } // END onlyDesctopFunctions sobaka(); function sobaka(){ $('form').each(function(){ // Объявляем переменные (форма и кнопка отправки) var form = $(this), btn = form.find('.btn-orange'); // Добавляем каждому проверяемому полю, указание что поле пустое form.find('input[type="text"]').addClass('empty_field'); // Функция проверки полей формы function checkInput(){ form.find('input[type="text"]').each(function(){ if($(this).val() != ''){ // Если поле не пустое удаляем класс-указание $(this).removeClass('empty_field'); } else { // Если поле пустое добавляем класс-указание $(this).addClass('empty_field'); } }); } // Функция подсветки незаполненных полей function lightEmpty(){ form.find('.empty_field').css({'border-color':'#d8512d'}); // Через полсекунды удаляем подсветку setTimeout(function(){ form.find('.empty_field').removeAttr('style'); },500); } // Проверка в режиме реального времени setInterval(function(){ // Запускаем функцию проверки полей на заполненность checkInput(); // Считаем к-во незаполненных полей var sizeEmpty = form.find('.empty_field').size(); // Вешаем условие-тригер на кнопку отправки формы if(sizeEmpty > 0){ if(btn.hasClass('disabled')){ return false } else { btn.addClass('disabled') } } else { btn.removeClass('disabled') } },500); // Событие клика по кнопке отправить btn.click(function(){ if($(this).hasClass('disabled')){ // подсвечиваем незаполненные поля и форму не отправляем, если есть незаполненные поля lightEmpty(); return false } else { send(form) } return false }); }); } function send(form) { var modal = $("#modal-2") $.ajax({ type: "POST", url: urlll, data: form.serialize(), success: function(responce){ $.fancybox.open(modal); yaCounter48183515.reachGoal("zayavka"); setTimeout(function() { // Done Functions $.fancybox.close( true ); form.trigger("reset"); }, 1000); }, }); return false; } // Cache selectors var lastId, topMenu = $(".top-nav, #my-menu-mobile"), topMenuHeight = topMenu.outerHeight() + 50, // All list items menuItems = topMenu.find("a"), // Anchors corresponding to menu items scrollItems = menuItems.map(function() { var item = $($(this).attr("href")); if (item.length) { return item; } }); // mobile mnu var headerNav = $('.fixed-nav .top-nav'), buttonMnu = $('.hamburger'), AnimationSpeed = 400, clonedMenu = headerNav.clone().attr('id','my-menu-mobile').removeAttr('class'), cloneButtonMnu = buttonMnu.eq(1).clone().attr('id','my-mobile-hamburger'); $('body').append(clonedMenu); $("#my-menu-mobile").append(cloneButtonMnu); function openMenu (){ clonedMenu.fadeIn(AnimationSpeed,'swing').css("display","table"); openBool = true; } function closeMenu (){ $("#my-menu-mobile").css('display', 'none'); } $("#my-menu-mobile a").click(function(event) { /* Act on the event */ $("#my-menu-mobile").css('display', 'none'); $('.hamburger').removeClass("is-active"); // addFixmnu(); }); $('.hamburger').click(function(){ $('.hamburger').toggleClass("is-active"); if($('.hamburger').hasClass("is-active")) { openMenu(); } else{ closeMenu(); } }) // Bind click handler to menu items // so we can get a fancy scroll animation var offsetScrl = 0; $(document).on('click', '#my-menu-mobile a', function(event) { closeMenu(); var href = $(this).attr("href"); var offsetTop = href === "#" ? 0 : $(href).offset().top - topMenuHeight - offsetScrl; $('html, body').stop().animate({ scrollTop: offsetTop }, 300); e.preventDefault(); }); menuItems.click(function(e) { closeMenu(); var href = $(this).attr("href"); if (href == "#products") { var offsetTop = href === "#" ? 0 : $(href).offset().top + 10; } else { var offsetTop = href === "#" ? 0 : $(href).offset().top - topMenuHeight - offsetScrl; } console.log('44444') $('html, body').stop().animate({ scrollTop: offsetTop }, 300); e.preventDefault(); }); var openBool = true; // Если вернулись на болшой экран закроем за собой меню) $(window).resize(function(event) { if ($(this).innerWidth() > 768) { if (openBool) { closeMenu(); $('.hamburger').removeClass("is-active"); openBool = false; } } }); // // trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim // if (!String.prototype.trim) { // (function() { // // Make sure we trim BOM and NBSP // var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; // String.prototype.trim = function() { // return this.replace(rtrim, ''); // }; // })(); // } // [].slice.call( document.querySelectorAll( 'input.input__field' ) ).forEach( function( inputEl ) { // // in case the input is already filled.. // if( inputEl.value.trim() !== '' ) { // classie.add( inputEl.parentNode, 'input--filled' ); // } // // events: // inputEl.addEventListener( 'focus', onInputFocus ); // inputEl.addEventListener( 'blur', onInputBlur ); // } ); // function onInputFocus( ev ) { // classie.add( ev.target.parentNode, 'input--filled' ); // console.log(ev); // } // function onInputBlur( ev ) { // if( ev.target.value.trim() === '' ) { // classie.remove( ev.target.parentNode, 'input--filled' ); // } // } // fixed mnu var fixnav = $(".fixed-nav"); $(window).on("scroll", addFixmnu) function addFixmnu(){ var wi_top = $(window).scrollTop(); if (wi_top >= $("#products").offset().top) { fixnav.addClass("fixed-active"); }else{ fixnav.removeClass("fixed-active"); } } addFixmnu(); // $('.brand-slider').kinetic(); if ($(".brand-slider .brand-slider-itm").length <= 8) { var newrow = $(".brand-slider .brand-slider-itm").clone(); $(".brand-slider").append(newrow); } $('section:not(#products, .formblock) .btn-orange').fancybox({ autoFocus : false, // beforeShow: function(){ // sobaka(); // } }); $(".brand-slider").smoothDivScroll({ autoScrollingMode: "always", autoScrollingDirection:"endlessLoopRight", manualContinuousScrolling: true, autoScrollingInterval: 20 }); $(document).on('click', '.politic', function(event) { event.preventDefault(); /* Act on the event */ $.fancybox.open(` `); }); $(document).on('click', '.products-col', function(event) { var title = $(this).find('.h5').text(); event.preventDefault(); /* Act on the event */ $.fancybox.open(``,{ afterShow : function( instance, current ) { $('.phone_mask').mask('+9 (999) 999-99-99'); sobaka(); }, autoFocus : false } ); }); $('.phone_mask').mask('+9 (999) 999-99-99'); // count numb var show = true; var countbox = "#advantagenum"; $(window).on("scroll load resize", function(){ if(!show) return false; // Отменяем показ анимации, если она уже была выполнена var w_top = $(window).scrollTop(); // Количество пикселей на которое была прокручена страница var e_top = $(countbox).offset().top; // Расстояние от блока со счетчиками до верха всего документа var w_height = $(window).height(); // Высота окна браузера var d_height = $(document).height(); // Высота всего документа var e_height = $(countbox).outerHeight(); // Полная высота блока со счетчиками if(w_top + 700 >= e_top || w_height + w_top == d_height || e_height + e_top < w_height){ $(".advantagenum-item > p > span").spincrement({ from: 0, thousandSeparator: "", duration: 2200 }); show = false; } }); // slick lider $('.aboutus-slider').slick({ infinite: true, slidesToShow: 4, slidesToScroll: 1, dots: true, draggable: false, responsive: [ { breakpoint: 992, settings: { slidesToShow: 3 } }, { breakpoint: 768, settings: { slidesToShow: 1 } } ], appendArrows: ".aboutus-slider-wrap", prevArrow: ``, nextArrow: ``, }); });