ldc-wenn-dann-mit-respekt/resources/views/fo/vendor/ldcweb-cookies.blade.php
Jérémy Munsch 0ba88f51eb
Closes #37
2024-06-10 13:58:45 +02:00

242 lines
9.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{-- blade-formatter-disable --}}
@php
$site_name = Str::ucfirst(config('app.name'));
$logo_picture_url = Vite::asset('resources/assets/images/Icons/logo-nature-respect.svg');
$logo_title_text = __('Logo du site :name', ['name' => $site_name]);
$logo_alt_text = __('Logo :name', ['name' => $site_name]);
$logo_title_text = Str::ucfirst(__('cookie-notice.logo_title_text', ['name' => $site_name]));
$logo_alt_text = Str::ucfirst(__('cookie-notice.logo_alt_text'));
$strings = (object)[
'modal_title' => __('cookie-notice.modal_title'),
'button_customize_cookies' => __('cookie-notice.button_customize_cookies'),
'button_close_cookies' => __('cookie-notice.button_close_cookies'),
'button_title_open_new_tab' => __('cookie-notice.button_title_open_new_tab'),
'button_toggle_cookie' => __('cookie-notice.button_toggle_cookie'),
'button_forbid_all' => Str::upper(__('cookie-notice.button_forbid_all')),
'button_allow_all' => Str::upper(__('cookie-notice.button_allow_all')),
'button_customize' => Str::upper(__('cookie-notice.button_customize')),
'button_forbid_all_title' => __('cookie-notice.button_forbid_all_title'),
'button_allow_all_title' => __('cookie-notice.button_allow_all_title'),
'button_validate_and_close' => Str::upper(__('cookie-notice.button_validate_and_close')),
'banner_title' => __('cookie-notice.banner_title', ['site_name' => $site_name]),
'banner_text' => sprintf(
"%s<br><br>%s",
__('cookie-notice.banner_text'),
"<a class='underline' href='" . route('privacy') . "'>" . __('Privacy Policy') . "</a>"
),
'panel_title' => __('cookie-notice.panel_title'),
'panel_content' => __('cookie-notice.panel_content'),
'panel_subtitle' => __('cookie-notice.panel_subtitle'),
'panel_details' => __('cookie-notice.panel_details'),
'picture_cookie_title' => __('cookie-notice.picture_cookie_title'),
'navigation_title' => __('cookie-notice.navigation_title'),
];
$cookies = [];
// YOUTUBE
$cookies['youtube'] = [
'name' => 'VIDEOS - Youtube',
'description' => __('Les cookies déposés via les services de partage de vidéo ont pour finalité de permettre à l’utilisateur de visionner directement sur le site le contenu multimédia.'),
'link' => 'https://policies.google.com/technologies/cookies?hl=fr&utm_source=ucb',
'labelLink' => __('En savoir +'),
'cookies' => ['NID', 'VISITOR_INFO1_LIVE', 'YSC']
];
$cookies['youtube']['script'] = <<<SCRIPT
function () {
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
if (el.dataset.cookieName === 'youtube') {
el.classList.add('d-none');
}
});
// * Video inlaid.
const videoInlaidList = document.querySelectorAll('.video-inlaid[type="youtube"]');
for (const videoLink of videoInlaidList) {
if (!videoLink.getAttribute("type")) {
throw new Error("Missing attribute type");
}
if (!videoLink.getAttribute("href")) {
throw new Error("Missing attribute href");
}
const newIframe = document.createElement("iframe");
newIframe.frameBorder = "0";
newIframe.allow = "fullscreen";
newIframe.width = "1920px";
newIframe.height = "1080px";
newIframe.classList.add("w-100");
newIframe.classList.add("h-100");
newIframe.setAttribute("allowfullscreen", "allowfullscreen");
newIframe.src = String(videoLink.getAttribute("href"));
videoLink.appendChild(newIframe);
}
}
SCRIPT;
$cookies['youtube']['fallback'] = <<<FALLBACK
function () {
// * Video inlaid.
const videoInlaidList = document.querySelectorAll('.video-inlaid[type="youtube"]');
for (const item of videoInlaidList) {
item.querySelector('iframe')?.remove();
setTimeout(() => window.listenInlineCnButtons(), 500);
}
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
if (el.dataset.cookieName === 'youtube') {
el.classList.remove('d-none');
}
});
}
FALLBACK;
// VIMEO
$cookies['vimeo'] = [
'name' => 'VIDEOS - Vimeo',
'description' => __('Les cookies déposés via les services de partage de vidéo ont pour finalité de permettre à l’utilisateur de visionner directement sur le site le contenu multimédia.'),
'link' => 'https://vimeo.com/cookie_policy',
'labelLink' => __('En savoir +'),
'cookies' => ['NID', 'VISITOR_INFO1_LIVE', 'YSC']
];
$cookies['vimeo']['script'] = <<<SCRIPT
function () {
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
if (el.dataset.cookieName === 'vimeo') {
el.classList.add('d-none');
}
});
const videoInlaidList = document.querySelectorAll('.video-inlaid[type="vimeo"]');
for (const videoLink of videoInlaidList) {
if (!videoLink.getAttribute("type")) {
throw new Error("Missing attribute type");
}
if (!videoLink.getAttribute("href")) {
throw new Error("Missing attribute href");
}
const newIframe = document.createElement("iframe");
newIframe.frameBorder = "0";
newIframe.allow = "fullscreen";
newIframe.width = "1920px";
newIframe.height = "1080px";
newIframe.classList.add("w-100");
newIframe.classList.add("h-100");
newIframe.setAttribute("allowfullscreen", "allowfullscreen");
newIframe.src = String(videoLink.getAttribute("href"));
videoLink.appendChild(newIframe);
}
}
SCRIPT;
$cookies['vimeo']['fallback'] = <<<FALLBACK
function () {
const videoInlaidList = document.querySelectorAll('.video-inlaid[type="vimeo"]');
for (const item of videoInlaidList) {
item.querySelector('iframe')?.remove();
setTimeout(() => window.listenInlineCnButtons(), 500);
}
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
if (el.dataset.cookieName === 'vimeo') {
el.classList.remove('d-none');
}
});
}
FALLBACK;
// RECAPTCHA
$cookies['recaptcha'] = [
'name' => __('cookie-notice.custom.recaptcha.title'),
'description' => __('cookie-notice.custom.recaptcha.description'),
'link' => 'https://policies.google.com/privacy',
'labelLink' => __('En savoir +'),
'cookies' => ['NID', '__Secure-3PAPISID', '__Secure-3PSID', '__Secure-3PSIDCC']
];
$cookies['recaptcha']['script'] = <<<SCRIPT
function () {
if (window.__CN_Recaptcha) {
window.__CN_Recaptcha();
}
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
if (el.dataset.cookieName === 'recaptcha') {
el.classList.add('d-none');
}
});
}
SCRIPT;
$cookies['recaptcha']['fallback'] = <<<FALLBACK
function () {
if (window.__CN_Recaptcha_Reset) {
window.__CN_Recaptcha_Reset();
}
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
if (el.dataset.cookieName === 'recaptcha') {
el.classList.remove('d-none');
}
});
}
FALLBACK;
// MATOMO
$cookies['matomo'] = [
'name' => __('cookie-notice.custom.matomo.title'),
'description' => __('cookie-notice.custom.matomo.description'),
'link' => 'https://fr.matomo.org/gdpr-analytics/',
'labelLink' => __('En savoir +'),
'cookies' => ['_pk']
];
$cookies['matomo']['script'] = <<<SCRIPT
function () {
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//yl.s-web.fr/";
_paq.push(['setTrackerUrl', u+'rainbow']);
_paq.push(['setSiteId', '
SCRIPT;
$cookies['matomo']['script'] .= config("services.matomo.site_id");
$cookies['matomo']['script'] .= <<<SCRIPT
']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'unicorn'; s.parentNode.insertBefore(g,s);
})();
}
SCRIPT;
@endphp
{{-- INCLUDE TEMPLATE --}}
@include('fo.vendor.cookie-notice.templates.standard', compact(
'site_name', 'logo_picture_url', 'logo_alt_text',
'logo_title_text', 'strings'
))
<script nonce="{{ $nonce ?? '' }}">
document.addEventListener('DOMContentLoaded', function () {
window.WebCookieNotice = {};
@foreach($cookies as $index_name => $cookie)
window.WebCookieNotice['{{ $index_name }}'] = {};
window.WebCookieNotice['{{ $index_name }}'].tmp = {};
// SCRIPT
window.WebCookieNotice['{{ $index_name }}'].tmp.script = {!! strip_tags($cookie['script']) !!};
@php unset($cookie['script']); @endphp
// FALLBACK
@if(isset($cookie['fallback']))
window.WebCookieNotice['{{ $index_name }}'].tmp.fallback = {!! strip_tags($cookie['fallback']) !!};
@php unset($cookie['fallback']); @endphp
@endif
window.WebCookieNotice['{{ $index_name }}'].conf = @json($cookie);
window.WebCookieNotice['{{ $index_name }}'].conf.script = window.WebCookieNotice['{{ $index_name }}'].tmp.script;
window.WebCookieNotice['{{ $index_name }}'].conf.fallback = window.WebCookieNotice['{{ $index_name }}'].tmp.fallback;
window.WebCookieNotice['{{ $index_name }}'] = window.WebCookieNotice['{{ $index_name }}'].conf;
@endforeach
window.WebCookieNotice = new window.CookieNotice(window.WebCookieNotice);
});
</script>