diff --git a/.gitignore b/.gitignore index 3c3629e..f06235c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +dist diff --git a/dist/browser/cookie-cn.css b/dist/browser/cookie-cn.css deleted file mode 100644 index c15a84e..0000000 --- a/dist/browser/cookie-cn.css +++ /dev/null @@ -1,438 +0,0 @@ -@charset "UTF-8"; -:root { - --cs-primary-color: var(); -} - -/* Distance par rapport à la gauche de la fenêtre */ -/* Distance par rapport à la droite de la fenêtre */ -/* Distance par rapport au bas de la fenêtre */ -/* Position gauche de base des cookies */ -/* Position droite de base des cookies */ -#cn-wrapper { - /* Buttons styles start */ - /* Button styles end */ -} -#cn-wrapper * { - box-sizing: border-box; -} -#cn-wrapper *::before { - display: none; -} -#cn-wrapper button { - display: inline-block; - padding: 0.2rem 0.5rem; - border: 0; - margin: 0; - appearance: none; - background: #d6d6d6; - color: #000; - cursor: pointer; - font-family: "Barlow", sans-serif; - font-size: 1rem; - line-height: 1; - text-align: center; - text-decoration: none; - transition: background 250ms ease-in-out, transform 150ms ease; -} -#cn-wrapper button:hover, -#cn-wrapper button:focus { - background: #bdbdbd; - /* prettier-ignore */ - color: #000; -} -#cn-wrapper button:focus { - outline: 1px solid; - /* prettier-ignore */ - outline-color: #000; - outline-offset: -4px; -} -#cn-wrapper button:active { - transform: scale(0.99); -} - -/** 5.0.4 */ -/* FENETRE D'ACCUEIL */ -/* Title settings */ -/* Text settings */ -/* Button settings */ -/* Title settings */ -/* Text settings */ -/* Switch Buttons */ -/* Cookies list settings */ -/* Size */ -#cn-wrapper .cn-nav #cn-settings-banner, #cn-wrapper .cn-nav #cn-accept-banner, #cn-wrapper .cn-nav #cn-deny-banner, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal { - display: flex; - height: 3rem; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 0; - background-color: #d6d6d6; - color: #000; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-nav #cn-settings-banner:hover, #cn-wrapper .cn-nav #cn-accept-banner:hover, #cn-wrapper .cn-nav #cn-deny-banner:hover, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal:hover, #cn-wrapper .cn-nav #cn-settings-banner:focus, #cn-wrapper .cn-nav #cn-accept-banner:focus, #cn-wrapper .cn-nav #cn-deny-banner:focus, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal:focus { - background-color: #bdbdbd; - /* prettier-ignore */ - color: #000; -} -#cn-wrapper .cn-nav #cn-settings-banner:focus, #cn-wrapper .cn-nav #cn-accept-banner:focus, #cn-wrapper .cn-nav #cn-deny-banner:focus, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal:focus { - /* prettier-ignore */ - outline-color: #000; -} - -.cn-modal-bg { - position: fixed; - z-index: 1030; - top: 0; - left: 0; - width: 100vw; - height: 100dvh; - background-color: rgba(0, 0, 0, 0.6); - cursor: pointer; - opacity: 0; - transition: 0.3s; - visibility: hidden; -} -.cn-modal-bg-active { - cursor: default; -} - -.cn-open .cn-modal-bg { - opacity: 1; - visibility: visible; -} - -.cn-disabled { - pointer-events: none; -} - -#cn-wrapper { - position: fixed; - z-index: 1050; - top: 0; - left: 0; - width: 100vw; - height: 100dvh; - pointer-events: none; -} -#cn-wrapper #cn-cookie-btn { - position: fixed; - right: auto; - bottom: 0.5rem; - left: 0.5rem; - width: 2.4rem; - height: 2.4rem; - padding: 0.3rem; - border-radius: 100%; - background-color: #fff; - box-shadow: 0 0.1rem 1rem rgba(0, 0, 0, 0.35); - cursor: pointer; - pointer-events: auto; -} -@media (min-width: 535px) { - #cn-wrapper #cn-cookie-btn { - right: auto; - bottom: -1.5rem; - left: -1.5rem; - width: 3rem; - height: 3rem; - padding: 0.5rem; - transition: all 1s 6s; - } - #cn-wrapper #cn-cookie-btn:hover, #cn-wrapper #cn-cookie-btn:focus { - right: auto; - bottom: 0.5rem; - left: 0.5rem; - transition: all 1s; - } -} -#cn-wrapper #cn-cookie-btn:focus { - outline-color: #d1842a; - outline-offset: 0.1rem; - outline-width: 0.2rem; -} -#cn-wrapper #cn-cookie-btn-icon path { - fill: #dc9c52; -} -#cn-wrapper #cn-cookie-btn-icon circle { - fill: #dc9c52; -} -#cn-wrapper #cn-banner { - position: absolute; - z-index: 1050; - top: 0; - bottom: 0; - left: 0; - display: flex; - width: 100vw; - max-height: 100dvh; - flex-direction: column; - align-items: center; - justify-content: flex-end; - padding: 0; - border-radius: 0; - margin: auto; - margin-bottom: 0; - background-color: #fff; - box-shadow: 0 0.1rem 1rem rgba(0, 0, 0, 0.35); - line-height: initial; - opacity: 0; - pointer-events: none; - transition: 0.3s; - user-select: none; - visibility: hidden; -} -#cn-wrapper #cn-banner .cn-modal-top-line { - align-self: end; -} -#cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal { - width: 4rem; - height: 3rem; - border-bottom-left-radius: 0.5rem; -} -@media (min-width: 535px) { - #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal { - border-top-right-radius: 0.5rem; - } -} -#cn-wrapper #cn-banner > * { - pointer-events: all; -} -@media (min-width: 535px) { - #cn-wrapper #cn-banner { - right: auto; - bottom: calc(0.5rem + 60px); - left: 0; - width: 30rem; - max-height: 26rem; - border-radius: 0.5rem; - } - #cn-wrapper #cn-banner.cn-modal-page { - max-height: 38rem; - } -} -#cn-wrapper #cn-li-template { - display: none; -} -#cn-wrapper .d-none { - display: none !important; -} -#cn-wrapper .cn-content { - flex-grow: 1; - padding: 0.8rem; - overflow-y: auto; -} -@media (min-width: 535px) { - #cn-wrapper .cn-content { - flex-grow: 0; - } -} -#cn-wrapper .cn-content .cn-switch { - position: relative; - display: inline-block; - overflow: hidden; - width: 4.2rem; - height: 2.4rem; - box-sizing: content-box; - cursor: pointer; -} -#cn-wrapper .cn-content .cn-switch:focus, #cn-wrapper .cn-content .cn-switch:focus-visible { - border-width: 0.1rem; - border-style: solid; - border-color: #b7b7b7; -} -#cn-wrapper .cn-content .cn-switch input { - display: none; -} -#cn-wrapper .cn-content .cn-switch input + span { - position: absolute; - border-radius: 2rem; - background: #b7b7b7; - inset: 0; -} -#cn-wrapper .cn-content .cn-switch input + span::before { - position: absolute; - top: 50%; - left: 0.21rem; - display: inline-block; - width: 1.8rem; - height: 1.8rem; - border-radius: 50%; - background: #fff; - content: ""; - transform: translateY(-50%); - transition: all 0.5s; -} -#cn-wrapper .cn-content .cn-switch input:indeterminate + span { - background: #b7b7b7; -} -#cn-wrapper .cn-content .cn-switch input:indeterminate + span::before { - left: 1.08rem; -} -#cn-wrapper .cn-content .cn-switch input:checked + span { - background: #b7b7b7; -} -#cn-wrapper .cn-content .cn-switch input:checked + span::before { - left: 2.16rem; -} -#cn-wrapper .cn-content .cn-banner-content { - display: flex; - min-height: 100%; - flex-direction: column; - color: #707070; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -@media (min-width: 535px) { - #cn-wrapper .cn-content .cn-banner-content { - flex-flow: row wrap; - align-items: center; - } - #cn-wrapper .cn-content .cn-banner-content .cn-banner-img { - width: 33%; - } - #cn-wrapper .cn-content .cn-banner-content .cn-banner-text { - width: 66%; - } -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-img { - text-align: center; -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-img img { - width: 90%; - object-fit: contain; -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-text .cn-banner-title { - color: #dc9c52; - font-family: "Satisfy", sans-serif; - font-size: 28px; - font-weight: bold; - line-height: inherit; - text-align: left; -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-text .cn-banner-para-p { - margin: 6px 0; - text-align: justify; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper { - position: relative; - display: flex; - overflow: auto; - flex-direction: column; - align-items: center; - /* stylelint-disable-next-line no-descending-specificity */ -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper ul { - display: flex; - flex-direction: column; - padding: 0; - margin: 0; - list-style: none; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper .cn-cookie-wrapper { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - padding: 20px; - border: 1px solid #e4e4e4; - border-radius: 20px; - margin: 10px 0; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper span { - color: #dc9c52; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper a { - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper label { - color: #dc9c52; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-name { - color: #dc9c52; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos { - display: flex; - width: 100%; - flex: 1; - flex-direction: column; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos span:first-of-type { - font-size: calc(16px * 1.25); - font-weight: bold; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos .cn-cookie-description { - color: #707070; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos a { - width: fit-content; -} -#cn-wrapper .cn-nav { - display: flex; - overflow: hidden; - width: 100%; - height: 6rem; - flex-shrink: 0; - flex-wrap: wrap; - align-items: center; - border-top: 1px solid #6d6d6d; -} -#cn-wrapper .cn-nav #cn-deny-banner { - width: 50%; -} -#cn-wrapper .cn-nav #cn-accept-banner { - width: 50%; - border-right: 1px solid #6d6d6d; - border-left: 1px solid #6d6d6d; -} -#cn-wrapper .cn-nav #cn-settings-banner { - width: 100%; - border-top: 1px solid #6d6d6d; -} -@media (min-width: 535px) { - #cn-wrapper .cn-nav { - height: 3rem; - flex-wrap: initial; - border-bottom-left-radius: 0.5rem; - border-bottom-right-radius: 0.5rem; - } - #cn-wrapper .cn-nav #cn-deny-banner { - width: 33.33%; - } - #cn-wrapper .cn-nav #cn-accept-banner { - width: 33.33%; - } - #cn-wrapper .cn-nav #cn-settings-banner { - width: 33.33%; - border-top: initial; - } -} - -.cn-open { - overflow: hidden !important; -} -.cn-open #cn-wrapper #cn-banner { - opacity: 1; - visibility: visible; -} -@media (min-width: 535px) { - .cn-open #cn-wrapper #cn-banner { - right: auto; - left: 0.5rem; - } -} -@media (min-width: 535px) { - .cn-open #cn-wrapper #cn-cookie-btn { - right: auto; - bottom: 0.5rem; - left: 0.5rem; - transition: all 1s; - } -} \ No newline at end of file diff --git a/dist/browser/cookie-cn.js b/dist/browser/cookie-cn.js deleted file mode 100644 index b507a10..0000000 --- a/dist/browser/cookie-cn.js +++ /dev/null @@ -1 +0,0 @@ -!function(){class e{constructor(e){this.browserCookieName="cn-init",this.cookieTimeLife=6,this.cookieExpirationName="_expiration",this.cookiePolicies={sameSite:o.lax,secure:""},this.config=e;let i=this.readCookiesExpirationDate();i||(i=new Date,i.setMonth(i.getMonth()+this.cookieTimeLife)),this.cookieExpirationDate=i;const n=document.createElement("div");n.classList.add("cn-modal-bg"),document.body.append(n),this.modalBg=n;const s=document.querySelector("div#cn-wrapper"),a=document.querySelector("button#cn-cookie-btn"),r=document.querySelector("button#cn-close-modal"),c=document.querySelectorAll(".cn-cookie-link"),l=document.querySelector("div#cn-banner"),d=document.querySelector("div.cn-banner-content"),h=document.querySelector("div.cn-modal-container"),u=document.querySelector("button#cn-accept-banner"),k=document.querySelector("button#cn-deny-banner"),C=document.querySelector("button#cn-settings-banner"),m=document.querySelector("ul#cn-modal-list"),b=document.querySelector("div.cn-modal-wrapper"),p=document.querySelector("div#cn-li-template");if(!s)throw new Error("Cannot find div#cn-wrapper");if(!a)throw new Error("Cannot find 'button#cn-cookie-btn' element");if(!r)throw new Error("Cannot find 'button#cn-close-modal' element");if(!l)throw new Error("Cannot find 'div#cn-banner' element");if(!d)throw new Error("Cannot find 'div.cn-banner-content' element");if(!h)throw new Error("Cannot find 'div.cn-modal-container' element");if(!u)throw new Error("Cannot find 'button#cn-accept-banner' element");if(!k)throw new Error("Cannot find 'button#cn-deny-banner' element");if(!C)throw new Error("Cannot find 'button.cn-settings-banner' element");if(!m)throw new Error("Cannot find 'ul#cn-modal-list' element");if(!b)throw new Error("Cannot find 'div.cn-modal-wrapper' element");if(!p)throw new Error("Cannot find 'div#cn-li-template' element");this.cookieShowModalBtn=a,this.cookieCloseModalBtn=r,this.cookieLinkShowCustomizeModalList=c,this.cookieContainer=s,this.bannerContainer=l,this.bannerContent=d,this.cookiesUnorderedList=m,this.modalWrapper=b,this.modalContainer=h,this.acceptAllBtn=u,this.denyAllBtn=k,this.customizeBtn=C,this.template=p;const g=this.template.cloneNode(!0);this.template.remove(),this.template=g,this.restrictCloseModal=!0,this.addEventPrevent(this.modalBg,"click",this.closeCookieModal),this.addEventPrevent(this.cookieCloseModalBtn,"click",this.closeCookieModal),this.addEventPrevent(this.acceptAllBtn,"click",this.acceptAllCookies),this.addEventPrevent(this.denyAllBtn,"click",this.denyAllCookies),this.addEventPrevent(this.customizeBtn,"click",this.switchToModalPageOrClose),this.addEventPrevent(this.cookieShowModalBtn,"click",this.toggleCookieModal),this.cookieLinkShowCustomizeModalList.forEach((e=>{this.addEventPrevent(e,"click",this.openCookieModalToCookiePage),this.addEventKbdValidate(e,this.openCookieModalToCookiePage)})),this.cookiesMatchesConfig()&&!this.cookiesOlderThan(new Date)||(this.resetBrowserCookie(),this.openCookieModalToBannerPage()),this.updateRestrictCloseModal(),Object.entries(this.getCookieStatusList()).forEach((([e,o])=>{o!==t.wait?this.config[e]&&(o!==t.true?null!=this.config[e].fallback&&this.config[e].fallback():this.config[e].script()):this.openCookieModalToBannerPage()}))}updateRestrictCloseModal(){this.restrictCloseModal=!!Object.values(this.getCookieStatusList()).includes(t.wait),this.restrictCloseModal?this.cookieCloseModalBtn.classList.add("d-none"):this.cookieCloseModalBtn.classList.remove("d-none"),this.restrictCloseModal?this.modalBg.classList.add("cn-modal-bg-active"):this.modalBg.classList.remove("cn-modal-bg-active")}readCookiesExpirationDate(){var e;const t=(null!==(e=this.getBrowserCookieValue())&&void 0!==e?e:"").split(",").find((e=>e.startsWith(this.cookieExpirationName)));if(!t)return null;try{const e=Number.parseInt(t.replace(`${this.cookieExpirationName}=`,""));return isNaN(e)?null:new Date(e)}catch(e){return null}}cookiesOlderThan(e){return this.cookieExpirationDate.getTime()this.acceptCookie(e))),this.closeCookieModal()}acceptCookie(e){const o=this.getCookie(e);this.setCookieStatus(e,t.true,o);const i=document.getElementById(`${e}-switch`),n=null==i?void 0:i.querySelector("input");i&&n&&(n.checked=!0,i.ariaChecked="true")}denyAllCookies(){Object.keys(this.config).forEach((e=>this.denyCookie(e))),this.closeCookieModal()}denyCookie(e){const o=this.getCookie(e);this.setCookieStatus(e,t.false,o);const i=document.getElementById(`${e}-switch`),n=null==i?void 0:i.querySelector("input");i&&n&&(n.checked=!1,i.ariaChecked="false")}denyAllWaitingCookies(){Object.entries(this.getCookieStatusList()).forEach((([e,o])=>{o!==t.wait||this.setBrowserCookieStatus(e,t.false)})),this.updateRestrictCloseModal()}getCookie(e){var t;const o=null===(t=Object.entries(this.config).find((t=>t[0]===e)))||void 0===t?void 0:t[1];if(void 0===o)throw new Error(`Cookie options ${e} not found in list`);return o}getCookieStatusList(){const e=this.getBrowserCookieValue(),t={};return void 0===e||e.split(",").filter((e=>!e.startsWith(this.cookieExpirationName))).forEach((e=>{const o=e.split("=");t[o[0]]=o[1]})),t}containsCookieStatus(e){const t=this.getCookieStatusList();return void 0!==Object.keys(t).find((t=>t===e))}getCookieStatus(e){const t=this.getCookieStatusList(),o=Object.keys(t).find((t=>t===e));if(void 0===o)throw new Error(`Cookie options ${e} not found in list`);return t[o]}setCookieStatus(e,o,i){o!==t.true?o!==t.false?this.setBrowserCookieStatus(e,t.wait):this.removeCookieStatus(e,i):this.addCookieStatus(e,i)}addCookieStatus(e,o){o.script&&o.script(),this.setBrowserCookieStatus(e,t.true)}removeCookieStatus(e,o){const i=document.getElementById(e);i&&i.remove(),o.fallback&&o.fallback(),this.setBrowserCookieStatus(e,t.false)}setBrowserCookieStatus(e,t){const o=this.getCookieStatusList();this.deleteBrowserCookie(),o[e]=t,this.saveBrowserCookie(o),this.updateRestrictCloseModal()}hasBrowserCookie(){return Boolean(this.getBrowserCookieValue())}getBrowserCookieValue(){const e=document.cookie.match(new RegExp("(?:^|; )"+this.browserCookieName.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}saveBrowserCookie(e){const t=new Date,o=Object.entries(e).map((([e,t])=>`${e}=${t}`));this.cookieExpirationDate=new Date(t.setMonth(t.getMonth()+this.cookieTimeLife)),o.push(`${this.cookieExpirationName}=${this.cookieExpirationDate.getTime()}`),document.cookie=`${this.browserCookieName}=${o.join(",")};path=/${location.hostname?`;domain=${location.hostname}`:""};expires=${this.cookieExpirationDate.toUTCString()};${this.getCookiePoliciesAsString()}`}deleteBrowserCookie(){this.hasBrowserCookie()&&(document.cookie=`${this.browserCookieName}=;path=/${location.hostname?`;domain=.${location.hostname}`:""};expires=Thu, 01 Jan 1970 00:00:01 GMT;`,document.cookie=`${this.browserCookieName}=;path=/${location.hostname?`;domain=${location.hostname}`:""};expires=Thu, 01 Jan 1970 00:00:01 GMT;`)}getCookiePoliciesAsString(){return Object.entries(this.cookiePolicies).map((([e,t])=>`${e}=${t}`)).join(";")}resetBrowserCookie(){const e={};Object.entries(this.config).forEach((([o])=>e[o]=t.wait)),this.saveBrowserCookie(e)}addEvent(e,t,o){return e.addEventListener(t,o.bind(this),!1)}addEventPrevent(e,t,o){return e.addEventListener(t,(e=>{e.preventDefault(),o.call(this,e)}),!1)}addEventKbdValidate(e,t){return this.addEvent(e,"keydown",(e=>{const o=e;" "!=o.key&&"Space"!=o.code&&32!=o.keyCode&&"Enter"!=o.key&&"Enter"!=o.code&&13!=o.keyCode||(t.call(this,o),e.preventDefault())}))}toggleCookieModal(){document.body.classList.contains("cn-open")?this.closeCookieModal():this.openCookieModalToBannerPage()}openCookieModalToBannerPage(){this.openCookieModalToCookiePage(),this.toggleCookieModalPages()}openCookieModalToCookiePage(){document.body.classList.add("cn-open"),this.resetCookieModal(),this.bannerContent.classList.add("d-none"),this.modalContainer.classList.remove("d-none"),this.bannerContainer.classList.add("cn-modal-page"),this.modalWrapper.scrollTop=0,this.setupCookieModalList(),this.setTabIndex()}closeCookieModal(){if(this.updateRestrictCloseModal(),this.restrictCloseModal)throw new Error("You need to accept or refuse all cookies");document.body.classList.remove("cn-open"),this.isOnBannerPage()||(this.bannerContent.classList.toggle("d-none"),this.modalContainer.classList.toggle("d-none"),this.bannerContainer.classList.remove("cn-modal-page")),this.unsetTabIndex(),this.setupCookieModalList()}setTabIndex(){document.documentElement.setAttribute("tabindex","-1"),setTimeout((()=>{const e='a[href], button, [role="button"], input, embed, object, iframe, textarea, select, details, [tabindex]:not([tabindex="-1"])';[...document.body.querySelectorAll(e)].filter((e=>!e.hasAttribute("disabled")&&!e.getAttribute("aria-hidden")&&!this.cookieContainer.contains(e))).forEach((e=>{e.setAttribute("tabindex","-1"),e.classList.add("cn-disabled")})),[...this.cookieContainer.querySelectorAll(e)].filter((e=>!(e.hasAttribute("disabled")||e.getAttribute("aria-hidden")||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)||this.cookieContainer.contains(e)))).forEach((e=>{e.setAttribute("tabindex","0"),e.classList.remove("cn-disabled")})),this.cookieShowModalBtn.setAttribute("tabindex","-1")}),500)}unsetTabIndex(){document.documentElement.setAttribute("tabindex","0"),setTimeout((()=>{document.body.querySelectorAll(".cn-disabled").forEach((e=>{e.setAttribute("tabindex","0"),e.classList.remove("cn-disabled")})),this.cookieShowModalBtn.setAttribute("tabindex","0")}),500)}resetCookieModal(){if(this.bannerContent.classList.remove("d-none"),this.modalContainer.classList.add("d-none"),this.bannerContainer.classList.remove("cn-modal-page"),!this.customizeBtn.dataset.openModal)throw new Error("Cannot find attribut data-open-modal");this.customizeBtn.innerHTML=this.customizeBtn.dataset.openModal}setupCookieModalList(){this.cookiesUnorderedList.innerHTML="",Object.entries(this.config).forEach((([e,o])=>{const i=document.createElement("li"),n=this.template.children.item(0);if(null===n)throw new Error("Cannot find child item");i.append(n.cloneNode(!0));const s=i.querySelector("span.cn-cookie-name"),a=i.querySelector("span.cn-cookie-description"),r=i.querySelector(".cn-cookie-link"),c=i.querySelector(".cn-switch"),l=i.querySelector(".cn-switch > input");l.indeterminate=!0,l.checked=!1,s.textContent=o.name,a.id=`${e}-desc`,a.textContent=o.description,r.textContent=o.labelLink,r.setAttribute("href",o.link),c.id=`${e}-switch`,c.name=e,c.dataset.name=e,c.setAttribute("aria-labelledby",`${e}-desc`),c.setAttribute("aria-describedby",`${e}-desc`);const d=e=>{const t=this.getCookieStatus(e);this.setCookieStatus(e,this.invertCookieStatus(t),o)};this.addEvent(l,"click",(()=>d(e))),this.addEventKbdValidate(c,(()=>l.click())),this.cookiesUnorderedList.append(i),this.hasBrowserCookie()&&Object.entries(this.getCookieStatusList()).forEach((([o,i])=>{if(o===e)switch(i){case t.true:l.indeterminate=!1,l.checked=!0;break;case t.false:l.indeterminate=!1,l.checked=!1;break;case t.wait:l.indeterminate=!0,l.checked=!1}}))}))}switchToModalPageOrClose(){this.isOnBannerPage()?this.toggleCookieModalPages():this.closeCookieModal()}toggleCookieModalPages(){this.bannerContent.classList.toggle("d-none"),this.modalContainer.classList.toggle("d-none"),this.bannerContainer.classList.toggle("cn-modal-page"),this.isOnBannerPage()||(this.bannerContainer.classList.add("cn-modal-page"),this.denyAllWaitingCookies()),this.setTabIndex(),this.setupCookieModalList(),this.togglePersonalizeBtn()}togglePersonalizeBtn(){const e=this.customizeBtn.dataset;this.modalWrapper.scrollTop=0,this.bannerContent.classList.contains("d-none")?(this.customizeBtn.innerHTML=e.openModal,this.customizeBtn.title=e.openModal):(this.customizeBtn.innerHTML=e.closeModal,this.customizeBtn.title=e.closeModal)}isOnBannerPage(){return this.modalContainer.classList.contains("d-none")}invertCookieStatus(e){switch(e){case t.true:case t.wait:return t.false;case t.false:return t.true;default:throw new Error(`Un handled cookie status ${e}`)}}}var t,o;!function(e){e.true="true",e.false="false",e.wait="wait"}(t||(t={})),function(e){e.lax="lax",e.strict="strict",e.none="none"}(o||(o={}));const i=window.CookieNotice;e.noConflict=function(t=!1){return t&&window.CookieNotice===e&&(window.CookieNotice=i),e},window.CookieNotice=e.noConflict()}(); diff --git a/dist/browser/typings/ts/export/global.d.ts b/dist/browser/typings/ts/export/global.d.ts deleted file mode 100644 index c61571c..0000000 --- a/dist/browser/typings/ts/export/global.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import "./../../scss/themes/standard.scss"; -import CookieNotice from "./../index"; -declare global { - interface Window { - CookieNotice: typeof CookieNotice; - } -} diff --git a/dist/browser/typings/ts/index.d.ts b/dist/browser/typings/ts/index.d.ts deleted file mode 100644 index d74b5da..0000000 --- a/dist/browser/typings/ts/index.d.ts +++ /dev/null @@ -1,267 +0,0 @@ -/** 5.0.4 */ -export default class CookieNotice { - browserCookieName: string; - /** Cookie life time */ - cookieTimeLife: number; - /** The index on which store the expiration date */ - cookieExpirationName: string; - /** Cookie policies for each functionality */ - cookiePolicies: CookiePolicy; - /** Cookie expiration date as specified in the cookie itself */ - cookieExpirationDate: Date; - config: Record; - modalBg: HTMLDivElement; - cookieContainer: HTMLDivElement; - bannerContainer: HTMLDivElement; - modalContainer: HTMLDivElement; - cookieShowModalBtn: HTMLButtonElement; - cookieCloseModalBtn: HTMLButtonElement; - bannerContent: HTMLDivElement; - acceptAllBtn: HTMLButtonElement; - denyAllBtn: HTMLButtonElement; - customizeBtn: HTMLButtonElement; - cookiesUnorderedList: HTMLUListElement; - cookieLinkShowCustomizeModalList: NodeListOf; - modalWrapper: HTMLDivElement; - template: HTMLDivElement; - restrictCloseModal: boolean; - static noConflict: (deep?: boolean) => typeof CookieNotice; - constructor(config: Record); - /** - * Update restrict for closing cookie modal - */ - updateRestrictCloseModal(): void; - /** - * Get cookies expiration date or null if not defined alread - */ - readCookiesExpirationDate(): Date | null; - /** - * Check if the cookies date are older than a specified date - - * @param date The limit date for cookies - */ - cookiesOlderThan(date: Date): boolean; - /** - * Check if the actual cookie matches the config - */ - cookiesMatchesConfig(): boolean; - /** - * Accept a all cookies - */ - acceptAllCookies(): void; - /** - * Accept a specific cookie - */ - acceptCookie(cookieName: string): void; - /** - * Deny a all cookies - */ - denyAllCookies(): void; - /** - * Deny a specific cookie - */ - denyCookie(cookieName: string): void; - /** - * Deny all waiting cookies - */ - denyAllWaitingCookies(): void; - /** - * Get a specific cookie config - */ - getCookie(cookieName: string): CookieOptions; - /** - * Fetch the cookie status list - * - * @returns the cookie status list - */ - getCookieStatusList(): CookieStatusList; - /** - * Check has cookie status - * - * @param key - * @param value - */ - containsCookieStatus(key: string): boolean; - /** - * Get a cookie status - * - * @param key - * @returns - */ - getCookieStatus(key: string): CookieStatus; - /** - * Set the cookie value - * - * @param cookieName - * @param status - * @param cookieOption - */ - setCookieStatus(cookieName: string, status: CookieStatus, cookieOption: CookieOptions): void; - /** - * Add a specific cookie and - * change his status to true - * - * @param cookieName - * @param cookieOption - */ - addCookieStatus(cookieName: string, cookieOption: CookieOptions): void; - /** - * Remove a specific cookie and - * change his status to false - * - * @param cookieName - * @param cookieOption - */ - removeCookieStatus(cookieName: string, cookieOption: CookieOptions): void; - /** - * Change the status of a cookie - * - * @param cookieName - * @param status - */ - setBrowserCookieStatus(cookieName: string, status: CookieStatus): void; - /** - * Has CN cokie setup ? - * @returns true if the cookie is setup - */ - hasBrowserCookie(): boolean; - /** - * Get the Ldcweb cookie - * - * @returns A string like analytics=true,youtube=true or undefined - */ - getBrowserCookieValue(): string | undefined; - /** - * Save cookie content on web browser - * - * @param list - */ - saveBrowserCookie(statusList: CookieStatusList): void; - /** - * Set an older expire parameter to a specific cookie - */ - deleteBrowserCookie(): void; - getCookiePoliciesAsString(): string; - /** - * Reset Ldc Web CN cookie - */ - resetBrowserCookie(): void; - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEvent(element: HTMLElement, evnt: string, funct: (e: Event) => void): void; - /** - * Add event on a specific element and prevent default - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEventPrevent(element: HTMLElement, evnt: string, funct: (e: Event) => void): void; - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEventKbdValidate(element: HTMLElement, funct: (e: Event) => void): void; - /** - * Show or hide Cookie modal - * @returns - */ - toggleCookieModal(): void; - /** - * Open the cookies modal to the banner page - */ - openCookieModalToBannerPage(): void; - /** - * Open the cookies modal to the cookies page - */ - openCookieModalToCookiePage(): void; - /** - * Hide the cookies modal - */ - closeCookieModal(): void; - /** - * Setup tab indexes on visible elements - */ - setTabIndex(): void; - /** - * Undo setup tab indexes on visible elements - */ - unsetTabIndex(): void; - /** - * Reset the modal view state - */ - resetCookieModal(): void; - /** - * Set the cookies list in the modal - */ - setupCookieModalList(): void; - switchToModalPageOrClose(): void; - /** - * Toggle Cookie modal pages - */ - toggleCookieModalPages(): void; - /** - * Toggle customize btn - */ - togglePersonalizeBtn(): void; - /** - * Get the actual page: banner or modal (with cookie choices) - */ - isOnBannerPage(): boolean; - /** - * Invert cookie status - * - * @param status - * @returns Inverted cookie status, `wait` will give `false`. - */ - private invertCookieStatus; -} -declare enum CookieStatus { - true = "true", - false = "false", - wait = "wait" -} -type CookieStatusList = Record; -type CookiePolicy = { - sameSite: CookiePolicySameSite; - secure: string; -}; -declare enum CookiePolicySameSite { - lax = "lax", - strict = "strict", - none = "none" -} -export type CookieOptions = { - name: string; - description: string; - link: string; - labelLink: string; - cookies: string[]; - /** - * Fonction qui sert à initialiser la fonctionnalité - * conduisant à la génération du cookie - * @return void - */ - script: () => void; - /** - * Fonction qui sert à informer l'utilisateur - * sur chaque élèment que le cookie - * associé à la fonctionnalité - * est désactivé et propose un lien sur - * cookie notice pour l'activer - * @return void - */ - fallback: () => void | null; -}; -export {}; diff --git a/dist/esm/ts/export/global.js b/dist/esm/ts/export/global.js deleted file mode 100644 index 3b1753a..0000000 --- a/dist/esm/ts/export/global.js +++ /dev/null @@ -1,11 +0,0 @@ -import "./../../scss/themes/standard.scss"; -import CookieNotice from "./../index"; -const // Map over CookieNotice in case of overwrite -_CookieNotice = window.CookieNotice; -CookieNotice.noConflict = function (deep = false) { - if (deep && window.CookieNotice === CookieNotice) { - window.CookieNotice = _CookieNotice; - } - return CookieNotice; -}; -window.CookieNotice = CookieNotice.noConflict(); diff --git a/dist/esm/ts/index.js b/dist/esm/ts/index.js deleted file mode 100644 index b70e543..0000000 --- a/dist/esm/ts/index.js +++ /dev/null @@ -1,697 +0,0 @@ -/** 5.0.4 */ -export default class CookieNotice { - constructor(config) { - this.browserCookieName = "cn-init"; - /** Cookie life time */ - this.cookieTimeLife = 6; - /** The index on which store the expiration date */ - this.cookieExpirationName = "_expiration"; - /** Cookie policies for each functionality */ - this.cookiePolicies = { - sameSite: CookiePolicySameSite.lax, - secure: "", - }; - // * Setup Config - this.config = config; - // * Setup cookie expiration date - let cookieExpirationDate = this.readCookiesExpirationDate(); - if (!cookieExpirationDate) { - cookieExpirationDate = new Date(); - cookieExpirationDate.setMonth(cookieExpirationDate.getMonth() + this.cookieTimeLife); - } - this.cookieExpirationDate = cookieExpirationDate; - // * Inject DOM modal BG - const modalBg = document.createElement("div"); - modalBg.classList.add("cn-modal-bg"); - document.body.append(modalBg); - this.modalBg = modalBg; - // * Setup Dom Elements - const cookieContainer = document.querySelector("div#cn-wrapper"), cookieShowModalBtn = document.querySelector("button#cn-cookie-btn"), cookieCloseModalBtn = document.querySelector("button#cn-close-modal"), cookieLinkShowCustomizeModalPageList = document.querySelectorAll(".cn-cookie-link"), bannerContainer = document.querySelector("div#cn-banner"), bannerContent = document.querySelector("div.cn-banner-content"), modalContainer = document.querySelector("div.cn-modal-container"), acceptAllBtn = document.querySelector("button#cn-accept-banner"), denyAllBtn = document.querySelector("button#cn-deny-banner"), customizeBtn = document.querySelector("button#cn-settings-banner"), cookiesUnorderedList = document.querySelector("ul#cn-modal-list"), modalWrapper = document.querySelector("div.cn-modal-wrapper"), template = document.querySelector("div#cn-li-template"); - if (!cookieContainer) { - throw new Error("Cannot find div#cn-wrapper"); - } - if (!cookieShowModalBtn) { - throw new Error("Cannot find 'button#cn-cookie-btn' element"); - } - if (!cookieCloseModalBtn) { - throw new Error("Cannot find 'button#cn-close-modal' element"); - } - if (!bannerContainer) { - throw new Error("Cannot find 'div#cn-banner' element"); - } - if (!bannerContent) { - throw new Error("Cannot find 'div.cn-banner-content' element"); - } - if (!modalContainer) { - throw new Error("Cannot find 'div.cn-modal-container' element"); - } - if (!acceptAllBtn) { - throw new Error("Cannot find 'button#cn-accept-banner' element"); - } - if (!denyAllBtn) { - throw new Error("Cannot find 'button#cn-deny-banner' element"); - } - if (!customizeBtn) { - throw new Error("Cannot find 'button.cn-settings-banner' element"); - } - if (!cookiesUnorderedList) { - throw new Error("Cannot find 'ul#cn-modal-list' element"); - } - if (!modalWrapper) { - throw new Error("Cannot find 'div.cn-modal-wrapper' element"); - } - if (!template) { - throw new Error("Cannot find 'div#cn-li-template' element"); - } - this.cookieShowModalBtn = cookieShowModalBtn; - this.cookieCloseModalBtn = cookieCloseModalBtn; - this.cookieLinkShowCustomizeModalList = - cookieLinkShowCustomizeModalPageList; - this.cookieContainer = cookieContainer; - this.bannerContainer = bannerContainer; - this.bannerContent = bannerContent; - this.cookiesUnorderedList = cookiesUnorderedList; - this.modalWrapper = modalWrapper; - this.modalContainer = modalContainer; - this.acceptAllBtn = acceptAllBtn; - this.denyAllBtn = denyAllBtn; - this.customizeBtn = customizeBtn; - this.template = template; - const memoryTemplate = this.template.cloneNode(true); - this.template.remove(); - this.template = memoryTemplate; - this.restrictCloseModal = true; - // * Setup Events - this.addEventPrevent(this.modalBg, "click", this.closeCookieModal); - this.addEventPrevent(this.cookieCloseModalBtn, "click", this.closeCookieModal); - this.addEventPrevent(this.acceptAllBtn, "click", this.acceptAllCookies); - this.addEventPrevent(this.denyAllBtn, "click", this.denyAllCookies); - this.addEventPrevent(this.customizeBtn, "click", this.switchToModalPageOrClose); - this.addEventPrevent(this.cookieShowModalBtn, "click", this.toggleCookieModal); - this.cookieLinkShowCustomizeModalList.forEach((cookieLink) => { - this.addEventPrevent(cookieLink, "click", this.openCookieModalToCookiePage); - this.addEventKbdValidate(cookieLink, this.openCookieModalToCookiePage); - }); - // * Setup CN Cookie - if (!this.cookiesMatchesConfig() || this.cookiesOlderThan(new Date())) { - // * Setup Browser Cookie if none. - this.resetBrowserCookie(); - this.openCookieModalToBannerPage(); - } - this.updateRestrictCloseModal(); - // * Cookie should have been created from here. - Object.entries(this.getCookieStatusList()).forEach(([cookieName, cookieStatus]) => { - if (cookieStatus === CookieStatus.wait) { - // * Open modal if any cookie config is not set. - this.openCookieModalToBannerPage(); - return; - } - if (!this.config[cookieName]) { - // * Ignore missing config - return; - } - if (cookieStatus === CookieStatus.true) { - // * Exec script part for accepted cookie. - this.config[cookieName].script(); - return; - } - if (this.config[cookieName].fallback != null) { - // * Exec fallback part for accepted cookie if provided. - this.config[cookieName].fallback(); - } - }); - } - // COOKIES - /** - * Update restrict for closing cookie modal - */ - updateRestrictCloseModal() { - this.restrictCloseModal = (Object.values(this.getCookieStatusList()).includes(CookieStatus.wait)) ? true : false; - (this.restrictCloseModal) ? this.cookieCloseModalBtn.classList.add("d-none") : this.cookieCloseModalBtn.classList.remove("d-none"); - (this.restrictCloseModal) ? this.modalBg.classList.add("cn-modal-bg-active") : this.modalBg.classList.remove("cn-modal-bg-active"); - } - /** - * Get cookies expiration date or null if not defined alread - */ - readCookiesExpirationDate() { - var _a; - const cookies = (_a = this.getBrowserCookieValue()) !== null && _a !== void 0 ? _a : "", expirationDateString = cookies.split(",").find((cookieString) => cookieString.startsWith(this.cookieExpirationName)); - if (!expirationDateString) { - return null; - } - try { - const epochExpiration = Number.parseInt(expirationDateString.replace(`${this.cookieExpirationName}=`, "")); - if (isNaN(epochExpiration)) { - return null; - } - return new Date(epochExpiration); - } - catch (e) { - return null; - } - } - /** - * Check if the cookies date are older than a specified date - - * @param date The limit date for cookies - */ - cookiesOlderThan(date) { - return this.cookieExpirationDate.getTime() < date.getTime(); - } - /** - * Check if the actual cookie matches the config - */ - cookiesMatchesConfig() { - const cookies = this.getCookieStatusList(); - return Object.keys(cookies).length === Object.keys(this.config).length; - } - /** - * Accept a all cookies - */ - acceptAllCookies() { - Object.keys(this.config).forEach((cookieName) => this.acceptCookie(cookieName)); - this.closeCookieModal(); - } - /** - * Accept a specific cookie - */ - acceptCookie(cookieName) { - const cookieOptions = this.getCookie(cookieName); - this.setCookieStatus(cookieName, CookieStatus.true, cookieOptions); - const cnSwitch = document.getElementById(`${cookieName}-switch`); - const cnSwitchInput = cnSwitch === null || cnSwitch === void 0 ? void 0 : cnSwitch.querySelector("input"); - if (!cnSwitch || !cnSwitchInput) { - return; - } - cnSwitchInput.checked = true; - cnSwitch.ariaChecked = "true"; - } - /** - * Deny a all cookies - */ - denyAllCookies() { - Object.keys(this.config).forEach((cookieName) => this.denyCookie(cookieName)); - this.closeCookieModal(); - } - /** - * Deny a specific cookie - */ - denyCookie(cookieName) { - const cookieOptions = this.getCookie(cookieName); - this.setCookieStatus(cookieName, CookieStatus.false, cookieOptions); - const cnSwitch = document.getElementById(`${cookieName}-switch`); - const cnSwitchInput = cnSwitch === null || cnSwitch === void 0 ? void 0 : cnSwitch.querySelector("input"); - if (!cnSwitch || !cnSwitchInput) { - return; - } - cnSwitchInput.checked = false; - cnSwitch.ariaChecked = "false"; - } - /** - * Deny all waiting cookies - */ - denyAllWaitingCookies() { - Object.entries(this.getCookieStatusList()).forEach(([cookieName, cookieStatus]) => { - if (cookieStatus === CookieStatus.wait) { - this.setBrowserCookieStatus(cookieName, CookieStatus.false); - return; - } - }); - this.updateRestrictCloseModal(); - } - /** - * Get a specific cookie config - */ - getCookie(cookieName) { - var _a; - const cookieOptions = (_a = Object.entries(this.config).find((entry) => entry[0] === cookieName)) === null || _a === void 0 ? void 0 : _a[1]; - if (cookieOptions === undefined) { - throw new Error(`Cookie options ${cookieName} not found in list`); - } - return cookieOptions; - } - /** - * Fetch the cookie status list - * - * @returns the cookie status list - */ - getCookieStatusList() { - const cookies = this.getBrowserCookieValue(), statusList = {}; - if (cookies === undefined) { - return statusList; - } - /** specificCookieString contains youtube=true like */ - cookies.split(",") - // * Ignore timestamp - .filter((specificCookieString) => !specificCookieString.startsWith(this.cookieExpirationName)) - .forEach((specificCookieString) => { - const values = specificCookieString.split("="); - statusList[values[0]] = values[1]; - }); - return statusList; - } - /** - * Check has cookie status - * - * @param key - * @param value - */ - containsCookieStatus(key) { - const statusList = this.getCookieStatusList(); - return (Object.keys(statusList).find((cookieName) => cookieName === key) !== - undefined); - } - /** - * Get a cookie status - * - * @param key - * @returns - */ - getCookieStatus(key) { - const statusList = this.getCookieStatusList(); - const cookieIndex = Object.keys(statusList).find((cookieName) => cookieName === key); - if (cookieIndex === undefined) { - throw new Error(`Cookie options ${key} not found in list`); - } - return statusList[cookieIndex]; - } - /** - * Set the cookie value - * - * @param cookieName - * @param status - * @param cookieOption - */ - setCookieStatus(cookieName, status, cookieOption) { - if (status === CookieStatus.true) { - this.addCookieStatus(cookieName, cookieOption); - return; - } - if (status === CookieStatus.false) { - this.removeCookieStatus(cookieName, cookieOption); - return; - } - this.setBrowserCookieStatus(cookieName, CookieStatus.wait); - } - /** - * Add a specific cookie and - * change his status to true - * - * @param cookieName - * @param cookieOption - */ - addCookieStatus(cookieName, cookieOption) { - if (cookieOption.script) { - cookieOption.script(); - } - this.setBrowserCookieStatus(cookieName, CookieStatus.true); - } - /** - * Remove a specific cookie and - * change his status to false - * - * @param cookieName - * @param cookieOption - */ - removeCookieStatus(cookieName, cookieOption) { - const cookieNameElement = document.getElementById(cookieName); - if (cookieNameElement) { - cookieNameElement.remove(); - } - if (cookieOption.fallback) { - cookieOption.fallback(); - } - this.setBrowserCookieStatus(cookieName, CookieStatus.false); - } - /** - * Change the status of a cookie - * - * @param cookieName - * @param status - */ - setBrowserCookieStatus(cookieName, status) { - const statusList = this.getCookieStatusList(); - // * Force refresh - this.deleteBrowserCookie(); - statusList[cookieName] = status; - this.saveBrowserCookie(statusList); - this.updateRestrictCloseModal(); - } - /** - * Has CN cokie setup ? - * @returns true if the cookie is setup - */ - hasBrowserCookie() { - return Boolean(this.getBrowserCookieValue()); - } - /** - * Get the Ldcweb cookie - * - * @returns A string like analytics=true,youtube=true or undefined - */ - getBrowserCookieValue() { - const matches = document.cookie.match(new RegExp("(?:^|; )" + - this.browserCookieName.replace(/([.$?*|{}()[\]\\/+^])/g, "\\$1") + - "=([^;]*)")); - return matches ? decodeURIComponent(matches[1]) : undefined; - } - /** - * Save cookie content on web browser - * - * @param list - */ - saveBrowserCookie(statusList) { - const date = new Date(), content = Object.entries(statusList) - .map(([cookieName, cookieStatus]) => { - return `${cookieName}=${cookieStatus}`; - }); - // * Update expiration date - this.cookieExpirationDate = new Date(date.setMonth(date.getMonth() + this.cookieTimeLife)); - // * Append expiration date - content.push(`${this.cookieExpirationName}=${this.cookieExpirationDate.getTime()}`); - document.cookie = `${this.browserCookieName}=${content.join(",")};path=/${location.hostname ? `;domain=${location.hostname}` : ""};expires=${this.cookieExpirationDate.toUTCString()};${this.getCookiePoliciesAsString()}`; - } - /** - * Set an older expire parameter to a specific cookie - */ - deleteBrowserCookie() { - if (this.hasBrowserCookie()) { - // * Suppression du cookie et de sa version precedé d'un point - document.cookie = `${this.browserCookieName}=;path=/${location.hostname ? `;domain=.${location.hostname}` : ""};expires=Thu, 01 Jan 1970 00:00:01 GMT;`; - document.cookie = `${this.browserCookieName}=;path=/${location.hostname ? `;domain=${location.hostname}` : ""};expires=Thu, 01 Jan 1970 00:00:01 GMT;`; - } - } - getCookiePoliciesAsString() { - return Object.entries(this.cookiePolicies) - .map(([policyName, policyValue]) => `${policyName}=${policyValue}`) - .join(";"); - } - /** - * Reset Ldc Web CN cookie - */ - resetBrowserCookie() { - // * Create Cookie as It does not exists. - const newCookieList = {}; - Object.entries(this.config).forEach(([cookieName]) => (newCookieList[cookieName] = CookieStatus.wait)); - this.saveBrowserCookie(newCookieList); - } - // LISTENERS - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEvent(element, evnt, funct) { - return element.addEventListener(evnt, funct.bind(this), false); - } - /** - * Add event on a specific element and prevent default - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEventPrevent(element, evnt, funct) { - return element.addEventListener(evnt, (e) => { - e.preventDefault(); - funct.call(this, e); - }, false); - } - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEventKbdValidate(element, funct) { - return this.addEvent(element, "keydown", (e) => { - const kbdEvt = e; - if (kbdEvt.key == " " || - kbdEvt.code == "Space" || - kbdEvt.keyCode == 32 || - kbdEvt.key == "Enter" || - kbdEvt.code == "Enter" || - kbdEvt.keyCode == 13) { - funct.call(this, kbdEvt); - e.preventDefault(); - } - }); - } - // COOKIE MODAL - /** - * Show or hide Cookie modal - * @returns - */ - toggleCookieModal() { - if (!document.body.classList.contains("cn-open")) { - this.openCookieModalToBannerPage(); - return; - } - this.closeCookieModal(); - } - /** - * Open the cookies modal to the banner page - */ - openCookieModalToBannerPage() { - this.openCookieModalToCookiePage(); - this.toggleCookieModalPages(); - } - /** - * Open the cookies modal to the cookies page - */ - openCookieModalToCookiePage() { - document.body.classList.add("cn-open"); - this.resetCookieModal(); - this.bannerContent.classList.add("d-none"); - this.modalContainer.classList.remove("d-none"); - this.bannerContainer.classList.add("cn-modal-page"); - // Scroll to the top of the cookies list - this.modalWrapper.scrollTop = 0; - this.setupCookieModalList(); - this.setTabIndex(); - } - /** - * Hide the cookies modal - */ - closeCookieModal() { - this.updateRestrictCloseModal(); - if (!this.restrictCloseModal) { - document.body.classList.remove("cn-open"); - if (!this.isOnBannerPage()) { - // * Make toggle page to banner on closing - this.bannerContent.classList.toggle("d-none"); - this.modalContainer.classList.toggle("d-none"); - this.bannerContainer.classList.remove("cn-modal-page"); - } - this.unsetTabIndex(); - this.setupCookieModalList(); - } - else { - throw new Error("You need to accept or refuse all cookies"); - } - } - /** - * Setup tab indexes on visible elements - */ - setTabIndex() { - // * Prevent focus html tag - document.documentElement.setAttribute("tabindex", "-1"); - setTimeout(() => { - const focusableSelector = "a[href], button, [role=\"button\"], input, embed, object, iframe, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])"; - // * Only focusable elements - [...document.body.querySelectorAll(focusableSelector)] - .filter((el) => !el.hasAttribute("disabled") && - !el.getAttribute("aria-hidden") && - !this.cookieContainer.contains(el)) - .forEach((el) => { - el.setAttribute("tabindex", "-1"); - el.classList.add("cn-disabled"); - }); - [...this.cookieContainer.querySelectorAll(focusableSelector)] - .filter((el) => !el.hasAttribute("disabled") && - !el.getAttribute("aria-hidden") && - // * Only visible elements - !!(el.offsetWidth || - el.offsetHeight || - el.getClientRects().length) && - !this.cookieContainer.contains(el)) - .forEach((el) => { - el.setAttribute("tabindex", "0"); - el.classList.remove("cn-disabled"); - }); - this.cookieShowModalBtn.setAttribute("tabindex", "-1"); - }, 500); - } - /** - * Undo setup tab indexes on visible elements - */ - unsetTabIndex() { - document.documentElement.setAttribute("tabindex", "0"); - setTimeout(() => { - document.body.querySelectorAll(".cn-disabled").forEach((el) => { - el.setAttribute("tabindex", "0"); - el.classList.remove("cn-disabled"); - }); - this.cookieShowModalBtn.setAttribute("tabindex", "0"); - }, 500); - } - /** - * Reset the modal view state - */ - resetCookieModal() { - this.bannerContent.classList.remove("d-none"); - this.modalContainer.classList.add("d-none"); - this.bannerContainer.classList.remove("cn-modal-page"); - if (!this.customizeBtn.dataset.openModal) { - throw new Error("Cannot find attribut data-open-modal"); - } - this.customizeBtn.innerHTML = this.customizeBtn.dataset.openModal; - } - /** - * Set the cookies list in the modal - */ - setupCookieModalList() { - this.cookiesUnorderedList.innerHTML = ""; - Object.entries(this.config).forEach(([cookieName, cookieConfig]) => { - const cookie = document.createElement("li"); - const childItem = this.template.children.item(0); - if (childItem === null) { - throw new Error("Cannot find child item"); - } - cookie.append(childItem.cloneNode(true)); - const name = cookie.querySelector("span.cn-cookie-name"); - const description = cookie.querySelector("span.cn-cookie-description"); - const link = cookie.querySelector(".cn-cookie-link"); - const cnSwitch = cookie.querySelector(".cn-switch"); - const cnSwitchInput = cookie.querySelector(".cn-switch > input"); - // * Undertermined state - cnSwitchInput.indeterminate = true; - cnSwitchInput.checked = false; - // * Assign cookie aside content - name.textContent = cookieConfig.name; - description.id = `${cookieName}-desc`; - description.textContent = cookieConfig.description; - link.textContent = cookieConfig.labelLink; - link.setAttribute("href", cookieConfig.link); - // * Assign cookie controls - cnSwitch.id = `${cookieName}-switch`; - cnSwitch.name = cookieName; - cnSwitch.dataset.name = cookieName; - cnSwitch.setAttribute("aria-labelledby", `${cookieName}-desc`); - cnSwitch.setAttribute("aria-describedby", `${cookieName}-desc`); - const toggleCookie = (cookieName) => { - const cookieStatus = this.getCookieStatus(cookieName); - this.setCookieStatus(cookieName, this.invertCookieStatus(cookieStatus), cookieConfig); - }; - this.addEvent(cnSwitchInput, "click", () => toggleCookie(cookieName)); - this.addEventKbdValidate(cnSwitch, () => cnSwitchInput.click()); - this.cookiesUnorderedList.append(cookie); - if (!this.hasBrowserCookie()) { - // * Ldcweb cookie is not set. - return; - } - // * Setup list status state - Object.entries(this.getCookieStatusList()).forEach(([ckName, cookieStatus]) => { - if (ckName === cookieName) { - switch (cookieStatus) { - case CookieStatus.true: - cnSwitchInput.indeterminate = false; - cnSwitchInput.checked = true; - break; - case CookieStatus.false: - cnSwitchInput.indeterminate = false; - cnSwitchInput.checked = false; - break; - case CookieStatus.wait: - cnSwitchInput.indeterminate = true; - cnSwitchInput.checked = false; - break; - } - } - }); - }); - } - switchToModalPageOrClose() { - // * Modification du comportement du bouton, même si ca n'a pas de sens. - // https://lab.s-web.fr/ldc-web/projets/ldc-web-cookie-notice/-/issues/9` - if (this.isOnBannerPage()) { - this.toggleCookieModalPages(); - return; - } - // * Pas de permutation en arrière - this.closeCookieModal(); - } - /** - * Toggle Cookie modal pages - */ - toggleCookieModalPages() { - this.bannerContent.classList.toggle("d-none"); - this.modalContainer.classList.toggle("d-none"); - this.bannerContainer.classList.toggle("cn-modal-page"); - if (!this.isOnBannerPage()) { - this.bannerContainer.classList.add("cn-modal-page"); - this.denyAllWaitingCookies(); - } - this.setTabIndex(); - this.setupCookieModalList(); - this.togglePersonalizeBtn(); - } - /** - * Toggle customize btn - */ - togglePersonalizeBtn() { - const customizeBtnBannerDataset = this.customizeBtn.dataset; - this.modalWrapper.scrollTop = 0; - if (this.bannerContent.classList.contains("d-none")) { - this.customizeBtn.innerHTML = - customizeBtnBannerDataset.openModal; - this.customizeBtn.title = customizeBtnBannerDataset.openModal; - } - else { - this.customizeBtn.innerHTML = - customizeBtnBannerDataset.closeModal; - this.customizeBtn.title = customizeBtnBannerDataset.closeModal; - } - } - /** - * Get the actual page: banner or modal (with cookie choices) - */ - isOnBannerPage() { - return this.modalContainer.classList.contains("d-none"); - } - /** - * Invert cookie status - * - * @param status - * @returns Inverted cookie status, `wait` will give `false`. - */ - invertCookieStatus(status) { - switch (status) { - case CookieStatus.true: - case CookieStatus.wait: - return CookieStatus.false; - case CookieStatus.false: - return CookieStatus.true; - default: - throw new Error(`Un handled cookie status ${status}`); - } - } -} -var CookieStatus; -(function (CookieStatus) { - CookieStatus["true"] = "true"; - CookieStatus["false"] = "false"; - CookieStatus["wait"] = "wait"; -})(CookieStatus || (CookieStatus = {})); -var CookiePolicySameSite; -(function (CookiePolicySameSite) { - CookiePolicySameSite["lax"] = "lax"; - CookiePolicySameSite["strict"] = "strict"; - CookiePolicySameSite["none"] = "none"; -})(CookiePolicySameSite || (CookiePolicySameSite = {})); diff --git a/dist/typings/ts/export/global.d.ts b/dist/typings/ts/export/global.d.ts deleted file mode 100644 index c61571c..0000000 --- a/dist/typings/ts/export/global.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import "./../../scss/themes/standard.scss"; -import CookieNotice from "./../index"; -declare global { - interface Window { - CookieNotice: typeof CookieNotice; - } -} diff --git a/dist/typings/ts/index.d.ts b/dist/typings/ts/index.d.ts deleted file mode 100644 index d74b5da..0000000 --- a/dist/typings/ts/index.d.ts +++ /dev/null @@ -1,267 +0,0 @@ -/** 5.0.4 */ -export default class CookieNotice { - browserCookieName: string; - /** Cookie life time */ - cookieTimeLife: number; - /** The index on which store the expiration date */ - cookieExpirationName: string; - /** Cookie policies for each functionality */ - cookiePolicies: CookiePolicy; - /** Cookie expiration date as specified in the cookie itself */ - cookieExpirationDate: Date; - config: Record; - modalBg: HTMLDivElement; - cookieContainer: HTMLDivElement; - bannerContainer: HTMLDivElement; - modalContainer: HTMLDivElement; - cookieShowModalBtn: HTMLButtonElement; - cookieCloseModalBtn: HTMLButtonElement; - bannerContent: HTMLDivElement; - acceptAllBtn: HTMLButtonElement; - denyAllBtn: HTMLButtonElement; - customizeBtn: HTMLButtonElement; - cookiesUnorderedList: HTMLUListElement; - cookieLinkShowCustomizeModalList: NodeListOf; - modalWrapper: HTMLDivElement; - template: HTMLDivElement; - restrictCloseModal: boolean; - static noConflict: (deep?: boolean) => typeof CookieNotice; - constructor(config: Record); - /** - * Update restrict for closing cookie modal - */ - updateRestrictCloseModal(): void; - /** - * Get cookies expiration date or null if not defined alread - */ - readCookiesExpirationDate(): Date | null; - /** - * Check if the cookies date are older than a specified date - - * @param date The limit date for cookies - */ - cookiesOlderThan(date: Date): boolean; - /** - * Check if the actual cookie matches the config - */ - cookiesMatchesConfig(): boolean; - /** - * Accept a all cookies - */ - acceptAllCookies(): void; - /** - * Accept a specific cookie - */ - acceptCookie(cookieName: string): void; - /** - * Deny a all cookies - */ - denyAllCookies(): void; - /** - * Deny a specific cookie - */ - denyCookie(cookieName: string): void; - /** - * Deny all waiting cookies - */ - denyAllWaitingCookies(): void; - /** - * Get a specific cookie config - */ - getCookie(cookieName: string): CookieOptions; - /** - * Fetch the cookie status list - * - * @returns the cookie status list - */ - getCookieStatusList(): CookieStatusList; - /** - * Check has cookie status - * - * @param key - * @param value - */ - containsCookieStatus(key: string): boolean; - /** - * Get a cookie status - * - * @param key - * @returns - */ - getCookieStatus(key: string): CookieStatus; - /** - * Set the cookie value - * - * @param cookieName - * @param status - * @param cookieOption - */ - setCookieStatus(cookieName: string, status: CookieStatus, cookieOption: CookieOptions): void; - /** - * Add a specific cookie and - * change his status to true - * - * @param cookieName - * @param cookieOption - */ - addCookieStatus(cookieName: string, cookieOption: CookieOptions): void; - /** - * Remove a specific cookie and - * change his status to false - * - * @param cookieName - * @param cookieOption - */ - removeCookieStatus(cookieName: string, cookieOption: CookieOptions): void; - /** - * Change the status of a cookie - * - * @param cookieName - * @param status - */ - setBrowserCookieStatus(cookieName: string, status: CookieStatus): void; - /** - * Has CN cokie setup ? - * @returns true if the cookie is setup - */ - hasBrowserCookie(): boolean; - /** - * Get the Ldcweb cookie - * - * @returns A string like analytics=true,youtube=true or undefined - */ - getBrowserCookieValue(): string | undefined; - /** - * Save cookie content on web browser - * - * @param list - */ - saveBrowserCookie(statusList: CookieStatusList): void; - /** - * Set an older expire parameter to a specific cookie - */ - deleteBrowserCookie(): void; - getCookiePoliciesAsString(): string; - /** - * Reset Ldc Web CN cookie - */ - resetBrowserCookie(): void; - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEvent(element: HTMLElement, evnt: string, funct: (e: Event) => void): void; - /** - * Add event on a specific element and prevent default - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEventPrevent(element: HTMLElement, evnt: string, funct: (e: Event) => void): void; - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - addEventKbdValidate(element: HTMLElement, funct: (e: Event) => void): void; - /** - * Show or hide Cookie modal - * @returns - */ - toggleCookieModal(): void; - /** - * Open the cookies modal to the banner page - */ - openCookieModalToBannerPage(): void; - /** - * Open the cookies modal to the cookies page - */ - openCookieModalToCookiePage(): void; - /** - * Hide the cookies modal - */ - closeCookieModal(): void; - /** - * Setup tab indexes on visible elements - */ - setTabIndex(): void; - /** - * Undo setup tab indexes on visible elements - */ - unsetTabIndex(): void; - /** - * Reset the modal view state - */ - resetCookieModal(): void; - /** - * Set the cookies list in the modal - */ - setupCookieModalList(): void; - switchToModalPageOrClose(): void; - /** - * Toggle Cookie modal pages - */ - toggleCookieModalPages(): void; - /** - * Toggle customize btn - */ - togglePersonalizeBtn(): void; - /** - * Get the actual page: banner or modal (with cookie choices) - */ - isOnBannerPage(): boolean; - /** - * Invert cookie status - * - * @param status - * @returns Inverted cookie status, `wait` will give `false`. - */ - private invertCookieStatus; -} -declare enum CookieStatus { - true = "true", - false = "false", - wait = "wait" -} -type CookieStatusList = Record; -type CookiePolicy = { - sameSite: CookiePolicySameSite; - secure: string; -}; -declare enum CookiePolicySameSite { - lax = "lax", - strict = "strict", - none = "none" -} -export type CookieOptions = { - name: string; - description: string; - link: string; - labelLink: string; - cookies: string[]; - /** - * Fonction qui sert à initialiser la fonctionnalité - * conduisant à la génération du cookie - * @return void - */ - script: () => void; - /** - * Fonction qui sert à informer l'utilisateur - * sur chaque élèment que le cookie - * associé à la fonctionnalité - * est désactivé et propose un lien sur - * cookie notice pour l'activer - * @return void - */ - fallback: () => void | null; -}; -export {}; diff --git a/dist/umd/css/standard.css b/dist/umd/css/standard.css deleted file mode 100644 index c15a84e..0000000 --- a/dist/umd/css/standard.css +++ /dev/null @@ -1,438 +0,0 @@ -@charset "UTF-8"; -:root { - --cs-primary-color: var(); -} - -/* Distance par rapport à la gauche de la fenêtre */ -/* Distance par rapport à la droite de la fenêtre */ -/* Distance par rapport au bas de la fenêtre */ -/* Position gauche de base des cookies */ -/* Position droite de base des cookies */ -#cn-wrapper { - /* Buttons styles start */ - /* Button styles end */ -} -#cn-wrapper * { - box-sizing: border-box; -} -#cn-wrapper *::before { - display: none; -} -#cn-wrapper button { - display: inline-block; - padding: 0.2rem 0.5rem; - border: 0; - margin: 0; - appearance: none; - background: #d6d6d6; - color: #000; - cursor: pointer; - font-family: "Barlow", sans-serif; - font-size: 1rem; - line-height: 1; - text-align: center; - text-decoration: none; - transition: background 250ms ease-in-out, transform 150ms ease; -} -#cn-wrapper button:hover, -#cn-wrapper button:focus { - background: #bdbdbd; - /* prettier-ignore */ - color: #000; -} -#cn-wrapper button:focus { - outline: 1px solid; - /* prettier-ignore */ - outline-color: #000; - outline-offset: -4px; -} -#cn-wrapper button:active { - transform: scale(0.99); -} - -/** 5.0.4 */ -/* FENETRE D'ACCUEIL */ -/* Title settings */ -/* Text settings */ -/* Button settings */ -/* Title settings */ -/* Text settings */ -/* Switch Buttons */ -/* Cookies list settings */ -/* Size */ -#cn-wrapper .cn-nav #cn-settings-banner, #cn-wrapper .cn-nav #cn-accept-banner, #cn-wrapper .cn-nav #cn-deny-banner, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal { - display: flex; - height: 3rem; - flex-direction: column; - align-items: center; - justify-content: center; - padding: 0; - background-color: #d6d6d6; - color: #000; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-nav #cn-settings-banner:hover, #cn-wrapper .cn-nav #cn-accept-banner:hover, #cn-wrapper .cn-nav #cn-deny-banner:hover, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal:hover, #cn-wrapper .cn-nav #cn-settings-banner:focus, #cn-wrapper .cn-nav #cn-accept-banner:focus, #cn-wrapper .cn-nav #cn-deny-banner:focus, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal:focus { - background-color: #bdbdbd; - /* prettier-ignore */ - color: #000; -} -#cn-wrapper .cn-nav #cn-settings-banner:focus, #cn-wrapper .cn-nav #cn-accept-banner:focus, #cn-wrapper .cn-nav #cn-deny-banner:focus, #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal:focus { - /* prettier-ignore */ - outline-color: #000; -} - -.cn-modal-bg { - position: fixed; - z-index: 1030; - top: 0; - left: 0; - width: 100vw; - height: 100dvh; - background-color: rgba(0, 0, 0, 0.6); - cursor: pointer; - opacity: 0; - transition: 0.3s; - visibility: hidden; -} -.cn-modal-bg-active { - cursor: default; -} - -.cn-open .cn-modal-bg { - opacity: 1; - visibility: visible; -} - -.cn-disabled { - pointer-events: none; -} - -#cn-wrapper { - position: fixed; - z-index: 1050; - top: 0; - left: 0; - width: 100vw; - height: 100dvh; - pointer-events: none; -} -#cn-wrapper #cn-cookie-btn { - position: fixed; - right: auto; - bottom: 0.5rem; - left: 0.5rem; - width: 2.4rem; - height: 2.4rem; - padding: 0.3rem; - border-radius: 100%; - background-color: #fff; - box-shadow: 0 0.1rem 1rem rgba(0, 0, 0, 0.35); - cursor: pointer; - pointer-events: auto; -} -@media (min-width: 535px) { - #cn-wrapper #cn-cookie-btn { - right: auto; - bottom: -1.5rem; - left: -1.5rem; - width: 3rem; - height: 3rem; - padding: 0.5rem; - transition: all 1s 6s; - } - #cn-wrapper #cn-cookie-btn:hover, #cn-wrapper #cn-cookie-btn:focus { - right: auto; - bottom: 0.5rem; - left: 0.5rem; - transition: all 1s; - } -} -#cn-wrapper #cn-cookie-btn:focus { - outline-color: #d1842a; - outline-offset: 0.1rem; - outline-width: 0.2rem; -} -#cn-wrapper #cn-cookie-btn-icon path { - fill: #dc9c52; -} -#cn-wrapper #cn-cookie-btn-icon circle { - fill: #dc9c52; -} -#cn-wrapper #cn-banner { - position: absolute; - z-index: 1050; - top: 0; - bottom: 0; - left: 0; - display: flex; - width: 100vw; - max-height: 100dvh; - flex-direction: column; - align-items: center; - justify-content: flex-end; - padding: 0; - border-radius: 0; - margin: auto; - margin-bottom: 0; - background-color: #fff; - box-shadow: 0 0.1rem 1rem rgba(0, 0, 0, 0.35); - line-height: initial; - opacity: 0; - pointer-events: none; - transition: 0.3s; - user-select: none; - visibility: hidden; -} -#cn-wrapper #cn-banner .cn-modal-top-line { - align-self: end; -} -#cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal { - width: 4rem; - height: 3rem; - border-bottom-left-radius: 0.5rem; -} -@media (min-width: 535px) { - #cn-wrapper #cn-banner .cn-modal-top-line #cn-close-modal { - border-top-right-radius: 0.5rem; - } -} -#cn-wrapper #cn-banner > * { - pointer-events: all; -} -@media (min-width: 535px) { - #cn-wrapper #cn-banner { - right: auto; - bottom: calc(0.5rem + 60px); - left: 0; - width: 30rem; - max-height: 26rem; - border-radius: 0.5rem; - } - #cn-wrapper #cn-banner.cn-modal-page { - max-height: 38rem; - } -} -#cn-wrapper #cn-li-template { - display: none; -} -#cn-wrapper .d-none { - display: none !important; -} -#cn-wrapper .cn-content { - flex-grow: 1; - padding: 0.8rem; - overflow-y: auto; -} -@media (min-width: 535px) { - #cn-wrapper .cn-content { - flex-grow: 0; - } -} -#cn-wrapper .cn-content .cn-switch { - position: relative; - display: inline-block; - overflow: hidden; - width: 4.2rem; - height: 2.4rem; - box-sizing: content-box; - cursor: pointer; -} -#cn-wrapper .cn-content .cn-switch:focus, #cn-wrapper .cn-content .cn-switch:focus-visible { - border-width: 0.1rem; - border-style: solid; - border-color: #b7b7b7; -} -#cn-wrapper .cn-content .cn-switch input { - display: none; -} -#cn-wrapper .cn-content .cn-switch input + span { - position: absolute; - border-radius: 2rem; - background: #b7b7b7; - inset: 0; -} -#cn-wrapper .cn-content .cn-switch input + span::before { - position: absolute; - top: 50%; - left: 0.21rem; - display: inline-block; - width: 1.8rem; - height: 1.8rem; - border-radius: 50%; - background: #fff; - content: ""; - transform: translateY(-50%); - transition: all 0.5s; -} -#cn-wrapper .cn-content .cn-switch input:indeterminate + span { - background: #b7b7b7; -} -#cn-wrapper .cn-content .cn-switch input:indeterminate + span::before { - left: 1.08rem; -} -#cn-wrapper .cn-content .cn-switch input:checked + span { - background: #b7b7b7; -} -#cn-wrapper .cn-content .cn-switch input:checked + span::before { - left: 2.16rem; -} -#cn-wrapper .cn-content .cn-banner-content { - display: flex; - min-height: 100%; - flex-direction: column; - color: #707070; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -@media (min-width: 535px) { - #cn-wrapper .cn-content .cn-banner-content { - flex-flow: row wrap; - align-items: center; - } - #cn-wrapper .cn-content .cn-banner-content .cn-banner-img { - width: 33%; - } - #cn-wrapper .cn-content .cn-banner-content .cn-banner-text { - width: 66%; - } -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-img { - text-align: center; -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-img img { - width: 90%; - object-fit: contain; -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-text .cn-banner-title { - color: #dc9c52; - font-family: "Satisfy", sans-serif; - font-size: 28px; - font-weight: bold; - line-height: inherit; - text-align: left; -} -#cn-wrapper .cn-content .cn-banner-content .cn-banner-text .cn-banner-para-p { - margin: 6px 0; - text-align: justify; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper { - position: relative; - display: flex; - overflow: auto; - flex-direction: column; - align-items: center; - /* stylelint-disable-next-line no-descending-specificity */ -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper ul { - display: flex; - flex-direction: column; - padding: 0; - margin: 0; - list-style: none; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper .cn-cookie-wrapper { - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - padding: 20px; - border: 1px solid #e4e4e4; - border-radius: 20px; - margin: 10px 0; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper span { - color: #dc9c52; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper a { - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-content .cn-modal-container .cn-modal-wrapper label { - color: #dc9c52; - font-family: "Barlow", sans-serif; - font-size: 16px; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-name { - color: #dc9c52; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos { - display: flex; - width: 100%; - flex: 1; - flex-direction: column; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos span:first-of-type { - font-size: calc(16px * 1.25); - font-weight: bold; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos .cn-cookie-description { - color: #707070; -} -#cn-wrapper .cn-content .cn-modal-container .cn-cookie-infos a { - width: fit-content; -} -#cn-wrapper .cn-nav { - display: flex; - overflow: hidden; - width: 100%; - height: 6rem; - flex-shrink: 0; - flex-wrap: wrap; - align-items: center; - border-top: 1px solid #6d6d6d; -} -#cn-wrapper .cn-nav #cn-deny-banner { - width: 50%; -} -#cn-wrapper .cn-nav #cn-accept-banner { - width: 50%; - border-right: 1px solid #6d6d6d; - border-left: 1px solid #6d6d6d; -} -#cn-wrapper .cn-nav #cn-settings-banner { - width: 100%; - border-top: 1px solid #6d6d6d; -} -@media (min-width: 535px) { - #cn-wrapper .cn-nav { - height: 3rem; - flex-wrap: initial; - border-bottom-left-radius: 0.5rem; - border-bottom-right-radius: 0.5rem; - } - #cn-wrapper .cn-nav #cn-deny-banner { - width: 33.33%; - } - #cn-wrapper .cn-nav #cn-accept-banner { - width: 33.33%; - } - #cn-wrapper .cn-nav #cn-settings-banner { - width: 33.33%; - border-top: initial; - } -} - -.cn-open { - overflow: hidden !important; -} -.cn-open #cn-wrapper #cn-banner { - opacity: 1; - visibility: visible; -} -@media (min-width: 535px) { - .cn-open #cn-wrapper #cn-banner { - right: auto; - left: 0.5rem; - } -} -@media (min-width: 535px) { - .cn-open #cn-wrapper #cn-cookie-btn { - right: auto; - bottom: 0.5rem; - left: 0.5rem; - transition: all 1s; - } -} \ No newline at end of file diff --git a/dist/umd/main.js b/dist/umd/main.js deleted file mode 100644 index e12f731..0000000 --- a/dist/umd/main.js +++ /dev/null @@ -1,1032 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["CookieNotice"] = factory(); - else - root["CookieNotice"] = factory(); -})(this, function() { -return /******/ (function() { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/ts/index.ts": -/*!*************************!*\ - !*** ./src/ts/index.ts ***! - \*************************/ -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": function() { return /* binding */ CookieNotice; } -/* harmony export */ }); -function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } -function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } -function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -/** 5.0.4 */ -var CookieNotice = /*#__PURE__*/function () { - /** Cookie expiration date as specified in the cookie itself */ - - function CookieNotice(config) { - var _this = this; - _classCallCheck(this, CookieNotice); - _defineProperty(this, "browserCookieName", "cn-init"); - /** Cookie life time */ - _defineProperty(this, "cookieTimeLife", 6); - /** The index on which store the expiration date */ - _defineProperty(this, "cookieExpirationName", "_expiration"); - /** Cookie policies for each functionality */ - _defineProperty(this, "cookiePolicies", { - sameSite: CookiePolicySameSite.lax, - secure: "" - }); - // * Setup Config - this.config = config; - - // * Setup cookie expiration date - var cookieExpirationDate = this.readCookiesExpirationDate(); - if (!cookieExpirationDate) { - cookieExpirationDate = new Date(); - cookieExpirationDate.setMonth(cookieExpirationDate.getMonth() + this.cookieTimeLife); - } - this.cookieExpirationDate = cookieExpirationDate; - - // * Inject DOM modal BG - var modalBg = document.createElement("div"); - modalBg.classList.add("cn-modal-bg"); - document.body.append(modalBg); - this.modalBg = modalBg; - - // * Setup Dom Elements - var cookieContainer = document.querySelector("div#cn-wrapper"), - cookieShowModalBtn = document.querySelector("button#cn-cookie-btn"), - cookieCloseModalBtn = document.querySelector("button#cn-close-modal"), - cookieLinkShowCustomizeModalPageList = document.querySelectorAll(".cn-cookie-link"), - bannerContainer = document.querySelector("div#cn-banner"), - bannerContent = document.querySelector("div.cn-banner-content"), - modalContainer = document.querySelector("div.cn-modal-container"), - acceptAllBtn = document.querySelector("button#cn-accept-banner"), - denyAllBtn = document.querySelector("button#cn-deny-banner"), - customizeBtn = document.querySelector("button#cn-settings-banner"), - cookiesUnorderedList = document.querySelector("ul#cn-modal-list"), - modalWrapper = document.querySelector("div.cn-modal-wrapper"), - template = document.querySelector("div#cn-li-template"); - if (!cookieContainer) { - throw new Error("Cannot find div#cn-wrapper"); - } - if (!cookieShowModalBtn) { - throw new Error("Cannot find 'button#cn-cookie-btn' element"); - } - if (!cookieCloseModalBtn) { - throw new Error("Cannot find 'button#cn-close-modal' element"); - } - if (!bannerContainer) { - throw new Error("Cannot find 'div#cn-banner' element"); - } - if (!bannerContent) { - throw new Error("Cannot find 'div.cn-banner-content' element"); - } - if (!modalContainer) { - throw new Error("Cannot find 'div.cn-modal-container' element"); - } - if (!acceptAllBtn) { - throw new Error("Cannot find 'button#cn-accept-banner' element"); - } - if (!denyAllBtn) { - throw new Error("Cannot find 'button#cn-deny-banner' element"); - } - if (!customizeBtn) { - throw new Error("Cannot find 'button.cn-settings-banner' element"); - } - if (!cookiesUnorderedList) { - throw new Error("Cannot find 'ul#cn-modal-list' element"); - } - if (!modalWrapper) { - throw new Error("Cannot find 'div.cn-modal-wrapper' element"); - } - if (!template) { - throw new Error("Cannot find 'div#cn-li-template' element"); - } - this.cookieShowModalBtn = cookieShowModalBtn; - this.cookieCloseModalBtn = cookieCloseModalBtn; - this.cookieLinkShowCustomizeModalList = cookieLinkShowCustomizeModalPageList; - this.cookieContainer = cookieContainer; - this.bannerContainer = bannerContainer; - this.bannerContent = bannerContent; - this.cookiesUnorderedList = cookiesUnorderedList; - this.modalWrapper = modalWrapper; - this.modalContainer = modalContainer; - this.acceptAllBtn = acceptAllBtn; - this.denyAllBtn = denyAllBtn; - this.customizeBtn = customizeBtn; - this.template = template; - var memoryTemplate = this.template.cloneNode(true); - this.template.remove(); - this.template = memoryTemplate; - this.restrictCloseModal = true; - - // * Setup Events - this.addEventPrevent(this.modalBg, "click", this.closeCookieModal); - this.addEventPrevent(this.cookieCloseModalBtn, "click", this.closeCookieModal); - this.addEventPrevent(this.acceptAllBtn, "click", this.acceptAllCookies); - this.addEventPrevent(this.denyAllBtn, "click", this.denyAllCookies); - this.addEventPrevent(this.customizeBtn, "click", this.switchToModalPageOrClose); - this.addEventPrevent(this.cookieShowModalBtn, "click", this.toggleCookieModal); - this.cookieLinkShowCustomizeModalList.forEach(function (cookieLink) { - _this.addEventPrevent(cookieLink, "click", _this.openCookieModalToCookiePage); - _this.addEventKbdValidate(cookieLink, _this.openCookieModalToCookiePage); - }); - - // * Setup CN Cookie - if (!this.cookiesMatchesConfig() || this.cookiesOlderThan(new Date())) { - // * Setup Browser Cookie if none. - this.resetBrowserCookie(); - this.openCookieModalToBannerPage(); - } - this.updateRestrictCloseModal(); - - // * Cookie should have been created from here. - Object.entries(this.getCookieStatusList()).forEach(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - cookieName = _ref2[0], - cookieStatus = _ref2[1]; - if (cookieStatus === CookieStatus.wait) { - // * Open modal if any cookie config is not set. - _this.openCookieModalToBannerPage(); - return; - } - if (!_this.config[cookieName]) { - // * Ignore missing config - return; - } - if (cookieStatus === CookieStatus.true) { - // * Exec script part for accepted cookie. - _this.config[cookieName].script(); - return; - } - if (_this.config[cookieName].fallback != null) { - // * Exec fallback part for accepted cookie if provided. - _this.config[cookieName].fallback(); - } - }); - } - - // COOKIES - - /** - * Update restrict for closing cookie modal - */ - return _createClass(CookieNotice, [{ - key: "updateRestrictCloseModal", - value: function updateRestrictCloseModal() { - this.restrictCloseModal = Object.values(this.getCookieStatusList()).includes(CookieStatus.wait) ? true : false; - this.restrictCloseModal ? this.cookieCloseModalBtn.classList.add("d-none") : this.cookieCloseModalBtn.classList.remove("d-none"); - this.restrictCloseModal ? this.modalBg.classList.add("cn-modal-bg-active") : this.modalBg.classList.remove("cn-modal-bg-active"); - } - - /** - * Get cookies expiration date or null if not defined alread - */ - }, { - key: "readCookiesExpirationDate", - value: function readCookiesExpirationDate() { - var _this$getBrowserCooki, - _this2 = this; - var cookies = (_this$getBrowserCooki = this.getBrowserCookieValue()) !== null && _this$getBrowserCooki !== void 0 ? _this$getBrowserCooki : "", - expirationDateString = cookies.split(",").find(function (cookieString) { - return cookieString.startsWith(_this2.cookieExpirationName); - }); - if (!expirationDateString) { - return null; - } - try { - var epochExpiration = Number.parseInt(expirationDateString.replace("".concat(this.cookieExpirationName, "="), "")); - if (isNaN(epochExpiration)) { - return null; - } - return new Date(epochExpiration); - } catch (e) { - return null; - } - } - - /** - * Check if the cookies date are older than a specified date - * @param date The limit date for cookies - */ - }, { - key: "cookiesOlderThan", - value: function cookiesOlderThan(date) { - return this.cookieExpirationDate.getTime() < date.getTime(); - } - - /** - * Check if the actual cookie matches the config - */ - }, { - key: "cookiesMatchesConfig", - value: function cookiesMatchesConfig() { - var cookies = this.getCookieStatusList(); - return Object.keys(cookies).length === Object.keys(this.config).length; - } - - /** - * Accept a all cookies - */ - }, { - key: "acceptAllCookies", - value: function acceptAllCookies() { - var _this3 = this; - Object.keys(this.config).forEach(function (cookieName) { - return _this3.acceptCookie(cookieName); - }); - this.closeCookieModal(); - } - - /** - * Accept a specific cookie - */ - }, { - key: "acceptCookie", - value: function acceptCookie(cookieName) { - var cookieOptions = this.getCookie(cookieName); - this.setCookieStatus(cookieName, CookieStatus.true, cookieOptions); - var cnSwitch = document.getElementById("".concat(cookieName, "-switch")); - var cnSwitchInput = cnSwitch === null || cnSwitch === void 0 ? void 0 : cnSwitch.querySelector("input"); - if (!cnSwitch || !cnSwitchInput) { - return; - } - cnSwitchInput.checked = true; - cnSwitch.ariaChecked = "true"; - } - - /** - * Deny a all cookies - */ - }, { - key: "denyAllCookies", - value: function denyAllCookies() { - var _this4 = this; - Object.keys(this.config).forEach(function (cookieName) { - return _this4.denyCookie(cookieName); - }); - this.closeCookieModal(); - } - - /** - * Deny a specific cookie - */ - }, { - key: "denyCookie", - value: function denyCookie(cookieName) { - var cookieOptions = this.getCookie(cookieName); - this.setCookieStatus(cookieName, CookieStatus.false, cookieOptions); - var cnSwitch = document.getElementById("".concat(cookieName, "-switch")); - var cnSwitchInput = cnSwitch === null || cnSwitch === void 0 ? void 0 : cnSwitch.querySelector("input"); - if (!cnSwitch || !cnSwitchInput) { - return; - } - cnSwitchInput.checked = false; - cnSwitch.ariaChecked = "false"; - } - - /** - * Deny all waiting cookies - */ - }, { - key: "denyAllWaitingCookies", - value: function denyAllWaitingCookies() { - var _this5 = this; - Object.entries(this.getCookieStatusList()).forEach(function (_ref3) { - var _ref4 = _slicedToArray(_ref3, 2), - cookieName = _ref4[0], - cookieStatus = _ref4[1]; - if (cookieStatus === CookieStatus.wait) { - _this5.setBrowserCookieStatus(cookieName, CookieStatus.false); - return; - } - }); - this.updateRestrictCloseModal(); - } - - /** - * Get a specific cookie config - */ - }, { - key: "getCookie", - value: function getCookie(cookieName) { - var _Object$entries$find; - var cookieOptions = (_Object$entries$find = Object.entries(this.config).find(function (entry) { - return entry[0] === cookieName; - })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1]; - if (cookieOptions === undefined) { - throw new Error("Cookie options ".concat(cookieName, " not found in list")); - } - return cookieOptions; - } - - /** - * Fetch the cookie status list - * - * @returns the cookie status list - */ - }, { - key: "getCookieStatusList", - value: function getCookieStatusList() { - var _this6 = this; - var cookies = this.getBrowserCookieValue(), - statusList = {}; - if (cookies === undefined) { - return statusList; - } - /** specificCookieString contains youtube=true like */ - cookies.split(",") - // * Ignore timestamp - .filter(function (specificCookieString) { - return !specificCookieString.startsWith(_this6.cookieExpirationName); - }).forEach(function (specificCookieString) { - var values = specificCookieString.split("="); - statusList[values[0]] = values[1]; - }); - return statusList; - } - - /** - * Check has cookie status - * - * @param key - * @param value - */ - }, { - key: "containsCookieStatus", - value: function containsCookieStatus(key) { - var statusList = this.getCookieStatusList(); - return Object.keys(statusList).find(function (cookieName) { - return cookieName === key; - }) !== undefined; - } - - /** - * Get a cookie status - * - * @param key - * @returns - */ - }, { - key: "getCookieStatus", - value: function getCookieStatus(key) { - var statusList = this.getCookieStatusList(); - var cookieIndex = Object.keys(statusList).find(function (cookieName) { - return cookieName === key; - }); - if (cookieIndex === undefined) { - throw new Error("Cookie options ".concat(key, " not found in list")); - } - return statusList[cookieIndex]; - } - - /** - * Set the cookie value - * - * @param cookieName - * @param status - * @param cookieOption - */ - }, { - key: "setCookieStatus", - value: function setCookieStatus(cookieName, status, cookieOption) { - if (status === CookieStatus.true) { - this.addCookieStatus(cookieName, cookieOption); - return; - } - if (status === CookieStatus.false) { - this.removeCookieStatus(cookieName, cookieOption); - return; - } - this.setBrowserCookieStatus(cookieName, CookieStatus.wait); - } - - /** - * Add a specific cookie and - * change his status to true - * - * @param cookieName - * @param cookieOption - */ - }, { - key: "addCookieStatus", - value: function addCookieStatus(cookieName, cookieOption) { - if (cookieOption.script) { - cookieOption.script(); - } - this.setBrowserCookieStatus(cookieName, CookieStatus.true); - } - - /** - * Remove a specific cookie and - * change his status to false - * - * @param cookieName - * @param cookieOption - */ - }, { - key: "removeCookieStatus", - value: function removeCookieStatus(cookieName, cookieOption) { - var cookieNameElement = document.getElementById(cookieName); - if (cookieNameElement) { - cookieNameElement.remove(); - } - if (cookieOption.fallback) { - cookieOption.fallback(); - } - this.setBrowserCookieStatus(cookieName, CookieStatus.false); - } - - /** - * Change the status of a cookie - * - * @param cookieName - * @param status - */ - }, { - key: "setBrowserCookieStatus", - value: function setBrowserCookieStatus(cookieName, status) { - var statusList = this.getCookieStatusList(); - // * Force refresh - this.deleteBrowserCookie(); - statusList[cookieName] = status; - this.saveBrowserCookie(statusList); - this.updateRestrictCloseModal(); - } - - /** - * Has CN cokie setup ? - * @returns true if the cookie is setup - */ - }, { - key: "hasBrowserCookie", - value: function hasBrowserCookie() { - return Boolean(this.getBrowserCookieValue()); - } - - /** - * Get the Ldcweb cookie - * - * @returns A string like analytics=true,youtube=true or undefined - */ - }, { - key: "getBrowserCookieValue", - value: function getBrowserCookieValue() { - var matches = document.cookie.match(new RegExp("(?:^|; )" + this.browserCookieName.replace(/([.$?*|{}()[\]\\/+^])/g, "\\$1") + "=([^;]*)")); - return matches ? decodeURIComponent(matches[1]) : undefined; - } - - /** - * Save cookie content on web browser - * - * @param list - */ - }, { - key: "saveBrowserCookie", - value: function saveBrowserCookie(statusList) { - var date = new Date(), - content = Object.entries(statusList).map(function (_ref5) { - var _ref6 = _slicedToArray(_ref5, 2), - cookieName = _ref6[0], - cookieStatus = _ref6[1]; - return "".concat(cookieName, "=").concat(cookieStatus); - }); - // * Update expiration date - this.cookieExpirationDate = new Date(date.setMonth(date.getMonth() + this.cookieTimeLife)); - // * Append expiration date - content.push("".concat(this.cookieExpirationName, "=").concat(this.cookieExpirationDate.getTime())); - document.cookie = "".concat(this.browserCookieName, "=").concat(content.join(","), ";path=/").concat(location.hostname ? ";domain=".concat(location.hostname) : "", ";expires=").concat(this.cookieExpirationDate.toUTCString(), ";").concat(this.getCookiePoliciesAsString()); - } - - /** - * Set an older expire parameter to a specific cookie - */ - }, { - key: "deleteBrowserCookie", - value: function deleteBrowserCookie() { - if (this.hasBrowserCookie()) { - // * Suppression du cookie et de sa version precedé d'un point - document.cookie = "".concat(this.browserCookieName, "=;path=/").concat(location.hostname ? ";domain=.".concat(location.hostname) : "", ";expires=Thu, 01 Jan 1970 00:00:01 GMT;"); - document.cookie = "".concat(this.browserCookieName, "=;path=/").concat(location.hostname ? ";domain=".concat(location.hostname) : "", ";expires=Thu, 01 Jan 1970 00:00:01 GMT;"); - } - } - }, { - key: "getCookiePoliciesAsString", - value: function getCookiePoliciesAsString() { - return Object.entries(this.cookiePolicies).map(function (_ref7) { - var _ref8 = _slicedToArray(_ref7, 2), - policyName = _ref8[0], - policyValue = _ref8[1]; - return "".concat(policyName, "=").concat(policyValue); - }).join(";"); - } - - /** - * Reset Ldc Web CN cookie - */ - }, { - key: "resetBrowserCookie", - value: function resetBrowserCookie() { - // * Create Cookie as It does not exists. - var newCookieList = {}; - Object.entries(this.config).forEach(function (_ref9) { - var _ref10 = _slicedToArray(_ref9, 1), - cookieName = _ref10[0]; - return newCookieList[cookieName] = CookieStatus.wait; - }); - this.saveBrowserCookie(newCookieList); - } - - // LISTENERS - - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - }, { - key: "addEvent", - value: function addEvent(element, evnt, funct) { - return element.addEventListener(evnt, funct.bind(this), false); - } - - /** - * Add event on a specific element and prevent default - * - * @param element - * @param evnt - * @param funct - * @returns - */ - }, { - key: "addEventPrevent", - value: function addEventPrevent(element, evnt, funct) { - var _this7 = this; - return element.addEventListener(evnt, function (e) { - e.preventDefault(); - funct.call(_this7, e); - }, false); - } - - /** - * Add event on a specific element - * - * @param element - * @param evnt - * @param funct - * @returns - */ - }, { - key: "addEventKbdValidate", - value: function addEventKbdValidate(element, funct) { - var _this8 = this; - return this.addEvent(element, "keydown", function (e) { - var kbdEvt = e; - if (kbdEvt.key == " " || kbdEvt.code == "Space" || kbdEvt.keyCode == 32 || kbdEvt.key == "Enter" || kbdEvt.code == "Enter" || kbdEvt.keyCode == 13) { - funct.call(_this8, kbdEvt); - e.preventDefault(); - } - }); - } - - // COOKIE MODAL - - /** - * Show or hide Cookie modal - * @returns - */ - }, { - key: "toggleCookieModal", - value: function toggleCookieModal() { - if (!document.body.classList.contains("cn-open")) { - this.openCookieModalToBannerPage(); - return; - } - this.closeCookieModal(); - } - - /** - * Open the cookies modal to the banner page - */ - }, { - key: "openCookieModalToBannerPage", - value: function openCookieModalToBannerPage() { - this.openCookieModalToCookiePage(); - this.toggleCookieModalPages(); - } - - /** - * Open the cookies modal to the cookies page - */ - }, { - key: "openCookieModalToCookiePage", - value: function openCookieModalToCookiePage() { - document.body.classList.add("cn-open"); - this.resetCookieModal(); - this.bannerContent.classList.add("d-none"); - this.modalContainer.classList.remove("d-none"); - this.bannerContainer.classList.add("cn-modal-page"); - - // Scroll to the top of the cookies list - this.modalWrapper.scrollTop = 0; - this.setupCookieModalList(); - this.setTabIndex(); - } - - /** - * Hide the cookies modal - */ - }, { - key: "closeCookieModal", - value: function closeCookieModal() { - this.updateRestrictCloseModal(); - if (!this.restrictCloseModal) { - document.body.classList.remove("cn-open"); - if (!this.isOnBannerPage()) { - // * Make toggle page to banner on closing - this.bannerContent.classList.toggle("d-none"); - this.modalContainer.classList.toggle("d-none"); - this.bannerContainer.classList.remove("cn-modal-page"); - } - this.unsetTabIndex(); - this.setupCookieModalList(); - } else { - throw new Error("You need to accept or refuse all cookies"); - } - } - - /** - * Setup tab indexes on visible elements - */ - }, { - key: "setTabIndex", - value: function setTabIndex() { - var _this9 = this; - // * Prevent focus html tag - document.documentElement.setAttribute("tabindex", "-1"); - setTimeout(function () { - var focusableSelector = "a[href], button, [role=\"button\"], input, embed, object, iframe, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])"; - - // * Only focusable elements - _toConsumableArray(document.body.querySelectorAll(focusableSelector)).filter(function (el) { - return !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden") && !_this9.cookieContainer.contains(el); - }).forEach(function (el) { - el.setAttribute("tabindex", "-1"); - el.classList.add("cn-disabled"); - }); - _toConsumableArray(_this9.cookieContainer.querySelectorAll(focusableSelector)).filter(function (el) { - return !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden") && - // * Only visible elements - !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length) && !_this9.cookieContainer.contains(el); - }).forEach(function (el) { - el.setAttribute("tabindex", "0"); - el.classList.remove("cn-disabled"); - }); - _this9.cookieShowModalBtn.setAttribute("tabindex", "-1"); - }, 500); - } - - /** - * Undo setup tab indexes on visible elements - */ - }, { - key: "unsetTabIndex", - value: function unsetTabIndex() { - var _this10 = this; - document.documentElement.setAttribute("tabindex", "0"); - setTimeout(function () { - document.body.querySelectorAll(".cn-disabled").forEach(function (el) { - el.setAttribute("tabindex", "0"); - el.classList.remove("cn-disabled"); - }); - _this10.cookieShowModalBtn.setAttribute("tabindex", "0"); - }, 500); - } - - /** - * Reset the modal view state - */ - }, { - key: "resetCookieModal", - value: function resetCookieModal() { - this.bannerContent.classList.remove("d-none"); - this.modalContainer.classList.add("d-none"); - this.bannerContainer.classList.remove("cn-modal-page"); - if (!this.customizeBtn.dataset.openModal) { - throw new Error("Cannot find attribut data-open-modal"); - } - this.customizeBtn.innerHTML = this.customizeBtn.dataset.openModal; - } - - /** - * Set the cookies list in the modal - */ - }, { - key: "setupCookieModalList", - value: function setupCookieModalList() { - var _this11 = this; - this.cookiesUnorderedList.innerHTML = ""; - Object.entries(this.config).forEach(function (_ref11) { - var _ref12 = _slicedToArray(_ref11, 2), - cookieName = _ref12[0], - cookieConfig = _ref12[1]; - var cookie = document.createElement("li"); - var childItem = _this11.template.children.item(0); - if (childItem === null) { - throw new Error("Cannot find child item"); - } - cookie.append(childItem.cloneNode(true)); - var name = cookie.querySelector("span.cn-cookie-name"); - var description = cookie.querySelector("span.cn-cookie-description"); - var link = cookie.querySelector(".cn-cookie-link"); - var cnSwitch = cookie.querySelector(".cn-switch"); - var cnSwitchInput = cookie.querySelector(".cn-switch > input"); - - // * Undertermined state - cnSwitchInput.indeterminate = true; - cnSwitchInput.checked = false; - - // * Assign cookie aside content - name.textContent = cookieConfig.name; - description.id = "".concat(cookieName, "-desc"); - description.textContent = cookieConfig.description; - link.textContent = cookieConfig.labelLink; - link.setAttribute("href", cookieConfig.link); - - // * Assign cookie controls - cnSwitch.id = "".concat(cookieName, "-switch"); - cnSwitch.name = cookieName; - cnSwitch.dataset.name = cookieName; - cnSwitch.setAttribute("aria-labelledby", "".concat(cookieName, "-desc")); - cnSwitch.setAttribute("aria-describedby", "".concat(cookieName, "-desc")); - var toggleCookie = function toggleCookie(cookieName) { - var cookieStatus = _this11.getCookieStatus(cookieName); - _this11.setCookieStatus(cookieName, _this11.invertCookieStatus(cookieStatus), cookieConfig); - }; - _this11.addEvent(cnSwitchInput, "click", function () { - return toggleCookie(cookieName); - }); - _this11.addEventKbdValidate(cnSwitch, function () { - return cnSwitchInput.click(); - }); - _this11.cookiesUnorderedList.append(cookie); - if (!_this11.hasBrowserCookie()) { - // * Ldcweb cookie is not set. - return; - } - // * Setup list status state - Object.entries(_this11.getCookieStatusList()).forEach(function (_ref13) { - var _ref14 = _slicedToArray(_ref13, 2), - ckName = _ref14[0], - cookieStatus = _ref14[1]; - if (ckName === cookieName) { - switch (cookieStatus) { - case CookieStatus.true: - cnSwitchInput.indeterminate = false; - cnSwitchInput.checked = true; - break; - case CookieStatus.false: - cnSwitchInput.indeterminate = false; - cnSwitchInput.checked = false; - break; - case CookieStatus.wait: - cnSwitchInput.indeterminate = true; - cnSwitchInput.checked = false; - break; - } - } - }); - }); - } - }, { - key: "switchToModalPageOrClose", - value: function switchToModalPageOrClose() { - // * Modification du comportement du bouton, même si ca n'a pas de sens. - // https://lab.s-web.fr/ldc-web/projets/ldc-web-cookie-notice/-/issues/9` - - if (this.isOnBannerPage()) { - this.toggleCookieModalPages(); - return; - } - // * Pas de permutation en arrière - this.closeCookieModal(); - } - - /** - * Toggle Cookie modal pages - */ - }, { - key: "toggleCookieModalPages", - value: function toggleCookieModalPages() { - this.bannerContent.classList.toggle("d-none"); - this.modalContainer.classList.toggle("d-none"); - this.bannerContainer.classList.toggle("cn-modal-page"); - if (!this.isOnBannerPage()) { - this.bannerContainer.classList.add("cn-modal-page"); - this.denyAllWaitingCookies(); - } - this.setTabIndex(); - this.setupCookieModalList(); - this.togglePersonalizeBtn(); - } - - /** - * Toggle customize btn - */ - }, { - key: "togglePersonalizeBtn", - value: function togglePersonalizeBtn() { - var customizeBtnBannerDataset = this.customizeBtn.dataset; - this.modalWrapper.scrollTop = 0; - if (this.bannerContent.classList.contains("d-none")) { - this.customizeBtn.innerHTML = customizeBtnBannerDataset.openModal; - this.customizeBtn.title = customizeBtnBannerDataset.openModal; - } else { - this.customizeBtn.innerHTML = customizeBtnBannerDataset.closeModal; - this.customizeBtn.title = customizeBtnBannerDataset.closeModal; - } - } - - /** - * Get the actual page: banner or modal (with cookie choices) - */ - }, { - key: "isOnBannerPage", - value: function isOnBannerPage() { - return this.modalContainer.classList.contains("d-none"); - } - - /** - * Invert cookie status - * - * @param status - * @returns Inverted cookie status, `wait` will give `false`. - */ - }, { - key: "invertCookieStatus", - value: function invertCookieStatus(status) { - switch (status) { - case CookieStatus.true: - case CookieStatus.wait: - return CookieStatus.false; - case CookieStatus.false: - return CookieStatus.true; - default: - throw new Error("Un handled cookie status ".concat(status)); - } - } - }]); -}(); - -var CookieStatus = /*#__PURE__*/function (CookieStatus) { - CookieStatus["true"] = "true"; - CookieStatus["false"] = "false"; - CookieStatus["wait"] = "wait"; - return CookieStatus; -}(CookieStatus || {}); -var CookiePolicySameSite = /*#__PURE__*/function (CookiePolicySameSite) { - CookiePolicySameSite["lax"] = "lax"; - CookiePolicySameSite["strict"] = "strict"; - CookiePolicySameSite["none"] = "none"; - return CookiePolicySameSite; -}(CookiePolicySameSite || {}); - -/***/ }), - -/***/ "./src/scss/themes/standard.scss": -/*!***************************************!*\ - !*** ./src/scss/themes/standard.scss ***! - \***************************************/ -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { - -module.exports = __webpack_require__.p + "css/standard.css"; - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/define property getters */ -/******/ !function() { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = function(exports, definition) { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ }(); -/******/ -/******/ /* webpack/runtime/global */ -/******/ !function() { -/******/ __webpack_require__.g = (function() { -/******/ if (typeof globalThis === 'object') return globalThis; -/******/ try { -/******/ return this || new Function('return this')(); -/******/ } catch (e) { -/******/ if (typeof window === 'object') return window; -/******/ } -/******/ })(); -/******/ }(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ !function() { -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -/******/ }(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ !function() { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ }(); -/******/ -/******/ /* webpack/runtime/publicPath */ -/******/ !function() { -/******/ var scriptUrl; -/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; -/******/ var document = __webpack_require__.g.document; -/******/ if (!scriptUrl && document) { -/******/ if (document.currentScript) -/******/ scriptUrl = document.currentScript.src; -/******/ if (!scriptUrl) { -/******/ var scripts = document.getElementsByTagName("script"); -/******/ if(scripts.length) { -/******/ var i = scripts.length - 1; -/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; -/******/ } -/******/ } -/******/ } -/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration -/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. -/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); -/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); -/******/ __webpack_require__.p = scriptUrl; -/******/ }(); -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ __webpack_require__("./src/ts/index.ts"); -/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined -/******/ var __webpack_exports__ = __webpack_require__("./src/scss/themes/standard.scss"); -/******/ -/******/ return __webpack_exports__; -/******/ })() -; -}); -//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/dist/umd/main.js.map b/dist/umd/main.js.map deleted file mode 100644 index 770180a..0000000 --- a/dist/umd/main.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"main.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVA;AAAA,IAEqBA,YAAY;EAe7B;;EAyBA,SAAAA,aAAYC,MAAqC,EAAE;IAAA,IAAAC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A2BtF,MAAoB,EAAgB;MAC3D,QAAQA,MAAM;QACV,KAAK3D,YAAY,CAACE,IAAI;QACtB,KAAKF,YAAY,CAACC,IAAI;UAClB,OAAOD,YAAY,CAAC2C,KAAK;QAC7B,KAAK3C,YAAY,CAAC2C,KAAK;UACnB,OAAO3C,YAAY,CAACE,IAAI;QAC5B;UACI,MAAM,IAAI/B,KAAK,6BAAAqD,MAAA,CAA6BmC,MAAM,CAAE,CAAC;MAC7D;IACJ;EAAC;AAAA;AAn3B4B;AAAA,IAs3B5B3D,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA,EAAZA,YAAY;AAAA,IAaZ5D,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA,EAApBA,oBAAoB;;;;;;;;;;;;;;;;UCr4BzB;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,GAAG;WACH;WACA;WACA,CAAC;;;;;WCPD,8CAA8C;;;;;WCA9C;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;UElBA;UACA;UACA;UACA;UACA","sources":["webpack://CookieNotice/webpack/universalModuleDefinition","webpack://CookieNotice/./src/ts/index.ts","webpack://CookieNotice/webpack/bootstrap","webpack://CookieNotice/webpack/runtime/define property getters","webpack://CookieNotice/webpack/runtime/global","webpack://CookieNotice/webpack/runtime/hasOwnProperty shorthand","webpack://CookieNotice/webpack/runtime/make namespace object","webpack://CookieNotice/webpack/runtime/publicPath","webpack://CookieNotice/webpack/before-startup","webpack://CookieNotice/webpack/startup","webpack://CookieNotice/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CookieNotice\"] = factory();\n\telse\n\t\troot[\"CookieNotice\"] = factory();\n})(this, function() {\nreturn ","/** 5.0.4 */\n\nexport default class CookieNotice {\n browserCookieName = \"cn-init\";\n\n /** Cookie life time */\n cookieTimeLife = 6;\n\n /** The index on which store the expiration date */\n cookieExpirationName = \"_expiration\";\n\n /** Cookie policies for each functionality */\n cookiePolicies: CookiePolicy = {\n sameSite: CookiePolicySameSite.lax,\n secure: \"\",\n };\n\n /** Cookie expiration date as specified in the cookie itself */\n cookieExpirationDate: Date;\n\n config: Record;\n modalBg: HTMLDivElement;\n cookieContainer: HTMLDivElement;\n bannerContainer: HTMLDivElement;\n modalContainer: HTMLDivElement;\n\n cookieShowModalBtn: HTMLButtonElement;\n cookieCloseModalBtn: HTMLButtonElement;\n\n bannerContent: HTMLDivElement;\n acceptAllBtn: HTMLButtonElement;\n denyAllBtn: HTMLButtonElement;\n customizeBtn: HTMLButtonElement;\n cookiesUnorderedList: HTMLUListElement;\n cookieLinkShowCustomizeModalList: NodeListOf;\n modalWrapper: HTMLDivElement;\n template: HTMLDivElement;\n\n restrictCloseModal: boolean;\n\n static noConflict: (deep?: boolean) => typeof CookieNotice;\n\n constructor(config: Record) {\n // * Setup Config\n this.config = config;\n\n // * Setup cookie expiration date\n let cookieExpirationDate: Date|null = this.readCookiesExpirationDate();\n if (!cookieExpirationDate) {\n cookieExpirationDate = new Date();\n cookieExpirationDate.setMonth(cookieExpirationDate.getMonth() + this.cookieTimeLife);\n }\n this.cookieExpirationDate = cookieExpirationDate;\n\n // * Inject DOM modal BG\n const modalBg = document.createElement(\"div\");\n modalBg.classList.add(\"cn-modal-bg\");\n document.body.append(modalBg);\n this.modalBg = modalBg;\n\n // * Setup Dom Elements\n const cookieContainer = document.querySelector(\n \"div#cn-wrapper\"\n ) as HTMLDivElement | null,\n cookieShowModalBtn = document.querySelector(\n \"button#cn-cookie-btn\"\n ) as HTMLButtonElement | null,\n cookieCloseModalBtn = document.querySelector(\n \"button#cn-close-modal\"\n ) as HTMLButtonElement | null,\n cookieLinkShowCustomizeModalPageList = document.querySelectorAll(\n \".cn-cookie-link\"\n ) as NodeListOf,\n bannerContainer = document.querySelector(\n \"div#cn-banner\"\n ) as HTMLDivElement | null,\n bannerContent = document.querySelector(\n \"div.cn-banner-content\"\n ) as HTMLDivElement | null,\n modalContainer = document.querySelector(\n \"div.cn-modal-container\"\n ) as HTMLDivElement | null,\n acceptAllBtn = document.querySelector(\n \"button#cn-accept-banner\"\n ) as HTMLButtonElement | null,\n denyAllBtn = document.querySelector(\n \"button#cn-deny-banner\"\n ) as HTMLButtonElement | null,\n customizeBtn = document.querySelector(\n \"button#cn-settings-banner\"\n ) as HTMLButtonElement | null,\n cookiesUnorderedList = document.querySelector(\n \"ul#cn-modal-list\"\n ) as HTMLUListElement | null,\n modalWrapper = document.querySelector(\n \"div.cn-modal-wrapper\"\n ) as HTMLDivElement,\n template = document.querySelector(\n \"div#cn-li-template\"\n ) as HTMLDivElement | null;\n if (!cookieContainer) {\n throw new Error(\"Cannot find div#cn-wrapper\");\n }\n if (!cookieShowModalBtn) {\n throw new Error(\"Cannot find 'button#cn-cookie-btn' element\");\n }\n if (!cookieCloseModalBtn) {\n throw new Error(\"Cannot find 'button#cn-close-modal' element\");\n }\n if (!bannerContainer) {\n throw new Error(\"Cannot find 'div#cn-banner' element\");\n }\n if (!bannerContent) {\n throw new Error(\"Cannot find 'div.cn-banner-content' element\");\n }\n if (!modalContainer) {\n throw new Error(\"Cannot find 'div.cn-modal-container' element\");\n }\n if (!acceptAllBtn) {\n throw new Error(\"Cannot find 'button#cn-accept-banner' element\");\n }\n if (!denyAllBtn) {\n throw new Error(\"Cannot find 'button#cn-deny-banner' element\");\n }\n if (!customizeBtn) {\n throw new Error(\"Cannot find 'button.cn-settings-banner' element\");\n }\n if (!cookiesUnorderedList) {\n throw new Error(\"Cannot find 'ul#cn-modal-list' element\");\n }\n if (!modalWrapper) {\n throw new Error(\"Cannot find 'div.cn-modal-wrapper' element\");\n }\n if (!template) {\n throw new Error(\"Cannot find 'div#cn-li-template' element\");\n }\n\n this.cookieShowModalBtn = cookieShowModalBtn;\n this.cookieCloseModalBtn = cookieCloseModalBtn;\n this.cookieLinkShowCustomizeModalList =\n cookieLinkShowCustomizeModalPageList;\n this.cookieContainer = cookieContainer;\n this.bannerContainer = bannerContainer;\n this.bannerContent = bannerContent;\n this.cookiesUnorderedList = cookiesUnorderedList;\n this.modalWrapper = modalWrapper;\n this.modalContainer = modalContainer;\n this.acceptAllBtn = acceptAllBtn;\n this.denyAllBtn = denyAllBtn;\n this.customizeBtn = customizeBtn;\n\n this.template = template;\n const memoryTemplate = this.template.cloneNode(true) as HTMLDivElement;\n this.template.remove();\n this.template = memoryTemplate;\n\n this.restrictCloseModal = true;\n\n // * Setup Events\n this.addEventPrevent(this.modalBg, \"click\", this.closeCookieModal);\n this.addEventPrevent(\n this.cookieCloseModalBtn,\n \"click\",\n this.closeCookieModal\n );\n this.addEventPrevent(this.acceptAllBtn, \"click\", this.acceptAllCookies);\n this.addEventPrevent(this.denyAllBtn, \"click\", this.denyAllCookies);\n this.addEventPrevent(\n this.customizeBtn,\n \"click\",\n this.switchToModalPageOrClose\n );\n this.addEventPrevent(\n this.cookieShowModalBtn,\n \"click\",\n this.toggleCookieModal\n );\n this.cookieLinkShowCustomizeModalList.forEach((cookieLink) => {\n this.addEventPrevent(\n cookieLink,\n \"click\",\n this.openCookieModalToCookiePage\n );\n this.addEventKbdValidate(cookieLink, this.openCookieModalToCookiePage);\n });\n\n // * Setup CN Cookie\n if (!this.cookiesMatchesConfig() || this.cookiesOlderThan(new Date())) {\n // * Setup Browser Cookie if none.\n this.resetBrowserCookie();\n this.openCookieModalToBannerPage();\n }\n\n this.updateRestrictCloseModal();\n\n // * Cookie should have been created from here.\n Object.entries(this.getCookieStatusList()).forEach(([cookieName, cookieStatus]) => {\n if (cookieStatus === CookieStatus.wait) {\n // * Open modal if any cookie config is not set.\n this.openCookieModalToBannerPage();\n return;\n }\n if (!this.config[cookieName]) {\n // * Ignore missing config\n return;\n }\n if (cookieStatus === CookieStatus.true) {\n // * Exec script part for accepted cookie.\n this.config[cookieName].script();\n return;\n }\n if (this.config[cookieName].fallback != null) {\n // * Exec fallback part for accepted cookie if provided.\n this.config[cookieName].fallback();\n }\n });\n }\n\n // COOKIES\n\n /**\n * Update restrict for closing cookie modal\n */\n updateRestrictCloseModal() {\n this.restrictCloseModal = (Object.values(this.getCookieStatusList()).includes(CookieStatus.wait)) ? true : false;\n (this.restrictCloseModal) ? this.cookieCloseModalBtn.classList.add(\"d-none\") : this.cookieCloseModalBtn.classList.remove(\"d-none\");\n (this.restrictCloseModal) ? this.modalBg.classList.add(\"cn-modal-bg-active\") : this.modalBg.classList.remove(\"cn-modal-bg-active\");\n }\n\n /**\n * Get cookies expiration date or null if not defined alread\n */\n readCookiesExpirationDate(): Date | null {\n const cookies = this.getBrowserCookieValue() ?? \"\",\n expirationDateString = cookies.split(\",\").find((cookieString) =>\n cookieString.startsWith(this.cookieExpirationName));\n if (!expirationDateString) {\n return null;\n }\n try {\n const epochExpiration = Number.parseInt(expirationDateString.replace(`${this.cookieExpirationName}=`, \"\"));\n if (isNaN(epochExpiration)) {\n return null;\n }\n return new Date(epochExpiration);\n } catch (e) {\n return null;\n }\n }\n\n /**\n * Check if the cookies date are older than a specified date\n\n * @param date The limit date for cookies\n */\n cookiesOlderThan(date: Date): boolean {\n return this.cookieExpirationDate.getTime() < date.getTime();\n }\n\n /**\n * Check if the actual cookie matches the config\n */\n cookiesMatchesConfig(): boolean {\n const cookies = this.getCookieStatusList();\n return Object.keys(cookies).length === Object.keys(this.config).length;\n }\n\n /**\n * Accept a all cookies\n */\n acceptAllCookies() {\n Object.keys(this.config).forEach((cookieName) => this.acceptCookie(cookieName));\n this.closeCookieModal();\n }\n\n /**\n * Accept a specific cookie\n */\n acceptCookie(cookieName: string) {\n const cookieOptions = this.getCookie(cookieName);\n this.setCookieStatus(cookieName, CookieStatus.true, cookieOptions);\n const cnSwitch = document.getElementById(`${cookieName}-switch`) as HTMLInputElement | null;\n const cnSwitchInput = cnSwitch?.querySelector(\"input\") as HTMLInputElement | null;\n if (!cnSwitch || !cnSwitchInput) {\n return;\n }\n cnSwitchInput.checked = true;\n cnSwitch.ariaChecked = \"true\";\n }\n\n /**\n * Deny a all cookies\n */\n denyAllCookies() {\n Object.keys(this.config).forEach((cookieName) => this.denyCookie(cookieName));\n this.closeCookieModal();\n }\n\n /**\n * Deny a specific cookie\n */\n denyCookie(cookieName: string) {\n const cookieOptions = this.getCookie(cookieName);\n this.setCookieStatus(cookieName, CookieStatus.false, cookieOptions);\n const cnSwitch = document.getElementById(`${cookieName}-switch`) as HTMLInputElement | null;\n const cnSwitchInput = cnSwitch?.querySelector(\"input\") as HTMLInputElement | null;\n if (!cnSwitch || !cnSwitchInput) {\n return;\n }\n cnSwitchInput.checked = false;\n cnSwitch.ariaChecked = \"false\";\n }\n\n /**\n * Deny all waiting cookies\n */\n denyAllWaitingCookies() {\n Object.entries(this.getCookieStatusList()).forEach(([cookieName, cookieStatus]) => {\n if (cookieStatus === CookieStatus.wait) {\n this.setBrowserCookieStatus(cookieName, CookieStatus.false);\n return;\n }\n });\n this.updateRestrictCloseModal();\n }\n\n /**\n * Get a specific cookie config\n */\n getCookie(cookieName: string): CookieOptions {\n const cookieOptions = Object.entries(this.config).find((entry) => entry[0] === cookieName)?.[1];\n if (cookieOptions === undefined) {\n throw new Error(`Cookie options ${cookieName} not found in list`);\n }\n return cookieOptions;\n }\n\n /**\n * Fetch the cookie status list\n *\n * @returns the cookie status list\n */\n getCookieStatusList(): CookieStatusList {\n const cookies = this.getBrowserCookieValue(),\n statusList: CookieStatusList = {};\n if (cookies === undefined) {\n return statusList;\n }\n /** specificCookieString contains youtube=true like */\n cookies.split(\",\")\n // * Ignore timestamp\n .filter((specificCookieString) => !specificCookieString.startsWith(this.cookieExpirationName))\n .forEach((specificCookieString) => {\n const values = specificCookieString.split(\"=\");\n statusList[values[0]] = values[1] as CookieStatus;\n });\n return statusList;\n }\n\n /**\n * Check has cookie status\n *\n * @param key\n * @param value\n */\n containsCookieStatus(key: string): boolean {\n const statusList: CookieStatusList = this.getCookieStatusList();\n return (\n Object.keys(statusList).find((cookieName) => cookieName === key) !==\n undefined\n );\n }\n\n /**\n * Get a cookie status\n *\n * @param key\n * @returns\n */\n getCookieStatus(key: string): CookieStatus {\n const statusList: CookieStatusList = this.getCookieStatusList();\n const cookieIndex = Object.keys(statusList).find((cookieName) => cookieName === key);\n if (cookieIndex === undefined) {\n throw new Error(`Cookie options ${key} not found in list`);\n }\n return statusList[cookieIndex];\n }\n\n /**\n * Set the cookie value\n *\n * @param cookieName\n * @param status\n * @param cookieOption\n */\n setCookieStatus(\n cookieName: string,\n status: CookieStatus,\n cookieOption: CookieOptions\n ) {\n if (status === CookieStatus.true) {\n this.addCookieStatus(cookieName, cookieOption);\n return;\n }\n if (status === CookieStatus.false) {\n this.removeCookieStatus(cookieName, cookieOption);\n return;\n }\n this.setBrowserCookieStatus(cookieName, CookieStatus.wait);\n }\n\n /**\n * Add a specific cookie and\n * change his status to true\n *\n * @param cookieName\n * @param cookieOption\n */\n addCookieStatus(cookieName: string, cookieOption: CookieOptions) {\n if (cookieOption.script) {\n cookieOption.script();\n }\n this.setBrowserCookieStatus(cookieName, CookieStatus.true);\n }\n\n /**\n * Remove a specific cookie and\n * change his status to false\n *\n * @param cookieName\n * @param cookieOption\n */\n removeCookieStatus(cookieName: string, cookieOption: CookieOptions) {\n const cookieNameElement = document.getElementById(cookieName);\n if (cookieNameElement) {\n cookieNameElement.remove();\n }\n if (cookieOption.fallback) {\n cookieOption.fallback();\n }\n this.setBrowserCookieStatus(cookieName, CookieStatus.false);\n }\n\n /**\n * Change the status of a cookie\n *\n * @param cookieName\n * @param status\n */\n setBrowserCookieStatus(cookieName: string, status: CookieStatus) {\n const statusList: CookieStatusList = this.getCookieStatusList();\n // * Force refresh\n this.deleteBrowserCookie();\n statusList[cookieName] = status;\n this.saveBrowserCookie(statusList);\n this.updateRestrictCloseModal();\n }\n\n /**\n * Has CN cokie setup ?\n * @returns true if the cookie is setup\n */\n hasBrowserCookie(): boolean {\n return Boolean(this.getBrowserCookieValue());\n }\n\n /**\n * Get the Ldcweb cookie\n *\n * @returns A string like analytics=true,youtube=true or undefined\n */\n getBrowserCookieValue() {\n const matches = document.cookie.match(\n new RegExp(\n \"(?:^|; )\" +\n this.browserCookieName.replace(\n /([.$?*|{}()[\\]\\\\/+^])/g,\n \"\\\\$1\"\n ) +\n \"=([^;]*)\"\n )\n );\n return matches ? decodeURIComponent(matches[1]) : undefined;\n }\n\n /**\n * Save cookie content on web browser\n *\n * @param list\n */\n saveBrowserCookie(statusList: CookieStatusList) {\n const date = new Date(),\n content = Object.entries(statusList)\n .map(([cookieName, cookieStatus]) => {\n return `${cookieName}=${cookieStatus}`;\n });\n // * Update expiration date\n this.cookieExpirationDate = new Date(date.setMonth(date.getMonth() + this.cookieTimeLife));\n // * Append expiration date\n content.push(`${this.cookieExpirationName}=${this.cookieExpirationDate.getTime()}`);\n document.cookie = `${this.browserCookieName}=${content.join(\",\")};path=/${\n location.hostname ? `;domain=${location.hostname}` : \"\"\n };expires=${this.cookieExpirationDate.toUTCString()};${this.getCookiePoliciesAsString()}`;\n }\n\n /**\n * Set an older expire parameter to a specific cookie\n */\n deleteBrowserCookie() {\n if (this.hasBrowserCookie()) {\n // * Suppression du cookie et de sa version precedé d'un point\n document.cookie = `${this.browserCookieName}=;path=/${\n location.hostname ? `;domain=.${location.hostname}` : \"\"\n };expires=Thu, 01 Jan 1970 00:00:01 GMT;`;\n document.cookie = `${this.browserCookieName}=;path=/${\n location.hostname ? `;domain=${location.hostname}` : \"\"\n };expires=Thu, 01 Jan 1970 00:00:01 GMT;`;\n }\n }\n\n getCookiePoliciesAsString(): string {\n return Object.entries(this.cookiePolicies)\n .map(([policyName, policyValue]) => `${policyName}=${policyValue}`)\n .join(\";\");\n }\n\n /**\n * Reset Ldc Web CN cookie\n */\n resetBrowserCookie() {\n // * Create Cookie as It does not exists.\n const newCookieList: CookieStatusList = {};\n Object.entries(this.config).forEach(\n ([cookieName]) => (newCookieList[cookieName] = CookieStatus.wait)\n );\n this.saveBrowserCookie(newCookieList);\n }\n\n // LISTENERS\n\n /**\n * Add event on a specific element\n *\n * @param element\n * @param evnt\n * @param funct\n * @returns\n */\n addEvent(element: HTMLElement, evnt: string, funct: (e: Event) => void) {\n return element.addEventListener(evnt, funct.bind(this), false);\n }\n\n /**\n * Add event on a specific element and prevent default\n *\n * @param element\n * @param evnt\n * @param funct\n * @returns\n */\n addEventPrevent(\n element: HTMLElement,\n evnt: string,\n funct: (e: Event) => void\n ) {\n return element.addEventListener(\n evnt,\n (e) => {\n e.preventDefault();\n funct.call(this, e);\n },\n false\n );\n }\n\n /**\n * Add event on a specific element\n *\n * @param element\n * @param evnt\n * @param funct\n * @returns\n */\n addEventKbdValidate(element: HTMLElement, funct: (e: Event) => void) {\n return this.addEvent(element, \"keydown\", (e: Event) => {\n const kbdEvt = e as KeyboardEvent;\n if (\n kbdEvt.key == \" \" ||\n kbdEvt.code == \"Space\" ||\n kbdEvt.keyCode == 32 ||\n kbdEvt.key == \"Enter\" ||\n kbdEvt.code == \"Enter\" ||\n kbdEvt.keyCode == 13\n ) {\n funct.call(this, kbdEvt);\n e.preventDefault();\n }\n });\n }\n\n // COOKIE MODAL\n\n /**\n * Show or hide Cookie modal\n * @returns\n */\n toggleCookieModal() {\n if (!document.body.classList.contains(\"cn-open\")) {\n this.openCookieModalToBannerPage();\n return;\n }\n this.closeCookieModal();\n }\n\n /**\n * Open the cookies modal to the banner page\n */\n openCookieModalToBannerPage() {\n this.openCookieModalToCookiePage();\n this.toggleCookieModalPages();\n }\n\n /**\n * Open the cookies modal to the cookies page\n */\n openCookieModalToCookiePage() {\n document.body.classList.add(\"cn-open\");\n this.resetCookieModal();\n this.bannerContent.classList.add(\"d-none\");\n this.modalContainer.classList.remove(\"d-none\");\n this.bannerContainer.classList.add(\"cn-modal-page\");\n\n // Scroll to the top of the cookies list\n this.modalWrapper.scrollTop = 0;\n this.setupCookieModalList();\n this.setTabIndex();\n }\n\n /**\n * Hide the cookies modal\n */\n closeCookieModal() {\n this.updateRestrictCloseModal();\n if (!this.restrictCloseModal) {\n document.body.classList.remove(\"cn-open\");\n if (!this.isOnBannerPage()) {\n // * Make toggle page to banner on closing\n this.bannerContent.classList.toggle(\"d-none\");\n this.modalContainer.classList.toggle(\"d-none\");\n this.bannerContainer.classList.remove(\"cn-modal-page\");\n }\n this.unsetTabIndex();\n this.setupCookieModalList();\n } else {\n throw new Error(\"You need to accept or refuse all cookies\");\n }\n }\n\n /**\n * Setup tab indexes on visible elements\n */\n setTabIndex() {\n // * Prevent focus html tag\n document.documentElement.setAttribute(\"tabindex\", \"-1\");\n setTimeout(() => {\n const focusableSelector =\n \"a[href], button, [role=\\\"button\\\"], input, embed, object, iframe, textarea, select, details, [tabindex]:not([tabindex=\\\"-1\\\"])\";\n\n // * Only focusable elements\n [...document.body.querySelectorAll(focusableSelector)]\n .filter(\n (el) =>\n !el.hasAttribute(\"disabled\") &&\n !el.getAttribute(\"aria-hidden\") &&\n !this.cookieContainer.contains(el)\n )\n .forEach((el) => {\n (el as HTMLElement).setAttribute(\"tabindex\", \"-1\");\n (el as HTMLElement).classList.add(\"cn-disabled\");\n });\n [...this.cookieContainer.querySelectorAll(focusableSelector)]\n .filter(\n (el) =>\n !el.hasAttribute(\"disabled\") &&\n !el.getAttribute(\"aria-hidden\") &&\n // * Only visible elements\n !!(\n (el as HTMLElement).offsetWidth ||\n (el as HTMLElement).offsetHeight ||\n el.getClientRects().length\n ) &&\n !this.cookieContainer.contains(el)\n )\n .forEach((el) => {\n (el as HTMLElement).setAttribute(\"tabindex\", \"0\");\n (el as HTMLElement).classList.remove(\"cn-disabled\");\n });\n this.cookieShowModalBtn.setAttribute(\"tabindex\", \"-1\");\n }, 500);\n }\n\n /**\n * Undo setup tab indexes on visible elements\n */\n unsetTabIndex() {\n document.documentElement.setAttribute(\"tabindex\", \"0\");\n setTimeout(() => {\n document.body.querySelectorAll(\".cn-disabled\").forEach((el) => {\n (el as HTMLElement).setAttribute(\"tabindex\", \"0\");\n (el as HTMLElement).classList.remove(\"cn-disabled\");\n });\n this.cookieShowModalBtn.setAttribute(\"tabindex\", \"0\");\n }, 500);\n }\n\n /**\n * Reset the modal view state\n */\n resetCookieModal() {\n this.bannerContent.classList.remove(\"d-none\");\n this.modalContainer.classList.add(\"d-none\");\n this.bannerContainer.classList.remove(\"cn-modal-page\");\n if (!this.customizeBtn.dataset.openModal) {\n throw new Error(\"Cannot find attribut data-open-modal\");\n }\n this.customizeBtn.innerHTML = this.customizeBtn.dataset.openModal;\n }\n\n /**\n * Set the cookies list in the modal\n */\n setupCookieModalList() {\n this.cookiesUnorderedList.innerHTML = \"\";\n Object.entries(this.config).forEach(([cookieName, cookieConfig]) => {\n const cookie = document.createElement(\"li\");\n const childItem = this.template.children.item(\n 0\n ) as HTMLDivElement | null;\n if (childItem === null) {\n throw new Error(\"Cannot find child item\");\n }\n cookie.append(childItem.cloneNode(true));\n const name = cookie.querySelector(\n \"span.cn-cookie-name\"\n ) as HTMLSpanElement;\n const description = cookie.querySelector(\n \"span.cn-cookie-description\"\n ) as HTMLSpanElement;\n const link = cookie.querySelector(\n \".cn-cookie-link\"\n ) as HTMLElement;\n const cnSwitch = cookie.querySelector(\n \".cn-switch\"\n ) as HTMLInputElement;\n const cnSwitchInput = cookie.querySelector(\n \".cn-switch > input\"\n ) as HTMLInputElement;\n\n // * Undertermined state\n cnSwitchInput.indeterminate = true;\n cnSwitchInput.checked = false;\n\n // * Assign cookie aside content\n name.textContent = cookieConfig.name;\n description.id = `${cookieName}-desc`;\n description.textContent = cookieConfig.description;\n link.textContent = cookieConfig.labelLink;\n link.setAttribute(\"href\", cookieConfig.link);\n\n // * Assign cookie controls\n cnSwitch.id = `${cookieName}-switch`;\n cnSwitch.name = cookieName;\n cnSwitch.dataset.name = cookieName;\n cnSwitch.setAttribute(\"aria-labelledby\", `${cookieName}-desc`);\n cnSwitch.setAttribute(\"aria-describedby\", `${cookieName}-desc`);\n\n const toggleCookie = (cookieName: string) => {\n const cookieStatus = this.getCookieStatus(cookieName);\n this.setCookieStatus(\n cookieName,\n this.invertCookieStatus(cookieStatus),\n cookieConfig\n );\n };\n this.addEvent(cnSwitchInput, \"click\", () => toggleCookie(cookieName));\n this.addEventKbdValidate(cnSwitch, () => cnSwitchInput.click());\n\n this.cookiesUnorderedList.append(cookie);\n\n if (!this.hasBrowserCookie()) {\n // * Ldcweb cookie is not set.\n return;\n }\n // * Setup list status state\n Object.entries(this.getCookieStatusList()).forEach(\n ([ckName, cookieStatus]) => {\n if (ckName === cookieName) {\n switch (cookieStatus) {\n case CookieStatus.true:\n cnSwitchInput.indeterminate = false;\n cnSwitchInput.checked = true;\n break;\n case CookieStatus.false:\n cnSwitchInput.indeterminate = false;\n cnSwitchInput.checked = false;\n break;\n case CookieStatus.wait:\n cnSwitchInput.indeterminate = true;\n cnSwitchInput.checked = false;\n break;\n }\n }\n }\n );\n });\n }\n\n switchToModalPageOrClose(): void {\n // * Modification du comportement du bouton, même si ca n'a pas de sens.\n // https://lab.s-web.fr/ldc-web/projets/ldc-web-cookie-notice/-/issues/9`\n\n if (this.isOnBannerPage()) {\n this.toggleCookieModalPages();\n return;\n }\n // * Pas de permutation en arrière\n this.closeCookieModal();\n }\n\n /**\n * Toggle Cookie modal pages\n */\n toggleCookieModalPages() {\n this.bannerContent.classList.toggle(\"d-none\");\n this.modalContainer.classList.toggle(\"d-none\");\n this.bannerContainer.classList.toggle(\"cn-modal-page\");\n if (!this.isOnBannerPage()) {\n this.bannerContainer.classList.add(\"cn-modal-page\");\n this.denyAllWaitingCookies();\n }\n this.setTabIndex();\n this.setupCookieModalList();\n this.togglePersonalizeBtn();\n }\n\n /**\n * Toggle customize btn\n */\n togglePersonalizeBtn() {\n const customizeBtnBannerDataset = this.customizeBtn.dataset;\n this.modalWrapper.scrollTop = 0;\n if (this.bannerContent.classList.contains(\"d-none\")) {\n this.customizeBtn.innerHTML =\n customizeBtnBannerDataset.openModal as string;\n this.customizeBtn.title = customizeBtnBannerDataset.openModal as string;\n } else {\n this.customizeBtn.innerHTML =\n customizeBtnBannerDataset.closeModal as string;\n this.customizeBtn.title = customizeBtnBannerDataset.closeModal as string;\n }\n }\n\n /**\n * Get the actual page: banner or modal (with cookie choices)\n */\n isOnBannerPage(): boolean {\n return this.modalContainer.classList.contains(\"d-none\");\n }\n\n /**\n * Invert cookie status\n *\n * @param status\n * @returns Inverted cookie status, `wait` will give `false`.\n */\n private invertCookieStatus(status: CookieStatus): CookieStatus {\n switch (status) {\n case CookieStatus.true:\n case CookieStatus.wait:\n return CookieStatus.false;\n case CookieStatus.false:\n return CookieStatus.true;\n default:\n throw new Error(`Un handled cookie status ${status}`);\n }\n }\n}\n\nenum CookieStatus {\n true = \"true\",\n false = \"false\",\n wait = \"wait\",\n}\n\ntype CookieStatusList = Record;\n\ntype CookiePolicy = {\n sameSite: CookiePolicySameSite;\n secure: string;\n};\n\nenum CookiePolicySameSite {\n lax = \"lax\",\n strict = \"strict\",\n none = \"none\",\n}\n\nexport type CookieOptions = {\n name: string;\n description: string;\n link: string;\n labelLink: string;\n cookies: string[];\n /**\n * Fonction qui sert à initialiser la fonctionnalité\n * conduisant à la génération du cookie\n * @return void\n */\n script: () => void;\n /**\n * Fonction qui sert à informer l'utilisateur\n * sur chaque élèment que le cookie\n * associé à la fonctionnalité\n * est désactivé et propose un lien sur\n * cookie notice pour l'activer\n * @return void\n */\n fallback: () => void | null;\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src;\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) {\n\t\t\tvar i = scripts.length - 1;\n\t\t\twhile (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;\n\t\t}\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","","// startup\n// Load entry module and return exports\n__webpack_require__(\"./src/ts/index.ts\");\n// This entry module doesn't tell about it's top-level declarations so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/scss/themes/standard.scss\");\n",""],"names":["CookieNotice","config","_this","_classCallCheck","_defineProperty","sameSite","CookiePolicySameSite","lax","secure","cookieExpirationDate","readCookiesExpirationDate","Date","setMonth","getMonth","cookieTimeLife","modalBg","document","createElement","classList","add","body","append","cookieContainer","querySelector","cookieShowModalBtn","cookieCloseModalBtn","cookieLinkShowCustomizeModalPageList","querySelectorAll","bannerContainer","bannerContent","modalContainer","acceptAllBtn","denyAllBtn","customizeBtn","cookiesUnorderedList","modalWrapper","template","Error","cookieLinkShowCustomizeModalList","memoryTemplate","cloneNode","remove","restrictCloseModal","addEventPrevent","closeCookieModal","acceptAllCookies","denyAllCookies","switchToModalPageOrClose","toggleCookieModal","forEach","cookieLink","openCookieModalToCookiePage","addEventKbdValidate","cookiesMatchesConfig","cookiesOlderThan","resetBrowserCookie","openCookieModalToBannerPage","updateRestrictCloseModal","Object","entries","getCookieStatusList","_ref","_ref2","_slicedToArray","cookieName","cookieStatus","CookieStatus","wait","true","script","fallback","_createClass","key","value","values","includes","_this$getBrowserCooki","_this2","cookies","getBrowserCookieValue","expirationDateString","split","find","cookieString","startsWith","cookieExpirationName","epochExpiration","Number","parseInt","replace","concat","isNaN","e","date","getTime","keys","length","_this3","acceptCookie","cookieOptions","getCookie","setCookieStatus","cnSwitch","getElementById","cnSwitchInput","checked","ariaChecked","_this4","denyCookie","false","denyAllWaitingCookies","_this5","_ref3","_ref4","setBrowserCookieStatus","_Object$entries$find","entry","undefined","_this6","statusList","filter","specificCookieString","containsCookieStatus","getCookieStatus","cookieIndex","status","cookieOption","addCookieStatus","removeCookieStatus","cookieNameElement","deleteBrowserCookie","saveBrowserCookie","hasBrowserCookie","Boolean","matches","cookie","match","RegExp","browserCookieName","decodeURIComponent","content","map","_ref5","_ref6","push","join","location","hostname","toUTCString","getCookiePoliciesAsString","cookiePolicies","_ref7","_ref8","policyName","policyValue","newCookieList","_ref9","_ref10","addEvent","element","evnt","funct","addEventListener","bind","_this7","preventDefault","call","_this8","kbdEvt","code","keyCode","contains","toggleCookieModalPages","resetCookieModal","scrollTop","setupCookieModalList","setTabIndex","isOnBannerPage","toggle","unsetTabIndex","_this9","documentElement","setAttribute","setTimeout","focusableSelector","_toConsumableArray","el","hasAttribute","getAttribute","offsetWidth","offsetHeight","getClientRects","_this10","dataset","openModal","innerHTML","_this11","_ref11","_ref12","cookieConfig","childItem","children","item","name","description","link","indeterminate","textContent","id","labelLink","toggleCookie","invertCookieStatus","click","_ref13","_ref14","ckName","togglePersonalizeBtn","customizeBtnBannerDataset","title","closeModal","default"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 2f79380..68ce051 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "build": "rm -rf ./dist/umd && webpack --progress && npm run buildbrowser", "buildbrowser": "rm -rf ./dist/browser && node ./node_modules/.bin/rollup --bundleConfigAsCjs -c rollup.config.js", "prebuild": "npm run stylelint && npm run eslint && rm -rf ./dist/typings && rm -rf ./dist/esm && tsc -p ./tsconfig.json", + "buildPackage": "git checkout main && git reset && git merge --no-ff --no-commit -m \"chore: 📦 Npm run build\" develop && npm run prebuild && npm run build && git add -f \"dist/\" && git commit --no-edit && echo 'DONE !!';", "eslint": "node ./node_modules/.bin/eslint --max-warnings 0 -c .eslintrc.json ./src", "eslint-fix": "node ./node_modules/.bin/eslint --fix --max-warnings 0 -c .eslintrc.json ./src", "eslint-ci": "node ./node_modules/.bin/eslint --max-warnings 0 -c .eslintrc.json ./src -f junit",