diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-10-30 18:59:16 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-10-30 18:59:16 +0000 |
commit | 430131f720187772f46e776a100273aba0d13aa6 (patch) | |
tree | 256067c6fe2e9dfbdbb97189f0b00a70c13e69a2 /app/assets | |
parent | bba020a56cbedd6403b637ec7f9eaee258eb7c67 (diff) | |
download | gitlab-ce-430131f720187772f46e776a100273aba0d13aa6.tar.gz |
Remove issue and issue status select from global namespace
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/header.js | 14 | ||||
-rw-r--r-- | app/assets/javascripts/init_legacy_filters.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/issuable_bulk_update_sidebar.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/issue.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/issue_status_select.js | 58 | ||||
-rw-r--r-- | app/assets/javascripts/main.js | 6 |
6 files changed, 40 insertions, 51 deletions
diff --git a/app/assets/javascripts/header.js b/app/assets/javascripts/header.js index ea2e2205077..33a352e158a 100644 --- a/app/assets/javascripts/header.js +++ b/app/assets/javascripts/header.js @@ -7,10 +7,12 @@ import { highCountTrim } from '~/lib/utils/text_utility'; * @param {jQuery.Event} e * @param {String} count */ -$(document).on('todo:toggle', (e, count) => { - const parsedCount = parseInt(count, 10); - const $todoPendingCount = $('.todos-count'); +export default function initTodoToggle() { + $(document).on('todo:toggle', (e, count) => { + const parsedCount = parseInt(count, 10); + const $todoPendingCount = $('.todos-count'); - $todoPendingCount.text(highCountTrim(parsedCount)); - $todoPendingCount.toggleClass('hidden', parsedCount === 0); -}); + $todoPendingCount.text(highCountTrim(parsedCount)); + $todoPendingCount.toggleClass('hidden', parsedCount === 0); + }); +} diff --git a/app/assets/javascripts/init_legacy_filters.js b/app/assets/javascripts/init_legacy_filters.js index 1211c2c802c..fcf424408f2 100644 --- a/app/assets/javascripts/init_legacy_filters.js +++ b/app/assets/javascripts/init_legacy_filters.js @@ -1,15 +1,15 @@ /* eslint-disable no-new */ /* global LabelsSelect */ /* global MilestoneSelect */ -/* global IssueStatusSelect */ /* global SubscriptionSelect */ import UsersSelect from './users_select'; +import issueStatusSelect from './issue_status_select'; export default () => { new UsersSelect(); new LabelsSelect(); new MilestoneSelect(); - new IssueStatusSelect(); + issueStatusSelect(); new SubscriptionSelect(); }; diff --git a/app/assets/javascripts/issuable_bulk_update_sidebar.js b/app/assets/javascripts/issuable_bulk_update_sidebar.js index bb509089b1d..4a15ec8b147 100644 --- a/app/assets/javascripts/issuable_bulk_update_sidebar.js +++ b/app/assets/javascripts/issuable_bulk_update_sidebar.js @@ -1,12 +1,11 @@ /* eslint-disable class-methods-use-this, no-new */ /* global LabelsSelect */ /* global MilestoneSelect */ -/* global IssueStatusSelect */ /* global SubscriptionSelect */ import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import './milestone_select'; -import './issue_status_select'; +import issueStatusSelect from './issue_status_select'; import './subscription_select'; import './labels_select'; @@ -49,7 +48,7 @@ export default class IssuableBulkUpdateSidebar { initDropdowns() { new LabelsSelect(); new MilestoneSelect(); - new IssueStatusSelect(); + issueStatusSelect(); new SubscriptionSelect(); } diff --git a/app/assets/javascripts/issue.js b/app/assets/javascripts/issue.js index 3fc29f9a661..acd5730cf3c 100644 --- a/app/assets/javascripts/issue.js +++ b/app/assets/javascripts/issue.js @@ -6,7 +6,7 @@ import TaskList from './task_list'; import CreateMergeRequestDropdown from './create_merge_request_dropdown'; import IssuablesHelper from './helpers/issuables_helper'; -class Issue { +export default class Issue { constructor() { if ($('a.btn-close').length) { this.taskList = new TaskList({ @@ -147,5 +147,3 @@ class Issue { }); } } - -export default Issue; diff --git a/app/assets/javascripts/issue_status_select.js b/app/assets/javascripts/issue_status_select.js index 56cb536dcde..fabfd26e699 100644 --- a/app/assets/javascripts/issue_status_select.js +++ b/app/assets/javascripts/issue_status_select.js @@ -1,34 +1,26 @@ -/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, quotes, object-shorthand, no-unused-vars, no-shadow, one-var, one-var-declaration-per-line, comma-dangle, max-len */ -(function() { - this.IssueStatusSelect = (function() { - function IssueStatusSelect() { - $('.js-issue-status').each(function(i, el) { - var fieldName; - fieldName = $(el).data("field-name"); - return $(el).glDropdown({ - selectable: true, - fieldName: fieldName, - toggleLabel: (function(_this) { - return function(selected, el, instance) { - var $item, label; - label = 'Author'; - $item = instance.dropdown.find('.is-active'); - if ($item.length) { - label = $item.text(); - } - return label; - }; - })(this), - clicked: function(options) { - return options.e.preventDefault(); - }, - id: function(obj, el) { - return $(el).data("id"); +/* eslint-disable func-names,wrap-iife, no-shadow, no-unused-vars, one-var */ +export default function issueStatusSelect() { + $('.js-issue-status').each(function (i, el) { + const fieldName = $(el).data('field-name'); + return $(el).glDropdown({ + selectable: true, + fieldName, + toggleLabel: (function (_this) { + return function (selected, el, instance) { + let label = 'Author'; + const $item = instance.dropdown.find('.is-active'); + if ($item.length) { + label = $item.text(); } - }); - }); - } - - return IssueStatusSelect; - })(); -}).call(window); + return label; + }; + })(this), + clicked(options) { + return options.e.preventDefault(); + }, + id(obj, el) { + return $(el).data('id'); + }, + }); + }); +} diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index fd9d0c335a5..d743f20c615 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -54,11 +54,8 @@ import './gl_dropdown'; import './gl_field_error'; import './gl_field_errors'; import './gl_form'; -import './header'; +import initTodoToggle from './header'; import initImporterStatus from './importer_status'; -import './issuable_form'; -import './issue'; -import './issue_status_select'; import './labels_select'; import './layout_nav'; import LazyLoader from './lazy_loader'; @@ -137,6 +134,7 @@ $(function () { initBreadcrumbs(); initImporterStatus(); + initTodoToggle(); // Set the default path for all cookies to GitLab's root directory Cookies.defaults.path = gon.relative_url_root || '/'; |