-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookiebot.js
75 lines (71 loc) · 2.32 KB
/
cookiebot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Required event: Show banner
*/
function showCookieBanner() {
var cookieBanner = document.getElementById('CookieBanner');
if (cookieBanner) {
cookieBanner.classList.add('is-visible-cookie-banner');
cookieBanner.classList.remove('is-closing-cookie-banner');
cookieBanner.style.display = 'flex';
}
document.body.classList.add('is-cookie-banner');
}
/**
* Required event: Hide banner
*/
function hideCookieBanner() {
var cookieBanner = document.getElementById('CookieBanner');
if (cookieBanner) {
cookieBanner.classList.add('is-closing-cookie-banner');
// hide element after CSS animation (250ms)
setTimeout(
function (cookieBanner) {
cookieBanner.classList.remove('is-visible-cookie-banner');
cookieBanner.style.display = 'none';
document.body.classList.remove('is-cookie-banner');
},
250,
cookieBanner
);
} else {
document.body.classList.remove('is-cookie-banner');
}
}
/**
* Event: Show cookie categories
*/
function eventCookieBannerDetailsClicked(e) {
var cookieBannerWrapper = document.getElementById('CookieBanner');
if (cookieBannerWrapper) {
cookieBannerWrapper.classList.toggle('is-details-open');
}
if (e.currentTarget) {
if (e.currentTarget.getAttribute('aria-expanded') == 'false') {
e.currentTarget.setAttribute('aria-expanded', 'true');
} else {
e.currentTarget.setAttribute('aria-expanded', 'false');
}
}
}
/**
* Event: Show details of cookie category
*/
function eventCookieBannerToggleTable(e) {
e.preventDefault();
e.stopPropagation();
if (e.currentTarget) {
var targetId = e.currentTarget.getAttribute('aria-controls');
if (targetId) {
var targetEl = document.getElementById(targetId);
if (targetEl) {
if (e.currentTarget.getAttribute('aria-expanded') == 'false') {
e.currentTarget.setAttribute('aria-expanded', 'true');
targetEl.classList.add('is-open');
} else {
e.currentTarget.setAttribute('aria-expanded', 'false');
targetEl.classList.remove('is-open');
}
}
}
}
}