3eedb2aede
Instead of the JS being in charge of the HTML, the HAML now handles it. The HAML can then check the cookie & show it needed. It also allows the HAML access to the paths so we don't have to pass that through. Closes #29955
27 lines
653 B
JavaScript
27 lines
653 B
JavaScript
import Cookies from 'js-cookie';
|
|
|
|
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
|
|
|
|
export default class UserCallout {
|
|
constructor() {
|
|
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
|
|
this.userCalloutBody = $('.user-callout');
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
|
|
$('.js-close-callout').on('click', e => this.dismissCallout(e));
|
|
}
|
|
}
|
|
|
|
dismissCallout(e) {
|
|
const $currentTarget = $(e.currentTarget);
|
|
|
|
Cookies.set(USER_CALLOUT_COOKIE, 'true');
|
|
|
|
if ($currentTarget.hasClass('close')) {
|
|
this.userCalloutBody.remove();
|
|
}
|
|
}
|
|
}
|