PageSourceSearch

https://globis.co.jp/wp-content/themes/salient-child/js/main-menu.js?ver=1.1.15.7

js globis.co.jp collected 2026-09-24 15:21:39 UTC 4,438 bytes, 104 lines download raw bytes

1const MAX_DESKTOP_MENU_WIDTH = 1180;
2const MIN_DESKTOP_MENU_WIDTH = 1000;
3const NO_SCROLL = 'no-scroll';
4
5(function ($) {
6    const CONTENT_WRAPPER = $("html");
7    const MOBILE_LANGUAGE_ITEM_SELECTOR = '#header-outer #top #mobile-menu li.menu-item.wpml-ls-item > a:not(:only-child)';
8    const LANGUAGE_ITEM_SELECTOR = '#top div:not(#mobile-menu) nav ul li.wpml-ls-menu-item';
9    const applyLanguageItemState = () => {
10        if ($.isDesktopScreen()) return;
11        const desktopLanguageMenuItems = $(LANGUAGE_ITEM_SELECTOR);
12        const currentActiveDesktopLanguageItem = $(LANGUAGE_ITEM_SELECTOR + '.wpml-ls-current-language');
13        if (!desktopLanguageMenuItems.length || !currentActiveDesktopLanguageItem.length) return;
14        const currentLanguageIndex = desktopLanguageMenuItems.index(currentActiveDesktopLanguageItem) + 1;
15        $(`${MOBILE_LANGUAGE_ITEM_SELECTOR}:nth-child(${currentLanguageIndex}) span`).addClass('current-language-item');
16        $(`${MOBILE_LANGUAGE_ITEM_SELECTOR}:not(:nth-child(${currentLanguageIndex})) span`).addClass('other-language-item');
17    }
18
19    const addLanguageItemsToMobile = () => {
20        const desktopLanguageMenuItems = $(LANGUAGE_ITEM_SELECTOR);
21        if (!desktopLanguageMenuItems.length) return;
22        const firstLanguageItem = $(desktopLanguageMenuItems[0]).clone().prependTo('#mobile-menu .menu-items-wrap>ul');
23        for (let i = 1; i < desktopLanguageMenuItems.length; i++) {
24            const currentLanguageItem = $(desktopLanguageMenuItems[i]);
25            firstLanguageItem.append(currentLanguageItem.html());
26        }
27    }
28
29    const closeSubMenus = (exception = '') => {
30        $("#mobile-menu li.menu-item").not(exception).removeClass("current-open-item visible")
31        $("#mobile-menu ul.sub-menu").not(exception ? exception.children() : '').css("display", "none")
32    }
33
34    const closeSubMenusWhenCloseMenu = () => $(".slide-out-widget-area-toggle.mobile-icon").click(() => closeSubMenus());
35
36    const closeOthersWhenOpenSubMenu = () => $(".menu-item a span.sf-sub-indicator").click(function () {
37        const isChildSubMenu = $(this).closest("li").parent("#mobile-menu ul.sub-menu").length > 0;
38        if (isChildSubMenu) return;
39        $openingLi = $(this).closest("li");
40        closeSubMenus($openingLi);
41    });
42
43    const closeMobileMenu = () => {
44        const menuIcon = $('.slide-out-widget-area-toggle.mobile-icon.simple a[class~="open"]');
45        if (!menuIcon.length) return;
46        menuIcon[0].click();
47    }
48
49    const closeMobileMenuOnClickSearch = () => {
50        $('a.mobile-search').click(closeMobileMenu);
51    }
52
53    const addScroll = () => {
54        CONTENT_WRAPPER.removeClass(NO_SCROLL);
55    }
56
57    const handleMenuOpen = () => {
58        $(window).on('resize', () => {
59            if ($(this).innerWidth() > MAX_DESKTOP_MENU_WIDTH) {
60                addScroll();
61            }
62        });
63        $("body").on('click', '.slide-out-widget-area-toggle:not(.std-menu) a', function () {
64            if (CONTENT_WRAPPER.hasClass(NO_SCROLL)) {
65                return addScroll();
66            }
67            return CONTENT_WRAPPER.addClass(NO_SCROLL);
68        });
69    }
70
71    const handleResizeMenu = () => {
72        if ($('body.home').length === 0) {
73            return;
74        }
75        let listenerIndex = '';
76        const emptyFunc = () => {
77        };
78        const {handler: smartResizeHandler} = jQuery._data(window, "events").resize.find((eventListener, index) => {
79            listenerIndex = index;
80            return eventListener.handler.toString().includes('.trigger("smartresize")');
81        }) || {handler: emptyFunc};
82        $(window).on('resize', () => {
83            if ($(this).innerWidth() <= MAX_DESKTOP_MENU_WIDTH && $(this).innerWidth() > MIN_DESKTOP_MENU_WIDTH && listenerIndex) {
84                jQuery._data(window, "events").resize[listenerIndex].handler = emptyFunc;
85            } else {
86                jQuery._data(window, "events").resize[listenerIndex].handler = smartResizeHandler;
87                $(window).trigger('smartresize');
88            }
89        })
90    }
91
92    $(document).ready(() => {
93        handleResizeMenu();
94        addLanguageItemsToMobile();
95        applyLanguageItemState();
96        closeSubMenusWhenCloseMenu();
97        closeMobileMenuOnClickSearch();
98        handleMenuOpen();
99        setTimeout(() => {
100            closeOthersWhenOpenSubMenu();
101        })
102    });
103
104})(jQuery);

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.