PageSourceSearch

https://start4truckers.com/wp-content/plugins/stick-my-header-for-astra/js/stick_header.js?ver=1791053779

js start4truckers.com collected 2026-10-04 03:07:30 UTC 3,452 bytes, 101 lines download raw bytes

1jQuery(document).ready(function ($) {
2    // 1. Core Variables
3    var scrollTimer = null;
4    var isHovered = false;
5    
6    // 2. Helper: Get current active menu (Smart Detection)
7    function getActiveMenu() {
8        var mobileHeader = $("#ast-mobile-header");
9        var desktopHeader = $("#ast-desktop-header");
10        
11        // If mobile header exists and is not hidden by CSS
12        if (mobileHeader.length && mobileHeader.css("display") !== "none") {
13            return mobileHeader;
14        }
15        return desktopHeader;
16    }
17
18    // 3. Helper: Calculate Menu Top Offset
19    // We calculate this once for the visible header
20    var initialMenu = getActiveMenu();
21    const menuTop = initialMenu.length ? initialMenu.offset().top : 0;
22
23    // 4. Hover Protection
24    $("#ast-desktop-header, #ast-mobile-header").on("mouseenter", function() {
25        isHovered = true;
26        if (scrollTimer !== null) clearTimeout(scrollTimer);
27        $(this).removeClass("hidden-idle");
28    }).on("mouseleave", function() {
29        isHovered = false;
30        if (sh_obj.reading_mode === 'yes' && $(this).hasClass("sticky")) {
31            startHideTimer();
32        }
33    });
34
35    // 5. Hide Logic (Reading Focus Mode)
36    function startHideTimer() {
37        if (scrollTimer !== null) clearTimeout(scrollTimer);
38        
39        var menu = getActiveMenu();
40        var timeout = parseFloat(sh_obj.timeout) || 3;
41
42        scrollTimer = setTimeout(function () {
43            if (menu.hasClass("sticky") && !isHovered && sh_obj.reading_mode === 'yes') {
44                menu.addClass("hidden-idle");
45            }
46        }, timeout * 1000);
47    }
48
49    // 6. Scroll Logic
50    function handleScroll() {
51        var menu = getActiveMenu();
52        var isMobile = window.matchMedia("(max-width: 921px)").matches;
53        
54        var canBeSticky = true;
55        if (isMobile && sh_obj.sticky_mobile !== 'yes') {
56            canBeSticky = false;
57        }
58
59        if (window.pageYOffset > menuTop && canBeSticky) {
60            if (!menu.hasClass("sticky")) {
61                // Determine admin bar height to prevent overlapping
62                var adminBarHeight = $("#wpadminbar").length ? $("#wpadminbar").outerHeight() : 0;
63                
64                // Insert a placeholder to prevent content from snapping up
65                if ($(".sh-header-placeholder").length === 0) {
66                    $('<div class="sh-header-placeholder"></div>')
67                        .height(menu.outerHeight())
68                        .insertBefore(menu);
69                }
70                
71                menu.css("top", adminBarHeight + "px");
72                menu.addClass("sticky");
73            }
74        } else {
75            if (menu.hasClass("sticky")) {
76                $(".sh-header-placeholder").remove();
77                menu.css("top", "");
78                menu.removeClass("sticky");
79                menu.removeClass("hidden-idle");
80            }
81        }
82
83        // Reading Focus Mode trigger
84        var isReadingModeActive = (sh_obj.reading_mode === 'yes' && canBeSticky);
85        
86        if (isReadingModeActive) {
87            menu.removeClass("hidden-idle");
88            if (!isHovered) {
89                startHideTimer();
90            }
91        } else {
92            menu.removeClass("hidden-idle");
93        }
94    }
95
96    // 7. Event Listeners
97    window.addEventListener("scroll", handleScroll);
98    
99    // Initial check
100    handleScroll();
101});

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.