PageSourceSearch

https://www.devwebpro.com/wp-content/themes/wpnsite_theme/js/theme.js?ver=1.0.3

js devwebpro.com collected 2026-09-26 02:23:46 UTC 3,039 bytes, 74 lines download raw bytes

1/**
2 * WPNSite Theme — main JavaScript
3 *
4 * Requires Bootstrap 5 (bundled with Popper), loaded before this file.
5 */
6
7( function () {
8    'use strict';
9
10    document.addEventListener( 'DOMContentLoaded', function () {
11
12        // Bootstrap tooltip initialization (for any elements that use them).
13        document.querySelectorAll( '[data-bs-toggle="tooltip"]' ).forEach( function ( el ) {
14            new bootstrap.Tooltip( el );
15        } );
16
17        // Bootstrap popover initialization.
18        document.querySelectorAll( '[data-bs-toggle="popover"]' ).forEach( function ( el ) {
19            new bootstrap.Popover( el );
20        } );
21
22        // Smooth scroll for on-page anchor links.
23        document.querySelectorAll( 'a[href^="#"]:not([href="#"])' ).forEach( function ( anchor ) {
24            anchor.addEventListener( 'click', function ( e ) {
25                var target = document.querySelector( this.getAttribute( 'href' ) );
26                if ( target ) {
27                    e.preventDefault();
28                    target.scrollIntoView( { behavior: 'smooth', block: 'start' } );
29                    // Move focus to the target for accessibility.
30                    target.setAttribute( 'tabindex', '-1' );
31                    target.focus( { preventScroll: true } );
32                }
33            } );
34        } );
35
36        // Frosted-glass header: add class when page is scrolled past the top bar.
37        var siteHeader = document.getElementById( 'masthead' );
38        if ( siteHeader ) {
39            var onScroll = function () {
40                siteHeader.classList.toggle( 'site-header--scrolled', window.scrollY > 60 );
41            };
42            window.addEventListener( 'scroll', onScroll, { passive: true } );
43            onScroll(); // handle the case where the page loads already scrolled
44        }
45
46        // Collapse navbar on mobile when a nav link is clicked (excludes dropdowns).
47        var navbarCollapse = document.getElementById( 'primaryNav' );
48        if ( navbarCollapse ) {
49            navbarCollapse.querySelectorAll( '.nav-link:not(.dropdown-toggle)' ).forEach( function ( link ) {
50                link.addEventListener( 'click', function () {
51                    var bsCollapse = bootstrap.Collapse.getInstance( navbarCollapse );
52                    if ( bsCollapse ) {
53                        bsCollapse.hide();
54                    }
55                } );
56            } );
57        }
58
59        // Topics overlay: close the mobile hamburger drawer when the modal opens.
60        var topicsModalEl = document.getElementById( 'wpnsiteTopicsOverlay' );
61        if ( topicsModalEl && navbarCollapse ) {
62            topicsModalEl.addEventListener( 'shown.bs.modal', function () {
63                if ( navbarCollapse.classList.contains( 'show' ) ) {
64                    var bsCollapse = bootstrap.Collapse.getInstance( navbarCollapse );
65                    if ( bsCollapse ) {
66                        bsCollapse.hide();
67                    }
68                }
69            } );
70        }
71
72    } );
73
74} )();

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.