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

38 lines
1018 B
JavaScript
Raw Normal View History

2017-02-15 01:49:36 +00:00
/* eslint-disable arrow-parens, class-methods-use-this, no-param-reassign */
/* global Cookies */
((global) => {
const userCalloutElementName = '#user-callout';
const dismissIcon = '.dismiss-icon';
const userCalloutBtn = '.user-callout-btn';
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
2017-02-15 01:49:36 +00:00
class UserCallout {
constructor() {
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
2017-02-15 01:49:36 +00:00
this.init();
}
init() {
$(document)
.on('click', dismissIcon, () => this.closeAndDismissCallout())
.on('click', userCalloutBtn, () => this.closeAndDismissCallout())
.on('DOMContentLoaded', () => this.isUserCalloutDismissed());
}
closeAndDismissCallout() {
$(userCalloutElementName).hide();
Cookies.set(USER_CALLOUT_COOKIE, '1');
}
isUserCalloutDismissed() {
if (!this.isCalloutDismissed) {
$(userCalloutElementName).show();
}
2017-02-15 01:49:36 +00:00
}
}
global.UserCallout = UserCallout;
})(window.gl || (window.gl = {}));