diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 5ca1708f1b3..748b1993c56 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -8,7 +8,8 @@ /* global NewBranchForm */ /* global NotificationsForm */ /* global NotificationsDropdown */ -/* global GroupAvatar */ +import groupAvatar from './group_avatar'; +import GroupLabelSubscription from './group_label_subscription'; /* global LineHighlighter */ import BuildArtifacts from './build_artifacts'; import CILintEditor from './ci_lint_editor'; @@ -423,11 +424,11 @@ import Diff from './diff'; case 'admin:groups:create': BindInOut.initAll(); new Group(); - new GroupAvatar(); + groupAvatar(); break; case 'groups:edit': case 'admin:groups:edit': - new GroupAvatar(); + groupAvatar(); break; case 'projects:tree:show': shortcut_handler = new ShortcutsNavigation(); @@ -474,7 +475,7 @@ import Diff from './diff'; const $el = $(el); if ($el.find('.dropdown-group-label').length) { - new gl.GroupLabelSubscription($el); + new GroupLabelSubscription($el); } else { new gl.ProjectLabelSubscription($el); } diff --git a/app/assets/javascripts/group_avatar.js b/app/assets/javascripts/group_avatar.js index f03b47b1c1d..2168ff3a8ba 100644 --- a/app/assets/javascripts/group_avatar.js +++ b/app/assets/javascripts/group_avatar.js @@ -1,19 +1,12 @@ -/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, one-var, one-var-declaration-per-line, no-useless-escape, max-len */ - -window.GroupAvatar = (function() { - function GroupAvatar() { - $('.js-choose-group-avatar-button').on("click", function() { - var form; - form = $(this).closest("form"); - return form.find(".js-group-avatar-input").click(); - }); - $('.js-group-avatar-input').on("change", function() { - var filename, form; - form = $(this).closest("form"); - filename = $(this).val().replace(/^.*[\\\/]/, ''); - return form.find(".js-avatar-filename").text(filename); - }); - } - - return GroupAvatar; -})(); +export default function groupAvatar() { + $('.js-choose-group-avatar-button').on('click', function onClickGroupAvatar() { + const form = $(this).closest('form'); + return form.find('.js-group-avatar-input').click(); + }); + $('.js-group-avatar-input').on('change', function onChangeAvatarInput() { + const form = $(this).closest('form'); + // eslint-disable-next-line no-useless-escape + const filename = $(this).val().replace(/^.*[\\\/]/, ''); + return form.find('.js-avatar-filename').text(filename); + }); +} diff --git a/app/assets/javascripts/group_label_subscription.js b/app/assets/javascripts/group_label_subscription.js index 7dc9ce898e8..befaebb635e 100644 --- a/app/assets/javascripts/group_label_subscription.js +++ b/app/assets/javascripts/group_label_subscription.js @@ -1,6 +1,4 @@ -/* eslint-disable func-names, object-shorthand, comma-dangle, wrap-iife, space-before-function-paren, no-param-reassign, max-len */ - -class GroupLabelSubscription { +export default class GroupLabelSubscription { constructor(container) { const $container = $(container); this.$dropdown = $container.find('.dropdown'); @@ -18,7 +16,7 @@ class GroupLabelSubscription { $.ajax({ type: 'POST', - url: url + url, }).done(() => { this.toggleSubscriptionButtons(); this.$unsubscribeButtons.removeAttr('data-url'); @@ -35,7 +33,7 @@ class GroupLabelSubscription { $.ajax({ type: 'POST', - url: url + url, }).done(() => { this.toggleSubscriptionButtons(); }); @@ -47,6 +45,3 @@ class GroupLabelSubscription { this.$unsubscribeButtons.toggleClass('hidden'); } } - -window.gl = window.gl || {}; -window.gl.GroupLabelSubscription = GroupLabelSubscription; diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 6b13fda0d44..52715fba43f 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -55,8 +55,6 @@ import './gl_dropdown'; import './gl_field_error'; import './gl_field_errors'; import './gl_form'; -import './group_avatar'; -import './group_label_subscription'; import './groups_select'; import './header'; import './importer_status';