PageSourceSearch

https://www.girlsaloud.com/wp-content/plugins/umg-grand-royal-them…/web-components/wc-splash.js?ver=3.5.8

js girlsaloud.com collected 2026-09-25 01:00:57 UTC 6,897 bytes, 177 lines download raw bytes

1(function ($) {
2
3    var splashVideo;
4
5    "use strict";
6    //check if splash modal is already set
7    function isSplashed() {
8        var splashed = false;
9        if (typeof (sessionStorage) !== 'undefined') {
10            splashed = sessionStorage.getItem('umggr-wc-splashed');
11        }
12        return splashed;
13    }
14
15    //set splashed session key
16    function setSplashed() {
17        if (typeof (sessionStorage) !== 'undefined') {
18            sessionStorage.setItem('umggr-wc-splashed', true);
19        }
20    }
21    function setplayerSplash(container, videoId) {
22        if(!$(container).length || (typeof YTPlayer === 'undefined')) return;
23
24        var ytPlayerHost = (!UMGGR_WC_Splash_Shortcode.disable_cookies ? 'https://www.youtube.com' : 'https://www.youtube-nocookie.com');
25
26        var ytPlayerAutoplay = false;
27        var ytPlayerMute = false;
28        if (UMGGR_WC_Splash_Shortcode.autoplay_setting != 'null') {
29            ytPlayerAutoplay = true;
30            ytPlayerMute = true;
31        }
32        $(container).YTPlayer({
33            videoId: videoId,
34            host: ytPlayerHost,
35            playerVars: {'autoplay': ytPlayerAutoplay, 'mute': ytPlayerMute, 'controls': 0, 'showinfo': 0, 'rel': 0, 'playlist': videoId, 'loop': 1},
36             events: {
37                    'onReady': function(event){
38                        // $('#umggr-wc-splash-modal').trigger('youtube-splash-ready');
39                        $('#umggr-wc-splash-modal .media-aspect-wrapper').css('display', 'block');
40                        $('#umggr-wc-splash-modal .media-aspect-wrapper').addClass('is-visible');
41                    },
42                }
43        });
44        splashVideo = $(container).data('ytPlayer').player;
45
46    }
47    function setYtVideo(container, videoId) {
48        $(container).parent().hide();
49        if (typeof (YT) == 'undefined' || typeof (YT.Player) == 'undefined') {
50            window.onYouTubeIframeAPIReady = function () {
51                setplayerSplash(container, videoId);
52            };
53        } else {
54            setplayerSplash(container, videoId);
55        }
56    }
57
58    UMGGR_WC_Splash_Shortcode.showSplash = function() {
59        //check if #umggr-wc-splash-modal modal is present and cookie is not set
60        //splash cookie is set once modal is shown once and valid for the current browser session
61        //only show splash page on homepage
62
63        if ($('#umggr-wc-splash-modal').length && UMGGR_WC_Splash_Shortcode.is_home){
64            var $obj = $('#umggr-wc-splash-modal');
65            if($obj.attr('data-repeatsplash') == 'first_time') {
66                if(!isSplashed()) {
67                    $obj.attr('visible', '');
68                    $('body').addClass('-no-overflow');
69                }
70            }else{
71                sessionStorage.setItem('umggr-wc-splashed', '');
72                $obj.attr('visible', '');
73                $('body').addClass('-no-overflow');
74            }
75        }
76    }
77
78    UMGGR_WC_Splash_Shortcode.initSplash = function() {
79
80        if ($('#umggr-wc-splash-modal .yt-holder').length > 0){
81            var ytId = $('#umggr-wc-splash-modal .yt-holder').data('yt-id');
82            var container = $('#umggr-wc-splash-modal .yt-holder')[0];
83            setYtVideo(container, ytId);
84        }
85
86        $('#close-modal, #close-splash').on('click', function(e){
87            e.preventDefault();
88            $('body').removeClass('-no-overflow');
89            $('#umggr-wc-splash-modal').remove();
90            setSplashed();
91        });
92
93        if (UMGGR_WC_Splash_Shortcode.video_format == 'youtube') {
94            // add the mute / unmute functionality to the mute icons
95            var sound_playing = false;
96            $('#video-audio-toggle').on('click', function(e) {
97                var audioToggleButton = document.querySelector("#video-audio-toggle-icon");
98                e.preventDefault();
99                sound_playing = !sound_playing;
100                $(this).toggleClass('playing');
101                muteUnmute(splashVideo, sound_playing);
102                if (sound_playing) {
103                    audioToggleButton.setAttribute('icon', 'unmute');
104                } else {
105                    audioToggleButton.setAttribute('icon', 'mute');
106                }
107            });
108        } else if (UMGGR_WC_Splash_Shortcode.video_format == 'mp4') {
109            $('#video-audio-toggle').on('click', function(e) {
110                var audioToggleButton = document.querySelector("#video-audio-toggle-icon");
111
112                e.preventDefault();
113                if( jQuery("#mp4-video").prop('muted') ) {
114                    jQuery("#mp4-video").prop('muted', false);
115                    audioToggleButton.setAttribute('icon', 'unmute');
116                } else {
117                    jQuery("#mp4-video").prop('muted', true);
118                    audioToggleButton.setAttribute('icon', 'mute');
119                }
120            });
121        }
122
123        function muteUnmute(player, sound_playing) {
124            if (typeof player !== 'undefined') {
125                if (sound_playing) {
126                    player.unMute();
127                } else {
128                    player.mute();
129                }
130            }
131        }
132    }
133
134    // Attempt to pause any youtube videos
135    function stopModalVideoPlayback()
136    {
137        // Find all <my-deferred-media> custom elements
138        var deferredMediaElements = document.querySelectorAll('umg-media-modal.deferred-media-modal umg-deferred-media');
139
140        // Loop through each <my-deferred-media> element
141        deferredMediaElements.forEach(function(deferredMediaElement) {
142
143            // Find all <iframe> elements inside the current <my-deferred-media> element
144            var iframes = deferredMediaElement.shadowRoot.querySelectorAll('iframe');
145
146            // Loop through each <iframe> element
147            iframes.forEach(function(iframe) {
148                // Access the content window of the <iframe> element
149                var iframeWindow = iframe.contentWindow;
150
151                // Send a message to the YouTube player API to stop the video playback
152                iframeWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
153            });
154        });
155    }
156    
157    // function that handles the esc key being pressed which will
158    // close modals automatically but we'll need to also stop any
159    // youtube videos from playing too
160    function handleEscKey(event)
161    {
162        // Check if the Escape key is pressed
163        if (event.key === 'Escape' || event.keyCode === 27) {
164            stopModalVideoPlayback();
165            $('body').removeClass('-no-overflow');
166        }
167    }
168
169    $(document).ready(function () {
170        UMGGR_WC_Splash_Shortcode.initSplash();
171        UMGGR_WC_Splash_Shortcode.showSplash();
172    });
173
174    // Add event listener for esc key event
175    document.addEventListener('keydown', handleEscKey);
176
177})(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.