(function() {
$(document).ready(function() {
$('.windows__items-info-btn').click(function() {
$(this).closest('.windows__items-item').removeClass('is--fade').toggleClass('is--opened')
.siblings().removeClass('is--opened').toggleClass('is--fade');
});
// Экран
var screenWidth = $(window).width();
//
var viewport = 992;
// ПК
var IsDesktop = screenWidth >= viewport;
/* Alex code */
// var cityBox = $('.lp-city__list');
//
// $.each(MoJson, function(index, value) {
// var LetterDiv = '
' + index + '
';
// cityBox.append(LetterDiv);
//
// $.each(value, function(subindex, subvalue) {
// var cities = '';
// cityBox.append(cities);
// });
// });
//
// var windowWidth = $(window).width();
// var num_cols_num = 5;
// if (windowWidth < 800 && windowWidth > 620) {
// num_cols_num = 4;
// }
// if (windowWidth < 620 && windowWidth > 540) {
// num_cols_num = 3;
// }
// if (windowWidth < 540 && windowWidth > 360) {
// num_cols_num = 2;
// }
// if (windowWidth < 360) {
// num_cols_num = 1;
// }
// $(function($) {
// var num_cols = num_cols_num,
// container = cityBox,
// listItem = 'div',
// listClass = 'sub-list';
// container.each(function() {
// var items_per_col = new Array(),
// items = $(this).find(listItem),
// min_items_per_col = Math.floor(items.length / num_cols),
// difference = items.length - (min_items_per_col * num_cols);
// for (var i = 0; i < num_cols; i++) {
// if (i < difference) {
// items_per_col[i] = min_items_per_col + 1;
// } else {
// items_per_col[i] = min_items_per_col;
// }
// }
// for (var i = 0; i < num_cols; i++) {
// $(this).append($('').addClass(listClass));
// for (var j = 0; j < items_per_col[i]; j++) {
// var pointer = 0;
// for (var k = 0; k < i; k++) {
// pointer += items_per_col[k];
// }
// $(this).find('.' + listClass).last().append(items[j + pointer]);
// }
// }
// });
// });
/* #Alex code */
// Аккордион
$('.clickable--area').click(function() {
$(this).closest('.clickable').toggleClass('is--opened').siblings().removeClass('is--opened');
});
// Переключалка городов
$('.lp-city__list-group').click(function() {
$(this).toggleClass('is--opened').closest('.lp-city__list').find('.is--opened').not(this).removeClass('is--opened');
$('.lp-city__list-col').css('margin-top', 0);
var h = $(this).find('.lp-city__list-group-items').height();
$(this).closest('.lp-city__list-col').next().css({
'margin-top': $(this).hasClass('is--opened') ? h + 10 : 0
});
});
function initSwiper() {
if (!IsDesktop) {
// Инит слайдеров
$('.sw__slider_ok').each(function() {
var slider = $(this);
var showCardLogic = function() {
slider.find('.swiper-slide-active').addClass('is--current').siblings().removeClass('is--current');
};
var settings = {
paginationClickable: true,
observer: true,
observeParents: true,
nextButton: slider.find('.sw__slider--dotted-button-next'),
prevButton: slider.find('.sw__slider--dotted-button-prev'),
pagination: slider.find('.sw__slider--dotted-pagination'),
speed: 800,
centeredSlides: true,
loop: slider.data('loop'),
autoplay: slider.data('autoplay'),
slidesPerView: slider.data('slides') || 'auto',
spaceBetween: slider.data('space'),
onInit: function() {
showCardLogic();
},
onSlideChangeEnd: function() {
showCardLogic();
}
};
// Эффект показа слайдов
var effect = slider.data('effect');
if (effect) {
settings.effect = effect;
switch (effect) {
case 'fade':
settings.fade = {
crossFade: true
};
break;
}
}
if (slider.data('type') == 'cards') {
settings.breakpoints = {
991: {
effect: 'slide',
speed: 300
}
};
}
new Swiper(slider, settings);
});
}
}
// Swiper plugin initialization
initSwiper();
});
})();