diff options
author | Yarden Shoham <git@yardenshoham.com> | 2024-03-31 00:30:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-30 22:30:00 +0100 |
commit | 2b3f7d3e966ab60cb147115303d1992e8b50d4df (patch) | |
tree | 6e428936bff6a4a21ad35c6f77f440094f418251 | |
parent | bcf3be3a6c2794f7a3841f9d110b14be29327e1a (diff) | |
download | gitea-2b3f7d3e966ab60cb147115303d1992e8b50d4df.tar.gz gitea-2b3f7d3e966ab60cb147115303d1992e8b50d4df.zip |
Remove jQuery class from the repository branch settings (#30184)
- Switched from jQuery class functions to plain JavaScript `classList`
- Tested the repository branch settings functionality and it works as
before
Signed-off-by: Yarden Shoham <git@yardenshoham.com>
-rw-r--r-- | web_src/js/features/repo-settings.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/web_src/js/features/repo-settings.js b/web_src/js/features/repo-settings.js index 0ea44130d0..52c5de2bfa 100644 --- a/web_src/js/features/repo-settings.js +++ b/web_src/js/features/repo-settings.js @@ -77,18 +77,24 @@ export function initRepoSettingGitHook() { } export function initRepoSettingBranches() { - if (!$('.repository.settings.branches').length) return; - $('.toggle-target-enabled').on('change', function () { - const $target = $(this.getAttribute('data-target')); - $target.toggleClass('disabled', !this.checked); - }); - $('.toggle-target-disabled').on('change', function () { - const $target = $(this.getAttribute('data-target')); - if (this.checked) $target.addClass('disabled'); // only disable, do not auto enable - }); - $('#dismiss_stale_approvals').on('change', function () { - const $target = $('#ignore_stale_approvals_box'); - $target.toggleClass('disabled', this.checked); + if (!document.querySelector('.repository.settings.branches')) return; + + for (const el of document.getElementsByClassName('toggle-target-enabled')) { + el.addEventListener('change', function () { + const target = document.querySelector(this.getAttribute('data-target')); + target?.classList.toggle('disabled', !this.checked); + }); + } + + for (const el of document.getElementsByClassName('toggle-target-disabled')) { + el.addEventListener('change', function () { + const target = document.querySelector(this.getAttribute('data-target')); + if (this.checked) target?.classList.add('disabled'); // only disable, do not auto enable + }); + } + + document.getElementById('dismiss_stale_approvals')?.addEventListener('change', function () { + document.getElementById('ignore_stale_approvals_box')?.classList.toggle('disabled', this.checked); }); // show the `Matched` mark for the status checks that match the pattern @@ -106,7 +112,6 @@ export function initRepoSettingBranches() { break; } } - toggleElem(el, matched); } }; |