PageSourceSearch

https://manaaptieka.lv/wp-content/themes/mana-aptieka/js/header-me…c741e336b4c1754fff12ba69631710f2.1790323451

js manaaptieka.lv collected 2026-09-25 08:04:23 UTC 4,978 bytes, 122 lines download raw bytes

1jQuery(function ($) {
2
3    let headerMenuWidth = 0;
4    let headerMenuWidthPrevious = 0;
5    let headerMenuWidthToCompare = 0;
6    let headerMenuPaddings = ($(window).width() > 1024) ? 64 : 0;
7    let headerMenuMoreButton = $(".single-menu-item-more");
8    let headerMenuFirstStaticElement = $(".single-menu-item").first();
9    let headerElementsVisibleWidth = 0;
10    let dropdownMenu = $(".dropdown-dynamic-menu");
11    let dropdownNonHomeButton = $(".non-home-dropdown-button");
12    let dropdownNonHomeMenu = $(".non-home-dropdown-list");
13    let dropdownSidebarMenu = $(".dropdown-dynamic-sidebar-menu");
14    let dropdownSidebarMenuOpener = $(".open-sidebar-menu-dropdown-link");
15    let hiddenElements = [];
16
17    // HIDDEN ELEMENTS
18    let checkElementsVisibility = () => {
19        hiddenElements = [];
20        $(".single-menu-item:not(.single-menu-item-more)").each(function (index, elem) {
21            if ($(elem).hasClass("d-none")) hiddenElements.push(index);
22        });
23        $(".single-dropdown-item").each(function (index, elem) {
24            let iteratedCounter = $(elem).data("counter");
25            (!inArray(iteratedCounter, hiddenElements)) ? $(elem).addClass("d-none") : $(elem).removeClass("d-none");
26        });
27        if (hiddenElements.length === 0) {
28            headerMenuFirstStaticElement.addClass("single-menu-item-no-more-button")
29            headerMenuMoreButton.addClass("d-none")
30        } else {
31            headerMenuFirstStaticElement.removeClass("single-menu-item-no-more-button")
32            headerMenuMoreButton.removeClass("d-none");
33        }
34    }
35    // END HIDDEN ELEMENTS
36
37    // CALCULATING HEADER ELEMENTS
38    let calculateHeaderElements = () => {
39        headerElementsVisibleWidth = 0;
40        $(".single-menu-item:not(.single-menu-item-more):not(.d-none)").each(function (index, elem) {
41            let iteratedItemWidth = $(elem).outerWidth();
42            headerElementsVisibleWidth += iteratedItemWidth;
43        });
44        headerMenuWidthToCompare = headerElementsVisibleWidth + headerMenuPaddings + headerMenuMoreButton.outerWidth();
45    }
46    // END CALCULATING HEADER ELEMENTS
47
48    // MAIN CALCULATING
49    let calculateHeaderMenu = () => {
50        let currentWindowWidth = $(window).width();
51        if (currentWindowWidth > 600) {
52            headerMenuPaddings = (currentWindowWidth > 1024) ? 64 : 0
53            headerMenuWidth = $(".header-menu").outerWidth();
54            calculateHeaderElements();
55            if (headerMenuWidth < headerMenuWidthToCompare) {
56                $(".single-menu-item:not(.single-menu-item-more):not(.d-none)").last().addClass("d-none")
57                headerMenuWidthPrevious = headerMenuWidth;
58                calculateHeaderMenu();
59            }
60            if (headerMenuWidthPrevious !== 0 && headerMenuWidth > headerMenuWidthPrevious) {
61                $(".single-menu-item.d-none:not(.single-menu-item-more)").first().removeClass("d-none");
62                calculateHeaderElements();
63
64                // RECALCULATE TOP BREAKPOINT
65                $(".single-menu-item.d-none:not(.single-menu-item-more)").first().removeClass("d-none");
66                calculateHeaderElements();
67                headerMenuWidthPrevious = parseInt(headerMenuWidthToCompare);
68                if (headerMenuWidthPrevious > headerMenuWidth) {
69                    $(".single-menu-item:not(.single-menu-item-more):not(.d-none)").last().addClass("d-none")
70                    calculateHeaderMenu();
71                }
72                // RECALCULATE TOP BREAKPOINT
73
74            }
75            checkElementsVisibility();
76        }
77    }
78    // END MAIN CALCULATING
79
80    // RUN
81    calculateHeaderMenu();
82    $(window).on("resize", function () {
83        calculateHeaderMenu();
84    });
85    // END RUN
86
87    // SWITCH DROPDOWN VISIBILITY
88    $(".open-header-menu-dropdown").on("click", function (e) {
89        e.preventDefault();
90        dropdownMenu.toggleClass("dropdown-visible");
91    });
92    // END SWITCH DROPDOWN VISIBILITY
93
94    // SWITCH DROPDOWN SIDEBAR VISIBILITY
95    dropdownSidebarMenuOpener.on("click", function (e) {
96        e.preventDefault();
97        dropdownSidebarMenu.toggleClass("dropdown-sidebar-visible");
98    });
99    // END SWITCH DROPDOWN SIDEBAR VISIBILITY
100
101    // SWITCH NON-HOME DROPDOWN SIDEBAR VISIBILITY
102    dropdownNonHomeButton.on("click", function (e) {
103        e.preventDefault();
104        dropdownNonHomeButton.toggleClass("non-home-dropdown-button-active");
105        dropdownNonHomeMenu.toggleClass("non-home-dropdown-list-visible");
106    });
107    // END SWITCH NON-HOME DROPDOWN SIDEBAR VISIBILITY
108
109    // ------------------------------------------------------------------------------------------------
110
111    // ADDITIONAL FUNCTIONS
112    function inArray(needle, haystack) {
113        let length = haystack.length;
114        for (let i = 0; i < length; i++) {
115            if (haystack[i] === needle) return true;
116        }
117        return false;
118    }
119
120    // END ADDITIONAL FUNCTIONS
121
122});

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.