2016-11-20 00:52:53 -05:00
|
|
|
/* eslint-disable no-param-reassign, class-methods-use-this */
|
2017-03-11 01:45:34 -05:00
|
|
|
|
2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2017-03-11 01:45:34 -05:00
|
|
|
import Cookies from 'js-cookie';
|
2017-12-15 04:31:58 -05:00
|
|
|
import Pager from './pager';
|
2017-12-07 06:09:17 -05:00
|
|
|
import { localTimeAgo } from './lib/utils/datetime_utility';
|
2016-11-20 00:52:53 -05:00
|
|
|
|
2017-12-14 06:50:40 -05:00
|
|
|
export default class Activities {
|
2017-03-11 02:30:44 -05:00
|
|
|
constructor() {
|
2017-06-02 21:40:20 -04:00
|
|
|
Pager.init(20, true, false, data => data, this.updateTooltips);
|
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
$('.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() {
|
2017-12-07 06:09:17 -05:00
|
|
|
localTimeAgo($('.js-timeago', '.content_list'));
|
2017-03-11 02:30:44 -05:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
reloadActivities() {
|
|
|
|
$('.content_list').html('');
|
2017-06-02 21:40:20 -04:00
|
|
|
Pager.init(20, true, false, data => data, this.updateTooltips);
|
2017-03-11 02:30:44 -05:00
|
|
|
}
|
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
|
|
|
}
|