PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.4.8
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.4.8
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
chunks 6 months ago vendor 8 months ago admin.build.js 7 months ago admin.js 9 months ago analytics-tracker.js 9 months ago analytics.build.js 6 months ago blocks.build.js 6 months ago carousel.js 1 year ago documents-viewer-script.js 3 years ago feature-notices.js 7 months ago front.js 6 months ago frontend.build.js 9 months ago gallery-justify.js 9 months ago gutneberg-script.js 1 year ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 8 months ago instafeed.js 7 months ago lazy-load.js 6 months ago license.js 7 months ago meetup-timezone.js 6 months ago preview.js 8 months ago settings.js 6 months ago sponsored.js 9 months ago
front.js
1493 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 // Run on initial load.
93 embedPressResponsiveEmbeds();
94
95 // Run on resize.
96 window.onresize = embedPressResponsiveEmbeds;
97
98
99 function hasClass(ele, cls) {
100 return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
101 }
102
103 function addClass(ele, cls) {
104 if (!hasClass(ele, cls)) ele.className += " " + cls;
105 }
106
107 function removeClass(ele, cls) {
108 if (hasClass(ele, cls)) {
109 var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
110 ele.className = ele.className.replace(reg, " ");
111 }
112 }
113 if (!Element.prototype.matches) {
114 Element.prototype.matches =
115 Element.prototype.matchesSelector ||
116 Element.prototype.webkitMatchesSelector ||
117 Element.prototype.mozMatchesSelector ||
118 Element.prototype.msMatchesSelector ||
119 Element.prototype.oMatchesSelector ||
120 function (s) {
121 var matches = (this.document || this.ownerDocument).querySelectorAll(s),
122 i = matches.length;
123 while (--i >= 0 && matches.item(i) !== this) { }
124 return i > -1;
125 };
126 }
127 var delegate = function (el, evt, sel, handler) {
128 el.addEventListener(evt, function (event) {
129 var t = event.target;
130 while (t && t !== this) {
131 if (t.matches(sel)) {
132 handler.call(t, event);
133 }
134 t = t.parentNode;
135 }
136 });
137 };
138
139 function sendRequest(url, postData, callback) {
140 var req = createXMLHTTPObject();
141 if (!req) return;
142 var method = postData ? "POST" : "GET";
143 req.open(method, url, true);
144 if (postData) {
145 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
146 }
147 req.onreadystatechange = function () {
148 if (req.readyState != 4) return;
149 if (req.status != 200 && req.status != 304) {
150 return;
151 }
152 callback(req);
153 };
154 if (req.readyState == 4) return;
155 req.send(postData);
156 }
157
158 var XMLHttpFactories = [
159 function () {
160 return new XMLHttpRequest();
161 },
162 function () {
163 return new ActiveXObject("Msxml3.XMLHTTP");
164 },
165 function () {
166 return new ActiveXObject("Msxml2.XMLHTTP.6.0");
167 },
168 function () {
169 return new ActiveXObject("Msxml2.XMLHTTP.3.0");
170 },
171 function () {
172 return new ActiveXObject("Msxml2.XMLHTTP");
173 },
174 function () {
175 return new ActiveXObject("Microsoft.XMLHTTP");
176 },
177 ];
178
179 function createXMLHTTPObject() {
180 var xmlhttp = false;
181 for (var i = 0; i < XMLHttpFactories.length; i++) {
182 try {
183 xmlhttp = XMLHttpFactories[i]();
184 } catch (e) {
185 continue;
186 }
187 break;
188 }
189 return xmlhttp;
190 }
191
192 epGlobals.youtubeChannelGallery = function () {
193 var playerWraps = document.getElementsByClassName("ep-player-wrap");
194 if (playerWraps && playerWraps.length) {
195 for (var i = 0, im = playerWraps.length; im > i; i++) {
196 youtubeChannelEvents(playerWraps[i])
197 }
198 }
199 }
200
201 function youtubeChannelEvents(playerWrap) {
202
203 delegate(playerWrap, "click", ".item", function (event) {
204 var embed = "https://www.youtube.com/embed/";
205 var vid = this.getAttribute("data-vid");
206 var iframe = playerWrap.getElementsByTagName("iframe");
207
208 console.log
209
210 if (vid) {
211 if (iframe) {
212 var vidSrc = iframe[0]?.src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
213 if (vidSrc.indexOf('autoplay') > 0) {
214 vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
215 }
216 else {
217 vidSrc += '&autoplay=1';
218 }
219 iframe[0].src = vidSrc;
220 playerWrap.scrollIntoView();
221 }
222 }
223 });
224
225 var currentPage = 1;
226
227 let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
228
229 let epContentBlock = playerWrap.querySelector('.ep-youtube__content__block');
230 let parentElement = epContentBlock.parentElement;
231
232 // Get the value of data-channel-url attribute from a sibling
233 let channelUrl = parentElement.querySelector('[data-channel-url]').getAttribute('data-channel-url');
234
235
236 delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
237 const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
238 const closestClass = event.target.closest('.ose-youtube').classList;
239
240 const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
241 if (activePage) {
242 document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
243 }
244
245
246
247 var isNext = this.classList.contains("ep-next");
248
249 if (isNext) {
250 currentPage++;
251 } else {
252 currentPage--;
253 }
254
255 var data = {
256 action: "youtube_rest_api",
257 playlistid: this.getAttribute("data-playlistid"),
258 pagetoken: this.getAttribute("data-pagetoken"),
259 pagesize: this.getAttribute("data-pagesize"),
260 channelUrl: channelUrl,
261 currentpage: currentPage
262 };
263
264 var formBody = [];
265 for (var property in data) {
266 var encodedKey = encodeURIComponent(property);
267 var encodedValue = encodeURIComponent(data[property]);
268 formBody.push(encodedKey + "=" + encodedValue);
269 }
270 formBody = formBody.join("&");
271
272 var galleryWrapper = playerWrap.getElementsByClassName(
273 "ep-youtube__content__block"
274 );
275
276 playerWrap.setAttribute('data-current-page', currentPage);
277
278
279 let x = 1;
280
281 sendRequest(embedpressFrontendData.ajaxurl, formBody, function (request) {
282 if (galleryWrapper && galleryWrapper[0] && request.responseText) {
283 var response = JSON.parse(request.responseText);
284 galleryWrapper[0].outerHTML = response.html;
285
286 var currentPageNode =
287 galleryWrapper[0].getElementsByClassName("current-page");
288 if (currentPageNode && currentPageNode[0]) {
289 currentPageNode[0].textContent = currentPage;
290
291 }
292 }
293 });
294
295 const intervalID = setInterval(() => {
296 x++
297
298 if (playerWrap.querySelector('.ep-youtube__content__block')) {
299 const newNearestEpContentId = playerWrap
300 .querySelector('.ep-youtube__content__block')
301 .getAttribute('data-unique-id');
302
303 if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) {
304 playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
305 nearestEpContentId = newNearestEpContentId;
306 clearInterval(intervalID);
307 }
308 }
309
310 if (x > 100) {
311 clearInterval(intervalID);
312 }
313 }, 100);
314
315 });
316 }
317
318 //Load more for OpenaSea collection
319 const epLoadMore = () => {
320
321 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
322 let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
323
324 let loadmorelabel = $(selctorEl).data('loadmorelabel');
325 let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
326
327 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>`;
328
329 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
330 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
331
332 $(selctorEl + " .nft-loadmore").click(function (e) {
333 //change the text of the button
334 $(this).html(loadmorelabel + spinicon);
335 //disable the button
336 $(this).prop("disabled", true);
337 //wait for 1 seconds
338 setTimeout(function () {
339 //change the text back
340 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
341 //enable the button
342 $(selctorEl + " .nft-loadmore").prop("disabled", false);
343 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
344 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
345 $(selctorEl + " .nft-loadmore").fadeOut("slow");
346 }
347 }, 500);
348 });
349 });
350 };
351
352 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
353 epLoadMore();
354 }
355
356 // Content protection system function
357 const unlockSubmitHander = (perentSel, that) => {
358 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
359 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
360 var post_id = jQuery(`input[name="post_id"]`).val();
361 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
362 const unlokingText = jQuery(that).data('unlocking-text');
363
364
365 var data = {
366 'action': 'lock_content_form_handler',
367 'client_id': ep_client_id,
368 'password': password,
369 'post_id': post_id,
370 };
371
372 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
373
374 jQuery.post(embedpressFrontendData.ajaxurl, data, function (response) {
375 if (response.success) {
376 if (!response.embedHtml) {
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 if (typeof initPlayer === 'function') {
396 initPlayer(document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper'));
397 }
398 if (embedpressFrontendData.isProPluginActive) {
399 const adIdEl = document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-sponsored-id]');
400 if (typeof adInitialization === 'function') {
401 adInitialization(adIdEl, adIdEl?.getAttribute('data-ad-index'));
402 }
403 }
404
405 }
406 } else {
407 jQuery('#password-error_' + ep_client_id).html(response.form);
408 jQuery('#password-error_' + ep_client_id).show();
409 }
410 }, 'json');
411 }
412
413 // unlockSubmitHander called for gutentberg
414 jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
415 e.preventDefault(); // Prevent the default form submission
416 unlockSubmitHander('ep-gutenberg-content', this);
417 });
418
419 jQuery('.ep-shortcode-content .password-form').submit(function (e) {
420 e.preventDefault(); // Prevent the default form submission
421 unlockSubmitHander('ep-shortcode-content', this);
422 });
423
424 window.addEventListener('load', function (e) {
425 const urlParams = new URLSearchParams(window.location.search);
426 const hash = urlParams.get('hash');
427
428 // find the element with the matching id
429 const element = document.getElementById(hash);
430
431 if (element) {
432 element.scrollIntoView({ behavior: 'smooth' });
433 }
434
435 });
436
437 // Get the insta-gallery container element
438 const getPopupTemplate = (instPost, hashtag = '', accountType) => {
439
440 let instaPostData = JSON.parse(instPost);
441
442
443 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>';
444
445 if (instaPostData.like_count > 0) {
446 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>';
447 }
448
449 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>';
450
451 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>';
452
453 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>';
454
455
456
457 const instaUserInfo = instPost.user_info;
458
459 let getDate = new Date(instaPostData.timestamp);
460 getDate = getDate.toLocaleString('en-US', { day: 'numeric', month: 'short', year: 'numeric' });
461
462 let getTime = new Date(instaPostData.timestamp);
463 getTime = getTime.toLocaleString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
464
465 let captionText = instaPostData.caption ? instaPostData.caption : '';
466 const tagRegex = /(#\w+)/g;
467
468 const wrapTag = (match) => {
469 const tag = match.substring(1); // Remove the '#' character
470 const tagUrl = `https://www.instagram.com/explore/tags/${tag}`;
471 return `<span class="tag-wrapper"><a target="_blank" href="${tagUrl}">${match}</a></span>`;
472 };
473
474 captionText = captionText.replace(tagRegex, wrapTag);
475
476 let carouselTemplate = '';
477 if (instaPostData.media_type === 'CAROUSEL_ALBUM') {
478 carouselTemplate += `<div class="popup-carousel"><div class="cg-carousel__track js-carousel__track">`;
479
480 instaPostData.children.data?.map((item) => {
481 if (item.media_type?.toLowerCase() === 'video') {
482 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>`;
483 }
484 else {
485 carouselTemplate += `<img width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" src="${item.media_url || ''}" alt="${item.caption || ''}" />`;
486 }
487 });
488
489 carouselTemplate += `</div></div>`;
490
491 carouselTemplate += `<div class="cg-carousel__btns">
492 <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>
493
494 <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>
495 </div>`
496 }
497 else {
498 if (instaPostData.media_type?.toLowerCase() === 'video') {
499 carouselTemplate += `<video width="630" class="popup-media-image" controls src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}"></video>`;
500 }
501 else {
502 carouselTemplate += `<img width="630" class="popup-media-image" src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}" />`;
503 }
504 }
505
506 let srcUrl = `https://www.instagram.com/${instaPostData.username}/`;
507
508 if (hashtag) {
509 instaPostData.username = '#' + hashtag;
510 srcUrl = `https://www.instagram.com/explore/tags/${hashtag}/`;
511 }
512
513
514 let likeComments = '';
515
516 if (embedpressFrontendData.isProPluginActive) {
517 if (instaPostData.show_likes_count == 'true') {
518 likeComments += `
519 <div class="embedpress-inline popup-like-button"><a target="_blank" href="${instaPostData.permalink}">${likeIcon} ${instaPostData.like_count || 0}</a></div>
520 `;
521 }
522 if (instaPostData.show_comments_count == 'true') {
523 likeComments += `
524 <div class="embedpress-inline"><a target="_blank" href="${instaPostData.permalink}">${commentsIcon} ${instaPostData.comments_count || 0}</a></div>
525 `;
526 }
527 }
528
529
530 let followBtn = '';
531 if (instaPostData.popup_follow_button_text == 'false') {
532 instaPostData.popup_follow_button_text = '';
533 }
534 if (instaPostData.popup_follow_button == 'true' || instaPostData.popup_follow_button == 'yes') {
535 followBtn = `<div class="insta-followbtn">
536 <a target="_new" href="${srcUrl}" type="button" class="btn btn-primary">${instaPostData.popup_follow_button_text}</a>
537 </div>`;
538 }
539
540 let popupHtml = '';
541 popupHtml += `
542 <div class="popup-container">
543 <div class="popup-md-9 white">
544 <div class="embedpress-popup-block embedpress-popup-img" id="post-${instaPostData.id}">
545 ${carouselTemplate}
546 </div>
547 </div>
548 <div class="popup-md-3 red">
549 <div class="embedpress-popup-block embedpress-popup-info">
550 <div class="embedpress-popup-header">
551 <div class="embedpress-popup-header-img"> <a target="_blank" href="${srcUrl}"
552 target="_blank" class="embedpress-href">
553 <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>
554 </a>
555 </div>
556 ${followBtn}
557 </div>
558 <div class="embedpress-popup-text">${captionText}</div>
559 <div class="embedpress-popup-stats">
560 ${likeComments}
561 <div class="embedpress-inline">
562 <div class="embedpress-popup-share-buttons"> <a
563 href="https://www.facebook.com/sharer/sharer.php?u=${instaPostData.permalink}" target="_blank">
564 <span class="dashicons dashicons-facebook"></span></a> <a
565 href="https://twitter.com/intent/tweet?url=${instaPostData.permalink}"
566 target="_blank"><span>
567 <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>
568 </span></a>
569 <a href="https://www.linkedin.com/shareArticle?mini=true&amp;url=${instaPostData.permalink}"
570 target="_blank"><span class="dashicons dashicons-linkedin"></span></a> <a
571 href="https://pinterest.com/pin/create/button/?url=${instaPostData.permalink}"
572 target="_blank"><span class="dashicons dashicons-pinterest"></span></a></div>
573 <div class="embedpress-href embedpress-popup-share">${shareIcon}</div>
574 </div><div class="embedpress-inline embedpress-popup-instagram-buttons"><a
575 href="${instaPostData.permalink}" target="_blank"
576 class="embedpress-href">${instaIcon}</a></div>
577 </div>
578
579 </div>
580 </div>
581 </div>
582 `;
583
584 // INIT CAROUSEL
585
586
587 return popupHtml;
588 }
589
590 // Add a click event listener to the insta-gallery container
591 epGlobals.instaPopup = (container) => {
592 container?.addEventListener('click', function (event) {
593 // Check if the clicked element has the class insta-gallery-item
594 const instaItem = event.target.closest('.insta-gallery-item');
595
596 if (instaItem) {
597
598 const postData = instaItem.dataset.postdata;
599
600 const postid = instaItem.getAttribute('data-insta-postid');
601 const accountType = container?.closest('.instagram-container')?.getAttribute('data-connected-acc-type');
602
603 let hashtag = '';
604
605 if (instaItem.closest('.instagram-container').getAttribute('data-hashtag')) {
606 hashtag = instaItem?.closest('.instagram-container')?.getAttribute('data-hashtag');
607 }
608
609 const closestPopup = event.target.closest('.ose-instagram-feed')?.querySelector('.insta-popup');
610
611 if (closestPopup) {
612 closestPopup.style.display = 'block';
613 }
614
615
616 var feedElement = event.target.closest('.ose-instagram-feed');
617 if (feedElement) {
618 var popupElement = feedElement.querySelector('.popup-is-initialized');
619 if (popupElement) {
620 popupElement.innerHTML = getPopupTemplate(postData, hashtag, accountType);
621 }
622 }
623
624 if (!document.querySelector(`#post-${postid}`)?.classList.contains('carousel-is-initialized')) {
625 const carousel = new CgCarousel(`#post-${postid}`, { slidesPerView: 1, loop: true }, {});
626
627 const next = document.querySelector(`#post-${postid} .js-carousel__next-1`);
628 next?.addEventListener('click', () => carousel.next());
629
630 const prev = document.querySelector(`#post-${postid} .js-carousel__prev-1`);
631 prev?.addEventListener('click', () => carousel.prev());
632
633 document.querySelector(`#post-${postid}`)?.classList.add('carousel-is-initialized');
634 }
635
636 }
637 });
638 }
639
640
641 const instaContainers = document.querySelectorAll('.embedpress-gutenberg-wrapper .insta-gallery');
642 if (instaContainers.length > 0) {
643 instaContainers.forEach((container) => {
644 epGlobals.instaPopup(container);
645 });
646 }
647
648 $('.popup-close').click(function (e) {
649 // Hide the popup by setting display to none
650 $('.insta-popup').hide();
651 $('.popup-container').remove();
652 });
653
654 $(document).on('click', function (e) {
655 if (e.target.classList.contains('popup-wrapper')) {
656 $('.insta-popup').hide();
657 $('.popup-container').remove();
658 }
659 });
660
661
662 const instafeeds = document.querySelectorAll('.ose-instagram-feed');
663
664 epGlobals.initializeTabs = (containerEl) => {
665
666 // Initial tab selection
667 showItems('ALL');
668
669 containerEl.addEventListener('click', function (event) {
670 const clickedElement = event.target;
671 if (!clickedElement) {
672 return; // No element clicked, ignore the event
673 }
674
675 if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'VIDEO' || clickedElement.getAttribute('data-media-type') === 'CAROUSEL_ALBUM')) {
676 containerEl.querySelector('.load-more-button-container').style.display = 'none';
677 }
678 else if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'ALL')) {
679 containerEl.querySelector('.load-more-button-container').style.display = 'flex';
680 }
681
682 // Handle tab click
683 if (clickedElement.matches('.tabs li')) {
684 if (clickedElement.classList.contains('active')) {
685 return;
686 } else {
687 const mediaType = clickedElement.getAttribute('data-media-type');
688 showItems(mediaType);
689
690 const tabs = containerEl.querySelectorAll('.tabs li');
691 tabs.forEach(t => t.classList.remove('active'));
692 clickedElement.classList.add('active');
693 }
694 }
695
696 });
697
698 function showItems(mediaType) {
699 const items = containerEl.getElementsByClassName('insta-gallery-item');
700 for (let i = 0; i < items.length; i++) {
701 const item = items[i];
702 if (mediaType === 'ALL' || item.getAttribute('data-media-type') === mediaType) {
703 item.style.display = 'block';
704 } else {
705 item.style.display = 'none';
706 }
707 }
708 }
709 }
710
711 epGlobals.instaLoadMore = () => {
712 // Unbind any previously bound click event to avoid multiple bindings
713 $('.insta-load-more-button').off('click').on('click', function (e) {
714 const that = $(this);
715 const loadmoreBtn = that.closest('.load-more-button-container');
716 const loadmoreKey = loadmoreBtn.data('loadmorekey');
717 const connectedAccount = that.closest('.instagram-container').data('connected-acc-type');
718 const feedType = that.closest('.instagram-container').data('feed-type');
719 const hashtagId = that.closest('.instagram-container').data('hashtag-id');
720 const userId = that.closest('.instagram-container').data('uid');
721 let loadedPosts = loadmoreBtn.data('loaded-posts') || 0;
722 let postsPerPage = loadmoreBtn.data('posts-per-page') || 0;
723 const params = JSON.stringify(that.closest('.instagram-container').data('params'));
724
725
726 const instaContainer = that.closest('.instagram-container');
727
728 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>`;
729
730 // Check if no spinicon exists
731 if (instaContainer.find('.insta-loadmore-spinicon').length === 0) {
732 that.append(spinicon);
733 }
734
735 that.attr('disabled', true);
736
737 var data = {
738 'action': 'loadmore_data_handler',
739 'user_id': userId,
740 'loaded_posts': loadedPosts,
741 'posts_per_page': postsPerPage,
742 'feed_type': feedType,
743 'connected_account_type': connectedAccount,
744 'loadmore_key': loadmoreKey,
745 'params': params,
746 '_nonce': embedpressFrontendData.nonce
747 };
748
749 if (feedType === 'hashtag_type') {
750 data.hashtag_id = hashtagId;
751 }
752
753 jQuery.post(embedpressFrontendData.ajaxurl, data, function (response) {
754 if (response.total_feed_posts >= response.next_post_index) {
755 var $responseHtml = $(response.html);
756
757 instaContainer.find('.insta-gallery').append($responseHtml);
758 that.removeAttr('disabled');
759
760 instaContainer.find('.insta-loadmore-spinicon').remove();
761
762 loadedPosts = response.next_post_index;
763
764 loadmoreBtn.data('loaded-posts', loadedPosts);
765
766 // After loading more items, reinitialize the tabs for the specific container
767 const containerEl = loadmoreBtn.closest('.ose-instagram-feed')[0];
768 epGlobals.initializeTabs(containerEl);
769
770 if (response.total_feed_posts === response.next_post_index) {
771 loadmoreBtn.remove();
772 }
773 } else {
774 loadmoreBtn.remove();
775 }
776 });
777 });
778 }
779
780
781 if (instafeeds.length > 0) {
782 instafeeds.forEach(function (feed) {
783 epGlobals.initializeTabs(feed);
784 });
785 }
786
787 if ($('.embedpress-gutenberg-wrapper .ose-instagram-feed').length > 0) {
788 epGlobals.instaLoadMore();
789 }
790
791 $(document).on({
792 mouseenter: function () {
793 $('.embedpress-popup-share-buttons').addClass('show');
794 },
795 mouseleave: function () {
796 var buttons = $('.embedpress-popup-share-buttons');
797 setTimeout(function () {
798 if (!buttons.is(':hover')) buttons.removeClass('show');
799 }, 200);
800 }
801 }, '.embedpress-href.embedpress-popup-share, .embedpress-popup-share-buttons');
802
803 $(document).on({
804 mouseenter: function () {
805 $(this).addClass('show');
806 },
807 mouseleave: function () {
808 $(this).removeClass('show');
809 }
810 }, '.embedpress-popup-share-buttons');
811
812
813
814
815
816 })(jQuery);
817
818
819
820 document.addEventListener('DOMContentLoaded', function () {
821
822 epGlobals.initCarousel = (carouselSelector, options, carouselId) => {
823
824 const carouselOptions = {
825 slidesPerView: options.slideshow,
826 spacing: options.spacing,
827 loop: options.loop,
828 autoplay: options.autoplay,
829 transitionSpeed: options.transitionspeed,
830 autoplaySpeed: options.autoplayspeed,
831 arrows: options.arrows,
832 breakpoints: {
833 0: {
834 slidesPerView: 1
835 },
836 768: {
837 slidesPerView: Math.max(1, parseInt(options.slideshow, 10) - 1)
838 },
839 1024: {
840 slidesPerView: Math.max(1, parseInt(options.slideshow, 10))
841 }
842 }
843 };
844
845 // INIT CAROUSEL
846 const carousel = new CgCarousel(carouselSelector, carouselOptions, {});
847
848 // Navigation
849 const next = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__next-1`);
850 next?.addEventListener('click', () => carousel.next());
851
852 const prev = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__prev-1`);
853 prev?.addEventListener('click', () => carousel.prev());
854 }
855
856 const instaWrappers = document.querySelectorAll('.ep-embed-content-wraper');
857
858 if (instaWrappers.length > 0) {
859 instaWrappers.forEach((wrapper) => {
860 const carouselId = wrapper.getAttribute('data-carouselid');
861
862 if (!carouselId) return;
863
864 let options = wrapper.getAttribute(`data-carousel-options`);
865
866 options = JSON.parse(options);
867 const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`;
868
869 if (options.arrows) {
870 document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
871 }
872
873 epGlobals.initCarousel(carouselSelector, options, carouselId);
874
875 });
876 }
877
878 // Youtube Channel Carousel
879
880 const youtubeCarouselWraper = document.querySelectorAll('[data-youtube-channel-carousel]');
881
882 if (youtubeCarouselWraper.length > 0) {
883 youtubeCarouselWraper.forEach((wrapper) => {
884 const carouselId = wrapper.getAttribute('data-youtube-channel-carousel');
885 if (!carouselId) return;
886
887 // let options = wrapper.getAttribute(`data-carousel-options`);
888
889 // options = JSON.parse(options);
890
891 const carouselSelector = `[data-youtube-channel-carousel="${carouselId}"] .youtube__content__body`;
892
893 // if (options.arrows) {
894 // document.querySelector(`[data-youtube-channel-carousel="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
895 // }
896
897 const options = {
898 slidesPerView: 2,
899 autoplay: true,
900 loop: true,
901 breakpoints: {
902 768: {
903 slidesPerView: 2
904 },
905 1024: {
906 slidesPerView: 4
907 }
908 }
909 }
910
911 // epGlobals.initCarousel(carouselSelector, options, {});
912
913 });
914 }
915
916
917
918 });
919
920 document.addEventListener('DOMContentLoaded', () => {
921 const carousel = document.querySelector('.youtube-carousel');
922
923 if (!carousel) {
924 return;
925 }
926
927 const items = document.querySelectorAll('.item');
928 const prevButton = document.querySelector('.preview');
929 const nextButton = document.querySelector('.next');
930
931 let itemsToShow = getItemsToShow(); // Determine items to show based on screen width
932
933 const totalItems = items.length;
934 let currentIndex = 0;
935
936 function updateCarousel() {
937 const offset = -currentIndex * (100 / itemsToShow);
938 carousel.style.transform = `translateX(${offset}%)`;
939 }
940
941 function nextSlide() {
942 const remainingItems = totalItems - (currentIndex + itemsToShow);
943 if (remainingItems >= itemsToShow) {
944 currentIndex += itemsToShow;
945 } else if (remainingItems > 0) {
946 currentIndex += remainingItems;
947 } else {
948 currentIndex = 0;
949 }
950 updateCarousel();
951 }
952
953 function prevSlide() {
954 if (currentIndex > 0) {
955 currentIndex -= itemsToShow;
956 if (currentIndex < 0) {
957 currentIndex = 0;
958 }
959 } else {
960 currentIndex = totalItems - itemsToShow;
961 }
962 updateCarousel();
963 }
964
965 nextButton?.addEventListener('click', nextSlide);
966 prevButton?.addEventListener('click', prevSlide);
967
968 // Optional: Autoplay
969 let autoplay = false;
970 const autoplayInterval = 3000; // Change the time as needed
971 let autoplayId;
972
973 function startAutoplay() {
974 autoplayId = setInterval(nextSlide, autoplayInterval);
975 }
976
977 function stopAutoplay() {
978 clearInterval(autoplayId);
979 }
980
981 if (autoplay) {
982 startAutoplay();
983
984 // Stop autoplay on mouseover, resume on mouseout
985 carousel.addEventListener('mouseover', stopAutoplay);
986 carousel.addEventListener('mouseout', startAutoplay);
987 }
988
989 // Handle responsive behavior
990 window.addEventListener('resize', () => {
991 itemsToShow = getItemsToShow();
992 updateCarousel();
993
994 });
995
996 function getItemsToShow() {
997 const width = window.innerWidth;
998 if (width >= 1024) {
999 return 3;
1000 } else if (width >= 768) {
1001 return 2;
1002 } else {
1003 return 1;
1004 }
1005 }
1006 });
1007
1008
1009
1010
1011 jQuery(window).on("elementor/frontend/init", function () {
1012
1013 var filterableGalleryHandler = function ($scope, $) {
1014
1015 // Get the Elementor unique selector for this widget
1016 let classes = $scope[0].className;
1017 let selectorEl = '.' + classes.split(' ').join('.');
1018
1019 const epElLoadMore = () => {
1020
1021 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>';
1022
1023 $('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').each(function () {
1024 let selctorEl = `.elementor-widget-embedpres_elementor [data-nftid='${$(this).data('nftid')}']`;
1025 let loadmorelabel = $(selctorEl).data('loadmorelabel');
1026 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
1027 $('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
1028
1029 $(selctorEl + " .nft-loadmore").click(function (e) {
1030 //change the text of the button
1031 $(this).html(loadmorelabel + spinicon);
1032
1033 //disable the button
1034 $(this).prop("disabled", true);
1035 //wait for 1 seconds
1036 setTimeout(function () {
1037 //change the text back
1038 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
1039 //enable the button
1040 $(selctorEl + " .nft-loadmore").prop("disabled", false);
1041 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
1042 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
1043 $(selctorEl + " .nft-loadmore").fadeOut("slow");
1044 }
1045 }, 500);
1046 });
1047 });
1048 };
1049
1050 if ($('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').length > 0) {
1051 epElLoadMore();
1052 }
1053
1054 // Content protection system function
1055 const unlockElSubmitHander = (perentSel, that) => {
1056 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
1057 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
1058 var post_id = jQuery(`input[name="post_id"]`).val();
1059 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
1060 const unlokingText = jQuery(that).data('unlocking-text');
1061
1062 var data = {
1063 'action': 'lock_content_form_handler',
1064 'client_id': ep_client_id,
1065 'password': password,
1066 'post_id': post_id,
1067 };
1068
1069 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
1070
1071 jQuery.post(embedpressFrontendData.ajaxurl, data, function (response) {
1072 if (response.success) {
1073 if (!response.embedHtml) {
1074 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
1075 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
1076 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
1077 }
1078 else {
1079 if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
1080 $('.ep-content-locked').removeClass('ep-content-locked');
1081 }
1082
1083 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
1084
1085 $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
1086
1087 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
1088 epGlobals.youtubeChannelGallery();
1089 }
1090
1091 if ($('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').length > 0) {
1092 epElLoadMore();
1093 }
1094 }
1095 } else {
1096 jQuery('#password-error_' + ep_client_id).html(response.form);
1097 jQuery('#password-error_' + ep_client_id).show();
1098 }
1099 }, 'json');
1100 }
1101
1102 // unlockElSubmitHander called for Elementor
1103 jQuery('.ep-elementor-content .password-form').submit(function (e) {
1104 e.preventDefault(); // Prevent the default form submission
1105 unlockElSubmitHander('ep-elementor-content', this);
1106 });
1107
1108
1109 const instaWrappers = document.querySelectorAll('.ep-embed-content-wrapper');
1110
1111 if (instaWrappers.length > 0) {
1112
1113 instaWrappers.forEach((wrapper) => {
1114 wrapper.classList.add('class-content-wrapper');
1115 const carouselId = wrapper.getAttribute('data-carouselid');
1116
1117 if (!carouselId) return;
1118
1119 let options = wrapper.getAttribute(`data-carousel-options`);
1120
1121 options = JSON.parse(options);
1122 const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`;
1123
1124
1125 if (options.arrows) {
1126 document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
1127 }
1128
1129 epGlobals.initCarousel(carouselSelector, options, carouselId);
1130
1131 });
1132 }
1133
1134
1135 const instaFeed = document.querySelector(`${selectorEl} .ose-instagram-feed`);
1136 const instaGallery = document.querySelector(`${selectorEl} .insta-gallery`);
1137 if (instaFeed) {
1138 epGlobals.initializeTabs(instaFeed);
1139 }
1140 if (instaGallery) {
1141 epGlobals.instaPopup(instaGallery);
1142
1143 $('.popup-close').click(function (e) {
1144 // Hide the popup by setting display to none
1145 $('.insta-popup').hide();
1146 $('.popup-container').remove();
1147 });
1148
1149 }
1150
1151 if ($('.elementor-widget-embedpres_elementor .ose-instagram-feed').length > 0) {
1152 epGlobals.instaLoadMore();
1153 }
1154
1155 };
1156
1157 const adsHandler = function ($scope, $) {
1158 window.epAdIndex = typeof (window.epAdIndex) === 'undefined' ? 0 : window.epAdIndex + 1;
1159 let classes = $scope[0].className;
1160 let classJoint = '.' + classes.split(' ').join('.');
1161 const selectorEl = document.querySelector(classJoint + ' [data-sponsored-id]');
1162
1163 if (jQuery('body').hasClass('elementor-editor-active') && embedpressFrontendData.isProPluginActive) {
1164 if (typeof adInitialization === 'function') {
1165 adInitialization(selectorEl, window.epAdIndex);
1166 }
1167 }
1168
1169 }
1170
1171 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
1172 elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
1173 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
1174 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", adsHandler);
1175 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", epGlobals.handlePosterImageLoad);
1176 });
1177
1178
1179 function presentationModeForIOS(iframes) {
1180 iframes?.forEach(function (iframe) {
1181 iframe.onload = function () {
1182 var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
1183 var button = iframeDoc?.querySelector('#presentationMode.presentationMode');
1184 button?.addEventListener('click', function () {
1185 iframe.classList.toggle('presentationModeEnabledIosDevice');
1186 });
1187 iframeDoc?.addEventListener('keydown', function (event) {
1188 if (event.keyCode === 27) {
1189 iframe.classList.remove('presentationModeEnabledIosDevice');
1190 }
1191 });
1192 };
1193 });
1194 }
1195
1196 function isIOSDevice() {
1197 return /iPhone|iPad|iPod/i.test(navigator.userAgent);
1198 }
1199
1200 if (isIOSDevice()) {
1201 var iframes = document.querySelectorAll('.embedpress-embed-document-pdf');
1202 presentationModeForIOS(iframes)
1203 }
1204
1205 document.addEventListener("DOMContentLoaded", epGlobals.handlePosterImageLoad);
1206
1207
1208 jQuery(document).ready(function ($) {
1209
1210 let currentIndex = -1;
1211
1212 function createVideoPopup() {
1213 const videoPopupHtml = `
1214 <div id="videoPopup" class="video-popup">
1215 <div class="video-popup-content">
1216 <span class="close">&times;</span>
1217 <div class="video-popup-inner-content">
1218 <iframe id="videoIframe" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
1219 <div id="videoDescription"></div>
1220 </div>
1221 <div class="popup-controls">
1222 <span id="prevVideo" class="nav-icon prev-icon">&#10094;</span>
1223 <span id="nextVideo" class="nav-icon next-icon">&#10095;</span>
1224 </div>
1225 </div>
1226 </div>`;
1227 return $(videoPopupHtml).appendTo('body');
1228 }
1229
1230 function openVideoPopup(index) {
1231 const items = $('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1232 if (index >= 0 && index < items.length) {
1233 // Remove any existing video popup before creating a new one
1234 $('#videoPopup').remove();
1235
1236 currentIndex = index;
1237 const videoId = $(items[currentIndex]).data('vid');
1238 const videoPopup = createVideoPopup();
1239 const videoIframe = videoPopup.find('#videoIframe');
1240 const videoDescriptionContainer = videoPopup.find('#videoDescription');
1241 const closeBtn = videoPopup.find('.close');
1242 const nextBtn = videoPopup.find('#nextVideo');
1243 const prevBtn = videoPopup.find('#prevVideo');
1244
1245 if (videoId) {
1246 fetchVideoData(videoId, videoIframe, videoDescriptionContainer);
1247 videoPopup.show();
1248 updateNavigationButtons(nextBtn, prevBtn, items);
1249
1250 closeBtn.on('click', () => {
1251 closeVideoPopup(videoPopup);
1252 });
1253
1254 $(window).on('click', function (event) {
1255 if ($(event.target).is(videoPopup)) {
1256 closeVideoPopup(videoPopup);
1257 }
1258 });
1259
1260 nextBtn.on('click', function () {
1261 if (currentIndex >= 0 && currentIndex < items.length - 1) {
1262 openVideoPopup(currentIndex + 1);
1263 }
1264 });
1265
1266 prevBtn.on('click', function () {
1267 if (currentIndex > 0) {
1268 openVideoPopup(currentIndex - 1);
1269 }
1270 });
1271 }
1272 }
1273 }
1274
1275
1276 function closeVideoPopup(videoPopup) {
1277 videoPopup.remove();
1278 currentIndex = -1; // Reset the index
1279 }
1280
1281 function updateNavigationButtons(nextBtn, prevBtn, items) {
1282 prevBtn.toggle(currentIndex > 0);
1283 nextBtn.toggle(currentIndex < items.length - 1);
1284 }
1285
1286 function fetchVideoData(videoId, videoIframe, videoDescriptionContainer) {
1287 const data = {
1288 action: 'fetch_video_description',
1289 vid: videoId
1290 };
1291
1292 $.post(embedpressFrontendData.ajaxurl, data, function (response) {
1293 if (response.success) {
1294 videoIframe.attr('src', `https://www.youtube.com/embed/${videoId}?autoplay=1`);
1295 videoDescriptionContainer.html(response.data.description);
1296 } else {
1297 console.error('Error fetching video data:', response?.data?.error);
1298 }
1299 });
1300 }
1301
1302 $(document).on('click', '.layout-grid .item, .layout-list .item, .layout-carousel .item', function () {
1303 const items = $('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1304 const index = items.index(this);
1305 openVideoPopup(index);
1306 });
1307 });
1308 jQuery(document).ready(function ($) {
1309 let currentIndex = 0;
1310 const $photos = $('.photo-item');
1311
1312 function createPopupGooglePhotos() {
1313 if ($('#ep-popup-overlay').length === 0) {
1314 const photoPopup = `
1315 <div class="popup-overlay" id="ep-popup-overlay" style="display: none!important">
1316
1317 <div class="popup">
1318 <span class="close-btn" id="close-btn">
1319 <svg width="20" height="20" viewBox="0 0 0.6 0.6" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.132.132a.025.025 0 0 1 .035 0L.3.265.432.133a.025.025 0 1 1 .035.035L.335.3l.132.132a.025.025 0 0 1-.035.035L.3.335.168.467A.025.025 0 0 1 .133.432L.265.3.132.168a.025.025 0 0 1 0-.035" fill="#fff"/></svg>
1320 </span>
1321 <button class="prev-btn" id="prev-btn">
1322 <svg width="20" height="20" viewBox="0 0 0.6 0.6" data-name="Flat Color" xmlns="http://www.w3.org/2000/svg" class="icon flat-color"><path d="M.525.275h-.39L.268.143A.025.025 0 1 0 .233.108L.058.283a.025.025 0 0 0 0 .035l.175.175a.025.025 0 0 0 .035 0 .025.025 0 0 0 0-.035L.135.325h.39a.025.025 0 0 0 0-.05" style="fill:#fff"/></svg>
1323 </button>
1324 <div id="popup-content" class="loading">
1325 <div class="photo-loader"></div>
1326 <img id="popup-image" src="" style="display:none;" loading="lazy" />
1327 </div>
1328 <button class="next-btn" id="next-btn">
1329 <svg width="20" height="20" viewBox="0 0 0.6 0.6" data-name="Flat Color" xmlns="http://www.w3.org/2000/svg" class="icon flat-color"><path d="M.543.282.368.107a.025.025 0 0 0-.035.035l.133.132H.075a.025.025 0 0 0 0 .05h.39L.332.456a.025.025 0 0 0 0 .035.025.025 0 0 0 .035 0L.542.316a.025.025 0 0 0 0-.035" style="fill:#fff"/></svg>
1330 </button>
1331 </div>
1332 </div>`;
1333 $('body').append(photoPopup);
1334
1335 // Loader spinner CSS (can be moved to your CSS file)
1336 const spinnerStyles = `
1337 <style>
1338 .popup #popup-content .photo-loader {
1339 display: none;
1340 }
1341 .popup #popup-content.loading .photo-loader {
1342 width: 40px;
1343 height: 40px;
1344 border: 4px solid #fff;
1345 border-top: 4px solid transparent;
1346 border-radius: 50%;
1347 animation: spin 1s linear infinite;
1348 margin: 40px auto;
1349 display: block;
1350 }
1351 @keyframes spin {
1352 0% { transform: rotate(0deg); }
1353 100% { transform: rotate(360deg); }
1354 }
1355 </style>`;
1356 $('head').append(spinnerStyles);
1357
1358 // Events
1359 $('#ep-popup-overlay').on('click', function (e) {
1360 if ($(e.target).is('#ep-popup-overlay') || $(e.target).is('.popup')) {
1361 $('#ep-popup-overlay').hide();
1362 }
1363 });
1364
1365 $('#close-btn').on('click', function () {
1366 $('#ep-popup-overlay').hide();
1367 });
1368
1369 $('#prev-btn').on('click', function () {
1370 currentIndex = (currentIndex - 1 + $photos.length) % $photos.length;
1371 updatePopupImage();
1372 });
1373
1374 $('#next-btn').on('click', function () {
1375 currentIndex = (currentIndex + 1) % $photos.length;
1376 updatePopupImage();
1377 });
1378 }
1379 }
1380
1381 function updatePopupImage() {
1382 const imgSrc = $photos.eq(currentIndex).find('img').attr('data-photo-src');
1383 const $popupImage = $('#popup-image');
1384 const $popupContent = $('#popup-content');
1385
1386 $popupContent.addClass('loading');
1387 $popupImage.hide();
1388
1389 const preload = new Image();
1390 preload.src = imgSrc;
1391
1392 preload.onload = function () {
1393 $popupImage.attr('src', imgSrc);
1394 $popupContent.removeClass('loading');
1395 $popupImage.fadeIn();
1396 };
1397 }
1398
1399 $('.photo-item').on('click', function () {
1400 currentIndex = $photos.index(this);
1401 createPopupGooglePhotos();
1402 updatePopupImage();
1403 $('#ep-popup-overlay').show();
1404 });
1405 });
1406
1407
1408 // pause audio/video
1409
1410 jQuery(document).ready(function () {
1411 const players = jQuery('.enabled-auto-pause audio, .enabled-auto-pause video');
1412
1413 function pauseAllExcept(currentPlayer) {
1414 players.each(function () {
1415 if (this !== currentPlayer[0]) {
1416 this.pause();
1417 }
1418 });
1419 }
1420
1421 players.on('play', function () {
1422 pauseAllExcept(jQuery(this));
1423 });
1424 });
1425
1426 // Meetup Events Load More
1427 jQuery(document).on('click', '.ep-load-more-button', function(e) {
1428 e.preventDefault();
1429
1430 const button = jQuery(this);
1431 const container = button.closest('.embedpress-meetup-events');
1432 const eventsContainer = container.find('.embedpress-meetup-events-list');
1433
1434 // Get data attributes
1435 const embedId = button.data('embed-id');
1436 const currentPage = parseInt(container.data('page')) || 1;
1437 const perPage = parseInt(container.data('per-page')) || 10;
1438 const nextPage = currentPage + 1;
1439
1440 // Show loading state
1441 const loadingText = button.find('.ep-load-more-text');
1442 const spinner = button.find('.ep-load-more-spinner');
1443 loadingText.hide();
1444 spinner.show();
1445 button.prop('disabled', true);
1446
1447 // Make AJAX request
1448 jQuery.ajax({
1449 url: embedpressFrontendData.ajaxurl,
1450 type: 'POST',
1451 data: {
1452 action: 'embedpress_meetup_load_more',
1453 nonce: embedpressFrontendData.nonce,
1454 embed_id: embedId,
1455 page: nextPage,
1456 per_page: perPage
1457 },
1458 success: function(response) {
1459 if (response.success) {
1460 // Append new events
1461 eventsContainer.append(response.data.html);
1462
1463 // Update page number
1464 container.data('page', nextPage);
1465
1466 // Trigger custom event for timezone conversion
1467 document.dispatchEvent(new Event('embedpress:meetup:loaded'));
1468
1469 // Hide button if no more events
1470 if (!response.data.has_more) {
1471 button.closest('.ep-events-load-more').fadeOut();
1472 } else {
1473 loadingText.show();
1474 spinner.hide();
1475 button.prop('disabled', false);
1476 }
1477 } else {
1478 alert(response.data.message || 'Error loading more events');
1479 loadingText.show();
1480 spinner.hide();
1481 button.prop('disabled', false);
1482 }
1483 },
1484 error: function() {
1485 alert('Error loading more events');
1486 loadingText.show();
1487 spinner.hide();
1488 button.prop('disabled', false);
1489 }
1490 });
1491 });
1492
1493