(function($){
'use strict';
function checkConsent(container){
var flags=container.attr('data-esf-flags')||'';
var hasGdpr=flags.indexOf('gdpr') > -1;
if(!hasGdpr){
return true;
}
var consentGiven=false;
if(typeof window.WPConsent!=='undefined'){
consentGiven=window.WPConsent.hasConsent('marketing');
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}}
if(typeof window.cookieyes!=='undefined'){
try {
if(typeof window.cookieyes._ckyConsentStore!=='undefined' &&
typeof window.cookieyes._ckyConsentStore.get!=='undefined'){
consentGiven=window.cookieyes._ckyConsentStore.get('functional')==='yes';
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}}
} catch (e){
}}
if(typeof CLI_Cookie!=='undefined'){
try {
if(CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)!==null){
if(CLI_Cookie.read('cookielawinfo-checkbox-non-necessary')!==null){
consentGiven=CLI_Cookie.read('cookielawinfo-checkbox-non-necessary')==='yes';
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}}
if(CLI_Cookie.read('cookielawinfo-checkbox-necessary')!==null){
consentGiven=CLI_Cookie.read('cookielawinfo-checkbox-necessary')==='yes';
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}}
}} catch (e){
}}
if(typeof window.cnArgs!=='undefined'){
try {
var value='; ' + document.cookie;
var parts=value.split('; cookie_notice_accepted=');
if(parts.length===2){
var val=parts.pop().split(';').shift();
consentGiven=(val==='true');
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}}
} catch (e){
}}
if(typeof window.complianz!=='undefined'||typeof window.cookieconsent!=='undefined'){
try {
consentGiven=esfGetCookie('cmplz_marketing')==='allow';
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}} catch (e){
}}
if(typeof window.Cookiebot!=='undefined'){
try {
consentGiven=Cookiebot.consented;
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}} catch (e){
}}
if(typeof window.BorlabsCookie!=='undefined'){
try {
consentGiven=window.BorlabsCookie.checkCookieConsent('facebook') ||
window.BorlabsCookie.checkCookieConsent('marketing');
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}} catch (e){
}}
try {
var mooveCookie=esfGetCookie('moove_gdpr_popup');
if(mooveCookie){
var moove_gdpr_popup=JSON.parse(decodeURIComponent(mooveCookie));
consentGiven=typeof moove_gdpr_popup.thirdparty!=='undefined' &&
moove_gdpr_popup.thirdparty==='1';
if(consentGiven!==null&&consentGiven!==undefined){
return consentGiven;
}}
} catch (e){
}
if(typeof window.consentApi!=='undefined'){
try {
} catch (e){
}}
return false;
}
function getGdprMode(container){
var flagsAttr=container.attr('data-esf-flags')||'';
var flags=flagsAttr ? flagsAttr.split(','):[];
if(flags.indexOf('gdpr_yes') > -1){
return 'yes';
}
if(flags.indexOf('gdpr_auto') > -1){
return 'auto';
}
return 'none';
}
function esfGetCookie(cname){
var name=cname + '=';
var cArr=document.cookie.split(';');
for (var i=0; i < cArr.length; i++){
var c=cArr[i].trim();
if(c.indexOf(name)===0){
return c.substring(name.length, c.length);
}}
return '';
}
function enableFullFeatures(container){
var mode=getGdprMode(container);
if(mode==='yes'){
return;
}
container.find('.esf-gdpr-notice').remove();
container.find('.esf-no-consent').each(function(){
var $element=$(this);
var realImageUrl=$element.attr('data-image-url');
if(realImageUrl){
var $img=$element.is('img') ? $element:$element.find('img');
if($img.length){
$img.attr('src', realImageUrl);
}
$element.css('background-image', 'url(' + realImageUrl + ')');
$element.removeClass('esf-no-consent');
$element.removeAttr('data-image-url');
}});
container.find('.efbl_load_more_holder').show();
}
function initConsentCheck(){
var $containers=$('.efbl_feed_wraper, .esf_insta_feed_wraper');
$containers.each(function(){
var $container=$(this);
var flags=$container.attr('data-esf-flags')||'';
var mode=getGdprMode($container);
if(flags.indexOf('gdpr') > -1){
if(mode==='yes'){
$container.find('.efbl_load_more_holder').hide();
return;
}
var immediateConsent=checkConsent($container);
if(immediateConsent){
enableFullFeatures($container);
return;
}
$container.find('.efbl_load_more_holder').hide();
setTimeout(function(){
var consent=checkConsent($container);
if(consent){
enableFullFeatures($container);
}}, 250);
}});
var attempts=0;
var maxAttempts=30;
var pollInterval=2000;
var intervalId=setInterval(function(){
attempts++;
$containers.each(function(){
var $container=$(this);
var flags=$container.attr('data-esf-flags')||'';
var mode=getGdprMode($container);
if(flags.indexOf('gdpr')===-1){
return;
}
if(mode==='yes'){
return;
}
if($container.find('.esf-no-consent').length===0){
return;
}
if(checkConsent($container)){
enableFullFeatures($container);
}});
if(attempts >=maxAttempts){
clearInterval(intervalId);
}}, pollInterval);
}
function afterConsentToggled(isConsent){
if(isConsent){
$('.efbl_feed_wraper, .esf_insta_feed_wraper').each(function(){
var $container=$(this);
var flags=$container.attr('data-esf-flags')||'';
var mode=getGdprMode($container);
if(flags.indexOf('gdpr')===-1){
return;
}
if(mode==='yes'){
return;
}
enableFullFeatures($container);
});
}}
$(document).ready(function(){
initConsentCheck();
function triggerAfterConsent(){
setTimeout(function(){
afterConsentToggled(true);
}, 1000);
}
$('#cookie-notice a').on('click', function(){
triggerAfterConsent();
});
$('#cookie-law-info-bar a').on('click', function(){
triggerAfterConsent();
});
$('.cli-user-preference-checkbox, .cky-notice button').on('click', function(){
triggerAfterConsent();
});
$(window).on('CookiebotOnAccept', function(){
triggerAfterConsent();
});
$('.cmplz-btn').on('click', function(){
if(typeof window.cmplz_accepted_categories==='function'){
setTimeout(function(){
var accepted=window.cmplz_accepted_categories();
if($.isArray(accepted)&&accepted.indexOf('marketing') > -1){
afterConsentToggled(true);
}}, 1000);
}else{
triggerAfterConsent();
}});
$(document).on('cmplzEnableScripts', function(event){
if(event.detail==='marketing'){
afterConsentToggled(true);
}});
$(document).on('cmplzFireCategories', function(event){
if(event.detail&&event.detail.category==='marketing'){
afterConsentToggled(true);
}});
$(document).on('borlabs-cookie-consent-saved', function(){
triggerAfterConsent();
});
if(typeof window.consentApi!=='undefined'){
window.consentApi.consent('easy-social-feed').then(function(){
triggerAfterConsent();
}).catch(function(){
});
}
$('.moove-gdpr-infobar-allow-all').on('click', function(){
triggerAfterConsent();
});
if(typeof window.addEventListener!=='undefined'){
window.addEventListener('wpconsent_consent_saved', function(){
setTimeout(function(){
if(typeof window.WPConsent!=='undefined'){
afterConsentToggled(window.WPConsent.hasConsent('marketing'));
}}, 1000);
});
window.addEventListener('wpconsent_consent_updated', function(){
setTimeout(function(){
if(typeof window.WPConsent!=='undefined'){
afterConsentToggled(window.WPConsent.hasConsent('marketing'));
}}, 1000);
});
}});
if(typeof window.addEventListener!=='undefined'){
window.addEventListener('wpconsent_consent_saved', function(){
setTimeout(function(){
if(typeof window.WPConsent!=='undefined'){
afterConsentToggled(window.WPConsent.hasConsent('marketing'));
}}, 1000);
});
window.addEventListener('wpconsent_consent_updated', function(){
setTimeout(function(){
if(typeof window.WPConsent!=='undefined'){
afterConsentToggled(window.WPConsent.hasConsent('marketing'));
}}, 1000);
});
}
$(document).on('cmplzEnableScripts', function(event){
if(event.detail==='marketing'){
afterConsentToggled(true);
}});
$(document).on('borlabs-cookie-consent-saved', function(){
afterConsentToggled(true);
});
if(typeof window.consentApi!=='undefined'){
window.consentApi.consent('easy-social-feed').then(function(){
setTimeout(function(){
afterConsentToggled(true);
}, 1000);
});
}
$(document).on('click', '.moove-gdpr-infobar-allow-all', function(){
setTimeout(function(){
afterConsentToggled(true);
}, 1000);
});
window.ESFGDPR={
checkConsent: checkConsent,
enableFullFeatures: enableFullFeatures,
afterConsentToggled: afterConsentToggled
};})(jQuery);