loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Gusted 9420d3d0 c1240141

+34 -31
+1 -1
eslint.config.mjs
··· 381 381 'no-jquery/no-sub': [2], 382 382 'no-jquery/no-support': [2], 383 383 'no-jquery/no-text': [0], 384 - 'no-jquery/no-trigger': [0], 384 + 'no-jquery/no-trigger': [2], 385 385 'no-jquery/no-trim': [2], 386 386 'no-jquery/no-type': [2], 387 387 'no-jquery/no-unique': [2],
+2 -2
web_src/js/components/RepoBranchTagSelector.vue
··· 98 98 $(`#${this.branchForm} input[name="refType"]`).val('branch'); 99 99 } 100 100 if (this.submitForm) { 101 - $(`#${this.branchForm}`).trigger('submit'); 101 + document.getElementById(this.branchForm).requestSubmit(); 102 102 } 103 103 this.menuVisible = false; 104 104 } 105 105 }, 106 106 createNewBranch() { 107 107 if (!this.showCreateNewBranch) return; 108 - $(this.$refs.newBranchForm).trigger('submit'); 108 + this.$refs.newBranchForm.requestSubmit(); 109 109 }, 110 110 focusSearchField() { 111 111 nextTick(() => {
+6 -4
web_src/js/features/admin/common.js
··· 175 175 onUsePagedSearchChange(); 176 176 } 177 177 }); 178 - $('#auth_type').trigger('change'); 178 + document.getElementById('auth_type').dispatchEvent(new Event('change')); 179 179 document.getElementById('security_protocol')?.addEventListener('change', onSecurityProtocolChange); 180 180 document.getElementById('use_paged_search')?.addEventListener('change', onUsePagedSearchChange); 181 181 document.getElementById('oauth2_provider')?.addEventListener('change', () => onOAuth2Change(true)); ··· 200 200 } 201 201 202 202 if (document.querySelector('.admin.authentication')) { 203 - $('#auth_name').on('input', function () { 203 + const authNameEl = document.getElementById('auth_name'); 204 + authNameEl.addEventListener('input', (el) => { 204 205 // appSubUrl is either empty or is a path that starts with `/` and doesn't have a trailing slash. 205 - document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(this.value)}/callback`; 206 - }).trigger('input'); 206 + document.getElementById('oauth2-callback-url').textContent = `${window.location.origin}${appSubUrl}/user/oauth2/${encodeURIComponent(el.target.value)}/callback`; 207 + }); 208 + authNameEl.dispatchEvent(new Event('input')); 207 209 } 208 210 209 211 // Notice
+2 -2
web_src/js/features/common-global.js
··· 57 57 export function initGlobalButtonClickOnEnter() { 58 58 $(document).on('keypress', 'div.ui.button,span.ui.button', (e) => { 59 59 if (e.code === ' ' || e.code === 'Enter') { 60 - $(e.target).trigger('click'); 60 + e.target.click(); 61 61 e.preventDefault(); 62 62 } 63 63 }); ··· 314 314 closable: false, 315 315 onApprove: async () => { 316 316 if ($this.data('type') === 'form') { 317 - $($this.data('form')).trigger('submit'); 317 + document.querySelector($this.data('form')).requestSubmit(); 318 318 return; 319 319 } 320 320 if ($this[0].getAttribute('hx-confirm')) {
+2 -2
web_src/js/features/comp/LabelEdit.js
··· 38 38 form.reportValidity(); 39 39 return false; 40 40 } 41 - $('.new-label.form').trigger('submit'); 41 + document.querySelector('.new-label.form').requestSubmit(); 42 42 }, 43 43 }).modal('show'); 44 44 return false; ··· 75 75 form.reportValidity(); 76 76 return false; 77 77 } 78 - $('.edit-label.form').trigger('submit'); 78 + document.querySelector('.edit-label.form').requestSubmit(); 79 79 }, 80 80 }).modal('show'); 81 81 return false;
+2 -1
web_src/js/features/repo-code.js
··· 184 184 $('html, body').scrollTop($first.offset().top - 200); 185 185 } 186 186 } 187 - }).trigger('hashchange'); 187 + }); 188 + window.dispatchEvent(new Event('hashchange')); 188 189 } 189 190 $(document).on('click', '.fold-file', ({currentTarget}) => { 190 191 invertFileFolding(currentTarget.closest('.file-content'), currentTarget);
+8 -8
web_src/js/features/repo-common.js
··· 33 33 } 34 34 35 35 export function initRepoCloneLink() { 36 - const $repoCloneSsh = $('#repo-clone-ssh'); 37 - const $repoCloneHttps = $('#repo-clone-https'); 38 - const $inputLink = $('#repo-clone-url'); 36 + const repoCloneSSH = document.getElementById('repo-clone-ssh'); 37 + const repoCloneHTTPS = document.getElementById('repo-clone-https'); 38 + const inputLink = document.getElementById('repo-clone-url'); 39 39 40 - if ((!$repoCloneSsh.length && !$repoCloneHttps.length) || !$inputLink.length) { 40 + if ((!repoCloneSSH && !repoCloneHTTPS) || !inputLink) { 41 41 return; 42 42 } 43 43 44 - $repoCloneSsh.on('click', () => { 44 + repoCloneSSH.addEventListener('click', () => { 45 45 localStorage.setItem('repo-clone-protocol', 'ssh'); 46 46 window.updateCloneStates(); 47 47 }); 48 - $repoCloneHttps.on('click', () => { 48 + repoCloneHTTPS.addEventListener('click', () => { 49 49 localStorage.setItem('repo-clone-protocol', 'https'); 50 50 window.updateCloneStates(); 51 51 }); 52 52 53 - $inputLink.on('focus', () => { 54 - $inputLink.trigger('select'); 53 + inputLink.addEventListener('focus', () => { 54 + inputLink.select(); 55 55 }); 56 56 } 57 57
+1 -1
web_src/js/features/repo-editor.js
··· 185 185 $('#edit-empty-content-modal') 186 186 .modal({ 187 187 onApprove() { 188 - $('.edit.form').trigger('submit'); 188 + document.querySelector('.edit.form').requestSubmit(); 189 189 }, 190 190 }) 191 191 .modal('show');
+10 -10
web_src/js/features/repo-issue.js
··· 37 37 $('.issue-start-time-modal').modal({ 38 38 duration: 200, 39 39 onApprove() { 40 - $('#add_time_manual_form').trigger('submit'); 40 + document.getElementById('add_time_manual_form').requestSubmit(); 41 41 }, 42 42 }).modal('show'); 43 43 $('.issue-start-time-modal input').on('keydown', (e) => { 44 44 if ((e.keyCode || e.key) === 13) { 45 - $('#add_time_manual_form').trigger('submit'); 45 + document.getElementById('add_time_manual_form').requestSubmit(); 46 46 } 47 47 }); 48 48 }); 49 49 $(document).on('click', '.issue-start-time, .issue-stop-time', () => { 50 - $('#toggle_stopwatch_form').trigger('submit'); 50 + document.getElementById('toggle_stopwatch_form').requestSubmit(); 51 51 }); 52 52 $(document).on('click', '.issue-cancel-time', () => { 53 - $('#cancel_stopwatch_form').trigger('submit'); 53 + document.getElementById('cancel_stopwatch_form').requestSubmit(); 54 54 }); 55 55 $(document).on('click', 'button.issue-delete-time', function () { 56 56 const sel = `.issue-delete-time-modal[data-id="${$(this).data('id')}"]`; 57 57 $(sel).modal({ 58 58 duration: 200, 59 59 onApprove() { 60 - $(`${sel} form`).trigger('submit'); 60 + document.getElementById(`${sel} form`).requestSubmit(); 61 61 }, 62 62 }).modal('show'); 63 63 }); ··· 247 247 onApprove: () => { 248 248 $('#removeDependencyID').val(id); 249 249 $('#dependencyType').val(type); 250 - $('#removeDependencyForm').trigger('submit'); 250 + document.getElementById('removeDependencyForm').requestSubmit(); 251 251 }, 252 252 }).modal('show'); 253 253 }); ··· 369 369 $('.title_wip_desc > a').on('click', (e) => { 370 370 e.preventDefault(); 371 371 372 - const $issueTitle = $('#issue_title'); 373 - $issueTitle.trigger('focus'); 374 - const value = $issueTitle.val().trim().toUpperCase(); 372 + const issueTitleEl = document.getElementById('issue_title'); 373 + issueTitleEl.focus(); 374 + const value = issueTitleEl.value.trim().toUpperCase(); 375 375 376 376 const wipPrefixes = $('.title_wip_desc').data('wip-prefixes'); 377 377 for (const prefix of wipPrefixes) { ··· 380 380 } 381 381 } 382 382 383 - $issueTitle.val(`${wipPrefixes[0]} ${$issueTitle.val()}`); 383 + issueTitleEl.value = `${wipPrefixes[0]} ${issueTitleEl.value}`; 384 384 }); 385 385 } 386 386