2017-02-14 20:49:36 -05:00
|
|
|
/* eslint-disable arrow-parens, class-methods-use-this, no-param-reassign */
|
|
|
|
/* global Cookies */
|
|
|
|
|
2017-02-17 12:28:52 -05:00
|
|
|
const userCalloutElementName = '.user-callout';
|
2017-02-20 10:39:23 -05:00
|
|
|
const closeButton = '.close-user-callout';
|
2017-02-17 12:28:52 -05:00
|
|
|
const userCalloutBtn = '.user-callout-btn';
|
2017-02-16 17:02:40 -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-02-17 12:28:52 -05:00
|
|
|
class UserCallout {
|
|
|
|
constructor() {
|
|
|
|
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
|
|
|
|
this.init();
|
|
|
|
this.isUserCalloutDismissed();
|
|
|
|
}
|
2017-02-14 20:49:36 -05:00
|
|
|
|
2017-02-17 12:28:52 -05:00
|
|
|
init() {
|
|
|
|
$(document)
|
2017-02-20 10:39:23 -05:00
|
|
|
.on('click', closeButton, () => this.closeAndDismissCallout())
|
2017-02-17 12:28:52 -05:00
|
|
|
.on('click', userCalloutBtn, () => this.closeAndDismissCallout());
|
|
|
|
}
|
2017-02-16 17:02:40 -05:00
|
|
|
|
2017-02-17 12:28:52 -05:00
|
|
|
closeAndDismissCallout() {
|
|
|
|
$(userCalloutElementName).hide();
|
|
|
|
Cookies.set(USER_CALLOUT_COOKIE, '1');
|
|
|
|
}
|
2017-02-16 17:02:40 -05:00
|
|
|
|
2017-02-17 12:28:52 -05:00
|
|
|
isUserCalloutDismissed() {
|
|
|
|
if (!this.isCalloutDismissed) {
|
|
|
|
$(userCalloutElementName).show();
|
2017-02-14 20:49:36 -05:00
|
|
|
}
|
|
|
|
}
|
2017-02-17 12:28:52 -05:00
|
|
|
}
|
2017-02-14 20:49:36 -05:00
|
|
|
|
2017-02-17 12:28:52 -05:00
|
|
|
module.exports = UserCallout;
|