| Server IP : 14.225.216.240 / Your IP : 216.73.216.26 Web Server : nginx/1.20.1 System : Linux localhost.localdomain 5.14.0-596.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jun 27 16:02:33 UTC 2025 x86_64 User : taidh ( 1001) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/taidh/papacafe.vn/wp-content/themes/papacafe/assets/js/ |
Upload File : |
(() => {
typeof WOW != "undefined" && (new WOW).init();
document.addEventListener("DOMContentLoaded", () => {
navigator.userAgent.toLowerCase().includes("firefox") && document.body.classList.add("firefox");
const headers = document.querySelectorAll(".header"),
primaryHeader = document.querySelector(".primary-header");
const handleStickyHeader = (mediaQuery) => {
if (mediaQuery.matches) {
window.addEventListener("scroll", () => {
const scrollY = window.scrollY;
scrollY >= 110 ? primaryHeader.classList.add("fixed") : primaryHeader.classList.remove("fixed");
});
if (headers.length > 0) {
const headerHeight = document.querySelector(".header").offsetHeight;
headers.forEach(header => { header.style.height = `${headerHeight}px`; });
}
}
};
const mediaQuery = window.matchMedia("(min-width: 992px)");
headers[0]?.classList.contains("sticky-active") && handleStickyHeader(mediaQuery);
$(".mobile-menu-items").meanmenu({
meanMenuContainer: ".side-menu-wrap",
meanScreenWidth: "992",
meanMenuCloseSize: "30px",
meanRemoveAttrs: true,
meanExpand: ['<i class="fa-solid fa-caret-down"><\/i>']
});
const mobileMenuToggle = document.querySelector(".mobile-side-menu-toggle"),
mobileMenu = document.querySelector(".mobile-side-menu"),
mobileMenuOverlay = document.querySelector(".mobile-side-menu-overlay"),
mobileMenuClose = document.querySelector(".mobile-side-menu-close");
const toggleMobileMenu = () => {
mobileMenu?.classList.toggle("is-open");
mobileMenuOverlay?.classList.toggle("is-open");
};
const closeMobileMenu = () => {
mobileMenu?.classList.remove("is-open");
mobileMenuOverlay?.classList.remove("is-open");
};
mobileMenuToggle?.addEventListener("click", toggleMobileMenu);
mobileMenuClose?.addEventListener("click", closeMobileMenu);
mobileMenuOverlay?.addEventListener("click", closeMobileMenu);
const searchBox = document.getElementById("popup-search-box"),
searchIcon = document.querySelector(".dl-search-icon"),
searchInput = document.getElementById("popup-search");
if (searchBox) {
searchBox.classList.remove("toggled");
const toggleSearchBox = (e) => {
e.stopPropagation();
searchBox.classList.toggle("toggled");
searchInput?.focus();
};
searchIcon?.addEventListener("click", toggleSearchBox);
searchBox.querySelector("input")?.addEventListener("click", (e) => e.stopPropagation());
document.addEventListener("click", () => searchBox.classList.remove("toggled"));
}
const initializeSidebar = () => {
document.body.classList.remove("open-sidebar");
document.addEventListener("click", (e) => {
if (e.target.matches(".sidebar-trigger")) {
e.preventDefault();
document.body.classList.toggle("open-sidebar");
} else if (e.target.matches(".sidebar-trigger.close, #sidebar-overlay")) {
e.preventDefault();
document.body.classList.remove("open-sidebar");
}
});
};
initializeSidebar();
new VenoBox({
selector: ".video-popup, .img-popup",
numeration: true,
infinigall: true,
share: true,
fitView: true,
spinner: "plane"
});
document.querySelectorAll("[data-background]").forEach((elem) => {
elem.style.backgroundImage = `url(${elem.getAttribute("data-background")})`;
});
$("select").niceSelect();
const filterItems = document.querySelector(".filter-items");
if (filterItems) {
imagesLoaded(filterItems, () => {
const isotopeInstance = new Isotope(filterItems, {
itemSelector: ".single-item",
layoutMode: "fitRows",
fitRows: { gutter: 0 }
});
document.querySelector(".project-filter").addEventListener("click", (e) => {
if (e.target.matches("li")) {
document.querySelectorAll(".project-filter li").forEach(li => li.classList.remove("active"));
e.target.classList.add("active");
const filter = e.target.getAttribute("data-filter");
isotopeInstance.arrange({ filter, animationOptions: { duration: 750, easing: "linear", queue: false } });
}
});
const initialFilter = document.querySelector(".project-filter li.active")?.getAttribute("data-filter") || "*";
isotopeInstance.arrange({ filter: initialFilter });
isotopeInstance.once("arrangeComplete", () => {
filterItems.classList.contains("opacity-0") && filterItems.classList.remove("opacity-0");
});
});
}
const setupCarousels = () => {
new Swiper(".shop-carousel", {
slidesPerView: 5,
spaceBetween: 10,
slidesPerGroup: 1,
loop: true,
speed: 700,
autoplay: true,
grabCursor: true,
pagination: { el: ".swiper-pagination", clickable: true },
navigation: { nextEl: ".fashion-section .swiper-prev", prevEl: ".fashion-section .swiper-next" },
breakpoints: {
320: { slidesPerView: 1, slidesPerGroup: 1, spaceBetween: 20 },
767: { slidesPerView: 2, slidesPerGroup: 1, spaceBetween: 30 },
992: { slidesPerView: 4, slidesPerGroup: 1, spaceBetween: 30 },
1170: { slidesPerView: 5, slidesPerGroup: 1, spaceBetween: 30 }
}
});
new Swiper(".testimonial-carousel", {
slidesPerView: 3,
spaceBetween: 10,
slidesPerGroup: 1,
loop: true,
speed: 700,
autoplay: false,
grabCursor: true,
pagination: { el: ".swiper-pagination", clickable: true },
navigation: { nextEl: ".testimonial-section .swiper-prev", prevEl: ".testimonial-section .swiper-next" },
breakpoints: {
320: { slidesPerView: 1, slidesPerGroup: 1, spaceBetween: 20 },
767: { slidesPerView: 2, slidesPerGroup: 1, spaceBetween: 30 },
992: { slidesPerView: 3, slidesPerGroup: 1, spaceBetween: 30 }
}
});
const productGalleryThumb = new Swiper(".product-gallary-thumb", {
spaceBetween: 10,
slidesPerView: 3,
freeMode: true,
watchSlidesProgress: true
});
new Swiper(".product-gallary", {
spaceBetween: 10,
navigation: { nextEl: ".swiper-nav-next", prevEl: ".swiper-nav-prev" },
thumbs: { swiper: productGalleryThumb }
});
};
setupCarousels();
const handleScrollEffects = () => {
const zaloContainer = document.querySelector(".zalo-container"),
scrollPercentage = document.getElementById("scroll-percentage"),
scrollPercentageValue = document.getElementById("scroll-percentage-value");
const updateScrollProgress = () => {
const scrollTop = document.documentElement.scrollTop,
scrollHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight,
scrollPercent = Math.round((scrollTop / scrollHeight) * 100);
scrollPercentage.style.background = `conic-gradient(var(--rr-color-theme-primary) ${scrollPercent}%, var(--rr-color-common-white) ${scrollPercent}%)`;
if (scrollTop > 100) {
scrollPercentage.classList.add("active");
zaloContainer.style.bottom = window.matchMedia("(max-width: 767px)").matches ? "100px" : "120px";
//chen
const isMobile = window.matchMedia("(max-width: 767px)").matches;
cartIcon.style.bottom = isMobile ? "200px" : "220px";
} else {
scrollPercentage.classList.remove("active");
zaloContainer.style.bottom = "40px";
//chen
cartIcon.style.bottom = "140px";
}
scrollPercentageValue.innerHTML = scrollPercent < 96 ? `${scrollPercent}%` : `
<svg aria-hidden="true" class="e-font-icon-svg e-fas-arrow-up" viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg" style="width: 16px; height: 16px;">
<path d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path>
</svg>`;
};
window.addEventListener("scroll", updateScrollProgress);
window.addEventListener("load", updateScrollProgress);
scrollPercentage.addEventListener("click", () => {
window.scrollTo({ top: 0, behavior: "smooth" });
});
};
handleScrollEffects();
//co the delete
// Tạo phần tử div cho icon giỏ hàng
const cartIcon = document.createElement("div");
cartIcon.className = "cart-icon";
cartIcon.innerHTML = `
<svg aria-hidden="true" class="e-font-icon-svg e-fas-shopping-cart" viewBox="0 0 576 512" xmlns="http://www.w3.org/2000/svg"><path d="M528.12 301.319l47.273-208C578.806 78.301 567.391 64 551.99 64H159.208l-9.166-44.81C147.758 8.021 137.93 0 126.529 0H24C10.745 0 0 10.745 0 24v16c0 13.255 10.745 24 24 24h69.883l70.248 343.435C147.325 417.1 136 435.222 136 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-15.674-6.447-29.835-16.824-40h209.647C430.447 426.165 424 440.326 424 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-22.172-12.888-41.332-31.579-50.405l5.517-24.276c3.413-15.018-8.002-29.319-23.403-29.319H218.117l-6.545-32h293.145c11.206 0 20.92-7.754 23.403-18.681z"></path></svg>
`;
cartIcon.addEventListener("click", function () {
window.location.href = "http://papacafe.vn/cart/";
});
document.body.appendChild(cartIcon);
});
})();