// $(window).on('load', function () {
// $preloader = $('#preloader'),
// $loader = $preloader.find('#loader');
// $loader.fadeOut();
// $preloader.delay(350).fadeOut('slow');
// });
/*new ImageZoom(document.getElementById("img-container"), {
fillContainer: true,
zoomWidth: 600,
offset: {vertical: 0, horizontal: 10}
});*/
$(document).ready(function () {
$(".top-block-slider").on("init", function (e, slick) {
var $firstAnimatingElements = $("div.top-block-item:first-child").find("[data-animation]");
doAnimations($firstAnimatingElements);
});
$(".top-block-slider").on("beforeChange", function (e, slick, currentSlide, nextSlide) {
var $animatingElements = $('div.top-block-item[data-slick-index="' + nextSlide + '"]').find("[data-animation]");
doAnimations($animatingElements);
});
$(".top-block-slider").slick({
autoplay: true,
autoplaySpeed: 10000,
dots: false,
fade: true,
prevArrow: '
',
nextArrow: '',
});
function doAnimations(elements) {
var animationEndEvents = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
elements.each(function () {
var $this = $(this);
var $animationDelay = $this.data("delay");
var $animationType = "animated " + $this.data("animation");
$this.css({
"animation-delay": $animationDelay,
"-webkit-animation-delay": $animationDelay,
});
$this.addClass($animationType).one(animationEndEvents, function () {
$this.removeClass($animationType);
});
});
}
$(".header__hamburger").click(function () {
if ($(this).hasClass("active")) {
$(this).removeClass("active");
$(".header-tablet").removeClass("active");
$("body").removeClass("_no-scroll");
$("html").removeClass("_no-scroll");
} else {
$(this).addClass("active");
$(".header-tablet").addClass("active");
$("body").addClass("_no-scroll");
$("html").addClass("_no-scroll");
}
});
$(".new-product-slider").slick({
dots: true,
infinite: true,
slidesToShow: 4,
slidesToScroll: 4,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 991,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
dots: false,
},
},
{
breakpoint: 780,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
dots: false,
},
},
{
breakpoint: 560,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
dots: false,
},
},
],
});
$(".description-slider").slick({
dots: true,
arrows: false,
infinite: false,
slidesToShow: 1,
slidesToScroll: 1,
fade: true,
cssEase: "linear",
autoplay: true,
autoplaySpeed: 2000,
appendDots: $(".slider-arrows"),
});
$(".news-slider").slick({
dots: false,
infinite: false,
slidesToShow: 2,
slidesToScroll: 2,
prevArrow: '',
nextArrow: '',
responsive: [
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
},
},
],
});
$(".item-slider").slick({
dots: false,
infinite: false,
slidesToShow: 1,
slidesToScroll: 1,
speed: 500,
cssEase: "linear",
fade: true,
// variableWidth: true,
prevArrow: '',
nextArrow: '',
lazyLoad: 'ondemand'
});
$(".nav-tabs .nav-item, .product-container .slick-arrow").click(function () {
$('.item-slider').slick("refresh");
});
$("a.new-product-item .slick-arrow").click(function (event) {
event.preventDefault();
});
$(".header-container .header-right .search-icon").click(function () {
if ($(".search-block-bg").css("display") == "none") {
$(".search-block-bg").fadeIn();
$(".bg").fadeIn();
} else {
$(".search-block-bg").fadeOut();
$(".bg").fadeOut();
}
});
$(".search-block").click(function () {
if ($(".search-block-bg").css("display") == "none") {
$(".search-block-bg").fadeIn();
$(".bg").fadeIn();
} else {
$(".search-block-bg").fadeOut();
$(".bg").fadeOut();
}
});
$(".bg").click(function () {
$(".search-block-bg").fadeOut();
$(".bg").fadeOut();
});
$(".close-icons").click(function () {
$(".search-block-bg").fadeOut();
$(".bg").fadeOut();
});
var offset = 0; // Вешаем обработчик события "клик" на кнопку с классом .more
$("button.more").click(function () {
// Ajax post-запрос к странице, выдающей ресурсы (в ней сниппет ajaxResources)
var data = $(this).data();
$.post("http://modx.ws/demo/ajax", data, function (data) {
offset += 5; // Выдаем ответ
$("#result").append(data);
$("button.more").data("offset", offset);
}); // В случае если у вас вместо кнопки ссылка - a href="#", то расскоментируйте строку ниже
//return false;
});
$(".nav-link").click(function () {
$(".nav-link").removeClass("active");
$(this).addClass("active");
let id = $(this)[0].id;
let item = Array.from($(".tab"));
item.forEach((element) => {
if (element.id == id) {
element.classList.add("active");
} else {
element.classList.remove("active");
}
});
});
$(".Geosales-region").click(function () {
if ($(this).hasClass("open")) {
$(".Geosales-region").removeClass("open");
$(this).addClass("open");
} else {
$(".Geosales-region").removeClass("open");
}
});
// var scene = new ScrollMagic.Scene({
// triggerElement: ".top-block-item"
// })
// .setTween("#animate-sheet", 0.2, { scale: 2.5}) // trigger a TweenMax.to tween
// .addIndicators({name: "1 (duration: 0)"}) // add indicators (requires plugin)
// .addTo(controller);
$(".new-product-item").click(function (e) {
itemId = $(this)[0].attributes[1].nodeValue;
$(itemId + " .nav-link").removeClass("active");
$(itemId + " #tab1").addClass("active");
$(itemId + " .tab").removeClass("active");
$(itemId + " #tab1").addClass("active");
var clickId = "img-containertab1" + itemId.substr(1);
var imgItem = $("#" + clickId)[0].attributes[1].nodeValue;
if ($("#" + clickId + " img").length == "0") {
new ImageZoom(document.getElementById(clickId), {
width: 600,
img: imgItem,
offset: { vertical: 0, horizontal: 10 },
});
}
});
$(".nav-link").click(function (e) {
var navId = $(this).attr("id");
var clickId = "img-container" + navId + itemId.substr(1);
var imgItem = $("#" + clickId)[0].attributes[1].nodeValue;
if ($("#" + clickId + " img").length == "0") {
new ImageZoom(document.getElementById(clickId), {
width: 600,
img: imgItem,
offset: { vertical: 0, horizontal: 10 },
});
}
});
$(".additional-title").click(function () {
$(".additional ul").slideToggle("slow");
$(".additional ul").toggleClass("active");
return false;
});
$("a[data-popup]").click(function (event) {
event.preventDefault();
var popup = $(this).attr("href");
$("#" + popup).addClass("active");
});
$(".box__hamburger").click(function () {
$(".box").removeClass("active");
$(".box").removeAttr("style");
});
// function up (e){
// e.insertBefore(e.prev());
// e.insertBefore(e.prev());
// e.insertBefore(e.prev());
// e.insertBefore(e.prev());
// }
// up ($('.Geosales > li:nth-child(5)'));
// Костыльная сортировка регионов в разделе "Фирменные магазины"
// Извлекаем список регионов
const geosalesList = document.getElementById("geosalesList");
const regions = Array.from(geosalesList.children);
// Сортируем регионы по алфавиту
regions.sort((a, b) => {
const textA = a.querySelector(".Geosales-region").textContent.trim();
const textB = b.querySelector(".Geosales-region").textContent.trim();
return textA.localeCompare(textB);
});
// Удаляем существующие регионы
geosalesList.innerHTML = "";
// Вставляем отсортированные регионы обратно
regions.forEach((region) => {
geosalesList.appendChild(region);
});
$(".Geosales-region").removeClass("open");
$(".Geosales > li:nth-child(1) > span").addClass("open");
$(document).click(function (e) {
if ($(".header-right__inst").css("display") == "block" && !$(".header-container .header-right a:nth-child(2)").is(e.target) && $(".header-container .header-right a:nth-child(2)").has(e.target).length === 0) {
$(".header-right__inst").css("display", "none");
}
});
});
$(window).on('load', function () {
$('.item-slider').slick("refresh");
});