PageSourceSearch

https://www.alpyland.com/wp-content/themes/overlay/js/custom.js?ver=2.0.11

js alpyland.com collected 2026-10-02 19:20:28 UTC 3,923 bytes, 104 lines download raw bytes

1/**
2 * Overlay Custom Functionality
3 * Gets overlay_js from localize script
4 */
5( function( $ ) {
6
7    $( document ).ready( function() {
8        // Add button to sub-menu item to show nested pages / Only used on mobile
9        $( '.main-navigation li.page_item_has_children > a, .main-navigation li.menu-item-has-children > a' ).after( '<button class="menu-dropdown-btn"><i class="fa fa-angle-right"></i></button>' );
10        $( '.main-navigation.overlay-nav-block ul#overlay-main-menu > li > a, .main-navigation.overlay-nav-block #overlay-main-menu > ul > li > a' ).wrapInner( '<span class="nav-span-block"></span>' );
11        // Add/Remove .focus class for accessibility
12        $( '.main-navigation' ).find( 'a' ).on( 'focus blur', function() {
13            $( this ).parents( 'ul, li' ).toggleClass( 'focus' );
14        } );
15        // Mobile nav button functionality
16        $( '.menu-dropdown-btn' ).click( function(e){
17            $(this).parent().toggleClass( 'open-page-item' );
18        });
19        // The menu toggle button
20        $( '.menu-toggle' ).click( function(e){
21            $( 'body' ).toggleClass( 'show-main-menu' );
22            var element = $( '.menu-main-menu-container' );
23            trapFocus( element );
24        });
25        $( '.main-menu-close' ).click( function(e){
26            $( '.menu-toggle' ).click();
27            $( '.menu-toggle' ).focus();
28        });
29        $( document ).on( 'keyup',function(evt) {
30            if ( $( 'body' ).hasClass( 'show-main-menu' ) && evt.keyCode == 27 ) {
31                $( '.menu-toggle' ).click();
32                $( '.menu-toggle' ).focus();
33            }
34        });
35        // True/False Aria label for accessibility
36        $( '.menu-toggle' ).on( 'click', function() {
37            var visible = $( 'body' ).hasClass( 'show-main-menu' );
38            if ( visible ) {
39                $( this ).attr( 'aria-expanded', 'true' );
40            } else {
41                $( this ).attr( 'aria-expanded', 'false' );
42            }
43        } );
44
45        // Show / Hide Floating Sidebar
46        $( '.floating-sidebar-control' ).click( function(e){
47            $( 'body' ).toggleClass( 'show-floating-sidebar' );
48        });
49
50        // Show / Hide Search
51        $( '.header-search' ).on( 'click', function() {
52            $( 'body').addClass( 'show-site-search' );
53            $( '.header-search-block input.search-field' ).focus();
54        });
55
56    } );
57
58    $( window ).resize(function () {
59        // Close menu if open and browser is scrolled out on mobile
60        var breakpoint = 'tablet' == overlay_js.menu_breakpoint ? overlay_js.menu_tablet : overlay_js.menu_mobile;
61        if ( $( window ).width() > breakpoint ) {
62            $( 'body' ).removeClass( 'show-main-menu' );
63        }
64    });
65
66    // Hide Search if user clicks outside
67    $( document ).mouseup( function (e) {
68        var container = $( '.header-search-block' );
69        if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) {
70            $( 'body' ).removeClass( 'show-site-search' );
71        }
72    });
73
74} )( jQuery );
75
76function trapFocus( element, namespace ) {
77    var focusableEls = element.find( 'a, button' );
78    var firstFocusableEl = focusableEls[0];
79    var lastFocusableEl = focusableEls[focusableEls.length - 1];
80    var KEYCODE_TAB = 9;
81
82    firstFocusableEl.focus();
83
84    element.keydown( function(e) {
85        var isTabPressed = ( e.key === 'Tab' || e.keyCode === KEYCODE_TAB );
86
87        if ( !isTabPressed ) { 
88            return;
89        }
90
91        if ( e.shiftKey ) /* shift + tab */ {
92            if ( document.activeElement === firstFocusableEl ) {
93                lastFocusableEl.focus();
94                e.preventDefault();
95            }
96        } else /* tab */ {
97            if ( document.activeElement === lastFocusableEl ) {
98                firstFocusableEl.focus();
99                e.preventDefault();
100            }
101        }
102
103    });
104}

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.