debian-mirror-gitlab/app/assets/javascripts/activities.js

38 lines
944 B
JavaScript
Raw Normal View History

2018-11-08 19:23:39 +05:30
/* eslint-disable class-methods-use-this */
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2017-08-17 22:00:37 +05:30
import Cookies from 'js-cookie';
2018-03-17 18:26:18 +05:30
import Pager from './pager';
import { localTimeAgo } from './lib/utils/datetime_utility';
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
export default class Activities {
2017-08-17 22:00:37 +05:30
constructor() {
2017-09-10 17:25:29 +05:30
Pager.init(20, true, false, data => data, this.updateTooltips);
2017-08-17 22:00:37 +05:30
$('.event-filter-link').on('click', (e) => {
e.preventDefault();
this.toggleFilter(e.currentTarget);
this.reloadActivities();
});
}
updateTooltips() {
2018-03-17 18:26:18 +05:30
localTimeAgo($('.js-timeago', '.content_list'));
2017-08-17 22:00:37 +05:30
}
reloadActivities() {
$('.content_list').html('');
2017-09-10 17:25:29 +05:30
Pager.init(20, true, false, data => data, this.updateTooltips);
2017-08-17 22:00:37 +05:30
}
toggleFilter(sender) {
const $sender = $(sender);
const filter = $sender.attr('id').split('_')[0];
$('.event-filter .active').removeClass('active');
Cookies.set('event_filter', filter);
$sender.closest('li').toggleClass('active');
}
}