Refactor legacy JS (#33115)

This commit is contained in:
wxiaoguang 2025-01-06 17:38:42 +08:00 committed by GitHub
parent 40765b5d45
commit ef736b7e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 29 deletions

View file

@ -1,4 +1,3 @@
import $ from 'jquery';
import {POST} from '../modules/fetch.ts';
import {queryElems, toggleElem} from '../utils/dom.ts';
import {initIssueSidebarComboList} from './repo-issue-sidebar-combolist.ts';
@ -9,9 +8,8 @@ function initBranchSelector() {
if (!elSelectBranch) return;
const urlUpdateIssueRef = elSelectBranch.getAttribute('data-url-update-issueref');
const $selectBranch = $(elSelectBranch);
const $branchMenu = $selectBranch.find('.reference-list-menu');
$branchMenu.find('.item:not(.no-select)').on('click', async function (e) {
const elBranchMenu = elSelectBranch.querySelector('.reference-list-menu');
queryElems(elBranchMenu, '.item:not(.no-select)', (el) => el.addEventListener('click', async function (e) {
e.preventDefault();
const selectedValue = this.getAttribute('data-id'); // eg: "refs/heads/my-branch"
const selectedText = this.getAttribute('data-name'); // eg: "my-branch"
@ -29,7 +27,7 @@ function initBranchSelector() {
document.querySelector<HTMLInputElement>(selectedHiddenSelector).value = selectedValue;
elSelectBranch.querySelector('.text-branch-name').textContent = selectedText;
}
});
}));
}
function initRepoIssueDue() {