activities.js.es6 941 Bytes
Newer Older
1 2 3 4 5 6
/* eslint-disable no-param-reassign, class-methods-use-this */
/* global Pager, Cookies */

((global) => {
  class Activities {
    constructor() {
Fatih Acet's avatar
Fatih Acet committed
7
      Pager.init(20, true, false, this.updateTooltips);
8 9 10
      $('.event-filter-link').on('click', (e) => {
        e.preventDefault();
        this.toggleFilter(e.currentTarget);
11 12
        this.reloadActivities();
      });
Fatih Acet's avatar
Fatih Acet committed
13 14
    }

15
    updateTooltips() {
16
      gl.utils.localTimeAgo($('.js-timeago', '.content_list'));
17
    }
Fatih Acet's avatar
Fatih Acet committed
18

19 20
    reloadActivities() {
      $('.content_list').html('');
21
      Pager.init(20, true, false, this.updateTooltips);
22
    }
23

24
    toggleFilter(sender) {
25 26
      const $sender = $(sender);
      const filter = $sender.attr('id').split('_')[0];
Fatih Acet's avatar
Fatih Acet committed
27

28 29
      $('.event-filter .active').removeClass('active');
      Cookies.set('event_filter', filter);
Fatih Acet's avatar
Fatih Acet committed
30

31
      $sender.closest('li').toggleClass('active');
32 33
    }
  }
Fatih Acet's avatar
Fatih Acet committed
34

35 36
  global.Activities = Activities;
})(window.gl || (window.gl = {}));