gitlab-org--gitlab-foss/app/assets/javascripts/activities.js

37 lines
939 B
JavaScript
Raw Normal View History

/* eslint-disable no-param-reassign, class-methods-use-this */
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';
import { localTimeAgo } from './lib/utils/datetime_utility';
export default class Activities {
constructor() {
Pager.init(20, true, false, data => data, this.updateTooltips);
$('.event-filter-link').on('click', (e) => {
e.preventDefault();
this.toggleFilter(e.currentTarget);
this.reloadActivities();
});
}
2016-07-24 16:45:11 -04:00
updateTooltips() {
localTimeAgo($('.js-timeago', '.content_list'));
}
2016-07-24 16:45:11 -04:00
reloadActivities() {
$('.content_list').html('');
Pager.init(20, true, false, data => data, this.updateTooltips);
}
toggleFilter(sender) {
const $sender = $(sender);
const filter = $sender.attr('id').split('_')[0];
2016-07-24 16:45:11 -04:00
$('.event-filter .active').removeClass('active');
Cookies.set('event_filter', filter);
2016-07-24 16:45:11 -04:00
$sender.closest('li').toggleClass('active');
}
}