2017-08-17 22:00:37 +05:30
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
|
|
|
|
export default class UserCallout {
|
2018-03-17 18:26:18 +05:30
|
|
|
constructor(options = {}) {
|
|
|
|
this.options = options;
|
|
|
|
|
|
|
|
const className = this.options.className || 'user-callout';
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
this.userCalloutBody = $(`.${className}`);
|
|
|
|
this.cookieName = this.userCalloutBody.data('uid');
|
|
|
|
this.isCalloutDismissed = Cookies.get(this.cookieName);
|
2017-08-17 22:00:37 +05:30
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
|
|
|
if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
|
|
|
|
$('.js-close-callout').on('click', e => this.dismissCallout(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dismissCallout(e) {
|
|
|
|
const $currentTarget = $(e.currentTarget);
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
if (this.options.setCalloutPerProject) {
|
|
|
|
Cookies.set(this.cookieName, 'true', { expires: 365, path: this.userCalloutBody.data('project-path') });
|
|
|
|
} else {
|
|
|
|
Cookies.set(this.cookieName, 'true', { expires: 365 });
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
if ($currentTarget.hasClass('close')) {
|
|
|
|
this.userCalloutBody.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|