diff options
author | Mike Greiling <mike@pixelcog.com> | 2016-11-20 08:52:53 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2016-11-20 10:32:20 +0300 |
commit | ed88515d56f72ba9f77cac2a4dca121fd34f622f (patch) | |
tree | 584e2517d8a29a1a00a3249df7a1c9ac6cd70864 /app/assets/javascripts | |
parent | 171ece8f8b238cea385cbc19441a44160d4d3e18 (diff) |
convert activities.js to es6 class syntax
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/activities.js.es6 | 52 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.es6 | 6 | ||||
-rw-r--r-- | app/assets/javascripts/user_tabs.js.es6 | 2 |
3 files changed, 29 insertions, 31 deletions
diff --git a/app/assets/javascripts/activities.js.es6 b/app/assets/javascripts/activities.js.es6 index 906a1a69d93..da8a4a8f3a2 100644 --- a/app/assets/javascripts/activities.js.es6 +++ b/app/assets/javascripts/activities.js.es6 @@ -1,37 +1,35 @@ -/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-undef, quotes, no-var, padded-blocks, max-len */ -(function() { - this.Activities = (function() { - function Activities() { +/* eslint-disable no-param-reassign, class-methods-use-this */ +/* global Pager, Cookies */ + +((global) => { + class Activities { + constructor() { Pager.init(20, true, false, this.updateTooltips); - $(".event-filter-link").on("click", (function(_this) { - return function(event) { - event.preventDefault(); - _this.toggleFilter($(event.currentTarget)); - return _this.reloadActivities(); - }; - })(this)); + $('.event-filter-link').on('click', (event) => { + event.preventDefault(); + this.toggleFilter($(event.currentTarget)); + this.reloadActivities(); + }); } - Activities.prototype.updateTooltips = function() { + updateTooltips() { gl.utils.localTimeAgo($('.js-timeago', '.content_list')); - }; + } - Activities.prototype.reloadActivities = function() { - $(".content_list").html(''); + reloadActivities() { + $('.content_list').html(''); 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 = {})); diff --git a/app/assets/javascripts/dispatcher.js.es6 b/app/assets/javascripts/dispatcher.js.es6 index 756a24cc0fc..ab4858dca32 100644 --- a/app/assets/javascripts/dispatcher.js.es6 +++ b/app/assets/javascripts/dispatcher.js.es6 @@ -110,10 +110,10 @@ Issuable.init(); break; case 'dashboard:activity': - new Activities(); + new gl.Activities(); break; case 'dashboard:projects:starred': - new Activities(); + new gl.Activities(); break; case 'projects:commit:show': new Commit(); @@ -139,7 +139,7 @@ new gl.Pipelines(); break; case 'groups:activity': - new Activities(); + new gl.Activities(); break; case 'groups:show': shortcut_handler = new ShortcutsNavigation(); diff --git a/app/assets/javascripts/user_tabs.js.es6 b/app/assets/javascripts/user_tabs.js.es6 index 2b310da319c..5a625611987 100644 --- a/app/assets/javascripts/user_tabs.js.es6 +++ b/app/assets/javascripts/user_tabs.js.es6 @@ -134,7 +134,7 @@ content on the Users#show page. } const $calendarWrap = this.$parentEl.find('.user-calendar'); $calendarWrap.load($calendarWrap.data('href')); - new Activities(); + new gl.Activities(); return this.loaded['activity'] = true; } |