Skip to content

Commit f21728b

Browse files
committed
move legacy "branch/tag selector" related code into repo-legacy.ts
1 parent 39378ee commit f21728b

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

Diff for: web_src/js/features/repo-common.ts

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import $ from 'jquery';
2-
import {hideElem, queryElems, showElem} from '../utils/dom.ts';
1+
import {queryElems} from '../utils/dom.ts';
32
import {POST} from '../modules/fetch.ts';
43
import {showErrorToast} from '../modules/toast.ts';
54
import {sleep} from '../utils.ts';
@@ -108,33 +107,6 @@ export function initRepoCloneButtons() {
108107
queryElems(document, '.clone-buttons-combo', initCloneSchemeUrlSelection);
109108
}
110109

111-
export function initRepoCommonBranchOrTagDropdown(selector: string) {
112-
$(selector).each(function () {
113-
const $dropdown = $(this);
114-
$dropdown.find('.reference.column').on('click', function () {
115-
hideElem($dropdown.find('.scrolling.reference-list-menu'));
116-
showElem($($(this).data('target')));
117-
return false;
118-
});
119-
});
120-
}
121-
122-
export function initRepoCommonFilterSearchDropdown(selector: string) {
123-
const $dropdown = $(selector);
124-
if (!$dropdown.length) return;
125-
126-
$dropdown.dropdown({
127-
fullTextSearch: 'exact',
128-
selectOnKeydown: false,
129-
onChange(_text, _value, $choice) {
130-
if ($choice[0].getAttribute('data-url')) {
131-
window.location.href = $choice[0].getAttribute('data-url');
132-
}
133-
},
134-
message: {noResults: $dropdown[0].getAttribute('data-no-results')},
135-
});
136-
}
137-
138110
export async function updateIssuesMeta(url, action, issue_ids, id) {
139111
try {
140112
const response = await POST(url, {data: new URLSearchParams({action, issue_ids, id})});

Diff for: web_src/js/features/repo-legacy.ts

+28-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import {
88
} from './repo-issue.ts';
99
import {initUnicodeEscapeButton} from './repo-unicode-escape.ts';
1010
import {initRepoBranchTagSelector} from '../components/RepoBranchTagSelector.vue';
11-
import {
12-
initRepoCloneButtons, initRepoCommonBranchOrTagDropdown, initRepoCommonFilterSearchDropdown,
13-
} from './repo-common.ts';
11+
import {initRepoCloneButtons} from './repo-common.ts';
1412
import {initCitationFileCopyContent} from './citation.ts';
1513
import {initCompLabelEdit} from './comp/LabelEdit.ts';
1614
import {initRepoDiffConversationNav} from './repo-diff.ts';
@@ -36,6 +34,33 @@ export function initBranchSelectorTabs() {
3634
});
3735
}
3836

37+
function initRepoCommonBranchOrTagDropdown(selector: string) {
38+
$(selector).each(function () {
39+
const $dropdown = $(this);
40+
$dropdown.find('.reference.column').on('click', function () {
41+
hideElem($dropdown.find('.scrolling.reference-list-menu'));
42+
showElem($($(this).data('target')));
43+
return false;
44+
});
45+
});
46+
}
47+
48+
function initRepoCommonFilterSearchDropdown(selector: string) {
49+
const $dropdown = $(selector);
50+
if (!$dropdown.length) return;
51+
52+
$dropdown.dropdown({
53+
fullTextSearch: 'exact',
54+
selectOnKeydown: false,
55+
onChange(_text, _value, $choice) {
56+
if ($choice[0].getAttribute('data-url')) {
57+
window.location.href = $choice[0].getAttribute('data-url');
58+
}
59+
},
60+
message: {noResults: $dropdown[0].getAttribute('data-no-results')},
61+
});
62+
}
63+
3964
export function initRepository() {
4065
if (!$('.page-content.repository').length) return;
4166

0 commit comments

Comments
 (0)