PageSourceSearch

https://newmanministry.com/wp-content/themes/newman-ministry-child/js/child-global.js?ver=1.05

js newmanministry.com collected 2026-09-24 21:29:47 UTC 4,716 bytes, 127 lines download raw bytes

1/*
2 * animations as you scroll
3 */
4document.addEventListener("DOMContentLoaded", function() {
5    function observeElements(elements, className) {
6        var observerOptions = {
7            root: null,
8            rootMargin: '0px',
9            threshold: 0.2
10        };
11
12        var observer = new IntersectionObserver(function(entries, observer) {
13            entries.forEach(function(entry) {
14                if (entry.isIntersecting) {
15                    entry.target.classList.add(className);
16                }
17            });
18        }, observerOptions);
19
20        elements.forEach(function(element) {
21            observer.observe(element);
22        });
23    }
24
25    var homeHeroCards = document.querySelectorAll(".home-hero-card");
26    if (homeHeroCards.length > 0) {
27        observeElements(homeHeroCards, "pop");
28    }
29
30    var animatedElements = document.querySelectorAll(".animated");
31    if (animatedElements.length > 0) {
32        observeElements(animatedElements, "appear");
33    }
34});
35
36jQuery(document).ready(function(e) {
37    var activeSlide = null; // Variable to keep track of the active slide
38    var isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
39
40    // Function to handle hero slides for larger screens (>1024px)
41    function handleHeroSlides() {
42        if (jQuery(window).width() > 1024) {
43            // Hover over card to trigger slide change
44            jQuery('.home-hero-card').hover(function() {
45                jQuery('.home-hero-default').fadeOut();
46
47                // Get the hero slide associated with the hovered card
48                var slideNumber = jQuery(this).data('hero');
49
50                // Check if the same slide is already active
51                if (activeSlide !== slideNumber) {
52                    // Hide all slides and show the relevant one
53                    jQuery('.home-hero-slide').hide();
54                    jQuery('#homeHero' + slideNumber).fadeIn();
55
56                    // Set the new active slide
57                    activeSlide = slideNumber;
58                }
59
60                // Remove active state from any other cards
61                jQuery('.home-hero-card').removeClass('active');
62                jQuery(this).addClass('active');
63
64            }, function() {
65                // Optionally, you can define behavior when hovering off the card.
66            });
67
68            // Add functionality for closing the slide and returning to default
69            jQuery('.close-slide').on('click', function() {
70                // Hide all slides
71                jQuery('.home-hero-slide').hide();
72
73                // Show the default hero state
74                jQuery('.home-hero-default').fadeIn();
75
76                // Remove active class from cards
77                jQuery('.home-hero-card').removeClass('active');
78
79                activeSlide = null; // Reset active slide
80            });
81
82            // Ensure the active slide remains visible when hovering between the card and the slide
83            jQuery('.home-hero-slide').hover(function() {
84                if (activeSlide !== null) {
85                    jQuery('#homeHero' + activeSlide).show(); // Keep active slide visible
86                }
87            }, function() {
88                // Behavior when hovering off the slide (optional)
89            });
90        } else {
91            jQuery('.home-hero-card').removeClass('active');
92            jQuery('.home-hero-card').removeClass('pop');
93
94            // For screens 1024px or smaller, handle click/touch without triggering hero slides
95            jQuery('.home-hero-card').off('mouseenter mouseleave');
96
97            // Use 'touchstart' for better responsiveness on touch devices
98            jQuery('.home-hero-card-expand').on('click touchend', function(e) {
99                e.preventDefault();
100                var $this = jQuery(this).parent();
101
102                // Check if the clicked card is already open
103                if ($this.hasClass('open')) {
104                    // If it's already open, remove the 'open' class
105                    $this.removeClass('open');
106                } else {
107                    // If it's not open, remove 'open' from all cards and add it to the clicked one
108                    jQuery('.home-hero-card').removeClass('open');
109                    $this.addClass('open');
110                }
111            });
112
113            // Reset hero slides and keep default visible for mobile
114            jQuery('.home-hero-slide').hide();
115            jQuery('.home-hero-default').show();
116        }
117    }
118
119    // Run on document ready
120    handleHeroSlides();
121
122    // Rerun the function on window resize to adjust behavior
123    jQuery(window).resize(function() {
124        handleHeroSlides();
125    });
126    
127});

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.