$(document).ready(function() { footerBottom(); scrollUp(); callMobile(); modalForms(); pagination(); openMobMenuNew(); closeMobMenu(); citySelectHomeAndFoterAndShops(); 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 catalogMenu() { $('.menu-catalog').children('ul').children('li').each(function () { if($(this).find('ul').length>0){ $(this).addClass('has-list'); $(this).attr('length-childs', $(this).find('.category-name').length); } }) $('.header-catalog-button').click(function (e) { e.preventDefault(); if($(this).hasClass('not-home-menu')) { $('.menu-pages .menu-catalog').fadeIn(500); $('.header-catalog-button').addClass('active') } else { // главная $('body, html').animate({scrollTop:($('.menu-catalog').offset().top)}, 500); } }) function catalogGo(this_) { console.log($(window).width()) if($(window).width()>767){ $('#overlay-catalog').addClass('show'); $('.menu-catalog ul li.has-list .first-a').parent().removeClass('active'); this_.parent().addClass('active'); } else { // $('.menu-catalog ul li.has-list .first-a').parent().find('.sub-menu-hidden').slideUp(200); if(this_.parent().hasClass('active-mob')) { //$('.menu-catalog ul li.has-list .first-a').parent().removeClass('active-mob'); this_.parent().removeClass('active-mob'); this_.parent().find('.sub-menu-hidden').css({height:0}); } else { //$('.menu-catalog ul li.has-list .first-a').parent().removeClass('active-mob'); var lengthChilds = +(this_.parent().attr('length-childs')); var mobHeight = (this_.height()) + 2; this_.parent().find('.sub-menu-hidden').css({height:lengthChilds * mobHeight + lengthChilds}); this_.parent().addClass('active-mob'); //this_.parent().find('.sub-menu-hidden').slideDown(300); } // $('.menu-catalog ul li.has-list .first-a').parent().find('.sub-menu-hidden').slideUp(200); // setTimeout(function () { // // },210) } } function catalogClear() { if($('.header-catalog-button').hasClass('not-home-menu')) { //если не главная $('.menu-pages .menu-catalog').fadeOut(400); $('.header-catalog-button').removeClass('active') } $('#overlay-catalog').removeClass('show'); $('.menu-catalog ul li.has-list .first-a').parent().removeClass('active'); } var timeout; var timeoutTimer = 200; $('.menu-catalog ul li.has-list .first-a').hover(function () { var this_ = $(this); if($(window).width()>991){ timeout = setTimeout(function () { catalogGo(this_) },timeoutTimer) } },function () { clearTimeout(timeout) }) $('#overlay-catalog').hover(function () { if($(window).width()>991){ timeout = setTimeout(function () { catalogClear() },300) } },function () { clearTimeout(timeout) }) $('.menu-catalog ul li.has-list .first-a').click(function () { if($(window).width()<=991){ var this_ = $(this); catalogGo(this_); } }) $('#overlay-catalog').click(function () { catalogClear() }) $('.mobi-menu-catalog').children('ul').children('li').each(function () { if($(this).find('ul').length>0){ $(this).addClass('has-list'); } }) $('.mobi-menu-catalog .first-a-mob').click(function () { if($(this).parent().hasClass('active')) { $(this).parent().removeClass('active'); } else { $(this).parent().addClass('active'); } }) } $(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') $('.mob_filters_wr').attr('style','') } }) 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) } function pagination() { $('body').on('click','.pagination li.active',function (e) { e.preventDefault(); }) } function citySelectHomeAndFoterAndShops() { $('.title_city-sel span.addCity,.title_card span.addCity, .shops-title span.addCity').click( function() { $(this) .toggleClass('active') if ($(this) .hasClass('active')) { $(this) .parents('.city-sel') .addClass('active') $(this) .parents('.city-sel') .find('#hidden_shops') .removeClass('_off') } else { $(this) .parents('.city-sel') .find('#hidden_shops') .addClass('_off') $(this) .parents('.city-sel') .removeClass('active') } } ) $('#hidden_shops li').click( function() { $('#hidden_shops li') .removeClass('active') $(this) .addClass('active') var cityName = $(this) .find('span.s_') .html() $(this) .parents('.city-sel') .find('span.addCity') .empty() .html(cityName) var footerCity = $(this) .parents('.shops-title').length if (footerCity <= 0) { var cityPhones = $(this) .find('div.phones_content') .html() $('#shops_phones, #shops_page') .animate( {opacity: 0}, 450, function() { $(this) .animate({opacity: 1}, 250) .empty() .html(cityPhones) } ) $(this) .parents('.city-sel') .find('span.addCity') .removeClass('active') $(this) .parents('.city-sel') .removeClass('active') $(this) .parents('.city-sel') .find('#hidden_shops') .addClass('_off') } else { var shops = $(this) .find('.phones_content') .html(); $('.footer_add') .empty() .append(shops) $(this) .parents('.city-sel') .find('span.addCity') .removeClass('active') $(this) .parents('.city-sel') .removeClass('active') $(this) .parents('.city-sel') .find('#hidden_shops') .addClass('_off') } } ) var timeoutCitySel $('.city-sel') .hover( function() { var this__ = $(this) clearTimeout(timeoutCitySel) }, function() { var this__ = $(this) timeoutCitySel = setTimeout( function() { this__.find('span.addCity') .removeClass('active') this__.removeClass('active') this__.find('#hidden_shops') .addClass('_off') }, 320 ) } ) } })