2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2017-03-11 01:45:34 -05:00
|
|
|
import Cookies from 'js-cookie';
|
2017-02-14 20:49:36 -05:00
|
|
|
|
2017-03-22 04:26:12 -04:00
|
|
|
export default class UserCallout {
|
2017-09-05 07:04:19 -04:00
|
|
|
constructor(options = {}) {
|
|
|
|
this.options = options;
|
|
|
|
|
|
|
|
const className = this.options.className || 'user-callout';
|
|
|
|
|
2017-05-24 06:25:44 -04:00
|
|
|
this.userCalloutBody = $(`.${className}`);
|
|
|
|
this.cookieName = this.userCalloutBody.data('uid');
|
|
|
|
this.isCalloutDismissed = Cookies.get(this.cookieName);
|
2017-02-17 12:28:52 -05:00
|
|
|
this.init();
|
|
|
|
}
|
2017-02-14 20:49:36 -05:00
|
|
|
|
2017-02-17 12:28:52 -05:00
|
|
|
init() {
|
2017-02-23 16:23:33 -05:00
|
|
|
if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
|
2017-03-24 08:41:42 -04:00
|
|
|
$('.js-close-callout').on('click', e => this.dismissCallout(e));
|
2017-02-23 16:23:33 -05:00
|
|
|
}
|
2017-02-17 12:28:52 -05:00
|
|
|
}
|
2017-02-16 17:02:40 -05:00
|
|
|
|
2017-02-23 16:23:33 -05:00
|
|
|
dismissCallout(e) {
|
|
|
|
const $currentTarget = $(e.currentTarget);
|
2017-03-24 08:41:42 -04:00
|
|
|
|
2017-09-05 07:04:19 -04:00
|
|
|
if (this.options.setCalloutPerProject) {
|
2018-02-20 17:20:48 -05:00
|
|
|
Cookies.set(this.cookieName, 'true', { expires: 365, path: this.userCalloutBody.data('projectPath') });
|
2017-09-05 07:04:19 -04:00
|
|
|
} else {
|
|
|
|
Cookies.set(this.cookieName, 'true', { expires: 365 });
|
|
|
|
}
|
2017-03-24 08:41:42 -04:00
|
|
|
|
|
|
|
if ($currentTarget.hasClass('close')) {
|
2017-03-02 16:10:39 -05:00
|
|
|
this.userCalloutBody.remove();
|
2017-02-14 20:49:36 -05:00
|
|
|
}
|
|
|
|
}
|
2017-02-17 12:28:52 -05:00
|
|
|
}
|