Skip to content

Commit fb14424

Browse files
committed
use export function instead of export {}, add more comments
1 parent b83e577 commit fb14424

37 files changed

+86
-203
lines changed

web_src/js/components/DashboardRepoList.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function initVueComponents() {
348348
}
349349

350350

351-
function initDashboardRepoList() {
351+
export function initDashboardRepoList() {
352352
const el = document.getElementById('dashboard-repo-list');
353353
const dashboardRepoListData = pageData.dashboardRepoList || null;
354354
if (!el || !dashboardRepoListData) return;
@@ -366,5 +366,3 @@ function initDashboardRepoList() {
366366
},
367367
});
368368
}
369-
370-
export {initDashboardRepoList};

web_src/js/components/RepoActivityTopAuthors.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,9 @@ const sfc = {
101101
}
102102
};
103103
104-
function initRepoActivityTopAuthorsChart() {
104+
export function initRepoActivityTopAuthorsChart() {
105105
initVueApp('#repo-activity-top-authors-chart', sfc);
106106
}
107107
108-
export default sfc;
109-
export {initRepoActivityTopAuthorsChart};
108+
export default sfc; // this line is necessary to activate the IDE's Vue plugin
110109
</script>

web_src/js/components/RepoBranchTagDropdown.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Vue from 'vue';
2+
import {vueDelimiters} from './VueComponentLoader.js';
23

3-
function initRepoBranchTagDropdown(selector) {
4+
export function initRepoBranchTagDropdown(selector) {
45
$(selector).each(function () {
56
const $dropdown = $(this);
67
const $data = $dropdown.find('.data');
@@ -26,7 +27,7 @@ function initRepoBranchTagDropdown(selector) {
2627
$data.remove();
2728
new Vue({
2829
el: this,
29-
delimiters: ['${', '}'],
30+
delimiters: vueDelimiters,
3031
data,
3132
computed: {
3233
filteredItems() {
@@ -157,5 +158,3 @@ function initRepoBranchTagDropdown(selector) {
157158
});
158159
});
159160
}
160-
161-
export {initRepoBranchTagDropdown};

web_src/js/components/VueComponentLoader.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Vue from 'vue';
22
import {svgs} from '../svg.js';
33

4-
const vueDelimiters = ['${', '}'];
4+
export const vueDelimiters = ['${', '}'];
55

66
let vueEnvInited = false;
7-
function initVueEnv() {
7+
export function initVueEnv() {
88
if (vueEnvInited) return;
99
vueEnvInited = true;
1010

@@ -14,7 +14,7 @@ function initVueEnv() {
1414
}
1515

1616
let vueSvgInited = false;
17-
function initVueSvg() {
17+
export function initVueSvg() {
1818
if (vueSvgInited) return;
1919
vueSvgInited = true;
2020

@@ -36,8 +36,7 @@ function initVueSvg() {
3636
}
3737
}
3838

39-
40-
function initVueApp(el, opts = {}) {
39+
export function initVueApp(el, opts = {}) {
4140
if (typeof el === 'string') {
4241
el = document.querySelector(el);
4342
}
@@ -48,5 +47,3 @@ function initVueApp(el, opts = {}) {
4847
delimiters: vueDelimiters,
4948
}, opts));
5049
}
51-
52-
export {vueDelimiters, initVueEnv, initVueSvg, initVueApp};

web_src/js/features/admin-common.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {csrf} = window.config;
22

3-
function initAdminCommon() {
3+
export function initAdminCommon() {
44
if ($('.admin').length === 0) {
55
return;
66
}
@@ -212,5 +212,3 @@ function initAdminCommon() {
212212
});
213213
}
214214
}
215-
216-
export {initAdminCommon};

web_src/js/features/admin-emails.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function initAdminEmails() {
1+
export function initAdminEmails() {
22
function linkEmailAction(e) {
33
const $this = $(this);
44
$('#form-uid').val($this.data('uid'));
@@ -10,5 +10,3 @@ function initAdminEmails() {
1010
}
1111
$('.link-email-action').on('click', linkEmailAction);
1212
}
13-
14-
export {initAdminEmails};

web_src/js/features/common-global.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import 'jquery.are-you-sure';
66

77
const {csrf} = window.config;
88

9-
function initGlobalFormDirtyLeaveConfirm() {
9+
export function initGlobalFormDirtyLeaveConfirm() {
1010
// Warn users that try to leave a page after entering data into a form.
1111
// Except on sign-in pages, and for forms marked as 'ignore-dirty'.
1212
if ($('.user.signin').length === 0) {
1313
$('form:not(.ignore-dirty)').areYouSure();
1414
}
1515
}
1616

17-
function initHeadNavbarContentToggle() {
17+
export function initHeadNavbarContentToggle() {
1818
const content = $('#navbar');
1919
const toggle = $('#navbar-expand-toggle');
2020
let isExpanded = false;
@@ -30,7 +30,7 @@ function initHeadNavbarContentToggle() {
3030
});
3131
}
3232

33-
function initFootLanguageMenu() {
33+
export function initFootLanguageMenu() {
3434
function linkLanguageAction() {
3535
const $this = $(this);
3636
$.post($this.data('url')).always(() => {
@@ -42,23 +42,23 @@ function initFootLanguageMenu() {
4242
}
4343

4444

45-
function initGlobalEnterQuickSubmit() {
45+
export function initGlobalEnterQuickSubmit() {
4646
$('.js-quick-submit').on('keydown', function (e) {
4747
if (((e.ctrlKey && !e.altKey) || e.metaKey) && (e.keyCode === 13 || e.keyCode === 10)) {
4848
$(this).closest('form').trigger('submit');
4949
}
5050
});
5151
}
5252

53-
function initGlobalButtonClickOnEnter() {
53+
export function initGlobalButtonClickOnEnter() {
5454
$(document).on('keypress', '.ui.button', (e) => {
5555
if (e.keyCode === 13 || e.keyCode === 32) { // enter key or space bar
5656
$(e.target).trigger('click');
5757
}
5858
});
5959
}
6060

61-
function initGlobalCommon() {
61+
export function initGlobalCommon() {
6262
// Show exact time
6363
$('.time-since').each(function () {
6464
$(this)
@@ -130,7 +130,7 @@ function initGlobalCommon() {
130130
});
131131
}
132132

133-
async function initGlobalDropzone() {
133+
export async function initGlobalDropzone() {
134134
// Dropzone
135135
for (const el of document.querySelectorAll('.dropzone')) {
136136
const $dropzone = $(el);
@@ -168,7 +168,7 @@ async function initGlobalDropzone() {
168168
}
169169
}
170170

171-
function initGlobalLinkActions() {
171+
export function initGlobalLinkActions() {
172172
function showDeletePopup() {
173173
const $this = $(this);
174174
const dataArray = $this.data();
@@ -278,7 +278,7 @@ function initGlobalLinkActions() {
278278
});
279279
}
280280

281-
function initGlobalButtons() {
281+
export function initGlobalButtons() {
282282
$('.show-panel.button').on('click', function () {
283283
$($(this).data('panel')).show();
284284
});
@@ -304,15 +304,3 @@ function initGlobalButtons() {
304304
});
305305
});
306306
}
307-
308-
export {
309-
initHeadNavbarContentToggle,
310-
initFootLanguageMenu,
311-
initGlobalEnterQuickSubmit,
312-
initGlobalFormDirtyLeaveConfirm,
313-
initGlobalButtonClickOnEnter,
314-
initGlobalCommon,
315-
initGlobalDropzone,
316-
initGlobalLinkActions,
317-
initGlobalButtons,
318-
};

web_src/js/features/common-issue.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {updateIssuesMeta} from './repo-issue.js';
22

3-
function initCommonIssue() {
3+
export function initCommonIssue() {
44
$('.issue-checkbox').on('click', () => {
55
const numChecked = $('.issue-checkbox').children('input:checked').length;
66
if (numChecked > 0) {
@@ -38,5 +38,3 @@ function initCommonIssue() {
3838
$(e).trigger('click');
3939
});
4040
}
41-
42-
export {initCommonIssue};

web_src/js/features/common-organization.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import {initCompLabelEdit} from './comp/LabelEdit.js';
22

3-
function initCommonOrganization() {
3+
export function initCommonOrganization() {
44
if ($('.organization').length === 0) {
55
return;
66
}
77

8-
// Options
98
if ($('.organization.settings.options').length > 0) {
109
$('#org_name').on('keyup', function () {
1110
const $prompt = $('#org-name-change-prompt');
@@ -23,5 +22,3 @@ function initCommonOrganization() {
2322
// Labels
2423
initCompLabelEdit('.organization.settings.labels');
2524
}
26-
27-
export {initCommonOrganization};
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import createColorPicker from '../colorpicker.js';
22

3-
function initCompColorPicker() {
3+
export function initCompColorPicker() {
44
createColorPicker($('.color-picker'));
55

66
$('.precolors .color').on('click', function () {
@@ -9,5 +9,3 @@ function initCompColorPicker() {
99
$('.minicolors-swatch-color').css('background-color', color_hex);
1010
});
1111
}
12-
13-
export {initCompColorPicker};

web_src/js/features/comp/CommentSimpleMDE.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import attachTribute from '../tribute.js';
22

3-
function createCommentSimpleMDE($editArea) {
3+
export function createCommentSimpleMDE($editArea) {
44
if ($editArea.length === 0) {
55
return null;
66
}
@@ -70,5 +70,3 @@ function createCommentSimpleMDE($editArea) {
7070
$(simplemde.codemirror.getInputField()).data('simplemde', simplemde);
7171
return simplemde;
7272
}
73-
74-
export {createCommentSimpleMDE};

web_src/js/features/comp/ImagePaste.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function replaceAndKeepCursor(field, oldval, newval) {
5353
}
5454
}
5555

56-
function initCompImagePaste($target) {
56+
export function initCompImagePaste($target) {
5757
$target.each(function () {
5858
const dropzone = this.querySelector('.dropzone');
5959
if (!dropzone) {
@@ -76,7 +76,7 @@ function initCompImagePaste($target) {
7676
});
7777
}
7878

79-
function initSimpleMDEImagePaste(simplemde, dropzone, files) {
79+
export function initSimpleMDEImagePaste(simplemde, dropzone, files) {
8080
const uploadUrl = dropzone.dataset.uploadUrl;
8181
simplemde.codemirror.on('paste', async (_, e) => {
8282
for (const img of clipboardPastedImages(e)) {
@@ -89,5 +89,3 @@ function initSimpleMDEImagePaste(simplemde, dropzone, files) {
8989
}
9090
});
9191
}
92-
93-
export {initCompImagePaste, initSimpleMDEImagePaste};

web_src/js/features/comp/LabelEdit.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {initCompColorPicker} from './ColorPicker.js';
22

3-
function initCompLabelEdit(selector) {
3+
export function initCompLabelEdit(selector) {
44
if (!$(selector).length) return;
55
// Create label
66
const $newLabelPanel = $('.new-label.segment');
@@ -28,5 +28,3 @@ function initCompLabelEdit(selector) {
2828
return false;
2929
});
3030
}
31-
32-
export {initCompLabelEdit};

web_src/js/features/comp/MarkupContentPreview.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {initMarkupContent} from '../../markup/content.js';
22

33
const {csrf} = window.config;
44

5-
function initCompMarkupContentPreviewTab($form) {
5+
export function initCompMarkupContentPreviewTab($form) {
66
const $tabMenu = $form.find('.tabular.menu');
77
$tabMenu.find('.item').tab();
88
$tabMenu.find(`.item[data-tab="${$tabMenu.data('preview')}"]`).on('click', function () {
@@ -19,5 +19,3 @@ function initCompMarkupContentPreviewTab($form) {
1919
});
2020
});
2121
}
22-
23-
export {initCompMarkupContentPreviewTab};

web_src/js/features/comp/ReactionSelector.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {csrf} = window.config;
22

3-
function initCompReactionSelector(parent) {
3+
export function initCompReactionSelector(parent) {
44
let reactions = '';
55
if (!parent) {
66
parent = $(document);
@@ -46,5 +46,3 @@ function initCompReactionSelector(parent) {
4646
});
4747
});
4848
}
49-
50-
export {initCompReactionSelector};

web_src/js/features/comp/SearchUserBox.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {htmlEscape} from 'escape-goat';
22

33
const {AppSubUrl} = window.config;
44

5-
function initSearchUserBox() {
5+
export function initSearchUserBox() {
66
const $searchUserBox = $('#search-user-box');
77
$searchUserBox.search({
88
minCharacters: 2,
@@ -34,5 +34,3 @@ function initSearchUserBox() {
3434
showNoResults: false
3535
});
3636
}
37-
38-
export {initSearchUserBox};

web_src/js/features/comp/WebHookEditor.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const {csrf} = window.config;
22

3-
function initWebHookEditor() {
3+
export function initWebHookEditor() {
44
if ($('.new.webhook').length === 0) {
55
return;
66
}
@@ -38,5 +38,3 @@ function initWebHookEditor() {
3838
);
3939
});
4040
}
41-
42-
export {initWebHookEditor};

web_src/js/features/install.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
function initInstall() {
1+
export function initInstall() {
32
if ($('.install').length === 0) {
43
return;
54
}
@@ -90,5 +89,3 @@ function initInstall() {
9089
}
9190
});
9291
}
93-
94-
export {initInstall};

0 commit comments

Comments
 (0)