PageSourceSearch

https://shoboyshow.com/components/com_gridbox/libraries/modules/initoverlay-button.js?2.20.2.1

js shoboyshow.com collected 2026-10-08 03:22:52 UTC 8,696 bytes, 211 lines download raw bytes

1/**
2* @package   Gridbox
3* @author    Balbooa http://www.balbooa.com/
4* @copyright Copyright @ Balbooa
5* @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
6*/
7
8var overlayVideo = {};
9
10function overlayClose(item)
11{
12    var iframes = item.querySelectorAll('.ba-item-custom-html iframe, .ba-item-video iframe, .ba-item-field-video iframe');
13    for (var i = 0; i < iframes.length; i++) {
14        let src = iframes[i].src,
15            videoId = iframes[i].id;
16        if (src && src.indexOf('youtube.com') !== -1 && 'pauseVideo' in overlayVideo[videoId]) {
17            overlayVideo[videoId].pauseVideo();
18        } else if (src && src.indexOf('vimeo.com') !== -1 && 'pause' in overlayVideo[videoId]) {
19            overlayVideo[videoId].pause();
20        } else if (src && src.indexOf('youtube-nocookie.com') !== -1) {
21            iframes[i].closest('.ba-video-wrapper').innerHTML = iframes[i].closest('.ba-video-wrapper').innerHTML;
22        }
23    }
24    iframes = item.querySelectorAll('.ba-item-video video, .ba-item-custom-html video, .ba-item-field-video video');
25    for (var i = 0; i < iframes.length; i++) {
26        let videoId = iframes[i].id;
27        overlayVideo[videoId].pause();
28    }
29}
30
31function overlayOpen(item)
32{
33    if (item.querySelectorAll('.video-lazy-load-thumbnail')) {
34        $g(item).find('.video-lazy-load-thumbnail').trigger('click');
35    }
36    var iframes = item.querySelectorAll('.ba-item-custom-html iframe, .ba-item-video iframe, .ba-item-field-video iframe'),
37        youtube = false,
38        vimeo = false,
39        id = +new Date();
40    for (var i = 0; i < iframes.length; i++) {
41        var src = iframes[i].src,
42            videoId;
43        if (src && src.indexOf('youtube.com') !== -1) {
44            if (!app.youtube) {
45                youtube = true;
46            } else {
47                if (src.indexOf('enablejsapi=1') === -1) {
48                    if (src.indexOf('?') === -1) {
49                        src += '?';
50                    } else {
51                        src += '&'
52                    }
53                    src += 'enablejsapi=1';
54                    iframes[i].src = src;
55                }
56                if (!iframes[i].id) {
57                    iframes[i].id = id++;
58                }
59                videoId = iframes[i].id;
60                if (!overlayVideo[videoId] || !('playVideo' in overlayVideo[videoId])) {
61                    overlayVideo[videoId] = new YT.Player(videoId, {
62                        events: {
63                            onReady: function(event){
64                                if (item.classList.contains('visible-section')) {
65                                    overlayVideo[videoId].playVideo();
66                                }
67                            }
68                        }
69                    });
70                } else {
71                    overlayVideo[videoId].playVideo();
72                }
73            }
74        } else if (src && src.indexOf('vimeo.com') !== -1) {
75            if (!app.vimeo) {
76                vimeo = true;
77            } else {
78                if (!iframes[i].id) {
79                    iframes[i].id = id++;
80                }
81                videoId = iframes[i].id;
82                if (!overlayVideo[videoId] || !('play' in overlayVideo[videoId])) {
83                    src = src.split('/');
84                    src = src.slice(-1);
85                    src = src[0].split('?');
86                    src = src[0];
87                    var options = {
88                        id: src * 1,
89                        loop: true,
90                    };
91                    overlayVideo[videoId] = new Vimeo.Player(videoId, options);
92                }
93                overlayVideo[videoId].play();
94            }
95        }
96    }
97    iframes = item.querySelectorAll('.ba-item-video video, .ba-item-custom-html video, .ba-item-field-video video');
98    for (var i = 0; i < iframes.length; i++) {
99        if (!iframes[i].id) {
100            iframes[i].id = id++;
101        }
102        videoId = iframes[i].id;
103        if (!overlayVideo[videoId]) {
104            overlayVideo[videoId] = iframes[i];
105        }
106        overlayVideo[videoId].play();
107    }
108    if (youtube || vimeo) {
109        var object = {
110            data : {}
111        };
112        if (youtube && !vimeo) {
113            object.data.type = 'youtube';
114        } else if (vimeo && !youtube) {
115            object.data.type = 'vimeo';
116        } else {
117            object.data.type = 'youtube+vimeo';
118        }
119        app.checkModule('loadVideoApi', object);
120    }
121    if (youtube) {
122        overlayVideo.overlay = item;
123    } else if (vimeo) {
124        overlayVideo.overlay = item;
125    }
126
127    return !youtube && !vimeo;
128}
129
130app['initoverlay-button'] = function(obj, key){
131    var button = $g('#'+key)[0],
132        id = button.id,
133        overlay = button.dataset.overlay;
134    $g(button).find('> .ba-button-wrapper > a, > .ba-image-wrapper').attr('tabindex', 0)
135    $g(button).on('click keyup', ' > .ba-button-wrapper > a, > .ba-image-wrapper', function(event){
136        app.AccessibilityHelper.processAction(event, () => {
137            event.preventDefault();
138            openOverlaySection(button);
139        })
140    });
141    $g(`.ba-overlay-section-backdrop[data-id="${overlay}"]`).on('keyup', function(event){
142        if (event.key == 'Escape') {
143            $g(this).find('.ba-overlay-section-close').first().click();
144        }
145    }).each(function(){
146        $g(this).find('.close-overlay-section .ba-overlay-section-close').attr('tabindex', 0);
147    }).find(`.ba-overlay-section-close`).on('click keyup', function(event){
148        app.AccessibilityHelper.processAction(event, () => {
149            const item = $g(this).closest('.ba-overlay-section-backdrop');
150            item.removeClass('visible-section').addClass('overlay-section-backdrop-out');
151            app.AccessibilityHelper.releaseTrap(item[0]);
152            setTimeout(function(){
153                item.removeClass('overlay-section-backdrop-out');
154            }, 400);
155            if (!$g('.ba-overlay-section-backdrop').not(item).hasClass('visible-section')) {
156                document.body.classList.remove('lightbox-open');
157                document.body.classList.remove('ba-not-default-header');
158                document.body.style.width = '';
159                $g('body > header.header').css('width', '');
160            }
161            item.find('div.ba-overlay-section-close').css('width', '');
162            $g('.ba-sticky-header').css('width', '');
163            overlayClose(item[0]);
164        })
165    }).on('mouseover', function(event){
166        event.stopPropagation();
167    });
168    initItems();
169}
170
171function openOverlaySection(button)
172{
173    let overlay = button.dataset.overlay,
174        item = document.querySelector('.ba-overlay-section-backdrop[data-id="'+overlay+'"]');
175    if (app.items[overlay][app.view].disable == 1 && !document.body.classList.contains('show-hidden-elements')) {
176        item.classList.remove('visible-section');
177        document.body.classList.remove('lightbox-open');
178        document.body.classList.remove('ba-not-default-header');
179    } else {
180        overlayOpen(item) ? openOverlay(item) : '';
181    }
182}
183
184function openOverlay(item)
185{
186    var header = document.querySelector('body > header.header'),
187        style = header ? getComputedStyle(header): {},
188        width = window.innerWidth - document.documentElement.clientWidth,
189        hWidth = width + (themeData.page.view == 'gridbox' && app.view == 'desktop' ? 103 : 0),
190        calc = 'calc(100% - '+width+'px)',
191        headerWidth = 'calc(100% - '+hWidth+'px)';
192    document.body.style.width = calc;
193    item.querySelector('div.ba-overlay-section-close').style.width = calc;
194    if (header && header.classList.contains('sidebar-menu') && (app.view == 'desktop' || app.view == 'laptop')) {
195        headerWidth = 'calc(100% - '+hWidth+'px - var(--sidebar-menu-width))';
196    }
197    $g('.ba-sticky-header').css('width', headerWidth);
198    item.classList.add('visible-section');
199    document.body.classList.add('lightbox-open');
200    if (style.position == 'fixed') {
201        $g('body > header.header').css('width', 'calc(100% - '+hWidth+'px)');
202    }
203    if (style.position != 'relative') {
204        document.body.classList.add('ba-not-default-header');
205    }
206    app.AccessibilityHelper.trapFocus(item, 350);
207    $g(window).trigger("scroll");
208}
209if (app.modules['initoverlay-button']) {
210    app['initoverlay-button'](app.modules['initoverlay-button'].data, app.modules['initoverlay-button'].selector);
211}

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.