From 872a4257ac3cc8d7b91a9ff828dcd10a5969dcc3 Mon Sep 17 00:00:00 2001 From: Shawn Rice Date: Mon, 31 Jul 2023 13:44:23 -0400 Subject: [PATCH] refactor: Convert JS from jQuery to vanilla JS --- .../CookiePolicy/assets/js/cookiepolicy.js | 25 +++++++++++-------- .../CookiePolicy/views/index.blade.php | 6 ++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/Widgets/CookiePolicy/assets/js/cookiepolicy.js b/app/Widgets/CookiePolicy/assets/js/cookiepolicy.js index d188368a6..73fb73075 100755 --- a/app/Widgets/CookiePolicy/assets/js/cookiepolicy.js +++ b/app/Widgets/CookiePolicy/assets/js/cookiepolicy.js @@ -2,25 +2,28 @@ * Cookie Policy scripts */ -jQuery(document).ready(function($){ +document.addEventListener('DOMContentLoaded', function () { - $('body').addClass('has-eprivacy-warning'); + let bdy = document.querySelector('body'); + bdy.classList.add('has-eprivacy-warning'); // Add an event to close the notice - $('.eprivacy-close').on('click', function(e) { - e.preventDefault(); + document.querySelectorAll('.eprivacy-close').forEach(function (el) { + el.addEventListener('click', function (e) { + e.preventDefault(); - var id = $($(this).parent().parent()).attr('id'), - days = $(this).attr('data-duration'); + let id = this.getAttribute('data-target'), + days = this.getAttribute('data-duration'), + date = new Date(); - $($(this).parent().parent()).hide(); + date.setTime(date.getTime()+(days*24*60*60*1000)); - var date = new Date(); - date.setTime(date.getTime()+(days*24*60*60*1000)); + document.cookie = id + '=acknowledged; expires=' + date.toGMTString() + ';'; - document.cookie = id + '=acknowledged; expires=' + date.toGMTString() + ';'; + bdy.classList.remove('has-eprivacy-warning'); - $('body').removeClass('has-eprivacy-warning'); + document.getElementById(id).remove(); + }); }); }); \ No newline at end of file diff --git a/app/Widgets/CookiePolicy/views/index.blade.php b/app/Widgets/CookiePolicy/views/index.blade.php index 06e25107d..70cfab047 100755 --- a/app/Widgets/CookiePolicy/views/index.blade.php +++ b/app/Widgets/CookiePolicy/views/index.blade.php @@ -2,11 +2,11 @@ @endpush -
-