Files
web/public/_static/js/cookie-bot.js
2024-06-28 13:41:37 +02:00

86 lines
4.1 KiB
JavaScript

/**
* Makes some brute force adjustments on the open cookiebot dialog and adds our own styling
*/
var fixCookieBotDialog = function() {
document.querySelector("head").insertAdjacentHTML("beforeend", "<link type='text/css' href='/_static/css/cookie-bot.css' rel='stylesheet' />");
var e = function(e) {
i = !!(e = !!e) || i;
var t = document.querySelector("#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection")
, o = document.querySelector("#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll");
t.style.display = "none" != t.style.display || e ? "none" : "block",
o.style.display = "none" == o.style.display || e ? "block" : "none"
};
document.querySelector("#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection").style.display = "none",
document.querySelector("#CybotCookiebotDialogBodyLevelDetailsWrapper").setAttribute("class", "custom-select");
var t = document.querySelector("#CybotCookiebotDialogBody")
, o = document.querySelector("#CybotCookiebotDialogBodyLevelWrapper");
t.insertBefore(document.querySelector("#CybotCookiebotDialogDetail"), o);
var n = document.querySelector("#CybotCookiebotDialogBodyLevelButtonsSelectPane");
t.insertBefore(n, o),
n.style.display = "none",
window.innerWidth > 740 && window.dispatchEvent(new Event("resize")),
document.querySelector("#CybotCookiebotDialogBodyLevelDetailsWrapper").addEventListener("click", (function() {
n.style.display = "none" == n.style.display ? "block" : "none";
var t = document.querySelector("#CybotCookiebotDialogBodyLevelDetailsWrapper").classList;
if (t.contains("active"))
t.remove("active"),
document.querySelector("#CybotCookiebotDialog").classList.remove("expanded"),
e(!0);
else {
t.add("active"),
document.querySelector("#CybotCookiebotDialog").classList.add("expanded"),
a();
var o = document.querySelectorAll(".CybotCookiebotDialogDetailBodyContentCookieTypeTableContainer");
if ("none" != o[0].parentElement.style.display)
for (var i = o[0].querySelector("table").clientWidth, l = 0; l < o.length; l++)
o[l].previousElementSibling.style.minWidth = i + "px",
o[l].style.minWidth = i + "px"
}
}
));
for (var i = !0, l = document.querySelectorAll("#CybotCookiebotDialogBodyLevelButtonsSelectPane input[type=checkbox]"), a = function() {
for (var t = !0, o = 0; o < l.length; o++)
l[o].checked || (t = !1);
i != t && (i = t,
e())
}, r = 0; r < l.length; r++)
l[r].addEventListener("change", a)
};
window.addEventListener("CookiebotOnDialogDisplay", fixCookieBotDialog);
// If the cookiebot dialog was opened before this file was run we run the fix function "manually"
if (document.querySelector("#CybotCookiebotDialog")) {
fixCookieBotDialog();
}
window.addEventListener("load", (function() {
var e = document.querySelector("#CookieDeclarationChangeConsent > a")
, t = document.querySelector("#CookieDeclarationChangeConsent > span > a");
if (e)
switch (document.documentElement.lang) {
default:
e.text = "Change your consent",
t.text = "Withdraw your consent";
break;
case "sv":
e.text = "Ändra mitt samtycke",
t.text = "Ångra mitt samtycke";
break;
case "no":
e.text = "Trække dit samtykke tilbage",
t.text = "Trekk tilbake ditt samtykke";
break;
case "da":
e.text = "Ændre dit samtykke",
t.text = "Trække dit samtykke tilbage";
break;
case "de":
e.text = "Ihre Einwilligung ändern",
t.text = "Ihre Einwilligung zurückziehen";
break;
case "fi":
e.text = "Muuta hyväksyntäsi",
t.text = "Peru hyväksyntäsi"
}
}));