diff --git a/web/app/themes/mitlib-parent/css/v2/components/alerts.css b/web/app/themes/mitlib-parent/css/v2/components/alerts.css index 41d472bd..477cff5e 100644 --- a/web/app/themes/mitlib-parent/css/v2/components/alerts.css +++ b/web/app/themes/mitlib-parent/css/v2/components/alerts.css @@ -21,6 +21,8 @@ #global-alert { position: relative; + &.hidden {display: none;} + .content-wrapper { gap: var(--sp-400); } @@ -31,7 +33,8 @@ flex-grow: 1; i { - margin-top: var(--sp-100); + font-size: 18px; + margin-top: 3px; flex-shrink: 0; flex-grow: 0; } diff --git a/web/app/themes/mitlib-parent/js/alerts.js b/web/app/themes/mitlib-parent/js/alerts.js index f4b70802..aa954938 100644 --- a/web/app/themes/mitlib-parent/js/alerts.js +++ b/web/app/themes/mitlib-parent/js/alerts.js @@ -1,3 +1,6 @@ +// Check to see if the current page is a v2 page. If it is, we'll use v2 alert markup and load a v2 close button in the respective functions. If not, we'll use v1. +var isV2page = document.body.classList.contains('v2-page'); + // Loads alert-level posts on the top of all pages function filterAlerts(posts) { // This processes an array of posts for valid, confirmed, alerts @@ -56,12 +59,26 @@ function renderAlert(markup,id) { } function setClosable(alert_ID) { - // Add a Close icon/svg/button - $('.posts--preview--alerts .post').append('Dismiss'); - // On click + // Add a Close button. We use v2 markup only for pages that are v2 pages. Otherwise, we'll use v1 markup. + if(isV2page) { + // v2 close button markup + $('#global-alert').append(''); + } else { + // v1 close button markup + $('.posts--preview--alerts .post').append('Dismiss'); + } + + // On click of the link with the close id $('#close').click(function(){ - // Add the necessary transition hide class - $(this).closest('.posts--preview--alerts').addClass('transition-vertical--hide'); + + // Apply relevant logic based on v1 or v2 alert. Add relevant class to hide the alert. + if(isV2page) { + // v2 + $(this).closest('#global-alert').addClass('hidden'); + } else { + // v1 + $(this).closest('.posts--preview--alerts').addClass('transition-vertical--hide'); + } // Bump the hours calendar down, if it is present. moveCalendar(-152); // If localStorage @@ -92,15 +109,32 @@ function showAlerts(json) { // Check for empty title alert_title = ('' === alert_posts_arr[i].title.rendered) ? 'Alert!' : alert_posts_arr[i].title.rendered; - // Alert HTML template - alert_template = '