Skip to content
Snippets Groups Projects
Commit 620fa1e9 authored by Stève ORIOL's avatar Stève ORIOL Committed by Anatoly Politsin
Browse files

Issue #3356097 by steveoriol: Drupal 10 version

parent 69b7eb1c
No related branches found
Tags 8.x-1.21
No related merge requests found
......@@ -3,39 +3,45 @@
* Gdpr cookie agreement js.
*/
(function ($) {
$(document).ready(function () {
var $gdprAgree = $.cookie('gdpr_compliance');
var $gdprPopup = $('#gdpr-popup');
(function ($, Drupal, cookies) {
Drupal.behaviors.gdpr_compliance = {
attach: function (context, settings) {
$(document).ready(function () {
var $gdprAgree = cookies.get("gdpr_compliance");
var $gdprPopup = $("#gdpr-popup");
if ($gdprAgree !== 'agreed') {
$gdprPopup.show();
}
$('#gdpr-agree').click(function () {
$gdprPopup.fadeOut();
$.cookie('gdpr_compliance', 'agreed', {path: '/', expires: 30});
});
$('#gdpr-find-more').click(function () {
$.cookie('gdpr_compliance', 'morelink', {path: '/', expires: 30});
// Go to rules page.
var $path = $(this).data('morelink');
if ($path.substring(0, 4) === 'http') {
window.open($path);
}
if ($path.substring(0, 1) === '/') {
window.open(window.location.origin + $path);
}
});
$('#gdpr-clear-cookie').click(function () {
for (var c in $.cookie()) {
$.removeCookie(c, {path: '/'});
}
if ($(this).data('done')) {
alert($(this).data('done'));
}
else {
alert('ok');
}
});
});
})(this.jQuery);
if ($gdprAgree !== "agreed") {
$gdprPopup.show();
}
$("#gdpr-agree").click(function () {
$gdprPopup.fadeOut();
cookies.set("gdpr_compliance", "agreed", { path: "/", expires: 30 });
});
$("#gdpr-find-more").click(function () {
cookies.set("gdpr_compliance", "morelink", {
path: "/",
expires: 30,
});
// Go to rules page.
var $path = $(this).data("morelink");
if ($path.substring(0, 4) === "http") {
window.open($path);
}
if ($path.substring(0, 1) === "/") {
window.open(window.location.origin + $path);
}
});
$("#gdpr-clear-cookie").click(function () {
for (var c in $.cookie()) {
$.removeCookie(c, { path: "/" });
}
if ($(this).data("done")) {
alert($(this).data("done"));
} else {
alert("ok");
}
});
});
},
};
})(jQuery, Drupal, window.Cookies);
......@@ -6,4 +6,4 @@ popup:
assets/css/gdpr-popup.css: {}
dependencies:
- core/jquery
- core/jquery.cookie
- core/js-cookie
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment