PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.4.9
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.4.9
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 5 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 5 months ago blocks.build.js 5 months ago carousel.js 1 year ago documents-viewer-script.js 3 years ago feature-notices.js 7 months ago front.js 5 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
1504 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 // Replace the content inside the wrapper, keeping the wrapper itself
383 const wrapperEl = jQuery('#' + perentSel + '-' + ep_client_id);
384 const parentWrapper = wrapperEl.parent('.ep-embed-content-wraper');
385
386 if (parentWrapper.length > 0) {
387 // If there's a parent .ep-embed-content-wraper, replace its content
388 parentWrapper.html(response.embedHtml);
389 } else {
390 // Otherwise replace the wrapper content directly
391 wrapperEl.html(response.embedHtml);
392 }
393
394 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
395 epGlobals.youtubeChannelGallery();
396 }
397
398 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
399 epLoadMore();
400 }
401
402 // Custom player initialization when content protection enabled
403 const targetEl = parentWrapper.length > 0 ? parentWrapper[0] : wrapperEl[0];
404 targetEl?.classList?.remove('plyr-initialized');
405
406 if (typeof initPlayer === 'function') {
407 initPlayer(targetEl);
408 }
409 if (embedpressFrontendData.isProPluginActive) {
410 const adIdEl = document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-sponsored-id]');
411 if (typeof adInitialization === 'function') {
412 adInitialization(adIdEl, adIdEl?.getAttribute('data-ad-index'));
413 }
414 }
415
416 }
417 } else {
418 jQuery('#password-error_' + ep_client_id).html(response.form);
419 jQuery('#password-error_' + ep_client_id).show();
420 }
421 }, 'json');
422 }
423
424 // unlockSubmitHander called for gutentberg
425 jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
426 e.preventDefault(); // Prevent the default form submission
427 unlockSubmitHander('ep-gutenberg-content', this);
428 });
429
430 jQuery('.ep-shortcode-content .password-form').submit(function (e) {
431 e.preventDefault(); // Prevent the default form submission
432 unlockSubmitHander('ep-shortcode-content', this);
433 });
434
435 window.addEventListener('load', function (e) {
436 const urlParams = new URLSearchParams(window.location.search);
437 const hash = urlParams.get('hash');
438
439 // find the element with the matching id
440 const element = document.getElementById(hash);
441
442 if (element) {
443 element.scrollIntoView({ behavior: 'smooth' });
444 }
445
446 });
447
448 // Get the insta-gallery container element
449 const getPopupTemplate = (instPost, hashtag = '', accountType) => {
450
451 let instaPostData = JSON.parse(instPost);
452
453
454 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>';
455
456 if (instaPostData.like_count > 0) {
457 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>';
458 }
459
460 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>';
461
462 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>';
463
464 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>';
465
466
467
468 const instaUserInfo = instPost.user_info;
469
470 let getDate = new Date(instaPostData.timestamp);
471 getDate = getDate.toLocaleString('en-US', { day: 'numeric', month: 'short', year: 'numeric' });
472
473 let getTime = new Date(instaPostData.timestamp);
474 getTime = getTime.toLocaleString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
475
476 let captionText = instaPostData.caption ? instaPostData.caption : '';
477 const tagRegex = /(#\w+)/g;
478
479 const wrapTag = (match) => {
480 const tag = match.substring(1); // Remove the '#' character
481 const tagUrl = `https://www.instagram.com/explore/tags/${tag}`;
482 return `<span class="tag-wrapper"><a target="_blank" href="${tagUrl}">${match}</a></span>`;
483 };
484
485 captionText = captionText.replace(tagRegex, wrapTag);
486
487 let carouselTemplate = '';
488 if (instaPostData.media_type === 'CAROUSEL_ALBUM') {
489 carouselTemplate += `<div class="popup-carousel"><div class="cg-carousel__track js-carousel__track">`;
490
491 instaPostData.children.data?.map((item) => {
492 if (item.media_type?.toLowerCase() === 'video') {
493 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>`;
494 }
495 else {
496 carouselTemplate += `<img width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" src="${item.media_url || ''}" alt="${item.caption || ''}" />`;
497 }
498 });
499
500 carouselTemplate += `</div></div>`;
501
502 carouselTemplate += `<div class="cg-carousel__btns">
503 <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>
504
505 <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>
506 </div>`
507 }
508 else {
509 if (instaPostData.media_type?.toLowerCase() === 'video') {
510 carouselTemplate += `<video width="630" class="popup-media-image" controls src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}"></video>`;
511 }
512 else {
513 carouselTemplate += `<img width="630" class="popup-media-image" src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}" />`;
514 }
515 }
516
517 let srcUrl = `https://www.instagram.com/${instaPostData.username}/`;
518
519 if (hashtag) {
520 instaPostData.username = '#' + hashtag;
521 srcUrl = `https://www.instagram.com/explore/tags/${hashtag}/`;
522 }
523
524
525 let likeComments = '';
526
527 if (embedpressFrontendData.isProPluginActive) {
528 if (instaPostData.show_likes_count == 'true') {
529 likeComments += `
530 <div class="embedpress-inline popup-like-button"><a target="_blank" href="${instaPostData.permalink}">${likeIcon} ${instaPostData.like_count || 0}</a></div>
531 `;
532 }
533 if (instaPostData.show_comments_count == 'true') {
534 likeComments += `
535 <div class="embedpress-inline"><a target="_blank" href="${instaPostData.permalink}">${commentsIcon} ${instaPostData.comments_count || 0}</a></div>
536 `;
537 }
538 }
539
540
541 let followBtn = '';
542 if (instaPostData.popup_follow_button_text == 'false') {
543 instaPostData.popup_follow_button_text = '';
544 }
545 if (instaPostData.popup_follow_button == 'true' || instaPostData.popup_follow_button == 'yes') {
546 followBtn = `<div class="insta-followbtn">
547 <a target="_new" href="${srcUrl}" type="button" class="btn btn-primary">${instaPostData.popup_follow_button_text}</a>
548 </div>`;
549 }
550
551 let popupHtml = '';
552 popupHtml += `
553 <div class="popup-container">
554 <div class="popup-md-9 white">
555 <div class="embedpress-popup-block embedpress-popup-img" id="post-${instaPostData.id}">
556 ${carouselTemplate}
557 </div>
558 </div>
559 <div class="popup-md-3 red">
560 <div class="embedpress-popup-block embedpress-popup-info">
561 <div class="embedpress-popup-header">
562 <div class="embedpress-popup-header-img"> <a target="_blank" href="${srcUrl}"
563 target="_blank" class="embedpress-href">
564 <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>
565 </a>
566 </div>
567 ${followBtn}
568 </div>
569 <div class="embedpress-popup-text">${captionText}</div>
570 <div class="embedpress-popup-stats">
571 ${likeComments}
572 <div class="embedpress-inline">
573 <div class="embedpress-popup-share-buttons"> <a
574 href="https://www.facebook.com/sharer/sharer.php?u=${instaPostData.permalink}" target="_blank">
575 <span class="dashicons dashicons-facebook"></span></a> <a
576 href="https://twitter.com/intent/tweet?url=${instaPostData.permalink}"
577 target="_blank"><span>
578 <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>
579 </span></a>
580 <a href="https://www.linkedin.com/shareArticle?mini=true&amp;url=${instaPostData.permalink}"
581 target="_blank"><span class="dashicons dashicons-linkedin"></span></a> <a
582 href="https://pinterest.com/pin/create/button/?url=${instaPostData.permalink}"
583 target="_blank"><span class="dashicons dashicons-pinterest"></span></a></div>
584 <div class="embedpress-href embedpress-popup-share">${shareIcon}</div>
585 </div><div class="embedpress-inline embedpress-popup-instagram-buttons"><a
586 href="${instaPostData.permalink}" target="_blank"
587 class="embedpress-href">${instaIcon}</a></div>
588 </div>
589
590 </div>
591 </div>
592 </div>
593 `;
594
595 // INIT CAROUSEL
596
597
598 return popupHtml;
599 }
600
601 // Add a click event listener to the insta-gallery container
602 epGlobals.instaPopup = (container) => {
603 container?.addEventListener('click', function (event) {
604 // Check if the clicked element has the class insta-gallery-item
605 const instaItem = event.target.closest('.insta-gallery-item');
606
607 if (instaItem) {
608
609 const postData = instaItem.dataset.postdata;
610
611 const postid = instaItem.getAttribute('data-insta-postid');
612 const accountType = container?.closest('.instagram-container')?.getAttribute('data-connected-acc-type');
613
614 let hashtag = '';
615
616 if (instaItem.closest('.instagram-container').getAttribute('data-hashtag')) {
617 hashtag = instaItem?.closest('.instagram-container')?.getAttribute('data-hashtag');
618 }
619
620 const closestPopup = event.target.closest('.ose-instagram-feed')?.querySelector('.insta-popup');
621
622 if (closestPopup) {
623 closestPopup.style.display = 'block';
624 }
625
626
627 var feedElement = event.target.closest('.ose-instagram-feed');
628 if (feedElement) {
629 var popupElement = feedElement.querySelector('.popup-is-initialized');
630 if (popupElement) {
631 popupElement.innerHTML = getPopupTemplate(postData, hashtag, accountType);
632 }
633 }
634
635 if (!document.querySelector(`#post-${postid}`)?.classList.contains('carousel-is-initialized')) {
636 const carousel = new CgCarousel(`#post-${postid}`, { slidesPerView: 1, loop: true }, {});
637
638 const next = document.querySelector(`#post-${postid} .js-carousel__next-1`);
639 next?.addEventListener('click', () => carousel.next());
640
641 const prev = document.querySelector(`#post-${postid} .js-carousel__prev-1`);
642 prev?.addEventListener('click', () => carousel.prev());
643
644 document.querySelector(`#post-${postid}`)?.classList.add('carousel-is-initialized');
645 }
646
647 }
648 });
649 }
650
651
652 const instaContainers = document.querySelectorAll('.embedpress-gutenberg-wrapper .insta-gallery');
653 if (instaContainers.length > 0) {
654 instaContainers.forEach((container) => {
655 epGlobals.instaPopup(container);
656 });
657 }
658
659 $('.popup-close').click(function (e) {
660 // Hide the popup by setting display to none
661 $('.insta-popup').hide();
662 $('.popup-container').remove();
663 });
664
665 $(document).on('click', function (e) {
666 if (e.target.classList.contains('popup-wrapper')) {
667 $('.insta-popup').hide();
668 $('.popup-container').remove();
669 }
670 });
671
672
673 const instafeeds = document.querySelectorAll('.ose-instagram-feed');
674
675 epGlobals.initializeTabs = (containerEl) => {
676
677 // Initial tab selection
678 showItems('ALL');
679
680 containerEl.addEventListener('click', function (event) {
681 const clickedElement = event.target;
682 if (!clickedElement) {
683 return; // No element clicked, ignore the event
684 }
685
686 if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'VIDEO' || clickedElement.getAttribute('data-media-type') === 'CAROUSEL_ALBUM')) {
687 containerEl.querySelector('.load-more-button-container').style.display = 'none';
688 }
689 else if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'ALL')) {
690 containerEl.querySelector('.load-more-button-container').style.display = 'flex';
691 }
692
693 // Handle tab click
694 if (clickedElement.matches('.tabs li')) {
695 if (clickedElement.classList.contains('active')) {
696 return;
697 } else {
698 const mediaType = clickedElement.getAttribute('data-media-type');
699 showItems(mediaType);
700
701 const tabs = containerEl.querySelectorAll('.tabs li');
702 tabs.forEach(t => t.classList.remove('active'));
703 clickedElement.classList.add('active');
704 }
705 }
706
707 });
708
709 function showItems(mediaType) {
710 const items = containerEl.getElementsByClassName('insta-gallery-item');
711 for (let i = 0; i < items.length; i++) {
712 const item = items[i];
713 if (mediaType === 'ALL' || item.getAttribute('data-media-type') === mediaType) {
714 item.style.display = 'block';
715 } else {
716 item.style.display = 'none';
717 }
718 }
719 }
720 }
721
722 epGlobals.instaLoadMore = () => {
723 // Unbind any previously bound click event to avoid multiple bindings
724 $('.insta-load-more-button').off('click').on('click', function (e) {
725 const that = $(this);
726 const loadmoreBtn = that.closest('.load-more-button-container');
727 const loadmoreKey = loadmoreBtn.data('loadmorekey');
728 const connectedAccount = that.closest('.instagram-container').data('connected-acc-type');
729 const feedType = that.closest('.instagram-container').data('feed-type');
730 const hashtagId = that.closest('.instagram-container').data('hashtag-id');
731 const userId = that.closest('.instagram-container').data('uid');
732 let loadedPosts = loadmoreBtn.data('loaded-posts') || 0;
733 let postsPerPage = loadmoreBtn.data('posts-per-page') || 0;
734 const params = JSON.stringify(that.closest('.instagram-container').data('params'));
735
736
737 const instaContainer = that.closest('.instagram-container');
738
739 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>`;
740
741 // Check if no spinicon exists
742 if (instaContainer.find('.insta-loadmore-spinicon').length === 0) {
743 that.append(spinicon);
744 }
745
746 that.attr('disabled', true);
747
748 var data = {
749 'action': 'loadmore_data_handler',
750 'user_id': userId,
751 'loaded_posts': loadedPosts,
752 'posts_per_page': postsPerPage,
753 'feed_type': feedType,
754 'connected_account_type': connectedAccount,
755 'loadmore_key': loadmoreKey,
756 'params': params,
757 '_nonce': embedpressFrontendData.nonce
758 };
759
760 if (feedType === 'hashtag_type') {
761 data.hashtag_id = hashtagId;
762 }
763
764 jQuery.post(embedpressFrontendData.ajaxurl, data, function (response) {
765 if (response.total_feed_posts >= response.next_post_index) {
766 var $responseHtml = $(response.html);
767
768 instaContainer.find('.insta-gallery').append($responseHtml);
769 that.removeAttr('disabled');
770
771 instaContainer.find('.insta-loadmore-spinicon').remove();
772
773 loadedPosts = response.next_post_index;
774
775 loadmoreBtn.data('loaded-posts', loadedPosts);
776
777 // After loading more items, reinitialize the tabs for the specific container
778 const containerEl = loadmoreBtn.closest('.ose-instagram-feed')[0];
779 epGlobals.initializeTabs(containerEl);
780
781 if (response.total_feed_posts === response.next_post_index) {
782 loadmoreBtn.remove();
783 }
784 } else {
785 loadmoreBtn.remove();
786 }
787 });
788 });
789 }
790
791
792 if (instafeeds.length > 0) {
793 instafeeds.forEach(function (feed) {
794 epGlobals.initializeTabs(feed);
795 });
796 }
797
798 if ($('.embedpress-gutenberg-wrapper .ose-instagram-feed').length > 0) {
799 epGlobals.instaLoadMore();
800 }
801
802 $(document).on({
803 mouseenter: function () {
804 $('.embedpress-popup-share-buttons').addClass('show');
805 },
806 mouseleave: function () {
807 var buttons = $('.embedpress-popup-share-buttons');
808 setTimeout(function () {
809 if (!buttons.is(':hover')) buttons.removeClass('show');
810 }, 200);
811 }
812 }, '.embedpress-href.embedpress-popup-share, .embedpress-popup-share-buttons');
813
814 $(document).on({
815 mouseenter: function () {
816 $(this).addClass('show');
817 },
818 mouseleave: function () {
819 $(this).removeClass('show');
820 }
821 }, '.embedpress-popup-share-buttons');
822
823
824
825
826
827 })(jQuery);
828
829
830
831 document.addEventListener('DOMContentLoaded', function () {
832
833 epGlobals.initCarousel = (carouselSelector, options, carouselId) => {
834
835 const carouselOptions = {
836 slidesPerView: options.slideshow,
837 spacing: options.spacing,
838 loop: options.loop,
839 autoplay: options.autoplay,
840 transitionSpeed: options.transitionspeed,
841 autoplaySpeed: options.autoplayspeed,
842 arrows: options.arrows,
843 breakpoints: {
844 0: {
845 slidesPerView: 1
846 },
847 768: {
848 slidesPerView: Math.max(1, parseInt(options.slideshow, 10) - 1)
849 },
850 1024: {
851 slidesPerView: Math.max(1, parseInt(options.slideshow, 10))
852 }
853 }
854 };
855
856 // INIT CAROUSEL
857 const carousel = new CgCarousel(carouselSelector, carouselOptions, {});
858
859 // Navigation
860 const next = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__next-1`);
861 next?.addEventListener('click', () => carousel.next());
862
863 const prev = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__prev-1`);
864 prev?.addEventListener('click', () => carousel.prev());
865 }
866
867 const instaWrappers = document.querySelectorAll('.ep-embed-content-wraper');
868
869 if (instaWrappers.length > 0) {
870 instaWrappers.forEach((wrapper) => {
871 const carouselId = wrapper.getAttribute('data-carouselid');
872
873 if (!carouselId) return;
874
875 let options = wrapper.getAttribute(`data-carousel-options`);
876
877 options = JSON.parse(options);
878 const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`;
879
880 if (options.arrows) {
881 document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
882 }
883
884 epGlobals.initCarousel(carouselSelector, options, carouselId);
885
886 });
887 }
888
889 // Youtube Channel Carousel
890
891 const youtubeCarouselWraper = document.querySelectorAll('[data-youtube-channel-carousel]');
892
893 if (youtubeCarouselWraper.length > 0) {
894 youtubeCarouselWraper.forEach((wrapper) => {
895 const carouselId = wrapper.getAttribute('data-youtube-channel-carousel');
896 if (!carouselId) return;
897
898 // let options = wrapper.getAttribute(`data-carousel-options`);
899
900 // options = JSON.parse(options);
901
902 const carouselSelector = `[data-youtube-channel-carousel="${carouselId}"] .youtube__content__body`;
903
904 // if (options.arrows) {
905 // document.querySelector(`[data-youtube-channel-carousel="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
906 // }
907
908 const options = {
909 slidesPerView: 2,
910 autoplay: true,
911 loop: true,
912 breakpoints: {
913 768: {
914 slidesPerView: 2
915 },
916 1024: {
917 slidesPerView: 4
918 }
919 }
920 }
921
922 // epGlobals.initCarousel(carouselSelector, options, {});
923
924 });
925 }
926
927
928
929 });
930
931 document.addEventListener('DOMContentLoaded', () => {
932 const carousel = document.querySelector('.youtube-carousel');
933
934 if (!carousel) {
935 return;
936 }
937
938 const items = document.querySelectorAll('.item');
939 const prevButton = document.querySelector('.preview');
940 const nextButton = document.querySelector('.next');
941
942 let itemsToShow = getItemsToShow(); // Determine items to show based on screen width
943
944 const totalItems = items.length;
945 let currentIndex = 0;
946
947 function updateCarousel() {
948 const offset = -currentIndex * (100 / itemsToShow);
949 carousel.style.transform = `translateX(${offset}%)`;
950 }
951
952 function nextSlide() {
953 const remainingItems = totalItems - (currentIndex + itemsToShow);
954 if (remainingItems >= itemsToShow) {
955 currentIndex += itemsToShow;
956 } else if (remainingItems > 0) {
957 currentIndex += remainingItems;
958 } else {
959 currentIndex = 0;
960 }
961 updateCarousel();
962 }
963
964 function prevSlide() {
965 if (currentIndex > 0) {
966 currentIndex -= itemsToShow;
967 if (currentIndex < 0) {
968 currentIndex = 0;
969 }
970 } else {
971 currentIndex = totalItems - itemsToShow;
972 }
973 updateCarousel();
974 }
975
976 nextButton?.addEventListener('click', nextSlide);
977 prevButton?.addEventListener('click', prevSlide);
978
979 // Optional: Autoplay
980 let autoplay = false;
981 const autoplayInterval = 3000; // Change the time as needed
982 let autoplayId;
983
984 function startAutoplay() {
985 autoplayId = setInterval(nextSlide, autoplayInterval);
986 }
987
988 function stopAutoplay() {
989 clearInterval(autoplayId);
990 }
991
992 if (autoplay) {
993 startAutoplay();
994
995 // Stop autoplay on mouseover, resume on mouseout
996 carousel.addEventListener('mouseover', stopAutoplay);
997 carousel.addEventListener('mouseout', startAutoplay);
998 }
999
1000 // Handle responsive behavior
1001 window.addEventListener('resize', () => {
1002 itemsToShow = getItemsToShow();
1003 updateCarousel();
1004
1005 });
1006
1007 function getItemsToShow() {
1008 const width = window.innerWidth;
1009 if (width >= 1024) {
1010 return 3;
1011 } else if (width >= 768) {
1012 return 2;
1013 } else {
1014 return 1;
1015 }
1016 }
1017 });
1018
1019
1020
1021
1022 jQuery(window).on("elementor/frontend/init", function () {
1023
1024 var filterableGalleryHandler = function ($scope, $) {
1025
1026 // Get the Elementor unique selector for this widget
1027 let classes = $scope[0].className;
1028 let selectorEl = '.' + classes.split(' ').join('.');
1029
1030 const epElLoadMore = () => {
1031
1032 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>';
1033
1034 $('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').each(function () {
1035 let selctorEl = `.elementor-widget-embedpres_elementor [data-nftid='${$(this).data('nftid')}']`;
1036 let loadmorelabel = $(selctorEl).data('loadmorelabel');
1037 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
1038 $('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
1039
1040 $(selctorEl + " .nft-loadmore").click(function (e) {
1041 //change the text of the button
1042 $(this).html(loadmorelabel + spinicon);
1043
1044 //disable the button
1045 $(this).prop("disabled", true);
1046 //wait for 1 seconds
1047 setTimeout(function () {
1048 //change the text back
1049 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
1050 //enable the button
1051 $(selctorEl + " .nft-loadmore").prop("disabled", false);
1052 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
1053 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
1054 $(selctorEl + " .nft-loadmore").fadeOut("slow");
1055 }
1056 }, 500);
1057 });
1058 });
1059 };
1060
1061 if ($('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').length > 0) {
1062 epElLoadMore();
1063 }
1064
1065 // Content protection system function
1066 const unlockElSubmitHander = (perentSel, that) => {
1067 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
1068 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
1069 var post_id = jQuery(`input[name="post_id"]`).val();
1070 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
1071 const unlokingText = jQuery(that).data('unlocking-text');
1072
1073 var data = {
1074 'action': 'lock_content_form_handler',
1075 'client_id': ep_client_id,
1076 'password': password,
1077 'post_id': post_id,
1078 };
1079
1080 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
1081
1082 jQuery.post(embedpressFrontendData.ajaxurl, data, function (response) {
1083 if (response.success) {
1084 if (!response.embedHtml) {
1085 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
1086 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
1087 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
1088 }
1089 else {
1090 if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
1091 $('.ep-content-locked').removeClass('ep-content-locked');
1092 }
1093
1094 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
1095
1096 $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
1097
1098 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
1099 epGlobals.youtubeChannelGallery();
1100 }
1101
1102 if ($('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').length > 0) {
1103 epElLoadMore();
1104 }
1105 }
1106 } else {
1107 jQuery('#password-error_' + ep_client_id).html(response.form);
1108 jQuery('#password-error_' + ep_client_id).show();
1109 }
1110 }, 'json');
1111 }
1112
1113 // unlockElSubmitHander called for Elementor
1114 jQuery('.ep-elementor-content .password-form').submit(function (e) {
1115 e.preventDefault(); // Prevent the default form submission
1116 unlockElSubmitHander('ep-elementor-content', this);
1117 });
1118
1119
1120 const instaWrappers = document.querySelectorAll('.ep-embed-content-wrapper');
1121
1122 if (instaWrappers.length > 0) {
1123
1124 instaWrappers.forEach((wrapper) => {
1125 wrapper.classList.add('class-content-wrapper');
1126 const carouselId = wrapper.getAttribute('data-carouselid');
1127
1128 if (!carouselId) return;
1129
1130 let options = wrapper.getAttribute(`data-carousel-options`);
1131
1132 options = JSON.parse(options);
1133 const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`;
1134
1135
1136 if (options.arrows) {
1137 document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
1138 }
1139
1140 epGlobals.initCarousel(carouselSelector, options, carouselId);
1141
1142 });
1143 }
1144
1145
1146 const instaFeed = document.querySelector(`${selectorEl} .ose-instagram-feed`);
1147 const instaGallery = document.querySelector(`${selectorEl} .insta-gallery`);
1148 if (instaFeed) {
1149 epGlobals.initializeTabs(instaFeed);
1150 }
1151 if (instaGallery) {
1152 epGlobals.instaPopup(instaGallery);
1153
1154 $('.popup-close').click(function (e) {
1155 // Hide the popup by setting display to none
1156 $('.insta-popup').hide();
1157 $('.popup-container').remove();
1158 });
1159
1160 }
1161
1162 if ($('.elementor-widget-embedpres_elementor .ose-instagram-feed').length > 0) {
1163 epGlobals.instaLoadMore();
1164 }
1165
1166 };
1167
1168 const adsHandler = function ($scope, $) {
1169 window.epAdIndex = typeof (window.epAdIndex) === 'undefined' ? 0 : window.epAdIndex + 1;
1170 let classes = $scope[0].className;
1171 let classJoint = '.' + classes.split(' ').join('.');
1172 const selectorEl = document.querySelector(classJoint + ' [data-sponsored-id]');
1173
1174 if (jQuery('body').hasClass('elementor-editor-active') && embedpressFrontendData.isProPluginActive) {
1175 if (typeof adInitialization === 'function') {
1176 adInitialization(selectorEl, window.epAdIndex);
1177 }
1178 }
1179
1180 }
1181
1182 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
1183 elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
1184 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
1185 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", adsHandler);
1186 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", epGlobals.handlePosterImageLoad);
1187 });
1188
1189
1190 function presentationModeForIOS(iframes) {
1191 iframes?.forEach(function (iframe) {
1192 iframe.onload = function () {
1193 var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
1194 var button = iframeDoc?.querySelector('#presentationMode.presentationMode');
1195 button?.addEventListener('click', function () {
1196 iframe.classList.toggle('presentationModeEnabledIosDevice');
1197 });
1198 iframeDoc?.addEventListener('keydown', function (event) {
1199 if (event.keyCode === 27) {
1200 iframe.classList.remove('presentationModeEnabledIosDevice');
1201 }
1202 });
1203 };
1204 });
1205 }
1206
1207 function isIOSDevice() {
1208 return /iPhone|iPad|iPod/i.test(navigator.userAgent);
1209 }
1210
1211 if (isIOSDevice()) {
1212 var iframes = document.querySelectorAll('.embedpress-embed-document-pdf');
1213 presentationModeForIOS(iframes)
1214 }
1215
1216 document.addEventListener("DOMContentLoaded", epGlobals.handlePosterImageLoad);
1217
1218
1219 jQuery(document).ready(function ($) {
1220
1221 let currentIndex = -1;
1222
1223 function createVideoPopup() {
1224 const videoPopupHtml = `
1225 <div id="videoPopup" class="video-popup">
1226 <div class="video-popup-content">
1227 <span class="close">&times;</span>
1228 <div class="video-popup-inner-content">
1229 <iframe id="videoIframe" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
1230 <div id="videoDescription"></div>
1231 </div>
1232 <div class="popup-controls">
1233 <span id="prevVideo" class="nav-icon prev-icon">&#10094;</span>
1234 <span id="nextVideo" class="nav-icon next-icon">&#10095;</span>
1235 </div>
1236 </div>
1237 </div>`;
1238 return $(videoPopupHtml).appendTo('body');
1239 }
1240
1241 function openVideoPopup(index) {
1242 const items = $('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1243 if (index >= 0 && index < items.length) {
1244 // Remove any existing video popup before creating a new one
1245 $('#videoPopup').remove();
1246
1247 currentIndex = index;
1248 const videoId = $(items[currentIndex]).data('vid');
1249 const videoPopup = createVideoPopup();
1250 const videoIframe = videoPopup.find('#videoIframe');
1251 const videoDescriptionContainer = videoPopup.find('#videoDescription');
1252 const closeBtn = videoPopup.find('.close');
1253 const nextBtn = videoPopup.find('#nextVideo');
1254 const prevBtn = videoPopup.find('#prevVideo');
1255
1256 if (videoId) {
1257 fetchVideoData(videoId, videoIframe, videoDescriptionContainer);
1258 videoPopup.show();
1259 updateNavigationButtons(nextBtn, prevBtn, items);
1260
1261 closeBtn.on('click', () => {
1262 closeVideoPopup(videoPopup);
1263 });
1264
1265 $(window).on('click', function (event) {
1266 if ($(event.target).is(videoPopup)) {
1267 closeVideoPopup(videoPopup);
1268 }
1269 });
1270
1271 nextBtn.on('click', function () {
1272 if (currentIndex >= 0 && currentIndex < items.length - 1) {
1273 openVideoPopup(currentIndex + 1);
1274 }
1275 });
1276
1277 prevBtn.on('click', function () {
1278 if (currentIndex > 0) {
1279 openVideoPopup(currentIndex - 1);
1280 }
1281 });
1282 }
1283 }
1284 }
1285
1286
1287 function closeVideoPopup(videoPopup) {
1288 videoPopup.remove();
1289 currentIndex = -1; // Reset the index
1290 }
1291
1292 function updateNavigationButtons(nextBtn, prevBtn, items) {
1293 prevBtn.toggle(currentIndex > 0);
1294 nextBtn.toggle(currentIndex < items.length - 1);
1295 }
1296
1297 function fetchVideoData(videoId, videoIframe, videoDescriptionContainer) {
1298 const data = {
1299 action: 'fetch_video_description',
1300 vid: videoId
1301 };
1302
1303 $.post(embedpressFrontendData.ajaxurl, data, function (response) {
1304 if (response.success) {
1305 videoIframe.attr('src', `https://www.youtube.com/embed/${videoId}?autoplay=1`);
1306 videoDescriptionContainer.html(response.data.description);
1307 } else {
1308 console.error('Error fetching video data:', response?.data?.error);
1309 }
1310 });
1311 }
1312
1313 $(document).on('click', '.layout-grid .item, .layout-list .item, .layout-carousel .item', function () {
1314 const items = $('.layout-grid .item, .layout-list .item, .layout-carousel .item');
1315 const index = items.index(this);
1316 openVideoPopup(index);
1317 });
1318 });
1319 jQuery(document).ready(function ($) {
1320 let currentIndex = 0;
1321 const $photos = $('.photo-item');
1322
1323 function createPopupGooglePhotos() {
1324 if ($('#ep-popup-overlay').length === 0) {
1325 const photoPopup = `
1326 <div class="popup-overlay" id="ep-popup-overlay" style="display: none!important">
1327
1328 <div class="popup">
1329 <span class="close-btn" id="close-btn">
1330 <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>
1331 </span>
1332 <button class="prev-btn" id="prev-btn">
1333 <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>
1334 </button>
1335 <div id="popup-content" class="loading">
1336 <div class="photo-loader"></div>
1337 <img id="popup-image" src="" style="display:none;" loading="lazy" />
1338 </div>
1339 <button class="next-btn" id="next-btn">
1340 <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>
1341 </button>
1342 </div>
1343 </div>`;
1344 $('body').append(photoPopup);
1345
1346 // Loader spinner CSS (can be moved to your CSS file)
1347 const spinnerStyles = `
1348 <style>
1349 .popup #popup-content .photo-loader {
1350 display: none;
1351 }
1352 .popup #popup-content.loading .photo-loader {
1353 width: 40px;
1354 height: 40px;
1355 border: 4px solid #fff;
1356 border-top: 4px solid transparent;
1357 border-radius: 50%;
1358 animation: spin 1s linear infinite;
1359 margin: 40px auto;
1360 display: block;
1361 }
1362 @keyframes spin {
1363 0% { transform: rotate(0deg); }
1364 100% { transform: rotate(360deg); }
1365 }
1366 </style>`;
1367 $('head').append(spinnerStyles);
1368
1369 // Events
1370 $('#ep-popup-overlay').on('click', function (e) {
1371 if ($(e.target).is('#ep-popup-overlay') || $(e.target).is('.popup')) {
1372 $('#ep-popup-overlay').hide();
1373 }
1374 });
1375
1376 $('#close-btn').on('click', function () {
1377 $('#ep-popup-overlay').hide();
1378 });
1379
1380 $('#prev-btn').on('click', function () {
1381 currentIndex = (currentIndex - 1 + $photos.length) % $photos.length;
1382 updatePopupImage();
1383 });
1384
1385 $('#next-btn').on('click', function () {
1386 currentIndex = (currentIndex + 1) % $photos.length;
1387 updatePopupImage();
1388 });
1389 }
1390 }
1391
1392 function updatePopupImage() {
1393 const imgSrc = $photos.eq(currentIndex).find('img').attr('data-photo-src');
1394 const $popupImage = $('#popup-image');
1395 const $popupContent = $('#popup-content');
1396
1397 $popupContent.addClass('loading');
1398 $popupImage.hide();
1399
1400 const preload = new Image();
1401 preload.src = imgSrc;
1402
1403 preload.onload = function () {
1404 $popupImage.attr('src', imgSrc);
1405 $popupContent.removeClass('loading');
1406 $popupImage.fadeIn();
1407 };
1408 }
1409
1410 $('.photo-item').on('click', function () {
1411 currentIndex = $photos.index(this);
1412 createPopupGooglePhotos();
1413 updatePopupImage();
1414 $('#ep-popup-overlay').show();
1415 });
1416 });
1417
1418
1419 // pause audio/video
1420
1421 jQuery(document).ready(function () {
1422 const players = jQuery('.enabled-auto-pause audio, .enabled-auto-pause video');
1423
1424 function pauseAllExcept(currentPlayer) {
1425 players.each(function () {
1426 if (this !== currentPlayer[0]) {
1427 this.pause();
1428 }
1429 });
1430 }
1431
1432 players.on('play', function () {
1433 pauseAllExcept(jQuery(this));
1434 });
1435 });
1436
1437 // Meetup Events Load More
1438 jQuery(document).on('click', '.ep-load-more-button', function(e) {
1439 e.preventDefault();
1440
1441 const button = jQuery(this);
1442 const container = button.closest('.embedpress-meetup-events');
1443 const eventsContainer = container.find('.embedpress-meetup-events-list');
1444
1445 // Get data attributes
1446 const embedId = button.data('embed-id');
1447 const currentPage = parseInt(container.data('page')) || 1;
1448 const perPage = parseInt(container.data('per-page')) || 10;
1449 const nextPage = currentPage + 1;
1450
1451 // Show loading state
1452 const loadingText = button.find('.ep-load-more-text');
1453 const spinner = button.find('.ep-load-more-spinner');
1454 loadingText.hide();
1455 spinner.show();
1456 button.prop('disabled', true);
1457
1458 // Make AJAX request
1459 jQuery.ajax({
1460 url: embedpressFrontendData.ajaxurl,
1461 type: 'POST',
1462 data: {
1463 action: 'embedpress_meetup_load_more',
1464 nonce: embedpressFrontendData.nonce,
1465 embed_id: embedId,
1466 page: nextPage,
1467 per_page: perPage
1468 },
1469 success: function(response) {
1470 if (response.success) {
1471 // Append new events
1472 eventsContainer.append(response.data.html);
1473
1474 // Update page number
1475 container.data('page', nextPage);
1476
1477 // Trigger custom event for timezone conversion
1478 document.dispatchEvent(new Event('embedpress:meetup:loaded'));
1479
1480 // Hide button if no more events
1481 if (!response.data.has_more) {
1482 button.closest('.ep-events-load-more').fadeOut();
1483 } else {
1484 loadingText.show();
1485 spinner.hide();
1486 button.prop('disabled', false);
1487 }
1488 } else {
1489 alert(response.data.message || 'Error loading more events');
1490 loadingText.show();
1491 spinner.hide();
1492 button.prop('disabled', false);
1493 }
1494 },
1495 error: function() {
1496 alert('Error loading more events');
1497 loadingText.show();
1498 spinner.hide();
1499 button.prop('disabled', false);
1500 }
1501 });
1502 });
1503
1504