diff --git a/site/assets/js/main.js b/site/assets/js/main.js index 9a881796..d9199362 100644 --- a/site/assets/js/main.js +++ b/site/assets/js/main.js @@ -26,4 +26,3 @@ import './modules/navbar/navbar'; import './modules/go-top-button'; -import './modules/cookie-notice'; diff --git a/site/assets/js/modules/cookie-notice.js b/site/assets/js/modules/cookie-notice.js deleted file mode 100644 index 34fe23de..00000000 --- a/site/assets/js/modules/cookie-notice.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2025, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -'use strict'; - -/** - * This script contains helper functions that display a cookie notice - * and manage cookies if the user clicked the consent button. - * - * Also, adds extra spaces to elements when a cookie notice - * is shown so they don't overlap. - */ -$(function() { - const cookieName = 'cookieConsent'; - const $cookieContainer = $('#cookie-notice'); - const $cookieConsentBtn = $('#cookie-consent-btn'); - const $copyright = $('footer .copyright'); - const copyrightPaddingBottom = 24; - const cookieActiveClass = 'active'; - - initCookieNotice(); - adjustLayout(); - - $(window).on('resize', function() { - addSpaceForCookies(); - adjustLayout(); - }); - - /** - * Shows a cookie notice in the user interface if the user has not yet consented - * to the collection of cookies. - */ - function initCookieNotice() { - if (!Cookies.get(cookieName)) { - $cookieContainer.addClass(cookieActiveClass); - addSpaceForCookies(); - } - } - - /** - * Adds additional bottom space if the cookie notice is shown on the page. - */ - function addSpaceForCookies() { - const cookieContainerHeight = $cookieContainer.innerHeight(); - if ($cookieContainer.length && $cookieContainer.hasClass(cookieActiveClass)) { - $copyright.css('padding-bottom', cookieContainerHeight + copyrightPaddingBottom); - } - } - - /** - * On the consent button click hides the cookie notice, removes additional paddings, - * and makes the corresponding entry inside `Cookies`. - */ - $cookieConsentBtn.click(function() { - $cookieContainer.removeClass(cookieActiveClass); - Cookies.set(cookieName, 'Yes'); - setInitialElementPosition(); - adjustLayout(); - }); - - /** - * Sets the initial element position - * as if there is no cookie notice element. - */ - function setInitialElementPosition() { - $copyright.css('padding-bottom', copyrightPaddingBottom); - } - - /** - * Adjusts the position of elements that depend on the cookie notification. - */ - function adjustLayout() { - const $goTopButton = $('#go-top-button'); - const goTopButtonOffset = 10; - - if ($cookieContainer.hasClass(cookieActiveClass)) { - const cookieHeight = $cookieContainer.innerHeight(); - $goTopButton.css('bottom', cookieHeight + goTopButtonOffset); - } else { - $goTopButton.css('bottom', goTopButtonOffset); - } - } -}); diff --git a/site/assets/scss/main.scss b/site/assets/scss/main.scss index 9c9f6d8d..92c02ccb 100644 --- a/site/assets/scss/main.scss +++ b/site/assets/scss/main.scss @@ -47,7 +47,6 @@ @import "modules/checkbox"; @import "modules/redirect-screen"; @import "modules/loader"; -@import "modules/cookie-notice"; @import "pages/landing"; diff --git a/site/assets/scss/modules/_cookie-notice.scss b/site/assets/scss/modules/_cookie-notice.scss deleted file mode 100644 index 2e7acc2c..00000000 --- a/site/assets/scss/modules/_cookie-notice.scss +++ /dev/null @@ -1,129 +0,0 @@ -/*! - * Copyright 2025, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -$cookie-bg-color: rgba($dark-color, .97); -$cookie-height: 200px; // Approximate height for maximum text content. -$cookie-padding: 12px; -$cookie-text-color: rgba(white, .7); -$cookie-link-color: #5dc4ff; -$cookie-font-size: 13px; -$cookie-btn-border-radius: 2px; -$cookie-btn-min-width: 130px; -$cookie-box-shadow: - 0 -1px 14px 0 rgba(black, .06), - 0 -1px 2px 0 rgba(black, .04), - 0 -5px 15px 0 rgba(black, .04); - -#cookie-notice { - display: none; - position: fixed; - background-color: $cookie-bg-color; - left: 0; - right: 0; - bottom: -$cookie-height; - transition: background .16s ease-in; - box-shadow: $cookie-box-shadow; - transform: translateZ(0); - animation: slideUpCookieNotice .6s 1s ease-in forwards; - z-index: map-get($z-index, 'cookie-notice'); - - &.active { - display: block; - } - - .cookie-content { - position: relative; - display: flex; - align-items: center; - justify-content: center; - padding: $cookie-padding 24px; - } - - .cookie-text { - color: $cookie-text-color; - font-size: $cookie-font-size; - line-height: 1.5; - letter-spacing: .6px; - cursor: default; - - a { - text-decoration: none; - color: $cookie-link-color; - border-bottom: 1px solid rgba($cookie-link-color, .7); - - &:hover { - color: $main-brand-color; - border-bottom-color: $main-brand-color; - } - } - - @include breakpoint(tablet) { - br { - content: ""; - - &:after { - content: " "; - } - } - } - - @include breakpoint(xmd-phone) { - padding-right: $cookie-btn-min-width + 16px; - } - } - - .agree-btn { - background-color: $main-brand-color; - color: white; - font-weight: 500; - border-radius: $cookie-btn-border-radius; - letter-spacing: 1px; - margin: 0 0 0 24px; - padding: 10px 24px; - - @include breakpoint(xmd-phone) { - position: absolute; - display: flex; - align-items: center; - justify-content: center; - top: 0; - right: 0; - bottom: 0; - padding: 12px 16px; - border-radius: 0; - } - - .btn-label { - white-space: nowrap; - } - } - - @keyframes slideUpCookieNotice { - 100% { - bottom: 0; - } - } -} diff --git a/site/config/_default/hugo.toml b/site/config/_default/hugo.toml index b07e86c5..013a7842 100644 --- a/site/config/_default/hugo.toml +++ b/site/config/_default/hugo.toml @@ -27,6 +27,9 @@ disableKinds = ['taxonomy', 'term'] [params.gtm] id = 'GTM-T6NZS3S' +[params.cookieScript] + id = '38b1283993fe8d87c0678be39b07ada2' + [security] [security.exec] osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM|HOME)$'] diff --git a/site/go.mod b/site/go.mod index 5077286e..39db6fa8 100644 --- a/site/go.mod +++ b/site/go.mod @@ -3,6 +3,6 @@ module github.com/SpineEventEngine/SpineEventEngine.github.io go 1.22.0 require ( - github.com/SpineEventEngine/documentation/docs v0.0.0-20251219134029-fa2a7bc2f266 // indirect + github.com/SpineEventEngine/documentation/docs v0.0.0-20251222151322-354f5188bf68 // indirect github.com/TeamDev-Ltd/site-commons v0.0.0-20251202150534-a795438915ff // indirect ) diff --git a/site/go.sum b/site/go.sum index b6212ae7..fc36e4d6 100644 --- a/site/go.sum +++ b/site/go.sum @@ -1,4 +1,4 @@ -github.com/SpineEventEngine/documentation/docs v0.0.0-20251219134029-fa2a7bc2f266 h1:UFv+IDkXRivFdj+fshCWlSZcnBuUZarYiKdgCJY3B64= -github.com/SpineEventEngine/documentation/docs v0.0.0-20251219134029-fa2a7bc2f266/go.mod h1:0lSB4kPZY9Qk429mepYiraNIEucYDIwiNVhJ3Wn3gKo= +github.com/SpineEventEngine/documentation/docs v0.0.0-20251222151322-354f5188bf68 h1:jv/OOMpj/9iPvw/rY1UTotFffK377bSqfqLNbMo7dDM= +github.com/SpineEventEngine/documentation/docs v0.0.0-20251222151322-354f5188bf68/go.mod h1:0lSB4kPZY9Qk429mepYiraNIEucYDIwiNVhJ3Wn3gKo= github.com/TeamDev-Ltd/site-commons v0.0.0-20251202150534-a795438915ff h1:8kjfGJhf6LeS+IlK9NRktxtcv6O/WDneBuQD3QLPGIs= github.com/TeamDev-Ltd/site-commons v0.0.0-20251202150534-a795438915ff/go.mod h1:atDeksDWBzsIidpW6Ivz2yYHwp2JPa1i1KXIxkctQ3c= diff --git a/site/layouts/_partials/scripts/head-scripts.html b/site/layouts/_partials/scripts/head-scripts.html index c4b48e24..149e04bc 100644 --- a/site/layouts/_partials/scripts/head-scripts.html +++ b/site/layouts/_partials/scripts/head-scripts.html @@ -27,3 +27,4 @@ {{ partial "scripts/head/gtm.html" . }} {{ partial "scripts/head/jquery.html" . }} {{ partial "scripts/head/docsearch.html" . }} +{{ partial "scripts/head/cookie-notice.html" . }} diff --git a/site/layouts/_partials/scripts/head/cookie-notice.html b/site/layouts/_partials/scripts/head/cookie-notice.html new file mode 100644 index 00000000..cefc5d81 --- /dev/null +++ b/site/layouts/_partials/scripts/head/cookie-notice.html @@ -0,0 +1,38 @@ + + + + +{{ $id := site.Params.cookieScript.id }} + +{{ if $id }} + {{ partial "scripts/cookie-script.html" (dict "cookie_script_id" $id) }} +{{ end }}