docbrown/app/assets/javascripts/initializers/initializeHeroBannerClose.js
Ridhwana 55909afdc7
Make Hero Banner closable (#6333) [deploy]
* feat: set up an event handler that will allow close the banner and set a cookie when you've closed it

* feat: return early if the cookie says it shouldn't be shown

* refactor: make the names more general so that they can be applied to other campaigns
2020-02-27 12:06:37 -05:00

13 lines
332 B
JavaScript

'use strict';
function initializeHeroBannerClose() {
let banner = document.getElementById("js-hero-banner");
let closeIcon = document.getElementById("js-hero-banner__x");
if (banner && closeIcon) {
closeIcon.onclick = (e) => {
document.cookie = "heroBanner=false";
banner.style.display = "none";
}
}
}