2016-11-20 00:52:53 -05:00
|
|
|
/* eslint-disable no-param-reassign, class-methods-use-this */
|
2016-11-21 18:19:51 -05:00
|
|
|
/* global Pager */
|
2017-03-11 01:45:34 -05:00
|
|
|
|
|
|
|
import Cookies from 'js-cookie';
|
2016-11-20 00:52:53 -05:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
class Activities {
|
|
|
|
constructor() {
|
|
|
|
Pager.init(20, true, false, this.updateTooltips);
|
|
|
|
$('.event-filter-link').on('click', (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.toggleFilter(e.currentTarget);
|
|
|
|
this.reloadActivities();
|
|
|
|
});
|
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
updateTooltips() {
|
|
|
|
gl.utils.localTimeAgo($('.js-timeago', '.content_list'));
|
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
reloadActivities() {
|
|
|
|
$('.content_list').html('');
|
|
|
|
Pager.init(20, true, false, this.updateTooltips);
|
|
|
|
}
|
2016-08-29 13:09:33 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
toggleFilter(sender) {
|
|
|
|
const $sender = $(sender);
|
|
|
|
const filter = $sender.attr('id').split('_')[0];
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
$('.event-filter .active').removeClass('active');
|
|
|
|
Cookies.set('event_filter', filter);
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
$sender.closest('li').toggleClass('active');
|
2016-11-20 00:52:53 -05:00
|
|
|
}
|
2017-03-11 02:30:44 -05:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
window.gl = window.gl || {};
|
|
|
|
window.gl.Activities = Activities;
|