vendor
7 years ago
admin.js
2 years ago
ads.js
2 years ago
carousel.min.js
2 years ago
documents-viewer-script.js
3 years ago
front.js
2 years ago
glider.min.js
2 years ago
gutneberg-script.js
2 years 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.min.js
3 years 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
1055 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 | delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) { |
| 229 | const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages'); |
| 230 | const closestClass = event.target.closest('.ose-youtube').classList; |
| 231 | |
| 232 | const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`); |
| 233 | if (activePage) { |
| 234 | document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active'); |
| 235 | } |
| 236 | |
| 237 | |
| 238 | |
| 239 | var isNext = this.classList.contains("ep-next"); |
| 240 | |
| 241 | if (isNext) { |
| 242 | currentPage++; |
| 243 | } else { |
| 244 | currentPage--; |
| 245 | } |
| 246 | |
| 247 | var data = { |
| 248 | action: "youtube_rest_api", |
| 249 | playlistid: this.getAttribute("data-playlistid"), |
| 250 | pagetoken: this.getAttribute("data-pagetoken"), |
| 251 | pagesize: this.getAttribute("data-pagesize"), |
| 252 | currentpage: currentPage |
| 253 | }; |
| 254 | |
| 255 | var formBody = []; |
| 256 | for (var property in data) { |
| 257 | var encodedKey = encodeURIComponent(property); |
| 258 | var encodedValue = encodeURIComponent(data[property]); |
| 259 | formBody.push(encodedKey + "=" + encodedValue); |
| 260 | } |
| 261 | formBody = formBody.join("&"); |
| 262 | |
| 263 | var galleryWrapper = playerWrap.getElementsByClassName( |
| 264 | "ep-youtube__content__block" |
| 265 | ); |
| 266 | |
| 267 | playerWrap.setAttribute('data-current-page', currentPage); |
| 268 | |
| 269 | |
| 270 | let x = 1; |
| 271 | |
| 272 | sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) { |
| 273 | if (galleryWrapper && galleryWrapper[0] && request.responseText) { |
| 274 | var response = JSON.parse(request.responseText); |
| 275 | galleryWrapper[0].outerHTML = response.html; |
| 276 | |
| 277 | var currentPageNode = |
| 278 | galleryWrapper[0].getElementsByClassName("current-page"); |
| 279 | if (currentPageNode && currentPageNode[0]) { |
| 280 | currentPageNode[0].textContent = currentPage; |
| 281 | |
| 282 | } |
| 283 | } |
| 284 | }); |
| 285 | |
| 286 | const intervalID = setInterval(() => { |
| 287 | x++ |
| 288 | |
| 289 | if (playerWrap.querySelector('.ep-youtube__content__block')) { |
| 290 | const newNearestEpContentId = playerWrap |
| 291 | .querySelector('.ep-youtube__content__block') |
| 292 | .getAttribute('data-unique-id'); |
| 293 | |
| 294 | if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) { |
| 295 | playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active'); |
| 296 | nearestEpContentId = newNearestEpContentId; |
| 297 | clearInterval(intervalID); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | if (x > 100) { |
| 302 | clearInterval(intervalID); |
| 303 | } |
| 304 | }, 100); |
| 305 | |
| 306 | }); |
| 307 | } |
| 308 | |
| 309 | //Load more for OpenaSea collection |
| 310 | const epLoadMore = () => { |
| 311 | |
| 312 | $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () { |
| 313 | let selctorEl = `[data-nftid='${$(this).data('nftid')}']`; |
| 314 | |
| 315 | let loadmorelabel = $(selctorEl).data('loadmorelabel'); |
| 316 | let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor'); |
| 317 | |
| 318 | 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>`; |
| 319 | |
| 320 | $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show(); |
| 321 | $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex'); |
| 322 | |
| 323 | $(selctorEl + " .nft-loadmore").click(function (e) { |
| 324 | //change the text of the button |
| 325 | $(this).html(loadmorelabel + spinicon); |
| 326 | //disable the button |
| 327 | $(this).prop("disabled", true); |
| 328 | //wait for 1 seconds |
| 329 | setTimeout(function () { |
| 330 | //change the text back |
| 331 | $(selctorEl + " .nft-loadmore").text(loadmorelabel); |
| 332 | //enable the button |
| 333 | $(selctorEl + " .nft-loadmore").prop("disabled", false); |
| 334 | $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow"); |
| 335 | if ($(selctorEl + " .ep_nft_item:hidden").length == 0) { |
| 336 | $(selctorEl + " .nft-loadmore").fadeOut("slow"); |
| 337 | } |
| 338 | }, 500); |
| 339 | }); |
| 340 | }); |
| 341 | }; |
| 342 | |
| 343 | if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) { |
| 344 | epLoadMore(); |
| 345 | } |
| 346 | |
| 347 | // Content protection system function |
| 348 | const unlockSubmitHander = (perentSel, that) => { |
| 349 | var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val(); |
| 350 | var password = jQuery(`input[name="pass_${ep_client_id}"]`).val(); |
| 351 | var post_id = jQuery(`input[name="post_id"]`).val(); |
| 352 | const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val(); |
| 353 | const unlokingText = jQuery(that).data('unlocking-text'); |
| 354 | |
| 355 | |
| 356 | var data = { |
| 357 | 'action': 'lock_content_form_handler', |
| 358 | 'client_id': ep_client_id, |
| 359 | 'password': password, |
| 360 | 'post_id': post_id, |
| 361 | }; |
| 362 | |
| 363 | jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText); |
| 364 | |
| 365 | jQuery.post(eplocalize.ajaxurl, data, function (response) { |
| 366 | if (response.success) { |
| 367 | if (!response.embedHtml) { |
| 368 | |
| 369 | jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText); |
| 370 | jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val(''); |
| 371 | jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden'); |
| 372 | } |
| 373 | else { |
| 374 | jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml); |
| 375 | |
| 376 | if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) { |
| 377 | epGlobals.youtubeChannelGallery(); |
| 378 | } |
| 379 | |
| 380 | if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) { |
| 381 | epLoadMore(); |
| 382 | } |
| 383 | |
| 384 | // Custom player initialization when content protection enabled |
| 385 | document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').classList.remove('plyr-initialized'); |
| 386 | |
| 387 | initPlayer(document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper')); |
| 388 | |
| 389 | if (eplocalize.is_pro_plugin_active) { |
| 390 | const adIdEl = document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-sponsored-id]'); |
| 391 | adInitialization(adIdEl, adIdEl?.getAttribute('data-ad-index')); |
| 392 | } |
| 393 | |
| 394 | } |
| 395 | } else { |
| 396 | jQuery('#password-error_' + ep_client_id).html(response.form); |
| 397 | jQuery('#password-error_' + ep_client_id).show(); |
| 398 | } |
| 399 | }, 'json'); |
| 400 | } |
| 401 | |
| 402 | // unlockSubmitHander called for gutentberg |
| 403 | jQuery('.ep-gutenberg-content .password-form').submit(function (e) { |
| 404 | e.preventDefault(); // Prevent the default form submission |
| 405 | unlockSubmitHander('ep-gutenberg-content', this); |
| 406 | }); |
| 407 | |
| 408 | window.addEventListener('load', function (e) { |
| 409 | const urlParams = new URLSearchParams(window.location.search); |
| 410 | const hash = urlParams.get('hash'); |
| 411 | |
| 412 | // find the element with the matching id |
| 413 | const element = document.getElementById(hash); |
| 414 | |
| 415 | if (element) { |
| 416 | element.scrollIntoView({ behavior: 'smooth' }); |
| 417 | } |
| 418 | |
| 419 | }); |
| 420 | |
| 421 | // Get the insta-gallery container element |
| 422 | const getPopupTemplate = (instPost, hashtag = '', accountType) => { |
| 423 | |
| 424 | let instaPostData = JSON.parse(instPost); |
| 425 | |
| 426 | |
| 427 | 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>'; |
| 428 | |
| 429 | if (instaPostData.like_count > 0) { |
| 430 | 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>'; |
| 431 | } |
| 432 | |
| 433 | 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>'; |
| 434 | |
| 435 | 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>'; |
| 436 | |
| 437 | 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>'; |
| 438 | |
| 439 | |
| 440 | |
| 441 | const instaUserInfo = instPost.user_info; |
| 442 | |
| 443 | let getDate = new Date(instaPostData.timestamp); |
| 444 | getDate = getDate.toLocaleString('en-US', { day: 'numeric', month: 'short', year: 'numeric' }); |
| 445 | |
| 446 | let getTime = new Date(instaPostData.timestamp); |
| 447 | getTime = getTime.toLocaleString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' }); |
| 448 | |
| 449 | let captionText = instaPostData.caption ? instaPostData.caption : ''; |
| 450 | const tagRegex = /(#\w+)/g; |
| 451 | |
| 452 | const wrapTag = (match) => { |
| 453 | const tag = match.substring(1); // Remove the '#' character |
| 454 | const tagUrl = `https://www.instagram.com/explore/tags/${tag}`; |
| 455 | return `<span class="tag-wrapper"><a target="_blank" href="${tagUrl}">${match}</a></span>`; |
| 456 | }; |
| 457 | |
| 458 | captionText = captionText.replace(tagRegex, wrapTag); |
| 459 | |
| 460 | let carouselTemplate = ''; |
| 461 | if (instaPostData.media_type === 'CAROUSEL_ALBUM') { |
| 462 | carouselTemplate += `<div class="popup-carousel"><div class="cg-carousel__track js-carousel__track">`; |
| 463 | |
| 464 | instaPostData.children.data?.map((item) => { |
| 465 | if (item.media_type?.toLowerCase() === 'video') { |
| 466 | 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>`; |
| 467 | } |
| 468 | else { |
| 469 | carouselTemplate += `<img width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" src="${item.media_url || ''}" alt="${item.caption || ''}" />`; |
| 470 | } |
| 471 | }); |
| 472 | |
| 473 | carouselTemplate += `</div></div>`; |
| 474 | |
| 475 | carouselTemplate += `<div class="cg-carousel__btns"> |
| 476 | <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> |
| 477 | |
| 478 | <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> |
| 479 | </div>` |
| 480 | } |
| 481 | else { |
| 482 | if (instaPostData.media_type?.toLowerCase() === 'video') { |
| 483 | carouselTemplate += `<video width="630" class="popup-media-image" controls src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}"></video>`; |
| 484 | } |
| 485 | else { |
| 486 | carouselTemplate += `<img width="630" class="popup-media-image" src="${instaPostData.media_url || ''}" alt="${instaPostData.caption || ''}" />`; |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | let srcUrl = `https://www.instagram.com/${instaPostData.username}/`; |
| 491 | |
| 492 | if (hashtag) { |
| 493 | instaPostData.username = '#' + hashtag; |
| 494 | srcUrl = `https://www.instagram.com/explore/tags/${hashtag}/`; |
| 495 | } |
| 496 | |
| 497 | |
| 498 | let likeComments = ''; |
| 499 | |
| 500 | if (eplocalize.is_pro_plugin_active && accountType === 'business') { |
| 501 | if (instaPostData.show_likes_count == 'true') { |
| 502 | likeComments += ` |
| 503 | <div class="embedpress-inline popup-like-button"><a target="_blank" href="${instaPostData.permalink}">${likeIcon} ${instaPostData.like_count || 0}</a></div> |
| 504 | `; |
| 505 | } |
| 506 | if (instaPostData.show_comments_count == 'true') { |
| 507 | likeComments += ` |
| 508 | <div class="embedpress-inline"><a target="_blank" href="${instaPostData.permalink}">${commentsIcon} ${instaPostData.comments_count || 0}</a></div> |
| 509 | `; |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | |
| 514 | let followBtn = ''; |
| 515 | if (instaPostData.popup_follow_button_text == 'false') { |
| 516 | instaPostData.popup_follow_button_text = ''; |
| 517 | } |
| 518 | if (instaPostData.popup_follow_button == 'true' || instaPostData.popup_follow_button == 'yes') { |
| 519 | followBtn = `<div class="insta-followbtn"> |
| 520 | <a target="_new" href="${srcUrl}" type="button" class="btn btn-primary">${instaPostData.popup_follow_button_text}</a> |
| 521 | </div>`; |
| 522 | } |
| 523 | console.log(instaPostData); |
| 524 | |
| 525 | let popupHtml = ''; |
| 526 | popupHtml += ` |
| 527 | <div class="popup-container"> |
| 528 | <div class="popup-md-9 white"> |
| 529 | <div class="embedpress-popup-block embedpress-popup-img" id="post-${instaPostData.id}"> |
| 530 | ${carouselTemplate} |
| 531 | </div> |
| 532 | </div> |
| 533 | <div class="popup-md-3 red"> |
| 534 | <div class="embedpress-popup-block embedpress-popup-info"> |
| 535 | <div class="embedpress-popup-header"> |
| 536 | <div class="embedpress-popup-header-img"> <a target="_blank" href="${srcUrl}" |
| 537 | target="_blank" class="embedpress-href"> |
| 538 | <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> |
| 539 | </a> |
| 540 | </div> |
| 541 | ${followBtn} |
| 542 | </div> |
| 543 | <div class="embedpress-popup-text">${captionText}</div> |
| 544 | <div class="embedpress-popup-stats"> |
| 545 | ${likeComments} |
| 546 | <div class="embedpress-inline"> |
| 547 | <div class="embedpress-popup-share-buttons"> <a |
| 548 | href="https://www.facebook.com/sharer/sharer.php?u=${instaPostData.permalink}" target="_blank"> |
| 549 | <span class="dashicons dashicons-facebook"></span></a> <a |
| 550 | href="https://twitter.com/intent/tweet?url=${instaPostData.permalink}" |
| 551 | target="_blank"><span> |
| 552 | <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> |
| 553 | </span></a> |
| 554 | <a href="https://www.linkedin.com/shareArticle?mini=true&url=${instaPostData.permalink}" |
| 555 | target="_blank"><span class="dashicons dashicons-linkedin"></span></a> <a |
| 556 | href="https://pinterest.com/pin/create/button/?url=${instaPostData.permalink}" |
| 557 | target="_blank"><span class="dashicons dashicons-pinterest"></span></a></div> |
| 558 | <div class="embedpress-href embedpress-popup-share">${shareIcon}</div> |
| 559 | </div><div class="embedpress-inline embedpress-popup-instagram-buttons"><a |
| 560 | href="${instaPostData.permalink}" target="_blank" |
| 561 | class="embedpress-href">${instaIcon}</a></div> |
| 562 | </div> |
| 563 | |
| 564 | </div> |
| 565 | </div> |
| 566 | </div> |
| 567 | `; |
| 568 | |
| 569 | // INIT CAROUSEL |
| 570 | |
| 571 | |
| 572 | return popupHtml; |
| 573 | } |
| 574 | |
| 575 | // Add a click event listener to the insta-gallery container |
| 576 | epGlobals.instaPopup = (container) => { |
| 577 | container?.addEventListener('click', function (event) { |
| 578 | // Check if the clicked element has the class insta-gallery-item |
| 579 | const instaItem = event.target.closest('.insta-gallery-item'); |
| 580 | |
| 581 | if (instaItem) { |
| 582 | |
| 583 | const postData = instaItem.dataset.postdata; |
| 584 | |
| 585 | const postid = instaItem.getAttribute('data-insta-postid'); |
| 586 | const accountType = container?.closest('.instagram-container')?.getAttribute('data-connected-acc-type'); |
| 587 | |
| 588 | let hashtag = ''; |
| 589 | |
| 590 | if (instaItem.closest('.instagram-container').getAttribute('data-hashtag')) { |
| 591 | hashtag = instaItem?.closest('.instagram-container')?.getAttribute('data-hashtag'); |
| 592 | } |
| 593 | |
| 594 | const closestPopup = event.target.closest('.ose-instagram-feed')?.querySelector('.insta-popup'); |
| 595 | |
| 596 | if (closestPopup) { |
| 597 | closestPopup.style.display = 'block'; |
| 598 | } |
| 599 | |
| 600 | |
| 601 | var feedElement = event.target.closest('.ose-instagram-feed'); |
| 602 | if (feedElement) { |
| 603 | var popupElement = feedElement.querySelector('.popup-is-initialized'); |
| 604 | if (popupElement) { |
| 605 | popupElement.innerHTML = getPopupTemplate(postData, hashtag, accountType); |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | if (!document.querySelector(`#post-${postid}`)?.classList.contains('carousel-is-initialized')) { |
| 610 | const carousel = new CgCarousel(`#post-${postid}`, { slidesPerView: 1, loop: true }, {}); |
| 611 | |
| 612 | const next = document.querySelector(`#post-${postid} .js-carousel__next-1`); |
| 613 | next?.addEventListener('click', () => carousel.next()); |
| 614 | |
| 615 | const prev = document.querySelector(`#post-${postid} .js-carousel__prev-1`); |
| 616 | prev?.addEventListener('click', () => carousel.prev()); |
| 617 | |
| 618 | document.querySelector(`#post-${postid}`)?.classList.add('carousel-is-initialized'); |
| 619 | } |
| 620 | |
| 621 | } |
| 622 | }); |
| 623 | } |
| 624 | |
| 625 | |
| 626 | const instaContainers = document.querySelectorAll('.embedpress-gutenberg-wrapper .insta-gallery'); |
| 627 | if (instaContainers.length > 0) { |
| 628 | instaContainers.forEach((container) => { |
| 629 | epGlobals.instaPopup(container); |
| 630 | }); |
| 631 | } |
| 632 | |
| 633 | $('.popup-close').click(function (e) { |
| 634 | // Hide the popup by setting display to none |
| 635 | $('.insta-popup').hide(); |
| 636 | $('.popup-container').remove(); |
| 637 | }); |
| 638 | |
| 639 | $(document).on('click', function (e) { |
| 640 | if (e.target.classList.contains('popup-wrapper')) { |
| 641 | $('.insta-popup').hide(); |
| 642 | $('.popup-container').remove(); |
| 643 | } |
| 644 | }); |
| 645 | |
| 646 | |
| 647 | const instafeeds = document.querySelectorAll('.ose-instagram-feed'); |
| 648 | |
| 649 | epGlobals.initializeTabs = (containerEl) => { |
| 650 | |
| 651 | // Initial tab selection |
| 652 | showItems('ALL'); |
| 653 | |
| 654 | containerEl.addEventListener('click', function (event) { |
| 655 | const clickedElement = event.target; |
| 656 | if (!clickedElement) { |
| 657 | return; // No element clicked, ignore the event |
| 658 | } |
| 659 | |
| 660 | if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'VIDEO' || clickedElement.getAttribute('data-media-type') === 'CAROUSEL_ALBUM')) { |
| 661 | containerEl.querySelector('.load-more-button-container').style.display = 'none'; |
| 662 | } |
| 663 | else if (containerEl.querySelector('.load-more-button-container') && (clickedElement.getAttribute('data-media-type') === 'ALL')) { |
| 664 | containerEl.querySelector('.load-more-button-container').style.display = 'flex'; |
| 665 | } |
| 666 | |
| 667 | // Handle tab click |
| 668 | if (clickedElement.matches('.tabs li')) { |
| 669 | if (clickedElement.classList.contains('active')) { |
| 670 | return; |
| 671 | } else { |
| 672 | const mediaType = clickedElement.getAttribute('data-media-type'); |
| 673 | showItems(mediaType); |
| 674 | |
| 675 | const tabs = containerEl.querySelectorAll('.tabs li'); |
| 676 | tabs.forEach(t => t.classList.remove('active')); |
| 677 | clickedElement.classList.add('active'); |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | }); |
| 682 | |
| 683 | function showItems(mediaType) { |
| 684 | const items = containerEl.getElementsByClassName('insta-gallery-item'); |
| 685 | for (let i = 0; i < items.length; i++) { |
| 686 | const item = items[i]; |
| 687 | if (mediaType === 'ALL' || item.getAttribute('data-media-type') === mediaType) { |
| 688 | item.style.display = 'block'; |
| 689 | } else { |
| 690 | item.style.display = 'none'; |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | epGlobals.instaLoadMore = () => { |
| 697 | // Unbind any previously bound click event to avoid multiple bindings |
| 698 | $('.insta-load-more-button').off('click').on('click', function (e) { |
| 699 | const that = $(this); |
| 700 | const loadmoreBtn = that.closest('.load-more-button-container'); |
| 701 | const loadmoreKey = loadmoreBtn.data('loadmorekey'); |
| 702 | const connectedAccount = that.closest('.instagram-container').data('connected-acc-type'); |
| 703 | const feedType = that.closest('.instagram-container').data('feed-type'); |
| 704 | const hashtagId = that.closest('.instagram-container').data('hashtag-id'); |
| 705 | const userId = that.closest('.instagram-container').data('uid'); |
| 706 | let loadedPosts = loadmoreBtn.data('loaded-posts') || 0; |
| 707 | let postsPerPage = loadmoreBtn.data('posts-per-page') || 0; |
| 708 | const params = JSON.stringify(that.closest('.instagram-container').data('params')); |
| 709 | |
| 710 | |
| 711 | const instaContainer = that.closest('.instagram-container'); |
| 712 | |
| 713 | 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>`; |
| 714 | |
| 715 | // Check if no spinicon exists |
| 716 | if (instaContainer.find('.insta-loadmore-spinicon').length === 0) { |
| 717 | that.append(spinicon); |
| 718 | } |
| 719 | |
| 720 | that.attr('disabled', true); |
| 721 | |
| 722 | var data = { |
| 723 | 'action': 'loadmore_data_handler', |
| 724 | 'user_id': userId, |
| 725 | 'loaded_posts': loadedPosts, |
| 726 | 'posts_per_page': postsPerPage, |
| 727 | 'feed_type': feedType, |
| 728 | 'connected_account_type': connectedAccount, |
| 729 | 'loadmore_key': loadmoreKey, |
| 730 | 'params': params, |
| 731 | '_nonce': eplocalize.nonce |
| 732 | }; |
| 733 | |
| 734 | if (feedType === 'hashtag_type') { |
| 735 | data.hashtag_id = hashtagId; |
| 736 | } |
| 737 | |
| 738 | jQuery.post(eplocalize.ajaxurl, data, function (response) { |
| 739 | if (response.total_feed_posts >= response.next_post_index) { |
| 740 | var $responseHtml = $(response.html); |
| 741 | |
| 742 | instaContainer.find('.insta-gallery').append($responseHtml); |
| 743 | that.removeAttr('disabled'); |
| 744 | |
| 745 | instaContainer.find('.insta-loadmore-spinicon').remove(); |
| 746 | |
| 747 | loadedPosts = response.next_post_index; |
| 748 | |
| 749 | loadmoreBtn.data('loaded-posts', loadedPosts); |
| 750 | |
| 751 | // After loading more items, reinitialize the tabs for the specific container |
| 752 | const containerEl = loadmoreBtn.closest('.ose-instagram-feed')[0]; |
| 753 | epGlobals.initializeTabs(containerEl); |
| 754 | |
| 755 | if (response.total_feed_posts === response.next_post_index) { |
| 756 | loadmoreBtn.remove(); |
| 757 | } |
| 758 | } else { |
| 759 | loadmoreBtn.remove(); |
| 760 | } |
| 761 | }); |
| 762 | }); |
| 763 | } |
| 764 | |
| 765 | |
| 766 | if (instafeeds.length > 0) { |
| 767 | instafeeds.forEach(function (feed) { |
| 768 | epGlobals.initializeTabs(feed); |
| 769 | }); |
| 770 | } |
| 771 | |
| 772 | if ($('.embedpress-gutenberg-wrapper .ose-instagram-feed').length > 0) { |
| 773 | epGlobals.instaLoadMore(); |
| 774 | } |
| 775 | |
| 776 | $(document).on({ |
| 777 | mouseenter: function () { |
| 778 | $('.embedpress-popup-share-buttons').addClass('show'); |
| 779 | }, |
| 780 | mouseleave: function () { |
| 781 | var buttons = $('.embedpress-popup-share-buttons'); |
| 782 | setTimeout(function () { |
| 783 | if (!buttons.is(':hover')) buttons.removeClass('show'); |
| 784 | }, 200); |
| 785 | } |
| 786 | }, '.embedpress-href.embedpress-popup-share, .embedpress-popup-share-buttons'); |
| 787 | |
| 788 | $(document).on({ |
| 789 | mouseenter: function () { |
| 790 | $(this).addClass('show'); |
| 791 | }, |
| 792 | mouseleave: function () { |
| 793 | $(this).removeClass('show'); |
| 794 | } |
| 795 | }, '.embedpress-popup-share-buttons'); |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | })(jQuery); |
| 802 | |
| 803 | |
| 804 | |
| 805 | document.addEventListener('DOMContentLoaded', function () { |
| 806 | |
| 807 | epGlobals.initCarousel = (carouselSelector, options, carouselId) => { |
| 808 | |
| 809 | const carouselOptions = { |
| 810 | slidesPerView: options.slideshow, |
| 811 | spacing: options.spacing, |
| 812 | loop: options.loop, |
| 813 | autoplay: options.autoplay, |
| 814 | transitionSpeed: options.transitionspeed, |
| 815 | autoplaySpeed: options.autoplayspeed, |
| 816 | arrows: options.arrows, |
| 817 | breakpoints: { |
| 818 | 768: { |
| 819 | slidesPerView: parseInt(options.slideshow) - 1 |
| 820 | }, |
| 821 | 1024: { |
| 822 | slidesPerView: parseInt(options.slideshow) |
| 823 | } |
| 824 | } |
| 825 | }; |
| 826 | |
| 827 | // INIT CAROUSEL |
| 828 | const carousel = new CgCarousel(carouselSelector, carouselOptions, {}); |
| 829 | |
| 830 | // Navigation |
| 831 | const next = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__next-1`); |
| 832 | next.addEventListener('click', () => carousel.next()); |
| 833 | |
| 834 | const prev = document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__prev-1`); |
| 835 | prev.addEventListener('click', () => carousel.prev()); |
| 836 | } |
| 837 | |
| 838 | const instaWrappers = document.querySelectorAll('.ep-embed-content-wraper'); |
| 839 | |
| 840 | if (instaWrappers.length > 0) { |
| 841 | instaWrappers.forEach((wrapper) => { |
| 842 | const carouselId = wrapper.getAttribute('data-carouselid'); |
| 843 | |
| 844 | if (!carouselId) return; |
| 845 | |
| 846 | let options = wrapper.getAttribute(`data-carousel-options`); |
| 847 | |
| 848 | options = JSON.parse(options); |
| 849 | const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`; |
| 850 | |
| 851 | if (options.arrows) { |
| 852 | document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden'); |
| 853 | } |
| 854 | |
| 855 | epGlobals.initCarousel(carouselSelector, options, carouselId); |
| 856 | |
| 857 | }); |
| 858 | } |
| 859 | |
| 860 | |
| 861 | |
| 862 | }); |
| 863 | |
| 864 | |
| 865 | |
| 866 | jQuery(window).on("elementor/frontend/init", function () { |
| 867 | |
| 868 | var filterableGalleryHandler = function ($scope, $) { |
| 869 | |
| 870 | // Get the Elementor unique selector for this widget |
| 871 | let classes = $scope[0].className; |
| 872 | let selectorEl = '.' + classes.split(' ').join('.'); |
| 873 | |
| 874 | const epElLoadMore = () => { |
| 875 | |
| 876 | 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>'; |
| 877 | |
| 878 | $('.elementor-widget-container .ep-nft-gallery-wrapper').each(function () { |
| 879 | let selctorEl = `.elementor-widget-container [data-nftid='${$(this).data('nftid')}']`; |
| 880 | let loadmorelabel = $(selctorEl).data('loadmorelabel'); |
| 881 | $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show(); |
| 882 | $('.elementor-widget-container .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex'); |
| 883 | |
| 884 | $(selctorEl + " .nft-loadmore").click(function (e) { |
| 885 | //change the text of the button |
| 886 | $(this).html(loadmorelabel + spinicon); |
| 887 | |
| 888 | //disable the button |
| 889 | $(this).prop("disabled", true); |
| 890 | //wait for 1 seconds |
| 891 | setTimeout(function () { |
| 892 | //change the text back |
| 893 | $(selctorEl + " .nft-loadmore").text(loadmorelabel); |
| 894 | //enable the button |
| 895 | $(selctorEl + " .nft-loadmore").prop("disabled", false); |
| 896 | $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow"); |
| 897 | if ($(selctorEl + " .ep_nft_item:hidden").length == 0) { |
| 898 | $(selctorEl + " .nft-loadmore").fadeOut("slow"); |
| 899 | } |
| 900 | }, 500); |
| 901 | }); |
| 902 | }); |
| 903 | }; |
| 904 | |
| 905 | if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) { |
| 906 | epElLoadMore(); |
| 907 | } |
| 908 | |
| 909 | // Content protection system function |
| 910 | const unlockElSubmitHander = (perentSel, that) => { |
| 911 | var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val(); |
| 912 | var password = jQuery(`input[name="pass_${ep_client_id}"]`).val(); |
| 913 | var post_id = jQuery(`input[name="post_id"]`).val(); |
| 914 | const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val(); |
| 915 | const unlokingText = jQuery(that).data('unlocking-text'); |
| 916 | |
| 917 | var data = { |
| 918 | 'action': 'lock_content_form_handler', |
| 919 | 'client_id': ep_client_id, |
| 920 | 'password': password, |
| 921 | 'post_id': post_id, |
| 922 | }; |
| 923 | |
| 924 | jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText); |
| 925 | |
| 926 | jQuery.post(eplocalize.ajaxurl, data, function (response) { |
| 927 | if (response.success) { |
| 928 | if (!response.embedHtml) { |
| 929 | jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText); |
| 930 | jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val(''); |
| 931 | jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden'); |
| 932 | } |
| 933 | else { |
| 934 | if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) { |
| 935 | $('.ep-content-locked').removeClass('ep-content-locked'); |
| 936 | } |
| 937 | |
| 938 | jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml); |
| 939 | |
| 940 | $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled'); |
| 941 | |
| 942 | if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) { |
| 943 | epGlobals.youtubeChannelGallery(); |
| 944 | } |
| 945 | |
| 946 | if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) { |
| 947 | epElLoadMore(); |
| 948 | } |
| 949 | } |
| 950 | } else { |
| 951 | jQuery('#password-error_' + ep_client_id).html(response.form); |
| 952 | jQuery('#password-error_' + ep_client_id).show(); |
| 953 | } |
| 954 | }, 'json'); |
| 955 | } |
| 956 | |
| 957 | // unlockElSubmitHander called for Elementor |
| 958 | jQuery('.ep-elementor-content .password-form').submit(function (e) { |
| 959 | e.preventDefault(); // Prevent the default form submission |
| 960 | unlockElSubmitHander('ep-elementor-content', this); |
| 961 | }); |
| 962 | |
| 963 | |
| 964 | const instaWrappers = document.querySelectorAll('.ep-embed-content-wraper'); |
| 965 | |
| 966 | if (instaWrappers.length > 0) { |
| 967 | instaWrappers.forEach((wrapper) => { |
| 968 | const carouselId = wrapper.getAttribute('data-carouselid'); |
| 969 | |
| 970 | if (!carouselId) return; |
| 971 | |
| 972 | let options = wrapper.getAttribute(`data-carousel-options`); |
| 973 | |
| 974 | options = JSON.parse(options); |
| 975 | const carouselSelector = `[data-carouselid="${carouselId}"] .embedpress-insta-container`; |
| 976 | |
| 977 | if (options.arrows) { |
| 978 | document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden'); |
| 979 | } |
| 980 | |
| 981 | epGlobals.initCarousel(carouselSelector, options, carouselId); |
| 982 | |
| 983 | }); |
| 984 | } |
| 985 | |
| 986 | const instaFeed = document.querySelector(`${selectorEl} .ose-instagram-feed`); |
| 987 | const instaGallery = document.querySelector(`${selectorEl} .insta-gallery`); |
| 988 | if (instaFeed) { |
| 989 | epGlobals.initializeTabs(instaFeed); |
| 990 | } |
| 991 | if (instaGallery) { |
| 992 | epGlobals.instaPopup(instaGallery); |
| 993 | |
| 994 | $('.popup-close').click(function (e) { |
| 995 | // Hide the popup by setting display to none |
| 996 | $('.insta-popup').hide(); |
| 997 | $('.popup-container').remove(); |
| 998 | }); |
| 999 | |
| 1000 | } |
| 1001 | |
| 1002 | if ($('.elementor-widget-container .ose-instagram-feed').length > 0) { |
| 1003 | epGlobals.instaLoadMore(); |
| 1004 | } |
| 1005 | |
| 1006 | }; |
| 1007 | |
| 1008 | const adsHandler = function ($scope, $) { |
| 1009 | window.epAdIndex = typeof (window.epAdIndex) === 'undefined' ? 0 : window.epAdIndex + 1; |
| 1010 | let classes = $scope[0].className; |
| 1011 | let classJoint = '.' + classes.split(' ').join('.'); |
| 1012 | const selectorEl = document.querySelector(classJoint + ' [data-sponsored-id]'); |
| 1013 | |
| 1014 | if (jQuery('body').hasClass('elementor-editor-active') && eplocalize.is_pro_plugin_active) { |
| 1015 | adInitialization(selectorEl, window.epAdIndex); |
| 1016 | } |
| 1017 | |
| 1018 | } |
| 1019 | |
| 1020 | elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler); |
| 1021 | elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler); |
| 1022 | elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler); |
| 1023 | elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", adsHandler); |
| 1024 | elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", epGlobals.handlePosterImageLoad); |
| 1025 | }); |
| 1026 | |
| 1027 | |
| 1028 | function presentationModeForIOS(iframes) { |
| 1029 | iframes?.forEach(function (iframe) { |
| 1030 | iframe.onload = function () { |
| 1031 | var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; |
| 1032 | var button = iframeDoc?.querySelector('#presentationMode'); |
| 1033 | button?.addEventListener('click', function () { |
| 1034 | iframe.classList.toggle('presentationModeEnabledIosDevice'); |
| 1035 | }); |
| 1036 | iframeDoc?.addEventListener('keydown', function (event) { |
| 1037 | if (event.keyCode === 27) { |
| 1038 | iframe.classList.remove('presentationModeEnabledIosDevice'); |
| 1039 | } |
| 1040 | }); |
| 1041 | }; |
| 1042 | }); |
| 1043 | } |
| 1044 | |
| 1045 | function isIOSDevice() { |
| 1046 | return /iPhone|iPad|iPod/i.test(navigator.userAgent); |
| 1047 | } |
| 1048 | |
| 1049 | if (isIOSDevice()) { |
| 1050 | var iframes = document.querySelectorAll('.embedpress-embed-document-pdf'); |
| 1051 | presentationModeForIOS(iframes) |
| 1052 | } |
| 1053 | |
| 1054 | document.addEventListener("DOMContentLoaded", epGlobals.handlePosterImageLoad); |
| 1055 |