aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-03-26 20:06:11 +0800
committerGitHub <noreply@github.com>2023-03-26 20:06:11 +0800
commit59eb660b1a6881b2cdded486b67c3c283207c255 (patch)
treec36d4c61cad15b3c524dc2ea1bb9a1fef3dc8f6d /web_src/js/features
parent12fff36d057998fe553decdc81c881d3d0e70274 (diff)
downloadgitea-59eb660b1a6881b2cdded486b67c3c283207c255.tar.gz
gitea-59eb660b1a6881b2cdded486b67c3c283207c255.zip
Fix incorrect `toggle` buttons (#23676)
Some of those are still Copy&Paste problems. This PR: * Only cleans the legacy incorrect code, doesn't change or improve the "action" logic. * Remove the redundant `$('.toggle.button').on('click')`, now `$('.show-panel.button').on('click')` handles that kinds of buttons Actually, there is only one correct "toggle button" in code, the one on the webhook page. No need to backport.
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/common-global.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index a061e53d8a..96fa8a7dd2 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -118,10 +118,6 @@ export function initGlobalCommon() {
$('.tabular.menu .item').tab();
- $('.toggle.button').on('click', function () {
- toggleElem($($(this).data('target')));
- });
-
// prevent multiple form submissions on forms containing .loading-button
document.addEventListener('submit', (e) => {
const btn = e.target.querySelector('.loading-button');
@@ -310,8 +306,15 @@ export function initGlobalButtons() {
});
$('.show-panel.button').on('click', function (e) {
+ // a '.show-panel.button' can show a panel, by `data-panel="selector"`
+ // if the button is a "toggle" button, it toggles the panel
e.preventDefault();
- showElem($(this).data('panel'));
+ const sel = $(this).attr('data-panel');
+ if (this.classList.contains('toggle')) {
+ toggleElem(sel);
+ } else {
+ showElem(sel);
+ }
});
$('.hide-panel.button').on('click', function (e) {