Skip to content

Commit

Permalink
cookies alert
Browse files Browse the repository at this point in the history
  • Loading branch information
desistefanova committed Jan 12, 2025
1 parent a3bd414 commit 29266dd
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 7,049 deletions.
70 changes: 70 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1714,4 +1714,74 @@ section,
--------------------------------------------------------------*/
.starter-section {
/* Add your styles here */
}


/* Cookies */

.cookiealert {
position: fixed;
bottom: 0;
right: 60px;
max-width: 440px;
margin: 0 !important;
padding: 0.2rem 1.25rem;
z-index: 999;
opacity: 0;
visibility: hidden;
border-radius: 12px;
transform: translateY(100%);
transition: all 500ms ease-out;
color: #000;
background-color: #fff;
font-size: 14px;
border: 1px solid var(--accent-color);
}

.cookiealert p
{
text-align: left;
}
.cookiealert.show {
opacity: 1;
visibility: visible;
transform: translateY(0%);
transition-delay: 1000ms;
}

.cookiealert a {
text-decoration: underline;
font-weight: bold;
}

.cookiealert .acceptcookies {
margin-left: 10px;
vertical-align: baseline;
}

.cookiealert button {
color: #ffffff;
background: var(--accent-color);
display: inline-block;
transition: 0.3s;
font-size: 16px;
text-align: center;
font-weight: 700;
font-family: Helvetica, sans-serif;
border-radius: 19px;
border-width: 0px;
padding: 10px 30px;
}

.cookiealert button:hover {
color: #ffffff;
background: #2c2a2a!important;
}
.sib-form-block button:hover {
background: #2c2a2a!important;
}
@media (max-width: 260px) {
.cookiealert
{font-size: 12px;
}
}
42 changes: 42 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,48 @@
}
});

var cookieAlert = document.querySelector(".cookiealert");
var acceptCookies = document.querySelector(".acceptcookies");

if (!cookieAlert) {
return;
}

cookieAlert.offsetHeight;

if (!getCookie("acceptCookies")) {
cookieAlert.classList.add("show");
}

acceptCookies.addEventListener("click", function () {
setCookie("acceptCookies", true, 365);
cookieAlert.classList.remove("show");

window.dispatchEvent(new Event("cookieAlertAccept"))
});

function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
/**
* Navmenu Scrollspy
*/
Expand Down
Loading

0 comments on commit 29266dd

Please sign in to comment.