diff --git a/dist/biscuitman-legacy.css b/dist/biscuitman-legacy.css index 3faa6b0..77fd297 100644 --- a/dist/biscuitman-legacy.css +++ b/dist/biscuitman-legacy.css @@ -1,4 +1,4 @@ -/*! biscuitman-legacy.js 0.5.4 */ +/*! biscuitman-legacy.js 0.5.5 */ .biscuitman { --ui: 0, 0, 0; --tx: #444; diff --git a/dist/biscuitman-legacy.js b/dist/biscuitman-legacy.js index ddc45ed..7573fb7 100644 --- a/dist/biscuitman-legacy.js +++ b/dist/biscuitman-legacy.js @@ -1,4 +1,4 @@ -/*! biscuitman-legacy.js 0.5.4 */ +/*! biscuitman-legacy.js 0.5.5 */ (function () { 'use strict'; @@ -909,6 +909,9 @@ setConsents(loadConsents() || {}); + // Render UI + render(); + // Optional Non-EU auto-consent var tz = Intl.DateTimeFormat().resolvedOptions().timeZone; var isEuropeTimezone = /^(GMT|UTC)$/.test(tz) || /(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(tz); @@ -917,9 +920,6 @@ displayUI(false); } - // Render UI - render(); - // Wipe matching cookies/localStorages without consent clearStorages(); diff --git a/dist/biscuitman-legacy.min.css b/dist/biscuitman-legacy.min.css index 81a2370..6edca01 100644 --- a/dist/biscuitman-legacy.min.css +++ b/dist/biscuitman-legacy.min.css @@ -1 +1 @@ -/*! biscuitman-legacy.js 0.5.4 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;-moz-box-sizing:border-box;box-sizing:border-box;z-index:3;background:#fff;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px rgba(0,0,0,.16)}.bm-show .biscuitman{display:block}.biscuitman *{-moz-box-sizing:border-box;box-sizing:border-box;color:#444;margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){-webkit-transform:translateY(100%);transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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;-webkit-transform:translateY(50%);transform:translateY(50%)}}.biscuitman article p{color:#444;margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{color:#105d89;cursor:pointer;background:#fff;border:2px solid #105d89;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:#105d89;color:#fff!important}.biscuitman button[data-id=close]{color:rgba(0,0,0,.5);opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-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 (min-width:576px){.biscuitman nav{-webkit-flex-direction:row-reverse;flex-direction:row-reverse;gap:10px;width:100%;display:-webkit-flex;display:flex}.biscuitman nav button{-webkit-flex-grow:1;flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{-webkit-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;flex-grow:1;display:-webkit-flex;display:flex}}.biscuitman dialog{background:#fff;border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px rgba(0,0,0,.3)}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{-webkit-flex-direction:column;flex-direction:column;height:100%;padding:20px;display:-webkit-flex;display:flex}.biscuitman .bm-dialog b{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";pointer-events:none;z-index:1;background:linear-gradient(#fff 20%,rgba(255,255,255,0));width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";pointer-events:none;background:linear-gradient(rgba(255,255,255,0),#fff 80%);width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(0,0,0,.2) #fff;-webkit-flex-shrink:1;flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=more]~span{display:none}.biscuitman a{font-size:inherit;color:#105d89;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 rgba(0,0,0,.2);border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;-webkit-transform:rotate(45deg)scale(.3);transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;-webkit-flex-direction:column;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:-webkit-flex;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid rgba(0,0,0,.4);border-color:transparent rgba(0,0,0,.4) rgba(0,0,0,.4) transparent;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;-webkit-transform:rotate(-45deg)scale(.3);transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:#444;font-size:14px}.biscuitman summary>*{display:-webkit-inline-flex;display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(0,0,0,.08);margin:10px;padding:10px;display:-webkit-flex;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:#444;font-size:12px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;background-color:rgba(0,0,0,.3);border-radius:1.2em;width:2.3em;height:1.2em;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";-webkit-transform-origin:50%;transform-origin:50%;background:#fff;border-radius:100%;width:1.2em;height:1.2em;display:block;position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%)scale(.8);transform:translateY(-50%)scale(.8)}.biscuitman label.checked{background-color:#105d89}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)} \ No newline at end of file +/*! biscuitman-legacy.js 0.5.5 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;-moz-box-sizing:border-box;box-sizing:border-box;z-index:3;background:#fff;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px rgba(0,0,0,.16)}.bm-show .biscuitman{display:block}.biscuitman *{-moz-box-sizing:border-box;box-sizing:border-box;color:#444;margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){-webkit-transform:translateY(100%);transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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;-webkit-transform:translateY(50%);transform:translateY(50%)}}.biscuitman article p{color:#444;margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{color:#105d89;cursor:pointer;background:#fff;border:2px solid #105d89;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:#105d89;color:#fff!important}.biscuitman button[data-id=close]{color:rgba(0,0,0,.5);opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-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 (min-width:576px){.biscuitman nav{-webkit-flex-direction:row-reverse;flex-direction:row-reverse;gap:10px;width:100%;display:-webkit-flex;display:flex}.biscuitman nav button{-webkit-flex-grow:1;flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{-webkit-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;flex-grow:1;display:-webkit-flex;display:flex}}.biscuitman dialog{background:#fff;border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px rgba(0,0,0,.3)}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{-webkit-flex-direction:column;flex-direction:column;height:100%;padding:20px;display:-webkit-flex;display:flex}.biscuitman .bm-dialog b{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";pointer-events:none;z-index:1;background:linear-gradient(#fff 20%,rgba(255,255,255,0));width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";pointer-events:none;background:linear-gradient(rgba(255,255,255,0),#fff 80%);width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(0,0,0,.2) #fff;-webkit-flex-shrink:1;flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=more]~span{display:none}.biscuitman a{font-size:inherit;color:#105d89;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 rgba(0,0,0,.2);border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;-webkit-transform:rotate(45deg)scale(.3);transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;-webkit-flex-direction:column;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:-webkit-flex;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid rgba(0,0,0,.4);border-color:transparent rgba(0,0,0,.4) rgba(0,0,0,.4) transparent;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;-webkit-transform:rotate(-45deg)scale(.3);transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:#444;font-size:14px}.biscuitman summary>*{display:-webkit-inline-flex;display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(0,0,0,.08);margin:10px;padding:10px;display:-webkit-flex;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:#444;font-size:12px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;background-color:rgba(0,0,0,.3);border-radius:1.2em;width:2.3em;height:1.2em;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";-webkit-transform-origin:50%;transform-origin:50%;background:#fff;border-radius:100%;width:1.2em;height:1.2em;display:block;position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%)scale(.8);transform:translateY(-50%)scale(.8)}.biscuitman label.checked{background-color:#105d89}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)} \ No newline at end of file diff --git a/dist/biscuitman-legacy.min.js b/dist/biscuitman-legacy.min.js index b0a6eb7..5b48bd8 100644 --- a/dist/biscuitman-legacy.min.js +++ b/dist/biscuitman-legacy.min.js @@ -1 +1 @@ -/*! biscuitman-legacy.js 0.5.4 */!function(){"use strict";if(Object.entries=Object.entries?Object.entries:function(t){var e=Object.prototype.toString.call(t);if(null==t)throw TypeError("Cannot convert undefined or null to object");if(!~["[object String]","[object Object]","[object Array]","[object Function]"].indexOf(e))return[];if(Object.keys)return Object.keys(t).map(function(e){return[e,t[e]]});var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push([r,t[r]]);return"[object Array]"===e?n:n.sort(function(t,e){return t[1]-e[1]})},Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var n,r;for(n=0,r=this.length;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substring(e,e+t.length)===t}),function(){if("undefined"!=typeof window)try{var t=new window.CustomEvent("test",{cancelable:!0});if(t.preventDefault(),!0!==t.defaultPrevented)throw Error("Could not prevent default")}catch(t){var e=function(t,e){var n,r,o={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i]);return o.bubbles=!!o.bubbles,o.cancelable=!!o.cancelable,(n=document.createEvent("CustomEvent")).initCustomEvent(t,o.bubbles,o.cancelable,o.detail),r=n.preventDefault,n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},n};e.prototype=window.Event.prototype,window.CustomEvent=e}}(),Array.from=Array.from||function(t,e,n){var r=[],o=[],i=0;for(window.Set&&t instanceof Set&&(t.forEach(function(t){o.push(t)}),t=o);i\ndetails, summary {\n display: block;\n}\ndetails:not([open]) > *:not(summary) {\n display: none;\n}\nsummary::before {\n content: "►";\n padding-right: 0.3rem;\n font-size: 0.6rem;\n cursor: default;\n}\n[open] > summary::before {\n content: "▼";\n}\n'),e=(t=document.createElement("details").constructor.prototype).setAttribute,n=t.removeAttribute,r=Object.getOwnPropertyDescriptor(t,"open"),Object.defineProperties(t,{open:{get:function(){return"DETAILS"==this.tagName?this.hasAttribute("open"):r&&r.get?r.get.call(this):void 0},set:function(t){return"DETAILS"==this.tagName?t?this.setAttribute("open",""):this.removeAttribute("open"):r&&r.set?r.set.call(this,t):void 0}},setAttribute:{value:function(t,n){var r=this,o=function(){return e.call(r,t,n)};if("open"==t&&"DETAILS"==this.tagName){var i=this.hasAttribute("open"),a=o();if(!i){var c=this.querySelector("summary");c&&c.setAttribute("aria-expanded",!0),p(this)}return a}return o()}},removeAttribute:{value:function(t){var e=this,r=function(){return n.call(e,t)};if("open"==t&&"DETAILS"==this.tagName){var o=this.hasAttribute("open"),i=r();if(o){var a=this.querySelector("summary");a&&a.setAttribute("aria-expanded",!1),p(this)}return i}return r()}}}),d(function(t){t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")}),u(document),window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){l.call(t.addedNodes,u)})}).observe(document.documentElement,{subtree:!0,childList:!0}):document.addEventListener("DOMNodeInserted",function(t){u(t.target)})),a.open&&!a.toggle&&(window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){var e=t.target,n=t.attributeName;"DETAILS"==e.tagName&&"open"==n&&p(e)})}).observe(document.documentElement,{attributes:!0,subtree:!0}):d(function(t){var e=t.getAttribute("open");setTimeout(function(){e!=t.getAttribute("open")&&p(t)},1)}))}(),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(this==null)throw TypeError('"this" is null or not defined');var n,r=Object(this),o=r.length>>>0;if(0===o)return!1;for(var i=0|e,a=Math.max(i>=0?i:o-Math.abs(i),0);at.length)&&(e=t.length);for(var n=0,r=Array(e);n\n".concat(u.title,"\n

").concat(u.message,"

\n\n\n\n
\n").concat(u.settingsTitle,"\n\n
\n

").concat(u.message,"

\n

").concat(u.info.split("\n").map(function(t,e,n){return"".concat(t,"\n").concat(n.length>1&&u.enableMore&&0==e?"".concat(u.more,""):"")}).join(""),"\n

\n").concat(u.sections.map(function(t){var e=v()[t],n="essential"===t,r=n?"disabled":"",o=n?"checked":"";void 0!==e&&(o=e?"checked":"");var c=u["".concat(t,"Cookies")];return"\n
\n
\n\n".concat(u["".concat(t,"Title")],"\n\n

').concat(u["".concat(t,"Message")],"

\n
\n").concat(c?a.entries(c).map(function(t){var e=i(t,2),n=e[0],r=e[1];return"
".concat(n,"
").concat(r,"
")}).join(""):"
".concat(u.noCookies,"
"),"\n
\n
")}).join(""),"\n
\n\n
\n
").replaceAll("{link}",'').concat(u.linkText,"")),f.onclick=function(t){var e=t.target.dataset.id;if(e)switch(y("button",{id:e}),e){case"more":t.target.remove();break;case"accept":j(!0);break;case"close":s.close();break;case"settings":m();break;case"save":j();break;case"reject":j(!1)}},f.onchange=function(t){t.target.dataset.s&&t.target.parentElement.classList.toggle("checked",t.target.checked)},s=f.querySelector("dialog"),u.dialogPolyfill&&!s.close&&function(e){function n(){t.documentElement.classList.add("bm-dialog-polyfill"),r.dialogPolyfill.registerDialog(e)}if(r.dialogPolyfill)n();else{var o=t.createElement("script");o.onload=n,o.src=u.dialogPolyfill,t.head.appendChild(o)}}(s),s.onclose=function(){return y("close")},u.force&&(s.oncancel=function(t){return t.preventDefault()},s.onkeydown=function(t){return"Escape"===t.key?t.preventDefault():null}),t.body.appendChild(f),r.addEventListener("resize",d),S(),r[u.global].consentTime?(p(!1),O()):(p(!0),u.force&&m()),r.bmInvalidate=function(){y("invalidate",{data:v()}),h({}),j(!1),g({}),localStorage.removeItem(u.key),p(!0),u.force&&s.showModal()},r.bmUpdate=function(){y("update",{data:v()}),p(!0),m()}}(document,window,Object,document.documentElement)}(); \ No newline at end of file +/*! biscuitman-legacy.js 0.5.5 */!function(){"use strict";if(Object.entries=Object.entries?Object.entries:function(t){var e=Object.prototype.toString.call(t);if(null==t)throw TypeError("Cannot convert undefined or null to object");if(!~["[object String]","[object Object]","[object Array]","[object Function]"].indexOf(e))return[];if(Object.keys)return Object.keys(t).map(function(e){return[e,t[e]]});var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push([r,t[r]]);return"[object Array]"===e?n:n.sort(function(t,e){return t[1]-e[1]})},Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var n,r;for(n=0,r=this.length;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substring(e,e+t.length)===t}),function(){if("undefined"!=typeof window)try{var t=new window.CustomEvent("test",{cancelable:!0});if(t.preventDefault(),!0!==t.defaultPrevented)throw Error("Could not prevent default")}catch(t){var e=function(t,e){var n,r,o={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i]);return o.bubbles=!!o.bubbles,o.cancelable=!!o.cancelable,(n=document.createEvent("CustomEvent")).initCustomEvent(t,o.bubbles,o.cancelable,o.detail),r=n.preventDefault,n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},n};e.prototype=window.Event.prototype,window.CustomEvent=e}}(),Array.from=Array.from||function(t,e,n){var r=[],o=[],i=0;for(window.Set&&t instanceof Set&&(t.forEach(function(t){o.push(t)}),t=o);i\ndetails, summary {\n display: block;\n}\ndetails:not([open]) > *:not(summary) {\n display: none;\n}\nsummary::before {\n content: "►";\n padding-right: 0.3rem;\n font-size: 0.6rem;\n cursor: default;\n}\n[open] > summary::before {\n content: "▼";\n}\n'),e=(t=document.createElement("details").constructor.prototype).setAttribute,n=t.removeAttribute,r=Object.getOwnPropertyDescriptor(t,"open"),Object.defineProperties(t,{open:{get:function(){return"DETAILS"==this.tagName?this.hasAttribute("open"):r&&r.get?r.get.call(this):void 0},set:function(t){return"DETAILS"==this.tagName?t?this.setAttribute("open",""):this.removeAttribute("open"):r&&r.set?r.set.call(this,t):void 0}},setAttribute:{value:function(t,n){var r=this,o=function(){return e.call(r,t,n)};if("open"==t&&"DETAILS"==this.tagName){var i=this.hasAttribute("open"),a=o();if(!i){var c=this.querySelector("summary");c&&c.setAttribute("aria-expanded",!0),p(this)}return a}return o()}},removeAttribute:{value:function(t){var e=this,r=function(){return n.call(e,t)};if("open"==t&&"DETAILS"==this.tagName){var o=this.hasAttribute("open"),i=r();if(o){var a=this.querySelector("summary");a&&a.setAttribute("aria-expanded",!1),p(this)}return i}return r()}}}),d(function(t){t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")}),u(document),window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){l.call(t.addedNodes,u)})}).observe(document.documentElement,{subtree:!0,childList:!0}):document.addEventListener("DOMNodeInserted",function(t){u(t.target)})),a.open&&!a.toggle&&(window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){var e=t.target,n=t.attributeName;"DETAILS"==e.tagName&&"open"==n&&p(e)})}).observe(document.documentElement,{attributes:!0,subtree:!0}):d(function(t){var e=t.getAttribute("open");setTimeout(function(){e!=t.getAttribute("open")&&p(t)},1)}))}(),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(this==null)throw TypeError('"this" is null or not defined');var n,r=Object(this),o=r.length>>>0;if(0===o)return!1;for(var i=0|e,a=Math.max(i>=0?i:o-Math.abs(i),0);at.length)&&(e=t.length);for(var n=0,r=Array(e);n\n".concat(u.title,"\n

").concat(u.message,"

\n\n\n\n
\n").concat(u.settingsTitle,"\n\n
\n

").concat(u.message,"

\n

").concat(u.info.split("\n").map(function(t,e,n){return"".concat(t,"\n").concat(n.length>1&&u.enableMore&&0==e?"".concat(u.more,""):"")}).join(""),"\n

\n").concat(u.sections.map(function(t){var e=v()[t],n="essential"===t,r=n?"disabled":"",o=n?"checked":"";void 0!==e&&(o=e?"checked":"");var c=u["".concat(t,"Cookies")];return"\n
\n
\n\n".concat(u["".concat(t,"Title")],"\n\n

').concat(u["".concat(t,"Message")],"

\n
\n").concat(c?a.entries(c).map(function(t){var e=i(t,2),n=e[0],r=e[1];return"
".concat(n,"
").concat(r,"
")}).join(""):"
".concat(u.noCookies,"
"),"\n
\n
")}).join(""),"\n
\n\n
\n
").replaceAll("{link}",'').concat(u.linkText,"")),f.onclick=function(t){var e=t.target.dataset.id;if(e)switch(y("button",{id:e}),e){case"more":t.target.remove();break;case"accept":j(!0);break;case"close":s.close();break;case"settings":m();break;case"save":j();break;case"reject":j(!1)}},f.onchange=function(t){t.target.dataset.s&&t.target.parentElement.classList.toggle("checked",t.target.checked)},s=f.querySelector("dialog"),u.dialogPolyfill&&!s.close&&function(e){function n(){t.documentElement.classList.add("bm-dialog-polyfill"),r.dialogPolyfill.registerDialog(e)}if(r.dialogPolyfill)n();else{var o=t.createElement("script");o.onload=n,o.src=u.dialogPolyfill,t.head.appendChild(o)}}(s),s.onclose=function(){return y("close")},u.force&&(s.oncancel=function(t){return t.preventDefault()},s.onkeydown=function(t){return"Escape"===t.key?t.preventDefault():null}),t.body.appendChild(f),r.addEventListener("resize",d);var A=Intl.DateTimeFormat().resolvedOptions().timeZone,w=/^(GMT|UTC)$/.test(A)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(A);u.acceptNonEU&&!w&&(j(!0),p(!1)),S(),r[u.global].consentTime?(p(!1),O()):(p(!0),u.force&&m()),r.bmInvalidate=function(){y("invalidate",{data:v()}),h({}),j(!1),g({}),localStorage.removeItem(u.key),p(!0),u.force&&s.showModal()},r.bmUpdate=function(){y("update",{data:v()}),p(!0),m()}}(document,window,Object,document.documentElement)}(); \ No newline at end of file diff --git a/dist/biscuitman-legacy.withcss.js b/dist/biscuitman-legacy.withcss.js index fad2781..a5baed2 100644 --- a/dist/biscuitman-legacy.withcss.js +++ b/dist/biscuitman-legacy.withcss.js @@ -1,4 +1,4 @@ -/*! biscuitman-legacy.js 0.5.4 */ +/*! biscuitman-legacy.js 0.5.5 */ (function () { 'use strict'; @@ -909,6 +909,9 @@ setConsents(loadConsents() || {}); + // Render UI + render(); + // Optional Non-EU auto-consent var tz = Intl.DateTimeFormat().resolvedOptions().timeZone; var isEuropeTimezone = /^(GMT|UTC)$/.test(tz) || /(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(tz); @@ -917,9 +920,6 @@ displayUI(false); } - // Render UI - render(); - // Wipe matching cookies/localStorages without consent clearStorages(); @@ -959,6 +959,6 @@ (function(d){ var css=d.createElement('style'); - css.textContent='/*! biscuitman-legacy.js 0.5.4 *//*! biscuitman-legacy.js 0.5.4 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;-moz-box-sizing:border-box;box-sizing:border-box;z-index:3;background:#fff;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px rgba(0,0,0,.16)}.bm-show .biscuitman{display:block}.biscuitman *{-moz-box-sizing:border-box;box-sizing:border-box;color:#444;margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){-webkit-transform:translateY(100%);transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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;-webkit-transform:translateY(50%);transform:translateY(50%)}}.biscuitman article p{color:#444;margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{color:#105d89;cursor:pointer;background:#fff;border:2px solid #105d89;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:#105d89;color:#fff!important}.biscuitman button[data-id=close]{color:rgba(0,0,0,.5);opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-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 (min-width:576px){.biscuitman nav{-webkit-flex-direction:row-reverse;flex-direction:row-reverse;gap:10px;width:100%;display:-webkit-flex;display:flex}.biscuitman nav button{-webkit-flex-grow:1;flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{-webkit-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;flex-grow:1;display:-webkit-flex;display:flex}}.biscuitman dialog{background:#fff;border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px rgba(0,0,0,.3)}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{-webkit-flex-direction:column;flex-direction:column;height:100%;padding:20px;display:-webkit-flex;display:flex}.biscuitman .bm-dialog b{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";pointer-events:none;z-index:1;background:linear-gradient(#fff 20%,rgba(255,255,255,0));width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";pointer-events:none;background:linear-gradient(rgba(255,255,255,0),#fff 80%);width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(0,0,0,.2) #fff;-webkit-flex-shrink:1;flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=more]~span{display:none}.biscuitman a{font-size:inherit;color:#105d89;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 rgba(0,0,0,.2);border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;-webkit-transform:rotate(45deg)scale(.3);transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;-webkit-flex-direction:column;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:-webkit-flex;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid rgba(0,0,0,.4);border-color:transparent rgba(0,0,0,.4) rgba(0,0,0,.4) transparent;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;-webkit-transform:rotate(-45deg)scale(.3);transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:#444;font-size:14px}.biscuitman summary>*{display:-webkit-inline-flex;display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(0,0,0,.08);margin:10px;padding:10px;display:-webkit-flex;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:#444;font-size:12px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;background-color:rgba(0,0,0,.3);border-radius:1.2em;width:2.3em;height:1.2em;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";-webkit-transform-origin:50%;transform-origin:50%;background:#fff;border-radius:100%;width:1.2em;height:1.2em;display:block;position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%)scale(.8);transform:translateY(-50%)scale(.8)}.biscuitman label.checked{background-color:#105d89}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}'; + css.textContent='/*! biscuitman-legacy.js 0.5.5 *//*! biscuitman-legacy.js 0.5.5 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;-moz-box-sizing:border-box;box-sizing:border-box;z-index:3;background:#fff;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px rgba(0,0,0,.16)}.bm-show .biscuitman{display:block}.biscuitman *{-moz-box-sizing:border-box;box-sizing:border-box;color:#444;margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){-webkit-transform:translateY(100%);transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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;-webkit-transform:translateY(50%);transform:translateY(50%)}}.biscuitman article p{color:#444;margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{color:#105d89;cursor:pointer;background:#fff;border:2px solid #105d89;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:#105d89;color:#fff!important}.biscuitman button[data-id=close]{color:rgba(0,0,0,.5);opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-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 (min-width:576px){.biscuitman nav{-webkit-flex-direction:row-reverse;flex-direction:row-reverse;gap:10px;width:100%;display:-webkit-flex;display:flex}.biscuitman nav button{-webkit-flex-grow:1;flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{-webkit-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;flex-grow:1;display:-webkit-flex;display:flex}}.biscuitman dialog{background:#fff;border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px rgba(0,0,0,.3)}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{-webkit-flex-direction:column;flex-direction:column;height:100%;padding:20px;display:-webkit-flex;display:flex}.biscuitman .bm-dialog b{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";pointer-events:none;z-index:1;background:linear-gradient(#fff 20%,rgba(255,255,255,0));width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";pointer-events:none;background:linear-gradient(rgba(255,255,255,0),#fff 80%);width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(0,0,0,.2) #fff;-webkit-flex-shrink:1;flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=more]~span{display:none}.biscuitman a{font-size:inherit;color:#105d89;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 rgba(0,0,0,.2);border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;-webkit-transform:rotate(45deg)scale(.3);transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;-webkit-flex-direction:column;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:-webkit-flex;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid rgba(0,0,0,.4);border-color:transparent rgba(0,0,0,.4) rgba(0,0,0,.4) transparent;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;-webkit-transform:rotate(-45deg)scale(.3);transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:#444;font-size:14px}.biscuitman summary>*{display:-webkit-inline-flex;display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(0,0,0,.08);margin:10px;padding:10px;display:-webkit-flex;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:#444;font-size:12px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;background-color:rgba(0,0,0,.3);border-radius:1.2em;width:2.3em;height:1.2em;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";-webkit-transform-origin:50%;transform-origin:50%;background:#fff;border-radius:100%;width:1.2em;height:1.2em;display:block;position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%)scale(.8);transform:translateY(-50%)scale(.8)}.biscuitman label.checked{background-color:#105d89}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}'; d.head.appendChild(css); })(document); \ No newline at end of file diff --git a/dist/biscuitman-legacy.withcss.min.js b/dist/biscuitman-legacy.withcss.min.js index 4a9fd48..fa7e202 100644 --- a/dist/biscuitman-legacy.withcss.min.js +++ b/dist/biscuitman-legacy.withcss.min.js @@ -1 +1 @@ -/*! biscuitman-legacy.js 0.5.4 */!function(){"use strict";if(Object.entries=Object.entries?Object.entries:function(t){var e=Object.prototype.toString.call(t);if(null==t)throw TypeError("Cannot convert undefined or null to object");if(!~["[object String]","[object Object]","[object Array]","[object Function]"].indexOf(e))return[];if(Object.keys)return Object.keys(t).map(function(e){return[e,t[e]]});var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push([r,t[r]]);return"[object Array]"===e?n:n.sort(function(t,e){return t[1]-e[1]})},Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var n,r;for(n=0,r=this.length;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substring(e,e+t.length)===t}),function(){if("undefined"!=typeof window)try{var t=new window.CustomEvent("test",{cancelable:!0});if(t.preventDefault(),!0!==t.defaultPrevented)throw Error("Could not prevent default")}catch(t){var e=function(t,e){var n,r,o={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i]);return o.bubbles=!!o.bubbles,o.cancelable=!!o.cancelable,(n=document.createEvent("CustomEvent")).initCustomEvent(t,o.bubbles,o.cancelable,o.detail),r=n.preventDefault,n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},n};e.prototype=window.Event.prototype,window.CustomEvent=e}}(),Array.from=Array.from||function(t,e,n){var r=[],o=[],i=0;for(window.Set&&t instanceof Set&&(t.forEach(function(t){o.push(t)}),t=o);i\ndetails, summary {\n display: block;\n}\ndetails:not([open]) > *:not(summary) {\n display: none;\n}\nsummary::before {\n content: "►";\n padding-right: 0.3rem;\n font-size: 0.6rem;\n cursor: default;\n}\n[open] > summary::before {\n content: "▼";\n}\n'),e=(t=document.createElement("details").constructor.prototype).setAttribute,n=t.removeAttribute,r=Object.getOwnPropertyDescriptor(t,"open"),Object.defineProperties(t,{open:{get:function(){return"DETAILS"==this.tagName?this.hasAttribute("open"):r&&r.get?r.get.call(this):void 0},set:function(t){return"DETAILS"==this.tagName?t?this.setAttribute("open",""):this.removeAttribute("open"):r&&r.set?r.set.call(this,t):void 0}},setAttribute:{value:function(t,n){var r=this,o=function(){return e.call(r,t,n)};if("open"==t&&"DETAILS"==this.tagName){var i=this.hasAttribute("open"),a=o();if(!i){var c=this.querySelector("summary");c&&c.setAttribute("aria-expanded",!0),p(this)}return a}return o()}},removeAttribute:{value:function(t){var e=this,r=function(){return n.call(e,t)};if("open"==t&&"DETAILS"==this.tagName){var o=this.hasAttribute("open"),i=r();if(o){var a=this.querySelector("summary");a&&a.setAttribute("aria-expanded",!1),p(this)}return i}return r()}}}),d(function(t){t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")}),u(document),window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){l.call(t.addedNodes,u)})}).observe(document.documentElement,{subtree:!0,childList:!0}):document.addEventListener("DOMNodeInserted",function(t){u(t.target)})),a.open&&!a.toggle&&(window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){var e=t.target,n=t.attributeName;"DETAILS"==e.tagName&&"open"==n&&p(e)})}).observe(document.documentElement,{attributes:!0,subtree:!0}):d(function(t){var e=t.getAttribute("open");setTimeout(function(){e!=t.getAttribute("open")&&p(t)},1)}))}(),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(this==null)throw TypeError('"this" is null or not defined');var n,r=Object(this),o=r.length>>>0;if(0===o)return!1;for(var i=0|e,a=Math.max(i>=0?i:o-Math.abs(i),0);at.length)&&(e=t.length);for(var n=0,r=Array(e);n\n".concat(u.title,"\n

").concat(u.message,"

\n\n\n\n
\n").concat(u.settingsTitle,"\n\n
\n

").concat(u.message,"

\n

").concat(u.info.split("\n").map(function(t,e,n){return"".concat(t,"\n").concat(n.length>1&&u.enableMore&&0==e?"".concat(u.more,""):"")}).join(""),"\n

\n").concat(u.sections.map(function(t){var e=v()[t],n="essential"===t,r=n?"disabled":"",o=n?"checked":"";void 0!==e&&(o=e?"checked":"");var c=u["".concat(t,"Cookies")];return"\n
\n
\n\n".concat(u["".concat(t,"Title")],"\n\n

').concat(u["".concat(t,"Message")],"

\n
\n").concat(c?a.entries(c).map(function(t){var e=i(t,2),n=e[0],r=e[1];return"
".concat(n,"
").concat(r,"
")}).join(""):"
".concat(u.noCookies,"
"),"\n
\n
")}).join(""),"\n
\n\n
\n
").replaceAll("{link}",'').concat(u.linkText,"")),f.onclick=function(t){var e=t.target.dataset.id;if(e)switch(y("button",{id:e}),e){case"more":t.target.remove();break;case"accept":j(!0);break;case"close":s.close();break;case"settings":m();break;case"save":j();break;case"reject":j(!1)}},f.onchange=function(t){t.target.dataset.s&&t.target.parentElement.classList.toggle("checked",t.target.checked)},s=f.querySelector("dialog"),u.dialogPolyfill&&!s.close&&function(e){function n(){t.documentElement.classList.add("bm-dialog-polyfill"),r.dialogPolyfill.registerDialog(e)}if(r.dialogPolyfill)n();else{var o=t.createElement("script");o.onload=n,o.src=u.dialogPolyfill,t.head.appendChild(o)}}(s),s.onclose=function(){return y("close")},u.force&&(s.oncancel=function(t){return t.preventDefault()},s.onkeydown=function(t){return"Escape"===t.key?t.preventDefault():null}),t.body.appendChild(f),r.addEventListener("resize",d),S(),r[u.global].consentTime?(p(!1),O()):(p(!0),u.force&&m()),r.bmInvalidate=function(){y("invalidate",{data:v()}),h({}),j(!1),g({}),localStorage.removeItem(u.key),p(!0),u.force&&s.showModal()},r.bmUpdate=function(){y("update",{data:v()}),p(!0),m()}}(document,window,Object,document.documentElement)}();;(function(d){var c=d.createElement('style');c.textContent='/*! biscuitman-legacy.js 0.5.4 *//*! biscuitman-legacy.js 0.5.4 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;-moz-box-sizing:border-box;box-sizing:border-box;z-index:3;background:#fff;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px rgba(0,0,0,.16)}.bm-show .biscuitman{display:block}.biscuitman *{-moz-box-sizing:border-box;box-sizing:border-box;color:#444;margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){-webkit-transform:translateY(100%);transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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;-webkit-transform:translateY(50%);transform:translateY(50%)}}.biscuitman article p{color:#444;margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{color:#105d89;cursor:pointer;background:#fff;border:2px solid #105d89;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:#105d89;color:#fff!important}.biscuitman button[data-id=close]{color:rgba(0,0,0,.5);opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-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 (min-width:576px){.biscuitman nav{-webkit-flex-direction:row-reverse;flex-direction:row-reverse;gap:10px;width:100%;display:-webkit-flex;display:flex}.biscuitman nav button{-webkit-flex-grow:1;flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{-webkit-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;flex-grow:1;display:-webkit-flex;display:flex}}.biscuitman dialog{background:#fff;border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px rgba(0,0,0,.3)}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{-webkit-flex-direction:column;flex-direction:column;height:100%;padding:20px;display:-webkit-flex;display:flex}.biscuitman .bm-dialog b{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";pointer-events:none;z-index:1;background:linear-gradient(#fff 20%,rgba(255,255,255,0));width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";pointer-events:none;background:linear-gradient(rgba(255,255,255,0),#fff 80%);width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(0,0,0,.2) #fff;-webkit-flex-shrink:1;flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=more]~span{display:none}.biscuitman a{font-size:inherit;color:#105d89;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 rgba(0,0,0,.2);border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;-webkit-transform:rotate(45deg)scale(.3);transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;-webkit-flex-direction:column;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:-webkit-flex;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid rgba(0,0,0,.4);border-color:transparent rgba(0,0,0,.4) rgba(0,0,0,.4) transparent;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;-webkit-transform:rotate(-45deg)scale(.3);transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:#444;font-size:14px}.biscuitman summary>*{display:-webkit-inline-flex;display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(0,0,0,.08);margin:10px;padding:10px;display:-webkit-flex;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:#444;font-size:12px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;background-color:rgba(0,0,0,.3);border-radius:1.2em;width:2.3em;height:1.2em;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";-webkit-transform-origin:50%;transform-origin:50%;background:#fff;border-radius:100%;width:1.2em;height:1.2em;display:block;position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%)scale(.8);transform:translateY(-50%)scale(.8)}.biscuitman label.checked{background-color:#105d89}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}';d.head.appendChild(c)})(document); \ No newline at end of file +/*! biscuitman-legacy.js 0.5.5 */!function(){"use strict";if(Object.entries=Object.entries?Object.entries:function(t){var e=Object.prototype.toString.call(t);if(null==t)throw TypeError("Cannot convert undefined or null to object");if(!~["[object String]","[object Object]","[object Array]","[object Function]"].indexOf(e))return[];if(Object.keys)return Object.keys(t).map(function(e){return[e,t[e]]});var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push([r,t[r]]);return"[object Array]"===e?n:n.sort(function(t,e){return t[1]-e[1]})},Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var n,r;for(n=0,r=this.length;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substring(e,e+t.length)===t}),function(){if("undefined"!=typeof window)try{var t=new window.CustomEvent("test",{cancelable:!0});if(t.preventDefault(),!0!==t.defaultPrevented)throw Error("Could not prevent default")}catch(t){var e=function(t,e){var n,r,o={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(o[i]=e[i]);return o.bubbles=!!o.bubbles,o.cancelable=!!o.cancelable,(n=document.createEvent("CustomEvent")).initCustomEvent(t,o.bubbles,o.cancelable,o.detail),r=n.preventDefault,n.preventDefault=function(){r.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},n};e.prototype=window.Event.prototype,window.CustomEvent=e}}(),Array.from=Array.from||function(t,e,n){var r=[],o=[],i=0;for(window.Set&&t instanceof Set&&(t.forEach(function(t){o.push(t)}),t=o);i\ndetails, summary {\n display: block;\n}\ndetails:not([open]) > *:not(summary) {\n display: none;\n}\nsummary::before {\n content: "►";\n padding-right: 0.3rem;\n font-size: 0.6rem;\n cursor: default;\n}\n[open] > summary::before {\n content: "▼";\n}\n'),e=(t=document.createElement("details").constructor.prototype).setAttribute,n=t.removeAttribute,r=Object.getOwnPropertyDescriptor(t,"open"),Object.defineProperties(t,{open:{get:function(){return"DETAILS"==this.tagName?this.hasAttribute("open"):r&&r.get?r.get.call(this):void 0},set:function(t){return"DETAILS"==this.tagName?t?this.setAttribute("open",""):this.removeAttribute("open"):r&&r.set?r.set.call(this,t):void 0}},setAttribute:{value:function(t,n){var r=this,o=function(){return e.call(r,t,n)};if("open"==t&&"DETAILS"==this.tagName){var i=this.hasAttribute("open"),a=o();if(!i){var c=this.querySelector("summary");c&&c.setAttribute("aria-expanded",!0),p(this)}return a}return o()}},removeAttribute:{value:function(t){var e=this,r=function(){return n.call(e,t)};if("open"==t&&"DETAILS"==this.tagName){var o=this.hasAttribute("open"),i=r();if(o){var a=this.querySelector("summary");a&&a.setAttribute("aria-expanded",!1),p(this)}return i}return r()}}}),d(function(t){t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")}),u(document),window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){l.call(t.addedNodes,u)})}).observe(document.documentElement,{subtree:!0,childList:!0}):document.addEventListener("DOMNodeInserted",function(t){u(t.target)})),a.open&&!a.toggle&&(window.MutationObserver?new MutationObserver(function(t){l.call(t,function(t){var e=t.target,n=t.attributeName;"DETAILS"==e.tagName&&"open"==n&&p(e)})}).observe(document.documentElement,{attributes:!0,subtree:!0}):d(function(t){var e=t.getAttribute("open");setTimeout(function(){e!=t.getAttribute("open")&&p(t)},1)}))}(),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(this==null)throw TypeError('"this" is null or not defined');var n,r=Object(this),o=r.length>>>0;if(0===o)return!1;for(var i=0|e,a=Math.max(i>=0?i:o-Math.abs(i),0);at.length)&&(e=t.length);for(var n=0,r=Array(e);n\n".concat(u.title,"\n

").concat(u.message,"

\n\n\n\n
\n").concat(u.settingsTitle,"\n\n
\n

").concat(u.message,"

\n

").concat(u.info.split("\n").map(function(t,e,n){return"".concat(t,"\n").concat(n.length>1&&u.enableMore&&0==e?"".concat(u.more,""):"")}).join(""),"\n

\n").concat(u.sections.map(function(t){var e=v()[t],n="essential"===t,r=n?"disabled":"",o=n?"checked":"";void 0!==e&&(o=e?"checked":"");var c=u["".concat(t,"Cookies")];return"\n
\n
\n\n".concat(u["".concat(t,"Title")],"\n\n

').concat(u["".concat(t,"Message")],"

\n
\n").concat(c?a.entries(c).map(function(t){var e=i(t,2),n=e[0],r=e[1];return"
".concat(n,"
").concat(r,"
")}).join(""):"
".concat(u.noCookies,"
"),"\n
\n
")}).join(""),"\n
\n\n
\n
").replaceAll("{link}",'').concat(u.linkText,"")),f.onclick=function(t){var e=t.target.dataset.id;if(e)switch(y("button",{id:e}),e){case"more":t.target.remove();break;case"accept":j(!0);break;case"close":s.close();break;case"settings":m();break;case"save":j();break;case"reject":j(!1)}},f.onchange=function(t){t.target.dataset.s&&t.target.parentElement.classList.toggle("checked",t.target.checked)},s=f.querySelector("dialog"),u.dialogPolyfill&&!s.close&&function(e){function n(){t.documentElement.classList.add("bm-dialog-polyfill"),r.dialogPolyfill.registerDialog(e)}if(r.dialogPolyfill)n();else{var o=t.createElement("script");o.onload=n,o.src=u.dialogPolyfill,t.head.appendChild(o)}}(s),s.onclose=function(){return y("close")},u.force&&(s.oncancel=function(t){return t.preventDefault()},s.onkeydown=function(t){return"Escape"===t.key?t.preventDefault():null}),t.body.appendChild(f),r.addEventListener("resize",d);var A=Intl.DateTimeFormat().resolvedOptions().timeZone,w=/^(GMT|UTC)$/.test(A)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(A);u.acceptNonEU&&!w&&(j(!0),p(!1)),S(),r[u.global].consentTime?(p(!1),O()):(p(!0),u.force&&m()),r.bmInvalidate=function(){y("invalidate",{data:v()}),h({}),j(!1),g({}),localStorage.removeItem(u.key),p(!0),u.force&&s.showModal()},r.bmUpdate=function(){y("update",{data:v()}),p(!0),m()}}(document,window,Object,document.documentElement)}();;(function(d){var c=d.createElement('style');c.textContent='/*! biscuitman-legacy.js 0.5.5 *//*! biscuitman-legacy.js 0.5.5 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;-moz-box-sizing:border-box;box-sizing:border-box;z-index:3;background:#fff;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px rgba(0,0,0,.16)}.bm-show .biscuitman{display:block}.biscuitman *{-moz-box-sizing:border-box;box-sizing:border-box;color:#444;margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){-webkit-transform:translateY(100%);transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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;-webkit-transform:translateY(50%);transform:translateY(50%)}}.biscuitman article p{color:#444;margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{color:#105d89;cursor:pointer;background:#fff;border:2px solid #105d89;border-radius:3px;margin-top:10px;padding:.8em;font-size:13px;line-height:1em}.biscuitman button[data-id=accept]{background:#105d89;color:#fff!important}.biscuitman button[data-id=close]{color:rgba(0,0,0,.5);opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-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 (min-width:576px){.biscuitman nav{-webkit-flex-direction:row-reverse;flex-direction:row-reverse;gap:10px;width:100%;display:-webkit-flex;display:flex}.biscuitman nav button{-webkit-flex-grow:1;flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{-webkit-flex-direction:column;flex-direction:column;-webkit-flex-grow:1;flex-grow:1;display:-webkit-flex;display:flex}}.biscuitman dialog{background:#fff;border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px rgba(0,0,0,.3)}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.biscuitman dialog nav{justify-self:flex-end;position:relative}.biscuitman .bm-dialog{-webkit-flex-direction:column;flex-direction:column;height:100%;padding:20px;display:-webkit-flex;display:flex}.biscuitman .bm-dialog b{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";pointer-events:none;z-index:1;background:linear-gradient(#fff 20%,rgba(255,255,255,0));width:100%;height:25px;margin-bottom:-24px;position:absolute;bottom:0;left:0}.biscuitman .bm-dialog nav:after{content:"";pointer-events:none;background:linear-gradient(rgba(255,255,255,0),#fff 80%);width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(0,0,0,.2) #fff;-webkit-flex-shrink:1;flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=more]~span{display:none}.biscuitman a{font-size:inherit;color:#105d89;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 rgba(0,0,0,.2);border-radius:5px;padding:10px;list-style:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.biscuitman details[open] summary b:after{margin:-3px 0 0 -2px;-webkit-transform:rotate(45deg)scale(.3);transform:rotate(45deg)scale(.3)}.biscuitman summary{cursor:pointer;-webkit-flex-direction:column;flex-direction:column;width:100%;padding:5px 80px 10px 10px;list-style:none;display:-webkit-flex;display:flex;position:relative}.biscuitman summary b{margin-bottom:3px}.biscuitman summary b:after{content:"";border:5px solid rgba(0,0,0,.4);border-color:transparent rgba(0,0,0,.4) rgba(0,0,0,.4) transparent;border-radius:2px;width:1em;height:1em;margin:-2px 0 0 -4px;display:block;-webkit-transform:rotate(-45deg)scale(.3);transform:rotate(-45deg)scale(.3)}.biscuitman summary p{color:#444;font-size:14px}.biscuitman summary>*{display:-webkit-inline-flex;display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(0,0,0,.08);margin:10px;padding:10px;display:-webkit-flex;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:#444;font-size:12px}.biscuitman dl dt{min-width:120px;padding-right:30px;font-weight:700}.biscuitman label{--height:1.2em;--width:2.3em;--gap:2px;background-color:rgba(0,0,0,.3);border-radius:1.2em;width:2.3em;height:1.2em;margin-top:-2px;display:block;position:absolute;top:50%;right:20px;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";-webkit-transform-origin:50%;transform-origin:50%;background:#fff;border-radius:100%;width:1.2em;height:1.2em;display:block;position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%)scale(.8);transform:translateY(-50%)scale(.8)}.biscuitman label.checked{background-color:#105d89}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}';d.head.appendChild(c)})(document); \ No newline at end of file diff --git a/dist/biscuitman.css b/dist/biscuitman.css index 9334785..1ebce64 100644 --- a/dist/biscuitman.css +++ b/dist/biscuitman.css @@ -1,4 +1,4 @@ -/*! biscuitman.js 0.5.4 */ +/*! biscuitman.js 0.5.5 */ .biscuitman { --ui: 0, 0, 0; --tx: #444; diff --git a/dist/biscuitman.js b/dist/biscuitman.js index 8f23de6..b217fe6 100644 --- a/dist/biscuitman.js +++ b/dist/biscuitman.js @@ -1,4 +1,4 @@ -/*! biscuitman.js 0.5.4 */ +/*! biscuitman.js 0.5.5 */ ((d, w, O, h)=>{ const defaults = { key: 'myconsent', @@ -66,10 +66,7 @@

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

- ${cookies ? O.entries(cookies).map((param)=>{ - let [k, v] = param; - return `
${k}
${v}
`; - }).join('') : `
${o.noCookies}
`} + ${cookies ? O.entries(cookies).map(([k, v])=>`
${k}
${v}
`).join('') : `
${o.noCookies}
`} `; }).join('')} @@ -288,6 +285,8 @@ } // Start: setConsents(loadConsents() || {}); + // Render UI + render(); // Optional Non-EU auto-consent const tz = Intl.DateTimeFormat().resolvedOptions().timeZone; const isEuropeTimezone = /^(GMT|UTC)$/.test(tz) || /(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(tz); @@ -295,8 +294,6 @@ saveConsents(true); displayUI(false); } - // Render UI - render(); // Wipe matching cookies/localStorages without consent clearStorages(); // Consent logic diff --git a/dist/biscuitman.min.css b/dist/biscuitman.min.css index c6f65fe..3af7fd5 100644 --- a/dist/biscuitman.min.css +++ b/dist/biscuitman.min.css @@ -1 +1 @@ -/*! biscuitman.js 0.5.4 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;background:var(--bg);box-sizing:border-box;z-index:3;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px #00000029}.bm-show .biscuitman{display:block}.biscuitman *{box-sizing:border-box;color:var(--tx);margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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(--tx);margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--bg);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(--bg)!important}.biscuitman button[data-id=close]{color:rgba(var(--ui),.5);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 (min-width:576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{background:var(--bg);border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.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{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--bg)20%,#fff0);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(--bg)20%,#fff0);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(var(--ui),.2)var(--bg);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=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 rgba(var(--ui),.2);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 rgba(var(--ui),.4);border-top-color:#0000;border-left-color:#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(--tx);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(var(--ui),.08);margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--tx);font-size:12px}.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);background-color:rgba(var(--ui),.3);border-radius:var(--height);margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--bg);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.checked{background-color:var(--c)}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;transform:translateY(-50%)} \ No newline at end of file +/*! biscuitman.js 0.5.5 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;background:var(--bg);box-sizing:border-box;z-index:3;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px #00000029}.bm-show .biscuitman{display:block}.biscuitman *{box-sizing:border-box;color:var(--tx);margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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(--tx);margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--bg);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(--bg)!important}.biscuitman button[data-id=close]{color:rgba(var(--ui),.5);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 (min-width:576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{background:var(--bg);border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.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{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--bg)20%,#fff0);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(--bg)20%,#fff0);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(var(--ui),.2)var(--bg);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=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 rgba(var(--ui),.2);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 rgba(var(--ui),.4);border-top-color:#0000;border-left-color:#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(--tx);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(var(--ui),.08);margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--tx);font-size:12px}.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);background-color:rgba(var(--ui),.3);border-radius:var(--height);margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--bg);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.checked{background-color:var(--c)}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;transform:translateY(-50%)} \ No newline at end of file diff --git a/dist/biscuitman.min.js b/dist/biscuitman.min.js index 31e0f7c..e3292b0 100644 --- a/dist/biscuitman.min.js +++ b/dist/biscuitman.min.js @@ -1 +1 @@ -/*! biscuitman.js 0.5.4 */((e,t,o,a)=>{let i;let n={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js",...t.biscuitman},l=e.createElement("div"),s=()=>{a.style.setProperty("--bm-height",`${l.offsetHeight}px`)},c=e=>{a.classList.toggle("bm-show",e),s()},r=()=>{let{consentTime:e,...t}=p();for(let[i,l]of(e||(t=o.fromEntries(n.sections.slice(1).map(e=>[e,!1]))),o.entries(t)))a.classList.toggle(`bm-${i}`,l),a.classList.toggle(`bm-no-${i}`,!l)};function d(){m("open"),i.showModal()}function m(t,o){let a=`bm:${t}`,i={...void 0!==o&&o,time:+new Date};e.dispatchEvent(new CustomEvent(a,{detail:i})),console.debug(a,i)}let p=()=>t[n.global]||{};function u(e){t[n.global]=e,r()}function b(e,t){for(let o in e)e[o]&&!1===t[o]&&m("revoke",{section:o})}function g(){try{return JSON.parse(localStorage.getItem(n.key))}catch(e){return console.error(e),localStorage.removeItem(n.key),{}}}function f(){let t=o.fromEntries(o.entries(localStorage)),a=o.fromEntries(e.cookie.split("; ").map(e=>e.split("="))),{consentTime:i,...l}=g()||n.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[i,s]of o.entries(l)){if(s)continue;let l=o.keys(n[`${i}Cookies`]||{});for(let i of(l.filter(e=>e.endsWith("*")).map(e=>{o.keys({...a,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(a[i]){let t=`${i}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;e.cookie=t,e.cookie=`${t}domain=${location.hostname};`,e.cookie=`${t}domain=.${location.hostname};`,m("delete",{cookie:i})}t[i]&&(localStorage.removeItem(i),m("delete",{localStorage:i}))}}}function $(e){let t=void 0===e,o={consentTime:+new Date};n.sections.forEach(a=>{if("essential"===a)return;let i=l.querySelector(`[data-s=${a}]`),n=t?i.checked:e;o[a]=n,t||(i.checked=e)}),b(p(),o),u(o),localStorage.setItem(n.key,JSON.stringify(o)),m("save",{data:o}),f(),k(),i.open&&i.close(),c(!1)}function k(){e.querySelectorAll("script[data-consent]").forEach(t=>{if(!p()[t.dataset.consent])return;let o=e.createElement("script");for(let{name:e,value:a}of t.attributes)e.startsWith("data-")||"type"===e||o.setAttribute(e,a);o.setAttribute("type",t.dataset.type||"text/javascript"),t.src||(o.textContent=t.textContent),t.parentNode.replaceChild(o,t),m("inject",{el:t,...t.id&&{id:t.id}}),t.src&&""!==t.textContent.trim()&&o.addEventListener("load",()=>{let a=e.createElement("script");a.textContent=t.textContent,t.id&&(a.id=t.id+"-after"),o.insertAdjacentElement("afterend",a),m("inject",{el:a,parent:t,...a.id&&{id:a.id}})})})}u(g()||{});let h=Intl.DateTimeFormat().resolvedOptions().timeZone,v=/^(GMT|UTC)$/.test(h)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(h);n.acceptNonEU&&!v&&($(!0),c(!1)),l.className="biscuitman",l.innerHTML=`
${n.title}

${n.message}

${n.settingsTitle}

${n.message}

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

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

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

${s?o.entries(s).map(e=>{let[t,o]=e;return`
${t}
${o}
`}).join(""):`
${n.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${n.linkText}`),l.onclick=e=>{let t=e.target.dataset.id;if(t)switch(m("button",{id:t}),t){case"more":e.target.remove();break;case"accept":$(!0);break;case"close":i.close();break;case"settings":d();break;case"save":$();break;case"reject":$(!1)}},l.onchange=e=>{e.target.dataset.s&&e.target.parentElement.classList.toggle("checked",e.target.checked)},i=l.querySelector("dialog"),n.dialogPolyfill&&!i.close&&function(o){function a(){e.documentElement.classList.add("bm-dialog-polyfill"),t.dialogPolyfill.registerDialog(o)}if(t.dialogPolyfill)a();else{let t=e.createElement("script");t.onload=a,t.src=n.dialogPolyfill,e.head.appendChild(t)}}(i),i.onclose=()=>m("close"),n.force&&(i.oncancel=e=>e.preventDefault(),i.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),e.body.appendChild(l),t.addEventListener("resize",s),f(),t[n.global].consentTime?(c(!1),k()):(c(!0),n.force&&d()),t.bmInvalidate=()=>{m("invalidate",{data:p()}),b({}),$(!1),u({}),localStorage.removeItem(n.key),c(!0),n.force&&i.showModal()},t.bmUpdate=()=>{m("update",{data:p()}),c(!0),d()}})(document,window,Object,document.documentElement); \ No newline at end of file +/*! biscuitman.js 0.5.5 */((e,t,o,a)=>{let i;let n={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js",...t.biscuitman},l=e.createElement("div"),s=()=>{a.style.setProperty("--bm-height",`${l.offsetHeight}px`)},c=e=>{a.classList.toggle("bm-show",e),s()},r=()=>{let{consentTime:e,...t}=p();for(let[i,l]of(e||(t=o.fromEntries(n.sections.slice(1).map(e=>[e,!1]))),o.entries(t)))a.classList.toggle(`bm-${i}`,l),a.classList.toggle(`bm-no-${i}`,!l)};function d(){m("open"),i.showModal()}function m(t,o){let a=`bm:${t}`,i={...void 0!==o&&o,time:+new Date};e.dispatchEvent(new CustomEvent(a,{detail:i})),console.debug(a,i)}let p=()=>t[n.global]||{};function u(e){t[n.global]=e,r()}function b(e,t){for(let o in e)e[o]&&!1===t[o]&&m("revoke",{section:o})}function g(){try{return JSON.parse(localStorage.getItem(n.key))}catch(e){return console.error(e),localStorage.removeItem(n.key),{}}}function f(){let t=o.fromEntries(o.entries(localStorage)),a=o.fromEntries(e.cookie.split("; ").map(e=>e.split("="))),{consentTime:i,...l}=g()||n.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[i,s]of o.entries(l)){if(s)continue;let l=o.keys(n[`${i}Cookies`]||{});for(let i of(l.filter(e=>e.endsWith("*")).map(e=>{o.keys({...a,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(a[i]){let t=`${i}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;e.cookie=t,e.cookie=`${t}domain=${location.hostname};`,e.cookie=`${t}domain=.${location.hostname};`,m("delete",{cookie:i})}t[i]&&(localStorage.removeItem(i),m("delete",{localStorage:i}))}}}function $(e){let t=void 0===e,o={consentTime:+new Date};n.sections.forEach(a=>{if("essential"===a)return;let i=l.querySelector(`[data-s=${a}]`),n=t?i.checked:e;o[a]=n,t||(i.checked=e)}),b(p(),o),u(o),localStorage.setItem(n.key,JSON.stringify(o)),m("save",{data:o}),f(),k(),i.open&&i.close(),c(!1)}function k(){e.querySelectorAll("script[data-consent]").forEach(t=>{if(!p()[t.dataset.consent])return;let o=e.createElement("script");for(let{name:e,value:a}of t.attributes)e.startsWith("data-")||"type"===e||o.setAttribute(e,a);o.setAttribute("type",t.dataset.type||"text/javascript"),t.src||(o.textContent=t.textContent),t.parentNode.replaceChild(o,t),m("inject",{el:t,...t.id&&{id:t.id}}),t.src&&""!==t.textContent.trim()&&o.addEventListener("load",()=>{let a=e.createElement("script");a.textContent=t.textContent,t.id&&(a.id=t.id+"-after"),o.insertAdjacentElement("afterend",a),m("inject",{el:a,parent:t,...a.id&&{id:a.id}})})})}u(g()||{}),l.className="biscuitman",l.innerHTML=`
${n.title}

${n.message}

${n.settingsTitle}

${n.message}

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

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

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

${s?o.entries(s).map(([e,t])=>`
${e}
${t}
`).join(""):`
${n.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${n.linkText}`),l.onclick=e=>{let t=e.target.dataset.id;if(t)switch(m("button",{id:t}),t){case"more":e.target.remove();break;case"accept":$(!0);break;case"close":i.close();break;case"settings":d();break;case"save":$();break;case"reject":$(!1)}},l.onchange=e=>{e.target.dataset.s&&e.target.parentElement.classList.toggle("checked",e.target.checked)},i=l.querySelector("dialog"),n.dialogPolyfill&&!i.close&&function(o){function a(){e.documentElement.classList.add("bm-dialog-polyfill"),t.dialogPolyfill.registerDialog(o)}if(t.dialogPolyfill)a();else{let t=e.createElement("script");t.onload=a,t.src=n.dialogPolyfill,e.head.appendChild(t)}}(i),i.onclose=()=>m("close"),n.force&&(i.oncancel=e=>e.preventDefault(),i.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),e.body.appendChild(l),t.addEventListener("resize",s);let h=Intl.DateTimeFormat().resolvedOptions().timeZone,v=/^(GMT|UTC)$/.test(h)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(h);n.acceptNonEU&&!v&&($(!0),c(!1)),f(),t[n.global].consentTime?(c(!1),k()):(c(!0),n.force&&d()),t.bmInvalidate=()=>{m("invalidate",{data:p()}),b({}),$(!1),u({}),localStorage.removeItem(n.key),c(!0),n.force&&i.showModal()},t.bmUpdate=()=>{m("update",{data:p()}),c(!0),d()}})(document,window,Object,document.documentElement); \ No newline at end of file diff --git a/dist/biscuitman.withcss.js b/dist/biscuitman.withcss.js index fd5f75d..b74df28 100644 --- a/dist/biscuitman.withcss.js +++ b/dist/biscuitman.withcss.js @@ -1,4 +1,4 @@ -/*! biscuitman.js 0.5.4 */ +/*! biscuitman.js 0.5.5 */ ((d, w, O, h)=>{ const defaults = { key: 'myconsent', @@ -66,10 +66,7 @@

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

- ${cookies ? O.entries(cookies).map((param)=>{ - let [k, v] = param; - return `
${k}
${v}
`; - }).join('') : `
${o.noCookies}
`} + ${cookies ? O.entries(cookies).map(([k, v])=>`
${k}
${v}
`).join('') : `
${o.noCookies}
`} `; }).join('')} @@ -288,6 +285,8 @@ } // Start: setConsents(loadConsents() || {}); + // Render UI + render(); // Optional Non-EU auto-consent const tz = Intl.DateTimeFormat().resolvedOptions().timeZone; const isEuropeTimezone = /^(GMT|UTC)$/.test(tz) || /(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(tz); @@ -295,8 +294,6 @@ saveConsents(true); displayUI(false); } - // Render UI - render(); // Wipe matching cookies/localStorages without consent clearStorages(); // Consent logic @@ -332,7 +329,7 @@ ; ((d)=>{ let css=d.createElement('style'); - css.textContent=`/*! biscuitman.js 0.5.4 */ + css.textContent=`/*! biscuitman.js 0.5.5 */ .biscuitman { --ui: 0, 0, 0; --tx: #444; diff --git a/dist/biscuitman.withcss.min.js b/dist/biscuitman.withcss.min.js index 4ff7bae..7243bad 100644 --- a/dist/biscuitman.withcss.min.js +++ b/dist/biscuitman.withcss.min.js @@ -1 +1 @@ -/*! biscuitman.js 0.5.4 */((e,t,o,a)=>{let i;let n={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js",...t.biscuitman},l=e.createElement("div"),s=()=>{a.style.setProperty("--bm-height",`${l.offsetHeight}px`)},c=e=>{a.classList.toggle("bm-show",e),s()},r=()=>{let{consentTime:e,...t}=p();for(let[i,l]of(e||(t=o.fromEntries(n.sections.slice(1).map(e=>[e,!1]))),o.entries(t)))a.classList.toggle(`bm-${i}`,l),a.classList.toggle(`bm-no-${i}`,!l)};function d(){m("open"),i.showModal()}function m(t,o){let a=`bm:${t}`,i={...void 0!==o&&o,time:+new Date};e.dispatchEvent(new CustomEvent(a,{detail:i})),console.debug(a,i)}let p=()=>t[n.global]||{};function u(e){t[n.global]=e,r()}function b(e,t){for(let o in e)e[o]&&!1===t[o]&&m("revoke",{section:o})}function g(){try{return JSON.parse(localStorage.getItem(n.key))}catch(e){return console.error(e),localStorage.removeItem(n.key),{}}}function f(){let t=o.fromEntries(o.entries(localStorage)),a=o.fromEntries(e.cookie.split("; ").map(e=>e.split("="))),{consentTime:i,...l}=g()||n.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[i,s]of o.entries(l)){if(s)continue;let l=o.keys(n[`${i}Cookies`]||{});for(let i of(l.filter(e=>e.endsWith("*")).map(e=>{o.keys({...a,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(a[i]){let t=`${i}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;e.cookie=t,e.cookie=`${t}domain=${location.hostname};`,e.cookie=`${t}domain=.${location.hostname};`,m("delete",{cookie:i})}t[i]&&(localStorage.removeItem(i),m("delete",{localStorage:i}))}}}function $(e){let t=void 0===e,o={consentTime:+new Date};n.sections.forEach(a=>{if("essential"===a)return;let i=l.querySelector(`[data-s=${a}]`),n=t?i.checked:e;o[a]=n,t||(i.checked=e)}),b(p(),o),u(o),localStorage.setItem(n.key,JSON.stringify(o)),m("save",{data:o}),f(),k(),i.open&&i.close(),c(!1)}function k(){e.querySelectorAll("script[data-consent]").forEach(t=>{if(!p()[t.dataset.consent])return;let o=e.createElement("script");for(let{name:e,value:a}of t.attributes)e.startsWith("data-")||"type"===e||o.setAttribute(e,a);o.setAttribute("type",t.dataset.type||"text/javascript"),t.src||(o.textContent=t.textContent),t.parentNode.replaceChild(o,t),m("inject",{el:t,...t.id&&{id:t.id}}),t.src&&""!==t.textContent.trim()&&o.addEventListener("load",()=>{let a=e.createElement("script");a.textContent=t.textContent,t.id&&(a.id=t.id+"-after"),o.insertAdjacentElement("afterend",a),m("inject",{el:a,parent:t,...a.id&&{id:a.id}})})})}u(g()||{});let h=Intl.DateTimeFormat().resolvedOptions().timeZone,v=/^(GMT|UTC)$/.test(h)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(h);n.acceptNonEU&&!v&&($(!0),c(!1)),l.className="biscuitman",l.innerHTML=`
${n.title}

