Commit ed88515d authored by Mike Greiling's avatar Mike Greiling

convert activities.js to es6 class syntax

parent 171ece8f
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-undef, quotes, no-var, padded-blocks, max-len */ /* eslint-disable no-param-reassign, class-methods-use-this */
(function() { /* global Pager, Cookies */
this.Activities = (function() {
function Activities() { ((global) => {
class Activities {
constructor() {
Pager.init(20, true, false, this.updateTooltips); Pager.init(20, true, false, this.updateTooltips);
$(".event-filter-link").on("click", (function(_this) { $('.event-filter-link').on('click', (event) => {
return function(event) { event.preventDefault();
event.preventDefault(); this.toggleFilter($(event.currentTarget));
_this.toggleFilter($(event.currentTarget)); this.reloadActivities();
return _this.reloadActivities(); });
};
})(this));
} }
Activities.prototype.updateTooltips = function() { updateTooltips() {
gl.utils.localTimeAgo($('.js-timeago', '.content_list')); gl.utils.localTimeAgo($('.js-timeago', '.content_list'));
}; }
Activities.prototype.reloadActivities = function() { reloadActivities() {
$(".content_list").html(''); $('.content_list').html('');
Pager.init(20, true, false, this.updateTooltips); Pager.init(20, true, false, this.updateTooltips);
}; }
Activities.prototype.toggleFilter = function(sender) {
var filter = sender.attr("id").split("_")[0];
$('.event-filter .active').removeClass("active");
Cookies.set("event_filter", filter);
sender.closest('li').toggleClass("active"); toggleFilter(sender) {
}; const filter = sender.attr('id').split('_')[0];
return Activities; $('.event-filter .active').removeClass('active');
Cookies.set('event_filter', filter);
})(); sender.closest('li').toggleClass('active');
}
}
}).call(this); global.Activities = Activities;
})(window.gl || (window.gl = {}));
...@@ -110,10 +110,10 @@ ...@@ -110,10 +110,10 @@
Issuable.init(); Issuable.init();
break; break;
case 'dashboard:activity': case 'dashboard:activity':
new Activities(); new gl.Activities();
break; break;
case 'dashboard:projects:starred': case 'dashboard:projects:starred':
new Activities(); new gl.Activities();
break; break;
case 'projects:commit:show': case 'projects:commit:show':
new Commit(); new Commit();
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
new gl.Pipelines(); new gl.Pipelines();
break; break;
case 'groups:activity': case 'groups:activity':
new Activities(); new gl.Activities();
break; break;
case 'groups:show': case 'groups:show':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
......
...@@ -134,7 +134,7 @@ content on the Users#show page. ...@@ -134,7 +134,7 @@ content on the Users#show page.
} }
const $calendarWrap = this.$parentEl.find('.user-calendar'); const $calendarWrap = this.$parentEl.find('.user-calendar');
$calendarWrap.load($calendarWrap.data('href')); $calendarWrap.load($calendarWrap.data('href'));
new Activities(); new gl.Activities();
return this.loaded['activity'] = true; return this.loaded['activity'] = true;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= spinner = spinner
:javascript :javascript
var activity = new Activities(); var activity = new gl.Activities();
$(document).on('page:restore', function (event) { $(document).on('page:restore', function (event) {
activity.reloadActivities() activity.reloadActivities()
}) })
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
describe('Activities', () => { describe('Activities', () => {
beforeEach(() => { beforeEach(() => {
fixture.load(fixtureTemplate); fixture.load(fixtureTemplate);
new Activities(); new gl.Activities();
}); });
for(let i = 0; i < filters.length; i++) { for(let i = 0; i < filters.length; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment