From 1f829136cf698190e56cbd599e3c2beb2c44e919 Mon Sep 17 00:00:00 2001 From: Dirk Persky Date: Sat, 4 Nov 2023 14:41:58 +0100 Subject: [PATCH] Bugfix #122 --- Resources/Private/Assets/src/js/main.js | 7 +++++-- Resources/Public/JavaScript/dp_cookieconsent.js | 2 +- ext_emconf.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Resources/Private/Assets/src/js/main.js b/Resources/Private/Assets/src/js/main.js index 29e47f9..a240686 100644 --- a/Resources/Private/Assets/src/js/main.js +++ b/Resources/Private/Assets/src/js/main.js @@ -458,7 +458,7 @@ import configCookie from './html/config/cookie.html?raw'; } }); // set required - if(id == 'required') { + if(id == 'require') { e.checked = true; e.disabled = true; } @@ -544,12 +544,13 @@ import configCookie from './html/config/cookie.html?raw'; id = id.replace('dp--cookie-', ''); // filter check switch (id) { - case 'required': + case 'require': break; default: filteres.push(e); } }); + return filteres; }; /** @@ -1129,6 +1130,8 @@ import configCookie from './html/config/cookie.html?raw'; var type = e.getAttribute('data-cookieconsent'); // get checkbox var checkbox = cc.popup.getCheckboxInputs(); + + console.log(checkbox); // chackboxes found? if (checkbox.length > 0) { checkbox.forEach(e => { diff --git a/Resources/Public/JavaScript/dp_cookieconsent.js b/Resources/Public/JavaScript/dp_cookieconsent.js index 5293336..f27610f 100644 --- a/Resources/Public/JavaScript/dp_cookieconsent.js +++ b/Resources/Public/JavaScript/dp_cookieconsent.js @@ -129,4 +129,4 @@ const k=`
\r * Cookie Consent * Copyright 2021 Dirk Persky (https://github.com/DirkPersky/npm-dp_cookieconsent/issues) * Licensed under AGPL v3+ (https://github.com/DirkPersky/npm-dp_cookieconsent/blob/master/LICENSE) - */(function(i,q){if(!i.hasInitialised){(function(){if(typeof window.CustomEvent=="function")return!1;function s(o,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var t=document.createEvent("CustomEvent");return t.initCustomEvent(o,e.bubbles,e.cancelable,e.detail),t}s.prototype=window.Event.prototype,window.CustomEvent=s})(),function(){if(typeof window.Event=="function")return!1;function s(o,e){e=e||{bubbles:!0,cancelable:!0,detail:void 0};var t=document.createEvent("Event");return t.initEvent(o,e.bubbles,e.cancelable,e.detail),t}s.prototype=window.Event.prototype,window.Event=s}();var l={detectRobot:function(s){return new RegExp([/Chrome-Lighthouse/,/bot/,/spider/,/crawl/,/APIs-Google/,/AdsBot/,/Googlebot/,/mediapartners/,/Google Favicon/,/FeedFetcher/,/Google-Read-Aloud/,/DuplexWeb-Google/,/googleweblight/,/bing/,/yandex/,/baidu/,/duckduck/,/yahoo/,/ecosia/,/ia_archiver/,/semrush/].map(e=>e.source).join("|"),"i").test(s)},reformatCheckboxOptions:function(s){var o=Object.entries(s).map(e=>{var t=String(e[1]).toLowerCase()=="true";return{name:e[0],checked:t}});return o},getCookie:function(s){var o="; "+document.cookie,e=o.split("; "+s+"=");return e.length<2?void 0:JSON.parse(e.pop().split(";").shift())},setCookie:function(s,o,e,t,n,c){var r=new Date;r.setHours(r.getHours()+(e||365)*24);var a=[s+"="+JSON.stringify(o),"expires="+r.toUTCString(),"path="+(n||"/"),"SameSite=Strict"];t&&a.push("domain="+t),c&&a.push("secure"),document.cookie=a.join(";")},prepareCookie:function(s,o){var e={status:"open"},t=this.getCookie(o);return typeof t<"u"&&this.deepExtend(e,t),this.deepExtend(e,s),{exists:typeof t<"u",config:e}},getElementsByTag:function(s,o){return typeof o>"u"&&(o="data-cookieconsent"),document.querySelectorAll(s+"["+o+"]")},deepExtend:function(s,o){for(var e in o)o.hasOwnProperty(e)&&(e in s&&typeof s[e]=="object"&&typeof o[e]=="object"?this.deepExtend(s[e],o[e]):s[e]=o[e]);return s},appendElement:function(s,o){var e=document.createElement("div"),t=o??document.body;e.innerHTML=this.replaceContent(s);var n=e.children[0];return t.appendChild(n),n},applyStyle:function(s){if(!(typeof this.options[s]>"u"))for(const[o,e]of Object.entries(this.options[s]))for(const[t,n]of Object.entries(e))document.documentElement.style.setProperty(`--dp-cookie-${s}-${o}-${t}`,n)},fireEvent:function(s,o){var e;o?e=new CustomEvent(s,{detail:{$el:o}}):e=new Event(s),document.dispatchEvent(e)}};i.utils=l;var u=function(){var s={cookie:{name:"dp_cookieconsent_status",path:"/",domain:"",expiryDays:365,secure:!1},position:"bottom-right",content:{},theme:"edgeless",type:"opt-in",revokable:!0,reloadOnRevoke:!0,checkboxes:[{name:"statistics",checked:!1},{name:"marketing",checked:!1}],palette:{popup:{background:"rgba(0,0,0,0.8)",text:"#ffffff"},button:{background:"#f96332",text:"#ffffff"}},overlay:{notice:!0,box:{background:"rgba(0,0,0,0.8)",text:"#ffffff"},btn:{background:"#f96332",text:"#ffffff"}},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(){},onStatusChange:function(e,t){},onRevokeChoice:function(){},compilance:{"opt-in":k,extend:b},revokeBtn:B,overlayLayout:A,wrap:{consent:L,config:S},elements:{"allow-all":w,allow:m,dismiss:C,deny:x,config:E,selection:y,description:g}};function o(){}return o.prototype.replaceContent=function(e){var t=this.options,n=["cc-"+t.position,"cc-type-"+t.type,"cc-theme-"+t.theme,"cc-hide"];e=e.replaceAll("{{classes}}",n.join(" "));for(const[c,r]of Object.entries(t.elements))e=e.replaceAll("{{"+c+"}}",r||"");for(const[c,r]of Object.entries(t.content))e=e.replaceAll("{{"+c+"}}",r||"");return e},o.prototype.templateOverwrites=function(){let e=i.utils.getElementsByTag("script","data-dp-cookieRevoke");e.length>0&&(this.options.revokeBtn=e[0].innerHTML);let t=i.utils.getElementsByTag("script","data-dp-cookieDesc");t.length>0&&(this.options.elements.description=t[0].innerHTML);let n=i.utils.getElementsByTag("script","data-dp-cookieSelect");n.length>0&&(this.options.elements.selection=n[0].innerHTML)},o.prototype.initialise=function(e){l.deepExtend(this.options={},s),typeof e.checkboxes=="object"&&(e.checkboxes=l.reformatCheckboxOptions(e.checkboxes)),typeof e=="object"&&l.deepExtend(this.options,e);var t=this.options.onInitialise.bind(this);this.templateOverwrites(),this.options.revokable&&(this.revokeBtn=i.utils.appendElement.call(this,this.options.revokeBtn)),this.window=i.utils.appendElement.call(this,this.options.wrap.consent),this.options.type=="extend"&&i.configWindow.initialise(this.options.wrap.config),i.utils.applyStyle.call(this,"palette"),i.utils.applyStyle.call(this,"overlay"),this.addCompilance(this.window),t(this),this.bindBtns(),this.presetCheckboxes()},o.prototype.presetCheckboxes=function(){var e=i.utils.getCookie(this.options.cookie.name);typeof e<"u"&&l.deepExtend(this.options.checkboxes,e.checkboxes);var t=this.getCheckboxInputs(!0);t.length>0&&t.forEach(n=>{var c=n.id;c=c.replace("dp--cookie-",""),this.options.checkboxes.map((r,a)=>{r.name==c&&(n.checked=r.checked)}),c=="required"&&(n.checked=!0,n.disabled=!0)})},o.prototype.addCompilance=function(e){var t=this.options.compilance["opt-in"];typeof this.options.compilance[this.options.type]<"u"&&(t=this.options.compilance[this.options.type]),this.compilance=i.utils.appendElement.call(this,t,e),this.allowAllBtn=this.compilance.getElementsByClassName("cc-allow-all"),this.allowBtn=this.compilance.getElementsByClassName("cc-allow"),this.denyBtn=this.compilance.getElementsByClassName("cc-deny"),this.dismissBtn=this.compilance.getElementsByClassName("cc-dismiss"),this.configBtn=this.compilance.querySelector("button.cc-config")},o.prototype.bindBtns=function(){this.allowAllBtn.length>0&&(this.allowAllBtn[0].onclick=()=>this.allowAll.call(this)),this.allowBtn.length>0&&(this.allowBtn[0].onclick=()=>this.allow.call(this)),this.dismissBtn.length>0&&(this.dismissBtn[0].onclick=()=>this.allow.call(this)),this.denyBtn.length>0&&(this.denyBtn[0].onclick=()=>this.denyAll.call(this)),this.revokeBtn&&(this.revokeBtn.onclick=()=>this.revoke.call(this)),this.configBtn&&(this.configBtn.onclick=()=>i.configWindow.showConfig())},o.prototype.allowAll=function(){this.saveCheckboxes(!0),i.utils.fireEvent("dp--cookie-accept"),this.save()},o.prototype.denyAll=function(){this.saveCheckboxes(!1),i.utils.fireEvent("dp--cookie-deny"),this.save()},o.prototype.allow=function(){i.utils.fireEvent("dp--cookie-accept"),this.save()},o.prototype.getCheckboxInputs=function(e){var t=document.querySelectorAll('input[id^="dp--cookie-"]');if(e)return t;var n=[];return t.forEach(c=>{var r=c.id;switch(r=r.replace("dp--cookie-",""),r){case"required":break;default:n.push(c)}}),n},o.prototype.saveCheckboxes=function(e){var t=this.getCheckboxInputs();t.length>0&&t.forEach(n=>{var c=n.id;c=c.replace("dp--cookie-",""),typeof e<"u"&&(n.checked=e);var r=this.options.checkboxes.map((a,p)=>{if(a.name==c)return this.options.checkboxes[p].checked=n.checked,!0}).filter(a=>a);r.length||this.options.checkboxes.push({name:c,checked:n.checked})})},o.prototype.save=function(){this.saveCheckboxes(),this.close()},o.prototype.hasChanged=function(){var e=!1;return typeof this.originalCookie>"u"||typeof this.originalCookie.checkboxes>"u"?!1:(this.originalCookie.checkboxes.map((t,n)=>{var c=this.options.checkboxes[n];if(t.checked===!0&&(!c||c.checked==!1)){e=!0;var r=this.options.onStatusChange.bind(this);r(c,t)}}),e)},o.prototype.hasConsent=function(){var e=i.utils.getCookie(this.options.cookie.name);return!(typeof e>"u"||e.status=="open")},o.prototype.saveCookie=function(e){var t=i.utils.prepareCookie(e,this.options.cookie.name);!t.exists&&t.config.status=="open"||(i.utils.setCookie(this.options.cookie.name,t.config,this.options.cookie.expiryDays,this.options.cookie.domain,this.options.cookie.path,this.options.cookie.secure),this.hasConsent()&&this.hasChanged()&&this.options.reloadOnRevoke&&location.reload())},o.prototype.revoke=function(){var e=this.options.onRevokeChoice.bind(this);e(this),i.utils.fireEvent("dp--cookie-revoke"),this.open()},o.prototype.open=function(){this.revokeBtn&&this.revokeBtn.classList.add("cc-hide"),this.showPopup(),this.originalCookie=i.utils.getCookie(this.options.cookie.name);var e=this.options.onPopupOpen.bind(this);e(this),this.saveCookie({status:"open"}),document.querySelector("body").classList.add("dp--cookie-consent")},o.prototype.hidePopup=function(){this.window.classList.add("cc-hide")},o.prototype.showPopup=function(){this.window.classList.remove("cc-hide")},o.prototype.close=function(){this.hidePopup(),i.configWindow.closeConfig(),this.revokeBtn&&this.revokeBtn.classList.remove("cc-hide");var e=this.options.onPopupClose.bind(this);e(this),this.saveCookie({status:"approved",checkboxes:this.options.checkboxes}),document.querySelector("body").classList.remove("dp--cookie-consent"),this.execute()},o.prototype.execute=function(){i.Handler.execute(this.options.checkboxes),i.Overlay.execute(this.options.checkboxes)},new o}();i.popup=u;var f=function(){function s(){}return s.prototype.overlays=function(){i.popup.options.overlay.notice&&(this.templateOverwrites(),this.overlaysView("iframe"),this.overlaysView("dp-content"))},s.prototype.templateOverwrites=function(){let o=i.utils.getElementsByTag("script","data-dp-cookieIframe");o.length>0&&(i.popup.options.overlayLayout=o[0].innerHTML)},s.prototype.overlaysView=function(o){var e=i.utils.getElementsByTag(o);e.length!=0&&e.forEach(t=>{var n=t.getAttribute("data-cookieconsent-notice")||i.popup.options.content.media.notice,c=t.getAttribute("data-cookieconsent-description")||i.popup.options.content.media.desc,r=t.getAttribute("data-cookieconsent-btn")||i.popup.options.content.media.btn,a=t.getAttribute("data-cookieconsent");if(!t.hasAttribute("data-cookieconsent-overlay-loaded")){t.setAttribute("data-cookieconsent-overlay-loaded","loaded");var p=document.createElement("div");p.classList.add("dp--overlay");var d=i.popup.options.overlayLayout.replace("{{notice}}",n).replace("{{desc}}",c).replace("{{type}}",a).replace("{{btn}}",r);d=i.utils.appendElement.call(i.popup,d,p),d.getElementsByClassName("db--overlay-submit"),t.parentNode.insertBefore(p,t.nextSibling)}})},s.prototype.execute=function(o){this.executeIframe(o),this.executeContent(o)},s.prototype.ajax=function(o,e,t,n){var c=new XMLHttpRequest;c.open(o,e),c.setRequestHeader("X-Requested-With","XMLHttpRequest"),c.setRequestHeader("Content-type","text/html"),c.onload=function(){c.status<200||c.status>=300?n(c):t(c)},c.onerror=function(){n(c)},c.send()},s.prototype.executeContent=function(o){var e=i.utils.getElementsByTag("dp-content");e.length>0&&e.forEach(t=>{if(i.Handler.typeAllowed(t,o)){t.classList.add("dp--loaded"),t.setAttribute("data-cookieconsent-loaded",t.getAttribute("data-cookieconsent")),t.removeAttribute("data-cookieconsent");var n=t.getAttribute("data-src");n&&n.length>0?this.ajax("GET",n,function(c){t.innerHTML=c.response,i.utils.fireEvent("dp--cookie-content",t)},function(c){}):i.utils.fireEvent("dp--cookie-content",t)}})},s.prototype.executeIframe=function(o){var e=i.utils.getElementsByTag("iframe");e.length>0&&e.forEach(t=>{if(i.Handler.typeAllowed(t,o)){var n=t.cloneNode(!0);n.getAttribute("data-src")&&(n.src=n.getAttribute("data-src")),t.parentNode.replaceChild(n,t),n.classList.add("dp--loaded"),n.setAttribute("data-cookieconsent-loaded",n.getAttribute("data-cookieconsent")),n.removeAttribute("data-cookieconsent"),i.utils.fireEvent("dp--cookie-iframe",n)}})},new s}();i.Overlay=f;var h=function(){function s(){}return s.prototype.execute=function(o){var e=i.utils.getElementsByTag("script");e.length>0&&e.forEach(t=>{if(this.typeAllowed(t,o)){var n=t.innerHTML;n&&n.length&&(n=n.trim()),n&&n.length?(eval.call(this,n),i.utils.fireEvent("dp--cookie-fire",t)):t.getAttribute("data-src")?this.asyncJS(t.getAttribute("data-src"),function(c){i.utils.fireEvent("dp--cookie-fire",t)}):t.src&&this.asyncJS(t.src,function(c){i.utils.fireEvent("dp--cookie-fire",t)}),t.setAttribute("data-cookieconsent-loaded",t.getAttribute("data-cookieconsent")),t.removeAttribute("data-cookieconsent")}})},s.prototype.asyncLoad=function(o,e,t){var n=document,c=n.createElement(e),r=n.getElementsByTagName(e)[0];switch(e){case"script":c.src=o,c.setAttribute("defer","");break;case"link":c.rel="stylesheet",c.type="text/css",c.setAttribute("defer",""),c.href=o;break}t&&c.addEventListener("load",function(a){t(null,a)},!1),r.parentNode.insertBefore(c,r)},s.prototype.asyncJS=function(o,e){this.asyncLoad(o,"script",e)},s.prototype.typeAllowed=function(o,e){var t=o.getAttribute("data-cookieconsent"),n=e.map(c=>{if(c.name==t&&c.checked===!0)return!0});return n.indexOf(!0)!==-1},new s}();i.Handler=h,i.initialise=function(s,o){if(o||(o=function(){}),i.popup.initialise(s),i.Overlay.overlays(),o(i.popup),i.utils.fireEvent("dp--cookie-init"),i.popup.hasConsent()||l.detectRobot(navigator.userAgent)){i.popup.close(),i.utils.fireEvent("dp--cookie-accept-init");return}i.popup.open()};var v=function(){function s(){}return s.prototype.initialise=function(o){this.prepareConfig(),this.configWrap=i.utils.appendElement.call(i.popup,o),this.getElements(),this.bindBtns()},s.prototype.prepareConfig=function(){var o=i.popup.options,e=o.cookies.map(t=>{var n=t.cookies.map(c=>(this.options=i.utils.deepExtend({elements:{},content:c},o),i.popup.replaceContent.call(this,H))).join("");return this.options=i.utils.deepExtend({elements:{"config-cookie":n},content:{group:t.name,"group-lower":t.name.toLowerCase()}},o),i.popup.replaceContent.call(this,O)}).join("");i.popup.options.elements["cookie-group"]=e},s.prototype.getElements=function(){this.closeBtn=this.configWrap.querySelector("button.cc-btn-close"),this.allowAllBtn=this.configWrap.querySelector("button.cc-allow-all"),this.allowBtn=this.configWrap.querySelector("button.cc-allow"),this.denyBtn=this.configWrap.querySelector("button.cc-deny"),this.configGroups=this.configWrap.querySelectorAll(".cc-config-group")},s.prototype.bindBtns=function(){this.allowAllBtn&&(this.allowAllBtn.onclick=()=>i.popup.allowAll(this)),this.allowBtn&&(this.allowBtn.onclick=()=>i.popup.allow(this)),this.denyBtn&&(this.denyBtn.onclick=()=>i.popup.denyAll(this)),this.closeBtn&&(this.closeBtn.onclick=()=>this.hideConfig.call(this)),this.configGroups&&this.configGroups.forEach(o=>{o.querySelector(".cc-btn-collapse").onclick=()=>{var e=!o.classList.contains("cc-show");this.configGroups.forEach(t=>t.classList.remove("cc-show")),e&&o.classList.add("cc-show")}})},s.prototype.closeConfig=function(){this.configWrap&&this.configWrap.classList.remove("cc-show")},s.prototype.hideConfig=function(){i.popup.showPopup(),this.configWrap&&this.closeConfig()},s.prototype.showConfig=function(){this.configWrap&&this.configWrap.classList.add("cc-show"),i.popup.hidePopup()},new s}();i.configWindow=v,i.forceAccept=function(s){var o=s.getAttribute("data-cookieconsent"),e=i.popup.getCheckboxInputs();e.length>0&&(e.forEach(t=>{var n=t.id;n=n.replace("dp--cookie-",""),i.popup.hasConsent()||(t.checked=!1),n==o&&(t.checked=!0)}),i.utils.fireEvent("dp--cookie-accept")),i.popup.save()},i.forceDeny=function(s){var o=s.getAttribute("data-cookieconsent"),e=i.popup.getCheckboxInputs();e.length>0&&e.forEach(t=>{var n=t.id;n=n.replace("dp--cookie-",""),i.popup.hasConsent()||(t.checked=!1),n==o&&(t.checked=!1)}),i.popup.save()},i.hasInitialised=!0,window.DPCookieConsent=i,window.addEventListener("load",function(){window.DPCookieConsent.initialise(window.cookieconsent_options||{}),window.DPCookieConsent.loaded=!0})}})(window.DPCookieConsent||{}); + */(function(i,q){if(!i.hasInitialised){(function(){if(typeof window.CustomEvent=="function")return!1;function s(o,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var t=document.createEvent("CustomEvent");return t.initCustomEvent(o,e.bubbles,e.cancelable,e.detail),t}s.prototype=window.Event.prototype,window.CustomEvent=s})(),function(){if(typeof window.Event=="function")return!1;function s(o,e){e=e||{bubbles:!0,cancelable:!0,detail:void 0};var t=document.createEvent("Event");return t.initEvent(o,e.bubbles,e.cancelable,e.detail),t}s.prototype=window.Event.prototype,window.Event=s}();var l={detectRobot:function(s){return new RegExp([/Chrome-Lighthouse/,/bot/,/spider/,/crawl/,/APIs-Google/,/AdsBot/,/Googlebot/,/mediapartners/,/Google Favicon/,/FeedFetcher/,/Google-Read-Aloud/,/DuplexWeb-Google/,/googleweblight/,/bing/,/yandex/,/baidu/,/duckduck/,/yahoo/,/ecosia/,/ia_archiver/,/semrush/].map(e=>e.source).join("|"),"i").test(s)},reformatCheckboxOptions:function(s){var o=Object.entries(s).map(e=>{var t=String(e[1]).toLowerCase()=="true";return{name:e[0],checked:t}});return o},getCookie:function(s){var o="; "+document.cookie,e=o.split("; "+s+"=");return e.length<2?void 0:JSON.parse(e.pop().split(";").shift())},setCookie:function(s,o,e,t,n,c){var r=new Date;r.setHours(r.getHours()+(e||365)*24);var a=[s+"="+JSON.stringify(o),"expires="+r.toUTCString(),"path="+(n||"/"),"SameSite=Strict"];t&&a.push("domain="+t),c&&a.push("secure"),document.cookie=a.join(";")},prepareCookie:function(s,o){var e={status:"open"},t=this.getCookie(o);return typeof t<"u"&&this.deepExtend(e,t),this.deepExtend(e,s),{exists:typeof t<"u",config:e}},getElementsByTag:function(s,o){return typeof o>"u"&&(o="data-cookieconsent"),document.querySelectorAll(s+"["+o+"]")},deepExtend:function(s,o){for(var e in o)o.hasOwnProperty(e)&&(e in s&&typeof s[e]=="object"&&typeof o[e]=="object"?this.deepExtend(s[e],o[e]):s[e]=o[e]);return s},appendElement:function(s,o){var e=document.createElement("div"),t=o??document.body;e.innerHTML=this.replaceContent(s);var n=e.children[0];return t.appendChild(n),n},applyStyle:function(s){if(!(typeof this.options[s]>"u"))for(const[o,e]of Object.entries(this.options[s]))for(const[t,n]of Object.entries(e))document.documentElement.style.setProperty(`--dp-cookie-${s}-${o}-${t}`,n)},fireEvent:function(s,o){var e;o?e=new CustomEvent(s,{detail:{$el:o}}):e=new Event(s),document.dispatchEvent(e)}};i.utils=l;var u=function(){var s={cookie:{name:"dp_cookieconsent_status",path:"/",domain:"",expiryDays:365,secure:!1},position:"bottom-right",content:{},theme:"edgeless",type:"opt-in",revokable:!0,reloadOnRevoke:!0,checkboxes:[{name:"statistics",checked:!1},{name:"marketing",checked:!1}],palette:{popup:{background:"rgba(0,0,0,0.8)",text:"#ffffff"},button:{background:"#f96332",text:"#ffffff"}},overlay:{notice:!0,box:{background:"rgba(0,0,0,0.8)",text:"#ffffff"},btn:{background:"#f96332",text:"#ffffff"}},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(){},onStatusChange:function(e,t){},onRevokeChoice:function(){},compilance:{"opt-in":k,extend:b},revokeBtn:B,overlayLayout:A,wrap:{consent:L,config:S},elements:{"allow-all":w,allow:m,dismiss:C,deny:x,config:E,selection:y,description:g}};function o(){}return o.prototype.replaceContent=function(e){var t=this.options,n=["cc-"+t.position,"cc-type-"+t.type,"cc-theme-"+t.theme,"cc-hide"];e=e.replaceAll("{{classes}}",n.join(" "));for(const[c,r]of Object.entries(t.elements))e=e.replaceAll("{{"+c+"}}",r||"");for(const[c,r]of Object.entries(t.content))e=e.replaceAll("{{"+c+"}}",r||"");return e},o.prototype.templateOverwrites=function(){let e=i.utils.getElementsByTag("script","data-dp-cookieRevoke");e.length>0&&(this.options.revokeBtn=e[0].innerHTML);let t=i.utils.getElementsByTag("script","data-dp-cookieDesc");t.length>0&&(this.options.elements.description=t[0].innerHTML);let n=i.utils.getElementsByTag("script","data-dp-cookieSelect");n.length>0&&(this.options.elements.selection=n[0].innerHTML)},o.prototype.initialise=function(e){l.deepExtend(this.options={},s),typeof e.checkboxes=="object"&&(e.checkboxes=l.reformatCheckboxOptions(e.checkboxes)),typeof e=="object"&&l.deepExtend(this.options,e);var t=this.options.onInitialise.bind(this);this.templateOverwrites(),this.options.revokable&&(this.revokeBtn=i.utils.appendElement.call(this,this.options.revokeBtn)),this.window=i.utils.appendElement.call(this,this.options.wrap.consent),this.options.type=="extend"&&i.configWindow.initialise(this.options.wrap.config),i.utils.applyStyle.call(this,"palette"),i.utils.applyStyle.call(this,"overlay"),this.addCompilance(this.window),t(this),this.bindBtns(),this.presetCheckboxes()},o.prototype.presetCheckboxes=function(){var e=i.utils.getCookie(this.options.cookie.name);typeof e<"u"&&l.deepExtend(this.options.checkboxes,e.checkboxes);var t=this.getCheckboxInputs(!0);t.length>0&&t.forEach(n=>{var c=n.id;c=c.replace("dp--cookie-",""),this.options.checkboxes.map((r,a)=>{r.name==c&&(n.checked=r.checked)}),c=="require"&&(n.checked=!0,n.disabled=!0)})},o.prototype.addCompilance=function(e){var t=this.options.compilance["opt-in"];typeof this.options.compilance[this.options.type]<"u"&&(t=this.options.compilance[this.options.type]),this.compilance=i.utils.appendElement.call(this,t,e),this.allowAllBtn=this.compilance.getElementsByClassName("cc-allow-all"),this.allowBtn=this.compilance.getElementsByClassName("cc-allow"),this.denyBtn=this.compilance.getElementsByClassName("cc-deny"),this.dismissBtn=this.compilance.getElementsByClassName("cc-dismiss"),this.configBtn=this.compilance.querySelector("button.cc-config")},o.prototype.bindBtns=function(){this.allowAllBtn.length>0&&(this.allowAllBtn[0].onclick=()=>this.allowAll.call(this)),this.allowBtn.length>0&&(this.allowBtn[0].onclick=()=>this.allow.call(this)),this.dismissBtn.length>0&&(this.dismissBtn[0].onclick=()=>this.allow.call(this)),this.denyBtn.length>0&&(this.denyBtn[0].onclick=()=>this.denyAll.call(this)),this.revokeBtn&&(this.revokeBtn.onclick=()=>this.revoke.call(this)),this.configBtn&&(this.configBtn.onclick=()=>i.configWindow.showConfig())},o.prototype.allowAll=function(){this.saveCheckboxes(!0),i.utils.fireEvent("dp--cookie-accept"),this.save()},o.prototype.denyAll=function(){this.saveCheckboxes(!1),i.utils.fireEvent("dp--cookie-deny"),this.save()},o.prototype.allow=function(){i.utils.fireEvent("dp--cookie-accept"),this.save()},o.prototype.getCheckboxInputs=function(e){var t=document.querySelectorAll('input[id^="dp--cookie-"]');if(e)return t;var n=[];return t.forEach(c=>{var r=c.id;switch(r=r.replace("dp--cookie-",""),r){case"require":break;default:n.push(c)}}),n},o.prototype.saveCheckboxes=function(e){var t=this.getCheckboxInputs();t.length>0&&t.forEach(n=>{var c=n.id;c=c.replace("dp--cookie-",""),typeof e<"u"&&(n.checked=e);var r=this.options.checkboxes.map((a,p)=>{if(a.name==c)return this.options.checkboxes[p].checked=n.checked,!0}).filter(a=>a);r.length||this.options.checkboxes.push({name:c,checked:n.checked})})},o.prototype.save=function(){this.saveCheckboxes(),this.close()},o.prototype.hasChanged=function(){var e=!1;return typeof this.originalCookie>"u"||typeof this.originalCookie.checkboxes>"u"?!1:(this.originalCookie.checkboxes.map((t,n)=>{var c=this.options.checkboxes[n];if(t.checked===!0&&(!c||c.checked==!1)){e=!0;var r=this.options.onStatusChange.bind(this);r(c,t)}}),e)},o.prototype.hasConsent=function(){var e=i.utils.getCookie(this.options.cookie.name);return!(typeof e>"u"||e.status=="open")},o.prototype.saveCookie=function(e){var t=i.utils.prepareCookie(e,this.options.cookie.name);!t.exists&&t.config.status=="open"||(i.utils.setCookie(this.options.cookie.name,t.config,this.options.cookie.expiryDays,this.options.cookie.domain,this.options.cookie.path,this.options.cookie.secure),this.hasConsent()&&this.hasChanged()&&this.options.reloadOnRevoke&&location.reload())},o.prototype.revoke=function(){var e=this.options.onRevokeChoice.bind(this);e(this),i.utils.fireEvent("dp--cookie-revoke"),this.open()},o.prototype.open=function(){this.revokeBtn&&this.revokeBtn.classList.add("cc-hide"),this.showPopup(),this.originalCookie=i.utils.getCookie(this.options.cookie.name);var e=this.options.onPopupOpen.bind(this);e(this),this.saveCookie({status:"open"}),document.querySelector("body").classList.add("dp--cookie-consent")},o.prototype.hidePopup=function(){this.window.classList.add("cc-hide")},o.prototype.showPopup=function(){this.window.classList.remove("cc-hide")},o.prototype.close=function(){this.hidePopup(),i.configWindow.closeConfig(),this.revokeBtn&&this.revokeBtn.classList.remove("cc-hide");var e=this.options.onPopupClose.bind(this);e(this),this.saveCookie({status:"approved",checkboxes:this.options.checkboxes}),document.querySelector("body").classList.remove("dp--cookie-consent"),this.execute()},o.prototype.execute=function(){i.Handler.execute(this.options.checkboxes),i.Overlay.execute(this.options.checkboxes)},new o}();i.popup=u;var f=function(){function s(){}return s.prototype.overlays=function(){i.popup.options.overlay.notice&&(this.templateOverwrites(),this.overlaysView("iframe"),this.overlaysView("dp-content"))},s.prototype.templateOverwrites=function(){let o=i.utils.getElementsByTag("script","data-dp-cookieIframe");o.length>0&&(i.popup.options.overlayLayout=o[0].innerHTML)},s.prototype.overlaysView=function(o){var e=i.utils.getElementsByTag(o);e.length!=0&&e.forEach(t=>{var n=t.getAttribute("data-cookieconsent-notice")||i.popup.options.content.media.notice,c=t.getAttribute("data-cookieconsent-description")||i.popup.options.content.media.desc,r=t.getAttribute("data-cookieconsent-btn")||i.popup.options.content.media.btn,a=t.getAttribute("data-cookieconsent");if(!t.hasAttribute("data-cookieconsent-overlay-loaded")){t.setAttribute("data-cookieconsent-overlay-loaded","loaded");var p=document.createElement("div");p.classList.add("dp--overlay");var d=i.popup.options.overlayLayout.replace("{{notice}}",n).replace("{{desc}}",c).replace("{{type}}",a).replace("{{btn}}",r);d=i.utils.appendElement.call(i.popup,d,p),d.getElementsByClassName("db--overlay-submit"),t.parentNode.insertBefore(p,t.nextSibling)}})},s.prototype.execute=function(o){this.executeIframe(o),this.executeContent(o)},s.prototype.ajax=function(o,e,t,n){var c=new XMLHttpRequest;c.open(o,e),c.setRequestHeader("X-Requested-With","XMLHttpRequest"),c.setRequestHeader("Content-type","text/html"),c.onload=function(){c.status<200||c.status>=300?n(c):t(c)},c.onerror=function(){n(c)},c.send()},s.prototype.executeContent=function(o){var e=i.utils.getElementsByTag("dp-content");e.length>0&&e.forEach(t=>{if(i.Handler.typeAllowed(t,o)){t.classList.add("dp--loaded"),t.setAttribute("data-cookieconsent-loaded",t.getAttribute("data-cookieconsent")),t.removeAttribute("data-cookieconsent");var n=t.getAttribute("data-src");n&&n.length>0?this.ajax("GET",n,function(c){t.innerHTML=c.response,i.utils.fireEvent("dp--cookie-content",t)},function(c){}):i.utils.fireEvent("dp--cookie-content",t)}})},s.prototype.executeIframe=function(o){var e=i.utils.getElementsByTag("iframe");e.length>0&&e.forEach(t=>{if(i.Handler.typeAllowed(t,o)){var n=t.cloneNode(!0);n.getAttribute("data-src")&&(n.src=n.getAttribute("data-src")),t.parentNode.replaceChild(n,t),n.classList.add("dp--loaded"),n.setAttribute("data-cookieconsent-loaded",n.getAttribute("data-cookieconsent")),n.removeAttribute("data-cookieconsent"),i.utils.fireEvent("dp--cookie-iframe",n)}})},new s}();i.Overlay=f;var h=function(){function s(){}return s.prototype.execute=function(o){var e=i.utils.getElementsByTag("script");e.length>0&&e.forEach(t=>{if(this.typeAllowed(t,o)){var n=t.innerHTML;n&&n.length&&(n=n.trim()),n&&n.length?(eval.call(this,n),i.utils.fireEvent("dp--cookie-fire",t)):t.getAttribute("data-src")?this.asyncJS(t.getAttribute("data-src"),function(c){i.utils.fireEvent("dp--cookie-fire",t)}):t.src&&this.asyncJS(t.src,function(c){i.utils.fireEvent("dp--cookie-fire",t)}),t.setAttribute("data-cookieconsent-loaded",t.getAttribute("data-cookieconsent")),t.removeAttribute("data-cookieconsent")}})},s.prototype.asyncLoad=function(o,e,t){var n=document,c=n.createElement(e),r=n.getElementsByTagName(e)[0];switch(e){case"script":c.src=o,c.setAttribute("defer","");break;case"link":c.rel="stylesheet",c.type="text/css",c.setAttribute("defer",""),c.href=o;break}t&&c.addEventListener("load",function(a){t(null,a)},!1),r.parentNode.insertBefore(c,r)},s.prototype.asyncJS=function(o,e){this.asyncLoad(o,"script",e)},s.prototype.typeAllowed=function(o,e){var t=o.getAttribute("data-cookieconsent"),n=e.map(c=>{if(c.name==t&&c.checked===!0)return!0});return n.indexOf(!0)!==-1},new s}();i.Handler=h,i.initialise=function(s,o){if(o||(o=function(){}),i.popup.initialise(s),i.Overlay.overlays(),o(i.popup),i.utils.fireEvent("dp--cookie-init"),i.popup.hasConsent()||l.detectRobot(navigator.userAgent)){i.popup.close(),i.utils.fireEvent("dp--cookie-accept-init");return}i.popup.open()};var v=function(){function s(){}return s.prototype.initialise=function(o){this.prepareConfig(),this.configWrap=i.utils.appendElement.call(i.popup,o),this.getElements(),this.bindBtns()},s.prototype.prepareConfig=function(){var o=i.popup.options,e=o.cookies.map(t=>{var n=t.cookies.map(c=>(this.options=i.utils.deepExtend({elements:{},content:c},o),i.popup.replaceContent.call(this,H))).join("");return this.options=i.utils.deepExtend({elements:{"config-cookie":n},content:{group:t.name,"group-lower":t.name.toLowerCase()}},o),i.popup.replaceContent.call(this,O)}).join("");i.popup.options.elements["cookie-group"]=e},s.prototype.getElements=function(){this.closeBtn=this.configWrap.querySelector("button.cc-btn-close"),this.allowAllBtn=this.configWrap.querySelector("button.cc-allow-all"),this.allowBtn=this.configWrap.querySelector("button.cc-allow"),this.denyBtn=this.configWrap.querySelector("button.cc-deny"),this.configGroups=this.configWrap.querySelectorAll(".cc-config-group")},s.prototype.bindBtns=function(){this.allowAllBtn&&(this.allowAllBtn.onclick=()=>i.popup.allowAll(this)),this.allowBtn&&(this.allowBtn.onclick=()=>i.popup.allow(this)),this.denyBtn&&(this.denyBtn.onclick=()=>i.popup.denyAll(this)),this.closeBtn&&(this.closeBtn.onclick=()=>this.hideConfig.call(this)),this.configGroups&&this.configGroups.forEach(o=>{o.querySelector(".cc-btn-collapse").onclick=()=>{var e=!o.classList.contains("cc-show");this.configGroups.forEach(t=>t.classList.remove("cc-show")),e&&o.classList.add("cc-show")}})},s.prototype.closeConfig=function(){this.configWrap&&this.configWrap.classList.remove("cc-show")},s.prototype.hideConfig=function(){i.popup.showPopup(),this.configWrap&&this.closeConfig()},s.prototype.showConfig=function(){this.configWrap&&this.configWrap.classList.add("cc-show"),i.popup.hidePopup()},new s}();i.configWindow=v,i.forceAccept=function(s){var o=s.getAttribute("data-cookieconsent"),e=i.popup.getCheckboxInputs();console.log(e),e.length>0&&(e.forEach(t=>{var n=t.id;n=n.replace("dp--cookie-",""),i.popup.hasConsent()||(t.checked=!1),n==o&&(t.checked=!0)}),i.utils.fireEvent("dp--cookie-accept")),i.popup.save()},i.forceDeny=function(s){var o=s.getAttribute("data-cookieconsent"),e=i.popup.getCheckboxInputs();e.length>0&&e.forEach(t=>{var n=t.id;n=n.replace("dp--cookie-",""),i.popup.hasConsent()||(t.checked=!1),n==o&&(t.checked=!1)}),i.popup.save()},i.hasInitialised=!0,window.DPCookieConsent=i,window.addEventListener("load",function(){window.DPCookieConsent.initialise(window.cookieconsent_options||{}),window.DPCookieConsent.loaded=!0})}})(window.DPCookieConsent||{}); diff --git a/ext_emconf.php b/ext_emconf.php index 8ab76c1..23a7d90 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -25,6 +25,6 @@ 'suggests' => [], ], 'state' => 'beta', // stable - 'version' => '12.1.0' + 'version' => '12.1.1' ];