$(function() {
// Табы в карточке товара
var tab = $('.tab__nav-tabs');
var content = $('.tab__content');
tab.first().addClass('active');
content.not(':first').hide();
tab.on('click', function(){
tab.removeClass('active').eq($(this).index()).addClass('active');
content.hide().eq($(this).index()).show();
});
// Слайдер на странице технологии
$('.tech_slider-row').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
swipe: false,
touchMove: false,
asNavFor: '.tech_band'
});
$('.tech_band').slick({
slidesToShow: 7,
slidesToScroll: 1,
asNavFor: '.tech_slider-row',
dots: false,
centerMode: true,
centerPadding: 0,
focusOnSelect: true,
responsive: [
{
breakpoint: 1800,
settings: {
slidesToShow: 7,
slidesToScroll: 1
}
},
{
breakpoint: 1440,
settings: {
slidesToShow: 6,
slidesToScroll: 1
}
},
{
breakpoint: 1280,
settings: {
slidesToShow: 4,
slidesToScroll: 1
}
},
{
breakpoint: 1025,
settings: {
centerMode: false,
slidesToShow: 4,
slidesToScroll: 1
}
},
{
breakpoint: 770,
settings: {
centerMode: false,
slidesToShow: 3,
arrows: false,
slidesToScroll: 1
}
},
{
breakpoint: 600,
settings: {
centerMode: true,
slidesToShow: 1,
slidesToScroll: 1,
arrows: false
}
}
]
});
// Калькулятор
$(".product_info-option").each(function(){
var $box = $(this),
$selects = $("select", $box),
$materialSel = $selects.filter("#product_select-material"),
$circulationlSel = $selects.filter("#product_select-circulation").hide(),
discountDat = [],
$countInp = $("#product_count", $box);
$("option", $circulationlSel).each(function(){
var $opt = $(this),
circulation = $opt.data("circulation"),
discount = $opt.data("discount");
if(circulation && discount){
discountDat.push({
circulation:circulation,
discount: discount
});
}
});
function getDiscount(count){
var res = 0;
$(discountDat).each(function(){
var data = this;
if(count >= data.circulation){
res = data.discount;
}
});
return res;
}
function calc(){
var $materialOpt = $("option:selected", $materialSel),
material = $materialOpt.data("material") || 0,
materialName = $materialOpt.val(),
circulation = $("option:selected", $circulationlSel).data("circulation") || 1,
count = $countInp.val(),
discount = getDiscount(count),
price = material * (100 - discount) / 100,
totalPrice = price * count,
res = "<span>Цена за шт: <strong>"+ price +"</strong> руб</span><span>Всего за тираж: <strong>"+ parseInt(totalPrice) +"</strong> руб</span><span>Скидка: <strong>"+discount+"</strong> %</span>",
$final = $('#final_price', $box).addClass('active').html(res),
$modal = $(".modal_product-content--total"),
$modalMaterial = $(".select_item-name", $modal).text(materialName),
$modalCount = $(".select_item-total", $modal).html("<span>Ваш тираж: <strong>" + count + "</strong></span>");
}
$selects.on("change", calc);
$countInp.on("keyup mouseup", calc);
});
// Мобильное меню
$('.burger').bind('click', function() {
$('.mobile_menu').toggleClass('open');
});
$('#burger-menu').on('click', function () {
$(this).toggleClass('active');
$('.mobile_menu').toggleClass('active');
$('.overlay').toggleClass('active');
});
$( '.my-menu' ).sliderMenu({
back: '<span class="slider-menu__text">НАЗАД</span>'
});
$('.my-menu .slider-menu-children a').animate({scrollTop: 0});
/* Generate Classes */
$('.mobile_menu-list li').has('ul').addClass('has-children');
// Слайдер в товаре
$('.product_slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoPlay: false,
autoplaySpeed : 4000,
dots : false,
arrows : true,
nextArrow: '<span class="sl_arrow sl_arrow-left"><i class="fas fa-angle-left"></i></span>',
prevArrow: '<span class="sl_arrow sl_arrow-right"><i class="fas fa-angle-right"></i></span>',
centerMode: true,
centerPadding:'',
responsive: [
{
breakpoint: 991,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
dots: false,
arrows: false
}
}
]
});
// Слайдер на главной
$('.slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed : 3000,
dots : true,
arrows : false,
nextArrow: '<span class="sl_arrow sl_arrow-left"><i class="fas fa-angle-left"></i></span>',
prevArrow: '<span class="sl_arrow sl_arrow-right"><i class="fas fa-angle-right"></i></span>',
centerMode: true,
centerPadding:'',
responsive: [
{
breakpoint: 991,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
dots: true,
arrows: false
}
}
]
});
// Слайдер ранее вы смотрели
$('.looked_slider').slick({
slidesToShow: 4,
slidesToScroll: 4,
autoplay: false,
autoplaySpeed : 4000,
dots : false,
arrows : true,
nextArrow: '<span class="sl_arrow sl_arrow-left"><i class="fas fa-angle-left"></i></span>',
prevArrow: '<span class="sl_arrow sl_arrow-right"><i class="fas fa-angle-right"></i></span>',
centerMode: false,
centerPadding:'',
responsive: [
{
breakpoint: 991,
settings: {
slidesToShow: 3,
slidesToScroll: 1,
dots: false,
arrows: true,
centerMode: true
}
},
{
breakpoint: 770,
settings: {
slidesToShow: 3,
arrows: false,
slidesToScroll: 1
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
arrows: true
}
}
]
});
// Верхнее меню
$('.top_menu li').has('ul').addClass('down');
// Боковое меню
$('.catalog_aside li').has('ul').addClass('down');
$('.catalog_aside > ul li.down > ul').before('<span class="btn-dropdown"><i class="fas fa-chevron-right"></i></span>');
$('.catalog_aside .down .btn-dropdown').each(function(){
if($(this).siblings('ul').is(':visible')){
$(this).addClass('active');
}
});
$('.catalog_aside .down .btn-dropdown').click(function(){
$(this).parent().addClass('open');
if($(this).siblings('ul').is(':visible')){
$(this).siblings('ul').slideUp();
$(this).removeClass('active');
}else{
$(this).siblings('ul').slideDown();
$(this).addClass('active');
}
});
// Партнеры
$('.partner_line-more').click(function(e) {
e.preventDefault();
$(this).parents('.partner_line').find('.partner_item-hidden').slideToggle();
$(this).toggleClass('logos-line__more_hide');
var link_text = $(this).text();
$(this).text(
link_text == "смотреть еще" ? "скрыть" : "смотреть еще");
});
// Похожие товары
$('.btn-similar').click(function(e) {
e.preventDefault();
$(this).parents('.similar_section-row').find('.catalog_item-hidden').slideToggle();
$(this).toggleClass('btn-similar--hide');
var link_text = $(this).text();
$(this).text(
link_text == "смотреть еще" ? "скрыть" : "смотреть еще");
});
});