BigW Consortium Gitlab

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

import Cookies from 'js-cookie';
5

6 7
class Activities {
  constructor() {
8 9
    Pager.init(20, true, false, data => data, this.updateTooltips);

10 11 12 13 14 15
    $('.event-filter-link').on('click', (e) => {
      e.preventDefault();
      this.toggleFilter(e.currentTarget);
      this.reloadActivities();
    });
  }
Fatih Acet committed
16

17 18 19
  updateTooltips() {
    gl.utils.localTimeAgo($('.js-timeago', '.content_list'));
  }
Fatih Acet committed
20

21 22
  reloadActivities() {
    $('.content_list').html('');
23
    Pager.init(20, true, false, data => data, this.updateTooltips);
24
  }
25

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

30 31
    $('.event-filter .active').removeClass('active');
    Cookies.set('event_filter', filter);
Fatih Acet committed
32

33
    $sender.closest('li').toggleClass('active');
34
  }
35
}
Fatih Acet committed
36

37 38
window.gl = window.gl || {};
window.gl.Activities = Activities;