Your IP : 3.139.81.238


Current Path : /home/bitrix/ext_www/dev.ballu.in.ua/turbo/assets/js/
Upload File :
Current File : /home/bitrix/ext_www/dev.ballu.in.ua/turbo/assets/js/script.js

$(document).ready(function() {





    // compare
    $('.compare__cell').hover(function() {
      var currentIndex = $(this).index();
      $(this).parents('.compare').find('.c-line').each(function(index, el) {
        $(this).find('.compare__cell').eq( currentIndex).addClass('hover');
      });

    }, function() {
      $(this).parents('.compare').find('.c-line').each(function(index, el) {
        $(this).find('.compare__cell').removeClass('hover');
      });
    });

    findCompareItemCellMaxHeight();
    $('.slider_turbo').slick({
      infinite: false,
      dots: false,
      arrows:true,
      autoplay: true,
      autoplaySpeed:4000,
      slidesToShow: 3,
      slidesToScroll: 3,
      vertical:false,
      responsive: [
      {
        breakpoint: 1681,
        settings: {
          slidesToShow: 3,
          slidesToScroll: 3,
        }
      },
      {
        breakpoint: 1368,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 2,
        }
      },
      {
        breakpoint: 1023,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 2,
        }
      },
      {
        breakpoint: 800,
        settings: {
          slidesToShow: 2,
          slidesToScroll: 2,
        }
      },
      {
        breakpoint: 480,
        settings: {
          slidesToShow: 1,
          slidesToScroll: 1,
        }
      },
          {
              breakpoint: 321,
              settings: {
                  slidesToShow: 1,
                  slidesToScroll: 1,
                  dots: true
              }
          }]

    });
    // $('.compare__cell_same').hide();
    findCompareItemCellMaxHeight();

    $('.compare__slider_turbo').slick({
      infinite: false,
      dots: false,
      arrows:true,
      autoplay: true,
      autoplaySpeed:4000,
      slidesToShow: 2,
      slidesToScroll: 2,
      vertical:false,
      responsive: [
      {
        breakpoint: 480,
        settings: {
          slidesToShow: 1,
          slidesToScroll: 1
        }
      }]

    });

/*    //buy button
    $('.buy-button').click(function(e){
      e.preventDefault();
        var anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $(anchor.attr('href')).offset().top
        }, 777);
        e.preventDefault();
        return false;
    });*/

    //short compare list or long list
    $('.control_delete').click(function() {
      $(this).toggleClass('active');
      var slideToggleCnt = $(this).parents('.compare').find('.compare__cell_same').length;
      $(this).parents('.compare').find('.compare__cell_same').slideToggle('slow',function(){
       slideToggleCnt = slideToggleCnt;
       if(slideToggleCnt === 0){
        findCompareItemCellMaxHeight();


        $(document).trigger('resize');
        $('html,body').animate({
          scrollTop: $(this).parents('.compare').offset().top},
          'fast');
      }

    });

    });
    //color
    $('.colors__item').click(function() {
      $('.colors__item').removeClass('active');
      $(this).addClass('active');
    });


