UNPKG

accept-cookie-popup

Version:
2 lines 6.64 kB
/*! For license information please see accept-cookie-popup.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("AcceptCookiePopup",[],t):"object"==typeof exports?exports.AcceptCookiePopup=t():e.AcceptCookiePopup=t()}(self,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>i});const o={siteName:window.location.host,linkCookiePage:"/cookie-policy/",showDelay:2e3,showAnimationDuration:800,hideMonthCount:2,cookieName:"cookiePopup",cookieValue:"allreadyShowed",popupName:"cookie-accept-popup",customCSS:!1,btnText:"Хорошо",closeTitle:"Закрыть",messageText:(e,t)=>`<p>Продолжая использовать сайт ${e}, Вы соглашаетесь на использование файлов COOKIE. Более подробная информация на странице <a href="${t}" target="_blank" rel="nofollow noreferer noopener">Политика обработки файлов cookie</a></p>`};class i{#e=null;#t=null;#o=null;#i;#p=null;#a=null;#n=null;#s=null;#l=null;#r=null;#c=null;#u=null;#h=null;#m=null;#d=null;constructor(e={}){this.#e=e,navigator.cookieEnabled&&(this.#i=this.#k("cookieName",o.cookieName),this.#p=this.#k("cookieValue",o.cookieValue),this.#n=this.#k("siteName",o.siteName),this.#s=this.#k("linkCookiePage",o.linkCookiePage),this.#a=this.#k("popupName",o.popupName),this.#o=this.#k("showDelay",o.showDelay),this.#d=this.#k("showAnimationDuration",o.showAnimationDuration),this.#r=this.#k("hideMonthCount",o.hideMonthCount),this.#c=this.#k("customCSS",o.customCSS),this.#u=this.#k("btnText",o.btnText),this.#h=this.#k("closeTitle",o.closeTitle),this.#m=this.#k("messageText",o.messageText),this.#g(),this.#b())}#b(){this.#x()&&this.#x()===this.#p||!window.isCookiePopupInit&&this.#w()}#k(e,t){return Object.prototype.hasOwnProperty.call(this.#e,e)?this.#e[e]:t}#g(){this.#l=`\n <template id="${this.#a}">\n <div class="${this.#a}">\n <button class="${this.#a}__cross ${this.#a}__close" type="button" aria-label="${this.#h}" title="${this.#h}"></button>\n <div class="${this.#a}__container">\n <div>\n ${this.#m(this.#n.toLocaleUpperCase(),this.#s)}\n </div>\n <button class="${this.#a}__btn ${this.#a}__close ${this.#a}__accept" type="button">${this.#u}</button>\n </div>\n </div>\n </template>\n `}#C(){return`.${this.#a}{box-sizing:border-box;display:none;position:fixed;left:0;bottom:0;width:100%;z-index:10200;color:var(--cookie-popup-color,#231f1e);background-color:var(--cookie-popup-bg,#fff);padding:30px 20px 20px;font-size:16px;line-height:1.3}.${this.#a}--show{display:block;-webkit-animation-name:show-popup;animation-name:show-popup;-webkit-animation-duration:${this.#d}ms;animation-duration:${this.#d}ms;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}.${this.#a}__cross{position:absolute;top:10px;right:20px;padding:0;border-radius:2px;border:none;width:18px;height:18px;background-color:transparent;background-image:url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.41425 7.00025L13.7072 1.70725C14.0982 1.31625 14.0982 0.68425 13.7072 0.29325C13.3162 -0.09775 12.6842 -0.09775 12.2933 0.29325L7.00025 5.58625L1.70725 0.29325C1.31625 -0.09775 0.68425 -0.09775 0.29325 0.29325C-0.09775 0.68425 -0.09775 1.31625 0.29325 1.70725L5.58625 7.00025L0.29325 12.2933C-0.09775 12.6842 -0.09775 13.3162 0.29325 13.7072C0.48825 13.9022 0.74425 14.0002 1.00025 14.0002C1.25625 14.0002 1.51225 13.9022 1.70725 13.7072L7.00025 8.41425L12.2933 13.7072C12.4882 13.9022 12.7443 14.0002 13.0002 14.0002C13.2562 14.0002 13.5122 13.9022 13.7072 13.7072C14.0982 13.3162 14.0982 12.6842 13.7072 12.2933L8.41425 7.00025Z' fill='%23231f1e'/%3E%3C/svg%3E%0A");background-repeat:no-repeat;background-position:center;background-size:contain;opacity:1;cursor:pointer}.${this.#a}__container{max-width:690px;margin:0 auto}.${this.#a}__container>div{margin:4px 0 18px;flex-grow: 1}.${this.#a}__container a{color:inherit;-webkit-text-decoration:1px solid underline;text-decoration:1px solid underline}.${this.#a}__btn{display:inline-flex;padding:14px 40px;border:none;border-radius:0;color:#fff;background-color:#231f1e;cursor:pointer;text-transform:uppercase}@media (any-hover:hover){.${this.#a}__cross{transition:opacity .2s ease-in-out}.${this.#a}__cross:hover{opacity:.6}.${this.#a}__container a{transition:text-decoration-color .2s ease-in-out}.${this.#a}__container a:hover{text-decoration-color:transparent}.${this.#a}__btn{transition:opacity .2s ease-in-out}.${this.#a}__btn:hover{opacity:.8}}@-webkit-keyframes show-popup{0%{-webkit-transform:translateY(100%);transform:translateY(100%);opacity:0}100%{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}}@keyframes show-popup{0%{-webkit-transform:translateY(100%);transform:translateY(100%);opacity:0}100%{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}}@media (min-width:768px){.${this.#a}__container{display:flex;align-items:center}.${this.#a}__container>div{margin:0 30px 0 0}}@media (min-width:1200px){.${this.#a}{padding:40px 0}.${this.#a}__cross{top:20px;right:max(40px,(100% - 1110px) / 2);width:24px;height:24px}.${this.#a}__container{max-width:990px}}`}#f(){const e=document.createElement("STYLE");e.textContent=this.#C(),document.head.appendChild(e)}#N(){document.body.insertAdjacentHTML("beforeend",this.#l)}#_(){document.querySelector(`#${this.#a}`).remove()}#w(){this.#c||this.#f(),this.#N();const e=document.querySelector(`#${this.#a}`).content.querySelector(`.${this.#a}`).cloneNode(!0);this.#t=e,this.#$(),document.body.appendChild(e),this.#_(),i.#y()}#$(){this.#t.querySelectorAll(`.${this.#a}__close`).forEach((e=>{e.addEventListener("click",this.#T)})),setTimeout((()=>this.#t.classList.add(`${this.#a}--show`)),this.#o)}#v(){this.#t.remove(),this.#t=null}#T=e=>{e.preventDefault(),e.currentTarget.classList.contains(`${this.#a}__accept`)&&this.#S(),this.#v()};#S=()=>{const e=new Date;e.setMonth(e.getMonth()+this.#r),document.cookie=this.#i+"="+this.#p+"; path=/; expires="+e.toUTCString()};#x=()=>{const e=document.cookie.match(new RegExp("(?:^|; )"+this.#i.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0};static#y(){window.isCookiePopupInit=!0}}return t.default})()));