]> _ Git - physioassist-wordpress.git/commitdiff
Allow cookie notice to work with caching mechanism. Wait #4147 @0.5
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 25 Feb 2021 16:35:50 +0000 (16:35 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 25 Feb 2021 16:35:50 +0000 (16:35 +0000)
wp-content/themes/physioassist/resources/assets/scripts/cookie-notice.js
wp-content/themes/physioassist/resources/assets/styles/widgets/cookie-notice.styl

index 6f81e7d3bc1261700d0fce92f3bc006851ac1199..ce16c38a6637aa8e8313b7bc564bc45b054a1457 100644 (file)
@@ -3,6 +3,14 @@ import Cookies from 'js-cookie';
 // Get name of cookie from localised script variable set in PHP
 let cookie_name = window.cube_cookie_notice.cookie_name;
 
+$(document).ready(function() {
+  let cookies_accepted = Cookies.get(cookie_name);
+
+  if (!cookies_accepted) {
+    $('html').addClass('cookies-not-accepted');
+  }
+});
+
 $(document).on('click', '.cube-cookie-notice-close', function() {
   Cookies.set(cookie_name, 1, { expires: 365 });
   $(this).parent().fadeOut();
index f8b8c18326069e0b893571fe6fa4dcb1055fba76..d2dad93140033dfa0db9d3c9e43f5f951a03ece3 100644 (file)
@@ -11,7 +11,8 @@
   font-size: 13px
   display: none // Hidden until user interacts (scrolls) the page
 
-  .interaction-started &
+  // Only show if cookies aren't already accepted
+  .cookies-not-accepted.interaction-started &
     display: block
 
   &-learn-more