gitlab-org--gitlab-foss/app/assets/javascripts/user_callout.js

28 lines
671 B
JavaScript
Raw Normal View History

2017-03-11 01:45:34 -05:00
import Cookies from 'js-cookie';
2017-02-14 20:49:36 -05:00
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
2017-02-14 20:49:36 -05:00
2017-03-22 04:26:12 -04:00
export default class UserCallout {
constructor() {
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
this.userCalloutBody = $('.user-callout');
this.init();
}
2017-02-14 20:49:36 -05:00
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', { expires: 365 });
if ($currentTarget.hasClass('close')) {
this.userCalloutBody.remove();
2017-02-14 20:49:36 -05:00
}
}
}