summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/user_callout.js
blob: fa078b48bf8a70d531a11ae3616d4da179d0b826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Cookies from 'js-cookie';

const USER_CALLOUT_COOKIE = 'user_callout_dismissed';

export default class UserCallout {
  constructor() {
    this.isCalloutDismissed = Cookies.get(USER_CALLOUT_COOKIE);
    this.userCalloutBody = $('.user-callout');
    this.init();
  }

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

  dismissCallout(e) {
    const $currentTarget = $(e.currentTarget);

    Cookies.set(USER_CALLOUT_COOKIE, 'true');

    if ($currentTarget.hasClass('close')) {
      this.userCalloutBody.remove();
    }
  }
}