gitlab-org--gitlab-foss/app/assets/javascripts/user_callout.js
Filipa Lacerda 38bcf699ab Get the project path through the DOM instead of gon
Open the settings section based on the location hash
2017-09-07 10:26:51 +01:00

34 lines
947 B
JavaScript

import Cookies from 'js-cookie';
export default class UserCallout {
constructor(options = {}) {
this.options = options;
const className = this.options.className || 'user-callout';
this.userCalloutBody = $(`.${className}`);
this.cookieName = this.userCalloutBody.data('uid');
this.isCalloutDismissed = Cookies.get(this.cookieName);
this.init();
}
init() {
if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
$('.js-close-callout').on('click', e => this.dismissCallout(e));
}
}
dismissCallout(e) {
const $currentTarget = $(e.currentTarget);
if (this.options.setCalloutPerProject) {
Cookies.set(this.cookieName, 'true', { expires: 365, path: this.userCalloutBody.data('project-path') });
} else {
Cookies.set(this.cookieName, 'true', { expires: 365 });
}
if ($currentTarget.hasClass('close')) {
this.userCalloutBody.remove();
}
}
}