BigW Consortium Gitlab

user_callout.js 671 Bytes
Newer Older
1
import Cookies from 'js-cookie';
2

3
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
4

Mike Greiling committed
5
export default class UserCallout {
6 7
  constructor() {
    this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
8
    this.userCalloutBody = $('.user-callout');
9 10
    this.init();
  }
11

12
  init() {
13
    if (!this.isCalloutDismissed || this.isCalloutDismissed === 'false') {
14
      $('.js-close-callout').on('click', e => this.dismissCallout(e));
15
    }
16
  }
17

18 19
  dismissCallout(e) {
    const $currentTarget = $(e.currentTarget);
20

21
    Cookies.set(USER_CALLOUT_COOKIE, 'true', { expires: 365 });
22 23

    if ($currentTarget.hasClass('close')) {
24
      this.userCalloutBody.remove();
25 26
    }
  }
27
}