Skip to content

Commit 2b3f7d3

Browse files
authored
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 <[email protected]>
1 parent bcf3be3 commit 2b3f7d3

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

web_src/js/features/repo-settings.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,24 @@ export function initRepoSettingGitHook() {
7777
}
7878

7979
export function initRepoSettingBranches() {
80-
if (!$('.repository.settings.branches').length) return;
81-
$('.toggle-target-enabled').on('change', function () {
82-
const $target = $(this.getAttribute('data-target'));
83-
$target.toggleClass('disabled', !this.checked);
84-
});
85-
$('.toggle-target-disabled').on('change', function () {
86-
const $target = $(this.getAttribute('data-target'));
87-
if (this.checked) $target.addClass('disabled'); // only disable, do not auto enable
88-
});
89-
$('#dismiss_stale_approvals').on('change', function () {
90-
const $target = $('#ignore_stale_approvals_box');
91-
$target.toggleClass('disabled', this.checked);
80+
if (!document.querySelector('.repository.settings.branches')) return;
81+
82+
for (const el of document.getElementsByClassName('toggle-target-enabled')) {
83+
el.addEventListener('change', function () {
84+
const target = document.querySelector(this.getAttribute('data-target'));
85+
target?.classList.toggle('disabled', !this.checked);
86+
});
87+
}
88+
89+
for (const el of document.getElementsByClassName('toggle-target-disabled')) {
90+
el.addEventListener('change', function () {
91+
const target = document.querySelector(this.getAttribute('data-target'));
92+
if (this.checked) target?.classList.add('disabled'); // only disable, do not auto enable
93+
});
94+
}
95+
96+
document.getElementById('dismiss_stale_approvals')?.addEventListener('change', function () {
97+
document.getElementById('ignore_stale_approvals_box')?.classList.toggle('disabled', this.checked);
9298
});
9399

94100
// show the `Matched` mark for the status checks that match the pattern
@@ -106,7 +112,6 @@ export function initRepoSettingBranches() {
106112
break;
107113
}
108114
}
109-
110115
toggleElem(el, matched);
111116
}
112117
};

0 commit comments

Comments
 (0)