-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3504 from open-formulieren/feature/cookie-consent…
…-bar Dynamic cookie consent bar
- Loading branch information
Showing
11 changed files
with
171 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/openforms/analytics_tools/templates/analytics_tools/all_bottom.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
{% include "analytics_tools/siteimprove.html" with request=request only %} | ||
<template class="analytics-scripts"> | ||
{% include "analytics_tools/siteimprove.html" with request=request only %} | ||
</template> |
10 changes: 6 additions & 4 deletions
10
src/openforms/analytics_tools/templates/analytics_tools/all_head.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{% include "analytics_tools/google.html" with request=request only %} | ||
{% include "analytics_tools/piwik.html" with request=request only %} | ||
{% include "analytics_tools/piwik_pro.html" with request=request only %} | ||
{% include "analytics_tools/matomo.html" with request=request only %} | ||
<template class="analytics-scripts"> | ||
{% include "analytics_tools/google.html" with request=request only %} | ||
{% include "analytics_tools/piwik.html" with request=request only %} | ||
{% include "analytics_tools/piwik_pro.html" with request=request only %} | ||
{% include "analytics_tools/matomo.html" with request=request only %} | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,61 @@ | ||
{% load i18n cookie_consent_tags %} | ||
|
||
{% not_accepted_or_declined_cookie_groups request as cookie_groups %} | ||
{% load i18n static cookie_consent_tags %} | ||
|
||
{% static "cookie_consent/cookiebar.module.js" as cookiebar_src %} | ||
{% url 'cookie_consent_cookie_group_list' as manage_url %} | ||
{% url 'cookie_consent_status' as status_url %} | ||
|
||
{% if request.path != manage_url %} | ||
|
||
{% all_cookie_groups 'cookie-consent__cookie-groups' %} | ||
|
||
<template id="cookie-consent__cookie-bar"> | ||
<section class="cookie-notice" aria-label="{% trans 'Cookie notice' %}"> | ||
|
||
{% if cookie_groups and request.path != manage_url %} | ||
<div class="cookie-notice"> | ||
<span class="cookie-notice__text"> | ||
{% blocktrans trimmed %} | ||
We use cookies to optimize and improve our website and services. | ||
You can <a class="utrecht-link utrecht-link--openforms" href="{{ manage_url }}">manage your preferences</a>. | ||
{% endblocktrans %} | ||
</span> | ||
|
||
<span class="cookie-notice__text"> | ||
{% blocktrans trimmed %} | ||
We use cookies to optimize and improve our website and services. | ||
You can <a class="utrecht-link utrecht-link--openforms" href="{{ manage_url }}">manage your preferences</a>. | ||
{% endblocktrans %} | ||
</span> | ||
<div class="openforms-toolbar"> | ||
<ul class="openforms-toolbar__list"> | ||
<li class="openforms-toolbar__list-item"> | ||
<button | ||
type="submit" | ||
class="utrecht-button utrecht-button--primary-action openforms-button openforms-button--primary cookie-notice__accept" | ||
>{% trans "Accept all" %}</button> | ||
</li> | ||
<li class="openforms-toolbar__list-item"> | ||
<button | ||
type="submit" | ||
class="utrecht-button utrecht-button--primary-action openforms-button openforms-button--primary cookie-notice__decline" | ||
>{% trans "Decline all" %}</button> | ||
</li> | ||
</ul> | ||
</div> | ||
</section> | ||
</template> | ||
|
||
<div class="openforms-toolbar"> | ||
<ul class="openforms-toolbar__list"> | ||
<li class="openforms-toolbar__list-item"> | ||
<form action="{% url 'cookie_consent_accept_all' %}" method="post" class="cookie-notice__form cookie-notice__form--accept"> | ||
{% csrf_token %} | ||
<input type="hidden" name="next" value="{{ request.build_absolute_uri }}" /> | ||
<button | ||
type="submit" | ||
class="utrecht-button utrecht-button--primary-action openforms-button openforms-button--primary" | ||
>{% trans "Accept all" %}</button> | ||
</form> | ||
</li> | ||
<li class="openforms-toolbar__list-item"> | ||
<form action="{% url 'cookie_consent_decline_all' %}" method="post" class="cookie-notice__form cookie-notice__form--decline"> | ||
{% csrf_token %} | ||
<input type="hidden" name="next" value="{{ request.build_absolute_uri }}" /> | ||
<button | ||
type="submit" | ||
class="utrecht-button utrecht-button--primary-action openforms-button openforms-button--primary" | ||
>{% trans "Decline all" %}</button> | ||
</form> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
<script type="module" nonce="{{ request.csp_nonce }}"> | ||
import {showCookieBar} from '{{ cookiebar_src }}'; | ||
const varName = '{{ analytics_varname|escapejs }}'; | ||
showCookieBar({ | ||
statusUrl: '{{ status_url|escapejs }}', | ||
templateSelector: '#cookie-consent__cookie-bar', | ||
cookieGroupsSelector: '#cookie-consent__cookie-groups', | ||
acceptSelector: '.cookie-notice__accept', | ||
declineSelector: '.cookie-notice__decline', | ||
insertBefore: '#cookie-consent__cookie-bar', | ||
onAccept: (groups) => { | ||
const isAnalyticsEnabled = groups.find(group => group.varname === varName); | ||
if (!isAnalyticsEnabled) return; | ||
const analyticsTemplateNodes = document.querySelectorAll('.analytics-scripts'); | ||
analyticsTemplateNodes.forEach(templateNode => { | ||
const clone = templateNode.content.cloneNode(true); | ||
templateNode.parentNode.insertBefore(clone, templateNode); | ||
}) | ||
}, | ||
}); | ||
</script> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.