${n.message}

${n.settingsTitle}

${n.message}

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

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

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

${s?o.entries(s).map(e=>{let[t,o]=e;return`
${t}
${o}
`}).join(""):`
${n.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${n.linkText}`),l.onclick=e=>{let t=e.target.dataset.id;if(t)switch(m("button",{id:t}),t){case"more":e.target.remove();break;case"accept":$(!0);break;case"close":i.close();break;case"settings":d();break;case"save":$();break;case"reject":$(!1)}},l.onchange=e=>{e.target.dataset.s&&e.target.parentElement.classList.toggle("checked",e.target.checked)},i=l.querySelector("dialog"),n.dialogPolyfill&&!i.close&&function(o){function a(){e.documentElement.classList.add("bm-dialog-polyfill"),t.dialogPolyfill.registerDialog(o)}if(t.dialogPolyfill)a();else{let t=e.createElement("script");t.onload=a,t.src=n.dialogPolyfill,e.head.appendChild(t)}}(i),i.onclose=()=>m("close"),n.force&&(i.oncancel=e=>e.preventDefault(),i.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),e.body.appendChild(l),t.addEventListener("resize",s),f(),t[n.global].consentTime?(c(!1),k()):(c(!0),n.force&&d()),t.bmInvalidate=()=>{m("invalidate",{data:p()}),b({}),$(!1),u({}),localStorage.removeItem(n.key),c(!0),n.force&&i.showModal()},t.bmUpdate=()=>{m("update",{data:p()}),c(!0),d()}})(document,window,Object,document.documentElement);;((d)=>{let c=d.createElement('style');c.textContent=`/*! biscuitman.js 0.5.4 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;background:var(--bg);box-sizing:border-box;z-index:3;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px #00000029}.bm-show .biscuitman{display:block}.biscuitman *{box-sizing:border-box;color:var(--tx);margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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(--tx);margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--bg);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(--bg)!important}.biscuitman button[data-id=close]{color:rgba(var(--ui),.5);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 (min-width:576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{background:var(--bg);border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.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{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--bg)20%,#fff0);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(--bg)20%,#fff0);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(var(--ui),.2)var(--bg);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=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 rgba(var(--ui),.2);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 rgba(var(--ui),.4);border-top-color:#0000;border-left-color:#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(--tx);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(var(--ui),.08);margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--tx);font-size:12px}.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);background-color:rgba(var(--ui),.3);border-radius:var(--height);margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--bg);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.checked{background-color:var(--c)}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;transform:translateY(-50%)}`;d.head.appendChild(c)})(document); \ No newline at end of file +/*! biscuitman.js 0.5.5 */((e,t,o,a)=>{let i;let n={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js",...t.biscuitman},l=e.createElement("div"),s=()=>{a.style.setProperty("--bm-height",`${l.offsetHeight}px`)},c=e=>{a.classList.toggle("bm-show",e),s()},r=()=>{let{consentTime:e,...t}=p();for(let[i,l]of(e||(t=o.fromEntries(n.sections.slice(1).map(e=>[e,!1]))),o.entries(t)))a.classList.toggle(`bm-${i}`,l),a.classList.toggle(`bm-no-${i}`,!l)};function d(){m("open"),i.showModal()}function m(t,o){let a=`bm:${t}`,i={...void 0!==o&&o,time:+new Date};e.dispatchEvent(new CustomEvent(a,{detail:i})),console.debug(a,i)}let p=()=>t[n.global]||{};function u(e){t[n.global]=e,r()}function b(e,t){for(let o in e)e[o]&&!1===t[o]&&m("revoke",{section:o})}function g(){try{return JSON.parse(localStorage.getItem(n.key))}catch(e){return console.error(e),localStorage.removeItem(n.key),{}}}function f(){let t=o.fromEntries(o.entries(localStorage)),a=o.fromEntries(e.cookie.split("; ").map(e=>e.split("="))),{consentTime:i,...l}=g()||n.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[i,s]of o.entries(l)){if(s)continue;let l=o.keys(n[`${i}Cookies`]||{});for(let i of(l.filter(e=>e.endsWith("*")).map(e=>{o.keys({...a,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(a[i]){let t=`${i}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;e.cookie=t,e.cookie=`${t}domain=${location.hostname};`,e.cookie=`${t}domain=.${location.hostname};`,m("delete",{cookie:i})}t[i]&&(localStorage.removeItem(i),m("delete",{localStorage:i}))}}}function $(e){let t=void 0===e,o={consentTime:+new Date};n.sections.forEach(a=>{if("essential"===a)return;let i=l.querySelector(`[data-s=${a}]`),n=t?i.checked:e;o[a]=n,t||(i.checked=e)}),b(p(),o),u(o),localStorage.setItem(n.key,JSON.stringify(o)),m("save",{data:o}),f(),k(),i.open&&i.close(),c(!1)}function k(){e.querySelectorAll("script[data-consent]").forEach(t=>{if(!p()[t.dataset.consent])return;let o=e.createElement("script");for(let{name:e,value:a}of t.attributes)e.startsWith("data-")||"type"===e||o.setAttribute(e,a);o.setAttribute("type",t.dataset.type||"text/javascript"),t.src||(o.textContent=t.textContent),t.parentNode.replaceChild(o,t),m("inject",{el:t,...t.id&&{id:t.id}}),t.src&&""!==t.textContent.trim()&&o.addEventListener("load",()=>{let a=e.createElement("script");a.textContent=t.textContent,t.id&&(a.id=t.id+"-after"),o.insertAdjacentElement("afterend",a),m("inject",{el:a,parent:t,...a.id&&{id:a.id}})})})}u(g()||{}),l.className="biscuitman",l.innerHTML=`
${n.title}

${n.message}

${n.settingsTitle}

${n.message}

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

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

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

${s?o.entries(s).map(([e,t])=>`
${e}
${t}
`).join(""):`
${n.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${n.linkText}`),l.onclick=e=>{let t=e.target.dataset.id;if(t)switch(m("button",{id:t}),t){case"more":e.target.remove();break;case"accept":$(!0);break;case"close":i.close();break;case"settings":d();break;case"save":$();break;case"reject":$(!1)}},l.onchange=e=>{e.target.dataset.s&&e.target.parentElement.classList.toggle("checked",e.target.checked)},i=l.querySelector("dialog"),n.dialogPolyfill&&!i.close&&function(o){function a(){e.documentElement.classList.add("bm-dialog-polyfill"),t.dialogPolyfill.registerDialog(o)}if(t.dialogPolyfill)a();else{let t=e.createElement("script");t.onload=a,t.src=n.dialogPolyfill,e.head.appendChild(t)}}(i),i.onclose=()=>m("close"),n.force&&(i.oncancel=e=>e.preventDefault(),i.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),e.body.appendChild(l),t.addEventListener("resize",s);let h=Intl.DateTimeFormat().resolvedOptions().timeZone,v=/^(GMT|UTC)$/.test(h)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(h);n.acceptNonEU&&!v&&($(!0),c(!1)),f(),t[n.global].consentTime?(c(!1),k()):(c(!0),n.force&&d()),t.bmInvalidate=()=>{m("invalidate",{data:p()}),b({}),$(!1),u({}),localStorage.removeItem(n.key),c(!0),n.force&&i.showModal()},t.bmUpdate=()=>{m("update",{data:p()}),c(!0),d()}})(document,window,Object,document.documentElement);;((d)=>{let c=d.createElement('style');c.textContent=`/*! biscuitman.js 0.5.5 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;background:var(--bg);box-sizing:border-box;z-index:3;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px #00000029}.bm-show .biscuitman{display:block}.biscuitman *{box-sizing:border-box;color:var(--tx);margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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(--tx);margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--bg);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(--bg)!important}.biscuitman button[data-id=close]{color:rgba(var(--ui),.5);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 (min-width:576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{background:var(--bg);border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.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{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--bg)20%,#fff0);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(--bg)20%,#fff0);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(var(--ui),.2)var(--bg);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=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 rgba(var(--ui),.2);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 rgba(var(--ui),.4);border-top-color:#0000;border-left-color:#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(--tx);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(var(--ui),.08);margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--tx);font-size:12px}.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);background-color:rgba(var(--ui),.3);border-radius:var(--height);margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--bg);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.checked{background-color:var(--c)}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;transform:translateY(-50%)}`;d.head.appendChild(c)})(document); \ No newline at end of file diff --git a/dist/dialog-polyfill.withcss.js b/dist/dialog-polyfill.withcss.js index 13e3d8f..3dcc57c 100644 --- a/dist/dialog-polyfill.withcss.js +++ b/dist/dialog-polyfill.withcss.js @@ -1,4 +1,4 @@ -/*! biscuitman.js 0.5.4 *//* dialog-polyfill.js ^0.5.6*/ +/*! biscuitman.js 0.5.5 *//* dialog-polyfill.js ^0.5.6*/ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : @@ -868,6 +868,6 @@ (function(d) { var css=d.createElement('style'); - css.textContent='/*! biscuitman.js 0.5.4 */dialog{color:#000;background:#fff;border:solid;width:fit-content;height:fit-content;margin:auto;padding:1em;display:block;position:absolute;left:0;right:0}dialog:not([open]){display:none}dialog+.backdrop{background:#0000001a;position:fixed;inset:0}._dialog_overlay{position:fixed;inset:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}'; + css.textContent='/*! biscuitman.js 0.5.5 */dialog{color:#000;background:#fff;border:solid;width:fit-content;height:fit-content;margin:auto;padding:1em;display:block;position:absolute;left:0;right:0}dialog:not([open]){display:none}dialog+.backdrop{background:#0000001a;position:fixed;inset:0}._dialog_overlay{position:fixed;inset:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}'; d.head.appendChild(css) })(document); \ No newline at end of file diff --git a/dist/dialog-polyfill.withcss.min.js b/dist/dialog-polyfill.withcss.min.js index e81aefd..348afdb 100644 --- a/dist/dialog-polyfill.withcss.min.js +++ b/dist/dialog-polyfill.withcss.min.js @@ -1 +1 @@ -/*! biscuitman.js 0.5.4 *//* dialog-polyfill.js ^0.5.6*/function _instanceof(left,right){return null!=right&&"undefined"!=typeof Symbol&&right[Symbol.hasInstance]?!!right[Symbol.hasInstance](left):left instanceof right}function _type_of(obj){return obj&&"undefined"!=typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj}!function(global,factory){("undefined"==typeof exports?"undefined":_type_of(exports))==="object"&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global=global||self).dialogPolyfill=factory()}(this,function(){"use strict";var supportCustomEvent=window.CustomEvent;function safeDispatchEvent(target,event){var check="on"+event.type.toLowerCase();return"function"==typeof target[check]&&target[check](event),target.dispatchEvent(event)}function findNearestDialog(el){for(;el;){if("dialog"===el.localName)return el;el=el.parentElement?el.parentElement:el.parentNode?el.parentNode.host:null}return null}function safeBlur(el){for(;el&&el.shadowRoot&&el.shadowRoot.activeElement;)el=el.shadowRoot.activeElement;el&&el.blur&&el!==document.body&&el.blur()}function isFormMethodDialog(el){return!!(el&&el.hasAttribute("method"))&&"dialog"===el.getAttribute("method").toLowerCase()}function isConnected(element){return element.isConnected||document.body.contains(element)}function findFormSubmitter(event){if(event.submitter)return event.submitter;var form=event.target;if(!_instanceof(form,HTMLFormElement))return null;var submitter=dialogPolyfill.formSubmitter;if(!submitter){var target=event.target;submitter=("getRootNode"in target&&target.getRootNode()||document).activeElement}return submitter&&submitter.form===form?submitter:null}function maybeHandleSubmit(event){if(!event.defaultPrevented){var form=event.target,value=dialogPolyfill.imagemapUseValue,submitter=findFormSubmitter(event);null===value&&submitter&&(value=submitter.value);var dialog=findNearestDialog(form);dialog&&"dialog"===(submitter&&submitter.getAttribute("formmethod")||form.getAttribute("method"))&&(event.preventDefault(),null!=value?dialog.close(value):dialog.close())}}function dialogPolyfillInfo(dialog){if(this.dialog_=dialog,this.replacedStyleTop_=!1,this.openAsModal_=!1,dialog.hasAttribute("role")||dialog.setAttribute("role","dialog"),dialog.show=this.show.bind(this),dialog.showModal=this.showModal.bind(this),dialog.close=this.close.bind(this),dialog.addEventListener("submit",maybeHandleSubmit,!1),"returnValue"in dialog||(dialog.returnValue=""),"MutationObserver"in window)new MutationObserver(this.maybeHideModal.bind(this)).observe(dialog,{attributes:!0,attributeFilter:["open"]});else{var timeout,removed=!1,cb=(function(){removed?this.downgradeModal():this.maybeHideModal(),removed=!1}).bind(this),delayModel=function(ev){if(ev.target===dialog){var cand="DOMNodeRemoved";removed|=ev.type.substr(0,cand.length)===cand,window.clearTimeout(timeout),timeout=window.setTimeout(cb,0)}};["DOMAttrModified","DOMNodeRemoved","DOMNodeRemovedFromDocument"].forEach(function(name){dialog.addEventListener(name,delayModel)})}Object.defineProperty(dialog,"open",{set:this.setOpen.bind(this),get:dialog.hasAttribute.bind(dialog,"open")}),this.backdrop_=document.createElement("div"),this.backdrop_.className="backdrop",this.backdrop_.addEventListener("mouseup",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("mousedown",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("click",this.backdropMouseEvent_.bind(this))}supportCustomEvent&&(void 0===supportCustomEvent?"undefined":_type_of(supportCustomEvent))!=="object"||((supportCustomEvent=function(event,x){x=x||{};var ev=document.createEvent("CustomEvent");return ev.initCustomEvent(event,!!x.bubbles,!!x.cancelable,x.detail||null),ev}).prototype=window.Event.prototype),dialogPolyfillInfo.prototype={get dialog(){return this.dialog_},maybeHideModal:function(){this.dialog_.hasAttribute("open")&&isConnected(this.dialog_)||this.downgradeModal()},downgradeModal:function(){this.openAsModal_&&(this.openAsModal_=!1,this.dialog_.style.zIndex="",this.replacedStyleTop_&&(this.dialog_.style.top="",this.replacedStyleTop_=!1),this.backdrop_.parentNode&&this.backdrop_.parentNode.removeChild(this.backdrop_),dialogPolyfill.dm.removeDialog(this))},setOpen:function(value){value?this.dialog_.hasAttribute("open")||this.dialog_.setAttribute("open",""):(this.dialog_.removeAttribute("open"),this.maybeHideModal())},backdropMouseEvent_:function(e){if(this.dialog_.hasAttribute("tabindex"))this.dialog_.focus();else{var fake=document.createElement("div");this.dialog_.insertBefore(fake,this.dialog_.firstChild),fake.tabIndex=-1,fake.focus(),this.dialog_.removeChild(fake)}var redirectedEvent=document.createEvent("MouseEvents");redirectedEvent.initMouseEvent(e.type,e.bubbles,e.cancelable,window,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget),this.dialog_.dispatchEvent(redirectedEvent),e.stopPropagation()},focus_:function(){var target=this.dialog_.querySelector("[autofocus]:not([disabled])");!target&&this.dialog_.tabIndex>=0&&(target=this.dialog_),target||(target=function findFocusableElementWithin(hostElement){var query=["button","input","keygen","select","textarea"].map(function(el){return el+":not([disabled])"});query.push('[tabindex]:not([disabled]):not([tabindex=""])');var target=hostElement.querySelector(query.join(", "));if(!target&&"attachShadow"in Element.prototype)for(var elems=hostElement.querySelectorAll("*"),i=0;i, the polyfill may not work correctly",element),"dialog"!==element.localName)throw Error("Failed to register dialog: The element is not a dialog.");new dialogPolyfillInfo(element)},dialogPolyfill.registerDialog=function(element){element.showModal||dialogPolyfill.forceRegisterDialog(element)},dialogPolyfill.DialogManager=function(){this.pendingDialogStack=[];var checkDOM=this.checkDOM_.bind(this);this.overlay=document.createElement("div"),this.overlay.className="_dialog_overlay",this.overlay.addEventListener("click",(function(e){this.forwardTab_=void 0,e.stopPropagation(),checkDOM([])}).bind(this)),this.handleKey_=this.handleKey_.bind(this),this.handleFocus_=this.handleFocus_.bind(this),this.zIndexLow_=1e5,this.zIndexHigh_=100150,this.forwardTab_=void 0,"MutationObserver"in window&&(this.mo_=new MutationObserver(function(records){var removed=[];records.forEach(function(rec){for(var c,i=0;c=rec.removedNodes[i];++i)_instanceof(c,Element)&&("dialog"===c.localName&&removed.push(c),removed=removed.concat(c.querySelectorAll("dialog")))}),removed.length&&checkDOM(removed)}))},dialogPolyfill.DialogManager.prototype.blockDocument=function(){document.documentElement.addEventListener("focus",this.handleFocus_,!0),document.addEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.observe(document,{childList:!0,subtree:!0})},dialogPolyfill.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0),document.removeEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.disconnect()},dialogPolyfill.DialogManager.prototype.updateStacking=function(){for(var dpi,zIndex=this.zIndexHigh_,i=0;dpi=this.pendingDialogStack[i];++i)dpi.updateZIndex(--zIndex,--zIndex),0===i&&(this.overlay.style.zIndex=--zIndex);var last=this.pendingDialogStack[0];last?(last.dialog.parentNode||document.body).appendChild(this.overlay):this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)},dialogPolyfill.DialogManager.prototype.containedByTopDialog_=function(candidate){for(;candidate=findNearestDialog(candidate);){for(var dpi,i=0;dpi=this.pendingDialogStack[i];++i)if(dpi.dialog===candidate)return 0===i;candidate=candidate.parentElement}return!1},dialogPolyfill.DialogManager.prototype.handleFocus_=function(event){var target=event.composedPath?event.composedPath()[0]:event.target;if(!this.containedByTopDialog_(target)&&document.activeElement!==document.documentElement&&(event.preventDefault(),event.stopPropagation(),safeBlur(target),void 0!==this.forwardTab_)){var dpi=this.pendingDialogStack[0];return dpi.dialog.compareDocumentPosition(target)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?dpi.focus_():target!==document.documentElement&&document.documentElement.focus()),!1}},dialogPolyfill.DialogManager.prototype.handleKey_=function(event){if(this.forwardTab_=void 0,27===event.keyCode){event.preventDefault(),event.stopPropagation();var cancelEvent=new supportCustomEvent("cancel",{bubbles:!1,cancelable:!0}),dpi=this.pendingDialogStack[0];dpi&&safeDispatchEvent(dpi.dialog,cancelEvent)&&dpi.dialog.close()}else 9===event.keyCode&&(this.forwardTab_=!event.shiftKey)},dialogPolyfill.DialogManager.prototype.checkDOM_=function(removed){this.pendingDialogStack.slice().forEach(function(dpi){-1!==removed.indexOf(dpi.dialog)?dpi.downgradeModal():dpi.maybeHideModal()})},dialogPolyfill.DialogManager.prototype.pushDialog=function(dpi){var allowed=(this.zIndexHigh_-this.zIndexLow_)/2-1;return!(this.pendingDialogStack.length>=allowed)&&(1===this.pendingDialogStack.unshift(dpi)&&this.blockDocument(),this.updateStacking(),!0)},dialogPolyfill.DialogManager.prototype.removeDialog=function(dpi){var index=this.pendingDialogStack.indexOf(dpi);-1!==index&&(this.pendingDialogStack.splice(index,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())},dialogPolyfill.dm=new dialogPolyfill.DialogManager,dialogPolyfill.formSubmitter=null,dialogPolyfill.imagemapUseValue=null,void 0===window.HTMLDialogElement){var testForm=document.createElement("form");if(testForm.setAttribute("method","dialog"),"dialog"!==testForm.method){var methodDescriptor=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method");if(methodDescriptor){var realGet=methodDescriptor.get;methodDescriptor.get=function(){return isFormMethodDialog(this)?"dialog":realGet.call(this)};var realSet=methodDescriptor.set;methodDescriptor.set=function(v){return"string"==typeof v&&"dialog"===v.toLowerCase()?this.setAttribute("method",v):realSet.call(this,v)},Object.defineProperty(HTMLFormElement.prototype,"method",methodDescriptor)}}document.addEventListener("click",function(ev){if(dialogPolyfill.formSubmitter=null,dialogPolyfill.imagemapUseValue=null,!ev.defaultPrevented){var target=ev.target;if("composedPath"in ev&&(target=ev.composedPath().shift()||target),target&&isFormMethodDialog(target.form)){if(!("submit"===target.type&&["button","input"].indexOf(target.localName)>-1)){if(!("input"===target.localName&&"image"===target.type))return;dialogPolyfill.imagemapUseValue=ev.offsetX+","+ev.offsetY}findNearestDialog(target)&&(dialogPolyfill.formSubmitter=target)}}},!1),document.addEventListener("submit",function(ev){var form=ev.target;if(!findNearestDialog(form)){var submitter=findFormSubmitter(ev);"dialog"===(submitter&&submitter.getAttribute("formmethod")||form.getAttribute("method"))&&ev.preventDefault()}});var nativeFormSubmit=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!isFormMethodDialog(this))return nativeFormSubmit.call(this);var dialog=findNearestDialog(this);dialog&&dialog.close()}}return dialogPolyfill});;(function(d){var c=d.createElement('style');c.textContent='/*! biscuitman.js 0.5.4 */dialog{color:#000;background:#fff;border:solid;width:fit-content;height:fit-content;margin:auto;padding:1em;display:block;position:absolute;left:0;right:0}dialog:not([open]){display:none}dialog+.backdrop{background:#0000001a;position:fixed;inset:0}._dialog_overlay{position:fixed;inset:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}';d.head.appendChild(c)})(document); \ No newline at end of file +/*! biscuitman.js 0.5.5 *//* dialog-polyfill.js ^0.5.6*/function _instanceof(left,right){return null!=right&&"undefined"!=typeof Symbol&&right[Symbol.hasInstance]?!!right[Symbol.hasInstance](left):left instanceof right}function _type_of(obj){return obj&&"undefined"!=typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj}!function(global,factory){("undefined"==typeof exports?"undefined":_type_of(exports))==="object"&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global=global||self).dialogPolyfill=factory()}(this,function(){"use strict";var supportCustomEvent=window.CustomEvent;function safeDispatchEvent(target,event){var check="on"+event.type.toLowerCase();return"function"==typeof target[check]&&target[check](event),target.dispatchEvent(event)}function findNearestDialog(el){for(;el;){if("dialog"===el.localName)return el;el=el.parentElement?el.parentElement:el.parentNode?el.parentNode.host:null}return null}function safeBlur(el){for(;el&&el.shadowRoot&&el.shadowRoot.activeElement;)el=el.shadowRoot.activeElement;el&&el.blur&&el!==document.body&&el.blur()}function isFormMethodDialog(el){return!!(el&&el.hasAttribute("method"))&&"dialog"===el.getAttribute("method").toLowerCase()}function isConnected(element){return element.isConnected||document.body.contains(element)}function findFormSubmitter(event){if(event.submitter)return event.submitter;var form=event.target;if(!_instanceof(form,HTMLFormElement))return null;var submitter=dialogPolyfill.formSubmitter;if(!submitter){var target=event.target;submitter=("getRootNode"in target&&target.getRootNode()||document).activeElement}return submitter&&submitter.form===form?submitter:null}function maybeHandleSubmit(event){if(!event.defaultPrevented){var form=event.target,value=dialogPolyfill.imagemapUseValue,submitter=findFormSubmitter(event);null===value&&submitter&&(value=submitter.value);var dialog=findNearestDialog(form);dialog&&"dialog"===(submitter&&submitter.getAttribute("formmethod")||form.getAttribute("method"))&&(event.preventDefault(),null!=value?dialog.close(value):dialog.close())}}function dialogPolyfillInfo(dialog){if(this.dialog_=dialog,this.replacedStyleTop_=!1,this.openAsModal_=!1,dialog.hasAttribute("role")||dialog.setAttribute("role","dialog"),dialog.show=this.show.bind(this),dialog.showModal=this.showModal.bind(this),dialog.close=this.close.bind(this),dialog.addEventListener("submit",maybeHandleSubmit,!1),"returnValue"in dialog||(dialog.returnValue=""),"MutationObserver"in window)new MutationObserver(this.maybeHideModal.bind(this)).observe(dialog,{attributes:!0,attributeFilter:["open"]});else{var timeout,removed=!1,cb=(function(){removed?this.downgradeModal():this.maybeHideModal(),removed=!1}).bind(this),delayModel=function(ev){if(ev.target===dialog){var cand="DOMNodeRemoved";removed|=ev.type.substr(0,cand.length)===cand,window.clearTimeout(timeout),timeout=window.setTimeout(cb,0)}};["DOMAttrModified","DOMNodeRemoved","DOMNodeRemovedFromDocument"].forEach(function(name){dialog.addEventListener(name,delayModel)})}Object.defineProperty(dialog,"open",{set:this.setOpen.bind(this),get:dialog.hasAttribute.bind(dialog,"open")}),this.backdrop_=document.createElement("div"),this.backdrop_.className="backdrop",this.backdrop_.addEventListener("mouseup",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("mousedown",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("click",this.backdropMouseEvent_.bind(this))}supportCustomEvent&&(void 0===supportCustomEvent?"undefined":_type_of(supportCustomEvent))!=="object"||((supportCustomEvent=function(event,x){x=x||{};var ev=document.createEvent("CustomEvent");return ev.initCustomEvent(event,!!x.bubbles,!!x.cancelable,x.detail||null),ev}).prototype=window.Event.prototype),dialogPolyfillInfo.prototype={get dialog(){return this.dialog_},maybeHideModal:function(){this.dialog_.hasAttribute("open")&&isConnected(this.dialog_)||this.downgradeModal()},downgradeModal:function(){this.openAsModal_&&(this.openAsModal_=!1,this.dialog_.style.zIndex="",this.replacedStyleTop_&&(this.dialog_.style.top="",this.replacedStyleTop_=!1),this.backdrop_.parentNode&&this.backdrop_.parentNode.removeChild(this.backdrop_),dialogPolyfill.dm.removeDialog(this))},setOpen:function(value){value?this.dialog_.hasAttribute("open")||this.dialog_.setAttribute("open",""):(this.dialog_.removeAttribute("open"),this.maybeHideModal())},backdropMouseEvent_:function(e){if(this.dialog_.hasAttribute("tabindex"))this.dialog_.focus();else{var fake=document.createElement("div");this.dialog_.insertBefore(fake,this.dialog_.firstChild),fake.tabIndex=-1,fake.focus(),this.dialog_.removeChild(fake)}var redirectedEvent=document.createEvent("MouseEvents");redirectedEvent.initMouseEvent(e.type,e.bubbles,e.cancelable,window,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget),this.dialog_.dispatchEvent(redirectedEvent),e.stopPropagation()},focus_:function(){var target=this.dialog_.querySelector("[autofocus]:not([disabled])");!target&&this.dialog_.tabIndex>=0&&(target=this.dialog_),target||(target=function findFocusableElementWithin(hostElement){var query=["button","input","keygen","select","textarea"].map(function(el){return el+":not([disabled])"});query.push('[tabindex]:not([disabled]):not([tabindex=""])');var target=hostElement.querySelector(query.join(", "));if(!target&&"attachShadow"in Element.prototype)for(var elems=hostElement.querySelectorAll("*"),i=0;i, the polyfill may not work correctly",element),"dialog"!==element.localName)throw Error("Failed to register dialog: The element is not a dialog.");new dialogPolyfillInfo(element)},dialogPolyfill.registerDialog=function(element){element.showModal||dialogPolyfill.forceRegisterDialog(element)},dialogPolyfill.DialogManager=function(){this.pendingDialogStack=[];var checkDOM=this.checkDOM_.bind(this);this.overlay=document.createElement("div"),this.overlay.className="_dialog_overlay",this.overlay.addEventListener("click",(function(e){this.forwardTab_=void 0,e.stopPropagation(),checkDOM([])}).bind(this)),this.handleKey_=this.handleKey_.bind(this),this.handleFocus_=this.handleFocus_.bind(this),this.zIndexLow_=1e5,this.zIndexHigh_=100150,this.forwardTab_=void 0,"MutationObserver"in window&&(this.mo_=new MutationObserver(function(records){var removed=[];records.forEach(function(rec){for(var c,i=0;c=rec.removedNodes[i];++i)_instanceof(c,Element)&&("dialog"===c.localName&&removed.push(c),removed=removed.concat(c.querySelectorAll("dialog")))}),removed.length&&checkDOM(removed)}))},dialogPolyfill.DialogManager.prototype.blockDocument=function(){document.documentElement.addEventListener("focus",this.handleFocus_,!0),document.addEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.observe(document,{childList:!0,subtree:!0})},dialogPolyfill.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0),document.removeEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.disconnect()},dialogPolyfill.DialogManager.prototype.updateStacking=function(){for(var dpi,zIndex=this.zIndexHigh_,i=0;dpi=this.pendingDialogStack[i];++i)dpi.updateZIndex(--zIndex,--zIndex),0===i&&(this.overlay.style.zIndex=--zIndex);var last=this.pendingDialogStack[0];last?(last.dialog.parentNode||document.body).appendChild(this.overlay):this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)},dialogPolyfill.DialogManager.prototype.containedByTopDialog_=function(candidate){for(;candidate=findNearestDialog(candidate);){for(var dpi,i=0;dpi=this.pendingDialogStack[i];++i)if(dpi.dialog===candidate)return 0===i;candidate=candidate.parentElement}return!1},dialogPolyfill.DialogManager.prototype.handleFocus_=function(event){var target=event.composedPath?event.composedPath()[0]:event.target;if(!this.containedByTopDialog_(target)&&document.activeElement!==document.documentElement&&(event.preventDefault(),event.stopPropagation(),safeBlur(target),void 0!==this.forwardTab_)){var dpi=this.pendingDialogStack[0];return dpi.dialog.compareDocumentPosition(target)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?dpi.focus_():target!==document.documentElement&&document.documentElement.focus()),!1}},dialogPolyfill.DialogManager.prototype.handleKey_=function(event){if(this.forwardTab_=void 0,27===event.keyCode){event.preventDefault(),event.stopPropagation();var cancelEvent=new supportCustomEvent("cancel",{bubbles:!1,cancelable:!0}),dpi=this.pendingDialogStack[0];dpi&&safeDispatchEvent(dpi.dialog,cancelEvent)&&dpi.dialog.close()}else 9===event.keyCode&&(this.forwardTab_=!event.shiftKey)},dialogPolyfill.DialogManager.prototype.checkDOM_=function(removed){this.pendingDialogStack.slice().forEach(function(dpi){-1!==removed.indexOf(dpi.dialog)?dpi.downgradeModal():dpi.maybeHideModal()})},dialogPolyfill.DialogManager.prototype.pushDialog=function(dpi){var allowed=(this.zIndexHigh_-this.zIndexLow_)/2-1;return!(this.pendingDialogStack.length>=allowed)&&(1===this.pendingDialogStack.unshift(dpi)&&this.blockDocument(),this.updateStacking(),!0)},dialogPolyfill.DialogManager.prototype.removeDialog=function(dpi){var index=this.pendingDialogStack.indexOf(dpi);-1!==index&&(this.pendingDialogStack.splice(index,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())},dialogPolyfill.dm=new dialogPolyfill.DialogManager,dialogPolyfill.formSubmitter=null,dialogPolyfill.imagemapUseValue=null,void 0===window.HTMLDialogElement){var testForm=document.createElement("form");if(testForm.setAttribute("method","dialog"),"dialog"!==testForm.method){var methodDescriptor=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method");if(methodDescriptor){var realGet=methodDescriptor.get;methodDescriptor.get=function(){return isFormMethodDialog(this)?"dialog":realGet.call(this)};var realSet=methodDescriptor.set;methodDescriptor.set=function(v){return"string"==typeof v&&"dialog"===v.toLowerCase()?this.setAttribute("method",v):realSet.call(this,v)},Object.defineProperty(HTMLFormElement.prototype,"method",methodDescriptor)}}document.addEventListener("click",function(ev){if(dialogPolyfill.formSubmitter=null,dialogPolyfill.imagemapUseValue=null,!ev.defaultPrevented){var target=ev.target;if("composedPath"in ev&&(target=ev.composedPath().shift()||target),target&&isFormMethodDialog(target.form)){if(!("submit"===target.type&&["button","input"].indexOf(target.localName)>-1)){if(!("input"===target.localName&&"image"===target.type))return;dialogPolyfill.imagemapUseValue=ev.offsetX+","+ev.offsetY}findNearestDialog(target)&&(dialogPolyfill.formSubmitter=target)}}},!1),document.addEventListener("submit",function(ev){var form=ev.target;if(!findNearestDialog(form)){var submitter=findFormSubmitter(ev);"dialog"===(submitter&&submitter.getAttribute("formmethod")||form.getAttribute("method"))&&ev.preventDefault()}});var nativeFormSubmit=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!isFormMethodDialog(this))return nativeFormSubmit.call(this);var dialog=findNearestDialog(this);dialog&&dialog.close()}}return dialogPolyfill});;(function(d){var c=d.createElement('style');c.textContent='/*! biscuitman.js 0.5.5 */dialog{color:#000;background:#fff;border:solid;width:fit-content;height:fit-content;margin:auto;padding:1em;display:block;position:absolute;left:0;right:0}dialog:not([open]){display:none}dialog+.backdrop{background:#0000001a;position:fixed;inset:0}._dialog_overlay{position:fixed;inset:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}';d.head.appendChild(c)})(document); \ No newline at end of file diff --git a/dist/esm/biscuitman.min.mjs b/dist/esm/biscuitman.min.mjs index 5acc424..0afafb2 100644 --- a/dist/esm/biscuitman.min.mjs +++ b/dist/esm/biscuitman.min.mjs @@ -1 +1 @@ -/*! biscuitman.js 0.5.4 */let e,t,o;let{document:a,window:n,Object:i}=globalThis,l=a.documentElement,s={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js"},c=document.createElement("div"),r={},d=()=>{l.style.setProperty("--bm-height",`${c.offsetHeight}px`)},m=e=>{l.classList.toggle("bm-show",e),d()},p=()=>{let{consentTime:t,...o}=b();for(let[a,n]of(t||(o=i.fromEntries(e.sections.slice(1).map(e=>[e,!1]))),i.entries(o)))l.classList.toggle(`bm-${a}`,n),l.classList.toggle(`bm-no-${a}`,!n)};function u(){f("open"),t.showModal()}function f(e,t){let o=`bm:${e}`,n={...void 0!==t&&t,time:+new Date};a.dispatchEvent(new CustomEvent(o,{detail:n})),console.debug(o,n),r[o]&&r[o].forEach(e=>e(n))}let b=()=>n[e.global]||{};function g(t){n[e.global]=t,p()}let $=e=>!!b()[e];function h(e,t){for(let o in e)e[o]&&!1===t[o]&&f("revoke",{section:o})}function v(){try{return JSON.parse(localStorage.getItem(e.key))}catch(t){return console.error(t),localStorage.removeItem(e.key),{}}}function k(){let t=i.fromEntries(i.entries(localStorage)),o=i.fromEntries(a.cookie.split("; ").map(e=>e.split("="))),{consentTime:n,...l}=v()||e.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[n,s]of i.entries(l)){if(s)continue;let l=i.keys(e[`${n}Cookies`]||{});for(let e of(l.filter(e=>e.endsWith("*")).map(e=>{i.keys({...o,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(o[e]){let t=`${e}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;a.cookie=t,a.cookie=`${t}domain=${location.hostname};`,a.cookie=`${t}domain=.${location.hostname};`,f("delete",{cookie:e})}t[e]&&(localStorage.removeItem(e),f("delete",{localStorage:e}))}}}function y(o){let a=void 0===o,n={consentTime:+new Date};e.sections.forEach(e=>{if("essential"===e)return;let t=c.querySelector(`[data-s=${e}]`),i=a?t.checked:o;n[e]=i,a||(t.checked=o)}),h(b(),n),g(n),localStorage.setItem(e.key,JSON.stringify(n)),f("save",{data:n}),k(),E(),t.open&&t.close(),m(!1)}function E(){a.querySelectorAll("script[data-consent]").forEach(e=>{if(!b()[e.dataset.consent])return;let t=a.createElement("script");for(let{name:o,value:a}of e.attributes)o.startsWith("data-")||"type"===o||t.setAttribute(o,a);t.setAttribute("type",e.dataset.type||"text/javascript"),e.src||(t.textContent=e.textContent),e.parentNode.replaceChild(t,e),f("inject",{el:e,...e.id&&{id:e.id}}),e.src&&""!==e.textContent.trim()&&t.addEventListener("load",()=>{let o=a.createElement("script");o.textContent=e.textContent,e.id&&(o.id=e.id+"-after"),t.insertAdjacentElement("afterend",o),f("inject",{el:o,parent:e,...o.id&&{id:o.id}})})})}export default{create:function(){let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o)return o;e={...s,...l};let p=n.bmInvalidate=()=>{f("invalidate",{data:b()}),h({}),y(!1),g({}),localStorage.removeItem(e.key),m(!0),e.force&&t.showModal()},T=n.bmUpdate=()=>{f("update",{data:b()}),m(!0),u()};return g(v()||{}),function(){let t=Intl.DateTimeFormat().resolvedOptions().timeZone,o=/^(GMT|UTC)$/.test(t)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(t);e.acceptNonEU&&!o&&(y(!0),m(!1))}(),c.className="biscuitman",c.innerHTML=`
${e.title}

${e.message}

${e.settingsTitle}

${e.message}

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

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

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

${s?i.entries(s).map(e=>{let[t,o]=e;return`
${t}
${o}
`}).join(""):`
${e.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${e.linkText}`),c.onclick=e=>{let o=e.target.dataset.id;if(o)switch(f("button",{id:o}),o){case"more":e.target.remove();break;case"accept":y(!0);break;case"close":t.close();break;case"settings":u();break;case"save":y();break;case"reject":y(!1)}},t=c.querySelector("dialog"),e.dialogPolyfill&&!t.close&&function(t){function o(){a.documentElement.classList.add("bm-dialog-polyfill"),n.dialogPolyfill.registerDialog(t)}if(n.dialogPolyfill)o();else{let t=a.createElement("script");t.onload=o,t.src=e.dialogPolyfill,a.head.appendChild(t)}}(t),t.onclose=()=>f("close"),e.force&&(t.oncancel=e=>e.preventDefault(),t.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),c.querySelectorAll("[data-s]").forEach(e=>e.addEventListener("change",t=>{e.parentElement.classList.toggle("checked",t.target.checked)})),a.body.appendChild(c),n.addEventListener("resize",d),k(),n[e.global].consentTime?(m(!1),E()):(m(!0),e.force&&u()),o={consent:$,invalidate:p,update:T,on:(e,t)=>{let a=`bm:${e}`;return r[a]||(r[a]=[]),r[a].push(t),o},off:(e,t)=>{let o=`bm:${e}`;r[o]&&(r[o]=r[o].filter(e=>e!==t))}}}}; \ No newline at end of file +/*! biscuitman.js 0.5.5 */let e,t,o;let{document:a,window:n,Object:i}=globalThis,l=a.documentElement,s={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js"},c=document.createElement("div"),r={},d=()=>{l.style.setProperty("--bm-height",`${c.offsetHeight}px`)},m=e=>{l.classList.toggle("bm-show",e),d()},p=()=>{let{consentTime:t,...o}=b();for(let[a,n]of(t||(o=i.fromEntries(e.sections.slice(1).map(e=>[e,!1]))),i.entries(o)))l.classList.toggle(`bm-${a}`,n),l.classList.toggle(`bm-no-${a}`,!n)};function u(){f("open"),t.showModal()}function f(e,t){let o=`bm:${e}`,n={...void 0!==t&&t,time:+new Date};a.dispatchEvent(new CustomEvent(o,{detail:n})),console.debug(o,n),r[o]&&r[o].forEach(e=>e(n))}let b=()=>n[e.global]||{};function g(t){n[e.global]=t,p()}let $=e=>!!b()[e];function h(e,t){for(let o in e)e[o]&&!1===t[o]&&f("revoke",{section:o})}function v(){try{return JSON.parse(localStorage.getItem(e.key))}catch(t){return console.error(t),localStorage.removeItem(e.key),{}}}function k(){let t=i.fromEntries(i.entries(localStorage)),o=i.fromEntries(a.cookie.split("; ").map(e=>e.split("="))),{consentTime:n,...l}=v()||e.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[n,s]of i.entries(l)){if(s)continue;let l=i.keys(e[`${n}Cookies`]||{});for(let e of(l.filter(e=>e.endsWith("*")).map(e=>{i.keys({...o,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(o[e]){let t=`${e}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;a.cookie=t,a.cookie=`${t}domain=${location.hostname};`,a.cookie=`${t}domain=.${location.hostname};`,f("delete",{cookie:e})}t[e]&&(localStorage.removeItem(e),f("delete",{localStorage:e}))}}}function y(o){let a=void 0===o,n={consentTime:+new Date};e.sections.forEach(e=>{if("essential"===e)return;let t=c.querySelector(`[data-s=${e}]`),i=a?t.checked:o;n[e]=i,a||(t.checked=o)}),h(b(),n),g(n),localStorage.setItem(e.key,JSON.stringify(n)),f("save",{data:n}),k(),E(),t.open&&t.close(),m(!1)}function E(){a.querySelectorAll("script[data-consent]").forEach(e=>{if(!b()[e.dataset.consent])return;let t=a.createElement("script");for(let{name:o,value:a}of e.attributes)o.startsWith("data-")||"type"===o||t.setAttribute(o,a);t.setAttribute("type",e.dataset.type||"text/javascript"),e.src||(t.textContent=e.textContent),e.parentNode.replaceChild(t,e),f("inject",{el:e,...e.id&&{id:e.id}}),e.src&&""!==e.textContent.trim()&&t.addEventListener("load",()=>{let o=a.createElement("script");o.textContent=e.textContent,e.id&&(o.id=e.id+"-after"),t.insertAdjacentElement("afterend",o),f("inject",{el:o,parent:e,...o.id&&{id:o.id}})})})}export default{create:function(l={}){if(o)return o;e={...s,...l};let p=n.bmInvalidate=()=>{f("invalidate",{data:b()}),h({}),y(!1),g({}),localStorage.removeItem(e.key),m(!0),e.force&&t.showModal()},T=n.bmUpdate=()=>{f("update",{data:b()}),m(!0),u()};return g(v()||{}),c.className="biscuitman",c.innerHTML=`
${e.title}

${e.message}

${e.settingsTitle}

${e.message}

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

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

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

${s?i.entries(s).map(([e,t])=>`
${e}
${t}
`).join(""):`
${e.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${e.linkText}`),c.onclick=e=>{let o=e.target.dataset.id;if(o)switch(f("button",{id:o}),o){case"more":e.target.remove();break;case"accept":y(!0);break;case"close":t.close();break;case"settings":u();break;case"save":y();break;case"reject":y(!1)}},t=c.querySelector("dialog"),e.dialogPolyfill&&!t.close&&function(t){function o(){a.documentElement.classList.add("bm-dialog-polyfill"),n.dialogPolyfill.registerDialog(t)}if(n.dialogPolyfill)o();else{let t=a.createElement("script");t.onload=o,t.src=e.dialogPolyfill,a.head.appendChild(t)}}(t),t.onclose=()=>f("close"),e.force&&(t.oncancel=e=>e.preventDefault(),t.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),c.querySelectorAll("[data-s]").forEach(e=>e.addEventListener("change",t=>{e.parentElement.classList.toggle("checked",t.target.checked)})),a.body.appendChild(c),n.addEventListener("resize",d),function(){let t=Intl.DateTimeFormat().resolvedOptions().timeZone,o=/^(GMT|UTC)$/.test(t)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(t);e.acceptNonEU&&!o&&(y(!0),m(!1))}(),k(),n[e.global].consentTime?(m(!1),E()):(m(!0),e.force&&u()),o={consent:$,invalidate:p,update:T,on:(e,t)=>{let a=`bm:${e}`;return r[a]||(r[a]=[]),r[a].push(t),o},off:(e,t)=>{let o=`bm:${e}`;r[o]&&(r[o]=r[o].filter(e=>e!==t))}}}}; \ No newline at end of file diff --git a/dist/esm/biscuitman.mjs b/dist/esm/biscuitman.mjs index ea40308..b610ebe 100644 --- a/dist/esm/biscuitman.mjs +++ b/dist/esm/biscuitman.mjs @@ -1,4 +1,4 @@ -/*! biscuitman.js 0.5.4 */ +/*! biscuitman.js 0.5.5 */ const { document: d, window: w, Object: O } = globalThis; const h = d.documentElement; const defaults = { @@ -65,10 +65,7 @@ function render() {

${options[`${section}Message`]}

- ${cookies ? O.entries(cookies).map((param)=>{ - let [k, v] = param; - return `
${k}
${v}
`; - }).join('') : `
${options.noCookies}
`} + ${cookies ? O.entries(cookies).map(([k, v])=>`
${k}
${v}
`).join('') : `
${options.noCookies}
`} `; }).join('')} @@ -295,8 +292,7 @@ function handleNonEUConsent() { } } let instance; -function create() { - let config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; +function create(config = {}) { if (instance) return instance; options = { ...defaults, @@ -304,10 +300,10 @@ function create() { }; function initialize() { setConsents(loadConsents() || {}); - // Optional Non-EU auto-consent - handleNonEUConsent(); // Render UI render(); + // Optional Non-EU auto-consent + handleNonEUConsent(); // Wipe matching cookies/localStorages without consent clearStorages(); // Consent logic diff --git a/dist/esm/biscuitman.withcss.min.mjs b/dist/esm/biscuitman.withcss.min.mjs index 926e137..53fb1e8 100644 --- a/dist/esm/biscuitman.withcss.min.mjs +++ b/dist/esm/biscuitman.withcss.min.mjs @@ -1 +1 @@ -/*! biscuitman.js 0.5.4 */let e,t,o;let{document:a,window:n,Object:i}=globalThis,l=a.documentElement,s={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js"},c=document.createElement("div"),r={},d=()=>{l.style.setProperty("--bm-height",`${c.offsetHeight}px`)},m=e=>{l.classList.toggle("bm-show",e),d()},p=()=>{let{consentTime:t,...o}=b();for(let[a,n]of(t||(o=i.fromEntries(e.sections.slice(1).map(e=>[e,!1]))),i.entries(o)))l.classList.toggle(`bm-${a}`,n),l.classList.toggle(`bm-no-${a}`,!n)};function u(){f("open"),t.showModal()}function f(e,t){let o=`bm:${e}`,n={...void 0!==t&&t,time:+new Date};a.dispatchEvent(new CustomEvent(o,{detail:n})),console.debug(o,n),r[o]&&r[o].forEach(e=>e(n))}let b=()=>n[e.global]||{};function g(t){n[e.global]=t,p()}let $=e=>!!b()[e];function h(e,t){for(let o in e)e[o]&&!1===t[o]&&f("revoke",{section:o})}function v(){try{return JSON.parse(localStorage.getItem(e.key))}catch(t){return console.error(t),localStorage.removeItem(e.key),{}}}function k(){let t=i.fromEntries(i.entries(localStorage)),o=i.fromEntries(a.cookie.split("; ").map(e=>e.split("="))),{consentTime:n,...l}=v()||e.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[n,s]of i.entries(l)){if(s)continue;let l=i.keys(e[`${n}Cookies`]||{});for(let e of(l.filter(e=>e.endsWith("*")).map(e=>{i.keys({...o,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(o[e]){let t=`${e}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;a.cookie=t,a.cookie=`${t}domain=${location.hostname};`,a.cookie=`${t}domain=.${location.hostname};`,f("delete",{cookie:e})}t[e]&&(localStorage.removeItem(e),f("delete",{localStorage:e}))}}}function y(o){let a=void 0===o,n={consentTime:+new Date};e.sections.forEach(e=>{if("essential"===e)return;let t=c.querySelector(`[data-s=${e}]`),i=a?t.checked:o;n[e]=i,a||(t.checked=o)}),h(b(),n),g(n),localStorage.setItem(e.key,JSON.stringify(n)),f("save",{data:n}),k(),E(),t.open&&t.close(),m(!1)}function E(){a.querySelectorAll("script[data-consent]").forEach(e=>{if(!b()[e.dataset.consent])return;let t=a.createElement("script");for(let{name:o,value:a}of e.attributes)o.startsWith("data-")||"type"===o||t.setAttribute(o,a);t.setAttribute("type",e.dataset.type||"text/javascript"),e.src||(t.textContent=e.textContent),e.parentNode.replaceChild(t,e),f("inject",{el:e,...e.id&&{id:e.id}}),e.src&&""!==e.textContent.trim()&&t.addEventListener("load",()=>{let o=a.createElement("script");o.textContent=e.textContent,e.id&&(o.id=e.id+"-after"),t.insertAdjacentElement("afterend",o),f("inject",{el:o,parent:e,...o.id&&{id:o.id}})})})}export default{create:function(){let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o)return o;e={...s,...l};let p=n.bmInvalidate=()=>{f("invalidate",{data:b()}),h({}),y(!1),g({}),localStorage.removeItem(e.key),m(!0),e.force&&t.showModal()},T=n.bmUpdate=()=>{f("update",{data:b()}),m(!0),u()};return g(v()||{}),function(){let t=Intl.DateTimeFormat().resolvedOptions().timeZone,o=/^(GMT|UTC)$/.test(t)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(t);e.acceptNonEU&&!o&&(y(!0),m(!1))}(),c.className="biscuitman",c.innerHTML=`
${e.title}

${e.message}

${e.settingsTitle}

${e.message}

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

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

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

${s?i.entries(s).map(e=>{let[t,o]=e;return`
${t}
${o}
`}).join(""):`
${e.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${e.linkText}`),c.onclick=e=>{let o=e.target.dataset.id;if(o)switch(f("button",{id:o}),o){case"more":e.target.remove();break;case"accept":y(!0);break;case"close":t.close();break;case"settings":u();break;case"save":y();break;case"reject":y(!1)}},t=c.querySelector("dialog"),e.dialogPolyfill&&!t.close&&function(t){function o(){a.documentElement.classList.add("bm-dialog-polyfill"),n.dialogPolyfill.registerDialog(t)}if(n.dialogPolyfill)o();else{let t=a.createElement("script");t.onload=o,t.src=e.dialogPolyfill,a.head.appendChild(t)}}(t),t.onclose=()=>f("close"),e.force&&(t.oncancel=e=>e.preventDefault(),t.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),c.querySelectorAll("[data-s]").forEach(e=>e.addEventListener("change",t=>{e.parentElement.classList.toggle("checked",t.target.checked)})),a.body.appendChild(c),n.addEventListener("resize",d),k(),n[e.global].consentTime?(m(!1),E()):(m(!0),e.force&&u()),o={consent:$,invalidate:p,update:T,on:(e,t)=>{let a=`bm:${e}`;return r[a]||(r[a]=[]),r[a].push(t),o},off:(e,t)=>{let o=`bm:${e}`;r[o]&&(r[o]=r[o].filter(e=>e!==t))}}}};;if(typeof BMCSS==='undefined'){let c=document.createElement('style');c.id='BMCSS';c.textContent=`/*! biscuitman.js 0.5.4 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;background:var(--bg);box-sizing:border-box;z-index:3;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px #00000029}.bm-show .biscuitman{display:block}.biscuitman *{box-sizing:border-box;color:var(--tx);margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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(--tx);margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--bg);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(--bg)!important}.biscuitman button[data-id=close]{color:rgba(var(--ui),.5);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 (min-width:576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{background:var(--bg);border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.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{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--bg)20%,#fff0);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(--bg)20%,#fff0);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(var(--ui),.2)var(--bg);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=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 rgba(var(--ui),.2);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 rgba(var(--ui),.4);border-top-color:#0000;border-left-color:#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(--tx);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(var(--ui),.08);margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--tx);font-size:12px}.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);background-color:rgba(var(--ui),.3);border-radius:var(--height);margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--bg);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.checked{background-color:var(--c)}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;transform:translateY(-50%)}`;document.head.appendChild(c)} \ No newline at end of file +/*! biscuitman.js 0.5.5 */let e,t,o;let{document:a,window:n,Object:i}=globalThis,l=a.documentElement,s={key:"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,dialogPolyfill:"/dist/dialog-polyfill.withcss.min.js"},c=document.createElement("div"),r={},d=()=>{l.style.setProperty("--bm-height",`${c.offsetHeight}px`)},m=e=>{l.classList.toggle("bm-show",e),d()},p=()=>{let{consentTime:t,...o}=b();for(let[a,n]of(t||(o=i.fromEntries(e.sections.slice(1).map(e=>[e,!1]))),i.entries(o)))l.classList.toggle(`bm-${a}`,n),l.classList.toggle(`bm-no-${a}`,!n)};function u(){f("open"),t.showModal()}function f(e,t){let o=`bm:${e}`,n={...void 0!==t&&t,time:+new Date};a.dispatchEvent(new CustomEvent(o,{detail:n})),console.debug(o,n),r[o]&&r[o].forEach(e=>e(n))}let b=()=>n[e.global]||{};function g(t){n[e.global]=t,p()}let $=e=>!!b()[e];function h(e,t){for(let o in e)e[o]&&!1===t[o]&&f("revoke",{section:o})}function v(){try{return JSON.parse(localStorage.getItem(e.key))}catch(t){return console.error(t),localStorage.removeItem(e.key),{}}}function k(){let t=i.fromEntries(i.entries(localStorage)),o=i.fromEntries(a.cookie.split("; ").map(e=>e.split("="))),{consentTime:n,...l}=v()||e.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[n,s]of i.entries(l)){if(s)continue;let l=i.keys(e[`${n}Cookies`]||{});for(let e of(l.filter(e=>e.endsWith("*")).map(e=>{i.keys({...o,...t}).map(t=>{t.startsWith(e.slice(0,-1))&&l.push(t)})}),l)){if(o[e]){let t=`${e}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;a.cookie=t,a.cookie=`${t}domain=${location.hostname};`,a.cookie=`${t}domain=.${location.hostname};`,f("delete",{cookie:e})}t[e]&&(localStorage.removeItem(e),f("delete",{localStorage:e}))}}}function y(o){let a=void 0===o,n={consentTime:+new Date};e.sections.forEach(e=>{if("essential"===e)return;let t=c.querySelector(`[data-s=${e}]`),i=a?t.checked:o;n[e]=i,a||(t.checked=o)}),h(b(),n),g(n),localStorage.setItem(e.key,JSON.stringify(n)),f("save",{data:n}),k(),E(),t.open&&t.close(),m(!1)}function E(){a.querySelectorAll("script[data-consent]").forEach(e=>{if(!b()[e.dataset.consent])return;let t=a.createElement("script");for(let{name:o,value:a}of e.attributes)o.startsWith("data-")||"type"===o||t.setAttribute(o,a);t.setAttribute("type",e.dataset.type||"text/javascript"),e.src||(t.textContent=e.textContent),e.parentNode.replaceChild(t,e),f("inject",{el:e,...e.id&&{id:e.id}}),e.src&&""!==e.textContent.trim()&&t.addEventListener("load",()=>{let o=a.createElement("script");o.textContent=e.textContent,e.id&&(o.id=e.id+"-after"),t.insertAdjacentElement("afterend",o),f("inject",{el:o,parent:e,...o.id&&{id:o.id}})})})}export default{create:function(l={}){if(o)return o;e={...s,...l};let p=n.bmInvalidate=()=>{f("invalidate",{data:b()}),h({}),y(!1),g({}),localStorage.removeItem(e.key),m(!0),e.force&&t.showModal()},T=n.bmUpdate=()=>{f("update",{data:b()}),m(!0),u()};return g(v()||{}),c.className="biscuitman",c.innerHTML=`
${e.title}

${e.message}

${e.settingsTitle}

${e.message}

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

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

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

${s?i.entries(s).map(([e,t])=>`
${e}
${t}
`).join(""):`
${e.noCookies}
`}
`}).join("")}
`.replaceAll("{link}",`${e.linkText}`),c.onclick=e=>{let o=e.target.dataset.id;if(o)switch(f("button",{id:o}),o){case"more":e.target.remove();break;case"accept":y(!0);break;case"close":t.close();break;case"settings":u();break;case"save":y();break;case"reject":y(!1)}},t=c.querySelector("dialog"),e.dialogPolyfill&&!t.close&&function(t){function o(){a.documentElement.classList.add("bm-dialog-polyfill"),n.dialogPolyfill.registerDialog(t)}if(n.dialogPolyfill)o();else{let t=a.createElement("script");t.onload=o,t.src=e.dialogPolyfill,a.head.appendChild(t)}}(t),t.onclose=()=>f("close"),e.force&&(t.oncancel=e=>e.preventDefault(),t.onkeydown=e=>"Escape"===e.key?e.preventDefault():null),c.querySelectorAll("[data-s]").forEach(e=>e.addEventListener("change",t=>{e.parentElement.classList.toggle("checked",t.target.checked)})),a.body.appendChild(c),n.addEventListener("resize",d),function(){let t=Intl.DateTimeFormat().resolvedOptions().timeZone,o=/^(GMT|UTC)$/.test(t)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(t);e.acceptNonEU&&!o&&(y(!0),m(!1))}(),k(),n[e.global].consentTime?(m(!1),E()):(m(!0),e.force&&u()),o={consent:$,invalidate:p,update:T,on:(e,t)=>{let a=`bm:${e}`;return r[a]||(r[a]=[]),r[a].push(t),o},off:(e,t)=>{let o=`bm:${e}`;r[o]&&(r[o]=r[o].filter(e=>e!==t))}}}};;if(typeof BMCSS==='undefined'){let c=document.createElement('style');c.id='BMCSS';c.textContent=`/*! biscuitman.js 0.5.5 */.biscuitman{--ui:0,0,0;--tx:#444;--bg:#fff;--c:#105d89;background:var(--bg);box-sizing:border-box;z-index:3;width:100%;padding:20px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;display:none;position:fixed;bottom:0;box-shadow:0 -2px 10px #00000029}.bm-show .biscuitman{display:block}.biscuitman *{box-sizing:border-box;color:var(--tx);margin:0;padding:0;font-family:inherit;font-size:16px;line-height:1.4em}.biscuitman:has([open]){transform:translateY(100%)}.biscuitman article{padding:0;position:relative}@media (min-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(--tx);margin:10px 0;font-size:13px}@media (min-width:575px){.biscuitman article p{font-size:14px}}.biscuitman button{background:var(--bg);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(--bg)!important}.biscuitman button[data-id=close]{color:rgba(var(--ui),.5);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 (min-width:576px){.biscuitman nav{flex-direction:row-reverse;gap:10px;width:100%;display:flex}.biscuitman nav button{flex-grow:1;margin-bottom:0}}@media (max-width:575px){.biscuitman nav{flex-direction:column;flex-grow:1;display:flex}}.biscuitman dialog{background:var(--bg);border:0;width:100%;max-width:100%;height:100%;max-height:100%}@media (min-width:576px){.biscuitman dialog{border-radius:10px;width:90vw;max-width:860px;max-height:80vh;margin:auto;box-shadow:0 0 8px #0000004d}}@media (min-width:576px) and (min-height:1134px){.biscuitman dialog{max-height:950px}}.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{padding-bottom:8px;position:relative}.biscuitman .bm-dialog>b:after{content:"";background:linear-gradient(180deg,var(--bg)20%,#fff0);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(--bg)20%,#fff0);pointer-events:none;width:100%;height:25px;position:absolute;top:-24px;left:0}.biscuitman .bm-sections{scrollbar-color:rgba(var(--ui),.2)var(--bg);flex-shrink:1;height:100%;padding:15px 0;position:relative;overflow-y:scroll}@media (min-width:576px){.biscuitman .bm-sections{margin-right:-18px;padding-right:4px}}.biscuitman .bm-sections>p{padding-right:30px;font-size:13px;line-height:18px}@media (min-width:576px){.biscuitman .bm-sections>p{font-size:14px}}.biscuitman .bm-sections>p span{font-size:inherit;padding-bottom:5px;display:inline-block}.biscuitman .bm-sections>p [data-id=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 rgba(var(--ui),.2);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 rgba(var(--ui),.4);border-top-color:#0000;border-left-color:#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(--tx);font-size:14px}.biscuitman summary>*{display:inline-flex}.biscuitman summary::marker{display:none}.biscuitman summary::-webkit-details-marker{display:none}.biscuitman dl{background:rgba(var(--ui),.08);margin:10px;padding:10px;display:flex}.biscuitman dl dt,.biscuitman dl dd{color:var(--tx);font-size:12px}.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);background-color:rgba(var(--ui),.3);border-radius:var(--height);margin-top:-2px;display:block;position:absolute;top:50%;right:20px;transform:translateY(-50%);font-size:20px!important}.biscuitman label:before{content:"";background:var(--bg);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.checked{background-color:var(--c)}.biscuitman label.checked:before{left:auto;right:0}.biscuitman label:has(:focus-visible){outline:auto highlight}.biscuitman label.disabled.checked{opacity:.5}.biscuitman label input{opacity:0}.bm-dialog-polyfill .biscuitman dialog{position:fixed;top:50%;transform:translateY(-50%)}`;document.head.appendChild(c)} \ No newline at end of file diff --git a/dist/esm/biscuitman.withcss.mjs b/dist/esm/biscuitman.withcss.mjs index f6873a3..c777de6 100644 --- a/dist/esm/biscuitman.withcss.mjs +++ b/dist/esm/biscuitman.withcss.mjs @@ -1,4 +1,4 @@ -/*! biscuitman.js 0.5.4 */ +/*! biscuitman.js 0.5.5 */ const { document: d, window: w, Object: O } = globalThis; const h = d.documentElement; const defaults = { @@ -65,10 +65,7 @@ function render() {

${options[`${section}Message`]}

- ${cookies ? O.entries(cookies).map((param)=>{ - let [k, v] = param; - return `
${k}
${v}
`; - }).join('') : `
${options.noCookies}
`} + ${cookies ? O.entries(cookies).map(([k, v])=>`
${k}
${v}
`).join('') : `
${options.noCookies}
`} `; }).join('')} @@ -295,8 +292,7 @@ function handleNonEUConsent() { } } let instance; -function create() { - let config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; +function create(config = {}) { if (instance) return instance; options = { ...defaults, @@ -304,10 +300,10 @@ function create() { }; function initialize() { setConsents(loadConsents() || {}); - // Optional Non-EU auto-consent - handleNonEUConsent(); // Render UI render(); + // Optional Non-EU auto-consent + handleNonEUConsent(); // Wipe matching cookies/localStorages without consent clearStorages(); // Consent logic @@ -366,7 +362,7 @@ export default { if (typeof BMCSS === 'undefined') { let css=document.createElement('style'); css.id = 'BMCSS'; - css.textContent=`/*! biscuitman.js 0.5.4 */ + css.textContent=`/*! biscuitman.js 0.5.5 */ .biscuitman { --ui: 0, 0, 0; --tx: #444; diff --git a/package.json b/package.json index d981066..3db1949 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "biscuitman", - "version": "0.5.4", + "version": "0.5.5", "description": "Super lightweight open-source privacy consent manager for your website ", "browser": "biscuitman.js", "keywords": [ diff --git a/src/biscuitman.js b/src/biscuitman.js index 384df23..45ba56a 100644 --- a/src/biscuitman.js +++ b/src/biscuitman.js @@ -293,6 +293,9 @@ setConsents(loadConsents() || {}) + // Render UI + render() + // Optional Non-EU auto-consent const tz = Intl.DateTimeFormat().resolvedOptions().timeZone const isEuropeTimezone = /^(GMT|UTC)$/.test(tz) || /(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(tz) @@ -301,9 +304,6 @@ displayUI(false) } - // Render UI - render() - // Wipe matching cookies/localStorages without consent clearStorages() diff --git a/src/biscuitman.mjs b/src/biscuitman.mjs index 6961057..d0f57a2 100644 --- a/src/biscuitman.mjs +++ b/src/biscuitman.mjs @@ -312,12 +312,12 @@ function create(config = {}) { function initialize() { setConsents(loadConsents() || {}) - // Optional Non-EU auto-consent - handleNonEUConsent() - // Render UI render() + // Optional Non-EU auto-consent + handleNonEUConsent() + // Wipe matching cookies/localStorages without consent clearStorages()