PageSourceSearch

https://appwrk.com/wp-content/themes/appwrk_theme/new-2024/js/new-header-menu-ky.js?v=1775047337

js appwrk.com collected 2026-09-24 08:59:29 UTC 4,262 bytes, 130 lines download raw bytes

1(function () {
2
3    const isMobile = window.matchMedia("(max-width: 1022px)").matches;
4
5    /* =========================
6       MOBILE ONLY
7    ========================= */
8    if (isMobile) {
9
10        // Load mobile menu after page load (non-blocking)
11        window.addEventListener("load", () => {
12            setTimeout(() => {
13                const script = document.createElement("script");
14                script.src = "https://appwrk.com/wp-content/themes/appwrk_theme/newtemp-2025/updated-files/mobile-menu.js";
15                script.defer = true;
16                document.body.appendChild(script);
17            }, 100);
18        });
19
20        return; // 🚀 STOP ALL DESKTOP JS
21    }
22
23    /* =========================
24       DOM READY (DESKTOP ONLY)
25    ========================= */
26    document.addEventListener("DOMContentLoaded", () => {
27
28        /* =========================
29           1. Sticky Header
30        ========================= */
31        const header = document.querySelector(".main-header-wraper");
32        const megaMenu = document.querySelector(".mega-menu-container");
33
34        if (header || megaMenu) {
35            let ticking = false;
36
37            const updateHeader = () => {
38                const isSticky = window.scrollY > 100;
39
40                header && header.classList.toggle("sticky-active", isSticky);
41                megaMenu && megaMenu.classList.toggle("sticky-sub-menu", isSticky);
42
43                ticking = false;
44            };
45
46            window.addEventListener("scroll", () => {
47                if (!ticking) {
48                    requestAnimationFrame(updateHeader);
49                    ticking = true;
50                }
51            }, { passive: true }); // ⚡ performance boost
52        }
53
54        /* =========================
55           2. Mega Menu
56        ========================= */
57        const wrapper = document.querySelector(".mega-wrapper");
58        if (!wrapper) return;
59
60        const links = wrapper.querySelectorAll(".menu-link");
61        const containers = document.querySelectorAll(".header-container");
62
63        let activeMenu = null;
64        let timeout = null;
65
66        const isHoverDevice = window.matchMedia("(hover: hover)").matches;
67
68        const clearTimer = () => {
69            if (timeout) {
70                clearTimeout(timeout);
71                timeout = null;
72            }
73        };
74
75        const resetMenu = () => {
76            clearTimer();
77            containers.forEach(el => el.classList.remove("active"));
78            links.forEach(el => el.classList.remove("active"));
79            activeMenu = null;
80        };
81
82        const delayedClose = () => {
83            clearTimer();
84            timeout = setTimeout(resetMenu, 120);
85        };
86
87        const openMenu = (link, target) => {
88            if (activeMenu === target) return;
89            resetMenu();
90            link.classList.add("active");
91            target.classList.add("active");
92            activeMenu = target;
93        };
94
95        links.forEach(link => {
96            const target = document.getElementById(link.dataset.target);
97            if (!target) return;
98
99            if (isHoverDevice) {
100                link.addEventListener("pointerenter", () => {
101                    clearTimer();
102                    openMenu(link, target);
103                });
104
105                link.addEventListener("pointerleave", delayedClose);
106                target.addEventListener("pointerenter", clearTimer);
107                target.addEventListener("pointerleave", delayedClose);
108            } else {
109                link.addEventListener("click", (e) => {
110                    e.preventDefault();
111                    clearTimer();
112                    activeMenu === target ? resetMenu() : openMenu(link, target);
113                });
114            }
115        });
116
117        // Click outside to close (for touch laptops)
118        document.addEventListener("click", (e) => {
119            if (
120                activeMenu &&
121                !wrapper.contains(e.target) &&
122                !activeMenu.contains(e.target)
123            ) {
124                resetMenu();
125            }
126        });
127
128    });
129
130})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.