mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-23 15:39:22 +00:00
chore: enable no-jquery/no-trigger
- A lot of substitution to `.requestSubmit()`. - Where possible, rewrite some other jquery to vanilla javascript to ease the linter fix.
This commit is contained in:
parent
c124014115
commit
9420d3d0a5
9 changed files with 34 additions and 31 deletions
|
@ -381,7 +381,7 @@ export default tseslint.config(
|
|||
'no-jquery/no-sub': [2],
|
||||
'no-jquery/no-support': [2],
|
||||
'no-jquery/no-text': [0],
|
||||
'no-jquery/no-trigger': [0],
|
||||
'no-jquery/no-trigger': [2],
|
||||
'no-jquery/no-trim': [2],
|
||||
'no-jquery/no-type': [2],
|
||||
'no-jquery/no-unique': [2],
|
||||
|
|
|
@ -98,14 +98,14 @@ const sfc = {
|
|||
$(`#${this.branchForm} input[name="refType"]`).val('branch');
|
||||
}
|
||||
if (this.submitForm) {
|
||||
$(`#${this.branchForm}`).trigger('submit');
|
||||
document.getElementById(this.branchForm).requestSubmit();
|
||||
}
|
||||
this.menuVisible = false;
|
||||
}
|
||||
},
|
||||
createNewBranch() {
|
||||
if (!this.showCreateNewBranch) return;
|
||||
$(this.$refs.newBranchForm).trigger('submit');
|
||||
this.$refs.newBranchForm.requestSubmit();
|
||||
},
|
||||
focusSearchField() {
|
||||
nextTick(() => {
|
||||
|
|
|
@ -175,7 +175,7 @@ export function initAdminCommon() {
|
|||
onUsePagedSearchChange();
|
||||
}
|
||||
});
|
||||
$('#auth_type').trigger('change');
|
||||
document.getElementById('auth_type').dispatchEvent(new Event('change'));
|
||||
document.getElementById('security_protocol')?.addEventListener('change', onSecurityProtocolChange);
|
||||
document.getElementById('use_paged_search')?.addEventListener('change', onUsePagedSearchChange);
|
||||
document.getElementById('oauth2_provider')?.addEventListener('change', () => onOAuth2Change(true));
|
||||
|
@ -200,10 +200,12 @@ export function initAdminCommon() {
|
|||
}
|
||||
|
||||
if (document.querySelector('.admin.authentication')) {
|
||||
$('#auth_name').on('input', function () {
|
||||
const authNameEl = document.getElementById('auth_name');
|
||||
authNameEl.addEventListener('input', (el) => {
|
||||
// appSubUrl is either empty or is a path that starts with `/` and doesn't have a trailing slash.
|
||||
document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(this.value)}/callback`;
|
||||
}).trigger('input');
|
||||
document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(el.target.value)}/callback`;
|
||||
});
|
||||
authNameEl.dispatchEvent(new Event('input'));
|
||||
}
|
||||
|
||||
// Notice
|
||||
|
|
|
@ -57,7 +57,7 @@ export function initGlobalEnterQuickSubmit() {
|
|||
export function initGlobalButtonClickOnEnter() {
|
||||
$(document).on('keypress', 'div.ui.button,span.ui.button', (e) => {
|
||||
if (e.code === ' ' || e.code === 'Enter') {
|
||||
$(e.target).trigger('click');
|
||||
e.target.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
@ -314,7 +314,7 @@ export function initGlobalLinkActions() {
|
|||
closable: false,
|
||||
onApprove: async () => {
|
||||
if ($this.data('type') === 'form') {
|
||||
$($this.data('form')).trigger('submit');
|
||||
document.querySelector($this.data('form')).requestSubmit();
|
||||
return;
|
||||
}
|
||||
if ($this[0].getAttribute('hx-confirm')) {
|
||||
|
|
|
@ -38,7 +38,7 @@ export function initCompLabelEdit(selector) {
|
|||
form.reportValidity();
|
||||
return false;
|
||||
}
|
||||
$('.new-label.form').trigger('submit');
|
||||
document.querySelector('.new-label.form').requestSubmit();
|
||||
},
|
||||
}).modal('show');
|
||||
return false;
|
||||
|
@ -75,7 +75,7 @@ export function initCompLabelEdit(selector) {
|
|||
form.reportValidity();
|
||||
return false;
|
||||
}
|
||||
$('.edit-label.form').trigger('submit');
|
||||
document.querySelector('.edit-label.form').requestSubmit();
|
||||
},
|
||||
}).modal('show');
|
||||
return false;
|
||||
|
|
|
@ -184,7 +184,8 @@ export function initRepoCodeView() {
|
|||
$('html, body').scrollTop($first.offset().top - 200);
|
||||
}
|
||||
}
|
||||
}).trigger('hashchange');
|
||||
});
|
||||
window.dispatchEvent(new Event('hashchange'));
|
||||
}
|
||||
$(document).on('click', '.fold-file', ({currentTarget}) => {
|
||||
invertFileFolding(currentTarget.closest('.file-content'), currentTarget);
|
||||
|
|
|
@ -33,25 +33,25 @@ export function initRepoArchiveLinks() {
|
|||
}
|
||||
|
||||
export function initRepoCloneLink() {
|
||||
const $repoCloneSsh = $('#repo-clone-ssh');
|
||||
const $repoCloneHttps = $('#repo-clone-https');
|
||||
const $inputLink = $('#repo-clone-url');
|
||||
const repoCloneSSH = document.getElementById('repo-clone-ssh');
|
||||
const repoCloneHTTPS = document.getElementById('repo-clone-https');
|
||||
const inputLink = document.getElementById('repo-clone-url');
|
||||
|
||||
if ((!$repoCloneSsh.length && !$repoCloneHttps.length) || !$inputLink.length) {
|
||||
if ((!repoCloneSSH && !repoCloneHTTPS) || !inputLink) {
|
||||
return;
|
||||
}
|
||||
|
||||
$repoCloneSsh.on('click', () => {
|
||||
repoCloneSSH.addEventListener('click', () => {
|
||||
localStorage.setItem('repo-clone-protocol', 'ssh');
|
||||
window.updateCloneStates();
|
||||
});
|
||||
$repoCloneHttps.on('click', () => {
|
||||
repoCloneHTTPS.addEventListener('click', () => {
|
||||
localStorage.setItem('repo-clone-protocol', 'https');
|
||||
window.updateCloneStates();
|
||||
});
|
||||
|
||||
$inputLink.on('focus', () => {
|
||||
$inputLink.trigger('select');
|
||||
inputLink.addEventListener('focus', () => {
|
||||
inputLink.select();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ export function initRepoEditor() {
|
|||
$('#edit-empty-content-modal')
|
||||
.modal({
|
||||
onApprove() {
|
||||
$('.edit.form').trigger('submit');
|
||||
document.querySelector('.edit.form').requestSubmit();
|
||||
},
|
||||
})
|
||||
.modal('show');
|
||||
|
|
|
@ -37,27 +37,27 @@ export function initRepoIssueTimeTracking() {
|
|||
$('.issue-start-time-modal').modal({
|
||||
duration: 200,
|
||||
onApprove() {
|
||||
$('#add_time_manual_form').trigger('submit');
|
||||
document.getElementById('add_time_manual_form').requestSubmit();
|
||||
},
|
||||
}).modal('show');
|
||||
$('.issue-start-time-modal input').on('keydown', (e) => {
|
||||
if ((e.keyCode || e.key) === 13) {
|
||||
$('#add_time_manual_form').trigger('submit');
|
||||
document.getElementById('add_time_manual_form').requestSubmit();
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).on('click', '.issue-start-time, .issue-stop-time', () => {
|
||||
$('#toggle_stopwatch_form').trigger('submit');
|
||||
document.getElementById('toggle_stopwatch_form').requestSubmit();
|
||||
});
|
||||
$(document).on('click', '.issue-cancel-time', () => {
|
||||
$('#cancel_stopwatch_form').trigger('submit');
|
||||
document.getElementById('cancel_stopwatch_form').requestSubmit();
|
||||
});
|
||||
$(document).on('click', 'button.issue-delete-time', function () {
|
||||
const sel = `.issue-delete-time-modal[data-id="${$(this).data('id')}"]`;
|
||||
$(sel).modal({
|
||||
duration: 200,
|
||||
onApprove() {
|
||||
$(`${sel} form`).trigger('submit');
|
||||
document.getElementById(`${sel} form`).requestSubmit();
|
||||
},
|
||||
}).modal('show');
|
||||
});
|
||||
|
@ -247,7 +247,7 @@ export function initRepoIssueDependencyDelete() {
|
|||
onApprove: () => {
|
||||
$('#removeDependencyID').val(id);
|
||||
$('#dependencyType').val(type);
|
||||
$('#removeDependencyForm').trigger('submit');
|
||||
document.getElementById('removeDependencyForm').requestSubmit();
|
||||
},
|
||||
}).modal('show');
|
||||
});
|
||||
|
@ -369,9 +369,9 @@ export function initRepoIssueWipTitle() {
|
|||
$('.title_wip_desc > a').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const $issueTitle = $('#issue_title');
|
||||
$issueTitle.trigger('focus');
|
||||
const value = $issueTitle.val().trim().toUpperCase();
|
||||
const issueTitleEl = document.getElementById('issue_title');
|
||||
issueTitleEl.focus();
|
||||
const value = issueTitleEl.value.trim().toUpperCase();
|
||||
|
||||
const wipPrefixes = $('.title_wip_desc').data('wip-prefixes');
|
||||
for (const prefix of wipPrefixes) {
|
||||
|
@ -380,7 +380,7 @@ export function initRepoIssueWipTitle() {
|
|||
}
|
||||
}
|
||||
|
||||
$issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`);
|
||||
issueTitleEl.value = `${wipPrefixes[0]} ${issueTitleEl.value}`;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue