. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 54.36.91.62 / Your IP :
216.73.216.168 [
Web Server : Apache System : Linux webm002.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : eticmes ( 123698) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/eticmes/www/wp-content/themes/oceanwp/assets/src/js/wp-plugins/woocommerce/ |
Upload File : |
import { slideDown, slideUp } from "../../lib/utils";
class WooCatWidget {
#elements;
constructor() {
this.#setElements();
this.#start();
}
#setElements = () => {
this.#elements = {
categories: document.querySelectorAll(
".woo-dropdown-cat .product-categories"
),
};
};
#start = () => {
this.#elements.categories.forEach((category) => {
const angleDownIcon = '<i class="fa fa-angle-down"></i>';
const angleUpIcon = '<i class="fa fa-angle-up"></i>';
category.querySelectorAll("li").forEach((li) => {
const hasChildrenElem =
Array.from(li.querySelectorAll(".children")).length !== 0;
const hasListElem = Array.from(li.querySelectorAll("li")).length !== 0;
if (hasChildrenElem && hasListElem) {
li.insertAdjacentHTML(
"afterbegin",
`<div class="open-this">${angleDownIcon}</div>`
);
}
});
category.querySelectorAll(".open-this")?.forEach((item) => {
item.addEventListener("click", (event) => {
const parentItem = item.parentNode;
const parentItemChildren = parentItem.children;
if (parentItem.classList.contains("opened")) {
item.innerHTML = angleDownIcon;
parentItem.classList.remove("opened");
for (let i = 0; i < parentItemChildren.length; i++) {
const element = parentItemChildren[i];
if (element.nodeName.toLowerCase() === "ul") {
slideUp(element, 250);
}
}
} else {
item.innerHTML = angleUpIcon;
parentItem.classList.add("opened");
for (let i = 0; i < parentItemChildren.length; i++) {
const element = parentItemChildren[i];
if (element.nodeName.toLowerCase() === "ul") {
slideDown(element, 250);
}
}
}
});
});
});
};
}
new WooCatWidget();