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