2017-03-11 01:45:34 -05:00
|
|
|
import Cookies from 'js-cookie';
|
2017-02-14 20:49:36 -05:00
|
|
|
|
2017-02-17 12:28:52 -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 {
|
2017-02-17 12:28:52 -05:00
|
|
|
constructor() {
|
|
|
|
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
|
2017-03-24 08:41:42 -04:00
|
|
|
this.userCalloutBody = $('.user-callout');
|
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-04-08 04:44:03 -04:00
|
|
|
Cookies.set(USER_CALLOUT_COOKIE, '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
|
|
|
}
|