152 lines
4.4 KiB
JavaScript
152 lines
4.4 KiB
JavaScript
function SetSlideNavigation(e) {
|
|
var anchors = e.parentNode.childNodes;
|
|
if (e.tagName == "SPAN") {
|
|
anchors = e.parentNode.parentNode.childNodes;
|
|
}
|
|
anchors.forEach((t) => {
|
|
if (t.tagName == "A") {
|
|
t.classList.remove("active");
|
|
}
|
|
});
|
|
if (e.tagName == "SPAN") {
|
|
e.parentNode.classList.add("active");
|
|
} else {
|
|
e.classList.add("active");
|
|
}
|
|
}
|
|
$(".swiper-wrapper").slick({
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1,
|
|
arrows: true,
|
|
infinite: true,
|
|
autoplay: true,
|
|
speed: 500,
|
|
prevArrow: $(".p3"),
|
|
nextArrow: $(".n3"),
|
|
});
|
|
$(".newsSlider").slick({
|
|
dots: false,
|
|
infinite: true,
|
|
autoplay: true,
|
|
speed: 300,
|
|
slidesToShow: 3,
|
|
arrows: true,
|
|
prevArrow: $(".p2"),
|
|
nextArrow: $(".n2"),
|
|
slidesToScroll: 1,
|
|
responsive: [
|
|
{
|
|
breakpoint: 1024,
|
|
settings: {
|
|
slidesToShow: 2,
|
|
slidesToScroll: 1,
|
|
},
|
|
},
|
|
],
|
|
});
|
|
// popUp start
|
|
var popUp = document.getElementById("popUp");
|
|
var popUpClose1 = document.getElementById("popUpClose1");
|
|
var popUpClose2 = document.getElementById("popUpClose2");
|
|
popUpClose1.onclick = function () {
|
|
popUp.classList.remove("active");
|
|
};
|
|
popUpClose2.onclick = function () {
|
|
popUp.classList.remove("active");
|
|
};
|
|
// popUp end
|
|
$(".marquee").slick({
|
|
speed: 8000,
|
|
autoplay: true,
|
|
autoplaySpeed: 0,
|
|
centerMode: true,
|
|
cssEase: "linear",
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1,
|
|
variableWidth: true,
|
|
infinite: true,
|
|
initialSlide: 1,
|
|
arrows: false,
|
|
buttons: false,
|
|
});
|
|
// lazyload start
|
|
// =============================================
|
|
if (
|
|
window.addEventListener &&
|
|
window.requestAnimationFrame &&
|
|
document.getElementsByClassName
|
|
)
|
|
window.addEventListener(
|
|
"load",
|
|
function () {
|
|
let pItem = document.getElementsByClassName("progressive replace"),
|
|
timer;
|
|
window.addEventListener("scroll", scroller, false);
|
|
window.addEventListener("resize", scroller, false);
|
|
inView();
|
|
function scroller(e) {
|
|
timer =
|
|
timer ||
|
|
setTimeout(function () {
|
|
timer = null;
|
|
requestAnimationFrame(inView);
|
|
}, 300);
|
|
}
|
|
function inView() {
|
|
let wT = window.pageYOffset,
|
|
wB = wT + window.innerHeight,
|
|
cRect,
|
|
pT,
|
|
pB,
|
|
p = 0;
|
|
while (p < pItem.length) {
|
|
cRect = pItem[p].getBoundingClientRect();
|
|
pT = wT + cRect.top;
|
|
pB = pT + cRect.height;
|
|
|
|
if (wT < pB && wB > pT) {
|
|
loadFullImage(pItem[p]);
|
|
pItem[p].classList.remove("replace");
|
|
} else p++;
|
|
}
|
|
}
|
|
function loadFullImage(item) {
|
|
if (!item || !item.href) return;
|
|
let img = new Image();
|
|
if (item.dataset) {
|
|
img.srcset = item.dataset.srcset || "";
|
|
img.sizes = item.dataset.sizes || "";
|
|
}
|
|
img.src = item.href;
|
|
img.className = "reveal";
|
|
if (img.complete) addImg();
|
|
else img.onload = addImg;
|
|
function addImg() {
|
|
item.addEventListener(
|
|
"click",
|
|
function (e) {
|
|
e.preventDefault();
|
|
},
|
|
false
|
|
);
|
|
item.appendChild(img).addEventListener(
|
|
"animationend",
|
|
function (e) {
|
|
var pImg =
|
|
item.querySelector &&
|
|
item.querySelector("img.preview");
|
|
if (pImg) {
|
|
e.target.alt = pImg.alt || "";
|
|
item.removeChild(pImg);
|
|
e.target.classList.remove("reveal");
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|
|
},
|
|
false
|
|
);
|
|
// lazyload end
|
|
// =============================================
|