gitlab-org--gitlab-foss/app/assets/javascripts/user_callout.js

36 lines
886 B
JavaScript
Raw Normal View History

2017-02-14 20:49:36 -05:00
/* eslint-disable arrow-parens, class-methods-use-this, no-param-reassign */
/* global Cookies */
const userCalloutElementName = '.user-callout';
const closeButton = '.close-user-callout';
const userCalloutBtn = '.user-callout-btn';
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
2017-02-14 20:49:36 -05:00
class UserCallout {
constructor() {
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
this.init();
this.isUserCalloutDismissed();
}
2017-02-14 20:49:36 -05:00
init() {
$(document)
.on('click', closeButton, () => this.closeAndDismissCallout())
.on('click', userCalloutBtn, () => this.closeAndDismissCallout());
}
closeAndDismissCallout() {
$(userCalloutElementName).hide();
Cookies.set(USER_CALLOUT_COOKIE, '1');
}
isUserCalloutDismissed() {
if (!this.isCalloutDismissed) {
$(userCalloutElementName).show();
2017-02-14 20:49:36 -05:00
}
}
}
2017-02-14 20:49:36 -05:00
module.exports = UserCallout;