-
Notifications
You must be signed in to change notification settings - Fork 0
/
purecookieconsent.min.js
7 lines (7 loc) · 2.48 KB
/
purecookieconsent.min.js
1
2
3
4
5
6
7
/* ========================================================================
* Pure Cookie Consent JS: purecookieconsent.js v1.0.1
* https://romulobrasil.com
* Copyright (c) 2023 Rômulo Brasil
* ========================================================================
*/
const PureCookieConsent={default:{txt:"Este site usa cookies para garantir a melhor experi\xeancia do usu\xe1rio. Ao continuar navegando no site, voc\xea concorda com o uso de cookies.",btnTxt:"Eu concordo",styleBar:{position:"fixed",left:"0",right:"0",bottom:"15px","margin-left":"auto","margin-tighe":"auto","font-family":'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"'},styleCon:{display:"flex","justify-content":"space-between","align-items":"center","background-color":"#FFF",color:"#5c6d7e",padding:"1.5em","box-shadow":"0px 0px 64px rgb(0 0 0 / 10%)","border-radius":"5px"},styleTxt:{margin:"0",color:"#5c6d7e","font-size":"14px","font-weight":"300"},styleBtn:{border:"0",padding:"0 46px","background-color":"#5c6d7e",color:"#fff",cursor:"pointer","font-size":"15px","font-weight":"500","line-height":"40px","letter-spacing":"1px","border-radius":"0.25rem"}},show(){let e=!!arguments[0]&&arguments[0];if(null!=this.getCookie("cookieConsent")){let t=document.createElement("div"),o=document.createElement("div"),i=document.createElement("p"),n=document.createElement("button");t.id="pureCookieConsent",t.classList.add("pure-cookie-consent"),o.classList.add("container","pure-cookie-consent_box"),i.classList.add("pure-cookie-consent__txt"),n.classList.add("pure-cookie-consent__btn"),i.innerHTML=e.txt?e.txt:this.default.txt,n.innerHTML=e.btnTxt?e.btnTxt:this.default.btnTxt,o.append(i,n),t.appendChild(o),void 0===e.style&&(this.css(t,this.default.styleBar),this.css(o,this.default.styleCon),this.css(i,this.default.styleTxt),this.css(n,this.default.styleBtn)),n.addEventListener("click",()=>{this.setCookie("cookieConsent",!0,365),this.hideCookieConsentBar()}),document.body.appendChild(t)}},hideCookieConsentBar(){cookieConsentBar.style.display="none"},setCookie(e,t,o){var i="";if(o){var n=new Date;n.setTime(n.getTime()+864e5*o),i="; expires="+n.toUTCString()}document.cookie=e+"="+t+i+"; path=/"},getCookie(e){for(var t=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var n=o[i];" "==n.charAt(0);)n=n.substring(1,n.length);if(0==n.indexOf(t))return;return n.substring(t.length,n.length)}return null},css(e,t){for(let o in t)e.style[o]=t[o]}};