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

3
const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
4

Mike Greiling's avatar
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 22 23

    Cookies.set(USER_CALLOUT_COOKIE, 'true');

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