From b101d3952aec073bd107104f2d56206b559450ad Mon Sep 17 00:00:00 2001 From: Olivier Legat Date: Fri, 24 Sep 2021 15:15:32 +0200 Subject: [PATCH] Add Cookie management --- wp-config.php | 25 +- .../themes/pole-sbv/css/cookies-ldc.css | 585 ++++++++++++++++++ wp-content/themes/pole-sbv/footer.php | 115 ++++ wp-content/themes/pole-sbv/functions.php | 7 + wp-content/themes/pole-sbv/header.php | 1 + wp-content/themes/pole-sbv/js/ldcweb-cn.js | 323 ++++++++++ .../pole-sbv/mentionslegales_en_template.php | 43 ++ .../pole-sbv/mentionslegales_template.php | 11 +- .../themes/pole-sbv/privacy_en_template.php | 43 ++ .../themes/pole-sbv/privacy_template.php | 43 ++ 10 files changed, 1183 insertions(+), 13 deletions(-) create mode 100644 wp-content/themes/pole-sbv/css/cookies-ldc.css create mode 100644 wp-content/themes/pole-sbv/js/ldcweb-cn.js create mode 100644 wp-content/themes/pole-sbv/mentionslegales_en_template.php create mode 100644 wp-content/themes/pole-sbv/privacy_en_template.php create mode 100644 wp-content/themes/pole-sbv/privacy_template.php diff --git a/wp-config.php b/wp-config.php index 569f5fbe..103ae6f8 100755 --- a/wp-config.php +++ b/wp-config.php @@ -72,14 +72,23 @@ define('DB_COLLATE', ''); * * @since 2.6.0 */ -define('AUTH_KEY', '3lxfhsfr7vvueubusinfq6wh3jzcct0dpokf9wvlesvyqctufzjrsjctkxomfkai'); -define('SECURE_AUTH_KEY', 'g8shsentpna4xjwd2hrndysspzqstjqhshl5ltojzfx2jt00mmgv5erkv9hhzfks'); -define('LOGGED_IN_KEY', 'bttywkfpheo5alewblait7g63ztfsoiscbrerdbzeinwt0qzyl3nopohusmoffo6'); -define('NONCE_KEY', 'g9vf7ljkcjkpgdtejb2rscp53u4lbhoezdzdytomoudzsibrsqh0lwn9rtcfgc8s'); -define('AUTH_SALT', 'maxi2iuf7im4jyxok9o9phyuwtesnqdvxpes8cbv6rcjglj4ksqbokhtafqlodm2'); -define('SECURE_AUTH_SALT', 'fxzzvwcjmq4gar1pmhgkhrdzgx2h8c8euy5ux3t5s4h9gu686hg6euxop5ahvqp1'); -define('LOGGED_IN_SALT', 'yxhrdruruy18h4euqzayua2avomvrjqdolujk66waswrx3kywpxuxwvbetnn1ymx'); -define('NONCE_SALT', 'h2xmi72rczdra3rx8gimpnhhztx1oudvlq5zsuufpztg6iipng6pyfpzwdh336x0'); +// define('AUTH_KEY', '3lxfhsfr7vvueubusinfq6wh3jzcct0dpokf9wvlesvyqctufzjrsjctkxomfkai'); +// define('SECURE_AUTH_KEY', 'g8shsentpna4xjwd2hrndysspzqstjqhshl5ltojzfx2jt00mmgv5erkv9hhzfks'); +// define('LOGGED_IN_KEY', 'bttywkfpheo5alewblait7g63ztfsoiscbrerdbzeinwt0qzyl3nopohusmoffo6'); +// define('NONCE_KEY', 'g9vf7ljkcjkpgdtejb2rscp53u4lbhoezdzdytomoudzsibrsqh0lwn9rtcfgc8s'); +// define('AUTH_SALT', 'maxi2iuf7im4jyxok9o9phyuwtesnqdvxpes8cbv6rcjglj4ksqbokhtafqlodm2'); +// define('SECURE_AUTH_SALT', 'fxzzvwcjmq4gar1pmhgkhrdzgx2h8c8euy5ux3t5s4h9gu686hg6euxop5ahvqp1'); +// define('LOGGED_IN_SALT', 'yxhrdruruy18h4euqzayua2avomvrjqdolujk66waswrx3kywpxuxwvbetnn1ymx'); +// define('NONCE_SALT', 'h2xmi72rczdra3rx8gimpnhhztx1oudvlq5zsuufpztg6iipng6pyfpzwdh336x0'); + +define('AUTH_KEY', 'J;E.R(2Sf?85#m~6e)nsQH+0H A/Sm^,mQ`ui79`ak8.la/(#P*}~wx6Ju|6rS|o'); +define('SECURE_AUTH_KEY', 'e#%_g|$gtt[U1)+%+O||H#Ow!=,$]4T~&N>qkKb!O-m^0i4W<#5wRH>ki6fB>A*B'); +define('LOGGED_IN_KEY', 'ZyR?_G-u?i[X X_ogeCe55+Mwa8n%)MGq8Bk&@@! div:not(:first-of-type){width: 100%;} +#ldcweb-cn-modal .modal-btn-close{ + position: absolute; + right: 0; + top: 0; + width: 5vw; height: 6vw; + display: flex; + justify-content: center; + align-items: center; +} +#ldcweb-cn-modal .modal-btn-close a{ + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + + font-family: Arial, Helvetica, sans-serif; + font-size: medium; + font-weight: bold; + color: var(--ck-w2-color-title); + background-color: var(--ck-w2-bgcolor-title); + text-decoration: none; + border-radius: 0 0 0 50%; + transition: all .5s; +} +#ldcweb-cn-modal .modal-btn-close a:hover{ + color: #000000; + background-color: #808080; + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); + box-shadow: -1px 1px 10px -4px #000; +} +#ldcweb-cn-modal .modal-title, #ldcweb-cn-modal .modal-all + {background-color: var(--ck-w2-bgcolor-title);} +#ldcweb-cn-modal .modal-title .description, +#ldcweb-cn-modal .modal-title > div, +#ldcweb-cn-modal .modal-all{ + display: flex; + flex-direction: column; + align-items: center; +} +#ldcweb-cn-modal .modal-title .description, +#ldcweb-cn-modal .modal-title > div a, +#ldcweb-cn-modal .modal-all p, +#ldcweb-cn-modal .modal-all a{ + font-family: var(--ck-w2-font-family-txt); + font-size: var(--ck-w2-font-size-txt); + color: var(--ck-w2-color-txt); + text-align: center; +} +#ldcweb-cn-modal .modal-title > div a:hover, +#ldcweb-cn-modal .modal-all a:hover + {color: var(--ck-w2-color-href-hover);} +/* TITLE */ +#ldcweb-cn-modal .modal-wrapper .modal-title{padding: 4vw;} +#ldcweb-cn-modal .modal-title .title{ + font-family: var(--ck-w2-font-family-title); + font-size: var(--ck-w2-font-size-title); + font-weight: bold; + color: var(--ck-w2-color-title); + text-align: center; +} +#ldcweb-cn-modal .modal-title .title::after, +#ldcweb-cn-modal .modal-title > div::after{ + content: ""; + display: block; + width: 90%; height: 2px; + margin: 4vw auto; + + background-color: rgba(255, 255, 255, .5); +} +#ldcweb-cn-modal .modal-title a{width: fit-content;} +/* ALL */ +#ldcweb-cn-modal .modal-wrapper .modal-all{padding: 0 4vw 4vw;} +#ldcweb-cn-modal .modal-all .all-buttons{ + display: flex; + flex-direction: column; + align-items: center; +} +#ldcweb-cn-modal .modal-all .all-buttons > div{ + width: calc(100% + 15vw); + margin: 2vw 0 0; +} +#ldcweb-cn-modal .modal-all a{ + display: block; + padding: 3vw 0; + + color: var(--ck-color-txt); + /* font-weight: bold; */ + text-decoration: none; + transition: all .5s; +} +#ldcweb-cn-modal .all-buttons > div.accept > a.active { + background-color: var(--ck-color-accept-hover); + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +#ldcweb-cn-modal .all-buttons > div.deny > a.active { + background-color: var(--ck-color-deny-hover); + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +#ldcweb-cn-modal .modal-all > div > div:first-of-type a{background-color: var(--ck-color-accept);} +#ldcweb-cn-modal .modal-all > div > div:last-of-type a{background-color: var(--ck-color-deny);} +#ldcweb-cn-modal .modal-all > div > div:first-of-type a:hover{ + color: var(--ck-color-txt-hover); + background-color: var(--ck-color-accept-hover); + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +#ldcweb-cn-modal .modal-all > div > div:last-of-type a:hover{ + color: var(--ck-color-txt-hover); + background-color: var(--ck-color-deny-hover); + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +/* DETAILS */ +#ldcweb-cn-modal .modal-wrapper .modal-details{padding: 2vw 0;} +#ldcweb-cn-modal .modal-details ul{ + display: flex; + flex-direction: column; +} +#ldcweb-cn-modal .modal-details li > div{ + display: flex; + flex-direction: column; + justify-content: space-between; + margin: 2vw 0; + padding: 2vw 4vw; + + background-color: var(--ck-bgcolor-list); +} +#ldcweb-cn-modal .modal-details li span, +#ldcweb-cn-modal .modal-details li a, +#ldcweb-cn-modal .modal-details li label{ + font-family: var(--ck-font-family-list); + font-size: var(--ck-font-size-list); + color: var(--ck-color-list); +} +#ldcweb-cn-modal .modal-details li a:hover{color:var(--secondary-color);} +#ldcweb-cn-modal .modal-details .ldcweb-cn-infos{ + display: flex; + flex-direction: column; + flex: 1; +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-infos span:first-of-type{ + font-size: calc(var(--ck-font-size-list) * 1.25); + font-weight: bold; +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-infos a{width: fit-content;} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons{display: flex;} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type, +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:last-of-type + {transition: all .5s;} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type{ + margin-right: 2vw; + background: var(--ck-color-accept); +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:last-of-type{background: var(--ck-color-deny);} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div{ + width: 25vw; + margin: 2vw 0; + display: table; + + /* font-weight: bold; */ + text-align: center; +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type:hover, +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:last-of-type:hover{ + cursor: pointer; + background: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:hover > label{color: var(--ck-color-txt-hover);} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type input:checked ~ label, +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type input ~label.active{ + background-color: var(--ck-color-accept-hover); + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:last-of-type input:checked ~ label, +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:last-of-type input ~ label.active{ + background-color: var(--ck-color-deny-hover); + background-image: linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.5)); +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons input{display: none;} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons label{ + display: block; + padding: 1.5vw 0; + + color: var(--ck-color-txt); + transition: color .5s; +} +#ldcweb-cn-modal .modal-details .ldcweb-cn-buttons label:hover{ + cursor: pointer; + color: var(--ck-color-txt-hover); +} + +/* ************************* */ +/* ** ** */ +/* ************************* */ +/* ** ** */ +/* ** ** */ +/* ** ** */ +/* ** ** */ +/* ** ** */ +/* ** ** */ +/* ** ** */ +/* ******* */ +@media only screen and (min-width:768px) { + #ldcweb-cn .ldcweb-cn-banner{ + padding-top: 4vw; + padding-bottom: 4vw; + } + #ldcweb-cn .btns {flex-direction: row;} + #ldcweb-cn .btns > div:first-child, + #ldcweb-cn .btns > div:last-child + {margin-top: 0;} + #ldcweb-cn .btns > div:not(:last-child) {margin: 0 2vw 0 0;} + + /* MODAL */ + #ldcweb-cn-modal .modal-wrapper{width: 90vw;} + /* ALL */ + #ldcweb-cn-modal .modal-all{ + flex-direction: row; + justify-content: space-between; + } + #ldcweb-cn-modal .modal-all a{padding: 2vw 0;} + #ldcweb-cn-modal .modal-all .all-buttons > div{margin: 0;} + #ldcweb-cn-modal .modal-all .all-buttons > div:last-of-type{margin: 1vw 0 0;} + #ldcweb-cn-modal .modal-all a{width: 30vw;} + /* DETAILS */ + #ldcweb-cn-modal .modal-details li > div{flex-direction: row;} + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons{flex-direction: column;} + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div{ + width: 20vw; + margin: 0; + } + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type{margin: 0 0 1vw;} +} + +/* **** */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* **** */ +@media only screen and (min-width:1024px) { + #ldcweb-cn .ldcweb-cn-banner{ + flex-direction: row; + align-items: flex-start; + justify-content: space-between; + padding: 2vw 3vw; + } + #ldcweb-cn .ldcweb-cn-banner div:not(:last-child){margin: 0 0 .5em 0;} + #ldcweb-cn .ldcweb-cn-banner > div:not(:last-child){margin: 0 4vw 0 0;} + #ldcweb-cn .ldcweb-cn-banner .banner-img{ + height: 100%; + display: flex; + align-items: center; + } + #ldcweb-cn .banner-img img{height: fit-content;} + + #ldcweb-cn .banner-txt{text-align: start;} + #ldcweb-cn .btns { + height: 100%; + flex-direction: column; + justify-content: center; + } + #ldcweb-cn .btns > div:first-child .btn{margin: 0;} + /* MODAL */ + #ldcweb-cn-modal .modal-wrapper{width: 80vw;} + #ldcweb-cn-modal .modal-btn-close{ + width: 3vw; + height: 3vw; + } + /* TITLE */ + #ldcweb-cn-modal .modal-wrapper .modal-title{padding: 2vw;} + #ldcweb-cn-modal .modal-title .title::after, + #ldcweb-cn-modal .modal-title > div::after{margin: 2vw auto;} + /* ALL */ + #ldcweb-cn-modal .modal-wrapper .modal-all{padding: 0 2vw 2vw;} + #ldcweb-cn-modal .modal-all a{padding: 1.5vw 0;} + #ldcweb-cn-modal .modal-all .all-buttons{flex-direction: row;} + #ldcweb-cn-modal .modal-all .all-buttons > div:first-of-type{margin: 0 1vw 0 0;} + #ldcweb-cn-modal .modal-all .all-buttons > div:last-of-type{margin: 0;} + #ldcweb-cn-modal .modal-all a{width: 22vw;} + /* DETAILS */ + #ldcweb-cn-modal .modal-wrapper .modal-details{padding: 1vw 0;} + #ldcweb-cn-modal .modal-details li > div{ + margin: 1vw 0; + padding: 2vw; + } + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons{ + flex-direction: row; + align-items: center; + } + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div{ + width: 10vw; + margin: 0; + } + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type{margin: 0 1vw 0;} + +} + +/* ******** */ +/* * ***** * */ +/* * * * * */ +/* *** * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * * */ +/* * ************** */ +/* * * */ +/* ***************** */ +@media only screen and (min-width: 1440px) { + #ldcweb-cn .col{flex: 4;} + /* MODAL */ + #ldcweb-cn-modal .modal-wrapper{width: 60vw;} + #ldcweb-cn-modal .modal-btn-close{ + width: 2vw; + height: 2vw; + } + /* ALL */ + #ldcweb-cn-modal .modal-all .all-buttons > div:first-of-type{margin: 0 1vw 0 0;} + #ldcweb-cn-modal .modal-all a{ + width: 15vw; + padding: 1vw 0; + } + /* DETAILS */ + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div{width: 8vw;} + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons label{padding: 1vw 0;} +} + +/* ************ */ +/* * **** */ +/* ********* * */ + /* ***** * */ + /* ** * */ + /* ** * */ +/* ********** * */ +/* * * */ +/* ********* * */ + /* ***** * */ + /* ** * */ + /* ** * */ +/* ********** * */ +/* * *** */ +/* ************ */ +@media only screen and (min-width: 1920px) { + #ldcweb-cn p{font-size: calc(var(--ck-w1-font-size-txt) * 1.25);} + #ldcweb-cn .banner-title p{font-size: calc(var(--ck-w1-font-size-title) * 1.25);} + #ldcweb-cn .btns .btn {font-size: calc(var(--ck-w1-font-size-btn-txt) * 1.25);} + + /* MODAL */ + #ldcweb-cn-modal .modal-wrapper{width: 50vw;} + #ldcweb-cn-modal .modal-btn-close{ + width: 2rem; + height: 2rem; + } + #ldcweb-cn-modal .modal-title .description, + #ldcweb-cn-modal .modal-title > div a, + #ldcweb-cn-modal .modal-all p, + #ldcweb-cn-modal .modal-all a + {font-size: calc(var(--ck-w2-font-size-txt) * 1.25);} + /* TITLE */ + #ldcweb-cn-modal .modal-wrapper .modal-title{padding: 1vw;} + #ldcweb-cn-modal .modal-title .title{font-size: calc(var(--ck-w2-font-size-title) * 1.25);} + #ldcweb-cn-modal .modal-title .title::after, + #ldcweb-cn-modal .modal-title > div::after{margin: 1vw auto;} + /* ALL */ + #ldcweb-cn-modal .modal-wrapper .modal-all{padding: 0 1vw 1vw;} + #ldcweb-cn-modal .modal-all a{ + width: 13vw; + padding: .5vw 0; + } + /* DETAILS */ + #ldcweb-cn-modal .modal-wrapper .modal-details{padding: .5vw 0;} + #ldcweb-cn-modal .modal-details li > div{ + margin: .5vw 0; + padding: 1vw; + } + #ldcweb-cn-modal .modal-details li span, + #ldcweb-cn-modal .modal-details li a, + #ldcweb-cn-modal .modal-details li label + {font-size: calc(var(--ck-font-size-list) * 1.25);} + #ldcweb-cn-modal .modal-details .ldcweb-cn-infos span:first-of-type{font-size: calc(var(--ck-font-size-list) * 1.5);} + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons{ + flex-direction: row; + align-items: center; + } + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div{width: 5vw;} + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons div:first-of-type{margin: 0 1vw 0;} + #ldcweb-cn-modal .modal-details .ldcweb-cn-buttons label{padding: .5vw 0;} +} \ No newline at end of file diff --git a/wp-content/themes/pole-sbv/footer.php b/wp-content/themes/pole-sbv/footer.php index 1212c8b7..a5bcebd0 100644 --- a/wp-content/themes/pole-sbv/footer.php +++ b/wp-content/themes/pole-sbv/footer.php @@ -38,12 +38,126 @@ + + +
+
+ +
+ + +
+ +
+
+ +
+
+ + + + + + + + diff --git a/wp-content/themes/pole-sbv/functions.php b/wp-content/themes/pole-sbv/functions.php index ca904f35..616e3932 100644 --- a/wp-content/themes/pole-sbv/functions.php +++ b/wp-content/themes/pole-sbv/functions.php @@ -104,6 +104,7 @@ pll_register_string( "Nos solutions au service de nos clients footer", "Nos sol pll_register_string( "Tous droits réservés", "Tous droits réservés", 'Footer'); pll_register_string( "Tous droits réservés", "Tous droits réservés", 'Footer'); pll_register_string( "Mentions légales", "Mentions légales", 'Footer'); +pll_register_string( "Gestion des cookies", "Gestion des cookies", 'Footer'); pll_register_string( "Coordonnées SBV", "Coordonnées SBV", 'Footer'); pll_register_string( "Tél :", "Tél :", 'Footer'); @@ -169,6 +170,12 @@ function mytheme_ninja_forms_translate( $label ){ } +/* +// --------------------------------------------------------------------- +// SCRIPTS +// --------------------------------------------------------------------- +*/ + /******************************************************************* SMTP Mail/HTML Mail *******************************************************************/ diff --git a/wp-content/themes/pole-sbv/header.php b/wp-content/themes/pole-sbv/header.php index f3f92e7a..aa91186e 100644 --- a/wp-content/themes/pole-sbv/header.php +++ b/wp-content/themes/pole-sbv/header.php @@ -25,6 +25,7 @@ + diff --git a/wp-content/themes/pole-sbv/js/ldcweb-cn.js b/wp-content/themes/pole-sbv/js/ldcweb-cn.js new file mode 100644 index 00000000..dde78660 --- /dev/null +++ b/wp-content/themes/pole-sbv/js/ldcweb-cn.js @@ -0,0 +1,323 @@ +/** + * LDC Service Web + * Version 1.1 + */ + +class LdcwebCn { + + constructor(config) { + this.config = config; + this.cookieContainer = document.getElementById('ldcweb-cn'); + this.bannerContainer = document.getElementById('ldcweb-banner'); + this.modalContainer = document.getElementById('ldcweb-cn-modal'); + this.modalCloseBtn = document.getElementById('close-link'); + this.acceptAllBtnBanner = document.getElementById('ldcweb-cn-accept-banner'); + this.denyAllBtnBanner = document.getElementById('ldcweb-cn-deny-banner'); + this.acceptAllBtn = document.getElementById('ldcweb-cn-accept'); + this.denyAllBtn = document.getElementById('ldcweb-cn-deny'); + this.personalizeBtn = document.getElementsByClassName('ldcweb-cn-personalize'); + this.changeBtn = document.getElementsByClassName('ldcweb-cn-change'); + this.cookiesList = document.getElementById('ldcweb-cn-list'); + this.cookieLink = document.getElementsByClassName('ldcweb-cn-cookie-link'); + this.template = document.getElementById('template').cloneNode(true); + document.getElementById('template').remove(); + + let cookies = this.getLDCWebCookie('ldcwebcn-init'); + if (cookies === undefined) { + let newCookie = []; + + for (const [key, value] of Object.entries(this.config)) { + newCookie.push(key + "=wait"); + } + + this.saveLDCWebCookie(newCookie); + this.cookieContainer.classList.add('open-banner'); + } else { + let test = cookies.split(','); + test.forEach(elm => { + let test = elm.split('='); + if (test[1] === 'wait') { + this.cookieContainer.classList.add('open-banner'); + } + }); + } + this.modalCloseBtn.addEventListener( + 'click', + function (e) { + e.preventDefault(); + let cookies = this.getLDCWebCookie('ldcwebcn-init'); + let test = cookies.split(','); + let bIsCompleted = true; + for (let item of test) { + if (item.indexOf('=wait') !== -1) { + bIsCompleted = false; + break; + } + } + if (bIsCompleted) { + this.cookieContainer.classList.remove('open-modal'); + this.cookieContainer.classList.remove('open-banner'); + } else { + alert("Vous devez renseigner votre choix pour tous les cookies, svp."); + } + }.bind(this) + ); + let accept = function (e) { + e.preventDefault(); + for (const [key, value] of Object.entries(this.config)) { + this.addCookie(key, value); + } + for (let acceptLabel of this.cookieContainer.querySelectorAll('.accept > label')) { + acceptLabel.classList.add('active'); + } + for (let denyLabel of this.cookieContainer.querySelectorAll('.deny > label')) { + denyLabel.classList.remove('active'); + } + this.updateAllCookiesButtonsActiveStatus(); + this.cookieContainer.classList.remove('open-modal'); + this.cookieContainer.classList.remove('open-banner'); + }.bind(this); + this.acceptAllBtnBanner.addEventListener('click', accept); + this.acceptAllBtn.addEventListener('click', accept); + + let deny = function (e) { + e.preventDefault(); + for (const [key, value] of Object.entries(this.config)) { + this.removeCookie(key, value); + } + for (let acceptLabel of this.cookieContainer.querySelectorAll('.accept > label')) { + acceptLabel.classList.remove('active'); + } + for (let denyLabel of this.cookieContainer.querySelectorAll('.deny > label')) { + denyLabel.classList.add('active'); + } + this.updateAllCookiesButtonsActiveStatus(); + this.cookieContainer.classList.remove('open-modal'); + this.cookieContainer.classList.remove('open-banner'); + }.bind(this); + this.denyAllBtnBanner.addEventListener('click', deny); + this.denyAllBtn.addEventListener('click', deny); + + for (let item of this.cookieLink) { + this.addEvent( + item, + 'click', + function (e) { + e.preventDefault(); + this.openModal(); + }.bind(this) + ); + } + + for (let item of this.personalizeBtn) { + this.addEvent( + item, + 'click', + function (e) { + e.preventDefault(); + this.setCookieList(); + }.bind(this) + ); + } + + this.setListenerOnChange(); + + let cookie = this.getLDCWebCookie('ldcwebcn-init'); + let test = cookie.split(','); + test.forEach(elm => { + let test = elm.split('='); + if (test[1] === 'true') { + this.config[test[0]].script(); + }else{ + if (this.config[test[0]].fallback !== undefined){ + this.config[test[0]].fallback(); + } + } + }); + + this.updateAllCookiesButtonsActiveStatus(); + } + + setCookieList() { + this.cookiesList.innerHTML = ""; + let cookiesSite = this.getLDCWebCookie('ldcwebcn-init'); + let acceptInputEvent = function(acceptLabel, denyLabel, key, value) { + return function (e) { + acceptLabel.classList.add('active'); + denyLabel.classList.remove('active'); + this.updateAllCookiesButtonsActiveStatus(); + this.addCookie(key, value); + }.bind(this, [acceptLabel, denyLabel, key, value]); + }; + let denyInputEvent = function(acceptLabel, denyLabel, key, value) { + return function (e) { + acceptLabel.classList.remove('active'); + denyLabel.classList.add('active'); + this.updateAllCookiesButtonsActiveStatus(); + this.removeCookie(key, value); + }.bind(this, [acceptLabel, denyLabel, key, value]); + }; + + for (const [key, value] of Object.entries(this.config)) { + let cookie = document.createElement('li'); + cookie.append(this.template.children.item(0).cloneNode(true)); + let name = cookie.querySelector('span.ldcweb-cn-name'); + let description = cookie.querySelector('span.ldcweb-cn-description'); + let link = cookie.querySelector('a.ldcweb-cn-link'); + let acceptInput = cookie.querySelector('.accept > input'); + let denyInput = cookie.querySelector('.deny > input'); + let acceptLabel = cookie.querySelector('.accept > label'); + let denyLabel = cookie.querySelector('.deny > label'); + + name.textContent = value.name; + description.textContent = value.description; + link.textContent = "En savoir plus"; + link.setAttribute("href", value.link); + acceptInput.id = key + '1'; + acceptInput.name = key; + acceptInput.dataset.name = key; + acceptLabel.htmlFor = key + '1'; + denyInput.id = key + '2'; + denyInput.name = key; + denyInput.dataset.name = key; + denyLabel.htmlFor = key + '2'; + + acceptInput.addEventListener('click', acceptInputEvent.apply(this, [acceptLabel, denyLabel, key, value])); + denyInput.addEventListener('click', denyInputEvent.apply(this, [acceptLabel, denyLabel, key, value])); + + this.cookiesList.append(cookie); + + let cookiesArray = cookiesSite.split(','); + for (const cookieEl of cookiesArray) { + let name = cookieEl.slice(0, cookieEl.indexOf('=')); + let status = cookieEl.slice(cookieEl.indexOf('=') + 1); + if (name === key) { + acceptLabel.classList.remove('active'); + denyLabel.classList.remove('active'); + switch (status) { + case 'true': + acceptLabel.classList.add('active'); + break; + case 'false': + denyLabel.classList.add('active'); + break; + } + } + if (status === 'wait') { + this.cookieContainer.classList.add('open-banner'); + } + } + } + + this.cookieContainer.classList.add('open-modal'); + this.setListenerOnChange(); + } + + updateAllCookiesButtonsActiveStatus() { + let acceptsButtons = this.cookieContainer.querySelectorAll('div.accept > label'); + let deniesButtons = this.cookieContainer.querySelectorAll('div.deny > label'); + let activeAcceptsButtons = this.cookieContainer.querySelectorAll('div.accept > label.active'); + let activeDeniesButtons = this.cookieContainer.querySelectorAll('div.deny > label.active'); + + this.acceptAllBtn.classList.remove('active'); + this.denyAllBtn.classList.remove('active'); + if (acceptsButtons.length && acceptsButtons.length === activeAcceptsButtons.length) { + this.acceptAllBtn.classList.add('active'); + } + if (deniesButtons.length && deniesButtons.length === activeDeniesButtons.length) { + this.denyAllBtn.classList.add('active'); + } + } + + addCookie(key, value) { + if (value.script) { + value.script(); + } + this.changeStatus(key, "true"); + } + + removeCookie(key, value) { + for (let cookieName of value.cookies) { + this.deleteBrowserCookie(cookieName, "/", "." + location.host); + } + if (document.getElementById(key)) { + document.getElementById(key).remove(); + } + this.changeStatus(key, "false"); + } + setListenerOnChange() { + this.changeBtn = document.getElementsByClassName('ldcweb-cn-change'); + let itemClick = function(item) { + return function () { + this.changeStatus(item.getAttribute('data-name'), item.getAttribute('data-status')); + }.bind(this); + }; + for (let item of this.changeBtn) { + this.addEvent( + item, + 'click', + itemClick.bind(this, [item]) + ); + } + } + + changeStatus(name, status) { + let newCookie = []; + + let cookie = this.getLDCWebCookie('ldcwebcn-init'); + let test = cookie.split(','); + test.forEach(elm => { + let test = elm.split('='); + if (test[0] === name) { + newCookie.push(name + "=" + status); + if (status === 'false') { + this.config[test[0]].cookies.forEach(elm => { + let cookies = this.getLDCWebCookie(elm); + if (cookies !== undefined) { + document.cookie = elm + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; domain=" + document.domain + "; path=/"; + document.cookie = elm + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; domain=." + document.domain + "; path=/"; + } + }); + } + } else { + newCookie.push(elm); + } + }); + + this.saveLDCWebCookie(newCookie); + } + + deleteBrowserCookie(name, path, domain) { + if (this.getLDCWebCookie(name)) { + document.cookie = name + "=" + + ((path) ? ";path=" + path : "") + + ((domain) ? ";domain=" + domain : "") + + ";expires=Thu, 01 Jan 1970 00:00:01 GMT"; + } + } + + getLDCWebCookie(name) { + let matches = document.cookie.match(new RegExp( + "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" + )); + return matches ? decodeURIComponent(matches[1]) : undefined; + } + + addEvent(element, evnt, funct) { + if (element.attachEvent) + return element.attachEvent('on' + evnt, funct); + else + return element.addEventListener(evnt, funct, false); + } + + saveLDCWebCookie(content) { + let date = new Date(); + let newDate = new Date(date.setMonth(date.getMonth() + 13)); + document.cookie = "ldcwebcn-init=" + content + "; expires=" + newDate.toUTCString() + "; path=/;"; + } + + openModal() { + this.setCookieList(); + this.updateAllCookiesButtonsActiveStatus(); + } +} diff --git a/wp-content/themes/pole-sbv/mentionslegales_en_template.php b/wp-content/themes/pole-sbv/mentionslegales_en_template.php new file mode 100644 index 00000000..2c9608f0 --- /dev/null +++ b/wp-content/themes/pole-sbv/mentionslegales_en_template.php @@ -0,0 +1,43 @@ + + + +
+
+
+ +
+
+
+ + + + diff --git a/wp-content/themes/pole-sbv/mentionslegales_template.php b/wp-content/themes/pole-sbv/mentionslegales_template.php index 341c8b42..0ac13735 100644 --- a/wp-content/themes/pole-sbv/mentionslegales_template.php +++ b/wp-content/themes/pole-sbv/mentionslegales_template.php @@ -4,16 +4,19 @@ * @package WordPress */ get_header(); ?> - +