gitlab-org--gitlab-foss/app/assets/javascripts/user_callout.js
Taurie Davis, Simon Knox and Adam Niedzielski 26dde5f55f Add Conversational Development Index page to admin panel
2017-06-01 17:37:21 +02:00

26 lines
690 B
JavaScript

import Cookies from 'js-cookie';
export default class UserCallout {
constructor(className = 'user-callout') {
this.userCalloutBody = $(`.${className}`);
this.cookieName = this.userCalloutBody.data('uid');
this.isCalloutDismissed = Cookies.get(this.cookieName);
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(this.cookieName, 'true', { expires: 365 });
if ($currentTarget.hasClass('close')) {
this.userCalloutBody.remove();
}
}
}