gitlab-org--gitlab-foss/app/assets/javascripts/user_callout.js
Jose Ivan Vargas 103f5a116b Created unit tests, fixtures and integration tests
Also changed the user_callout haml to a partial and
added the corresponding SVG icon
2017-02-23 15:47:23 -06:00

37 lines
1,018 B
JavaScript

/* 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';
class UserCallout {
constructor() {
this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
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();
}
}
}
global.UserCallout = UserCallout;
})(window.gl || (window.gl = {}));