PageSourceSearch

https://senatorpicozzi.com/wp-content/themes/psrc22_senator/js/senator-header-zindex-toggle.js

js senatorpicozzi.com collected 2026-10-08 06:38:13 UTC 2,488 bytes, 84 lines download raw bytes

1jQuery(document).ready(function (jQuery) {
2    // Select the target button
3    var $toggleButton = jQuery('.mega-toggle-animated');
4    var $headerOuter = jQuery('.psrc-senator-header-outer');
5
6    if ($toggleButton.length === 0 || $headerOuter.length === 0) {
7        return;
8    }
9
10    var mq = window.matchMedia('(max-width: 767px)');
11    var observer = null;
12    var enabled = false;
13
14    // Function to update z-index based on aria-expanded state
15    function updateZIndex() {
16        var isExpanded = $toggleButton.attr('aria-expanded') === 'true';
17        if (isExpanded) {
18            $headerOuter.css('z-index', '0');
19        } else {
20            $headerOuter.css('z-index', '1001');
21        }
22    }
23
24    function enableMobileBehavior() {
25        if (enabled) return;
26        enabled = true;
27
28        // Initial state
29        updateZIndex();
30
31        // Click handler (namespaced)
32        $toggleButton.on('click.senatorZ', function () {
33            // Delay slightly to let aria-expanded attribute update
34            setTimeout(updateZIndex, 10);
35        });
36
37        // Observe attribute changes in case another script toggles it
38        observer = new MutationObserver(function (mutations) {
39            mutations.forEach(function (mutation) {
40                if (mutation.attributeName === 'aria-expanded') {
41                    updateZIndex();
42                }
43            });
44        });
45
46        $toggleButton.each(function (i, el) {
47            observer.observe(el, { attributes: true, attributeFilter: ['aria-expanded'] });
48        });
49    }
50
51    function disableMobileBehavior() {
52        if (!enabled) return;
53        enabled = false;
54
55        // Remove click handler and observer
56        $toggleButton.off('click.senatorZ');
57        if (observer) {
58            observer.disconnect();
59            observer = null;
60        }
61
62        // Clear inline style so desktop CSS applies
63        $headerOuter.css('z-index', '');
64    }
65
66    function evaluate() {
67        if (mq.matches) {
68            enableMobileBehavior();
69        } else {
70            disableMobileBehavior();
71        }
72    }
73
74    // Initial run
75    evaluate();
76
77    // Respond to viewport changes
78    if (typeof mq.addEventListener === 'function') {
79        mq.addEventListener('change', evaluate);
80    } else if (typeof mq.addListener === 'function') {
81        // Older browsers
82        mq.addListener(evaluate);
83    }
84});

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.