mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 11:23:48 -05:00
turns out that we're only using errorBanner with a static message, and it's also full of rich html content. This means that it's probably better to put it in the html templates with other content, rather than hidden away in js files if we can help it. Since there are two places, had to dupe the error message but i think that's fine as i don't anticipate this error message being used in significantly more places. making it a string is a bit gross and means we don't get nice syntax highlighting on it, but as it needs to be passed in to a jinja macro that's the way it has to go unfortunately.
18 lines
687 B
JavaScript
18 lines
687 B
JavaScript
(function (window) {
|
|
"use strict";
|
|
|
|
/*
|
|
This module is intended to be used to show and hide an error banner based on a javascript trigger. You should make
|
|
sure the banner has an appropriate aria-live attribute, and a tabindex of -1 so that screenreaders and keyboard users
|
|
are alerted to the change respectively.
|
|
|
|
This may behave in unexpected ways if you have more than one element with the `banner-dangerous` class on your page.
|
|
*/
|
|
window.GOVUK.ErrorBanner = {
|
|
hideBanner: () => $('.banner-dangerous').addClass('govuk-!-display-none'),
|
|
showBanner: () => $('.banner-dangerous')
|
|
.removeClass('govuk-!-display-none')
|
|
.trigger('focus'),
|
|
};
|
|
})(window);
|