|
@@ -21,35 +21,95 @@ const searchButton = document.querySelector(".search-btn-mobile")
|
|
|
|
|
|
|
|
|
// header mega menu
|
|
|
-
|
|
|
const megaMenuContainer = document.querySelectorAll(".megamenu-parrent");
|
|
|
-
|
|
|
const menuItemsAll = document.querySelectorAll(".menu-items");
|
|
|
|
|
|
|
|
|
- if(megaMenuContainer) {
|
|
|
- megaMenuContainer.forEach(container => {
|
|
|
+ // megamenu open close for mobile
|
|
|
+ function megamenuClickToggle () {
|
|
|
+
|
|
|
+ if(megaMenuContainer) {
|
|
|
+ megaMenuContainer.forEach(container => {
|
|
|
+
|
|
|
+ const megaButton = container.querySelector(".collapse-buton");
|
|
|
+
|
|
|
+ const menuItems = container.querySelector(".menu-items")
|
|
|
+
|
|
|
+ if(megaButton && menuItems) {
|
|
|
+ megaButton.addEventListener("click", () => {
|
|
|
+ menuItems.classList.toggle("active");
|
|
|
+
|
|
|
+ menuItemsAll.forEach(item => {
|
|
|
+ if (item !== menuItems) {
|
|
|
+ item.classList.remove("active")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- const megaButton = container.querySelector(".collapse-buton");
|
|
|
+ };
|
|
|
|
|
|
- const menuItems = container.querySelector(".menu-items")
|
|
|
+ // for desktop megamenu open
|
|
|
+ function megamenuHoverOpen () {
|
|
|
+ if(megaMenuContainer) {
|
|
|
+ megaMenuContainer.forEach(container => {
|
|
|
+
|
|
|
+ const menuItems = container.querySelector(".menu-items")
|
|
|
|
|
|
- if(megaButton && menuItems) {
|
|
|
- megaButton.addEventListener("click", () => {
|
|
|
- menuItems.classList.toggle("active");
|
|
|
+ container.addEventListener("mouseover", () => {
|
|
|
+ menuItems.classList.add("active");
|
|
|
|
|
|
- menuItemsAll.forEach(item => {
|
|
|
- if (item !== menuItems) {
|
|
|
- item.classList.remove("active")
|
|
|
- }
|
|
|
+ menuItemsAll.forEach(item => {
|
|
|
+ if (item !== menuItems) {
|
|
|
+ item.classList.remove("active")
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- // header sub-menu
|
|
|
+ // for desktop megamenu close
|
|
|
+ function megamenuHoverClose () {
|
|
|
+ if(megaMenuContainer) {
|
|
|
+ megaMenuContainer.forEach(container => {
|
|
|
+
|
|
|
+ const menuItems = container.querySelector(".menu-items")
|
|
|
+
|
|
|
+ container.addEventListener("mouseleave", () => {
|
|
|
+ console.log("first")
|
|
|
+ menuItems.classList.remove("active");
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ const resizeFunction = () => {
|
|
|
+ console.log(window.innerWidth)
|
|
|
+ if(window.innerWidth > 1199) {
|
|
|
+ megamenuHoverOpen();
|
|
|
+ megamenuHoverClose();
|
|
|
+ } else {
|
|
|
+ megamenuClickToggle();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ resizeFunction();
|
|
|
+
|
|
|
+ window.addEventListener("resize", ()=> {
|
|
|
+ resizeFunction()
|
|
|
+ });
|
|
|
+
|
|
|
+ // header mega menu end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // header mega sub-menu
|
|
|
|
|
|
const megaSubMenu = document.querySelectorAll('.megamenu-submenu .items');
|
|
|
|
|
@@ -77,7 +137,7 @@ const searchButton = document.querySelector(".search-btn-mobile")
|
|
|
})
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ // header mega sub-menu end
|
|
|
|
|
|
|
|
|
// burger menu function
|
|
@@ -98,6 +158,7 @@ const searchButton = document.querySelector(".search-btn-mobile")
|
|
|
mainNav.classList.remove("active")
|
|
|
})
|
|
|
}
|
|
|
+ // burger menu function end
|
|
|
|
|
|
|
|
|
|