diff options
author | Phil Hughes <me@iamphill.com> | 2017-07-25 16:27:51 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-07-25 16:27:51 +0100 |
commit | fe27de8bf124d65013da1d82618a1ab45584ff68 (patch) | |
tree | 0826d84ae6697a957705ca677bf4db46306fc808 | |
parent | 205090fcfb741884215723281dfb0afb56efbbfb (diff) | |
download | gitlab-ce-fe27de8bf124d65013da1d82618a1ab45584ff68.tar.gz |
moved some code into new files
fixed duplication of code
-rw-r--r-- | app/assets/javascripts/dispatcher.js | 40 | ||||
-rw-r--r-- | app/assets/javascripts/init_issuable_sidebar.js | 16 | ||||
-rw-r--r-- | app/assets/javascripts/init_legacy_filters.js | 14 | ||||
-rw-r--r-- | app/assets/javascripts/init_notes.js | 14 | ||||
-rw-r--r-- | app/assets/javascripts/main.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/todos.js | 4 |
6 files changed, 52 insertions, 41 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 8a142e49b72..2802c3a375a 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -30,7 +30,6 @@ /* global IssuableContext */ /* global IssueStatusSelect */ /* global SubscriptionSelect */ -/* global Notes */ import Issue from './issue'; import BindInOut from './behaviors/bind_in_out'; @@ -66,6 +65,9 @@ import initSettingsPanels from './settings_panels'; import initExperimentalFlags from './experimental_flags'; import OAuthRememberMe from './oauth_remember_me'; import PerformanceBar from './performance_bar'; +import initNotes from './init_notes'; +import initLegacyFilters from './init_legacy_filters'; +import initIssuableSidebar from './init_issuable_sidebar'; (function() { var Dispatcher; @@ -130,42 +132,6 @@ import PerformanceBar from './performance_bar'; .init(); } - function initIssuableSidebar() { - new MilestoneSelect({ - full_path: gl.sidebarOptions.fullPath, - }); - new LabelsSelect(); - new IssuableContext(gl.sidebarOptions.currentUser); - gl.Subscription.bindAll('.subscription'); - new gl.DueDateSelectors(); - window.sidebar = new Sidebar(); - } - - function initLegacyFilters() { - new UsersSelect(); - new LabelsSelect(); - new MilestoneSelect(); - new IssueStatusSelect(); - new SubscriptionSelect(); - $('form.filter-form').on('submit', function (event) { - event.preventDefault(); - gl.utils.visitUrl(`${this.action}&${$(this).serialize()}`); - }); - } - - function initNotes() { - const dataEl = document.querySelector('.js-notes-data'); - const { - notesUrl, - notesIds, - now, - diffView, - autocomplete, - } = JSON.parse(dataEl.innerHTML); - - window.notes = new Notes(notesUrl, notesIds, now, diffView, autocomplete); - } - switch (page) { case 'profiles:preferences:show': initExperimentalFlags(); diff --git a/app/assets/javascripts/init_issuable_sidebar.js b/app/assets/javascripts/init_issuable_sidebar.js new file mode 100644 index 00000000000..82071348d99 --- /dev/null +++ b/app/assets/javascripts/init_issuable_sidebar.js @@ -0,0 +1,16 @@ +/* eslint-disable no-new */ +/* global MilestoneSelect */ +/* global LabelsSelect */ +/* global IssuableContext */ +/* global Sidebar */ + +export default () => { + new MilestoneSelect({ + full_path: gl.sidebarOptions.fullPath, + }); + new LabelsSelect(); + new IssuableContext(gl.sidebarOptions.currentUser); + gl.Subscription.bindAll('.subscription'); + new gl.DueDateSelectors(); + window.sidebar = new Sidebar(); +}; diff --git a/app/assets/javascripts/init_legacy_filters.js b/app/assets/javascripts/init_legacy_filters.js new file mode 100644 index 00000000000..aa25f295bbc --- /dev/null +++ b/app/assets/javascripts/init_legacy_filters.js @@ -0,0 +1,14 @@ +/* eslint-disable no-new */ +/* global UsersSelect */ +/* global LabelsSelect */ +/* global MilestoneSelect */ +/* global IssueStatusSelect */ +/* global SubscriptionSelect */ + +export default () => { + new UsersSelect(); + new LabelsSelect(); + new MilestoneSelect(); + new IssueStatusSelect(); + new SubscriptionSelect(); +}; diff --git a/app/assets/javascripts/init_notes.js b/app/assets/javascripts/init_notes.js new file mode 100644 index 00000000000..3a8b4360cb6 --- /dev/null +++ b/app/assets/javascripts/init_notes.js @@ -0,0 +1,14 @@ +/* global Notes */ + +export default () => { + const dataEl = document.querySelector('.js-notes-data'); + const { + notesUrl, + notesIds, + now, + diffView, + autocomplete, + } = JSON.parse(dataEl.innerHTML); + + window.notes = new Notes(notesUrl, notesIds, now, diffView, autocomplete); +}; diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 6d3f5390cf6..3afc420140d 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -346,4 +346,9 @@ $(function () { gl.utils.renderTimeago(); $(document).trigger('init.scrolling-tabs'); + + $('form.filter-form').on('submit', function (event) { + event.preventDefault(); + gl.utils.visitUrl(`${this.action}&${$(this).serialize()}`); + }); }); diff --git a/app/assets/javascripts/todos.js b/app/assets/javascripts/todos.js index cd305631c10..bba8b5abbb4 100644 --- a/app/assets/javascripts/todos.js +++ b/app/assets/javascripts/todos.js @@ -37,10 +37,6 @@ export default class Todos { this.initFilterDropdown($('.js-type-search'), 'type'); this.initFilterDropdown($('.js-action-search'), 'action_id'); - $('form.filter-form').on('submit', function applyFilters(event) { - event.preventDefault(); - gl.utils.visitUrl(`${this.action}&${$(this).serialize()}`); - }); return new UsersSelect(); } |