diff --git a/src/css/cookie.css b/src/css/cookie.css new file mode 100644 index 0000000..046d375 --- /dev/null +++ b/src/css/cookie.css @@ -0,0 +1,42 @@ +.cookie-bar{ + background-color: var(--cookie-background); + display: none; +} +.cookie-bar .privacy-settings { + max-height: 50vh; +} +.container-max{ + z-index: auto; + max-width: 1200px; + width: 100%; + padding-right: 15px; + padding-left: 15px; + margin-right: auto; + margin-left: auto; +} +.container-max p { + color: var(--navbar-font-color); +} +.container-max a { + color: var(--doc-font-color); +} +.cookie-bar .btn-appearance { + color: var(--cookie-button-color); + background-color: var(--cookie-button-background); + border-color: var(--cookie-button-border); +} +.custom-control-label { + color: var(--navbar-font-color); +} +#cookie-further-settings { + display: none; +} +.cookie-bar .flex-fill, .cookie-bar .card-text { + color: var(--plentyBluesTealBlue); +} +.cookie-bar .card-link { + color: var(--plentyBluesPacificBlue); +} +td.pl-3 { + width: 260px; +} diff --git a/src/css/dark-theme.css b/src/css/dark-theme.css index f5df293..4441a21 100644 --- a/src/css/dark-theme.css +++ b/src/css/dark-theme.css @@ -42,6 +42,10 @@ --footer-background-color: var(--plentyGreysLimedSpruce); --footer-link-font-color: var(--plenty-secondaries-white); --footer-link-hover-color: var(--link_hover-font-color); + --cookie-background: var(--plentyBluesTealBlue); + --cookie-button-background: var(--plentyBluesFadedJade); + --cookie-button-color: var(--plenty-secondaries-white); + --cookie-button-border: var(--plentyBluesFadedJade); /* docsearch */ --docsearch-searchbox-background: var(--plentyBluesTealBlue); --docsearch-muted-color: var(--color-white); diff --git a/src/css/light-theme.css b/src/css/light-theme.css index bc6e7db..78094d8 100644 --- a/src/css/light-theme.css +++ b/src/css/light-theme.css @@ -42,6 +42,10 @@ --footer-background-color: var(--plentyGreysLimedSpruce); --footer-link-font-color: var(--plenty-secondaries-white); --footer-link-hover-color: var(--link_hover-font-color); + --cookie-background: var(--plenty-secondaries-white); + --cookie-button-background: var(--plentyRedCrimson); + --cookie-button-color: var(--plenty-secondaries-white); + --cookie-button-border: var(--plentyRedCrimson); /* docsearch */ --docsearch-searchbox-background: var(--plenty-secondaries-white); --docsearch-muted-color: var(--plentyGreysLimedSpruce); diff --git a/src/css/site-light-theme.css b/src/css/site-light-theme.css index f76323a..82bc75c 100644 --- a/src/css/site-light-theme.css +++ b/src/css/site-light-theme.css @@ -25,5 +25,6 @@ @import "swagger-ui.css"; @import "plenty-icon-font.css"; @import "icon-colours.css"; +@import "cookie.css"; @import "search.css"; @import "responsive.css"; diff --git a/src/css/site.css b/src/css/site.css index ef7f0d9..c88dfc1 100644 --- a/src/css/site.css +++ b/src/css/site.css @@ -25,4 +25,5 @@ @import "swagger-ui.css"; @import "plenty-icon-font.css"; @import "icon-colours.css"; +@import "cookie.css"; @import "responsive.css"; diff --git a/src/helpers/i18n.js b/src/helpers/i18n.js index f5d28ca..e1c6a97 100644 --- a/src/helpers/i18n.js +++ b/src/helpers/i18n.js @@ -1,15 +1,64 @@ 'use strict' module.exports = (...data) => { - const currentLang = data[0] || 'en-gb' const path = process.cwd() - let trans = 'Lorem ipsum' + const currentLang = data[0] || 'en-gb' + const inputKey = data[1] + const splitKey = inputKey.split('.') + const splitKeyElements = splitKey.length + const keyElementZero = splitKey[0] + const keyElementOne = splitKey[1] + const keyElementTwo = splitKey[2] + const keyElementThree = splitKey[3] + const keyElementFour = splitKey[4] + const keyElementFive = splitKey[5] + const keyElementSix = splitKey[6] + const keyElementSeven = splitKey[7] + const keyElementEight = splitKey[8] + const keyElementNine = splitKey[9] + let translation = 'Lorem ipsum' + let langJson = '' if (process.env.GITHUB_ACTION) { - trans = require(path + '/lang/' + currentLang + '.json') + langJson = require(path + '/lang/' + currentLang + '.json') } else if (path.includes('plenty-docs-ui')) { - trans = require(path + '/public/_/lang/' + currentLang + '.json') + langJson = require(path + '/public/_/lang/' + currentLang + '.json') } else { - return trans + return translation + } + switch (splitKeyElements) { + case 1: + translation = langJson[keyElementZero] + break + case 2: + translation = langJson[keyElementZero][keyElementOne] + break + case 3: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo] + break + case 4: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree] + break + case 5: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree][keyElementFour] + break + case 6: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree][keyElementFour][keyElementFive] + break + case 7: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree][keyElementFour][keyElementFive][keyElementSix] + break + case 8: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree][keyElementFour][keyElementFive][keyElementSix][keyElementSeven] + break + case 9: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree][keyElementFour][keyElementFive][keyElementSix][keyElementSeven][keyElementEight] + break + case 10: + translation = langJson[keyElementZero][keyElementOne][keyElementTwo][keyElementThree][keyElementFour][keyElementFive][keyElementSix][keyElementSeven][keyElementEight][keyElementNine] + break + default: + translation = 'Lorem ipsum' + break } - return trans[data[1]] + return translation } diff --git a/src/js/13-cookies.js b/src/js/13-cookies.js new file mode 100644 index 0000000..e8dade9 --- /dev/null +++ b/src/js/13-cookies.js @@ -0,0 +1,126 @@ +const name = 'plenty-cookies' + +class Cookies { + constructor () { + this.addListeners() + if (document.cookie.indexOf(name) === -1) { + this.toggleCookies() + } + this.setDefaultSettings() + } + + addListeners () { + const acceptAllButton = document.getElementsByClassName('cookie-accept') + const acceptSelectedButton = document.getElementsByClassName('cookie-accept-selection') + const declineButton = document.getElementsByClassName('cookie-deny') + const showfurtherSettings = document.getElementById('show-cookie-further-settings') + const hidefurtherSettings = document.getElementById('hide-cookie-further-settings') + + acceptAllButton[0].addEventListener('click', () => { this.setCookie(true, true, true, true, true) }) + acceptSelectedButton[0].addEventListener('click', () => { + this.setCookie(this.consent, this.statistics.googleAnalytics, this.media.youtube, this.media.vimeo, this.functional.preferredLanguage) + }) + declineButton[0].addEventListener('click', () => { this.setCookie(true, false, false, false, false) }) + showfurtherSettings.addEventListener('click', () => { this.toggleExtraSettings('show') }) + hidefurtherSettings.addEventListener('click', () => { this.toggleExtraSettings('hide') }) + + document.querySelectorAll('.cookie-settings').forEach((item) => { + item.addEventListener('click', (event) => { + if (typeof this[item.getAttribute('source')] === 'object' && this[item.getAttribute('source')] !== null) { + if (item.getAttribute('target') !== null) { + this[item.getAttribute('source')][item.getAttribute('target')] = !this[item.getAttribute('source')][item.getAttribute('target')] + + let parentCheck = true + Object.keys(this[item.getAttribute('source')]).forEach((v) => { + if (!this[item.getAttribute('source')][v]) { + parentCheck = false + } + }) + + document.querySelectorAll('.cookie-settings[source="' + item.getAttribute('source') + '"]').forEach((v) => { + if (v !== item && v.getAttribute('target') === null) { + v.checked = parentCheck + } + }) + return + } + + Object.keys(this[item.getAttribute('source')]).forEach((v) => { + this[item.getAttribute('source')][v] = item.checked + }) + document.querySelectorAll('.cookie-settings[source="' + item.getAttribute('source') + '"]').forEach((v) => { + v.checked = item.checked + }) + document.querySelectorAll('.cookie-settings[source="' + item.getAttribute('source') + '"][target="' + item.getAttribute('target') + '"]').forEach((v) => { + v.checked = item.checked + }) + } + }) + }) + } + + toggleCookies (action) { + let display = 'block' + if (action === 'hide') { + display = 'none' + } + document.getElementsByClassName('cookie-bar')[0].style.display = display + } + + toggleExtraSettings (action) { + let cookieSettingsDisplay = 'none' + let cookieFurtherSettingsDisplay = 'block' + if (action === 'hide') { + cookieSettingsDisplay = 'flex' + cookieFurtherSettingsDisplay = 'none' + } + document.getElementById('cookie-further-settings').style.display = cookieFurtherSettingsDisplay + document.getElementById('cookie-settings').style.display = cookieSettingsDisplay + } + + setCookie (consent, googleAnalytics, youtube, vimeo, preferredLanguage) { + this.consent = consent + this.statistics.googleAnalytics = googleAnalytics + this.media.youtube = youtube + this.media.vimeo = vimeo + this.functional.preferredLanguage = preferredLanguage + document.cookie = name + '= ' + this.createCookie() + '; Secure' + this.toggleCookies('hide') + this.setDefaultSettings() + } + + createCookie () { + const cookie = {} + cookie.necessary = {} + cookie.tracking = {} + cookie.media = {} + cookie.convenience = {} + cookie.necessary.consent = this.consent + cookie.necessary.session = this.consent + cookie.necessary.csrf = this.consent + cookie.necessary.elasticSearch = this.consent + cookie.tracking.googleAnalytics = this.statistics.googleAnalytics + cookie.media.youtube = this.media.youtube + cookie.media.vimeo = this.media.vimeo + cookie.convenience.languageDetection = this.functional.preferredLanguage + return JSON.stringify(cookie) + } + + setDefaultSettings () { + this.consent = true + this.statistics = {} + this.statistics.googleAnalytics = false + this.media = {} + this.media.youtube = false + this.media.vimeo = false + this.functional = {} + this.functional.preferredLanguage = false + } +} + +(function () { + window.addEventListener('DOMContentLoaded', (event) => { + // eslint-disable-next-line no-new + new Cookies() + }) +})() diff --git a/src/lang/de-de.json b/src/lang/de-de.json index d68c8ac..7f07c71 100644 --- a/src/lang/de-de.json +++ b/src/lang/de-de.json @@ -22,6 +22,116 @@ "terms_and_conditions_text": "AGB", "terms_and_conditions_link": "https://www.plentymarkets.com/de/agb/", + "cookies_info": "Wir nutzen Cookies auf unserer Website. Einige von diesen sind essenziell, während andere uns helfen, diese Website und Ihre Erfahrung zu verbessern. Weitere Informationen zu den von uns verwendeten Cookies und Ihren Rechten als Nutzer finden Sie in unserer Datenschutzerklärung und unserem Impressum.", + "cookies_accept-selection": "Auswahl akzeptieren", + "cookies_accept-all": "Alle akzeptieren", + "cookies_reject-all": "Alle ablehnen", + "cookies_further_settings_label": "Weitere Einstellungen", + "cookies_further_settings_back": "Zurück", + + "cookies_more_information": "Mehr Informationen", + "cookies_essential_tag_label": "Essenziell", + "cookies_provider_label": "Anbieter", + "cookies_purpose_label": "Zweck", + "cookies_privacy_policy_label": "Datenschutzerklärung", + "cookies_lifespan_label": "Laufzeit", + + "cookies_essential-label": "Essenziell", + "cookies_essential": { + "amount": "5", + "description": "Essenzielle Cookies ermöglichen grundlegende Funktionen und sind für die einwandfreie Funktion der Website erforderlich.", + "cookies_convenience_label": "Komfort", + "cookies_consent_label": "Consent", + "cookies_session_label": "Session", + "cookies_csrf_label": "CSRF", + "cookies_elasticsearch_label": "Elasticsearch", + + "cookies_convenience": { + "provider": "plentymarkets", + "purpose": "Durch Komfort-Cookies wird das Browsen der Seite für dich angenehmer.", + "privacy_policy": "https://www.plentymarkets.com/de/datenschutz/", + "lifespan": "Session" + }, + + "cookies_consent": { + "provider": "plentymarkets", + "purpose": "Der Consent-Cookie speichert den Zustimmungsstatus des Benutzers für Cookies auf unserer Seite.", + "privacy_policy": "https://www.plentymarkets.com/de/datenschutz/", + "lifespan": "Session" + }, + + "cookies_session": { + "provider": "plentymarkets", + "purpose": "Der Session-Cookie behält die Zustände des Benutzers bei allen Seitenanfragen bei.", + "privacy_policy": "https://www.plentymarkets.com/de/datenschutz/", + "lifespan": "Session" + }, + + "cookies_csrf": { + "provider": "plentymarkets", + "purpose": "Der CSRF-Cookie dient dazu, Cross-Site Request Forgery-Angriffe zu verhindern.", + "privacy_policy": " +
+
+
+ + + + + + + +
+
+
+ +
+ + {{ i18n page.attributes.lang 'cookies_further_settings_back' }} + +
+ diff --git a/src/partials/cookie.hbs b/src/partials/cookie.hbs new file mode 100644 index 0000000..ce0ec46 --- /dev/null +++ b/src/partials/cookie.hbs @@ -0,0 +1,53 @@ + diff --git a/src/partials/footer-content.hbs b/src/partials/footer-content.hbs index 06915fa..7ef0dec 100644 --- a/src/partials/footer-content.hbs +++ b/src/partials/footer-content.hbs @@ -96,4 +96,5 @@ + {{> cookie}}