PageSourceSearch

https://twigeducation.com/wp-content/plugins/responsive-youtube-vi…/assets/js/wp-video-popup.js?ver=2.10.1

js twigeducation.com collected 2026-10-02 07:30:17 UTC 2,803 bytes, 110 lines download raw bytes

1/**
2 * NodeList.forEach polyfill for IE
3 * 
4 * @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
5 */
6if (window.NodeList && !NodeList.prototype.forEach) {
7	NodeList.prototype.forEach = Array.prototype.forEach;
8}
9
10/**
11 * Custom Event polyfill for >= IE9
12 *
13 * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
14 */
15(function () {
16	if (typeof window.CustomEvent === "function") return false;
17
18	function CustomEvent(event, params) {
19		params = params || { bubbles: false, cancelable: false, detail: null };
20		var evt = document.createEvent('CustomEvent');
21		evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
22		return evt;
23	}
24
25	window.CustomEvent = CustomEvent;
26})();
27
28(function ($) {
29	// Free version only support 1 video per page/ post.
30	var popup = document.querySelector('.wp-video-popup-wrapper');
31	var speed = 200;
32
33	function init() {
34		if (!popup) return;
35		setupOpenActions();
36		setupVideoHeight();
37		setupCloseActions();
38	}
39
40	function setupOpenActions() {
41		// Setup trigger for single popup.
42		setupOpenTriggers('.wp-video-popup');
43
44		// Setup trigger for single popup (backward compatibility support).
45		setupOpenTriggers('.ryv-popup');
46	}
47
48	function setupOpenTriggers(triggerSelector) {
49		var triggers = document.querySelectorAll(triggerSelector);
50		if (!triggers) return;
51
52		triggers.forEach(function (trigger) {
53			trigger.addEventListener('click', function (e) {
54				e.preventDefault();
55				openPopup();
56			});
57		});
58	}
59
60	function setupCloseActions() {
61		// Close on click.
62		popup.addEventListener('click', function (e) {
63			if (e.target == this || e.target.classList.contains('wp-video-popup-close')) closePopup();
64		});
65
66		// Close on escape.
67		document.addEventListener('keyup', function (e) {
68			if (e.key !== 'Escape' && e.key !== 'Esc' && e.keyCode !== 27) return;
69			if ($(popup).is(':visible')) closePopup();
70		});
71	}
72
73	function setupVideoHeight() {
74		window.addEventListener('resize', function () {
75			var video = document.querySelector('.wp-video-popup-video.is-resizable');
76			if (video) $(video).height($(video).width() * 0.5625);
77		});
78	}
79
80	function openPopup() {
81		var video = popup.querySelector('.wp-video-popup-video');
82
83		document.body.insertBefore(popup, document.body.firstChild);
84
85		$(popup).css({ display: 'flex' }).stop().animate({
86			opacity: 1
87		}, speed);
88
89		$(video).stop().fadeIn(speed);
90		video.src = video.dataset.wpVideoPopupUrl;
91
92		window.dispatchEvent(new Event('resize'));
93	}
94
95	function closePopup() {
96		var video = popup.querySelector('.wp-video-popup-video');
97
98		$(popup).stop().animate({
99			opacity: 0
100		}, speed, function () {
101			$(popup).css({ display: 'none' });
102		});
103
104		$(video).stop().fadeOut(speed, function () {
105			video.src = '';
106		});
107	}
108
109	init();
110})(jQuery);

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.