PageSourceSearch

https://jamesbazen.net/wp-content/themes/customify/assets/js/theme.js?ver=0.4.13

js jamesbazen.net collected 2026-10-08 01:27:42 UTC 33,779 bytes, 1,014 lines download raw bytes

1/**
2 * Customify theme javaScript.
3 *
4 * @since 0.2.6
5 *
6 * Copyright 2017, PressMaximum
7 */
8
9'use strict'; // prevent global namespace pollution
10(function (elmPrototype, docPrototype) {
11    var scopeRegex = /:scope\b/gi;
12
13    function patchElement(method) {
14        var native = elmPrototype[method];
15
16        elmPrototype[method] = function (selector) {
17            var element = this;
18            var id = element.id || 'qsid' + new Date().getTime();
19            var needsId = !element.id;
20            var hasScope = scopeRegex.test(selector);
21
22            try {
23                if (hasScope) {
24                    if (needsId) {
25                        element.id = id;
26                    }
27
28                    selector = selector.replace(scopeRegex, '#' + id);
29                }
30
31                return native.call(this, selector);
32            } finally {
33                if (needsId) {
34                    element.id = null;
35                }
36            }
37        };
38    }
39
40    function patchDocument(method) {
41        var native = docPrototype[method];
42        docPrototype[method] = function (selector) {
43            // In context of document, :scope is the same
44            // as :root so can just be stripped
45            // https://www.w3.org/TR/selectors4/#scope-pseudo
46            return native.call(this, selector.replace(scopeRegex, ''));
47        };
48    }
49
50    try {
51        document.querySelector(':scope');
52    } catch (err) {
53        patchElement('querySelector');
54        patchElement('querySelectorAll');
55        patchDocument('querySelector');
56        patchDocument('querySelectorAll');
57    }
58})(Element.prototype, Document.prototype);
59
60(function (arr) {
61    arr.forEach(function (item) {
62        if (item.hasOwnProperty('append')) {
63            return;
64        }
65        Object.defineProperty(item, 'append', {
66            configurable: true,
67            enumerable: true,
68            writable: true,
69            value: function append() {
70                var argArr = Array.prototype.slice.call(arguments),
71                    docFrag = document.createDocumentFragment();
72
73                argArr.forEach(function (argItem) {
74                    var isNode = argItem instanceof Node;
75                    docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
76                });
77
78                this.appendChild(docFrag);
79            }
80        });
81    });
82})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
83(function () {
84    if (typeof NodeList.prototype.forEach === 'function') return false;
85    NodeList.prototype.forEach = Array.prototype.forEach;
86})();
87
88/**
89 * matches() pollyfil
90 * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
91 */
92if (!Element.prototype.matches) {
93    Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
94}
95
96/**
97 * closest() pollyfil
98 * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
99 */
100if (!Element.prototype.closest) {
101    Element.prototype.closest = function (s) {
102        var el = this;
103        if (!document.documentElement.contains(el)) {
104            return null;
105        }
106        do {
107            if (el.matches(s)) {
108                return el;
109            }
110            el = el.parentElement || el.parentNode;
111        } while (el !== null && el.nodeType === 1);
112        return null;
113    };
114}
115
116/**
117 * Main Customify Scripts
118 */
119(function () {
120    var Customify = function () {
121        this.options = {
122            menuToggleDuration: 300
123        };
124
125        this.menuSidebarState = 'closed';
126        this.isPreviewing = document.body.classList.contains('customize-previewing');
127
128        this.init();
129    };
130
131    /**
132     * Add body class to check touch screen.
133     */
134    Customify.prototype.checkTouchScreen = function () {
135        if ('ontouchstart' in document.documentElement) {
136            document.body.classList.add('ontouch-screen');
137        } else {
138            document.body.classList.add('not-touch-screen');
139        }
140    };
141
142    /**
143     * Check if current mobile viewing.
144     *
145     * @return bool
146     */
147    Customify.prototype.isMobile = function () {
148        if (
149            navigator.userAgent.match(/Android/i) ||
150            navigator.userAgent.match(/webOS/i) ||
151            navigator.userAgent.match(/iPhone/i) ||
152            navigator.userAgent.match(/iPad/i) ||
153            navigator.userAgent.match(/iPod/i) ||
154            navigator.userAgent.match(/BlackBerry/i) ||
155            navigator.userAgent.match(/Windows Phone/i)
156        ) {
157            return true;
158        } else {
159            return false;
160        }
161    };
162
163    /**
164     * Init mobile sidebar.
165     *
166     * @todo Move menu sidebar to body.
167     * @todo Add events to menu buttons.
168     */
169    Customify.prototype.initMenuSidebar = function () {
170        var themeMenuSidebar;
171        const that = this;
172        if (document.body.classList.contains('menu_sidebar_dropdown')) {
173            // $( '#header-menu-sidebar' ).insertAfter( "#masthead" );
174        } else {
175            themeMenuSidebar = document.getElementById('header-menu-sidebar');
176            if (themeMenuSidebar) {
177                document.body.append(themeMenuSidebar);
178            }
179        }
180
181        document.addEventListener(
182            'customize_section_opened',
183            function (e) {
184                if (e.detail === 'header_sidebar') {
185                    this.toggleMenuSidebar(false);
186                }
187            }.bind(this)
188        );
189
190        var menuMobileToggleButtons = document.querySelectorAll('.menu-mobile-toggle');
191        /**
192         * When click to toggle buttons.
193         */
194        this.addEvent(
195            menuMobileToggleButtons,
196            'click',
197            function (e) {
198                e.preventDefault();
199                this.toggleMenuSidebar();
200            }.bind(this)
201        );
202
203
204
205        var closeButtons = document.querySelectorAll('#header-menu-sidebar .close-panel, .close-sidebar-panel');
206
207        /**
208         * When click close buttons.
209         */
210        this.addEvent(
211            closeButtons,
212            'click',
213            function (e) {
214                e.preventDefault();
215                this.closeMenuSidebar();
216            }.bind(this)
217        );
218
219        /**
220         * When click to ouside of menu sidebar.
221         */
222        this.addEvent(
223            document,
224            'click',
225            function (e) {
226                if (document.body.classList.contains('is-menu-sidebar')) {
227                    var menuSidebar = document.getElementById('header-menu-sidebar');
228                    var buttons = document.querySelectorAll('.menu-mobile-toggle');
229                    var outside = false;
230
231                    var isClickInside = menuSidebar.contains(e.target);
232                    if (!isClickInside) {
233                        outside = true;
234                    }
235
236                    // If the click happened inside the the container, bail
237                    if (!e.target.closest('#header-menu-sidebar') && e.target !== menuSidebar) {
238                        // Outside menu sidebar.
239                        outside = true;
240                    }
241
242                    // Check if not click to menu toggle buttons.
243                    var onButton = false;
244                    if (buttons.length) {
245                        for (var i = 0; i < buttons.length; i++) {
246                            // If click on toggle button.
247                            if (e.target.closest('.menu-mobile-toggle') || e.target === buttons[i]) {
248                                onButton = true;
249                            }
250                        }
251                    }
252
253                    if (outside && !onButton) {
254                        this.closeMenuSidebar();
255                    }
256                }
257            }.bind(this)
258        );
259
260        this.addEvent(
261            document,
262            'keyup',
263            function (e) {
264                if (e.keyCode === 27) {
265                    this.closeMenuSidebar();
266                }
267            }.bind(this)
268        );
269
270
271        /**
272         * When click to anchor links.
273         * @since 0.3.9
274         */
275        this.addEvent(
276            document.querySelectorAll('.menu a[href*="#"]'),
277            'click',
278            function (e) {
279                let el = e.target.tagName === 'A' ? e.target : e.target.closest('a');
280                let url = new URL(el.href);
281                if (url.origin + url.pathname === window.location.origin + window.location.pathname) {
282                    let elTo = document.querySelector(url.hash);
283                    if (elTo) {
284                        e.preventDefault();
285                        that.closeMenuSidebar();
286                        window.scrollTo({
287                            top: elTo.getBoundingClientRect().y,
288                            left: 0,
289                            behavior: 'smooth'
290                        })
291                        window.history.pushState({}, null, url.href);
292                    }
293                }
294            }
295        );
296    };
297
298    /**
299     * Init mobile search form
300     *
301     * @todo Need check
302     */
303    Customify.prototype.initMobieSearchForm = function () {
304        var mobileSearchForm = document.querySelector('.search-form--mobile');
305        if (mobileSearchForm) {
306            mobileSearchForm.classList.add('mobile-search-form-sidebar menu-sidebar-panel');
307            mobileSearchForm.classList.remove('hide-on-mobile hide-on-tablet');
308            document.body.prepend(mobileSearchForm);
309        }
310    };
311
312    Customify.prototype.toggleMobileSubmenu = function (e) {
313        e.preventDefault();
314        var that = this;
315        var li = e.target.closest('li');
316        var firstSubmenu = li.querySelectorAll(':scope  > .sub-menu, .sub-lv-0');
317
318        if (!li.classList.contains('open-sub')) {
319            // Show the sub menu.
320            li.classList.add('open-sub');
321            if (firstSubmenu.length) {
322                for (var i = 0; i < firstSubmenu.length; i++) {
323                    that.slideDown(firstSubmenu[i], this.options.menuToggleDuration, function () {
324                        li.classList.add('open-sub');
325                    });
326                }
327            }
328        } else {
329            // Hide the sub menu.
330            if (firstSubmenu.length) {
331                for (var i = 0; i < firstSubmenu.length; i++) {
332                    that.slideUp(firstSubmenu[i], this.options.menuToggleDuration, function () {
333                        li.classList.remove('open-sub');
334                    });
335                }
336            }
337        }
338    };
339
340    /**
341     * Add events listener for mobile toggle button.
342     *
343     * @param Element toggleIcon
344     */
345    Customify.prototype.toggleMobileSubmenuEvents = function (toggleIcon) {
346        toggleIcon.addEventListener('click', this.toggleMobileSubmenu.bind(this));
347    };
348
349    /**
350     * Inital mobile submenu.
351     */
352    Customify.prototype.initMobileSubMenu = function () {
353        var menuChildren = document.querySelectorAll('#header-menu-sidebar .nav-menu-mobile .menu-item-has-children');
354
355        if (menuChildren.length) {
356            for (var i = 0; i < menuChildren.length; i++) {
357                var child = menuChildren[i];
358
359                if (!child.classList.contains('toggle--added')) {
360                    child.classList.add('toggle--added');
361
362                    var fistLink = child.querySelector(':scope > a');
363                    var d = fistLink.cloneNode(true);
364
365                    if (this.isPreviewing) {
366                    }
367
368                    var toggleButton = document.createElement('span');
369                    toggleButton.classList.add('nav-toggle-icon');
370                    toggleButton.innerHTML = '<i class="nav-icon-angle"></i>';
371
372                    fistLink.parentNode.insertBefore(toggleButton, fistLink);
373                    var submenu = child.querySelector(':scope > .sub-menu');
374                    if ('1' !== Customify_JS.sidebar_menu_no_duplicator) {
375                        submenu.prepend(d);
376                    }
377                    var firstSubmenu = child.querySelectorAll(':scope  > .sub-menu, .sub-lv-0');
378                    if (firstSubmenu.length) {
379                        for (var j = 0; j < firstSubmenu.length; j++) {
380                            this.slideUp(firstSubmenu[j], 0);
381                        }
382                    }
383                    if ('1' !== Customify_JS.sidebar_menu_no_duplicator) {
384                        var dWrapper = document.createElement('li');
385                        d.parentNode.prepend(dWrapper);
386                        dWrapper.appendChild(d);
387                    }
388                    this.toggleMobileSubmenuEvents(toggleButton);
389                }
390            }
391        }
392    };
393
394    /**
395     * SideUp
396     *
397     * @param Element element
398     * @param number duration
399     * @param function callBack
400     */
401    Customify.prototype.slideUp = function (element, duration, callBack) {
402        if (typeof duration !== 'number') {
403            duration = 0;
404        }
405
406        // if ( element._sideUpTimeOut ) {
407        // 	clearTimeout( element._sideUpTimeOut );
408        // 	element._sideUpTimeOut = false;
409        // }
410
411        if (element._slideDownTimeOut) {
412            clearTimeout(element._slideDownTimeOut);
413            element._slideDownTimeOut = false;
414        }
415
416        // Get orignal height.
417        var offset = element.getBoundingClientRect();
418        // Back to default.
419        element.style.overflow = 'hidden';
420        element.style.height = offset.height + 'px';
421        element.style.transition = 'height ' + duration + 'ms linear';
422        setTimeout(function () {
423            element.style.height = '0px';
424        }, 20);
425
426        element._sideUpTimeOut = setTimeout(function () {
427            element.style.transition = '';
428            if (typeof callBack === 'function') {
429                callBack.call(this);
430            }
431        }, duration + 20);
432    };
433
434    /**
435     *
436     * @param Element element
437     * @param number duration
438     * @param function callBack
439     */
440    Customify.prototype.slideDown = function (element, duration, callBack) {
441        if (typeof duration !== 'number') {
442            duration = 0;
443        }
444
445        if (element._sideUpTimeOut) {
446            clearTimeout(element._sideUpTimeOut);
447            element._sideUpTimeOut = false;
448        }
449
450        // if ( element._slideDownTimeOut ) {
451        // 	clearTimeout( element._slideDownTimeOut );
452        // 	element._slideDownTimeOut = false;
453        // }
454
455        // Reset element styling to get orignal height.
456        element.style.height = 'initial';
457        element.style.overflow = 'initial';
458        element.style.transition = '';
459        // Get orignal height.
460        var offset = element.getBoundingClientRect();
461        // Back to default.
462        element.style.height = '0px';
463        element.style.overflow = 'hidden';
464        element.style.transition = 'height ' + duration + 'ms linear';
465        setTimeout(function () {
466            element.style.height = offset.height + 'px';
467        }, 50);
468
469        element._sideUpTimeOut = setTimeout(function () {
470            element.style.height = '';
471            element.style.overflow = '';
472            element.style.transition = '';
473            if (typeof callBack === 'function') {
474                callBack.call(this);
475            }
476        }, duration);
477    };
478
479    Customify.prototype.insertMenuOverlayClass = function () {
480        var navMobile = document.querySelector('.nav-menu-mobile');
481        if (navMobile) {
482            if (document.body.classList.contains('menu_sidebar_slide_overlay')) {
483                navMobile.classList.add('nav-menu-overlay');
484            } else {
485                navMobile.classList.remove('nav-menu-overlay');
486            }
487        }
488    };
489
490    Customify.prototype.setupMobileItemAnimations = function (element) {
491        var h = window.height;
492        if (typeof element === 'undefined') {
493            element = document.getElementById('header-menu-sidebar');
494        }
495
496        var t = 0.2;
497        var index = 0;
498        var itemsInner = element.querySelectorAll('.item--inner');
499        if (itemsInner.length) {
500            for (var i = 0; i < itemsInner.length; i++) {
501                index++;
502                itemsInner[i].style.transitionDelay = index * t + 's';
503            }
504        }
505    };
506
507    /**
508     * Toogle Element class name.
509     *
510     * @param Element element
511     * @param string className
512     */
513    Customify.prototype.toggleClass = function (element, className) {
514        if (element instanceof NodeList) {
515            for (var i = 0; i < element.length; i++) {
516                if (element[i].classList.contains(className)) {
517                    element[i].classList.remove(className);
518                } else {
519                    element[i].classList.add(className);
520                }
521            }
522        } else if (element instanceof Node || element instanceof Element) {
523            if (element.classList.contains(className)) {
524                element.classList.remove(className);
525            } else {
526                element.classList.add(className);
527            }
528        }
529    };
530
531    /**
532     * Add class to element.
533     *
534     * @param Element element
535     * @param string className
536     */
537    Customify.prototype.addClass = function (element, className) {
538        if (element instanceof NodeList) {
539            for (var i = 0; i < element.length; i++) {
540                element[i].classList.add(className);
541            }
542        } else if (element instanceof Node || element instanceof Element) {
543            element.classList.add(className);
544        }
545    };
546
547    /**
548     * Remove class name from element.
549     *
550     * @param Element element
551     * @param string className
552     */
553    Customify.prototype.removeClass = function (element, className) {
554        // Split each class by space.
555        var classes = className.split(' ');
556        if (element instanceof NodeList) {
557            for (var i = 0; i < element.length; i++) {
558                for (var j = 0; j < classes.length; j++) {
559                    element[i].classList.remove(classes[j]);
560                }
561            }
562        } else if (element instanceof Node || element instanceof Element) {
563            for (var j = 0; j < classes.length; j++) {
564                element.classList.remove(classes[j]);
565            }
566        }
567    };
568
569    /**
570     * Add event handle to elements.
571     *
572     * @param Element element
573     * @param string event
574     * @param function callBack
575     */
576    Customify.prototype.addEvent = function (element, event, callBack) {
577        if (element instanceof NodeList) {
578            for (var i = 0; i < element.length; i++) {
579                element[i].addEventListener(event, callBack);
580            }
581        } else if (element instanceof Node || element instanceof Element) {
582            element.addEventListener(event, callBack);
583        }
584    };
585
586    /**
587     * Close menu sidebar.
588     */
589    Customify.prototype.closeMenuSidebar = function () {
590        document.body.classList.add('hiding-header-menu-sidebar');
591        document.body.classList.remove('is-menu-sidebar');
592        var toggleButtons = document.querySelectorAll('.menu-mobile-toggle, .menu-mobile-toggle .hamburger');
593        this.removeClass(toggleButtons, 'is-active');
594
595        /**
596         * For dropdown sidebar.
597         */
598        if (document.body.classList.contains('menu_sidebar_dropdown')) {
599            this.removeClass(document.body, 'hiding-header-menu-sidebar');
600            var menuSidebar = document.getElementById('header-menu-sidebar');
601            var menuSidebarInner = document.getElementById('header-menu-sidebar-inner');
602            var offset = menuSidebarInner.getBoundingClientRect();
603            var h = offset.height;
604
605            this.slideUp(
606                menuSidebar,
607                300,
608                function () {
609                    menuSidebar.style.height = 0;
610                    menuSidebar.style.display = 'block';
611                }.bind(this)
612            );
613        } else {
614            // Else slide sidebar.
615            setTimeout(
616                function () {
617                    this.removeClass(document.body, 'hiding-header-menu-sidebar');
618                }.bind(this),
619                1000
620            );
621        }
622    };
623
624    /**
625     * Toggle menu sidebar.
626     *
627     * @param bool open use animation or not.
628     */
629    Customify.prototype.toggleMenuSidebar = function (toggle) {
630        if (typeof toggle === 'undefined') {
631            toggle = true;
632        }
633
634        document.body.classList.remove('hiding-header-menu-sidebar');
635
636        if (!toggle) {
637            document.body.classList.add('is-menu-sidebar');
638        } else {
639            this.toggleClass(document.body, 'is-menu-sidebar');
640        }
641
642        if (document.body.classList.contains('menu_sidebar_dropdown')) {
643            var buttons = document.querySelectorAll('.menu-mobile-toggle, .menu-mobile-toggle .hamburger');
644            if (toggle) {
645                this.toggleClass(buttons, 'is-active');
646            } else {
647                this.addClass(buttons, 'is-active');
648            }
649
650            if (document.body.classList.contains('is-menu-sidebar')) {
651                var menuSidebar = document.getElementById('header-menu-sidebar');
652                var menuSidebarInner = document.getElementById('header-menu-sidebar-inner');
653                var offset = menuSidebarInner.getBoundingClientRect();
654                var h = offset.height;
655
656                this.slideDown(menuSidebar, 300, function () {
657                    menuSidebar.style.height = h + 'px';
658                });
659            } else {
660                if (toggle) {
661                    this.closeMenuSidebar();
662                }
663            }
664        }
665    };
666
667    /**
668     * Auto align search form.
669     */
670    Customify.prototype.searchFormAutoAlign = function () {
671        var searchItems = document.querySelectorAll('.header-search_icon-item');
672        var w = window.innerWidth;
673
674        for (var i = 0; i < searchItems.length; i++) {
675            var container = searchItems[i];
676            var button = container.querySelector('.search-icon');
677            var buttonOffset = button.getBoundingClientRect();
678            this.removeClass(container, 'search-right search-left');
679            if (buttonOffset.left > w / 2) {
680                if (Customify_JS.is_rtl) {
681                    this.removeClass(container, 'search-left');
682                    this.addClass(container, 'search-right');
683                } else {
684                    this.removeClass(container, 'search-right');
685                    this.addClass(container, 'search-left');
686                }
687            } else {
688                if (Customify_JS.is_rtl) {
689                    this.removeClass(container, 'search-right');
690                    this.addClass(container, 'search-left');
691                } else {
692                    this.removeClass(container, 'search-left');
693                    this.addClass(container, 'search-right');
694                }
695            }
696        }
697    };
698
699    /**
700     * Search form.
701     */
702    Customify.prototype.initSearchForm = function () {
703        var searchItems = document.querySelectorAll('.header-search_icon-item');
704        var that = this;
705        searchItems.forEach(function (container) {
706            if (!container.classList.contains('js-added')) {
707                that.addClass(container, 'js-added');
708                that.removeClass(container, 'active');
709                var icon = container.querySelector('.search-icon');
710
711                var iconSearchClick = function (e) {
712                    e.preventDefault();
713                    var inputField = container.querySelector('.search-field');
714                    if (!container.classList.contains('active')) {
715                        container.classList.add('active');
716                        inputField.blur();
717                    } else {
718                        this.removeClass(container, 'active');
719                        inputField.focus();
720                    }
721                };
722
723                var clickOutSideSearchIcon = function (e) {
724                    // if the target of the click isn't the container nor a descendant of the container
725                    if (!(container === e.target) && !container.contains(e.target)) {
726                        that.removeClass(container, 'active');
727                    }
728                };
729
730                icon.removeEventListener('click', iconSearchClick);
731                //document.removeEventListener("click", clickOutSideSearchIcon);
732                /**
733                 * Add event handle when click to icon.
734                 */
735                that.addEvent(icon, 'click', iconSearchClick.bind(that));
736
737                /**
738                 * When click outside search form.
739                 */
740                that.addEvent(document, 'click', clickOutSideSearchIcon.bind(that));
741            }
742        });
743
744        that.searchFormAutoAlign();
745    };
746
747    /**
748     * Wrapper element
749     *
750     * @param Element element
751     * @param strig tag Tag name.
752     *
753     * @return Element
754     */
755    Customify.prototype.wrapper = function (element, tag) {
756        if (typeof tag === 'undefined') {
757            tag = 'div';
758        }
759        var wrapper = document.createElement(tag);
760        element.parentNode.replaceChild(wrapper, element);
761        wrapper.appendChild(element);
762        return wrapper;
763    };
764
765    /**
766     * Responsive table.
767     */
768    Customify.prototype.responsiveTable = function () {
769        var tables = document.querySelectorAll('.entry-content table');
770        for (var i = 0; i < tables.length; i++) {
771            if (!tables[i].parentNode.classList.contains('table-wrapper')) {
772                // Wrap table by each div.table-wrapper
773                var dWrapper = document.createElement('div');
774                dWrapper.classList.add('table-wrapper');
775                tables[i].parentNode.replaceChild(dWrapper, tables[i]);
776                dWrapper.appendChild(tables[i]);
777            }
778        }
779    };
780
781    /**
782     * Reponsive video style.
783     */
784    Customify.prototype.responsiveVideos = function () { };
785
786    /**
787     * Inittial
788     */
789    Customify.prototype.init = function () {
790        this.checkTouchScreen();
791        this.initMobieSearchForm();
792        this.initMobileSubMenu();
793        this.insertMenuOverlayClass();
794        this.setupMobileItemAnimations();
795        this.initMenuSidebar();
796        this.initSearchForm();
797        this.responsiveTable();
798        this.responsiveVideos();
799
800        /**
801         * Add action when Header Panel rendered by customizer.
802         */
803        document.addEventListener(
804            'header_builder_panel_changed',
805            function () {
806                this.initMobileSubMenu();
807                this.insertMenuOverlayClass();
808            }.bind(this)
809        );
810        // Add actions when window resize.
811        var tf;
812        window.addEventListener(
813            'resize',
814            function () {
815                // Resetup mobile animations
816                this.setupMobileItemAnimations();
817
818                // Resetup search form alignmenet.
819                this.removeClass(document.querySelectorAll('.header-search_icon-item'), 'active');
820                if (tf) {
821                    clearTimeout(tf);
822                }
823                tf = setTimeout(this.searchFormAutoAlign.bind(this), 100);
824            }.bind(this)
825        );
826
827        document.addEventListener(
828            'selective-refresh-content-rendered',
829            function (e) {
830                console.log('e.detail', e.detail);
831
832                if ('customify_customize_render_header' === e.detail) {
833                    var oldMenu = document.querySelector('body > .header-menu-sidebar');
834                    if (null !== oldMenu) {
835                        oldMenu.remove();
836                    }
837                    this.initMobieSearchForm();
838                    this.initMobileSubMenu();
839                    this.insertMenuOverlayClass();
840                    this.setupMobileItemAnimations();
841                    this.initMenuSidebar();
842                    this.initSearchForm();
843                    console.log('header_change');
844                }
845
846                if ('Customify_Builder_Item_Search_Icon__render' === e.detail) {
847                    this.initMobieSearchForm();
848                    this.initSearchForm();
849                    this.setupMobileItemAnimations();
850                }
851            }.bind(this)
852        );
853    };
854
855    /**
856     * Check is mobile.
857     * This may use in plugins.
858     *
859     * @deprecated 0.2.6
860     */
861    function customify_is_mobile() {
862        return Customify.isMobile();
863    }
864
865    window.customify_is_mobile = customify_is_mobile;
866    window.Customify = new Customify();
867
868    /**
869     * Fix viewport units on Mobile.
870     */
871    (function () {
872        if (window.Customify.isMobile()) {
873            /**
874             * https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
875             */
876            // First we get the viewport height and we multiple it by 1% to get a value for a vh unit
877            var vh = window.innerHeight * 0.01;
878            var vw = window.innerWidth * 0.01;
879            // Then we set the value in the --vh, --vw custom property to the root of the document
880            document.documentElement.style.setProperty('--vh', vh + 'px');
881            document.documentElement.style.setProperty('--vw', vw + 'px');
882
883            window.addEventListener('resize', function () {
884                var vh = window.innerHeight * 0.01;
885                var vw = window.innerWidth * 0.01;
886                document.documentElement.style.setProperty('--vh', vh + 'px');
887                document.documentElement.style.setProperty('--vw', vw + 'px');
888            });
889        }
890    })();
891})();
892
893/**
894 *
895 * Handles toggling the navigation menu for small screens and enables TAB key
896 * navigation support for dropdown menus.
897 */
898(function () {
899    var container, button, menu, links, i, len;
900
901    container = document.getElementById('site-navigation-main-desktop');
902    if (!container) {
903        return;
904    }
905
906    menu = container.getElementsByTagName('ul')[0];
907    // Hide menu toggle button if menu is empty and return early.
908    if ('undefined' === typeof menu) {
909        return;
910    }
911
912    menu.setAttribute('aria-expanded', 'false');
913    if (-1 === menu.className.indexOf('nav-menu')) {
914        menu.className += ' nav-menu';
915    }
916
917    // Get all the link elements within the menu.
918    links = menu.getElementsByTagName('a');
919
920    // Each time a menu link is focused or blurred, toggle focus.
921    for (i = 0, len = links.length; i < len; i++) {
922        links[i].addEventListener('focus', toggleFocus, true);
923        links[i].addEventListener('blur', toggleFocus, true);
924    }
925
926    /**
927     * Sets or removes .focus class on an element.
928     */
929    function toggleFocus() {
930        var self = this;
931
932        // Move up through the ancestors of the current link until we hit .nav-menu.
933        while (-1 === self.className.indexOf('nav-menu')) {
934            // On li elements toggle the class .focus.
935            if ('li' === self.tagName.toLowerCase()) {
936                if (-1 !== self.className.indexOf('focus')) {
937                    self.className = self.className.replace(' focus', '');
938                } else {
939                    self.className += ' focus';
940                }
941            }
942
943            self = self.parentElement;
944        }
945    }
946
947    /**
948     * Toggles `focus` class to allow submenu access on tablets.
949     */
950    (function (container) {
951        var touchStartFn,
952            i,
953            parentLink = container.querySelectorAll('.menu-item-has-children > a, .page_item_has_children > a');
954
955        if ('ontouchstart' in window) {
956            touchStartFn = function (e) {
957                var menuItem = this.parentNode,
958                    i;
959
960                if (!menuItem.classList.contains('focus')) {
961                    e.preventDefault();
962                    for (i = 0; i < menuItem.parentNode.children.length; ++i) {
963                        if (menuItem === menuItem.parentNode.children[i]) {
964                            continue;
965                        }
966                        menuItem.parentNode.children[i].classList.remove('focus');
967                    }
968                    menuItem.classList.add('focus');
969                } else {
970                    menuItem.classList.remove('focus');
971                }
972            };
973
974            for (i = 0; i < parentLink.length; ++i) {
975                parentLink[i].addEventListener('touchstart', touchStartFn, false);
976            }
977        }
978    })(container);
979})();
980
981/**
982 *
983 * Helps with accessibility for keyboard only users.
984 *
985 * Learn more: https://git.io/vWdr2
986 */
987(function () {
988    var isIe = /(trident|msie)/i.test(navigator.userAgent);
989
990    if (isIe && document.getElementById && window.addEventListener) {
991        window.addEventListener(
992            'hashchange',
993            function () {
994                var id = location.hash.substring(1),
995                    element;
996
997                if (!/^[A-z0-9_-]+$/.test(id)) {
998                    return;
999                }
1000
1001                element = document.getElementById(id);
1002
1003                if (element) {
1004                    if (!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)) {
1005                        element.tabIndex = -1;
1006                    }
1007
1008                    element.focus();
1009                }
1010            },
1011            false
1012        );
1013    }
1014})();

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.