/*  //cities
    $('.js-show-city-block').click(function(e){
      e.preventDefault();
      $(this).parents('.block').find('.block_city').slideToggle('fast');
      $('html,body').animate({
          scrollTop: $(this).parents('.block').find('.block_city').offset().top},
          'slow');
    });
    $('.city__item').click(function(e) {
      e.preventDefault();

      var currentObject = $(this);
      var country =  $(this).attr('data-country');
      var city =  $(this).attr('data-city');
      var city_name =  $(this).text();
      var category =  $(this).attr('data-category');
      var link = '' + $(this).attr('href') +'&format=json'+ '';

      $.getJSON(link, function( data ) {
        var obj = data;
        var text = '';
        $.each( data, function( key, val ) {
          var output = '';
          for (var property in val) 
          {
           text += '<div class="shops__item">';
           var shop = val[property];
           if (shop.name !== null) {
             text += '<div class="shops_name">' + shop.name + '</div>';
           }
           if (shop.address !== null) {
             text += '<div class="shops_line">' + shop.address + '</div>';
           }
           if (shop.phone !== null) {
             text += '<div class="shops_line">' + shop.phone + '</div>';
           }
           if (shop.site !== null) {
             text += '<div class="shops_line"><a href="http://'+shop.site+'" target="_blank">' + shop.site + '</a></div>';
           }
           text += '</div>';
         }
       });
        $('.cities__modal-block').find('.shops').html(text);
        $('.cities__modal-block').find('.cities__header').text(city_name);

        $('.cities__modal-block').fadeIn('fast', function() {
         $('.cities__modal').addClass('active');
       });
        $(".shops").mCustomScrollbar({
         theme:"minimal",
         autoHideScrollbar:false,
         alwaysShowScrollbar: 2
       });

      });

    });

    $('.cities__close').click(function() {
      $('.cities__modal-block').fadeOut('fast', function() {
        $('.cities__modal').removeClass('active');
      });
      $(".shops").mCustomScrollbar("destroy");
    });
    $(document).click( function(event){
      if(( $(event.target).closest(".cities__body").length )||($(event.target).closest(".city__item").length))
        return;
        $('.cities__modal-block').fadeOut('fast', function() {
          $('.cities__modal').removeClass('active');
        });
        $(".shops").mCustomScrollbar("destroy");
      event.stopPropagation();
    });

    $(document).resize(function(event) {
        block14Resize();
        var maxHeights = [];
         findCompareItemCellMaxHeight();
    });;*/
});

//function to fix compare block cells height
function  findCompareItemCellMaxHeight()
{
  var maxHeights = [];
  setTimeout(function () {
    $('.compare').each(function() {
      currentCompare = $(this);
      for(j=0; j<currentCompare.find('.c-line .compare__cell').length / currentCompare.find('.c-line').length; j++)
      {
        height = 0;

        for(i=0; i < currentCompare.find('.c-line').length; i++)
        {
          cell = currentCompare.find('.c-line').eq(i).find('.compare__cell').eq(j);

          if(cell.is(":visible") === true)
          {
            if(height < cell.height())
            {
              height = cell.height();
            }
          }
        }
        maxHeights.push(height);
      }
      currentCompare.find('.compare__cell').each(function(){
        var index = $(this).index();
        if(maxHeights[index] > 0){
          $(this).height(maxHeights[index]);
        }
      });
    });

  }, 500);
}




$(".butn-buy").click(function(e)
  {
    e.preventDefault();
    
    var prod_id = $(this).attr("data-id");
    
    if(prod_id > 0)
    {
      $.fancybox({
        'padding'       : 0,
        //'autoScale'     : false,
        //'transitionIn'  : 'none',
        //'transitionOut' : 'none',
        'width'         : 680,
        'height'        : 500,
        
        "href": "/ajax/add2basket.php",
        "type": "ajax",
        "ajax": {
          "type": "POST",
          "data": {
            "id": prod_id
          }
        }
      });
    }
  });
$('.buy-button').click(function(e){
      e.preventDefault();
        var anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $(anchor.attr('href')).offset().top
        }, 777);
        e.preventDefault();
        return false;
    });

if($(window).width()<415) {
  $('.advantages-block__icon').slick({
  infinite: true,
  dots: true,
  slidesToShow: 1,
  slidesToScroll: 1
  });
}



if($(window).width()<321) {
  $('.option__img-text').slick({
  infinite: true,
  slidesToShow: 1,
  slidesToScroll: 1
  });
}

  
$('.block__icons').slick({
  arrows: true,
  dots: false,
  infinite: true,
  slidesToShow: 2,
  slidesToScroll: 2,
  mobileFirst: true,
  responsive: [{
    breakpoint: 480,
    settings: 'unslick'
  }]
});