$(document).ready(function(){ //var basket = new ArtboxBasket(); footerBottom(); slidersItemsPositionFix(); callMobile(); openMobMenu(); closeCallMobileHide(); closeMobMenu(); addArrowMobMenuAndOpen(); modalForms(); popularRequest(); hoverMainMenu(); seoTxt(); scrollUp(); headerPhonesAndMap(); disabledTagsCatalog(); sortList(); pagination(); filters(); priceSlider(); priceSliderFixInputTxt(); menuAllPage(); filtersShowMobil(); searchShow(); openCardParams(); openComments(); checkedFilter(); phoneMask(); blogListTags(); scrollToCommentsWrite(); basketTabs(); basketHiddenRadio(); footerBottom(); 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() { $('body').append('
') } function mobOverlayRemove() { $('.mob-overlay').remove() } function openMobMenu() { $('.menu_mob').click(function () { mobOverlayAdd() $('body').addClass('off-scroll') $('#menu-mob-hidden').addClass('opens') setTimeout(function () { $('#menu-mob-hidden').addClass('visible') },10) }) } function closeCallMobileHide() { $('.call-mobile-wr').removeClass('visible') setTimeout(function () { $('.call-mobile-wr').removeClass('open') },200) } function closeMobMenu() { $('body').on('click','.mob-overlay',function () { mobOverlayRemove() if($('#menu-mob-hidden').hasClass('visible')) { $('#menu-mob-hidden').removeClass('visible') setTimeout(function () { $('#menu-mob-hidden').removeClass('opens') },200) $('body').removeClass('off-scroll') } if($('.btn_call').hasClass('close')) { $('.btn_call').removeClass('close') closeCallMobileHide() } }) $('.close-menu-mob .close_mob').click(function () { mobOverlayRemove() $('#menu-mob-hidden').removeClass('visible') setTimeout(function () { $('#menu-mob-hidden').removeClass('opens') },200) $('body').removeClass('off-scroll') $('#menu-mob-hidden ul li.has_ul').removeClass('open') }) } function addArrowMobMenuAndOpen() { $('#menu-mob-hidden ul li').each(function () { if($(this).find('ul').length>0){ $(this).addClass('has_ul') $(this).parent().addClass('sub_m') $('#menu-mob-hidden>ul').removeClass('sub_m').addClass('sub_m-first'); } }) $('body').on('click','#menu-mob-hidden ul li.has_ul a',function () { if($(this).parent().parent().hasClass('sub_m')){ //если li элемент вложженый if($(this).parent().hasClass('open')){ $(this).parent().removeClass('open') } else { $('.sub_m').find('.has_ul').removeClass('open') $(this).parent().addClass('open') } } if($(this).parent().parent().hasClass('sub_m-first')) { //если ли родительский открываем/закрываем if($(this).parent().hasClass('open')) { $(this).parent().removeClass('open') $(this).parent().find('.open').removeClass('open') } else { $(this).parent().addClass('open') } } }) } var scrollPos = 0; var posY = 0; scrollItemsPos() function scrollItemsPos() { scrollPos = $(this).scrollTop() // console.log(scrollPos) } $(window).scroll(function () { scrollItemsPos() $('.items_.cloned').css({top:posY-scrollPos}) }) function slidersItemsPositionFix() { $('.items_.clone').remove() $('.sliders .items_').mouseover(function () { $('.items_.clone').remove() $('#overlay').addClass('overlay_cloned') if(($(window).width())>=768) { var width = $(this).width(); var posX = $(this).offset().left; posY = $(this).offset().top; var this_ = $(this); this_.clone().appendTo('body').addClass('cloned no-transition').css({ width:width + 29.5, top:posY - scrollPos, left:posX }) } }) $('#overlay').hover(function () { $('.items_.cloned').remove(); $(this).removeClass('overlay_cloned') }, function () { //console.log('leave hover') }) } window.onresize = function () { 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','') } hoverMainMenu() } function callMobile() { $('.btn_call').click(function() { if(!($(this).hasClass('close'))){ $('.btn_call').addClass('close') mobOverlayAdd() $('.call-mobile-wr').addClass('visible') setTimeout( function() { $('.call-mobile-wr').addClass('open') }, 20 ) } else { mobOverlayRemove() closeCallMobileHide() $('.btn_call') .removeClass('close') $('.call-mobile-wr') .removeClass('open') $('body') .removeClass('off-scroll') } }) } function popularRequest() { $('.popular-requests span, .popular-requests a').click(function () { var thisRequest = $(this).html(); $(this).parent().parent().find('form input').val(thisRequest); $(this).parent().parent().find('form').submit(); }) } function hoverMainMenu() { if(window.innerWidth>=992){ var widthMenu = ($('.section-box-content .container').width())-($('.section-box-content .main-menu').width()); $('.main-menu').addClass('full'); $('.main-menu ul li ul').css({width:widthMenu}); } $('.section-box-content .main-menu ul li').each(function () { if($(this).find('ul').length<=0){ $(this).addClass('not-list') } }) } function seoTxt() { var txt1 = $('.all_seo_text').data('show'); var txt2 = $('.all_seo_text').data('hide'); $('.all_seo_text').click(function (e) { e.preventDefault() $('.seo-text').toggleClass('show') $(this).toggleClass('show') if($(this).hasClass('show')) { $(this).html(txt2) } else { $(this).html(txt1); } }) } function scrollUp() { $('.btn_up').click(function () { $('body, html').animate({scrollTop:0}, 500); }) btnScroll() function btnScroll() { btnScrollPos() function btnScrollPos() { var containerPos = $('.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 headerPhonesAndMap() { $('.cities-wr .s_').click(function () { var thisCity = $(this).html() var thisPhones = $(this).next().html() if(!($(this).parents('.cities-wr').hasClass('cities-wr-map'))){ $('.header-phones p').remove() $('.header-phones').append(thisPhones) } else { //блок с картой $('.adress-map span').remove() $('.adress-map').append(thisPhones) var thisDataLat = $(this).data('lat')//определяем координаты lat var thisDataLng = $(this).data('lng')//определяем координаты lng var magaz = $(this).next().find('span'); function initialize() { var start_position = new google.maps.LatLng(thisDataLat, thisDataLng); var styles = [{ stylers: [ { saturation: -100 } ] }]; var settings = { styles: styles, zoom: 12, scrollwheel: false, center: start_position, mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: false, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, scaleControl: true, streetViewControl: true, rotateControl: true, zoomControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), settings); var image1 = new google.maps.MarkerImage('images/markers/marker-we-1.png', new google.maps.Size(34, 48), new google.maps.Point(0,0), new google.maps.Point(16, 35) ); var markers = []; magaz.each(function () { var newLat = $(this).data('lat');//определяем координаты lat var newLng = $(this).data('lng');//определяем координаты lng var newName = $(this).text();//title var marker = new google.maps.Marker({ position: new google.maps.LatLng(newLat, newLng), map: map, title: newName, icon: image1 }); markers.push(marker); }) var clusterStyles = [ { url: 'images/markers/clasters.png', height: 36, width: 36 } ]; markerClusterer = new MarkerClusterer(map, markers, { maxZoom: 10, gridSize: 100, styles: clusterStyles }); } if($(window).width()>=768){ initialize() } $(window).resize(function () { if($(window).width()>=768){ initialize() } }) } $(this).parents('.cities-wr').find('.addCity i').html(thisCity) $(this).parents('.cities-wr').find('.hidden_shops').css({display:'none'}) $(this).parents('.cities-wr').find('.hidden_shops ul li').removeClass('active') $(this).parent().addClass('active') }) $('body').on('click','.adress-map span',function () { var thisDataLat = $(this).data('lat')//определяем координаты lat var thisDataLng = $(this).data('lng')//определяем координаты lng var newName = $(this).text();//название function initialize() { var start_position = new google.maps.LatLng(thisDataLat, thisDataLng); var styles = [{ stylers: [ { saturation: -100 } ] }]; var settings = { styles: styles, zoom: 16, scrollwheel: false, center: start_position, mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, navigationControl: false, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, scaleControl: true, streetViewControl: true, rotateControl: true, zoomControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), settings); var image1 = new google.maps.MarkerImage('images/markers/marker-we-1.png', new google.maps.Size(34, 48), new google.maps.Point(0,0), new google.maps.Point(16, 35) ); var marker = new google.maps.Marker({ position: new google.maps.LatLng(thisDataLat, thisDataLng), map: map, title: newName, icon: image1 }); } if($(window).width()>=768){ initialize() } $(window).resize(function () { if($(window).width()>=768){ initialize() } }) }) } function disabledTagsCatalog() { $('body').on('click','.tags-catalog .disabled',function (e) { e.preventDefault(); }) } function sortList() { $('.sort-cat>a').click(function (e) { if($(this).hasClass('category-sort')){ e.preventDefault(); $('.sort-cat').toggleClass('active') } }) $('.sort-cat ul li a').click(function () { $('.category-sort').html($(this).text()) $('.sort-cat ul li a').removeClass('desc') $(this).addClass('desc') }) var timeoutSort $('.sort-cat').hover(function () { clearTimeout(timeoutSort) },function () { timeoutSort = setTimeout(function () { $('.sort-cat').removeClass('active') },320) }) } function pagination() { $('body').on('click','.pagination li.active',function (e) { e.preventDefault(); }) } function filters() { //удаляем выбранне фильтра(серые кнопки) $('body').on('click','.wrapp_clear-link a',function () { var thisParents = $(this).parent().parent(); $(this).remove(); if($('.wrapp_clear-link a').length<=0){ thisParents.remove(); } }) $('body').on('click','.buttonsSort a.active',function (e) { e.preventDefault(); }) //открываем/скрываем все фильтра $('.close_filter').click(function () { var desiredBlock = $(this).parents('.input-blocks'); desiredBlock.toggleClass('hide_filter'); desiredBlock.find('.s_c_h').removeClass('visible_s_c_h'); desiredBlock.find('.more_six-btn span').removeClass('show_all'); }) //открываем/скрываем группу фильтров(6 штук) $('.more_six-btn span').click(function () { var desiredBlock = $(this).parents('.more_six').find('.s_c_h'); desiredBlock.toggleClass('visible_s_c_h'); $(this).toggleClass('show_all'); }) } function priceSlider(){ var $price_interval = $('#price_interval'); var $filter_prices_min = $('#filter-prices-min'); var $filter_prices_max = $('#filter-prices-max'); if($price_interval.length){ var block = $('#price_block'); var link = block.data('url'); var min = block.data('min'); var max = block.data('max'); var from = block.data('from'); var to = block.data('to'); $price_interval.ionRangeSlider({ type: 'double', min: min, max: max, from: from, to: to, grid: false, hide_min_max: true, hide_from_to: true, onChange: function (e) { $filter_prices_min.val(e.from); $filter_prices_max.val(e.to) }, onFinish: function(e) { } }); $('#btn_ok span').click(function () { var from = $filter_prices_min.val(); var to = $filter_prices_max.val(); $.pjax({url: link.replace('{from}', from).replace('{to}', to), container: "#list-container",timeout:5000, scrollTo: 0}) }); var slider = $price_interval.data("ionRangeSlider"); $filter_prices_min.change(function () { var newVal = $(this).val(); slider.update({ from: newVal }); }); $filter_prices_max.change(function () { var newVal = $(this).val(); slider.update({ to: newVal }); }) } } function priceSliderFixInputTxt() { $('.price_inputs input').keypress(function(e) { if (!(e.which==8 ||(e.which>47 && e.which<58))) return false; }); $('.price_inputs input').focusout(function () { var thisVal = +($(this).val()); var thisMin = +($(this).attr('min')); var thisMax = +($(this).attr('max')); if(thisVal