Skip to content

Commit a1f11e2

Browse files
authored
Remove jQuery calls that have no effect on showElem and hideElem (#30110)
There's no need to initialize a jQuery object with a CSS selector when we can pass the CSS selector directly. Signed-off-by: Yarden Shoham <[email protected]>
1 parent e0b0187 commit a1f11e2

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

web_src/js/features/admin/common.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export function initAdminCommon() {
1717
if ($(this).val().substring(0, 1) === '0') {
1818
$('#user_name').removeAttr('disabled');
1919
$('#login_name').removeAttr('required');
20-
hideElem($('.non-local'));
21-
showElem($('.local'));
20+
hideElem('.non-local');
21+
showElem('.local');
2222
$('#user_name').trigger('focus');
2323

2424
if ($(this).data('password') === 'required') {
@@ -29,8 +29,8 @@ export function initAdminCommon() {
2929
$('#user_name').attr('disabled', 'disabled');
3030
}
3131
$('#login_name').attr('required', 'required');
32-
showElem($('.non-local'));
33-
hideElem($('.local'));
32+
showElem('.non-local');
33+
hideElem('.local');
3434
$('#login_name').trigger('focus');
3535

3636
$('#password').removeAttr('required');
@@ -40,9 +40,9 @@ export function initAdminCommon() {
4040

4141
function onSecurityProtocolChange() {
4242
if ($('#security_protocol').val() > 0) {
43-
showElem($('.has-tls'));
43+
showElem('.has-tls');
4444
} else {
45-
hideElem($('.has-tls'));
45+
hideElem('.has-tls');
4646
}
4747
}
4848

@@ -57,29 +57,29 @@ export function initAdminCommon() {
5757
}
5858

5959
function onOAuth2Change(applyDefaultValues) {
60-
hideElem($('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url'));
60+
hideElem('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url');
6161
$('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');
6262

6363
const provider = $('#oauth2_provider').val();
6464
switch (provider) {
6565
case 'openidConnect':
6666
$('.open_id_connect_auto_discovery_url input').attr('required', 'required');
67-
showElem($('.open_id_connect_auto_discovery_url'));
67+
showElem('.open_id_connect_auto_discovery_url');
6868
break;
6969
default:
7070
if ($(`#${provider}_customURLSettings`).data('required')) {
7171
$('#oauth2_use_custom_url').attr('checked', 'checked');
7272
}
7373
if ($(`#${provider}_customURLSettings`).data('available')) {
74-
showElem($('.oauth2_use_custom_url'));
74+
showElem('.oauth2_use_custom_url');
7575
}
7676
}
7777
onOAuth2UseCustomURLChange(applyDefaultValues);
7878
}
7979

8080
function onOAuth2UseCustomURLChange(applyDefaultValues) {
8181
const provider = $('#oauth2_provider').val();
82-
hideElem($('.oauth2_use_custom_url_field'));
82+
hideElem('.oauth2_use_custom_url_field');
8383
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');
8484

8585
if (document.getElementById('oauth2_use_custom_url')?.checked) {
@@ -102,38 +102,38 @@ export function initAdminCommon() {
102102
// New authentication
103103
if ($('.admin.new.authentication').length > 0) {
104104
$('#auth_type').on('change', function () {
105-
hideElem($('.ldap, .dldap, .smtp, .pam, .oauth2, .has-tls, .search-page-size, .sspi'));
105+
hideElem('.ldap, .dldap, .smtp, .pam, .oauth2, .has-tls, .search-page-size, .sspi');
106106

107107
$('.ldap input[required], .binddnrequired input[required], .dldap input[required], .smtp input[required], .pam input[required], .oauth2 input[required], .has-tls input[required], .sspi input[required]').removeAttr('required');
108108
$('.binddnrequired').removeClass('required');
109109

110110
const authType = $(this).val();
111111
switch (authType) {
112112
case '2': // LDAP
113-
showElem($('.ldap'));
113+
showElem('.ldap');
114114
$('.binddnrequired input, .ldap div.required:not(.dldap) input').attr('required', 'required');
115115
$('.binddnrequired').addClass('required');
116116
break;
117117
case '3': // SMTP
118-
showElem($('.smtp'));
119-
showElem($('.has-tls'));
118+
showElem('.smtp');
119+
showElem('.has-tls');
120120
$('.smtp div.required input, .has-tls').attr('required', 'required');
121121
break;
122122
case '4': // PAM
123-
showElem($('.pam'));
123+
showElem('.pam');
124124
$('.pam input').attr('required', 'required');
125125
break;
126126
case '5': // LDAP
127-
showElem($('.dldap'));
127+
showElem('.dldap');
128128
$('.dldap div.required:not(.ldap) input').attr('required', 'required');
129129
break;
130130
case '6': // OAuth2
131-
showElem($('.oauth2'));
131+
showElem('.oauth2');
132132
$('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required');
133133
onOAuth2Change(true);
134134
break;
135135
case '7': // SSPI
136-
showElem($('.sspi'));
136+
showElem('.sspi');
137137
$('.sspi div.required input').attr('required', 'required');
138138
break;
139139
}

web_src/js/features/org-team.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export function initOrgTeamSettings() {
88
$('.organization.new.team input[name=permission]').on('change', () => {
99
const val = $('input[name=permission]:checked', '.organization.new.team').val();
1010
if (val === 'admin') {
11-
hideElem($('.organization.new.team .team-units'));
11+
hideElem('.organization.new.team .team-units');
1212
} else {
13-
showElem($('.organization.new.team .team-units'));
13+
showElem('.organization.new.team .team-units');
1414
}
1515
});
1616
}

web_src/js/features/repo-editor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export function initRepoEditor() {
6464

6565
$('.js-quick-pull-choice-option').on('change', function () {
6666
if ($(this).val() === 'commit-to-new-branch') {
67-
showElem($('.quick-pull-branch-name'));
67+
showElem('.quick-pull-branch-name');
6868
document.querySelector('.quick-pull-branch-name input').required = true;
6969
} else {
70-
hideElem($('.quick-pull-branch-name'));
70+
hideElem('.quick-pull-branch-name');
7171
document.querySelector('.quick-pull-branch-name input').required = false;
7272
}
7373
$('#commit-button').text(this.getAttribute('button_text'));

0 commit comments

Comments
 (0)