@@ -, +, @@ --- .../prog/en/includes/intranet-bottom.inc | 2 +- .../intranet-tmpl/prog/js/cookieconsent.js | 4 +++- .../intranet-tmpl/prog/js/pages/preferences.js | 17 +++++++++++++++++ .../bootstrap/en/includes/opac-bottom.inc | 2 +- .../opac-tmpl/bootstrap/js/cookieconsent.js | 4 +++- 5 files changed, 25 insertions(+), 4 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -136,7 +136,7 @@ [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).length > 0 %] [% consents = JSConsents.all() %] [% FOREACH consent IN consents %] - + [% END %] [% END %] [% IF Koha.Preference( 'CookieConsent' ) %] --- a/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js +++ a/koha-tmpl/intranet-tmpl/prog/js/cookieconsent.js @@ -106,13 +106,15 @@ // This code doesn't have consent to run, we may need to remove // any cookies it has previously set const matchPattern = $(this).data('consent-match-pattern'); + const cookieDomain = $(this).data('consent-cookie-domain'); + const cookiePath = $(this).data('consent-cookie-path'); if (matchPattern.length > 0) { const regex = new RegExp(matchPattern); const allCookies = document.cookie.split('; '); allCookies.forEach(function (cookie) { const name = cookie.split('=')[0]; if (regex.test(name)) { - document.cookie = name + '=; expires=Thu, 01 Jan 1970 00: 00: 01 GMT'; + document.cookie = name + '=; expires=Thu, 01 Jan 1970 00: 00: 01 GMT; domain=' + cookieDomain + '; path=' + cookiePath; } }); --- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js +++ a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js @@ -362,6 +362,14 @@ $( document ).ready( function () { ' ' + ' ' + __('Required') + '' + ' ' + + '
' + + ' ' + + ' ' + __('Required') + '' + + '
' + + '
' + + ' ' + + ' ' + __('Required') + '' + + '
' + ' ' + '
' + ' ' + @@ -392,6 +400,8 @@ $( document ).ready( function () { name: '', description: '', matchPattern: '', + cookieDomain: '', + cookiePath: '', code: '', consentInOpac: false, consentInStaff: false @@ -470,6 +480,8 @@ $( document ).ready( function () { const name = $(this).find('.metaName').val(); const desc = $(this).find('.metaDescription').val(); const matchPattern = $(this).find('.metaMatchPattern').val(); + const cookieDomain = $(this).find('.metaCookieDomain').val(); + const cookiePath = $(this).find('.metaCookiePath').val(); const opacConsent = $(this).find('.opacConsent').is(':checked') const staffConsent = $(this).find('.staffConsent').is(':checked'); const code = $(this).find('.preference-code').val(); @@ -479,6 +491,8 @@ $( document ).ready( function () { name.length === 0 && desc.length === 0 && matchPattern.length === 0 && + cookieDomain.length === 0 && + cookiePath.length === 0 && code.length === 0 ) { return; @@ -488,6 +502,7 @@ $( document ).ready( function () { (name.length === 0) || (desc.length === 0) || (matchPattern.length === 0) || + (cookiePath.length === 0) || (code.length === 0) ) { invalid.push(this); @@ -497,6 +512,8 @@ $( document ).ready( function () { name: name, description: desc, matchPattern: matchPattern, + cookieDomain: cookieDomain, + cookiePath: cookiePath, opacConsent: opacConsent, staffConsent: staffConsent, code: btoa(code) --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -124,7 +124,7 @@ [% IF Koha.Preference( 'CookieConsent' ) && Koha.Preference( 'ConsentJS' ).length > 0 %] [% consents = JSConsents.all() %] [% FOREACH consent IN consents %] - + [% END %] [% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js +++ a/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js @@ -120,13 +120,15 @@ // This code doesn't have consent to run, we may need to remove // any cookies it has previously set const matchPattern = $(this).data('consent-match-pattern'); + const cookieDomain = $(this).data('consent-cookie-domain'); + const cookiePath = $(this).data('consent-cookie-path'); if (matchPattern.length > 0) { const regex = new RegExp(matchPattern); const allCookies = document.cookie.split('; '); allCookies.forEach(function (cookie) { const name = cookie.split('=')[0]; if (regex.test(name)) { - document.cookie = name + '=; expires=Thu, 01 Jan 1970 00: 00: 01 GMT'; + document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain=' + cookieDomain +'; path=' + cookiePath; } }); } --