docbrown/app/assets/javascripts/initializers/initializeHeroBannerClose.js
Ben Halpern 6131c4f03c
[deploy] Remove hardcoded banner exit code (#7018)
* Remove hardcoded banner exit code

* Fix issues with html variant name

* Fix html call logic
2020-04-02 12:08:13 -04:00

15 lines
585 B
JavaScript

'use strict';
function initializeHeroBannerClose() {
let bannerWrapper = document.getElementById('hero-html-wrapper');
let closeIcon = document.getElementById('js-hero-banner__x');
// Currently js-hero-banner__x button icon ID needs to be written into the abstract html
// In the future this could be extracted so the implementer doesn't need to worry about it.
if (bannerWrapper && closeIcon) {
closeIcon.addEventListener('click', () => {
localStorage.setItem('exited_hero', bannerWrapper.dataset.name);
bannerWrapper.style.display = 'none';
});
}
}