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