diff --git a/biscuitman.js b/biscuitman.js index c6f70d7..cf87b3b 100644 --- a/biscuitman.js +++ b/biscuitman.js @@ -184,7 +184,7 @@ } function insertScripts() { - const scripts = ui.querySelectorAll('script[data-consent]') + const scripts = d.querySelectorAll('script[data-consent]') scripts.forEach(script => { if (!w[o.global][script.dataset.consent]) return false diff --git a/dist/biscuitman.min.css b/dist/biscuitman.min.css index 295a200..4303afb 100644 --- a/dist/biscuitman.min.css +++ b/dist/biscuitman.min.css @@ -1 +1 @@ -/*! biscuitman.js 0.3.4 */.biscuitman{--t:#444;--b:#fff;--c:#105d89;background:var(--b);box-sizing:border-box;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;box-shadow:0 -2px 10px #00000029}.biscuitman *{box-sizing:border-box;margin:0;padding:0;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman.bm-hide{padding:0}.biscuitman.bm-hide article{display:none}.biscuitman article{position:relative}@media (width>=770px){.biscuitman article{padding-right:calc(max(300px,30vw) + 20px)}.biscuitman article nav{width:30vw;min-width:300px;position:absolute;bottom:50%;right:0;transform:translateY(50%)}}.biscuitman article p{color:var(--t);margin:10px 0;font-size:13px}@media (width>=575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--b);border:2px solid var(--c);color:var(--c);cursor:pointer;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:var(--c);color:var(--b)!important}.biscuitman button[data-id=close]{color:#000;opacity:.6;-webkit-user-select:none;user-select:none;z-index:2;background:0 0;border:none;outline:none;padding:10px;font-size:24px;line-height:1em;position:absolute;top:0;right:10px}.biscuitman button[disabled]{display:none}.biscuitman button:hover{opacity:.8}@media (width>=576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (width<=575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (width>=576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (width>=576px) and (height>=1134px){.biscuitman dialog{height:890px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{flex-direction:column;height:100%;padding:20px;display:flex}.biscuitman .bm-dialog b{position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--b)20%,transparent);pointer-events:none;z-index:1;width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";background:linear-gradient(0deg,var(--b)20%,transparent);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:#ddd var(--b);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (width>=576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;line-height:18px}.biscuitman .bm-sections>p span{padding-bottom:5px;font-size:13px;display:block}@media (width>=576px){.biscuitman .bm-sections>p span{font-size:14px}}.biscuitman .bm-sections>p span:has(.more)~span{display:none}.biscuitman a{font-size:inherit;color:var(--c);cursor:pointer;text-decoration:none;display:inline-block}.biscuitman a:hover{text-decoration:underline}.biscuitman section{margin-bottom:10px;position:relative}.biscuitman section:first-of-type{margin-top:10px}.biscuitman details{border:1px solid #ccc;border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px #0000001a}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid #777;border-color:#0000 #777 #777 #0000;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:var(--t);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:#eee;margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--t);font-size:13px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;height:var(--height);width:var(--width);border-radius:var(--height);background-color:#999;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--b);height:calc(var(--height) - calc(var(--gap)*2));width:calc(var(--height) - calc(var(--gap)*2));height:var(--height);width:var(--height);left:var(--gap);transform-origin:50%;border-radius:100%;display:block;position:absolute;top:50%;left:0;transform:translateY(-50%)scale(.8)}.biscuitman label:has(:checked){background-color:var(--c)}.biscuitman label:has(:checked):before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label:has([disabled]:checked){opacity:.6}.biscuitman label input{opacity:0} \ No newline at end of file +/*! biscuitman.js 0.3.5 */.biscuitman{--t:#444;--b:#fff;--c:#105d89;background:var(--b);box-sizing:border-box;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;box-shadow:0 -2px 10px #00000029}.biscuitman *{box-sizing:border-box;margin:0;padding:0;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman.bm-hide{padding:0}.biscuitman.bm-hide article{display:none}.biscuitman article{position:relative}@media (width>=770px){.biscuitman article{padding-right:calc(max(300px,30vw) + 20px)}.biscuitman article nav{width:30vw;min-width:300px;position:absolute;bottom:50%;right:0;transform:translateY(50%)}}.biscuitman article p{color:var(--t);margin:10px 0;font-size:13px}@media (width>=575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--b);border:2px solid var(--c);color:var(--c);cursor:pointer;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:var(--c);color:var(--b)!important}.biscuitman button[data-id=close]{color:#000;opacity:.6;-webkit-user-select:none;user-select:none;z-index:2;background:0 0;border:none;outline:none;padding:10px;font-size:24px;line-height:1em;position:absolute;top:0;right:10px}.biscuitman button[disabled]{display:none}.biscuitman button:hover{opacity:.8}@media (width>=576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (width<=575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (width>=576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (width>=576px) and (height>=1134px){.biscuitman dialog{height:890px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{flex-direction:column;height:100%;padding:20px;display:flex}.biscuitman .bm-dialog b{position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--b)20%,transparent);pointer-events:none;z-index:1;width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";background:linear-gradient(0deg,var(--b)20%,transparent);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:#ddd var(--b);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (width>=576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;line-height:18px}.biscuitman .bm-sections>p span{padding-bottom:5px;font-size:13px;display:block}@media (width>=576px){.biscuitman .bm-sections>p span{font-size:14px}}.biscuitman .bm-sections>p span:has(.more)~span{display:none}.biscuitman a{font-size:inherit;color:var(--c);cursor:pointer;text-decoration:none;display:inline-block}.biscuitman a:hover{text-decoration:underline}.biscuitman section{margin-bottom:10px;position:relative}.biscuitman section:first-of-type{margin-top:10px}.biscuitman details{border:1px solid #ccc;border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px #0000001a}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid #777;border-color:#0000 #777 #777 #0000;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:var(--t);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:#eee;margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--t);font-size:13px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;height:var(--height);width:var(--width);border-radius:var(--height);background-color:#999;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--b);height:calc(var(--height) - calc(var(--gap)*2));width:calc(var(--height) - calc(var(--gap)*2));height:var(--height);width:var(--height);left:var(--gap);transform-origin:50%;border-radius:100%;display:block;position:absolute;top:50%;left:0;transform:translateY(-50%)scale(.8)}.biscuitman label:has(:checked){background-color:var(--c)}.biscuitman label:has(:checked):before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label:has([disabled]:checked){opacity:.6}.biscuitman label input{opacity:0} \ No newline at end of file diff --git a/dist/biscuitman.min.js b/dist/biscuitman.min.js index 4076355..c826aff 100644 --- a/dist/biscuitman.min.js +++ b/dist/biscuitman.min.js @@ -1 +1 @@ -/*! biscuitman.js 0.3.4 */((e,t,a)=>{let n;let o={storageKey:"myconsent",global:"Consent",force:!1,enableMore:!0,sections:["essential"],title:"Your privacy matters",message:"We use cookies",settings:"Settings",reject:"Reject All",accept:"Accept All",save:"Save My Settings",settingsTitle:"My Consent Settings",info:"",more:"(Show more)",noCookies:"No cookies to display",acceptNonEU:!1,...t.biscuitman},s=e.createElement("div"),i=e=>s.classList[e?"remove":"add"]("bm-hide");function c(e){let t=e.target.dataset.id;switch(b("button",{id:t}),t){case"accept":p(!0);break;case"close":n.close();break;case"settings":d();break;case"save":p();break;case"reject":p(!1)}}function l(){b("close")}function r(e){o.force&&e.preventDefault()}function d(){b("open"),n.showModal()}function b(t,n){let o=`${a}:${t}`,s={...void 0!==n&&n,time:+new Date};e.dispatchEvent(new CustomEvent(o,s)),console.debug(o,s)}function u(){try{return JSON.parse(localStorage.getItem(o.storageKey))}catch(e){return console.error(e),localStorage.removeItem(o.storageKey),{}}}function p(e){let a=void 0===e;t[o.global].consentTime=+new Date,o.sections.forEach(n=>{if("essential"===n)return!1;let i=s.querySelector(`[data-s=${n}]`);t[o.global][n]=a?i.checked:e,a||(i.checked=e)}),localStorage.setItem(o.storageKey,JSON.stringify(t[o.global])),b("save",{data:t[o.global]}),m(),n.close(),i(!1)}function m(){s.querySelectorAll("script[data-consent]").forEach(a=>{if(!t[o.global][a.dataset.consent])return!1;let n=e.createElement("script");for(let{name:e,value:t}of a.attributes)e.startsWith("data-")||"type"===e||n.setAttribute(e,t);n.setAttribute("type",a.dataset.type||"text/javascript"),a.src||(n.textContent=a.textContent),a.parentNode.replaceChild(n,a),b("inject",{el:a}),a.src&&""!==a.textContent.trim()&&n.addEventListener("load",()=>{let t=e.createElement("script");t.textContent=a.textContent,n.insertAdjacentElement("afterend",t),b("inject",{el:t,parent:a})})})}t[o.global]=u()||{};let g=Intl.DateTimeFormat().resolvedOptions().timeZone,$=/^(GMT|UTC)$/.test(g)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(g);o.acceptNonEU&&!$&&(p(!0),i(!1)),function(){s.classList.add(a),s.style="position:fixed;background:#fff;bottom:0",s.innerHTML=`
${o.title}

${o.message}

${o.settingsTitle}

${o.message}

${o.info.split("\n").map((e,t,a)=>{let n=a.length>1&&o.enableMore&&0==t?`${o.more}`:"";return`${e}${n}`}).join("")}

${o.sections.map(e=>{let n=t[o.global][e],s="essential"===e,i=s?"checked":"";void 0!==n&&(i=n?"checked":"");let c=o[`${e}Cookies`];return`
${o[`${e}Title`]}

${o[`${e}Message`]}

${c?Object.entries(c).map(([e,t])=>`
${e}
${t}
`).join(""):`
${o.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${o.linkText}`),s.querySelectorAll("button").forEach(e=>e.addEventListener("click",c)),(n=s.querySelector("dialog")).addEventListener("close",l),n.addEventListener("cancel",r);let i=s.querySelector(".more");i&&i.addEventListener("click",i.remove),e.body.appendChild(s)}(),t[o.global].consentTime?(i(!1),m()):o.force&&d(),t.bmInvalidate=()=>{b("invalidate",{data:u()}),p(!1),localStorage.removeItem(o.storageKey),i(!0)},t.bmUpdate=()=>{b("update",{data:u()}),d()}})(document,window,"biscuitman"); \ No newline at end of file +/*! biscuitman.js 0.3.5 */((e,t,a)=>{let n;let o={storageKey:"myconsent",global:"Consent",force:!1,enableMore:!0,sections:["essential"],title:"Your privacy matters",message:"We use cookies",settings:"Settings",reject:"Reject All",accept:"Accept All",save:"Save My Settings",settingsTitle:"My Consent Settings",info:"",more:"(Show more)",noCookies:"No cookies to display",acceptNonEU:!1,...t.biscuitman},s=e.createElement("div"),i=e=>s.classList[e?"remove":"add"]("bm-hide");function c(e){let t=e.target.dataset.id;switch(b("button",{id:t}),t){case"accept":p(!0);break;case"close":n.close();break;case"settings":d();break;case"save":p();break;case"reject":p(!1)}}function l(){b("close")}function r(e){o.force&&e.preventDefault()}function d(){b("open"),n.showModal()}function b(t,n){let o=`${a}:${t}`,s={...void 0!==n&&n,time:+new Date};e.dispatchEvent(new CustomEvent(o,s)),console.debug(o,s)}function u(){try{return JSON.parse(localStorage.getItem(o.storageKey))}catch(e){return console.error(e),localStorage.removeItem(o.storageKey),{}}}function p(e){let a=void 0===e;t[o.global].consentTime=+new Date,o.sections.forEach(n=>{if("essential"===n)return!1;let i=s.querySelector(`[data-s=${n}]`);t[o.global][n]=a?i.checked:e,a||(i.checked=e)}),localStorage.setItem(o.storageKey,JSON.stringify(t[o.global])),b("save",{data:t[o.global]}),m(),n.close(),i(!1)}function m(){e.querySelectorAll("script[data-consent]").forEach(a=>{if(!t[o.global][a.dataset.consent])return!1;let n=e.createElement("script");for(let{name:e,value:t}of a.attributes)e.startsWith("data-")||"type"===e||n.setAttribute(e,t);n.setAttribute("type",a.dataset.type||"text/javascript"),a.src||(n.textContent=a.textContent),a.parentNode.replaceChild(n,a),b("inject",{el:a}),a.src&&""!==a.textContent.trim()&&n.addEventListener("load",()=>{let t=e.createElement("script");t.textContent=a.textContent,n.insertAdjacentElement("afterend",t),b("inject",{el:t,parent:a})})})}t[o.global]=u()||{};let g=Intl.DateTimeFormat().resolvedOptions().timeZone,$=/^(GMT|UTC)$/.test(g)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(g);o.acceptNonEU&&!$&&(p(!0),i(!1)),function(){s.classList.add(a),s.style="position:fixed;background:#fff;bottom:0",s.innerHTML=`
${o.title}

${o.message}

${o.settingsTitle}

${o.message}

${o.info.split("\n").map((e,t,a)=>{let n=a.length>1&&o.enableMore&&0==t?`${o.more}`:"";return`${e}${n}`}).join("")}

${o.sections.map(e=>{let n=t[o.global][e],s="essential"===e,i=s?"checked":"";void 0!==n&&(i=n?"checked":"");let c=o[`${e}Cookies`];return`
${o[`${e}Title`]}

${o[`${e}Message`]}

${c?Object.entries(c).map(([e,t])=>`
${e}
${t}
`).join(""):`
${o.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${o.linkText}`),s.querySelectorAll("button").forEach(e=>e.addEventListener("click",c)),(n=s.querySelector("dialog")).addEventListener("close",l),n.addEventListener("cancel",r);let i=s.querySelector(".more");i&&i.addEventListener("click",i.remove),e.body.appendChild(s)}(),t[o.global].consentTime?(i(!1),m()):o.force&&d(),t.bmInvalidate=()=>{b("invalidate",{data:u()}),p(!1),localStorage.removeItem(o.storageKey),i(!0)},t.bmUpdate=()=>{b("update",{data:u()}),d()}})(document,window,"biscuitman"); \ No newline at end of file diff --git a/dist/biscuitman.withcss.min.js b/dist/biscuitman.withcss.min.js index 7689e74..bc7a866 100644 --- a/dist/biscuitman.withcss.min.js +++ b/dist/biscuitman.withcss.min.js @@ -1 +1 @@ -/*! biscuitman.js 0.3.4 */((e,t,a)=>{let n;let o={storageKey:"myconsent",global:"Consent",force:!1,enableMore:!0,sections:["essential"],title:"Your privacy matters",message:"We use cookies",settings:"Settings",reject:"Reject All",accept:"Accept All",save:"Save My Settings",settingsTitle:"My Consent Settings",info:"",more:"(Show more)",noCookies:"No cookies to display",acceptNonEU:!1,...t.biscuitman},s=e.createElement("div"),i=e=>s.classList[e?"remove":"add"]("bm-hide");function c(e){let t=e.target.dataset.id;switch(b("button",{id:t}),t){case"accept":p(!0);break;case"close":n.close();break;case"settings":d();break;case"save":p();break;case"reject":p(!1)}}function l(){b("close")}function r(e){o.force&&e.preventDefault()}function d(){b("open"),n.showModal()}function b(t,n){let o=`${a}:${t}`,s={...void 0!==n&&n,time:+new Date};e.dispatchEvent(new CustomEvent(o,s)),console.debug(o,s)}function u(){try{return JSON.parse(localStorage.getItem(o.storageKey))}catch(e){return console.error(e),localStorage.removeItem(o.storageKey),{}}}function p(e){let a=void 0===e;t[o.global].consentTime=+new Date,o.sections.forEach(n=>{if("essential"===n)return!1;let i=s.querySelector(`[data-s=${n}]`);t[o.global][n]=a?i.checked:e,a||(i.checked=e)}),localStorage.setItem(o.storageKey,JSON.stringify(t[o.global])),b("save",{data:t[o.global]}),m(),n.close(),i(!1)}function m(){s.querySelectorAll("script[data-consent]").forEach(a=>{if(!t[o.global][a.dataset.consent])return!1;let n=e.createElement("script");for(let{name:e,value:t}of a.attributes)e.startsWith("data-")||"type"===e||n.setAttribute(e,t);n.setAttribute("type",a.dataset.type||"text/javascript"),a.src||(n.textContent=a.textContent),a.parentNode.replaceChild(n,a),b("inject",{el:a}),a.src&&""!==a.textContent.trim()&&n.addEventListener("load",()=>{let t=e.createElement("script");t.textContent=a.textContent,n.insertAdjacentElement("afterend",t),b("inject",{el:t,parent:a})})})}t[o.global]=u()||{};let g=Intl.DateTimeFormat().resolvedOptions().timeZone,$=/^(GMT|UTC)$/.test(g)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(g);o.acceptNonEU&&!$&&(p(!0),i(!1)),function(){s.classList.add(a),s.style="position:fixed;background:#fff;bottom:0",s.innerHTML=`
${o.title}

${o.message}

${o.settingsTitle}

${o.message}

${o.info.split("\n").map((e,t,a)=>{let n=a.length>1&&o.enableMore&&0==t?`${o.more}`:"";return`${e}${n}`}).join("")}

${o.sections.map(e=>{let n=t[o.global][e],s="essential"===e,i=s?"checked":"";void 0!==n&&(i=n?"checked":"");let c=o[`${e}Cookies`];return`
${o[`${e}Title`]}

${o[`${e}Message`]}

${c?Object.entries(c).map(([e,t])=>`
${e}
${t}
`).join(""):`
${o.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${o.linkText}`),s.querySelectorAll("button").forEach(e=>e.addEventListener("click",c)),(n=s.querySelector("dialog")).addEventListener("close",l),n.addEventListener("cancel",r);let i=s.querySelector(".more");i&&i.addEventListener("click",i.remove),e.body.appendChild(s)}(),t[o.global].consentTime?(i(!1),m()):o.force&&d(),t.bmInvalidate=()=>{b("invalidate",{data:u()}),p(!1),localStorage.removeItem(o.storageKey),i(!0)},t.bmUpdate=()=>{b("update",{data:u()}),d()}})(document,window,"biscuitman");;((d)=>{let c=d.createElement('style');c.textContent=`.biscuitman{--t:#444;--b:#fff;--c:#105d89;background:var(--b);box-sizing:border-box;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;box-shadow:0 -2px 10px #00000029}.biscuitman *{box-sizing:border-box;margin:0;padding:0;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman.bm-hide{padding:0}.biscuitman.bm-hide article{display:none}.biscuitman article{position:relative}@media (width>=770px){.biscuitman article{padding-right:calc(max(300px,30vw) + 20px)}.biscuitman article nav{width:30vw;min-width:300px;position:absolute;bottom:50%;right:0;transform:translateY(50%)}}.biscuitman article p{color:var(--t);margin:10px 0;font-size:13px}@media (width>=575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--b);border:2px solid var(--c);color:var(--c);cursor:pointer;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:var(--c);color:var(--b)!important}.biscuitman button[data-id=close]{color:#000;opacity:.6;-webkit-user-select:none;user-select:none;z-index:2;background:0 0;border:none;outline:none;padding:10px;font-size:24px;line-height:1em;position:absolute;top:0;right:10px}.biscuitman button[disabled]{display:none}.biscuitman button:hover{opacity:.8}@media (width>=576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (width<=575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (width>=576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (width>=576px) and (height>=1134px){.biscuitman dialog{height:890px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{flex-direction:column;height:100%;padding:20px;display:flex}.biscuitman .bm-dialog b{position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--b)20%,transparent);pointer-events:none;z-index:1;width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";background:linear-gradient(0deg,var(--b)20%,transparent);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:#ddd var(--b);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (width>=576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;line-height:18px}.biscuitman .bm-sections>p span{padding-bottom:5px;font-size:13px;display:block}@media (width>=576px){.biscuitman .bm-sections>p span{font-size:14px}}.biscuitman .bm-sections>p span:has(.more)~span{display:none}.biscuitman a{font-size:inherit;color:var(--c);cursor:pointer;text-decoration:none;display:inline-block}.biscuitman a:hover{text-decoration:underline}.biscuitman section{margin-bottom:10px;position:relative}.biscuitman section:first-of-type{margin-top:10px}.biscuitman details{border:1px solid #ccc;border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px #0000001a}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid #777;border-color:#0000 #777 #777 #0000;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:var(--t);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:#eee;margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--t);font-size:13px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;height:var(--height);width:var(--width);border-radius:var(--height);background-color:#999;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--b);height:calc(var(--height) - calc(var(--gap)*2));width:calc(var(--height) - calc(var(--gap)*2));height:var(--height);width:var(--height);left:var(--gap);transform-origin:50%;border-radius:100%;display:block;position:absolute;top:50%;left:0;transform:translateY(-50%)scale(.8)}.biscuitman label:has(:checked){background-color:var(--c)}.biscuitman label:has(:checked):before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label:has([disabled]:checked){opacity:.6}.biscuitman label input{opacity:0}`;d.documentElement.appendChild(c)})(document); \ No newline at end of file +/*! biscuitman.js 0.3.5 */((e,t,a)=>{let n;let o={storageKey:"myconsent",global:"Consent",force:!1,enableMore:!0,sections:["essential"],title:"Your privacy matters",message:"We use cookies",settings:"Settings",reject:"Reject All",accept:"Accept All",save:"Save My Settings",settingsTitle:"My Consent Settings",info:"",more:"(Show more)",noCookies:"No cookies to display",acceptNonEU:!1,...t.biscuitman},s=e.createElement("div"),i=e=>s.classList[e?"remove":"add"]("bm-hide");function c(e){let t=e.target.dataset.id;switch(b("button",{id:t}),t){case"accept":p(!0);break;case"close":n.close();break;case"settings":d();break;case"save":p();break;case"reject":p(!1)}}function l(){b("close")}function r(e){o.force&&e.preventDefault()}function d(){b("open"),n.showModal()}function b(t,n){let o=`${a}:${t}`,s={...void 0!==n&&n,time:+new Date};e.dispatchEvent(new CustomEvent(o,s)),console.debug(o,s)}function u(){try{return JSON.parse(localStorage.getItem(o.storageKey))}catch(e){return console.error(e),localStorage.removeItem(o.storageKey),{}}}function p(e){let a=void 0===e;t[o.global].consentTime=+new Date,o.sections.forEach(n=>{if("essential"===n)return!1;let i=s.querySelector(`[data-s=${n}]`);t[o.global][n]=a?i.checked:e,a||(i.checked=e)}),localStorage.setItem(o.storageKey,JSON.stringify(t[o.global])),b("save",{data:t[o.global]}),m(),n.close(),i(!1)}function m(){e.querySelectorAll("script[data-consent]").forEach(a=>{if(!t[o.global][a.dataset.consent])return!1;let n=e.createElement("script");for(let{name:e,value:t}of a.attributes)e.startsWith("data-")||"type"===e||n.setAttribute(e,t);n.setAttribute("type",a.dataset.type||"text/javascript"),a.src||(n.textContent=a.textContent),a.parentNode.replaceChild(n,a),b("inject",{el:a}),a.src&&""!==a.textContent.trim()&&n.addEventListener("load",()=>{let t=e.createElement("script");t.textContent=a.textContent,n.insertAdjacentElement("afterend",t),b("inject",{el:t,parent:a})})})}t[o.global]=u()||{};let g=Intl.DateTimeFormat().resolvedOptions().timeZone,$=/^(GMT|UTC)$/.test(g)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(g);o.acceptNonEU&&!$&&(p(!0),i(!1)),function(){s.classList.add(a),s.style="position:fixed;background:#fff;bottom:0",s.innerHTML=`
${o.title}

${o.message}

${o.settingsTitle}

${o.message}

${o.info.split("\n").map((e,t,a)=>{let n=a.length>1&&o.enableMore&&0==t?`${o.more}`:"";return`${e}${n}`}).join("")}

${o.sections.map(e=>{let n=t[o.global][e],s="essential"===e,i=s?"checked":"";void 0!==n&&(i=n?"checked":"");let c=o[`${e}Cookies`];return`
${o[`${e}Title`]}

${o[`${e}Message`]}

${c?Object.entries(c).map(([e,t])=>`
${e}
${t}
`).join(""):`
${o.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${o.linkText}`),s.querySelectorAll("button").forEach(e=>e.addEventListener("click",c)),(n=s.querySelector("dialog")).addEventListener("close",l),n.addEventListener("cancel",r);let i=s.querySelector(".more");i&&i.addEventListener("click",i.remove),e.body.appendChild(s)}(),t[o.global].consentTime?(i(!1),m()):o.force&&d(),t.bmInvalidate=()=>{b("invalidate",{data:u()}),p(!1),localStorage.removeItem(o.storageKey),i(!0)},t.bmUpdate=()=>{b("update",{data:u()}),d()}})(document,window,"biscuitman");;((d)=>{let c=d.createElement('style');c.textContent=`.biscuitman{--t:#444;--b:#fff;--c:#105d89;background:var(--b);box-sizing:border-box;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;box-shadow:0 -2px 10px #00000029}.biscuitman *{box-sizing:border-box;margin:0;padding:0;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman.bm-hide{padding:0}.biscuitman.bm-hide article{display:none}.biscuitman article{position:relative}@media (width>=770px){.biscuitman article{padding-right:calc(max(300px,30vw) + 20px)}.biscuitman article nav{width:30vw;min-width:300px;position:absolute;bottom:50%;right:0;transform:translateY(50%)}}.biscuitman article p{color:var(--t);margin:10px 0;font-size:13px}@media (width>=575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--b);border:2px solid var(--c);color:var(--c);cursor:pointer;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:var(--c);color:var(--b)!important}.biscuitman button[data-id=close]{color:#000;opacity:.6;-webkit-user-select:none;user-select:none;z-index:2;background:0 0;border:none;outline:none;padding:10px;font-size:24px;line-height:1em;position:absolute;top:0;right:10px}.biscuitman button[disabled]{display:none}.biscuitman button:hover{opacity:.8}@media (width>=576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (width<=575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (width>=576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (width>=576px) and (height>=1134px){.biscuitman dialog{height:890px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{flex-direction:column;height:100%;padding:20px;display:flex}.biscuitman .bm-dialog b{position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--b)20%,transparent);pointer-events:none;z-index:1;width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";background:linear-gradient(0deg,var(--b)20%,transparent);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:#ddd var(--b);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (width>=576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;line-height:18px}.biscuitman .bm-sections>p span{padding-bottom:5px;font-size:13px;display:block}@media (width>=576px){.biscuitman .bm-sections>p span{font-size:14px}}.biscuitman .bm-sections>p span:has(.more)~span{display:none}.biscuitman a{font-size:inherit;color:var(--c);cursor:pointer;text-decoration:none;display:inline-block}.biscuitman a:hover{text-decoration:underline}.biscuitman section{margin-bottom:10px;position:relative}.biscuitman section:first-of-type{margin-top:10px}.biscuitman details{border:1px solid #ccc;border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px #0000001a}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid #777;border-color:#0000 #777 #777 #0000;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:var(--t);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:#eee;margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--t);font-size:13px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;height:var(--height);width:var(--width);border-radius:var(--height);background-color:#999;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--b);height:calc(var(--height) - calc(var(--gap)*2));width:calc(var(--height) - calc(var(--gap)*2));height:var(--height);width:var(--height);left:var(--gap);transform-origin:50%;border-radius:100%;display:block;position:absolute;top:50%;left:0;transform:translateY(-50%)scale(.8)}.biscuitman label:has(:checked){background-color:var(--c)}.biscuitman label:has(:checked):before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label:has([disabled]:checked){opacity:.6}.biscuitman label input{opacity:0}`;d.documentElement.appendChild(c)})(document); \ No newline at end of file diff --git a/package.json b/package.json index 516bbd7..46864db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "biscuitman", - "version": "0.3.4", + "version": "0.3.5", "description": "Lightweight client-side cookie consent manager with dependency hooks and script injection", "browser": "biscuitman.js", "keywords": [