PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.1.6
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.1.6
4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / front.js
embedpress / assets / js Last commit date
vendor 7 years ago admin.js 1 year ago ads.js 1 year ago carousel.js 1 year ago carousel.min.js 2 years ago documents-viewer-script.js 3 years ago front.js 1 year ago glider.js 1 year ago glider.min.js 2 years ago gutneberg-script.js 2 years ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 2 years ago instafeed.js 2 years ago license.js 2 years ago pdfobject.js 1 year ago plyr.js 1 year ago plyr.polyfilled.js 3 years ago preview.js 3 years ago settings.js 6 years ago vimeo-player.js 2 years ago ytiframeapi.js 2 years ago
front.js
1397 lines
1 /**
2 * @package EmbedPress
3 * @author EmbedPress <help@embedpress.com>
4 * @copyright Copyright (C) 2023 EmbedPress. All rights reserved.
5 * @license GPLv2 or later
6 * @since 1.7.0
7 */
8
9
10
11 let epGlobals = {};
12
13 (function ($) {
14 'use strict';
15 // function equivalent to jquery ready()
16 function ready(fn) {
17 if (document.readyState !== 'loading') {
18 fn();
19 } else {
20 document.addEventListener('DOMContentLoaded', fn);
21 }
22 }
23
24 ready(function () {
25 let option = {
26 forceObject: true,
27 };
28 let selector = document.querySelectorAll('.embedpress-embed-document-pdf');
29 if (selector.length) {
30 selector.forEach((function (value, index, thisArg) {
31 let id = value.dataset['emid'];
32 let src = value.dataset['emsrc'];
33 PDFObject?.embed(src, "." + id, option);
34 }));
35 }
36 if (typeof epGlobals.youtubeChannelGallery === 'function') {
37 epGlobals.youtubeChannelGallery();
38 }
39 });
40
41 /**
42 *
43 * Make embeds responsive so they don't overflow their container.
44 */
45
46 /**
47 * Add max-width & max-height to <iframe> elements, depending on their width & height props.
48 *
49 *
50 * @return {void}
51 */
52 function embedPressResponsiveEmbeds() {
53 var proportion, parentWidth;
54
55 // Loop iframe elements.
56 document.querySelectorAll('iframe').forEach(function (iframe) {
57 // Only continue if the iframe has a width & height defined.
58 if (iframe.width && iframe.height) {
59 // Calculate the proportion/ratio based on the width & height.
60 proportion = parseFloat(iframe.width) / parseFloat(iframe.height);
61 // Get the parent element's width.
62 parentWidth = parseFloat(window.getComputedStyle(iframe.parentElement, null).width.replace('px', ''));
63 // Set the max-width & height.
64 iframe.style.maxWidth = '100%';
65 iframe.style.maxHeight = Math.round(parentWidth / proportion).toString() + 'px';
66 }
67 });
68 }
69
70 epGlobals.handlePosterImageLoad = function () {
71 var posterImages = document.querySelectorAll(".plyr__poster");
72 posterImages.forEach(function (posterImage) {
73 if (posterImage) {
74 var videoWrappers = document.querySelectorAll("[data-playerid]");
75 videoWrappers.forEach(function (videoWrapper) {
76 var observer = new MutationObserver(function (mutationsList, observer) {
77 var posterImageStyle = window.getComputedStyle(posterImage);
78 if (posterImageStyle.getPropertyValue('background-image') !== 'none') {
79 setTimeout(function () {
80 videoWrapper.style.opacity = "1";
81 }, 200);
82 observer.disconnect();
83 }
84 });
85
86 observer.observe(posterImage, { attributes: true, attributeFilter: ['style'] });
87 });
88 }
89 });
90 }
91
92
93
94 // Run on initial load.
95 embedPressResponsiveEmbeds();
96
97 // Run on resize.
98 window.onresize = embedPressResponsiveEmbeds;
99
100
101 function hasClass(ele, cls) {
102 return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
103 }
104
105 function addClass(ele, cls) {
106 if (!hasClass(ele, cls)) ele.className += " " + cls;
107 }
108
109 function removeClass(ele, cls) {
110 if (hasClass(ele, cls)) {
111 var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
112 ele.className = ele.className.replace(reg, " ");
113 }
114 }
115 if (!Element.prototype.matches) {
116 Element.prototype.matches =
117 Element.prototype.matchesSelector ||
118 Element.prototype.webkitMatchesSelector ||
119 Element.prototype.mozMatchesSelector ||
120 Element.prototype.msMatchesSelector ||
121 Element.prototype.oMatchesSelector ||
122 function (s) {
123 var matches = (this.document || this.ownerDocument).querySelectorAll(s),
124 i = matches.length;
125 while (--i >= 0 && matches.item(i) !== this) { }
126 return i > -1;
127 };
128 }
129 var delegate = function (el, evt, sel, handler) {
130 el.addEventListener(evt, function (event) {
131 var t = event.target;
132 while (t && t !== this) {
133 if (t.matches(sel)) {
134 handler.call(t, event);
135 }
136 t = t.parentNode;
137 }
138 });
139 };
140
141 function sendRequest(url, postData, callback) {
142 var req = createXMLHTTPObject();
143 if (!req) return;
144 var method = postData ? "POST" : "GET";
145 req.open(method, url, true);
146 if (postData) {
147 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
148 }
149 req.onreadystatechange = function () {
150 if (req.readyState != 4) return;
151 if (req.status != 200 && req.status != 304) {
152 return;
153 }
154 callback(req);
155 };
156 if (req.readyState == 4) return;
157 req.send(postData);
158 }
159
160 var XMLHttpFactories = [
161 function () {
162 return new XMLHttpRequest();
163 },
164 function () {
165 return new ActiveXObject("Msxml3.XMLHTTP");
166 },
167 function () {
168 return new ActiveXObject("Msxml2.XMLHTTP.6.0");
169 },
170 function () {
171 return new ActiveXObject("Msxml2.XMLHTTP.3.0");
172 },
173 function () {
174 return new ActiveXObject("Msxml2.XMLHTTP");
175 },
176 function () {
177 return new ActiveXObject("Microsoft.XMLHTTP");
178 },
179 ];
180
181 function createXMLHTTPObject() {
182 var xmlhttp = false;
183 for (var i = 0; i < XMLHttpFactories.length; i++) {
184 try {
185 xmlhttp = XMLHttpFactories[i]();
186 } catch (e) {
187 continue;
188 }
189 break;
190 }
191 return xmlhttp;
192 }
193
194 epGlobals.youtubeChannelGallery = function () {
195 var playerWraps = document.getElementsByClassName("ep-player-wrap");
196 if (playerWraps && playerWraps.length) {
197 for (var i = 0, im = playerWraps.length; im > i; i++) {
198 youtubeChannelEvents(playerWraps[i])
199 }
200 }
201 }
202
203 function youtubeChannelEvents(playerWrap) {
204
205 delegate(playerWrap, "click", ".item", function (event) {
206 var embed = "https://www.youtube.com/embed/";
207 var vid = this.getAttribute("data-vid");
208 var iframe = playerWrap.getElementsByTagName("iframe");
209 if (vid) {
210 if (iframe) {
211 var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
212 if (vidSrc.indexOf('autoplay') > 0) {
213 vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
214 }
215 else {
216 vidSrc += '&autoplay=1';
217 }
218 iframe[0].src = vidSrc;
219 playerWrap.scrollIntoView();
220 }
221 }
222 });
223
224 var currentPage = 1;
225
226 let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
227
228 let epContentBlock = playerWrap.querySelector('.ep-youtube__content__block');
229 let parentElement = epContentBlock.parentElement;
230
231 // Get the value of data-channel-url attribute from a sibling
232 let channelUrl = parentElement.querySelector('[data-channel-url]').getAttribute('data-channel-url');
233
234
235 delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
236 const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
237 const closestClass = event.target.closest('.ose-youtube').classList;
238
239 const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
240 if (activePage) {
241 document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
242 }
243
244
245
246 var isNext = this.classList.contains("ep-next");
247
248 if (isNext) {
249 currentPage++;
250 } else {
251 currentPage--;
252 }
253
254 var data = {
255 action: "youtube_rest_api",
256 playlistid: this.getAttribute("data-playlistid"),
257 pagetoken: this.getAttribute("data-pagetoken"),
258 pagesize: this.getAttribute("data-pagesize"),
259 channelUrl: channelUrl,
260 currentpage: currentPage
261 };
262
263 var formBody = [];
264 for (var property in data) {
265 var encodedKey = encodeURIComponent(property);
266 var encodedValue = encodeURIComponent(data[property]);
267 formBody.push(encodedKey + "=" + encodedValue);
268 }
269 formBody = formBody.join("&");
270
271 var galleryWrapper = playerWrap.getElementsByClassName(
272 "ep-youtube__content__block"
273 );
274
275 playerWrap.setAttribute('data-current-page', currentPage);
276
277
278 let x = 1;
279
280 sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) {
281 if (galleryWrapper && galleryWrapper[0] && request.responseText) {
282 var response = JSON.parse(request.responseText);
283 galleryWrapper[0].outerHTML = response.html;
284
285 var currentPageNode =
286 galleryWrapper[0].getElementsByClassName("current-page");
287 if (currentPageNode && currentPageNode[0]) {
288 currentPageNode[0].textContent = currentPage;
289
290 }
291 }
292 });
293
294 const intervalID = setInterval(() => {
295 x++
296
297 if (playerWrap.querySelector('.ep-youtube__content__block')) {
298 const newNearestEpContentId = playerWrap
299 .querySelector('.ep-youtube__content__block')
300 .getAttribute('data-unique-id');
301
302 if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) {
303 playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
304 nearestEpContentId = newNearestEpContentId;
305 clearInterval(intervalID);
306 }
307 }
308
309 if (x > 100) {
310 clearInterval(intervalID);
311 }
312 }, 100);
313
314 });
315 }
316
317 //Load more for OpenaSea collection
318 const epLoadMore = () => {
319
320 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
321 let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
322
323 let loadmorelabel = $(selctorEl).data('loadmorelabel');
324 let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
325
326 let spinicon = `<svg width="18" height="18" fill="${iconcolor || '#fff'}" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>`;
327
328 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
329 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
330
331 $(selctorEl + " .nft-loadmore").click(function (e) {
332 //change the text of the button
333 $(this).html(loadmorelabel + spinicon);
334 //disable the button
335 $(this).prop("disabled", true);
336 //wait for 1 seconds
337 setTimeout(function () {
338 //change the text back
339 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
340 //enable the button
341 $(selctorEl + " .nft-loadmore").prop("disabled", false);
342 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
343 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
344 $(selctorEl + " .nft-loadmore").fadeOut("slow");
345 }
346 }, 500);
347 });
348 });
349 };
350
351 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
352 epLoadMore();
353 }
354
355 // Content protection system function
356 const unlockSubmitHander = (perentSel, that) => {
357 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
358 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
359 var post_id = jQuery(`input[name="post_id"]`).val();
360 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
361 const unlokingText = jQuery(that).data('unlocking-text');
362
363
364 var data = {
365 'action': 'lock_content_form_handler',
366 'client_id': ep_client_id,
367 'password': password,
368 'post_id': post_id,
369 };
370
371 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
372
373 jQuery.post(eplocalize.ajaxurl, data, function (response) {
374 if (response.success) {
375 if (!response.embedHtml) {
376
377 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
378 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
379 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
380 }
381 else {
382 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
383
384 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
385 epGlobals.youtubeChannelGallery();
386 }
387
388 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
389 epLoadMore();
390 }
391
392 // Custom player initialization when content protection enabled
393 document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').classList.remove('plyr-initialized');
394
395 initPlayer(document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper'));
396
397 if (eplocalize.is_pro_plugin_active) {
398 const adIdEl = document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-sponsored-id]');
399 adInitialization(adIdEl, adIdEl?.getAttribute('data-ad-index'));
400 }
401
402 }
403 } else {
404 jQuery('#password-error_' + ep_client_id).html(response.form);
405 jQuery('#password-error_' + ep_client_id).show();
406 }
407 }, 'json');
408 }
409
410 // unlockSubmitHander called for gutentberg
411 jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
412 e.preventDefault(); // Prevent the default form submission
413 unlockSubmitHander('ep-gutenberg-content', this);
414 });
415
416 window.addEventListener('load', function (e) {
417 const urlParams = new URLSearchParams(window.location.search);
418 const hash = urlParams.get('hash');
419
420 // find the element with the matching id
421 const element = document.getElementById(hash);
422
423 if (element) {
424 element.scrollIntoView({ behavior: 'smooth' });
425 }
426
427 });
428
429 // Get the insta-gallery container element
430 const getPopupTemplate = (instPost, hashtag = '', accountType) => {
431
432 let instaPostData = JSON.parse(instPost);
433
434
435 let likeIcon = '<svg aria-label="Like" class="x1lliihq x1n2onr6" color="#262626" fill="#262626" height="24" viewBox="0 0 24 24" width="24"><path d="M16.792 3.904A4.989 4.989 0 0 1 21.5 9.122c0 3.072-2.652 4.959-5.197 7.222-2.512 2.243-3.865 3.469-4.303 3.752-.477-.309-2.143-1.823-4.303-3.752C5.141 14.072 2.5 12.167 2.5 9.122a4.989 4.989 0 0 1 4.708-5.218 4.21 4.21 0 0 1 3.675 1.941c.84 1.175.98 1.763 1.12 1.763s.278-.588 1.11-1.766a4.17 4.17 0 0 1 3.679-1.938m0-2a6.04 6.04 0 0 0-4.797 2.127 6.052 6.052 0 0 0-4.787-2.127A6.985 6.985 0 0 0 .5 9.122c0 3.61 2.55 5.827 5.015 7.97.283.246.569.494.853.747l1.027.918a44.998 44.998 0 0 0 3.518 3.018 2 2 0 0 0 2.174 0 45.263 45.263 0 0 0 3.626-3.115l.922-.824c.293-.26.59-.519.885-.774 2.334-2.025 4.98-4.32 4.98-7.94a6.985 6.985 0 0 0-6.708-7.218Z"/></svg>';
436
437 if (instaPostData.like_count > 0) {
438 likeIcon = '<svg aria-label="Unlike" class="x1lliihq x1n2onr6" color="#FF3040" fill="#FF3040" height="24" viewBox="0 0 48 48" width="24"><path d="M34.6 3.1c-4.5 0-7.9 1.8-10.6 5.6-2.7-3.7-6.1-5.5-10.6-5.5C6 3.1 0 9.6 0 17.6c0 7.3 5.4 12 10.6 16.5.6.5 1.3 1.1 1.9 1.7l2.3 2c4.4 3.9 6.6 5.9 7.6 6.5.5.3 1.1.5 1.6.5s1.1-.2 1.6-.5c1-.6 2.8-2.2 7.8-6.8l2-1.8c.7-.6 1.3-1.2 2-1.7C42.7 29.6 48 25 48 17.6c0-8-6-14.5-13.4-14.5z"/></svg>';
439 }
440
441 const commentsIcon = '<svg aria-label="Comment" class="x1lliihq x1n2onr6" color="#000" height="24" viewBox="0 0 24 24" width="24"><path d="M20.656 17.008a9.993 9.993 0 1 0-3.59 3.615L22 22Z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="2"/></svg>';
442
443 const shareIcon = '<svg width="20" height="20" viewBox="0 0 0.6 0.6" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg"><path stroke-width="1" d="m.543.282-.2-.2A.025.025 0 0 0 .3.1v.089a.275.275 0 0 0-.25.274V.5a.025.025 0 0 0 .045.015.3.3 0 0 1 .197-.101L.3.413V.5a.025.025 0 0 0 .043.018l.2-.2a.025.025 0 0 0 0-.035M.35.44V.388A.025.025 0 0 0 .325.363L.286.365a.35.35 0 0 0-.185.074.225.225 0 0 1 .224-.201A.025.025 0 0 0 .35.213V.16L.49.3Z"/></svg>';
444
445 const instaIcon = '<svg width="18" height="18" viewBox="0 0 0.338 0.338" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.248.079H.27M.102.012h.135a.09.09 0 0 1 .09.09v.135a.09.09 0 0 1-.09.09H.102a.09.09 0 0 1-.09-.09V.102a.09.09 0 0 1 .09-.09ZM.17.237a.068.068 0 1 1 0-.135.068.068 0 0 1 0 .135Z" stroke="#000" stroke-width=".032"/></svg>';
446
447
448
449 const instaUserInfo = instPost.user_info;
450
451 let getDate = new Date(instaPostData.timestamp);
452 getDate = getDate.toLocaleString('en-US', { day: 'numeric', month: 'short', year: 'numeric' });
453
454 let getTime = new Date(instaPostData.timestamp);
455 getTime = getTime.toLocaleString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
456
457 let captionText = instaPostData.caption ? instaPostData.caption : '';
458 const tagRegex = /(#\w+)/g;
459
460 const wrapTag = (match) => {
461 const tag = match.substring(1); // Remove the '#' character
462 const tagUrl = `https://www.instagram.com/explore/tags/${tag}`;
463 return `<span class="tag-wrapper"><a target="_blank" href="${tagUrl}">${match}</a></span>`;
464 };
465
466 captionText = captionText.replace(tagRegex, wrapTag);
467
468 let carouselTemplate = '';
469 if (instaPostData.media_type === 'CAROUSEL_ALBUM') {
470 carouselTemplate += `<div class="popup-carousel"><div class="cg-carousel__track js-carousel__track">`;
471
472 instaPostData.children.data?.map((item) => {
473 if (item.media_type?.toLowerCase() === 'video') {
474 carouselTemplate += `<video width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" controls src="${item.media_url || ''}" alt="${item.caption || ''}" controlsList="nodownload"></video>`;
475 }
476 else {
477 carouselTemplate += `<img width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" src="${item.media_url || ''}" alt="${item.caption || ''}" />`;
478 }
479 });
480
481 carouselTemplate += `</div></div>`;
482
483 carouselTemplate += `<div class="cg-carousel__btns">
484 <button class="cg-carousel__btn js-carousel__prev-1"><svg width="20" height="30" viewBox="-5 0 23 23" xmlns="http://www.w3.org/2000/svg"><path d="M11.24.29.361 10.742l-.06.054a.97.97 0 0 0-.301.642v.124a.97.97 0 0 0 .3.642l.054.044L11.239 22.71a1.061 1.061 0 0 0 1.459 0 .964.964 0 0 0 0-1.402l-10.15-9.746 10.15-9.87a.964.964 0 0 0 0-1.402 1.061 1.061 0 0 0-1.459 0Z" fill="#fff"/></svg></button>
485
486 <button class="cg-carousel__btn js-carousel__next-1"><svg width="20" height="30" viewBox="-5 0 23 23" xmlns="http://www.w3.org/2000/svg"><path d="m1.76.29 10.879 10.452.06.054a.97.97 0 0 1 .301.642v.124a.97.97 0 0 1-.3.642l-.054.044L1.761 22.71a1.061 1.061 0 0 1-1.459 0 .964.964 0 0 1 0-1.402l10.15-9.746-10.15-9.87a.964.964 0 0 1 0-1.402 1.061 1.061 0 0 1 1.459 0Z" fill="#fff"/></svg></button>
487 </div>`
488 }
489 else {
490 if (instaPostData.media_type?.toLowerCase() === 'video') {
491 carouselTemplate += `<video width="630" class="popup-media-image" controls src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}"></video>`;
492 }
493 else {
494 carouselTemplate += `<img width="630" class="popup-media-image" src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}" />`;
495 }
496 }
497
498 let srcUrl = `https://www.instagram.com/${instaPostData.username}/`;
499
500 if (hashtag) {
501 instaPostData.username = '#' + hashtag;
502 srcUrl = `https://www.instagram.com/explore/tags/${hashtag}/`;
503 }
504
505
506 let likeComments = '';
507
508 if (eplocalize.is_pro_plugin_active && accountType === 'business') {
509 if (instaPostData.show_likes_count == 'true') {
510 likeComments += `
511 <div class="embedpress-inline popup-like-button"><a target="_blank" href="${instaPostData.permalink}">${likeIcon} ${instaPostData.like_count || 0}</a></div>
512 `;
513 }
514 if (instaPostData.show_comments_count == 'true') {
515 likeComments += `
516 <div class="embedpress-inline"><a target="_blank" href="${instaPostData.permalink}">${commentsIcon} ${instaPostData.comments_count || 0}</a></div>
517 `;
518 }
519 }
520
521
522 let followBtn = '';
523 if (instaPostData.popup_follow_button_text == 'false') {
524 instaPostData.popup_follow_button_text = '';
525 }
526 if (instaPostData.popup_follow_button == 'true' || instaPostData.popup_follow_button == 'yes') {
527 followBtn = `<div class="insta-followbtn">
528 <a target="_new" href="${srcUrl}" type="button" class="btn btn-primary">${instaPostData.popup_follow_button_text}</a>
529 </div>`;
530 }
531
532 let popupHtml = '';
533 popupHtml += `
534 <div class="popup-container">
535 <div class="popup-md-9 white">
536 <div class="embedpress-popup-block embedpress-popup-img" id="post-${instaPostData.id}">
537 ${carouselTemplate}
538 </div>
539 </div>
540 <div class="popup-md-3 red">
541 <div class="embedpress-popup-block embedpress-popup-info">
542 <div class="embedpress-popup-header">
543 <div class="embedpress-popup-header-img"> <a target="_blank" href="${srcUrl}"
544 target="_blank" class="embedpress-href">
545 <img decoding="async" loading="lazy" class="embedpress-popup-round" src="${instaPostData.profile_picture_url}" width="30" height="30"> <span class="embedpress-popup-username">${instaPostData.username}</span>
546 </a>
547 </div>
548 ${followBtn}
549 </div>
550 <div class="embedpress-popup-text">${captionText}</div>
551 <div class="embedpress-popup-stats">
552 ${likeComments}
553 <div class="embedpress-inline">
554 <div class="embedpress-popup-share-buttons"> <a
555 href="https://www.facebook.com/sharer/sharer.php?u=${instaPostData.permalink}" target="_blank">
556 <span class="dashicons dashicons-facebook"></span></a> <a
557 href="https://twitter.com/intent/tweet?url=${instaPostData.permalink}"
558 target="_blank"><span>
559 <svg viewBox="0 0 18 18" aria-hidden="true" class="r-4qtqp9 r-yyyyoo r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-lrsllp r-18jsvk2 r-16y2uox r-8kz0gk" width="18" height="18"><path d="M13.683 1.688h2.481l-5.42 6.195 6.377 8.43h-4.993L8.217 11.2l-4.474 5.113H1.26l5.798-6.626L.941 1.688H6.06l3.535 4.673zm-.871 13.14h1.375L5.313 3.095H3.838z"/></svg>
560 </span></a>
561 <a href="https://www.linkedin.com/shareArticle?mini=true&amp;url=${instaPostData.permalink}"
562 target="_blank"><span class="dashicons dashicons-linkedin"></span></a> <a
563 href="https://pinterest.com/pin/create/button/?url=${instaPostData.permalink}"
564 target="_blank"><span class="dashicons dashicons-pinterest"></span></a></div>
565 <div class="embedpress-href embedpress-popup-share">${shareIcon}</div>
566 </div><div class="embedpress-inline embedpress-popup-instagram-buttons"><a
567 href="${instaPostData.permalink}" target="_blank"
568 class="embedpress-href">${instaIcon}</a></div>
569 </div>
570
571 </div>
572 </div>
573 </div>
574 `;
575
576 // INIT CAROUSEL
577
578
579 return popupHtml;
580 }
581
582 // Add a click event listener to the insta-gallery container
583 epGlobals.instaPopup = (container) => {
584 container?.addEventListener('click', function (event) {
585 // Check if the clicked element has the class insta-gallery-item
586 const instaItem = event.target.closest('.insta-gallery-item');
587
588 if (instaItem) {
589
590 const postData = instaItem.dataset.postdata;
591
592 const postid = instaItem.getAttribute('data-insta-postid');
593 const accountType = container?.closest('.instagram-container')?.getAttribute('data-connected-acc-type');
594
595 let hashtag = '';
596
597 if (instaItem.closest('.instagram-container').getAttribute('data-hashtag')) {
598 hashtag = instaItem?.closest('.instagram-container')?.getAttribute('data-hashtag');
599 }
600
601 const closestPopup = event.target.closest('.ose-instagram-feed')?.querySelector('.insta-popup');
602
603 if (closestPopup) {
604 closestPopup.style.display = 'block';
605 }
606
607
608 var feedElement = event.target.closest('.ose-instagram-feed');
609 if (feedElement) {
610 var popupElement = feedElement.querySelector('.popup-is-initialized');
611 if (popupElement) {
612 popupElement.innerHTML = getPopupTemplate(postData, hashtag, accountType);
613 }
614 }
615
616 if (!document.querySelector(`#post-${postid}`)?.classList.contains('carousel-is-initialized')) {
617 const carousel = new CgCarousel(`#post-${postid}`, { slidesPerView: 1, loop: true }, {});
618
619 const next = document.querySelector(`#post-${postid} .js-carousel__next-1`);
620 next?.addEventListener('click', () => carousel.next());
621
622 const prev = document.querySelector(`#post-${postid} .js-carousel__prev-1`);
623 prev?.addEventListener('click', () => carousel.prev());
624
625 document.querySelector(`#post-${postid}`)?.classList.add('carousel-is-initialized');
626 }
627
628 }
629 });
630 }
631
632
633 const instaContainers = document.querySelectorAll('.embedpress-gutenberg-wrapper .insta-gallery');
634 if (instaContainers.length > 0) {
635 instaContainers.forEach((container) => {
636 epGlobals.instaPopup(container);
637 });
638 }
639
640 $('.popup-close').click(function (e) {
641 // Hide the popup by setting display to none
642 $('.insta-popup').hide();
643 $('.popup-container').remove();
644 });
645
646 $(document).on('click', function (e) {
647 if (e.target.classList.contains('popup-wrapper')) {
648 $('.insta-popup').hide();
649 $('.popup-container').remove();
650 }
651 });
652
653
654 const instafeeds = document.querySelectorAll('.ose-instagram-feed');
655
656 epGlobals.initializeTabs = (containerEl) => {
657
658 // Initial tab selection
659 showItems('ALL');
660
661 containerEl.addEventListener('click', function (event) {
662 const clickedElement = event.target;
663 if (!clickedElement) {
664 return; // No element clicked, ignore the event
665 }
666
667 if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'VIDEO' || clickedElement.getAttribute('data-media-type') === 'CAROUSEL_ALBUM')) {
668 containerEl.querySelector('.load-more-button-container').style.display = 'none';
669 }
670 else if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'ALL')) {
671 containerEl.querySelector('.load-more-button-container').style.display = 'flex';
672 }
673
674 // Handle tab click
675 if (clickedElement.matches('.tabs li')) {
676 if (clickedElement.classList.contains('active')) {
677 return;
678 } else {
679 const mediaType = clickedElement.getAttribute('data-media-type');
680 showItems(mediaType);
681
682 const tabs = containerEl.querySelectorAll('.tabs li');
683 tabs.forEach(t => t.classList.remove('active'));
684 clickedElement.classList.add('active');
685 }
686 }
687
688 });
689
690 function showItems(mediaType) {
691 const items = containerEl.getElementsByClassName('insta-gallery-item');
692 for (let i = 0; i < items.length; i++) {
693 const item = items[i];
694 if (mediaType === 'ALL' || item.getAttribute('data-media-type') === mediaType) {
695 item.style.display = 'block';
696 } else {
697 item.style.display = 'none';
698 }
699 }
700 }
701 }
702
703 epGlobals.instaLoadMore = () => {
704 // Unbind any previously bound click event to avoid multiple bindings
705 $('.insta-load-more-button').off('click').on('click', function (e) {
706 const that = $(this);
707 const loadmoreBtn = that.closest('.load-more-button-container');
708 const loadmoreKey = loadmoreBtn.data('loadmorekey');
709 const connectedAccount = that.closest('.instagram-container').data('connected-acc-type');
710 const feedType = that.closest('.instagram-container').data('feed-type');
711 const hashtagId = that.closest('.instagram-container').data('hashtag-id');
712 const userId = that.closest('.instagram-container').data('uid');
713 let loadedPosts = loadmoreBtn.data('loaded-posts') || 0;
714 let postsPerPage = loadmoreBtn.data('posts-per-page') || 0;
715 const params = JSON.stringify(that.closest('.instagram-container').data('params'));
716
717
718 const instaContainer = that.closest('.instagram-container');
719
720 const spinicon = `<svg class="insta-loadmore-spinicon" width="18" height="18" fill="${'#fff'}" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>`;
721
722 // Check if no spinicon exists
723 if (instaContainer.find('.insta-loadmore-spinicon').length === 0) {
724 that.append(spinicon);
725 }
726
727 that.attr('disabled', true);
728
729 var data = {
730 'action': 'loadmore_data_handler',
731 'user_id': userId,
732 'loaded_posts': loadedPosts,
733 'posts_per_page': postsPerPage,
734 'feed_type': feedType,
735 'connected_account_type': connectedAccount,
736 'loadmore_key': loadmoreKey,
737 'params': params,
738 '_nonce': eplocalize.nonce
739 };
740
741 if (feedType === 'hashtag_type') {
742 data.hashtag_id = hashtagId;
743 }
744
745 jQuery.post(eplocalize.ajaxurl, data, function (response) {
746 if (response.total_feed_posts >= response.next_post_index) {
747 var $responseHtml = $(response.html);
748
749 instaContainer.find('.insta-gallery').append($responseHtml);
750 that.removeAttr('disabled');
751
752 instaContainer.find('.insta-loadmore-spinicon').remove();
753
754 loadedPosts = response.next_post_index;
755
756 loadmoreBtn.data('loaded-posts', loadedPosts);
757
758 // After loading more items, reinitialize the tabs for the specific container
759 const containerEl = loadmoreBtn.closest('.ose-instagram-feed')[0];
760 epGlobals.initializeTabs(containerEl);
761
762 if (response.total_feed_posts === response.next_post_index) {
763 loadmoreBtn.remove();
764 }
765 } else {
766 loadmoreBtn.remove();
767 }
768 });
769 });
770 }
771
772
773 if (instafeeds.length > 0) {
774 instafeeds.forEach(function (feed) {
775 epGlobals.initializeTabs(feed);
776 });
777 }
778
779 if ($('.embedpress-gutenberg-wrapper .ose-instagram-feed').length > 0) {
780 epGlobals.instaLoadMore();
781 }
782
783 $(document).on({
784 mouseenter: function () {
785 $('.embedpress-popup-share-buttons').addClass('show');
786 },
787 mouseleave: function () {
788 var buttons = $('.embedpress-popup-share-buttons');
789 setTimeout(function () {
790 if (!buttons.is(':hover')) buttons.removeClass('show');
791 }, 200);
792 }
793 }, '.embedpress-href.embedpress-popup-share, .embedpress-popup-share-buttons');
794
795 $(document).on({
796 mouseenter: function () {
797 $(this).addClass('show');
798 },
799 mouseleave: function () {
800 $(this).removeClass('show');
801 }
802 }, '.embedpress-popup-share-buttons');
803
804
805
806
807
808 })(jQuery);
809
810
811
812 document.addEventListener('DOMContentLoaded', function () {
813
814 epGlobals.initCarousel = (carouselSelector, options, carouselId) => {
815
816 const carouselOptions = {
817 slidesPerView: options.slideshow,
818 spacing: options.spacing,
819 loop: options.loop,
820 autoplay: options.autoplay,
821 transitionSpeed: options.transitionspeed,
822 autoplaySpeed: options.autoplayspeed,
823 arrows: options.arrows,
824 breakpoints: {
825 768: {
826 slidesPerView: parseInt(options.slideshow) - 1
827 },
828 1024: {
829 slidesPerView: parseInt(options.slideshow)
830 }
831 }
832 };
833
834 // INIT CAROUSEL
835 const carousel = new CgCarousel(carouselSelector, carouselOptions, {});
836
837 // Navigation
838 const next = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__next-1`);
839 next?.addEventListener('click', () => carousel.next());
840
841 const prev = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__prev-1`);
842 prev?.addEventListener('click', () => carousel.prev());
843 }
844
845 const instaWrappers = document.querySelectorAll('.ep-embed-content-wraper');
846
847 if (instaWrappers.length > 0) {
848 instaWrappers.forEach((wrapper) => {
849 const carouselId = wrapper.getAttribute('data-carouselid');
850
851 if (!carouselId) return;
852
853 let options = wrapper.getAttribute(`data-carousel-options`);
854
855 options = JSON.parse(options);
856 const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`;
857
858 if (options.arrows) {
859 document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
860 }
861
862 epGlobals.initCarousel(carouselSelector, options, carouselId);
863
864 });
865 }
866
867 // Youtube Channel Carousel
868
869 const youtubeCarouselWraper = document.querySelectorAll('[data-youtube-channel-carousel]');
870
871 if (youtubeCarouselWraper.length > 0) {
872 youtubeCarouselWraper.forEach((wrapper) => {
873 const carouselId = wrapper.getAttribute('data-youtube-channel-carousel');
874 if (!carouselId) return;
875
876 // let options = wrapper.getAttribute(`data-carousel-options`);
877
878 // options = JSON.parse(options);
879
880 const carouselSelector = `[data-youtube-channel-carousel="${carouselId}"] .youtube__content__body`;
881
882 // if (options.arrows) {
883 // document.querySelector(`[data-youtube-channel-carousel="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
884 // }
885
886 const options = {
887 slidesPerView: 2,
888 autoplay: true,
889 loop: true,
890 breakpoints: {
891 768: {
892 slidesPerView: 2
893 },
894 1024: {
895 slidesPerView: 4
896 }
897 }
898 }
899
900 // epGlobals.initCarousel(carouselSelector, options, {});
901
902 });
903 }
904
905
906
907 });
908
909 document.addEventListener('DOMContentLoaded', () => {
910 const carousel = document.querySelector('.youtube-carousel');
911
912 if (!carousel) {
913 return;
914 }
915
916 const items = document.querySelectorAll('.item');
917 const prevButton = document.querySelector('.preview');
918 const nextButton = document.querySelector('.next');
919
920 let itemsToShow = getItemsToShow(); // Determine items to show based on screen width
921
922 const totalItems = items.length;
923 let currentIndex = 0;
924
925 function updateCarousel() {
926 const offset = -currentIndex * (100 / itemsToShow);
927 carousel.style.transform = `translateX(${offset}%)`;
928 }
929
930 function nextSlide() {
931 const remainingItems = totalItems - (currentIndex + itemsToShow);
932 if (remainingItems >= itemsToShow) {
933 currentIndex += itemsToShow;
934 } else if (remainingItems > 0) {
935 currentIndex += remainingItems;
936 } else {
937 currentIndex = 0;
938 }
939 updateCarousel();
940 }
941
942 function prevSlide() {
943 if (currentIndex > 0) {
944 currentIndex -= itemsToShow;
945 if (currentIndex < 0) {
946 currentIndex = 0;
947 }
948 } else {
949 currentIndex = totalItems - itemsToShow;
950 }
951 updateCarousel();
952 }
953
954 nextButton?.addEventListener('click', nextSlide);
955 prevButton?.addEventListener('click', prevSlide);
956
957 // Optional: Autoplay
958 let autoplay = false;
959 const autoplayInterval = 3000; // Change the time as needed
960 let autoplayId;
961
962 function startAutoplay() {
963 autoplayId = setInterval(nextSlide, autoplayInterval);
964 }
965
966 function stopAutoplay() {
967 clearInterval(autoplayId);
968 }
969
970 if (autoplay) {
971 startAutoplay();
972
973 // Stop autoplay on mouseover, resume on mouseout
974 carousel.addEventListener('mouseover', stopAutoplay);
975 carousel.addEventListener('mouseout', startAutoplay);
976 }
977
978 // Handle responsive behavior
979 window.addEventListener('resize', () => {
980 itemsToShow = getItemsToShow();
981 updateCarousel();
982
983 });
984
985 function getItemsToShow() {
986 const width = window.innerWidth;
987 if (width >= 1024) {
988 return 3;
989 } else if (width >= 768) {
990 return 2;
991 } else {
992 return 1;
993 }
994 }
995 });
996
997
998
999
1000 jQuery(window).on("elementor/frontend/init", function () {
1001
1002 var filterableGalleryHandler = function ($scope, $) {
1003
1004 // Get the Elementor unique selector for this widget
1005 let classes = $scope[0].className;
1006 let selectorEl = '.' + classes.split(' ').join('.');
1007
1008 const epElLoadMore = () => {
1009
1010 const spinicon = '<svg width="18" height="18" fill="#fff" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>';
1011
1012 $('.elementor-widget-container .ep-nft-gallery-wrapper').each(function () {
1013 let selctorEl = `.elementor-widget-container [data-nftid='${$(this).data('nftid')}']`;
1014 let loadmorelabel = $(selctorEl).data('loadmorelabel');
1015 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
1016 $('.elementor-widget-container .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
1017
1018 $(selctorEl + " .nft-loadmore").click(function (e) {
1019 //change the text of the button
1020 $(this).html(loadmorelabel + spinicon);
1021
1022 //disable the button
1023 $(this).prop("disabled", true);
1024 //wait for 1 seconds
1025 setTimeout(function () {
1026 //change the text back
1027 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
1028 //enable the button
1029 $(selctorEl + " .nft-loadmore").prop("disabled", false);
1030 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
1031 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
1032 $(selctorEl + " .nft-loadmore").fadeOut("slow");
1033 }
1034 }, 500);
1035 });
1036 });
1037 };
1038
1039 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
1040 epElLoadMore();
1041 }
1042
1043 // Content protection system function
1044 const unlockElSubmitHander = (perentSel, that) => {
1045 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
1046 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
1047 var post_id = jQuery(`input[name="post_id"]`).val();
1048 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
1049 const unlokingText = jQuery(that).data('unlocking-text');
1050
1051 var data = {
1052 'action': 'lock_content_form_handler',
1053 'client_id': ep_client_id,
1054 'password': password,
1055 'post_id': post_id,
1056 };
1057
1058 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
1059
1060 jQuery.post(eplocalize.ajaxurl, data, function (response) {
1061 if (response.success) {
1062 if (!response.embedHtml) {
1063 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
1064 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
1065 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
1066 }
1067 else {
1068 if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
1069 $('.ep-content-locked').removeClass('ep-content-locked');
1070 }
1071
1072 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
1073
1074 $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
1075
1076 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
1077 epGlobals.youtubeChannelGallery();
1078 }
1079
1080 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
1081 epElLoadMore();
1082 }
1083 }
1084 } else {
1085 jQuery('#password-error_' + ep_client_id).html(response.form);
1086 jQuery('#password-error_' + ep_client_id).show();
1087 }
1088 }, 'json');
1089 }
1090
1091 // unlockElSubmitHander called for Elementor
1092 jQuery('.ep-elementor-content .password-form').submit(function (e) {
1093 e.preventDefault(); // Prevent the default form submission
1094 unlockElSubmitHander('ep-elementor-content', this);
1095 });
1096
1097
1098 const instaWrappers = document.querySelectorAll('.ep-embed-content-wrapper');
1099
1100 if (instaWrappers.length > 0) {
1101
1102 instaWrappers.forEach((wrapper) => {
1103 wrapper.classList.add('class-content-wrapper');
1104 const carouselId = wrapper.getAttribute('data-carouselid');
1105
1106 if (!carouselId) return;
1107
1108 let options = wrapper.getAttribute(`data-carousel-options`);
1109
1110 options = JSON.parse(options);
1111 const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`;
1112
1113
1114 if (options.arrows) {
1115 document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
1116 }
1117
1118 epGlobals.initCarousel(carouselSelector, options, carouselId);
1119
1120 });
1121 }
1122
1123
1124 const instaFeed = document.querySelector(`${selectorEl} .ose-instagram-feed`);
1125 const instaGallery = document.querySelector(`${selectorEl} .insta-gallery`);
1126 if (instaFeed) {
1127 epGlobals.initializeTabs(instaFeed);
1128 }
1129 if (instaGallery) {
1130 epGlobals.instaPopup(instaGallery);
1131
1132 $('.popup-close').click(function (e) {
1133 // Hide the popup by setting display to none
1134 $('.insta-popup').hide();
1135 $('.popup-container').remove();
1136 });
1137
1138 }
1139
1140 if ($('.elementor-widget-container .ose-instagram-feed').length > 0) {
1141 epGlobals.instaLoadMore();
1142 }
1143
1144 };
1145
1146 const adsHandler = function ($scope, $) {
1147 window.epAdIndex = typeof (window.epAdIndex) === 'undefined' ? 0 : window.epAdIndex + 1;
1148 let classes = $scope[0].className;
1149 let classJoint = '.' + classes.split(' ').join('.');
1150 const selectorEl = document.querySelector(classJoint + ' [data-sponsored-id]');
1151
1152 if (jQuery('body').hasClass('elementor-editor-active') && eplocalize.is_pro_plugin_active) {
1153 adInitialization(selectorEl, window.epAdIndex);
1154 }
1155
1156 }
1157
1158 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
1159 elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
1160 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
1161 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", adsHandler);
1162 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", epGlobals.handlePosterImageLoad);
1163 });
1164
1165
1166 function presentationModeForIOS(iframes) {
1167 iframes?.forEach(function (iframe) {
1168 iframe.onload = function () {
1169 var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
1170 var button = iframeDoc?.querySelector('#presentationMode.presentationMode');
1171 button?.addEventListener('click', function () {
1172 iframe.classList.toggle('presentationModeEnabledIosDevice');
1173 });
1174 iframeDoc?.addEventListener('keydown', function (event) {
1175 if (event.keyCode === 27) {
1176 iframe.classList.remove('presentationModeEnabledIosDevice');
1177 }
1178 });
1179 };
1180 });
1181 }
1182
1183 function isIOSDevice() {
1184 return /iPhone|iPad|iPod/i.test(navigator.userAgent);
1185 }
1186
1187 if (isIOSDevice()) {
1188 var iframes = document.querySelectorAll('.embedpress-embed-document-pdf');
1189 presentationModeForIOS(iframes)
1190 }
1191
1192 document.addEventListener("DOMContentLoaded", epGlobals.handlePosterImageLoad);
1193
1194
1195
1196 // document.addEventListener('DOMContentLoaded', function () {
1197 // const videoPopup = document.getElementById('videoPopup');
1198 // const videoIframe = document.getElementById('videoIframe');
1199 // const videoDescription = document.getElementById('videoDescription');
1200 // const closeBtn = document.querySelector('.close');
1201 // const nextBtn = document.getElementById('nextVideo');
1202 // const prevBtn = document.getElementById('prevVideo');
1203
1204 // let currentIndex = -1;
1205
1206 // function openVideoPopup(index) {
1207 // const items = document.querySelectorAll('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1208 // if (index >= 0 && index < items.length) {
1209 // currentIndex = index;
1210 // const videoId = items[currentIndex].getAttribute('data-vid');
1211 // const description = items[currentIndex].querySelector('.video-description').innerHTML;
1212
1213 // if (videoId) {
1214 // videoIframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1`;
1215 // videoDescription.innerHTML = description;
1216 // videoPopup.style.display = 'block';
1217
1218 // // Update navigation buttons visibility
1219 // updateNavigationButtons();
1220 // }
1221 // }
1222 // }
1223
1224 // function closeVideoPopup() {
1225 // videoPopup.style.display = 'none';
1226 // videoIframe.src = '';
1227 // videoDescription.innerHTML = '';
1228 // }
1229
1230 // function updateNavigationButtons() {
1231 // const items = document.querySelectorAll('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1232 // if (currentIndex <= 0) {
1233 // prevBtn.style.display = 'none';
1234 // } else {
1235 // prevBtn.style.display = 'block';
1236 // }
1237
1238 // if (currentIndex >= items.length - 1) {
1239 // nextBtn.style.display = 'none';
1240 // } else {
1241 // nextBtn.style.display = 'block';
1242 // }
1243 // }
1244
1245 // document.addEventListener('click', function (event) {
1246 // const items = document.querySelectorAll('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1247 // const item = event.target.closest('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1248 // if (item) {
1249 // const index = Array.prototype.indexOf.call(items, item);
1250 // openVideoPopup(index);
1251 // }
1252 // });
1253
1254 // closeBtn.addEventListener('click', closeVideoPopup);
1255
1256 // window.addEventListener('click', function (event) {
1257 // if (event.target === videoPopup) {
1258 // closeVideoPopup();
1259 // }
1260 // });
1261
1262 // nextBtn.addEventListener('click', function () {
1263 // const items = document.querySelectorAll('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1264 // if (currentIndex >= 0 && currentIndex < items.length - 1) {
1265 // openVideoPopup(currentIndex + 1);
1266 // }
1267 // });
1268
1269 // prevBtn.addEventListener('click', function () {
1270 // if (currentIndex > 0) {
1271 // openVideoPopup(currentIndex - 1);
1272 // }
1273 // });
1274 // });
1275
1276
1277 jQuery(document).ready(function ($) {
1278
1279 let currentIndex = -1;
1280
1281 function createVideoPopup() {
1282 const videoPopupHtml = `
1283 <div id="videoPopup" class="video-popup">
1284 <div class="video-popup-content">
1285 <span class="close">&times;</span>
1286 <div class="video-popup-inner-content">
1287 <iframe id="videoIframe" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
1288 <div id="videoDescription"></div>
1289 </div>
1290 <div class="popup-controls">
1291 <span id="prevVideo" class="nav-icon prev-icon">&#10094;</span>
1292 <span id="nextVideo" class="nav-icon next-icon">&#10095;</span>
1293 </div>
1294 </div>
1295 </div>`;
1296 return $(videoPopupHtml).appendTo('body');
1297 }
1298
1299 function openVideoPopup(index) {
1300 const items = $('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1301 if (index >= 0 && index < items.length) {
1302 // Remove any existing video popup before creating a new one
1303 $('#videoPopup').remove();
1304
1305 currentIndex = index;
1306 const videoId = $(items[currentIndex]).data('vid');
1307 const videoPopup = createVideoPopup();
1308 const videoIframe = videoPopup.find('#videoIframe');
1309 const videoDescriptionContainer = videoPopup.find('#videoDescription');
1310 const closeBtn = videoPopup.find('.close');
1311 const nextBtn = videoPopup.find('#nextVideo');
1312 const prevBtn = videoPopup.find('#prevVideo');
1313
1314 if (videoId) {
1315 fetchVideoData(videoId, videoIframe, videoDescriptionContainer);
1316 videoPopup.show();
1317 updateNavigationButtons(nextBtn, prevBtn, items);
1318
1319 closeBtn.on('click', () => {
1320 closeVideoPopup(videoPopup);
1321 });
1322
1323 $(window).on('click', function (event) {
1324 if ($(event.target).is(videoPopup)) {
1325 closeVideoPopup(videoPopup);
1326 }
1327 });
1328
1329 nextBtn.on('click', function () {
1330 if (currentIndex >= 0 && currentIndex < items.length - 1) {
1331 openVideoPopup(currentIndex + 1);
1332 }
1333 });
1334
1335 prevBtn.on('click', function () {
1336 if (currentIndex > 0) {
1337 openVideoPopup(currentIndex - 1);
1338 }
1339 });
1340 }
1341 }
1342 }
1343
1344
1345 function closeVideoPopup(videoPopup) {
1346 videoPopup.remove();
1347 currentIndex = -1; // Reset the index
1348 }
1349
1350 function updateNavigationButtons(nextBtn, prevBtn, items) {
1351 prevBtn.toggle(currentIndex > 0);
1352 nextBtn.toggle(currentIndex < items.length - 1);
1353 }
1354
1355 function fetchVideoData(videoId, videoIframe, videoDescriptionContainer) {
1356 const data = {
1357 action: 'fetch_video_description',
1358 vid: videoId
1359 };
1360
1361 $.post(eplocalize.ajaxurl, data, function (response) {
1362 if (response.success) {
1363 videoIframe.attr('src', `https://www.youtube.com/embed/${videoId}?autoplay=1`);
1364 videoDescriptionContainer.html(response.data.description);
1365 } else {
1366 console.error('Error fetching video data:', response?.data?.error);
1367 }
1368 });
1369 }
1370
1371 $(document).on('click', '.layout-grid .item, .layout-list .item, .layout-carousel .item', function () {
1372 const items = $('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1373 const index = items.index(this);
1374 openVideoPopup(index);
1375 });
1376 });
1377
1378
1379
1380 // pause audio/video
1381
1382 jQuery(document).ready(function () {
1383 const players = jQuery('.enabled-auto-pause audio, .enabled-auto-pause video');
1384
1385 function pauseAllExcept(currentPlayer) {
1386 players.each(function () {
1387 if (this !== currentPlayer[0]) {
1388 this.pause();
1389 }
1390 });
1391 }
1392
1393 players.on('play', function () {
1394 pauseAllExcept(jQuery(this));
1395 });
1396 });
1397