2022-02-01 16:12:02 -05:00
|
|
|
import { getCookie, setCookie, parseBoolean } from '~/lib/utils/common_utils';
|
2017-05-02 04:05:43 -04:00
|
|
|
|
|
|
|
class Landing {
|
|
|
|
constructor(landingElement, dismissButton, cookieName) {
|
|
|
|
this.landingElement = landingElement;
|
|
|
|
this.cookieName = cookieName;
|
|
|
|
this.dismissButton = dismissButton;
|
|
|
|
this.eventWrapper = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle() {
|
|
|
|
const isDismissed = this.isDismissed();
|
|
|
|
|
|
|
|
this.landingElement.classList.toggle('hidden', isDismissed);
|
|
|
|
if (!isDismissed) this.addEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
addEvents() {
|
|
|
|
this.eventWrapper.dismissLanding = this.dismissLanding.bind(this);
|
|
|
|
this.dismissButton.addEventListener('click', this.eventWrapper.dismissLanding);
|
|
|
|
}
|
|
|
|
|
|
|
|
removeEvents() {
|
|
|
|
this.dismissButton.removeEventListener('click', this.eventWrapper.dismissLanding);
|
|
|
|
}
|
|
|
|
|
|
|
|
dismissLanding() {
|
|
|
|
this.landingElement.classList.add('hidden');
|
2022-02-01 16:12:02 -05:00
|
|
|
setCookie(this.cookieName, 'true');
|
2017-05-02 04:05:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
isDismissed() {
|
2022-02-01 16:12:02 -05:00
|
|
|
return parseBoolean(getCookie(this.cookieName));
|
2017-05-02 04:05:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Landing;
|