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