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.

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 <git@yardenshoham.com>
(cherry picked from commit a1f11e2e33f20409eac65b2d0e9a7cd7c767eb72)

authored by

Yarden Shoham and committed by
Earl Warren
95024f14 7e0dfa07

+22 -22
+18 -18
web_src/js/features/admin/common.js
··· 17 17 if ($(this).val().substring(0, 1) === '0') { 18 18 $('#user_name').removeAttr('disabled'); 19 19 $('#login_name').removeAttr('required'); 20 - hideElem($('.non-local')); 21 - showElem($('.local')); 20 + hideElem('.non-local'); 21 + showElem('.local'); 22 22 $('#user_name').trigger('focus'); 23 23 24 24 if ($(this).data('password') === 'required') { ··· 29 29 $('#user_name').attr('disabled', 'disabled'); 30 30 } 31 31 $('#login_name').attr('required', 'required'); 32 - showElem($('.non-local')); 33 - hideElem($('.local')); 32 + showElem('.non-local'); 33 + hideElem('.local'); 34 34 $('#login_name').trigger('focus'); 35 35 36 36 $('#password').removeAttr('required'); ··· 40 40 41 41 function onSecurityProtocolChange() { 42 42 if ($('#security_protocol').val() > 0) { 43 - showElem($('.has-tls')); 43 + showElem('.has-tls'); 44 44 } else { 45 - hideElem($('.has-tls')); 45 + hideElem('.has-tls'); 46 46 } 47 47 } 48 48 ··· 57 57 } 58 58 59 59 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'); 61 61 $('.open_id_connect_auto_discovery_url input[required]').removeAttr('required'); 62 62 63 63 const provider = $('#oauth2_provider').val(); 64 64 switch (provider) { 65 65 case 'openidConnect': 66 66 $('.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'); 68 68 break; 69 69 default: 70 70 if ($(`#${provider}_customURLSettings`).data('required')) { 71 71 $('#oauth2_use_custom_url').attr('checked', 'checked'); 72 72 } 73 73 if ($(`#${provider}_customURLSettings`).data('available')) { 74 - showElem($('.oauth2_use_custom_url')); 74 + showElem('.oauth2_use_custom_url'); 75 75 } 76 76 } 77 77 onOAuth2UseCustomURLChange(applyDefaultValues); ··· 79 79 80 80 function onOAuth2UseCustomURLChange(applyDefaultValues) { 81 81 const provider = $('#oauth2_provider').val(); 82 - hideElem($('.oauth2_use_custom_url_field')); 82 + hideElem('.oauth2_use_custom_url_field'); 83 83 $('.oauth2_use_custom_url_field input[required]').removeAttr('required'); 84 84 85 85 if (document.getElementById('oauth2_use_custom_url')?.checked) { ··· 102 102 // New authentication 103 103 if ($('.admin.new.authentication').length > 0) { 104 104 $('#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'); 106 106 107 107 $('.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'); 108 108 $('.binddnrequired').removeClass('required'); ··· 110 110 const authType = $(this).val(); 111 111 switch (authType) { 112 112 case '2': // LDAP 113 - showElem($('.ldap')); 113 + showElem('.ldap'); 114 114 $('.binddnrequired input, .ldap div.required:not(.dldap) input').attr('required', 'required'); 115 115 $('.binddnrequired').addClass('required'); 116 116 break; 117 117 case '3': // SMTP 118 - showElem($('.smtp')); 119 - showElem($('.has-tls')); 118 + showElem('.smtp'); 119 + showElem('.has-tls'); 120 120 $('.smtp div.required input, .has-tls').attr('required', 'required'); 121 121 break; 122 122 case '4': // PAM 123 - showElem($('.pam')); 123 + showElem('.pam'); 124 124 $('.pam input').attr('required', 'required'); 125 125 break; 126 126 case '5': // LDAP 127 - showElem($('.dldap')); 127 + showElem('.dldap'); 128 128 $('.dldap div.required:not(.ldap) input').attr('required', 'required'); 129 129 break; 130 130 case '6': // OAuth2 131 - showElem($('.oauth2')); 131 + showElem('.oauth2'); 132 132 $('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required'); 133 133 onOAuth2Change(true); 134 134 break; 135 135 case '7': // SSPI 136 - showElem($('.sspi')); 136 + showElem('.sspi'); 137 137 $('.sspi div.required input').attr('required', 'required'); 138 138 break; 139 139 }
+2 -2
web_src/js/features/org-team.js
··· 8 8 $('.organization.new.team input[name=permission]').on('change', () => { 9 9 const val = $('input[name=permission]:checked', '.organization.new.team').val(); 10 10 if (val === 'admin') { 11 - hideElem($('.organization.new.team .team-units')); 11 + hideElem('.organization.new.team .team-units'); 12 12 } else { 13 - showElem($('.organization.new.team .team-units')); 13 + showElem('.organization.new.team .team-units'); 14 14 } 15 15 }); 16 16 }
+2 -2
web_src/js/features/repo-editor.js
··· 64 64 65 65 $('.js-quick-pull-choice-option').on('change', function () { 66 66 if ($(this).val() === 'commit-to-new-branch') { 67 - showElem($('.quick-pull-branch-name')); 67 + showElem('.quick-pull-branch-name'); 68 68 document.querySelector('.quick-pull-branch-name input').required = true; 69 69 } else { 70 - hideElem($('.quick-pull-branch-name')); 70 + hideElem('.quick-pull-branch-name'); 71 71 document.querySelector('.quick-pull-branch-name input').required = false; 72 72 } 73 73 $('#commit-button').text(this.getAttribute('button_text'));