PageSourceSearch

https://lifelinechild.org/wp-content/plugins/smartupworld-video-modal/assets/script.js?ver=1790182076

js lifelinechild.org collected 2026-09-24 19:15:56 UTC 2,961 bytes, 88 lines download raw bytes

1( function () {
2	'use strict';
3
4	function closeModal( modal ) {
5		modal.querySelector( '.video-container' )
6			.querySelectorAll( 'video, iframe' )
7			.forEach( function ( el ) { el.remove(); } );
8		modal.classList.remove( 'is-open' );
9		modal.style.display = 'none';
10	}
11
12	document.addEventListener( 'DOMContentLoaded', function () {
13
14		// Open modal on button click
15		document.querySelectorAll( '.smartupworld-video-modal-button' ).forEach( function ( btn ) {
16			btn.addEventListener( 'click', function ( e ) {
17				e.preventDefault();
18
19				var uniq     = btn.getAttribute( 'data-target' );
20				var modal    = document.getElementById( 'videoModal_' + uniq );
21				if ( ! modal ) return;
22
23				var container = modal.querySelector( '.video-container' );
24				var videoUrl  = btn.getAttribute( 'data-video-url' );
25				var type      = btn.getAttribute( 'data-type' ) || 'video';
26
27				// Remove any existing media
28				container.querySelectorAll( 'video, iframe' ).forEach( function ( el ) { el.remove(); } );
29
30				if ( type === 'youtube' ) {
31					var autoplayUrl = videoUrl.indexOf( '?' ) !== -1
32						? videoUrl + '&autoplay=1'
33						: videoUrl + '?autoplay=1';
34
35					var iframe          = document.createElement( 'iframe' );
36					iframe.src          = autoplayUrl;
37					iframe.width        = '100%';
38					iframe.height       = '450';
39					iframe.setAttribute( 'frameborder', '0' );
40					iframe.setAttribute( 'allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' );
41					iframe.setAttribute( 'allowfullscreen', 'true' );
42					iframe.setAttribute( 'loading', 'lazy' );
43					container.appendChild( iframe );
44				} else {
45					var video     = document.createElement( 'video' );
46					video.controls = true;
47					video.autoplay = true;
48					video.setAttribute( 'playsinline', '' );
49					video.src      = videoUrl;
50					container.appendChild( video );
51				}
52
53				modal.style.display = 'flex';
54				modal.classList.add( 'is-open' );
55
56				// Move focus to close button for accessibility
57				var closeBtn = modal.querySelector( '.close-btn' );
58				if ( closeBtn ) closeBtn.focus();
59			} );
60		} );
61
62		// Close on close button click
63		document.querySelectorAll( '.close-btn' ).forEach( function ( closeBtn ) {
64			closeBtn.addEventListener( 'click', function () {
65				var uniq  = closeBtn.getAttribute( 'data-target' );
66				var modal = document.getElementById( 'videoModal_' + uniq );
67				if ( modal ) closeModal( modal );
68			} );
69		} );
70
71		// Close on backdrop click
72		document.querySelectorAll( '.video-modal' ).forEach( function ( modal ) {
73			modal.addEventListener( 'click', function ( e ) {
74				if ( e.target === modal ) closeModal( modal );
75			} );
76		} );
77
78		// Close on Escape key
79		document.addEventListener( 'keydown', function ( e ) {
80			if ( e.key === 'Escape' ) {
81				document.querySelectorAll( '.video-modal.is-open' ).forEach( function ( modal ) {
82					closeModal( modal );
83				} );
84			}
85		} );
86
87	} );
88} )();

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.