window.CgCarousel=class{constructor(t,i={},e=[]){this.container=document.querySelector(t),this.container&&(this.slidesSelector=i.slidesSelector||".js-carousel__slide",this.trackSelector=i.trackSelector||".js-carousel__track",this.slides=[],this.track=this.container.querySelector(this.trackSelector),this.slidesLength=0,this.currentBreakpoint=void 0,this.breakpoints=i.breakpoints||{},this.hooks=e,this.initialOptions={loop:i.loop||!1,autoplay:i.autoplay||!1,autoplaySpeed:i.autoplaySpeed||3e3,transitionSpeed:i.transitionSpeed||650,slidesPerView:i.slidesPerView||1,spacing:i.spacing||0},this.options=this.initialOptions,this.animationStart=void 0,this.animation=void 0,this.animationCurrentTrans=0,this.animationIndex=0,window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame,this.autoplayInterval=void 0,this.isButtonRightDisabled=!1,this.isButtonLeftDisabled=!1,this.currentIndex=0,this.maxIndex=0,this.isInfinite=!1,this.isPrevInfinite=!1,this.swipeStartX=void 0,this.swipeStartY=void 0,this.swipeThreshold=100,this.swipeRestraint=100,this.swipeDir=void 0,this.track&&(this.addEventListeners(),this.initCarousel()))}hook(t){this.hooks[t]&&this.hooks[t](this)}isTouchableDevice(){return window.matchMedia("(pointer: coarse)").matches}handleSwipe(){switch(this.swipeDir){case"top":case"bottom":default:break;case"left":this.next();break;case"right":this.prev()}}onSwipeStart(t){if(!this.isTouchableDevice()||!t.changedTouches)return;const i=t.changedTouches[0];this.swipeStartX=i.pageX,this.swipeStartY=i.pageY}setSwipeDirection(t){const i=t.changedTouches[0],e=i.pageX-this.swipeStartX,s=i.pageY-this.swipeStartY;Math.abs(e)>=this.swipeThreshold&&Math.abs(s)<=this.swipeRestraint?this.swipeDir=e<0?"left":"right":Math.abs(s)>=this.swipeThreshold&&Math.abs(e)<=this.swipeRestraint&&(this.swipeDir=s<0?"up":"down")}onSwipeMove(t){this.isTouchableDevice()&&t.changedTouches&&(this.setSwipeDirection(t),["left","right"].includes(this.swipeDir)&&t.cancelable&&t.preventDefault())}onSwipeEnd(t){this.isTouchableDevice()&&t.changedTouches&&(this.setSwipeDirection(t),this.handleSwipe())}addEventListeners(){window.addEventListener("orientationchange",(()=>this.onResize())),window.addEventListener("resize",(()=>this.onResize())),this.container.addEventListener("touchstart",(t=>this.onSwipeStart(t)),{passive:!0}),this.container.addEventListener("touchmove",(t=>this.onSwipeMove(t)),!1),this.container.addEventListener("touchend",(t=>this.onSwipeEnd(t)),{passive:!0})}onResize(){this.checkBreakpoint()&&this.buildCarousel(),this.hook("resized")}setUpAutoplay(){this.options.autoplay&&(clearInterval(this.autoplayInterval),this.autoplayInterval=setInterval((()=>this.next()),this.options.autoplaySpeed))}checkBreakpoint(){if(!this.breakpoints)return;const t=Object.keys(this.breakpoints).reverse().find((t=>{const i=`(min-width: ${t}px)`;return window.matchMedia(i).matches}));if(this.currentBreakpoint===t)return;this.currentBreakpoint=t;const i=t?this.breakpoints[t]:this.initialOptions;return this.options={...this.initialOptions,...i},!0}setButtonsVisibility(){this.isButtonLeftDisabled=!this.options.loop&&0===this.currentIndex,this.isButtonRightDisabled=!this.options.loop&&this.currentIndex===this.maxIndex-1}clearCarouselStyles(){["grid-auto-columns","gap","transition","left"].map((t=>this.track.style.removeProperty(t)));const t=["grid-column-start","grid-column-end","grid-row-start","grid-row-end","left"];this.slides.forEach((i=>{t.map((t=>i.style.removeProperty(t)))}))}setCarouselStyles(){if(!this.slides)return;const t=this.options.slidesPerView,i=100/t,e=this.options.spacing*(t-1)/t;this.track.style.gridAutoColumns=`calc(${i}% - ${e}px)`,this.track.style.gridGap=`${this.options.spacing}px`,this.track.style.left=0}buildCarousel(){this.maxIndex=Math.ceil(this.slidesLength/this.options.slidesPerView),this.clearCarouselStyles(),this.setCarouselStyles(),this.setButtonsVisibility(),this.setUpAutoplay(),this.currentIndex=0,this.hook("built")}initCarousel(){this.slides=this.container.querySelectorAll(this.slidesSelector),this.slidesLength=this.slides?.length,this.checkBreakpoint(),this.buildCarousel(),this.hook("created")}onAnimationEnd(){const t=this.options.spacing*this.animationIndex,i=-100*this.animationIndex;this.track.style.left=`calc(${i}% - ${t}px)`,this.animationCurrentTrans=i,this.animation=null,this.isInfinite&&this.clearInfinite(),this.isPrevInfinite&&this.clearPrevInfinite()}moveAnimateAbort(){this.animation&&(window.cancelAnimationFrame(this.animation),this.onAnimationEnd())}animateLeft(t,i,e,s){const n=t-this.animationStart,o=(r=n/s,1-Math.pow(1-r,5));var r;const a=(i*o+this.animationCurrentTrans*(1-o)).toFixed(2);this.track.style.left=`calc(${a}% - ${e}px)`,n>=s?this.onAnimationEnd():this.animation=window.requestAnimationFrame((t=>{this.animateLeft(t,i,e,s)}))}moveSlide(t,i){this.moveAnimateAbort();const e=this.options.spacing*t,s=-100*t;this.animation=window.requestAnimationFrame((i=>{t===this.maxIndex&&this.setInfinite(),-1===t&&this.setPrevInfinite(),this.animationStart=i,this.animationIndex=this.currentIndex,this.animateLeft(i,s,e,this.options.transitionSpeed)})),this.currentIndex=i,this.setUpAutoplay(),this.setButtonsVisibility(),this.hook("moved")}setInfinite(){this.isInfinite=!0;const t=this.options.slidesPerView*this.maxIndex;for(let i=0;i<this.options.slidesPerView;i++){this.slides[i].style.left=`calc((100% * ${t}) + (${this.options.spacing}px * ${t}))`}}clearInfinite(){this.isInfinite=!1,this.track.style.left=`calc(${-100*this.currentIndex}% - ${this.options.spacing*this.currentIndex}px)`,this.slides.forEach(((t,i)=>{i>=this.options.slidesPerView||t.style.removeProperty("left")}))}next(){const t=this.currentIndex===this.maxIndex-1?0:this.currentIndex+1;!this.options.loop&&t<this.currentIndex||(t<this.currentIndex?this.moveSlide(this.currentIndex+1,t):this.moveSlide(t,t))}setPrevInfinite(){this.isPrevInfinite=!0;const t=this.options.slidesPerView*this.maxIndex,i=t-this.options.slidesPerView;for(let e=this.slides.length-1;e>=0;e--){if(e<i)return;this.slides[e].style.left=`calc((-100% * ${t}) - (${this.options.spacing}px * ${t}))`}}clearPrevInfinite(){this.isPrevInfinite=!1,this.track.style.left=`calc(${-100*this.currentIndex}% - ${this.options.spacing*this.currentIndex}px)`,this.slides.forEach(((t,i)=>{t.style.removeProperty("left")}))}prev(){const t=0===this.currentIndex?this.maxIndex-1:this.currentIndex-1;!this.options.loop&&t>this.currentIndex||(t>this.currentIndex?this.moveSlide(this.currentIndex-1,t):this.moveSlide(t,t))}moveToSlide(t){t!==this.currentIndex&&this.moveSlide(t,t)}getSlides(){return this.slides}getCurrentIndex(){return this.currentIndex}getOptions(){return this.options}getPageSize(){return this.maxIndex}};
(function (root, factory){
if(typeof define==="function"&&define.amd){
define([], factory);
}else if(typeof module==="object"&&module.exports){
module.exports=factory();
}else{
root.PDFObject=factory();
}}(this, function (){
"use strict";
if(typeof window==="undefined" ||
window.navigator===undefined ||
window.navigator.userAgent===undefined ||
window.navigator.mimeTypes===undefined){
return false;
}
let pdfobjectversion="2.2.6";
let nav=window.navigator;
let ua=window.navigator.userAgent;
let isIE=("ActiveXObject" in window);
let isModernBrowser=(window.Promise!==undefined);
let supportsPdfMimeType=(nav.mimeTypes["application/pdf"]!==undefined);
let isSafariIOSDesktopMode=(nav.platform!==undefined &&
nav.platform==="MacIntel" &&
nav.maxTouchPoints!==undefined &&
nav.maxTouchPoints > 1);
let isMobileDevice=(isSafariIOSDesktopMode||/Mobi|Tablet|Android|iPad|iPhone/.test(ua));
let isSafariDesktop=(!isMobileDevice &&
nav.vendor!==undefined &&
/Apple/.test(nav.vendor) &&
/Safari/.test(ua));
let isFirefoxWithPDFJS=(!isMobileDevice&&/irefox/.test(ua)&&ua.split("rv:").length > 1) ? (parseInt(ua.split("rv:")[1].split(".")[0], 10) > 18):false;
let createAXO=function (type){
var ax;
try {
ax=new ActiveXObject(type);
} catch (e){
ax=null;
}
return ax;
};
let supportsPdfActiveX=function (){ return !!(createAXO("AcroPDF.PDF")||createAXO("PDF.PdfCtrl")); };
let supportsPDFs=(
!isMobileDevice&&(
isModernBrowser ||
isFirefoxWithPDFJS ||
supportsPdfMimeType ||
(isIE&&supportsPdfActiveX())
)
);
let buildURLFragmentString=function(pdfParams){
let string="";
let prop;
if(pdfParams){
for (prop in pdfParams){
if(pdfParams.hasOwnProperty(prop)){
string +=encodeURIComponent(prop) + "=" + encodeURIComponent(pdfParams[prop]) + "&";
}}
if(string){
string="#" + string;
string=string.slice(0, string.length - 1);
}}
return string;
};
let embedError=function (msg, suppressConsole){
if(!suppressConsole){
}
return false;
};
let emptyNodeContents=function (node){
while(node.firstChild){
node.removeChild(node.firstChild);
}};
let getTargetElement=function (targetSelector){
let targetNode=document.body;
if(typeof targetSelector==="string"){
targetNode=document.querySelector(targetSelector);
}else if(window.jQuery!==undefined&&targetSelector instanceof jQuery&&targetSelector.length){
targetNode=targetSelector.get(0);
}else if(targetSelector.nodeType!==undefined&&targetSelector.nodeType===1){
targetNode=targetSelector;
}
return targetNode;
};
let generatePDFJSMarkup=function (targetNode, url, pdfOpenFragment, PDFJS_URL, id, omitInlineStyles){
emptyNodeContents(targetNode);
let fullURL=PDFJS_URL + "?file=" + encodeURIComponent(url) + pdfOpenFragment;
let div=document.createElement("div");
let iframe=document.createElement("iframe");
iframe.src=fullURL;
iframe.className="pdfobject";
iframe.type="application/pdf";
iframe.frameborder="0";
iframe.allow="fullscreen";
if(id){
iframe.id=id;
}
if(!omitInlineStyles){
div.style.cssText="position: absolute; top: 0; right: 0; bottom: 0; left: 0;";
iframe.style.cssText="border: none; width: 100%; height: 100%;";
targetNode.style.position="relative";
targetNode.style.overflow="auto";
}
div.appendChild(iframe);
targetNode.appendChild(div);
targetNode.classList.add("pdfobject-container");
return targetNode.getElementsByTagName("iframe")[0];
};
let generatePDFObjectMarkup=function (embedType, targetNode, targetSelector, url, pdfOpenFragment, width, height, id, title, omitInlineStyles){
emptyNodeContents(targetNode);
let embed=document.createElement(embedType);
if('object'===embedType){
embed.data=url + pdfOpenFragment;
}else{
embed.src=url + pdfOpenFragment;
}
embed.className="pdfobject";
embed.type="application/pdf";
embed.title=title;
if(id){
embed.id=id;
}
if(embedType==="iframe"){
embed.allow="fullscreen";
}
if(!omitInlineStyles){
let style=(embedType==="embed") ? "overflow: auto;":"border: none;";
if(targetSelector&&targetSelector!==document.body){
style +="width: " + width + "; height: " + height + ";";
}else{
style +="position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;";
}
embed.style.cssText=style;
}
targetNode.classList.add("pdfobject-container");
targetNode.appendChild(embed);
return targetNode.getElementsByTagName(embedType)[0];
};
let embed=function(url, targetSelector, options){
let selector=targetSelector||false;
let opt=options||{};
let id=(typeof opt.id==="string") ? opt.id:"";
let page=opt.page||false;
let pdfOpenParams=opt.pdfOpenParams||{};
let fallbackLink=opt.fallbackLink||true;
let width=opt.width||"100%";
let height=opt.height||"100%";
let title=opt.title||"Embedded PDF";
let assumptionMode=(typeof opt.assumptionMode==="boolean") ? opt.assumptionMode:true;
let forcePDFJS=(typeof opt.forcePDFJS==="boolean") ? opt.forcePDFJS:false;
let supportRedirect=(typeof opt.supportRedirect==="boolean") ? opt.supportRedirect:false;
let omitInlineStyles=(typeof opt.omitInlineStyles==="boolean") ? opt.omitInlineStyles:false;
let suppressConsole=(typeof opt.suppressConsole==="boolean") ? opt.suppressConsole:false;
let forceIframe=(typeof opt.forceIframe==="boolean") ? opt.forceIframe:false;
let forceObject=(typeof opt.forceObject==="boolean") ? opt.forceObject:false;
let PDFJS_URL=opt.PDFJS_URL||false;
let targetNode=getTargetElement(selector);
let fallbackHTML="";
let pdfOpenFragment="";
let fallbackHTML_default="<p>This browser does not support inline PDFs. Please download the PDF to view it: <a href='[url]'>Download PDF</a></p>";
if(typeof url!=="string"){ return embedError("URL is not valid", suppressConsole); }
if(!targetNode){ return embedError("Target element cannot be determined", suppressConsole); }
if(page){ pdfOpenParams.page=page; }
pdfOpenFragment=buildURLFragmentString(pdfOpenParams);
if(forcePDFJS&&PDFJS_URL){
return generatePDFJSMarkup(targetNode, url, pdfOpenFragment, PDFJS_URL, id, omitInlineStyles);
}
if(supportsPDFs||(assumptionMode&&!isMobileDevice)){
let embedtype=(forceIframe||supportRedirect||isSafariDesktop) ? "iframe":(forceObject ? "object":"embed");
return generatePDFObjectMarkup(embedtype, targetNode, targetSelector, url, pdfOpenFragment, width, height, id, title, omitInlineStyles);
}
if(PDFJS_URL){
return generatePDFJSMarkup(targetNode, url, pdfOpenFragment, PDFJS_URL, id, omitInlineStyles);
}
if(fallbackLink){
fallbackHTML=(typeof fallbackLink==="string") ? fallbackLink:fallbackHTML_default;
targetNode.innerHTML=fallbackHTML.replace(/\[url\]/g, url);
}
return embedError("This browser does not support embedded PDFs", suppressConsole);
};
return {
embed: function (a,b,c){ return embed(a,b,c); },
pdfobjectversion: (function (){ return pdfobjectversion; })(),
supportsPDFs: (function (){ return supportsPDFs; })()
};}));
(function (){
'use strict';
function setCookie(name, value, days, isSession=false){
let expires='';
if(!isSession&&days){
const date=new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires='; expires=' + date.toUTCString();
}
document.cookie=name + '=' + (value||'') + expires + '; path=/; SameSite=Lax';
}
function getCookie(name){
const nameEQ=name + '=';
const ca=document.cookie.split(';');
for (let i=0; i < ca.length; i++){
let c=ca[i];
while (c.charAt(0)===' ') c=c.substring(1, c.length);
if(c.indexOf(nameEQ)===0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function getOrCreateUserId(){
const COOKIE_NAME='ep_user_id';
let userId=getCookie(COOKIE_NAME);
if(!userId){
userId='ep-user-' + Date.now() + '-' + Math.random().toString(36).substring(2, 15);
setCookie(COOKIE_NAME, userId, 30);
}
return userId;
}
function getOrCreateSessionId(){
const COOKIE_NAME='ep_session_id';
let id=getCookie(COOKIE_NAME);
if(!id){
id='ep-sess-' + Date.now() + '-' + Math.random().toString(36).substring(2, 10);
setCookie(COOKIE_NAME, id, null, true);
}
return id;
}
const config={
viewThreshold: 49,
viewDuration: 3000,
viewResetCooldown: 60000,
impressionCooldown: 5000,
clickCooldown: 2000,
debug: false,
restUrl: embedpress_analytics?.rest_url||'/wp-json/embedpress/v1/analytics/',
userId: getOrCreateUserId(),
sessionId: getOrCreateSessionId(),
pageUrl: embedpress_analytics?.page_url||window.location.href,
postId: embedpress_analytics?.post_id||0,
ipLocationData: null
};
const trackedElements=new Map();
const sessionData={
viewedContent: new Set(),
clickedContent: new Map(),
impressedContent: new Map()
};
function getBrowserFingerprint(){
const canvas=document.createElement('canvas');
const ctx=canvas.getContext('2d');
ctx.textBaseline='top';
ctx.font='14px Arial';
ctx.fillText('Browser fingerprint', 2, 2);
const fingerprintData={
userAgent: navigator.userAgent,
language: navigator.language,
platform: navigator.platform,
screen: `${screen.width}x${screen.height}`,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
canvas: canvas.toDataURL(),
cookieEnabled: navigator.cookieEnabled,
doNotTrack: navigator.doNotTrack,
hardwareConcurrency: navigator.hardwareConcurrency||0,
maxTouchPoints: navigator.maxTouchPoints||0,
colorDepth: screen.colorDepth,
pixelDepth: screen.pixelDepth,
availWidth: screen.availWidth,
availHeight: screen.availHeight,
webgl: getWebGLFingerprint()
};
return simpleHash(JSON.stringify(fingerprintData));
}
function simpleHash(str){
let hash=0;
if(str.length===0) return hash.toString();
for (let i=0; i < str.length; i++){
const char=str.charCodeAt(i);
hash=((hash << 5) - hash) + char;
hash=hash & hash;
}
return Math.abs(hash).toString(16).padStart(8, '0');
}
function getWebGLFingerprint(){
try {
const canvas=document.createElement('canvas');
const gl=canvas.getContext('webgl')||canvas.getContext('experimental-webgl');
if(!gl) return 'no-webgl';
const debugInfo=gl.getExtension('WEBGL_debug_renderer_info');
return {
vendor: gl.getParameter(gl.VENDOR),
renderer: gl.getParameter(gl.RENDERER),
version: gl.getParameter(gl.VERSION),
shadingLanguageVersion: gl.getParameter(gl.SHADING_LANGUAGE_VERSION),
unmaskedVendor: debugInfo ? gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL):'unknown',
unmaskedRenderer: debugInfo ? gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL):'unknown'
};} catch (e){
return 'webgl-error';
}}
const observer=new IntersectionObserver((entries)=> {
entries.forEach(entry=> {
const element=entry.target;
const data=trackedElements.get(element);
if(!data) return;
let visiblePercentage=Math.floor(entry.intersectionRatio * 100);
if(visiblePercentage < config.viewThreshold&&entry.isIntersecting){
const rect=entry.boundingClientRect;
const vh=window.innerHeight, vw=window.innerWidth;
const visibleH=Math.min(rect.bottom, vh) - Math.max(rect.top, 0);
const visibleW=Math.min(rect.right, vw) - Math.max(rect.left, 0);
const viewportCoverage=(visibleH * visibleW) / (vh * vw) * 100;
if(viewportCoverage >=30){
visiblePercentage=Math.max(visiblePercentage, config.viewThreshold);
}}
data.viewportPercentage=visiblePercentage;
data.inViewport=entry.isIntersecting;
if(entry.isIntersecting){
trackImpression(element, data);
}
handleViewTracking(element, data, visiblePercentage);
});
}, {
threshold: Array.from({ length: 11 }, (_, i)=> i / 10)
});
function trackImpression(element, data){
if(!isTrackingEnabled()) return;
const now=Date.now();
const last=sessionData.impressedContent.get(data.contentId)||0;
if(now - last < config.impressionCooldown) return;
sessionData.impressedContent.set(data.contentId, now);
data.lastImpressionTime=now;
sendTrackingData({
content_id: data.contentId,
interaction_type: 'impression',
user_id: config.userId,
session_id: config.sessionId,
page_url: config.pageUrl,
interaction_data: {
embed_type: data.embedType,
embed_url: data.embedUrl,
viewport_percentage: data.viewportPercentage,
location_data: config.ipLocationData,
browser_fingerprint: getBrowserFingerprint()
}});
}
function handleViewTracking(element, data, visiblePercentage){
if(!data.inViewport||visiblePercentage < config.viewThreshold){
if(data.viewTimer){
clearTimeout(data.viewTimer);
data.viewTimer=null;
}
return;
}
const now=Date.now();
if(data.viewTracked&&now - (data.lastViewTime||0) > config.viewResetCooldown){
data.viewTracked=false;
}
if(data.viewTracked||sessionData.viewedContent.has(data.contentId)) return;
if(!data.viewTimer){
data.viewTimer=setTimeout(()=> {
trackView(element, data);
data.viewTracked=true;
data.lastViewTime=Date.now();
sessionData.viewedContent.add(data.contentId);
data.viewTimer=null;
}, config.viewDuration);
}}
function trackView(element, data){
if(!isTrackingEnabled()) return;
sendTrackingData({
content_id: data.contentId,
interaction_type: 'view',
user_id: config.userId,
session_id: config.sessionId,
page_url: config.pageUrl,
view_duration: data.viewDuration||config.viewDuration||0,
interaction_data: {
embed_type: data.embedType,
embed_url: data.embedUrl,
viewport_percentage: data.viewportPercentage,
view_duration: data.viewDuration||config.viewDuration||0,
browser_fingerprint: getBrowserFingerprint()
}});
}
function setupClickTracking(){
trackedElements.forEach((data, element)=> {
element.addEventListener('click', (event)=> {
if(!event.isTrusted) return;
const now=Date.now();
const last=sessionData.clickedContent.get(data.contentId)||0;
if(now - last < config.clickCooldown) return;
if(!isTrackingEnabled()) return;
sessionData.clickedContent.set(data.contentId, now);
sendTrackingData({
content_id: data.contentId,
interaction_type: 'click',
user_id: config.userId,
session_id: config.sessionId,
page_url: config.pageUrl,
interaction_data: {
embed_type: data.embedType,
embed_url: data.embedUrl,
browser_fingerprint: getBrowserFingerprint()
}});
});
});
}
function prepareElementForTracking(element){
if(trackedElements.has(element)) return;
const embedType=element.getAttribute('data-embed-type');
if(!embedType) return;
let contentId=element.getAttribute('data-embedpress-content') ||
element.getAttribute('data-source-id') ||
element.getAttribute('data-emid');
if(!contentId){
const embedUrl=element.getAttribute('data-embed-url') ||
element.querySelector('iframe')?.src ||
element.querySelector('embed')?.src ||
element.querySelector('object')?.data ||
window.location.href;
contentId='ep-' + embedType + '-' + btoa(embedUrl).replace(/[^a-zA-Z0-9]/g, '').substring(0, 10);
}
element.setAttribute('data-embedpress-content', contentId);
const data={
contentId,
embedType,
embedUrl: getEmbedUrl(element),
inViewport: false,
viewTimer: null,
viewTracked: false,
lastImpressionTime: 0,
lastViewTime: 0,
viewportPercentage: 0
};
trackedElements.set(element, data);
observer.observe(element);
}
function getEmbedUrl(element){
const iframe=element.querySelector('iframe');
const video=element.querySelector('video source');
const audio=element.querySelector('audio source');
const embed=element.querySelector('embed');
const object=element.querySelector('object');
return iframe?.src||video?.src||audio?.src||embed?.src||object?.data ||
element.getAttribute('data-url') ||
element.getAttribute('data-src') ||
element.getAttribute('href')||'';
}
function findAndTrackEmbeds(){
document.querySelectorAll('[data-embed-type]:not([data-embed-type] [data-embed-type])')
.forEach(prepareElementForTracking);
}
function setupMutationObserver(){
if(!('MutationObserver' in window)) return;
const mo=new MutationObserver((mutations)=> {
mutations.forEach(m=> {
m.addedNodes.forEach(n=> {
if(n.nodeType!==1) return;
if(n.getAttribute?.('data-embed-type')) prepareElementForTracking(n);
n.querySelectorAll?.('[data-embed-type]').forEach(prepareElementForTracking);
});
});
});
mo.observe(document.body, { childList: true, subtree: true });
}
function sendTrackingData(data){
if(!data.interaction_data?.embed_type ||
data.interaction_data.embed_type==='unknown' ||
data.interaction_data.embed_type===''){
return;
}
const trackingData={
...data,
user_id: data.user_id||config.userId,
session_id: data.session_id||config.sessionId,
page_url: data.page_url||config.pageUrl,
post_id: data.post_id||config.postId,
original_referrer: embedpress_analytics?.original_referrer||''
};
fetch(config.restUrl + 'track', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': embedpress_analytics?.nonce||''
},
body: JSON.stringify(trackingData),
credentials: 'same-origin'
}).catch(err=> {
if(navigator.sendBeacon){
const blob=new Blob([JSON.stringify(trackingData)], { type: 'application/json' });
navigator.sendBeacon(config.restUrl + 'track', blob);
}});
}
async function getIPLocationData(){
try {
const res=await fetch('https://ipinfo.io/json');
const data=await res.json();
config.ipLocationData={
country: data.country,
city: data.city,
timezone: data.timezone,
source: 'ip'
};} catch {
return null;
}}
function sendBrowserInfo(){
const fingerprint=getBrowserFingerprint();
const info={
user_id: config.userId,
session_id: config.sessionId,
browser_fingerprint: fingerprint,
screen_resolution: window.screen.width + 'x' + window.screen.height,
language: navigator.language,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
user_agent: navigator.userAgent
};
getIPLocationData().then(()=> {
if(config.ipLocationData){
info.country=config.ipLocationData.country;
info.city=config.ipLocationData.city;
}
fetch(config.restUrl + 'browser-info', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': embedpress_analytics?.nonce||''
},
body: JSON.stringify(info),
credentials: 'same-origin'
});
});
}
function isTrackingEnabled(){
if(window.embedpressAnalyticsData?.trackingEnabled!==undefined){
return Boolean(window.embedpressAnalyticsData.trackingEnabled);
}
return Boolean(embedpress_analytics?.tracking_enabled);
}
function init(){
if(!isTrackingEnabled()){
return;
}
if(embedpress_analytics?.has_embedded_content===false){
return;
}
findAndTrackEmbeds();
setupClickTracking();
setupMutationObserver();
sendBrowserInfo();
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', init);
}else{
init();
}})();
let epGlobals={};
(function ($){
'use strict';
function ready(fn){
if(document.readyState!=='loading'){
fn();
}else{
document.addEventListener('DOMContentLoaded', fn);
}}
ready(function (){
let option={
forceObject: true,
};
let selector=document.querySelectorAll('.embedpress-embed-document-pdf');
if(selector.length){
selector.forEach((function (value, index, thisArg){
let id=value.dataset['emid'];
let src=value.dataset['emsrc'];
PDFObject?.embed(src, "." + id, option);
}));
}
if(typeof epGlobals.youtubeChannelGallery==='function'){
epGlobals.youtubeChannelGallery();
}});
function embedPressResponsiveEmbeds(){
var proportion, parentWidth;
document.querySelectorAll('iframe').forEach(function (iframe){
if(iframe.width&&iframe.height){
proportion=parseFloat(iframe.width) / parseFloat(iframe.height);
parentWidth=parseFloat(window.getComputedStyle(iframe.parentElement, null).width.replace('px', ''));
iframe.style.maxWidth='100%';
iframe.style.maxHeight=Math.round(parentWidth / proportion).toString() + 'px';
}});
}
epGlobals.handlePosterImageLoad=function (){
var posterImages=document.querySelectorAll(".plyr__poster");
var videoWrappers=document.querySelectorAll("[data-playerid]");
if(!posterImages.length){
videoWrappers.forEach(function (videoWrapper){
videoWrapper.style.opacity="1";
});
return;
}
posterImages.forEach(function (posterImage){
if(posterImage){
videoWrappers.forEach(function (videoWrapper){
var posterImageStyle=window.getComputedStyle(posterImage);
if(posterImageStyle.getPropertyValue('background-image')!=='none'){
videoWrapper.style.opacity="1";
return;
}
var observer=new MutationObserver(function (mutationsList, observer){
var posterImageStyle=window.getComputedStyle(posterImage);
if(posterImageStyle.getPropertyValue('background-image')!=='none'){
setTimeout(function (){
videoWrapper.style.opacity="1";
}, 200);
observer.disconnect();
}});
observer.observe(posterImage, { attributes: true, attributeFilter: ['style'] });
setTimeout(function (){
observer.disconnect();
videoWrapper.style.opacity="1";
}, 5000);
});
}});
}
embedPressResponsiveEmbeds();
window.onresize=embedPressResponsiveEmbeds;
function hasClass(ele, cls){
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
}
function addClass(ele, cls){
if(!hasClass(ele, cls)) ele.className +=" " + cls;
}
function removeClass(ele, cls){
if(hasClass(ele, cls)){
var reg=new RegExp("(\\s|^)" + cls + "(\\s|$)");
ele.className=ele.className.replace(reg, " ");
}}
if(!Element.prototype.matches){
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.webkitMatchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
function (s){
var matches=(this.document||this.ownerDocument).querySelectorAll(s),
i=matches.length;
while (--i >=0&&matches.item(i)!==this){ }
return i > -1;
};}
var delegate=function (el, evt, sel, handler){
el.addEventListener(evt, function (event){
var t=event.target;
while (t&&t!==this){
if(t.matches(sel)){
handler.call(t, event);
}
t=t.parentNode;
}});
};
function sendRequest(url, postData, callback){
var req=createXMLHTTPObject();
if(!req) return;
var method=postData ? "POST":"GET";
req.open(method, url, true);
if(postData){
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
}
req.onreadystatechange=function (){
if(req.readyState!=4) return;
if(req.status!=200&&req.status!=304){
return;
}
callback(req);
};
if(req.readyState==4) return;
req.send(postData);
}
var XMLHttpFactories=[
function (){
return new XMLHttpRequest();
},
function (){
return new ActiveXObject("Msxml3.XMLHTTP");
},
function (){
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
},
function (){
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
},
function (){
return new ActiveXObject("Msxml2.XMLHTTP");
},
function (){
return new ActiveXObject("Microsoft.XMLHTTP");
},
];
function createXMLHTTPObject(){
var xmlhttp=false;
for (var i=0; i < XMLHttpFactories.length; i++){
try {
xmlhttp=XMLHttpFactories[i]();
} catch (e){
continue;
}
break;
}
return xmlhttp;
}
epGlobals.youtubeChannelGallery=function (){
var playerWraps=document.getElementsByClassName("ep-player-wrap");
if(playerWraps&&playerWraps.length){
for (var i=0, im=playerWraps.length; im > i; i++){
youtubeChannelEvents(playerWraps[i])
}}
}
function youtubeChannelEvents(playerWrap){
delegate(playerWrap, "click", ".item", function (event){
var embed="https://www.youtube.com/embed/";
var vid=this.getAttribute("data-vid");
var iframe=playerWrap.getElementsByTagName("iframe");
console.log
if(vid){
if(iframe){
var vidSrc=iframe[0]?.src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
if(vidSrc.indexOf('autoplay') > 0){
vidSrc=vidSrc.replace('autoplay=0', 'autoplay=1');
}else{
vidSrc +='&autoplay=1';
}
iframe[0].src=vidSrc;
playerWrap.scrollIntoView();
}}
});
var currentPage=1;
let nearestEpContentId=playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
let epContentBlock=playerWrap.querySelector('.ep-youtube__content__block');
let parentElement=epContentBlock.parentElement;
let channelUrl=parentElement.querySelector('[data-channel-url]').getAttribute('data-channel-url');
delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event){
const totalPages=event.target.closest('.ose-youtube').getAttribute('data-total-pages');
const closestClass=event.target.closest('.ose-youtube').classList;
const activePage=document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
if(activePage){
document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
}
var isNext=this.classList.contains("ep-next");
if(isNext){
currentPage++;
}else{
currentPage--;
}
var data={
action: "youtube_rest_api",
playlistid: this.getAttribute("data-playlistid"),
pagetoken: this.getAttribute("data-pagetoken"),
pagesize: this.getAttribute("data-pagesize"),
channelUrl: channelUrl,
currentpage: currentPage
};
var formBody=[];
for (var property in data){
var encodedKey=encodeURIComponent(property);
var encodedValue=encodeURIComponent(data[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody=formBody.join("&");
var galleryWrapper=playerWrap.getElementsByClassName("ep-youtube__content__block"
);
playerWrap.setAttribute('data-current-page', currentPage);
let x=1;
sendRequest(embedpressFrontendData.ajaxurl, formBody, function (request){
if(galleryWrapper&&galleryWrapper[0]&&request.responseText){
var response=JSON.parse(request.responseText);
galleryWrapper[0].outerHTML=response.html;
var currentPageNode =
galleryWrapper[0].getElementsByClassName("current-page");
if(currentPageNode&&currentPageNode[0]){
currentPageNode[0].textContent=currentPage;
}}
});
const intervalID=setInterval(()=> {
x++
if(playerWrap.querySelector('.ep-youtube__content__block')){
const newNearestEpContentId=playerWrap
.querySelector('.ep-youtube__content__block')
.getAttribute('data-unique-id');
if(newNearestEpContentId!==nearestEpContentId&&playerWrap.querySelector(`[data-page="${currentPage}"]`)){
playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
nearestEpContentId=newNearestEpContentId;
clearInterval(intervalID);
}}
if(x > 100){
clearInterval(intervalID);
}}, 100);
});
}
const epLoadMore=()=> {
$('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function (){
let selctorEl=`[data-nftid='${$(this).data('nftid')}']`;
let loadmorelabel=$(selctorEl).data('loadmorelabel');
let iconcolor=$(selctorEl + " .nft-loadmore").data('iconcolor');
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>`;
$(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
$('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
$(selctorEl + " .nft-loadmore").click(function (e){
$(this).html(loadmorelabel + spinicon);
$(this).prop("disabled", true);
setTimeout(function (){
$(selctorEl + " .nft-loadmore").text(loadmorelabel);
$(selctorEl + " .nft-loadmore").prop("disabled", false);
$(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
if($(selctorEl + " .ep_nft_item:hidden").length==0){
$(selctorEl + " .nft-loadmore").fadeOut("slow");
}}, 500);
});
});
};
if($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0){
epLoadMore();
}
const unlockSubmitHander=(perentSel, that)=> {
var ep_client_id=jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
var password=jQuery(`input[name="pass_${ep_client_id}"]`).val();
var post_id=jQuery(`input[name="post_id"]`).val();
const buttonText=jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
const unlokingText=jQuery(that).data('unlocking-text');
var data={
'action': 'lock_content_form_handler',
'client_id': ep_client_id,
'password': password,
'post_id': post_id,
};
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
jQuery.post(embedpressFrontendData.ajaxurl, data, function (response){
if(response.success){
if(!response.embedHtml){
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
}else{
const wrapperEl=jQuery('#' + perentSel + '-' + ep_client_id);
const parentWrapper=wrapperEl.parent('.ep-embed-content-wraper');
if(parentWrapper.length > 0){
parentWrapper.html(response.embedHtml);
}else{
wrapperEl.html(response.embedHtml);
}
if(jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0){
epGlobals.youtubeChannelGallery();
}
if($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0){
epLoadMore();
}
const targetEl=parentWrapper.length > 0 ? parentWrapper[0]:wrapperEl[0];
targetEl?.classList?.remove('plyr-initialized');
if(typeof initPlayer==='function'){
initPlayer(targetEl);
}
if(embedpressFrontendData.isProPluginActive){
const adIdEl=document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-sponsored-id]');
if(typeof adInitialization==='function'){
adInitialization(adIdEl, adIdEl?.getAttribute('data-ad-index'));
}}
}}else{
jQuery('#password-error_' + ep_client_id).html(response.form);
jQuery('#password-error_' + ep_client_id).show();
}}, 'json');
}
jQuery('.ep-gutenberg-content .password-form').submit(function (e){
e.preventDefault();
unlockSubmitHander('ep-gutenberg-content', this);
});
jQuery('.ep-shortcode-content .password-form').submit(function (e){
e.preventDefault();
unlockSubmitHander('ep-shortcode-content', this);
});
window.addEventListener('load', function (e){
const urlParams=new URLSearchParams(window.location.search);
const hash=urlParams.get('hash');
const element=document.getElementById(hash);
if(element){
element.scrollIntoView({ behavior: 'smooth' });
}});
const getPopupTemplate=(instPost, hashtag='', accountType)=> {
let instaPostData=JSON.parse(instPost);
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>';
if(instaPostData.like_count > 0){
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>';
}
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>';
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>';
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>';
const instaUserInfo=instPost.user_info;
let getDate=new Date(instaPostData.timestamp);
getDate=getDate.toLocaleString('en-US', { day: 'numeric', month: 'short', year: 'numeric' });
let getTime=new Date(instaPostData.timestamp);
getTime=getTime.toLocaleString('en-US', { hour12: false, hour: 'numeric', minute: 'numeric', second: 'numeric' });
let captionText=instaPostData.caption ? instaPostData.caption:'';
const tagRegex=/(#\w+)/g;
const wrapTag=(match)=> {
const tag=match.substring(1);
const tagUrl=`https://www.instagram.com/explore/tags/${tag}`;
return `<span class="tag-wrapper"><a target="_blank" href="${tagUrl}">${match}</a></span>`;
};
captionText=captionText.replace(tagRegex, wrapTag);
let carouselTemplate='';
if(instaPostData.media_type==='CAROUSEL_ALBUM'){
carouselTemplate +=`<div class="popup-carousel"><div class="cg-carousel__track js-carousel__track">`;
instaPostData.children.data?.map((item)=> {
if(item.media_type?.toLowerCase()==='video'){
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>`;
}else{
carouselTemplate +=`<img width="630" class="popup-media-image cg-carousel__slide js-carousel__slide" src="${item.media_url||''}" alt="${item.caption||''}" />`;
}});
carouselTemplate +=`</div></div>`;
carouselTemplate +=`<div class="cg-carousel__btns">
<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>
<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>
</div>`
}else{
if(instaPostData.media_type?.toLowerCase()==='video'){
carouselTemplate +=`<video width="630" class="popup-media-image" controls src="${instaPostData.media_url||''}" alt="${instaPostData.caption||''}"></video>`;
}else{
carouselTemplate +=`<img width="630" class="popup-media-image" src="${instaPostData.media_url||''}" alt="${instaPostData.caption||''}" />`;
}}
let srcUrl=`https://www.instagram.com/${instaPostData.username}/`;
if(hashtag){
instaPostData.username='#' + hashtag;
srcUrl=`https://www.instagram.com/explore/tags/${hashtag}/`;
}
let likeComments='';
if(embedpressFrontendData.isProPluginActive){
if(instaPostData.show_likes_count=='true'){
likeComments +=`
<div class="embedpress-inline popup-like-button"><a target="_blank" href="${instaPostData.permalink}">${likeIcon} ${instaPostData.like_count||0}</a></div>
`;
}
if(instaPostData.show_comments_count=='true'){
likeComments +=`
<div class="embedpress-inline"><a target="_blank" href="${instaPostData.permalink}">${commentsIcon} ${instaPostData.comments_count||0}</a></div>
`;
}}
let followBtn='';
if(instaPostData.popup_follow_button_text=='false'){
instaPostData.popup_follow_button_text='';
}
if(instaPostData.popup_follow_button=='true'||instaPostData.popup_follow_button=='yes'){
followBtn=`<div class="insta-followbtn">
<a target="_new" href="${srcUrl}" type="button" class="btn btn-primary">${instaPostData.popup_follow_button_text}</a>
</div>`;
}
let popupHtml='';
popupHtml +=`
<div class="popup-container">
<div class="popup-md-9 white">
<div class="embedpress-popup-block embedpress-popup-img" id="post-${instaPostData.id}">
${carouselTemplate}
</div>
</div>
<div class="popup-md-3 red">
<div class="embedpress-popup-block embedpress-popup-info">
<div class="embedpress-popup-header">
<div class="embedpress-popup-header-img"> <a target="_blank" href="${srcUrl}"
target="_blank" class="embedpress-href">
<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>
</a>
</div>
${followBtn}
</div>
<div class="embedpress-popup-text">${captionText}</div>
<div class="embedpress-popup-stats">
${likeComments}
<div class="embedpress-inline">
<div class="embedpress-popup-share-buttons"> <a
href="https://www.facebook.com/sharer/sharer.php?u=${instaPostData.permalink}" target="_blank">
<span class="dashicons dashicons-facebook"></span></a> <a
href="https://twitter.com/intent/tweet?url=${instaPostData.permalink}"
target="_blank"><span>
<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>
</span></a>
<a href="https://www.linkedin.com/shareArticle?mini=true&amp;url=${instaPostData.permalink}"
target="_blank"><span class="dashicons dashicons-linkedin"></span></a> <a
href="https://pinterest.com/pin/create/button/?url=${instaPostData.permalink}"
target="_blank"><span class="dashicons dashicons-pinterest"></span></a></div>
<div class="embedpress-href embedpress-popup-share">${shareIcon}</div>
</div><div class="embedpress-inline embedpress-popup-instagram-buttons"><a
href="${instaPostData.permalink}" target="_blank"
class="embedpress-href">${instaIcon}</a></div>
</div>
</div>
</div>
</div>
`;
return popupHtml;
}
epGlobals.instaPopup=(container)=> {
container?.addEventListener('click', function (event){
const instaItem=event.target.closest('.insta-gallery-item');
if(instaItem){
const postData=instaItem.dataset.postdata;
const postid=instaItem.getAttribute('data-insta-postid');
const accountType=container?.closest('.instagram-container')?.getAttribute('data-connected-acc-type');
let hashtag='';
if(instaItem.closest('.instagram-container').getAttribute('data-hashtag')){
hashtag=instaItem?.closest('.instagram-container')?.getAttribute('data-hashtag');
}
const closestPopup=event.target.closest('.ose-instagram-feed')?.querySelector('.insta-popup');
if(closestPopup){
closestPopup.style.display='block';
}
var feedElement=event.target.closest('.ose-instagram-feed');
if(feedElement){
var popupElement=feedElement.querySelector('.popup-is-initialized');
if(popupElement){
popupElement.innerHTML=getPopupTemplate(postData, hashtag, accountType);
}}
if(!document.querySelector(`#post-${postid}`)?.classList.contains('carousel-is-initialized')){
const carousel=new CgCarousel(`#post-${postid}`, { slidesPerView: 1, loop: true }, {});
const next=document.querySelector(`#post-${postid} .js-carousel__next-1`);
next?.addEventListener('click', ()=> carousel.next());
const prev=document.querySelector(`#post-${postid} .js-carousel__prev-1`);
prev?.addEventListener('click', ()=> carousel.prev());
document.querySelector(`#post-${postid}`)?.classList.add('carousel-is-initialized');
}}
});
}
const instaContainers=document.querySelectorAll('.embedpress-gutenberg-wrapper .insta-gallery');
if(instaContainers.length > 0){
instaContainers.forEach((container)=> {
epGlobals.instaPopup(container);
});
}
$('.popup-close').click(function (e){
$('.insta-popup').hide();
$('.popup-container').remove();
});
$(document).on('click', function (e){
if(e.target.classList.contains('popup-wrapper')){
$('.insta-popup').hide();
$('.popup-container').remove();
}});
const instafeeds=document.querySelectorAll('.ose-instagram-feed');
epGlobals.initializeTabs=(containerEl)=> {
showItems('ALL');
containerEl.addEventListener('click', function (event){
const clickedElement=event.target;
if(!clickedElement){
return;
}
if(containerEl.querySelector('.load-more-button-container')&&(clickedElement.getAttribute('data-media-type')==='VIDEO'||clickedElement.getAttribute('data-media-type')==='CAROUSEL_ALBUM')){
containerEl.querySelector('.load-more-button-container').style.display='none';
}
else if(containerEl.querySelector('.load-more-button-container')&&(clickedElement.getAttribute('data-media-type')==='ALL')){
containerEl.querySelector('.load-more-button-container').style.display='flex';
}
if(clickedElement.matches('.tabs li')){
if(clickedElement.classList.contains('active')){
return;
}else{
const mediaType=clickedElement.getAttribute('data-media-type');
showItems(mediaType);
const tabs=containerEl.querySelectorAll('.tabs li');
tabs.forEach(t=> t.classList.remove('active'));
clickedElement.classList.add('active');
}}
});
function showItems(mediaType){
const items=containerEl.getElementsByClassName('insta-gallery-item');
for (let i=0; i < items.length; i++){
const item=items[i];
if(mediaType==='ALL'||item.getAttribute('data-media-type')===mediaType){
item.style.display='block';
}else{
item.style.display='none';
}}
}}
epGlobals.instaLoadMore=()=> {
$('.insta-load-more-button').off('click').on('click', function (e){
const that=$(this);
const loadmoreBtn=that.closest('.load-more-button-container');
const loadmoreKey=loadmoreBtn.data('loadmorekey');
const connectedAccount=that.closest('.instagram-container').data('connected-acc-type');
const feedType=that.closest('.instagram-container').data('feed-type');
const hashtagId=that.closest('.instagram-container').data('hashtag-id');
const userId=that.closest('.instagram-container').data('uid');
let loadedPosts=loadmoreBtn.data('loaded-posts')||0;
let postsPerPage=loadmoreBtn.data('posts-per-page')||0;
const params=JSON.stringify(that.closest('.instagram-container').data('params'));
const instaContainer=that.closest('.instagram-container');
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>`;
if(instaContainer.find('.insta-loadmore-spinicon').length===0){
that.append(spinicon);
}
that.attr('disabled', true);
var data={
'action': 'loadmore_data_handler',
'user_id': userId,
'loaded_posts': loadedPosts,
'posts_per_page': postsPerPage,
'feed_type': feedType,
'connected_account_type': connectedAccount,
'loadmore_key': loadmoreKey,
'params': params,
'_nonce': embedpressFrontendData.nonce
};
if(feedType==='hashtag_type'){
data.hashtag_id=hashtagId;
}
jQuery.post(embedpressFrontendData.ajaxurl, data, function (response){
if(response.total_feed_posts >=response.next_post_index){
var $responseHtml=$(response.html);
instaContainer.find('.insta-gallery').append($responseHtml);
that.removeAttr('disabled');
instaContainer.find('.insta-loadmore-spinicon').remove();
loadedPosts=response.next_post_index;
loadmoreBtn.data('loaded-posts', loadedPosts);
const containerEl=loadmoreBtn.closest('.ose-instagram-feed')[0];
epGlobals.initializeTabs(containerEl);
if(response.total_feed_posts===response.next_post_index){
loadmoreBtn.remove();
}}else{
loadmoreBtn.remove();
}});
});
}
if(instafeeds.length > 0){
instafeeds.forEach(function (feed){
epGlobals.initializeTabs(feed);
});
}
if($('.embedpress-gutenberg-wrapper .ose-instagram-feed').length > 0){
epGlobals.instaLoadMore();
}
$(document).on({
mouseenter: function (){
$('.embedpress-popup-share-buttons').addClass('show');
},
mouseleave: function (){
var buttons=$('.embedpress-popup-share-buttons');
setTimeout(function (){
if(!buttons.is(':hover')) buttons.removeClass('show');
}, 200);
}}, '.embedpress-href.embedpress-popup-share, .embedpress-popup-share-buttons');
$(document).on({
mouseenter: function (){
$(this).addClass('show');
},
mouseleave: function (){
$(this).removeClass('show');
}}, '.embedpress-popup-share-buttons');
})(jQuery);
document.addEventListener('DOMContentLoaded', function (){
epGlobals.initCarousel=(carouselSelector, options, carouselId)=> {
const carouselOptions={
slidesPerView: options.slideshow,
spacing: options.spacing,
loop: options.loop,
autoplay: options.autoplay,
transitionSpeed: options.transitionspeed,
autoplaySpeed: options.autoplayspeed,
arrows: options.arrows,
breakpoints: {
0: {
slidesPerView: 1
},
768: {
slidesPerView: Math.max(1, parseInt(options.slideshow, 10) - 1)
},
1024: {
slidesPerView: Math.max(1, parseInt(options.slideshow, 10))
}}
};
const carousel=new CgCarousel(carouselSelector, carouselOptions, {});
const next=document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__next-1`);
next?.addEventListener('click', ()=> carousel.next());
const prev=document.querySelector(`[data-carouselid="${carouselId}"] #js-carousel__prev-1`);
prev?.addEventListener('click', ()=> carousel.prev());
}
const instaWrappers=document.querySelectorAll('.ep-embed-content-wraper');
if(instaWrappers.length > 0){
instaWrappers.forEach((wrapper)=> {
const carouselId=wrapper.getAttribute('data-carouselid');
if(!carouselId) return;
let options=wrapper.getAttribute(`data-carousel-options`);
options=JSON.parse(options);
const carouselSelector=`[data-carouselid="${carouselId}"] .embedpress-insta-container`;
if(options.arrows){
document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
}
epGlobals.initCarousel(carouselSelector, options, carouselId);
});
}
const youtubeCarouselWraper=document.querySelectorAll('[data-youtube-channel-carousel]');
if(youtubeCarouselWraper.length > 0){
youtubeCarouselWraper.forEach((wrapper)=> {
const carouselId=wrapper.getAttribute('data-youtube-channel-carousel');
if(!carouselId) return;
const carouselSelector=`[data-youtube-channel-carousel="${carouselId}"] .youtube__content__body`;
const options={
slidesPerView: 2,
autoplay: true,
loop: true,
breakpoints: {
768: {
slidesPerView: 2
},
1024: {
slidesPerView: 4
}}
}});
}});
document.addEventListener('DOMContentLoaded', ()=> {
const carousel=document.querySelector('.youtube-carousel');
if(!carousel){
return;
}
const items=document.querySelectorAll('.item');
const prevButton=document.querySelector('.preview');
const nextButton=document.querySelector('.next');
let itemsToShow=getItemsToShow();
const totalItems=items.length;
let currentIndex=0;
function updateCarousel(){
const offset=-currentIndex * (100 / itemsToShow);
carousel.style.transform=`translateX(${offset}%)`;
}
function nextSlide(){
const remainingItems=totalItems - (currentIndex + itemsToShow);
if(remainingItems >=itemsToShow){
currentIndex +=itemsToShow;
}else if(remainingItems > 0){
currentIndex +=remainingItems;
}else{
currentIndex=0;
}
updateCarousel();
}
function prevSlide(){
if(currentIndex > 0){
currentIndex -=itemsToShow;
if(currentIndex < 0){
currentIndex=0;
}}else{
currentIndex=totalItems - itemsToShow;
}
updateCarousel();
}
nextButton?.addEventListener('click', nextSlide);
prevButton?.addEventListener('click', prevSlide);
let autoplay=false;
const autoplayInterval=3000;
let autoplayId;
function startAutoplay(){
autoplayId=setInterval(nextSlide, autoplayInterval);
}
function stopAutoplay(){
clearInterval(autoplayId);
}
if(autoplay){
startAutoplay();
carousel.addEventListener('mouseover', stopAutoplay);
carousel.addEventListener('mouseout', startAutoplay);
}
window.addEventListener('resize', ()=> {
itemsToShow=getItemsToShow();
updateCarousel();
});
function getItemsToShow(){
const width=window.innerWidth;
if(width >=1024){
return 3;
}else if(width >=768){
return 2;
}else{
return 1;
}}
});
jQuery(window).on("elementor/frontend/init", function (){
var filterableGalleryHandler=function ($scope, $){
let classes=$scope[0].className;
let selectorEl='.' + classes.split(' ').join('.');
const epElLoadMore=()=> {
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>';
$('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').each(function (){
let selctorEl=`.elementor-widget-embedpres_elementor [data-nftid='${$(this).data('nftid')}']`;
let loadmorelabel=$(selctorEl).data('loadmorelabel');
$(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
$('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
$(selctorEl + " .nft-loadmore").click(function (e){
$(this).html(loadmorelabel + spinicon);
$(this).prop("disabled", true);
setTimeout(function (){
$(selctorEl + " .nft-loadmore").text(loadmorelabel);
$(selctorEl + " .nft-loadmore").prop("disabled", false);
$(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
if($(selctorEl + " .ep_nft_item:hidden").length==0){
$(selctorEl + " .nft-loadmore").fadeOut("slow");
}}, 500);
});
});
};
if($('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').length > 0){
epElLoadMore();
}
const unlockElSubmitHander=(perentSel, that)=> {
var ep_client_id=jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
var password=jQuery(`input[name="pass_${ep_client_id}"]`).val();
var post_id=jQuery(`input[name="post_id"]`).val();
const buttonText=jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
const unlokingText=jQuery(that).data('unlocking-text');
var data={
'action': 'lock_content_form_handler',
'client_id': ep_client_id,
'password': password,
'post_id': post_id,
};
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
jQuery.post(embedpressFrontendData.ajaxurl, data, function (response){
if(response.success){
if(!response.embedHtml){
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
}else{
if($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length){
$('.ep-content-locked').removeClass('ep-content-locked');
}
jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
$('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
if(jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0){
epGlobals.youtubeChannelGallery();
}
if($('.elementor-widget-embedpres_elementor .ep-nft-gallery-wrapper').length > 0){
epElLoadMore();
}}
}else{
jQuery('#password-error_' + ep_client_id).html(response.form);
jQuery('#password-error_' + ep_client_id).show();
}}, 'json');
}
jQuery('.ep-elementor-content .password-form').submit(function (e){
e.preventDefault();
unlockElSubmitHander('ep-elementor-content', this);
});
const instaWrappers=document.querySelectorAll('.ep-embed-content-wrapper');
if(instaWrappers.length > 0){
instaWrappers.forEach((wrapper)=> {
wrapper.classList.add('class-content-wrapper');
const carouselId=wrapper.getAttribute('data-carouselid');
if(!carouselId) return;
let options=wrapper.getAttribute(`data-carousel-options`);
options=JSON.parse(options);
const carouselSelector=`[data-carouselid="${carouselId}"] .embedpress-insta-container`;
if(options.arrows){
document.querySelector(`[data-carouselid="${carouselId}"] .cg-carousel__btns`).classList.remove('hidden');
}
epGlobals.initCarousel(carouselSelector, options, carouselId);
});
}
const instaFeed=document.querySelector(`${selectorEl} .ose-instagram-feed`);
const instaGallery=document.querySelector(`${selectorEl} .insta-gallery`);
if(instaFeed){
epGlobals.initializeTabs(instaFeed);
}
if(instaGallery){
epGlobals.instaPopup(instaGallery);
$('.popup-close').click(function (e){
$('.insta-popup').hide();
$('.popup-container').remove();
});
}
if($('.elementor-widget-embedpres_elementor .ose-instagram-feed').length > 0){
epGlobals.instaLoadMore();
}};
const adsHandler=function ($scope, $){
window.epAdIndex=typeof (window.epAdIndex)==='undefined' ? 0:window.epAdIndex + 1;
let classes=$scope[0].className;
let classJoint='.' + classes.split(' ').join('.');
const selectorEl=document.querySelector(classJoint + ' [data-sponsored-id]');
if(jQuery('body').hasClass('elementor-editor-active')&&embedpressFrontendData.isProPluginActive){
if(typeof adInitialization==='function'){
adInitialization(selectorEl, window.epAdIndex);
}}
}
elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", adsHandler);
elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", epGlobals.handlePosterImageLoad);
var customPlayerHandler=function ($scope, $){
var wrappers=$scope[0].querySelectorAll('.ep-embed-content-wraper');
if(typeof initPlayer==='function'){
wrappers.forEach(function (wrapper){
var playerId=wrapper.getAttribute('data-playerid');
if(playerId&&wrapper.classList.contains('plyr-initialized')){
if(typeof playerInit!=='undefined'&&playerInit[playerId]){
try {
playerInit[playerId].destroy();
} catch (e){
}
delete playerInit[playerId];
}
wrapper.classList.remove('plyr-initialized');
}
if(playerId){
initPlayer(wrapper);
}});
}else{
wrappers.forEach(function (wrapper){
if(wrapper.hasAttribute('data-playerid')){
wrapper.style.opacity='1';
}});
}
if(typeof window.epReinitLazyLoad==='function'){
window.epReinitLazyLoad();
}};
elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", customPlayerHandler);
});
function presentationModeForIOS(iframes){
iframes?.forEach(function (iframe){
iframe.onload=function (){
var iframeDoc=iframe.contentDocument||iframe.contentWindow.document;
var button=iframeDoc?.querySelector('#presentationMode.presentationMode');
button?.addEventListener('click', function (){
iframe.classList.toggle('presentationModeEnabledIosDevice');
});
iframeDoc?.addEventListener('keydown', function (event){
if(event.keyCode===27){
iframe.classList.remove('presentationModeEnabledIosDevice');
}});
};});
}
function isIOSDevice(){
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
}
if(isIOSDevice()){
var iframes=document.querySelectorAll('.embedpress-embed-document-pdf');
presentationModeForIOS(iframes)
}
document.addEventListener("DOMContentLoaded", epGlobals.handlePosterImageLoad);
jQuery(document).ready(function ($){
let currentIndex=-1;
function createVideoPopup(){
const videoPopupHtml=`
<div id="videoPopup" class="video-popup">
<div class="video-popup-content">
<span class="close">&times;</span>
<div class="video-popup-inner-content">
<iframe id="videoIframe" frameborder="0" allowfullscreen allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>
<div id="videoDescription"></div>
</div>
<div class="popup-controls">
<span id="prevVideo" class="nav-icon prev-icon">&#10094;</span>
<span id="nextVideo" class="nav-icon next-icon">&#10095;</span>
</div>
</div>
</div>`;
return $(videoPopupHtml).appendTo('body');
}
function openVideoPopup(index){
const items=$('.layout-grid .item, .layout-list .item, .layout-carousel .item');
if(index >=0&&index < items.length){
$('#videoPopup').remove();
currentIndex=index;
const videoId=$(items[currentIndex]).data('vid');
const videoPopup=createVideoPopup();
const videoIframe=videoPopup.find('#videoIframe');
const videoDescriptionContainer=videoPopup.find('#videoDescription');
const closeBtn=videoPopup.find('.close');
const nextBtn=videoPopup.find('#nextVideo');
const prevBtn=videoPopup.find('#prevVideo');
if(videoId){
fetchVideoData(videoId, videoIframe, videoDescriptionContainer);
videoPopup.show();
updateNavigationButtons(nextBtn, prevBtn, items);
closeBtn.on('click', ()=> {
closeVideoPopup(videoPopup);
});
$(window).on('click', function (event){
if($(event.target).is(videoPopup)){
closeVideoPopup(videoPopup);
}});
nextBtn.on('click', function (){
if(currentIndex >=0&&currentIndex < items.length - 1){
openVideoPopup(currentIndex + 1);
}});
prevBtn.on('click', function (){
if(currentIndex > 0){
openVideoPopup(currentIndex - 1);
}});
}}
}
function closeVideoPopup(videoPopup){
videoPopup.remove();
currentIndex=-1;
}
function updateNavigationButtons(nextBtn, prevBtn, items){
prevBtn.toggle(currentIndex > 0);
nextBtn.toggle(currentIndex < items.length - 1);
}
function fetchVideoData(videoId, videoIframe, videoDescriptionContainer){
const data={
action: 'fetch_video_description',
vid: videoId
};
$.post(embedpressFrontendData.ajaxurl, data, function (response){
if(response.success){
videoIframe.attr('src', `https://www.youtube.com/embed/${videoId}?autoplay=1`);
videoDescriptionContainer.html(response.data.description);
}else{
console.error('Error fetching video data:', response?.data?.error);
}});
}
$(document).on('click', '.layout-grid .item, .layout-list .item, .layout-carousel .item', function (){
const items=$('.layout-grid .item, .layout-list .item, .layout-carousel .item');
const index=items.index(this);
openVideoPopup(index);
});
});
jQuery(document).ready(function ($){
let currentIndex=0;
const $photos=$('.photo-item');
function createPopupGooglePhotos(){
if($('#ep-popup-overlay').length===0){
const photoPopup=`
<div class="popup-overlay" id="ep-popup-overlay" style="display: none!important">
<div class="popup">
<span class="close-btn" id="close-btn">
<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>
</span>
<button class="prev-btn" id="prev-btn">
<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>
</button>
<div id="popup-content" class="loading">
<div class="photo-loader"></div>
<img id="popup-image" src="" style="display:none;" loading="lazy" />
</div>
<button class="next-btn" id="next-btn">
<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>
</button>
</div>
</div>`;
$('body').append(photoPopup);
const spinnerStyles=`
<style>
.popup #popup-content .photo-loader {
display: none;
}
.popup #popup-content.loading .photo-loader {
width: 40px;
height: 40px;
border: 4px solid #fff;
border-top: 4px solid transparent;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 40px auto;
display: block;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }}
</style>`;
$('head').append(spinnerStyles);
$('#ep-popup-overlay').on('click', function (e){
if($(e.target).is('#ep-popup-overlay')||$(e.target).is('.popup')){
$('#ep-popup-overlay').hide();
}});
$('#close-btn').on('click', function (){
$('#ep-popup-overlay').hide();
});
$('#prev-btn').on('click', function (){
currentIndex=(currentIndex - 1 + $photos.length) % $photos.length;
updatePopupImage();
});
$('#next-btn').on('click', function (){
currentIndex=(currentIndex + 1) % $photos.length;
updatePopupImage();
});
}}
function updatePopupImage(){
const imgSrc=$photos.eq(currentIndex).find('img').attr('data-photo-src');
const $popupImage=$('#popup-image');
const $popupContent=$('#popup-content');
$popupContent.addClass('loading');
$popupImage.hide();
const preload=new Image();
preload.src=imgSrc;
preload.onload=function (){
$popupImage.attr('src', imgSrc);
$popupContent.removeClass('loading');
$popupImage.fadeIn();
};}
$('.photo-item').on('click', function (){
currentIndex=$photos.index(this);
createPopupGooglePhotos();
updatePopupImage();
$('#ep-popup-overlay').show();
});
});
jQuery(document).ready(function (){
const players=jQuery('.enabled-auto-pause audio, .enabled-auto-pause video');
function pauseAllExcept(currentPlayer){
players.each(function (){
if(this!==currentPlayer[0]){
this.pause();
}});
}
players.on('play', function (){
pauseAllExcept(jQuery(this));
});
});
jQuery(document).on('click', '.ep-load-more-button', function(e){
e.preventDefault();
const button=jQuery(this);
const container=button.closest('.embedpress-meetup-events');
const eventsContainer=container.find('.embedpress-meetup-events-list');
const embedId=button.data('embed-id');
const currentPage=parseInt(container.data('page'))||1;
const perPage=parseInt(container.data('per-page'))||10;
const nextPage=currentPage + 1;
const loadingText=button.find('.ep-load-more-text');
const spinner=button.find('.ep-load-more-spinner');
loadingText.hide();
spinner.show();
button.prop('disabled', true);
jQuery.ajax({
url: embedpressFrontendData.ajaxurl,
type: 'POST',
data: {
action: 'embedpress_meetup_load_more',
nonce: embedpressFrontendData.nonce,
embed_id: embedId,
page: nextPage,
per_page: perPage
},
success: function(response){
if(response.success){
eventsContainer.append(response.data.html);
container.data('page', nextPage);
document.dispatchEvent(new Event('embedpress:meetup:loaded'));
if(!response.data.has_more){
button.closest('.ep-events-load-more').fadeOut();
}else{
loadingText.show();
spinner.hide();
button.prop('disabled', false);
}}else{
alert(response.data.message||'Error loading more events');
loadingText.show();
spinner.hide();
button.prop('disabled', false);
}},
error: function(){
alert('Error loading more events');
loadingText.show();
spinner.hide();
button.prop('disabled', false);
}});
});
(function (){
'use strict';
var ThumbnailGenerator={
pdfjsLoaded: false,
pdfjsLoading: false,
loadCallbacks: [],
loadPdfJs: function (callback){
if(this.pdfjsLoaded&&window.pdfjsLib){
callback();
return;
}
this.loadCallbacks.push(callback);
if(this.pdfjsLoading) return;
this.pdfjsLoading=true;
var self=this;
var scriptUrl=(typeof embedpressObj!=='undefined'&&embedpressObj.pluginUrl)
? embedpressObj.pluginUrl + 'assets/pdf/build/script.js'
: null;
if(!scriptUrl){
var scripts=document.querySelectorAll('script[src*="embedpress"]');
for (var i=0; i < scripts.length; i++){
var match=scripts[i].src.match(/(.*embedpress[^/]*\/(?:assets|static)\/)/);
if(match){
scriptUrl=match[1] + 'pdf/build/script.js';
break;
}}
}
if(!scriptUrl){
self.pdfjsLoading=false;
return;
}
var script=document.createElement('script');
script.src=scriptUrl;
script.type='module';
script.onload=function (){
setTimeout(function (){
if(window.pdfjsLib||globalThis.pdfjsLib){
if(!window.pdfjsLib) window.pdfjsLib=globalThis.pdfjsLib;
var workerUrl=scriptUrl.replace('script.js', 'pdf.worker.js');
window.pdfjsLib.GlobalWorkerOptions.workerSrc=workerUrl;
self.pdfjsLoaded=true;
}
self.pdfjsLoading=false;
self.loadCallbacks.forEach(function (cb){ cb(); });
self.loadCallbacks=[];
}, 50);
};
script.onerror=function (){
self.pdfjsLoading=false;
self.loadCallbacks=[];
};
document.head.appendChild(script);
},
renderThumbnail: function (canvas, pdfUrl){
if(!window.pdfjsLib) return;
canvas.setAttribute('data-loading', 'true');
var loadingTask=window.pdfjsLib.getDocument(pdfUrl);
loadingTask.promise.then(function (pdf){
pdf.getPage(1).then(function (page){
var containerWidth=canvas.parentElement ? canvas.parentElement.offsetWidth:400;
var scale=containerWidth / page.getViewport({ scale: 1 }).width;
scale=Math.max(scale, 0.5);
var viewport=page.getViewport({ scale: scale });
canvas.width=viewport.width;
canvas.height=viewport.height;
var ctx=canvas.getContext('2d');
page.render({
canvasContext: ctx,
viewport: viewport
}).promise.then(function (){
canvas.removeAttribute('data-loading');
});
});
}).catch(function (){
canvas.removeAttribute('data-loading');
canvas.style.display='none';
var wrap=canvas.parentElement;
if(wrap&&!wrap.querySelector('.ep-pdf-thumbnail-placeholder')){
var placeholder=document.createElement('div');
placeholder.className='ep-pdf-thumbnail-placeholder';
placeholder.innerHTML='<svg viewBox="0 0 24 24" width="48" height="48" fill="#999"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm-1 2l5 5h-5V4zM6 20V4h5v7h7v9H6z"/></svg>';
wrap.appendChild(placeholder);
}});
},
initAll: function (){
var canvases=document.querySelectorAll('.ep-pdf-thumbnail-canvas[data-pdf-url]');
if(!canvases.length) return;
var self=this;
this.loadPdfJs(function (){
if(!window.pdfjsLib) return;
if('IntersectionObserver' in window){
var observer=new IntersectionObserver(function (entries){
entries.forEach(function (entry){
if(entry.isIntersecting){
var c=entry.target;
observer.unobserve(c);
self.renderThumbnail(c, c.dataset.pdfUrl);
}});
}, { rootMargin: '200px' });
canvases.forEach(function (c){ observer.observe(c); });
}else{
canvases.forEach(function (c){
self.renderThumbnail(c, c.dataset.pdfUrl);
});
}});
}};
var Lightbox={
lightboxEl: null,
iframe: null,
isOpen: false,
init: function (){
this.createLightboxElement();
this.bindEvents();
},
createLightboxElement: function (){
if(document.querySelector('.ep-pdf-lightbox')) return;
var lightbox=document.createElement('div');
lightbox.className='ep-pdf-lightbox';
lightbox.innerHTML =
'<div class="ep-pdf-lightbox__overlay">' +
'<button class="ep-pdf-lightbox__close" aria-label="Close">&times;</button>' +
'<div class="ep-pdf-lightbox__viewer">' +
'<iframe class="ep-pdf-lightbox__iframe" src="" allowfullscreen></iframe>' +
'</div>' +
'</div>';
document.body.appendChild(lightbox);
this.lightboxEl=lightbox;
this.iframe=lightbox.querySelector('.ep-pdf-lightbox__iframe');
},
bindEvents: function (){
var self=this;
document.addEventListener('click', function (e){
var wrap=e.target.closest('.ep-pdf-thumbnail-wrap');
if(!wrap) return;
e.preventDefault();
self.openFromElement(wrap);
});
if(this.lightboxEl){
this.lightboxEl.querySelector('.ep-pdf-lightbox__close').addEventListener('click', function (){
self.close();
});
this.lightboxEl.querySelector('.ep-pdf-lightbox__overlay').addEventListener('click', function (e){
if(e.target===e.currentTarget){
self.close();
}});
}
document.addEventListener('keydown', function (e){
if(!self.isOpen) return;
if(e.key==='Escape') self.close();
});
},
openFromElement: function (wrapEl){
var pdfUrl=wrapEl.dataset.pdfUrl;
var viewerStyle=wrapEl.dataset.viewerStyle||'modern';
var viewerParams=wrapEl.dataset.viewerParams||'';
if(!pdfUrl) return;
var viewerSrc=this.buildViewerUrl(pdfUrl, viewerStyle, viewerParams);
this.iframe.src=viewerSrc;
this.lightboxEl.classList.add('ep-pdf-lightbox--open');
document.body.style.overflow='hidden';
this.isOpen=true;
},
close: function (){
if(!this.lightboxEl) return;
this.lightboxEl.classList.remove('ep-pdf-lightbox--open');
this.iframe.src='';
document.body.style.overflow='';
this.isOpen=false;
},
buildViewerUrl: function (pdfUrl, viewerStyle, viewerParams){
var encodedFile=encodeURIComponent(pdfUrl);
var pdfRenderer='';
var flipbookRenderer='';
if(typeof embedpressObj!=='undefined'){
pdfRenderer=embedpressObj.pdfRenderer||'';
flipbookRenderer=embedpressObj.flipbookRenderer||'';
}
if(viewerStyle==='flip-book'&&flipbookRenderer){
return flipbookRenderer + '&file=' + encodedFile + '&key=' + viewerParams;
}else if(pdfRenderer){
return pdfRenderer + '&file=' + encodedFile + '#key=' + viewerParams;
}
return pdfUrl;
}};
function init(){
var thumbnails=document.querySelectorAll('.ep-pdf-thumbnail-wrap');
if(!thumbnails.length) return;
ThumbnailGenerator.initAll();
Lightbox.init();
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', init);
}else{
init();
}
function registerElementorHandler(){
if(typeof elementorFrontend==='undefined') return;
elementorFrontend.hooks.addAction('frontend/element_ready/embedpress_pdf.default',
function ($scope){
var canvases=$scope.find('.ep-pdf-thumbnail-canvas[data-pdf-url]');
if(canvases.length){
ThumbnailGenerator.loadPdfJs(function (){
if(!window.pdfjsLib) return;
canvases.each(function (){
ThumbnailGenerator.renderThumbnail(this, this.dataset.pdfUrl);
});
});
}
if(!Lightbox.lightboxEl){
Lightbox.init();
}}
);
}
if(typeof jQuery!=='undefined'){
if(typeof elementorFrontend!=='undefined'){
registerElementorHandler();
}else{
jQuery(window).on('elementor/frontend/init', registerElementorHandler);
}}
})();