$(document).ready(function() { footerBottom(); scrollUp(); callMobile(); modalForms(); openMobMenuNew(); closeMobMenu(); phoneMask(); catalogMenu(); function footerBottom(){ var heightHeader = document.getElementById('header_').offsetHeight var heightFooter = document.getElementById('footer_').offsetHeight var windowHeight = window.innerHeight document.getElementById('content_').style.minHeight = windowHeight-heightHeader-heightFooter+'px'; } function mobOverlayAdd() { if($('body').find('.mob-overlay').length > 0) { } else { $('body').append('
') } $('.mob-overlay').fadeIn(300); } function mobOverlayRemove() { $('.mob-overlay').fadeOut(300); $('body').removeClass('show-block-mobile'); setTimeout(function () { $('body').removeClass('body-fixed'); },510) } function openMobMenuNew() { $('.menu_mob').click(function () { mobOverlayAdd() $('body').addClass('body-fixed show-block-mobile'); }) } function closeCallMobileHide() { $('.call-mobile-wr').removeClass('visible') setTimeout(function () { $('.call-mobile-wr').removeClass('open') },200) } function closeMobMenu() { $('body').on('click','.mob-overlay',function () { mobOverlayRemove(); }) $('.close-mobile-menu').click(function () { mobOverlayRemove(); }) } function scrollUp() { $('.btn_up').click(function () { $('body, html').animate({scrollTop:0}, 500); }) btnScroll() function btnScroll() { btnScrollPos() function btnScrollPos() { var containerPos = $('#content_ .container').offset().left // console.log($('.container').offset().left) $('.btn_up').css({right:containerPos}) } btnScrollShowHide() function btnScrollShowHide() { var windowHeight = $(window).height() if($(this).scrollTop() < windowHeight) { $('.btn_up').removeClass('visible') } else { $('.btn_up').addClass('visible') } var scrpos = $(this).scrollTop() var documentHeight = $(document).height() var fHe = ($('.section-box-footer').height())-39 var fPos = $('.section-box-footer').offset().top var docFooterHeight = documentHeight-fHe-windowHeight if(($(this).scrollTop())>=docFooterHeight){ $('.btn_up').css({bottom:(fHe+16)-((documentHeight-scrpos)-($(window).height()))}) } else { $('.btn_up').css({bottom:16}) } } $(window).resize(function () { btnScrollPos() btnScrollShowHide() }) $(window).scroll(function () { btnScrollShowHide() }) $('.btn_scroll').click(function () { $('body,html').animate( { scrollTop: 0 }, 500 ); }) } } function callMobile() { //new $('.btn_call').click(function() { $('.btn_call').addClass('close'); $('.btn_call_close').addClass('visible'); mobOverlayAdd(); $('.call-mobile-wr').addClass('visible'); setTimeout( function() { $('.call-mobile-wr').addClass('open') }, 20 ) }) $('.btn_call_close').click(function () { $(this).removeClass('visible'); mobOverlayRemove(); closeCallMobileHide(); $('.btn_call') .removeClass('close'); $('.call-mobile-wr').removeClass('open'); $('body').removeClass('off-scroll'); }) } function phoneMask() { var phoneInput = '.phones_mask input' if($('body').find('.phones_mask').find('input').length>0){ $(phoneInput).mask('(000) 000-00-00',{placeholder:'(0__)___-__-__'}); $(phoneInput).focus(function () { var text = $(this).val(); $(this).val(text); if(($(this).val())== '') {$(this).val('(0')} }) $(phoneInput).focusout(function () { var phoneVal = $(this).val() //if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')} if(phoneVal.length <17) {$(this).val('')} }) } } function catalogMenu() { $('.mobi-menu-catalog').children('ul').children('li') .each(function() { if ($(this) .find('ul').length > 0) { $(this) .addClass('has-list'); } }) $('.mobi-menu-catalog a').click(function() { if ($(this).parent().hasClass('active-menu')) { $(this).parent().removeClass('active-menu'); } else { $(this).parent().addClass('active-menu'); } }) } $(window).resize(function () { // heightSliderCol(); footerBottom(); if(window.innerWidth>=992){ mobOverlayRemove() $('#menu-mob-hidden').removeClass('visible') setTimeout(function () { $('#menu-mob-hidden').removeClass('opens') },200) $('body').removeClass('off-scroll') $('body').removeClass('hidden_scroll-y') } }) function modalForms() { $('body').on('click','.modal-link', function (e) { e.preventDefault(); e.stopPropagation(); mobOverlayRemove() $('#menu-mob-hidden').removeClass('visible') setTimeout(function () { $('#menu-mob-hidden').removeClass('opens') },200) $('body').removeClass('off-scroll') mobOverlayRemove() closeCallMobileHide() $('.btn_call').removeClass('close') $('.call-mobile-wr').removeClass('open') $('body').removeClass('off-scroll') var idForm = $(this).data('form'); var pos = ($(window).scrollTop()) + 30; if($(this).hasClass('fixed-modal')){ pos = 30; $('#'+idForm).css({position:'fixed'}) } if($(this).hasClass('pos-top')){ pos = 30; } $('#overlay').removeClass('overlay_cloned'); $('#overlay').fadeIn(400, function(){ $('#'+idForm) .css('display', 'block') .animate({opacity: 1, top: pos}, 200); }); }) } closeForms(); function closeForms() { $('#modal_close, #overlay').click( function(){ $('.forms_, .basket_modal').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).prev("#overlay").css('display', 'none'); $('#overlay').fadeOut(400); }); $('#success_form').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); $(this).prev("#overlay").css('display', 'none'); $(this).css({top:'50%'}); }); }); } //после удачной отправки формы запускать success() // success() function success() { var pos = ($(window).scrollTop()) + 30; $('.forms_').animate({opacity: 0, top: '0'}, 200,function(){ $(this).css('display', 'none'); }); setTimeout(function () { $('#overlay').fadeIn(400); $('#success_form').css('display', 'block').animate({opacity: 1, top: pos}, 700); },400) } if($(window).width() >= 768) { animations(); } function animations() { if($('.section-box-3').length) { $('.section-box-3').addClass('anim') function animBox3() { var scrollPos = $(window).scrollTop(); var windHeight = $(window).height(); var bl = $('.section-box-3'); var pos = bl.offset().top; if(scrollPos >= (pos - (windHeight - 200 ))) { bl.addClass('start') } } } if($('.section-box-4').length) { $('.section-box-4').addClass('anim') function animBox4() { var scrollPos = $(window).scrollTop(); var windHeight = $(window).height(); var bl = $('.section-box-4'); var pos = bl.offset().top; if(scrollPos >= (pos - (windHeight - 200 ))) { bl.addClass('start'); setTimeout(function () { bl.addClass('start2'); },1100) setTimeout(function () { bl.addClass('start3'); },1100+2500) } } } if($('.section-box-2').length) { $('.section-box-2').addClass('anim'); $('.categories-home .img').click(function () { var link = $(this).parent().find('.categories-home-links-title a').attr('href'); document.location.href = link; }) function animBox2() { var scrollPos = $(window).scrollTop(); var windHeight = $(window).height(); var bl = $('.section-box-2'); var pos = bl.offset().top; if(scrollPos >= (pos - (windHeight - 200 ))) { bl.addClass('start'); setTimeout(function () { bl.addClass('start2'); },1100) } } } $(window).scroll(function () { animBox3(); animBox4(); animBox2(); }) } showTextHome() function showTextHome() { $('.show-txt-mo span').click(function () { if($(this).parent().hasClass('hide-status')){ $('.for-hidden-mob').removeClass('status-hide'); $(this).parent().removeClass('hide-status'); var text = $(this).parent().data('langhide'); $(this).find('b').html(text); } else { $('.for-hidden-mob').addClass('status-hide'); $(this).parent().addClass('hide-status'); var text = $(this).parent().data('langshow'); $(this).find('b').html(text); } }) } $('nav').addClass('hide_') $('body').addClass('start-preloader') window.onload = function () { // // $('body').addClass('end-preloader') // $('nav').addClass('start') // $('body').addClass('disabled-preloader') //альтернативный с задержкой выключения setTimeout(function () { $('body').addClass('end-preloader') },2700) setTimeout(function () { $('nav').addClass('start') $('body').addClass('disabled-preloader') },2700 + 2000) } })