From ab45424fe8d2d08173587ef5d14d59580834ae2c Mon Sep 17 00:00:00 2001 From: Rachele Morino Date: Fri, 12 Jan 2024 16:32:29 -0500 Subject: [PATCH 1/3] Adjust banner logic to display by alert ID & text content --- python/cac_tripplanner/templates/base.html | 10 +++++++--- .../templates/partials/alert-banner.html | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/python/cac_tripplanner/templates/base.html b/python/cac_tripplanner/templates/base.html index 4c79e5f3..2943d803 100644 --- a/python/cac_tripplanner/templates/base.html +++ b/python/cac_tripplanner/templates/base.html @@ -172,14 +172,18 @@ jQuery.noConflict(); // because JotForms. // Hide top alert banner across pages on close jQuery(document).ready(function ($) { - const hideBanner = localStorage.getItem('hide-top-alert-banner') || false; - if(!hideBanner){ + // update this for every new alert to match id in alert-banner.html + var alertId = 'gophillygo-alert-2024-01-12', + hasAlertMessage = jQuery('.alert-body').text().trim(), + wasAlreadyHidden = localStorage.getItem(alertId) || false, + shouldShowBanner = hasAlertMessage && !wasAlreadyHidden; + if(shouldShowBanner){ jQuery('.nav-banner').removeClass('hidden'); }; jQuery('.nav-banner').on('click', function(e) { e.stopPropagation(); - localStorage.setItem('hide-top-alert-banner', true); + localStorage.setItem(alertId, true); jQuery('.nav-banner').addClass('hidden'); }); }); diff --git a/python/cac_tripplanner/templates/partials/alert-banner.html b/python/cac_tripplanner/templates/partials/alert-banner.html index b05b5b58..82d9b753 100644 --- a/python/cac_tripplanner/templates/partials/alert-banner.html +++ b/python/cac_tripplanner/templates/partials/alert-banner.html @@ -1,5 +1,10 @@