Skip to content

Commit d73223b

Browse files
Remove jQuery from the repo release form (#29225)
- Switched to plain JavaScript - Tested the repo release form functionality and it works as before # Demo using JavaScript without jQuery ![action](https://github.com/go-gitea/gitea/assets/20454870/ede2072a-823d-418f-9890-a5a7445a1cc6) --------- Signed-off-by: Yarden Shoham <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 658cbdd commit d73223b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

web_src/js/features/repo-release.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import $ from 'jquery';
21
import {hideElem, showElem} from '../utils/dom.js';
32
import {initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
43

54
export function initRepoRelease() {
6-
$(document).on('click', '.remove-rel-attach', function() {
7-
const uuid = $(this).data('uuid');
8-
const id = $(this).data('id');
9-
$(`input[name='attachment-del-${uuid}']`).attr('value', true);
10-
hideElem($(`#attachment-${id}`));
5+
document.addEventListener('click', (e) => {
6+
if (e.target.matches('.remove-rel-attach')) {
7+
const uuid = e.target.getAttribute('data-uuid');
8+
const id = e.target.getAttribute('data-id');
9+
document.querySelector(`input[name='attachment-del-${uuid}']`).value = 'true';
10+
hideElem(`#attachment-${id}`);
11+
}
1112
});
1213
}
1314

1415
export function initRepoReleaseNew() {
15-
const $repoReleaseNew = $('.repository.new.release');
16-
if (!$repoReleaseNew.length) return;
16+
if (!document.querySelector('.repository.new.release')) return;
1717

1818
initTagNameEditor();
1919
initRepoReleaseEditor();
@@ -45,9 +45,9 @@ function initTagNameEditor() {
4545
}
4646

4747
function initRepoReleaseEditor() {
48-
const $editor = $('.repository.new.release .combo-markdown-editor');
49-
if ($editor.length === 0) {
48+
const editor = document.querySelector('.repository.new.release .combo-markdown-editor');
49+
if (!editor) {
5050
return;
5151
}
52-
const _promise = initComboMarkdownEditor($editor);
52+
initComboMarkdownEditor(editor);
5353
}

0 commit comments

Comments
 (0)