var pageLoaded = false; $(function () { $('ul.left_menu').after($('div.connected-consultants').html()); $('.in_m .inset_top').each(function (){ $(this).css({'right': -($(this).parent().parent().parent().width())}) if ( $(this).height() > 0) { $(this).parent().parent().parent().addClass('act') } }); var url = window.location.pathname.split('/'); $('ul.menu_top > li').each(function(i,el){ if(url[1] == $(' > ', this).attr('href').split('/')[3]) $(' > ', this).addClass('active'); }); $('.accordion .title_accord').click(function(e) { e.preventDefault(); $(this).toggleClass('active'); $(this).next().toggle(); }); if($('ul.big_img_product')[0]) { $("a[rel^='prettyPhoto']").prettyPhoto(); } /*Оборачиваем таблицы блоком с прокруткой если они не влазят на моб версии*/ var windowWidth = $(window).width(); if ( windowWidth<769 ) { $('.txt_content table').each(function(indx){ if ( $(this).width()>windowWidth ) { console.log($(this)); $(this).wrap('
') } }); } /*END Оборачиваем таблицы блоком с прокруткой если они не влазят на моб версии*/ /*mob_burger*/ $('.mob_burger_btn').on('click', function(){ $('.menu_top').toggle(); }); /*END mob burger*/ $(".big_img_product").each(function(){ var i = $(this).attr('id'); $(this).bxSlider({ slideMargin: 0, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: true, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto: false, //òîæå ïîíÿòíî nextText:'', prevText:'', pagerCustom: '.small_img_'+i }); }); $('.thanks ul li:eq(3)').css('clear','both'); $('.carousel_tabs a:first-child').attr('class','active'); $('.carousel_tabs a').click(function(e) { e.preventDefault(); var TabNum = $(this).index(); console.log(TabNum); if ($(this).hasClass('defoul')) { $('.carousel_tabs a').removeClass('active').addClass('defoul'); $(this).removeClass('defoul').addClass('active'); $('.carou_tab').hide().css({'opacity':'0','position':'absolute', 'display':'none','z-index':'1'}); $('.carou_tab').eq(TabNum).show().css({'opacity':'1','position':'relative', 'display':'block', 'z-index':'2'}); } }); $(".slider ul").bxSlider({ startSlide: 0, infiniteLoop: false, slideMargin: 0, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: true, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto: true, //òîæå ïîíÿòíî pause:11000, nextText:'', prevText:'', onSliderLoad: function () { $('.bx-pager.bx-default-pager div:first-child').addClass('fff'); $('.bx-pager.bx-default-pager div:last').addClass('llll'); }, }); if ( $(window).width() < 768 & ($(window).width() > 500) ) { $(".carou_tab .carou_m").bxSlider({ slideWidth: 320, slideMargin: 24, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto:false, //òîæå ïîíÿòíî minSlides: 2, maxSlides: 2, moveSlides: 1, nextText:'', prevText:'' }); } else if ( ($(window).width() <= 500) ){ $(".carou_tab .carou_m").bxSlider({ slideWidth: 320, slideMargin: 0, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto:false, //òîæå ïîíÿòíî minSlides: 1, maxSlides: 1, moveSlides: 1, nextText:'', prevText:'' }); } else if ( ($(window).width() < 1400) & ($(window).width() > 1024) ){ $(".carou_tab .carou_m").bxSlider({ slideWidth: 320, slideMargin: 0, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto:false, //òîæå ïîíÿòíî minSlides: 4, maxSlides: 4, moveSlides: 1, nextText:'', prevText:'' }); } else { $(".carou_tab .carou_m").bxSlider({ slideWidth: 220, slideMargin: 0, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto:false, //òîæå ïîíÿòíî minSlides: 3, maxSlides: 3, moveSlides: 1, nextText:'', prevText:'' }); } /*wr_repair slider*/ if ($(window).width() < 768) { $(".wr_repair ul").bxSlider({ slideWidth: 320, slideMargin: 24, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto: false, //òîæå ïîíÿòíî minSlides: 1, maxSlides: 1, moveSlides: 1, nextText:'', prevText:'' }); } else { $(".wr_repair ul").bxSlider({ slideWidth: 400, //øèðèíà ñëàéäà slideMargin: 24, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto: false, //òîæå ïîíÿòíî minSlides: 2, maxSlides: 2, moveSlides: 2, nextText:'', prevText:'' }); } /*END wr_repair sldier*/ $(".slider_three ul:not(.offSlider)").bxSlider({ slideWidth: 165, //øèðèíà ñëàéäà slideMargin: 0, //ðàññòîÿíèå ìåæäó ñëàéäàìè mode: 'horizontal', //'horizontal', 'vertical', 'fade' - ïåðåõîä speed: 500, //íó ïîíÿòíî pager: false, //ïýéäæèíàòîð randomStart: false, //ðàíäîìíûé 1-é ñëàéä auto: false, //òîæå ïîíÿòíî minSlides: 3, maxSlides: 3, moveSlides: 2, nextText:'', prevText:'' }); $('span.more_repair:not(.news_more)').prev('p').html(function(){ lnk = $(this).next('span').html(); $(this).next('span').remove(); return $(this).text() +''+lnk+''; }); var shadowBox; //$('ul.big_img_product li a, ul.reviews li a, ul.sertificate li a').click(function(ev){ // $('ul.reviews li a, ul.sertificate li a').click(function(ev){ $('ul.sertificate li a').click(function(ev){ ev.preventDefault(); if(!pageLoaded) { $('header').before('
'); var interval = setInterval(function(){ if(pageLoaded) { $('div.popBG').remove(); clearInterval(interval); $('ul.big_img_product li a, ul.reviews li a, ul.sertificate li a').trigger('click'); } },500); return; } var idList = $(this).parents('ul').attr('id'); var classList = $('#'+idList).attr('class'); if(typeof(shadowBox) !== 'undefined') removeShadowBox(); var isShowPager = shadowBoxList[idList]['imgShadowBoxBigDOM'].length > 1 && classList != 'reviews' ? true : false; $('header').before(tplShadowBox(idList, isShowPager)); if(classList != 'big_img_product') { var wClickedImg = $('> img', this).width(); $('div.content_pop_up').css({'width':wClickedImg, 'margin-left':'-'+(parseInt(wClickedImg)/2)+'px'}); $('div.wrapper_pr_card').css({'width':wClickedImg}); $('div.bx-viewport ul li').css({'width':wClickedImg}); } shadowBox = $("#sB"+idList).bxSlider({ slideMargin: 0, mode: 'horizontal', speed: 500, pager: isShowPager, randomStart: false, auto: false, nextText:'', prevText:'', pagerCustom: '.small_img_sB'+idList }); if(!isShowPager) $('#sB'+idList).parent().next().hide(); }); $('a.close_POP').live('click',function(ev){ ev.preventDefault(); removeShadowBox(); }); $('div.popBG').live('click',function(ev){ ev.preventDefault(); $('a.close_POP').trigger('click'); }); var tplShadowBox = function(idList,isShowPager){ tpl = '
'+ '
'+ '
'+ ''+ '
'+ '
'+ '
    '+tplShadowBoxItem(idList,'imgShadowBoxBigDOM')+'
'+ '
'; if(isShowPager) tpl += '
    '+tplShadowBoxItem(idList,'imgShadowBoxSmallDOM')+'
'; tpl += '
'; return tpl; }; var tplShadowBoxItem = function(idList, key) { var tpl = ''; for(var i = 0; i < shadowBoxList[idList][key].length; i++) { switch(key) { case 'imgShadowBoxBigDOM': tpl += '
  • '+shadowBoxList[idList][key][i].outerHTML+'
  • '; break; case 'imgShadowBoxSmallDOM': tpl += '
  • '+shadowBoxList[idList][key][i].outerHTML+'
  • '; break; } } return tpl; } loadImage = function(img) { var imgDOM = []; if(img.length > 0) { for(var i = 0; i < img.length; i++) { imgDOM[i] = new Image(); imgDOM[i].src = img[i]; } } return imgDOM; } function removeShadowBox() { $('div.popBG, div.content_pop_up').remove(); shadowBox = null; } $('a').click(function (e) { var href = $(this).attr('href'); var urlObj = new URL(href, window.location.origin); var urlHash = urlObj.hash; if (urlHash) { e.preventDefault(); if (typeof window.history !== 'undefined' && typeof window.history.pushState === 'function') { window.history.pushState(null, null, href); } showPopupFromHash(); } }); }); window.onload = function(){ for(var el in shadowBoxList) { shadowBoxList[el]['imgShadowBoxBigDOM'] = loadImage(shadowBoxList[el]['imgShadowBoxBig']); shadowBoxList[el]['imgShadowBoxSmallDOM'] = loadImage(shadowBoxList[el]['imgShadowBoxSmall']); } pageLoaded = true; }; $(document).ready(function(){ // if hash exists -> try to open popup if (window.location.hash) { showPopupFromHash(); } /* var $menu = $(".wrapper_menu"); $(window).scroll(function(){ if ( $(this).scrollTop() > 92 && $menu.hasClass("default") ){ $menu.removeClass("default").addClass("fixed"); } else if($(this).scrollTop() <= 92 && $menu.hasClass("fixed")) { $menu.removeClass("fixed").addClass("default"); } });//scroll*/ $('.showPopUpForm').on('click', function(e) { var $this = $(this), $targetForm = $this.data('target'), $directorForm = $('#form4824'), $consultantForm = $('#form4819'), consultantEmail = $this.data('email'), $layout = $('.layout'), fadeInDuration = 600, $customForm = $('.form-' + $targetForm); e.preventDefault(); if ($targetForm == 'director') { $directorForm.fadeIn(fadeInDuration); } else if ($targetForm == 'consultant') { $consultantForm.find('#seh').attr('value', consultantEmail); $consultantForm.fadeIn(fadeInDuration); } else if ($customForm.length){ $customForm.fadeIn(fadeInDuration); } else { return; } $layout.fadeIn(fadeInDuration); }); $('.closePopUpForm').on('click', function(e) { var $layout = $('.layout'), $PopUpForms = $('.layout .send_mes'); fadeInDuration = 600; e.preventDefault(); //window.history.go(-1); $layout.add($PopUpForms).fadeOut(fadeInDuration); }); /*$(document).mouseup(function(e) { var $container = $('.layout .send_mes'), fadeInDuration = 600; if ($container.has(e.target).length === 0) { $container.fadeOut(fadeInDuration); $('.layout').fadeOut(fadeInDuration); } });*/ $('.menu_top li a[href="https://www.mari.by/kommercheskij-transport"]').addClass('iveco_menu'); // MOD: autoservice popup // open popup by window hash if (window.location.hash.length > 1){ var $el = $('.href-' + window.location.hash.substr(1)); if ($el.length){ $el.click(); } } // form scripting $('.form-autoservice').submit(function () { var $form = $(this); var $container = $form.find('.form__container'); if ($container.hasClass('freeze')){ // already sending return false; } $container.addClass('freeze'); var contact = {}; var formFields = $form.serializeArray(); for(var x in formFields){ contact[formFields[x]['name']] = formFields[x]['value']; } $.ajax({ type: 'POST', url: '/sku-service/api.php', data: { action: 'autoservice', contact: contact } }).done(function (raw) { var data = null; try { data = JSON.parse(raw); } catch (e) { // } if (data) { if (data.error) { $form.find('.form__message').html('' + data.error + ''); } else { $form.find('.form__message').html('' + data.message + ''); } } }).fail(function () { $form.find('.form__message').html('Не удалось оставить заявку. ' + 'Вы также можете оставить заявку по телефону.'); }).always(function () { $container.removeClass('freeze'); }); return false; }); // ~~~ }); // redirect to https to prevent CORS issues if (window.location.protocol === 'http:'){ window.location.protocol = 'https:'; throw 'Redirect'; } // inject sku service if (/zapchasti-group/.test(window.location.href)){ $.getScript('/sku-service/api.php?action=ui'); } // handle modal showing when hash exists function showPopupFromHash() { var hashWithoutPrefix = window.location.hash.replace('#', ''); if (hashWithoutPrefix) { try { var $popup = $('.' + hashWithoutPrefix); if ($popup.length) { var fadeInDuration = 600; var $layout = $('.layout'); $popup.fadeIn(fadeInDuration); $layout.fadeIn(fadeInDuration); } } catch (e) { } } } $(window).on('hashchange', function (e) { e.preventDefault(); showPopupFromHash(); });