From 81fe5d61851c0e586af7d32c29171ceff9a571bb Mon Sep 17 00:00:00 2001 From: delvh Date: Tue, 14 Mar 2023 04:34:09 +0100 Subject: [PATCH] Convert `
` to ` -
{{.locale.Tr "admin.auths.delete"}}
+
diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index 091f5011f953..d8fa986cff3e 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -78,7 +78,7 @@ {{.locale.Tr "admin.emails.change_email_header"}}
-

{{.locale.Tr "admin.emails.change_email_text"}}

+

{{.locale.Tr "admin.emails.change_email_text"}}

{{$.CsrfTokenHtml}} @@ -93,11 +93,9 @@ -
-
{{$.locale.Tr "settings.cancel"}}
- +
+ {{template "base/delete_modal_actions" .}}
-
diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index a2c7ca2f6ae8..34bd83a21449 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -23,7 +23,7 @@
- +
{{.ID}} @@ -39,13 +39,11 @@ -
-
- {{.CsrfTokenHtml}} - -
-
- @@ -70,16 +61,7 @@ -
-
- {{svg "octicon-trash" 16 "gt-mr-2"}} - {{$.locale.Tr "modal.no"}} -
- -
+ {{template "base/delete_modal_actions" .}} diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 5dd1f531fda9..73017e1b13f1 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -151,7 +151,7 @@
-
{{.locale.Tr "admin.users.delete_account"}}
+
@@ -189,7 +189,7 @@
- {{$.locale.Tr "settings.delete_current_avatar"}} + {{$.locale.Tr "settings.delete_current_avatar"}}{{/* TODO: Convert links without href to buttons for a11y */}}
@@ -213,16 +213,7 @@

{{.locale.Tr "admin.users.purge_help"}}

-
-
- {{svg "octicon-x"}} - {{.locale.Tr "modal.no"}} -
- -
+ {{template "base/delete_modal_actions" .}} {{template "base/footer" .}} diff --git a/templates/base/delete_modal_actions.tmpl b/templates/base/delete_modal_actions.tmpl index fb4d31270af5..29bf5f92fd53 100644 --- a/templates/base/delete_modal_actions.tmpl +++ b/templates/base/delete_modal_actions.tmpl @@ -1,10 +1,10 @@
-
+
-
+ +
+
diff --git a/templates/org/settings/delete.tmpl b/templates/org/settings/delete.tmpl index 669e393e1dec..69e226f410a7 100644 --- a/templates/org/settings/delete.tmpl +++ b/templates/org/settings/delete.tmpl @@ -19,9 +19,9 @@ -
+
+ diff --git a/templates/org/settings/labels.tmpl b/templates/org/settings/labels.tmpl index 5436bcba05ca..e04b39127162 100644 --- a/templates/org/settings/labels.tmpl +++ b/templates/org/settings/labels.tmpl @@ -11,7 +11,7 @@
-
{{.locale.Tr "repo.issues.new_label"}}
+
diff --git a/templates/package/settings.tmpl b/templates/package/settings.tmpl index dc12fb8207dd..875bf852bb98 100644 --- a/templates/package/settings.tmpl +++ b/templates/package/settings.tmpl @@ -57,10 +57,7 @@
{{.CsrfTokenHtml}} -
-
{{.locale.Tr "cancel"}}
- -
+ {{template "base/delete_modal_actions" .}}
diff --git a/templates/projects/list.tmpl b/templates/projects/list.tmpl index 4a21c0fd28ce..89c52dee6808 100644 --- a/templates/projects/list.tmpl +++ b/templates/projects/list.tmpl @@ -84,15 +84,6 @@

{{.locale.Tr "repo.projects.deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}} {{end}} diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index 6867309510f8..b776f89efa39 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -29,7 +29,7 @@
-
{{$.locale.Tr "settings.cancel"}}
+
@@ -127,7 +127,7 @@
-
{{$.locale.Tr "settings.cancel"}}
+
@@ -144,7 +144,7 @@
-
{{$.locale.Tr "settings.cancel"}}
+
@@ -158,8 +158,8 @@ {{$.locale.Tr "repo.projects.column.deletion_desc"}} -
-
{{$.locale.Tr "settings.cancel"}}
+
{{/* TODO: convert to base/delete_modal_actions.tmpl */}} +
@@ -265,15 +265,6 @@

{{.locale.Tr "repo.projects.deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}} {{end}} diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index a093c19deb8c..7e8bf348a4d6 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -176,7 +176,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
diff --git a/templates/repo/cite/cite_modal.tmpl b/templates/repo/cite/cite_modal.tmpl index 185b34173dc8..f00bab8859e4 100644 --- a/templates/repo/cite/cite_modal.tmpl +++ b/templates/repo/cite/cite_modal.tmpl @@ -15,8 +15,8 @@
-
+
+
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index f19a4d4223c7..ace5a410875e 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -96,7 +96,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
@@ -121,7 +121,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index afd471368fa8..e0c58896f0f0 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -107,8 +107,8 @@
{{if $showFileViewToggle}}
- {{svg "octicon-code"}} - {{svg "octicon-file"}} + +
{{end}} {{if $file.IsProtected}} @@ -200,8 +200,8 @@ {{$.locale.Tr "loading"}}
-
{{.locale.Tr "repo.issues.cancel"}}
-
{{.locale.Tr "repo.issues.save"}}
+ +
diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 992ccee8e4ff..431033e18e8a 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -65,14 +65,14 @@

{{.locale.Tr "repo.editor.commit_empty_file_text"}}

-
+
-
+ +
+
diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl index bbd5c2dbdef1..75a8b5d687d9 100644 --- a/templates/repo/editor/patch.tmpl +++ b/templates/repo/editor/patch.tmpl @@ -45,14 +45,14 @@

{{.locale.Tr "repo.editor.commit_empty_file_text"}}

-
- +
-
- + +
+
diff --git a/templates/repo/issue/labels.tmpl b/templates/repo/issue/labels.tmpl index 82cfcd071204..0a25d9c87ff1 100644 --- a/templates/repo/issue/labels.tmpl +++ b/templates/repo/issue/labels.tmpl @@ -6,7 +6,7 @@ {{template "repo/issue/navbar" .}} {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}}
-
{{.locale.Tr "repo.issues.new_label"}}
+
{{end}} diff --git a/templates/repo/issue/labels/edit_delete_label.tmpl b/templates/repo/issue/labels/edit_delete_label.tmpl index 450061e8357c..38a948172ffc 100644 --- a/templates/repo/issue/labels/edit_delete_label.tmpl +++ b/templates/repo/issue/labels/edit_delete_label.tmpl @@ -6,16 +6,7 @@

{{.locale.Tr "repo.issues.label_deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}}
-
+
-
+ +
+
diff --git a/templates/repo/issue/labels/label_new.tmpl b/templates/repo/issue/labels/label_new.tmpl index 62f7155b745c..c937f28e8aa2 100644 --- a/templates/repo/issue/labels/label_new.tmpl +++ b/templates/repo/issue/labels/label_new.tmpl @@ -36,12 +36,15 @@ +
-
+
-
+ +
+
diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index ca05264e77b6..36faf861136b 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -213,9 +213,9 @@ {{if not .Repository.IsArchived}} {{if .IsShowClosed}} -
{{.locale.Tr "repo.issues.action_open"}}
+ {{else}} -
{{.locale.Tr "repo.issues.action_close"}}
+ {{end}} diff --git a/templates/repo/issue/view_content/comments_delete_time.tmpl b/templates/repo/issue/view_content/comments_delete_time.tmpl index bc08d7fde78d..b79b7ae2be09 100644 --- a/templates/repo/issue/view_content/comments_delete_time.tmpl +++ b/templates/repo/issue/view_content/comments_delete_time.tmpl @@ -7,10 +7,7 @@ {{.ctxData.CsrfTokenHtml}}
{{.ctxData.locale.Tr "repo.issues.del_time"}}
-
-
{{.ctxData.locale.Tr "repo.issues.context.delete"}}
-
{{.ctxData.locale.Tr "repo.issues.add_time_cancel"}}
-
+ {{template "base/delete_modal_actions" .}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index e58f94aff389..165dca7e0c16 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -346,8 +346,8 @@
-
{{.locale.Tr "repo.issues.add_time_short"}}
-
{{.locale.Tr "repo.issues.add_time_cancel"}}
+ +
@@ -532,14 +532,14 @@ {{end}}

-
+
-
+ +
+
{{end}} @@ -619,7 +619,7 @@ {{end}}
-
{{.locale.Tr "settings.cancel"}}
+
diff --git a/templates/repo/issue/view_content/update_branch_by_merge.tmpl b/templates/repo/issue/view_content/update_branch_by_merge.tmpl index 6d36a9b45f38..49e4467dc3f4 100644 --- a/templates/repo/issue/view_content/update_branch_by_merge.tmpl +++ b/templates/repo/issue/view_content/update_branch_by_merge.tmpl @@ -19,8 +19,8 @@ diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index f0ac1e021ec4..2a8381b0b47b 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -1,9 +1,7 @@
{{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}} -
- -
+ {{end}}

{{RenderIssueTitle $.Context .Issue.Title $.RepoLink $.Repository.ComposeMetas | RenderCodeBlock}} diff --git a/templates/repo/migrate/migrating.tmpl b/templates/repo/migrate/migrating.tmpl index a3552610c47d..cd3c5e754ecb 100644 --- a/templates/repo/migrate/migrating.tmpl +++ b/templates/repo/migrate/migrating.tmpl @@ -72,7 +72,7 @@

-
{{.locale.Tr "settings.cancel"}}
+
diff --git a/templates/repo/projects/list.tmpl b/templates/repo/projects/list.tmpl index f066f84ea2e8..6833b7d785a7 100644 --- a/templates/repo/projects/list.tmpl +++ b/templates/repo/projects/list.tmpl @@ -86,16 +86,7 @@

{{.locale.Tr "repo.projects.deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}}
{{end}} {{template "base/footer" .}} diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index bef9cb9bf062..0248b9c6d2c7 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -33,7 +33,7 @@
-
{{$.locale.Tr "settings.cancel"}}
+
@@ -131,7 +131,7 @@
-
{{$.locale.Tr "settings.cancel"}}
+
@@ -148,7 +148,7 @@
-
{{$.locale.Tr "settings.cancel"}}
+
@@ -162,8 +162,8 @@ {{$.locale.Tr "repo.projects.column.deletion_desc"}} -
-
{{$.locale.Tr "settings.cancel"}}
+
{{/* TODO: Convert to base/delete_modal_actions.tmpl? */}} +
@@ -276,16 +276,7 @@

{{.locale.Tr "repo.projects.deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}} {{end}} diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index d7c580fed969..8c4df98d1911 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -114,7 +114,7 @@ {{$.locale.Tr "repo.release.delete_release"}} {{if .IsDraft}} - + @@ -125,9 +125,9 @@ {{end}} {{else}} {{if not .tag_name}} - + {{end}} - + diff --git a/templates/repo/settings/deploy_keys.tmpl b/templates/repo/settings/deploy_keys.tmpl index 22fddeb4df67..ea4fba240edb 100644 --- a/templates/repo/settings/deploy_keys.tmpl +++ b/templates/repo/settings/deploy_keys.tmpl @@ -8,9 +8,9 @@ {{.locale.Tr "repo.settings.deploy_keys"}}
{{if not .DisableSSH}} -
{{.locale.Tr "repo.settings.add_deploy_key"}}
+ {{else}} -
{{.locale.Tr "settings.ssh_disabled"}}
+ {{end}}
@@ -85,15 +85,6 @@

{{.locale.Tr "repo.settings.deploy_key_deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}} {{template "base/footer" .}} diff --git a/templates/repo/settings/lfs.tmpl b/templates/repo/settings/lfs.tmpl index 566a701efb2a..9a38d3234573 100644 --- a/templates/repo/settings/lfs.tmpl +++ b/templates/repo/settings/lfs.tmpl @@ -50,8 +50,8 @@

{{$.CsrfTokenHtml}} -
-
{{$.locale.Tr "settings.cancel"}}
+
{{/* TODO: Convert to base/delete_modal_actions */}} +
diff --git a/templates/repo/settings/lfs_pointers.tmpl b/templates/repo/settings/lfs_pointers.tmpl index 8eebc6e870a1..67021ba6cda6 100644 --- a/templates/repo/settings/lfs_pointers.tmpl +++ b/templates/repo/settings/lfs_pointers.tmpl @@ -49,9 +49,9 @@ {{ShortSha .Oid}} {{else}} - + {{end}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 030c77b881da..be07aeb0ffeb 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -825,7 +825,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
@@ -856,7 +856,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
@@ -892,7 +892,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
@@ -926,7 +926,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
@@ -958,7 +958,7 @@
-
{{.locale.Tr "settings.cancel"}}
+
@@ -988,10 +988,7 @@ {{.CsrfTokenHtml}} -
-
{{.locale.Tr "settings.cancel"}}
- -
+ {{template "base/delete_modal_actions" .}} {{end}} diff --git a/templates/repo/settings/webhook/delete_modal.tmpl b/templates/repo/settings/webhook/delete_modal.tmpl index fdc49ada4e37..f455899663e8 100644 --- a/templates/repo/settings/webhook/delete_modal.tmpl +++ b/templates/repo/settings/webhook/delete_modal.tmpl @@ -6,14 +6,5 @@

{{.locale.Tr "repo.settings.webhook_deletion_desc"}}

-
-
- - {{.locale.Tr "modal.no"}} -
-
- - {{.locale.Tr "modal.yes"}} -
-
+ {{template "base/delete_modal_actions" .}} diff --git a/templates/repo/unicode_escape_prompt.tmpl b/templates/repo/unicode_escape_prompt.tmpl index d55bd0150a1b..12eff6aebe3a 100644 --- a/templates/repo/unicode_escape_prompt.tmpl +++ b/templates/repo/unicode_escape_prompt.tmpl @@ -1,7 +1,7 @@ {{if .EscapeStatus}} {{if .EscapeStatus.HasInvisible}}
- {{svg "octicon-x" 16 "close inside"}} +
{{$.root.locale.Tr "repo.invisible_runes_header"}}
@@ -12,7 +12,7 @@
{{else if .EscapeStatus.HasAmbiguous}}
- {{svg "octicon-x" 16 "close inside"}} +
{{$.root.locale.Tr "repo.ambiguous_runes_header"}}
diff --git a/templates/shared/actions/runner_list.tmpl b/templates/shared/actions/runner_list.tmpl index eabddbb30cdc..30c52c01b457 100644 --- a/templates/shared/actions/runner_list.tmpl +++ b/templates/shared/actions/runner_list.tmpl @@ -20,9 +20,9 @@
-
+
+
diff --git a/templates/shared/secrets/add_list.tmpl b/templates/shared/secrets/add_list.tmpl index 9105b7ad9bf4..4aa5f0ccd578 100644 --- a/templates/shared/secrets/add_list.tmpl +++ b/templates/shared/secrets/add_list.tmpl @@ -1,7 +1,7 @@

{{.locale.Tr "secrets.secrets"}}
-
{{.locale.Tr "secrets.creation"}}
+

diff --git a/templates/user/auth/grant.tmpl b/templates/user/auth/grant.tmpl index c906db3e0a17..060b67527300 100644 --- a/templates/user/auth/grant.tmpl +++ b/templates/user/auth/grant.tmpl @@ -23,7 +23,7 @@ - + Cancel
diff --git a/templates/user/auth/webauthn_error.tmpl b/templates/user/auth/webauthn_error.tmpl index 447d289a2807..b6467de1aad8 100644 --- a/templates/user/auth/webauthn_error.tmpl +++ b/templates/user/auth/webauthn_error.tmpl @@ -17,6 +17,6 @@
-
{{.locale.Tr "cancel"}}
+
diff --git a/templates/user/settings/account.tmpl b/templates/user/settings/account.tmpl index 9a57bd572267..53f7d021e0b6 100644 --- a/templates/user/settings/account.tmpl +++ b/templates/user/settings/account.tmpl @@ -151,9 +151,9 @@
-
+
+ {{.locale.Tr "auth.forgot_password"}}
diff --git a/templates/user/settings/applications.tmpl b/templates/user/settings/applications.tmpl index b0cd37d44c47..18132c4a7534 100644 --- a/templates/user/settings/applications.tmpl +++ b/templates/user/settings/applications.tmpl @@ -276,15 +276,16 @@

{{.locale.Tr "settings.access_token_deletion_desc"}}

-
-
- + +
{{/* TODO: Convert to base/delete_modal_actions.tmpl */}} +
-
- + +
+
diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index c80890940a44..93ca12a0880c 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -1,7 +1,7 @@

{{.locale.Tr "settings.manage_gpg_keys"}}
-
{{.locale.Tr "settings.add_key"}}
+

diff --git a/templates/user/settings/keys_principal.tmpl b/templates/user/settings/keys_principal.tmpl index cc1152b739a6..8012b874cdcf 100644 --- a/templates/user/settings/keys_principal.tmpl +++ b/templates/user/settings/keys_principal.tmpl @@ -3,9 +3,9 @@ {{.locale.Tr "settings.manage_ssh_principals"}}
{{if not .DisableSSH}} -
{{.locale.Tr "settings.add_new_principal"}}
+ {{else}} -
{{.locale.Tr "settings.ssh_disabled"}}
+ {{end}}
diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 891959d35145..1ff4dab34e31 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -2,11 +2,11 @@ {{.locale.Tr "settings.manage_ssh_keys"}}
{{if not .DisableSSH}} -
+
+ {{else}} -
{{.locale.Tr "settings.ssh_disabled"}}
+ {{end}}
diff --git a/templates/user/settings/repos.tmpl b/templates/user/settings/repos.tmpl index 902b3fb2f33b..2e107ca7fa1a 100644 --- a/templates/user/settings/repos.tmpl +++ b/templates/user/settings/repos.tmpl @@ -50,16 +50,7 @@ {{$.CsrfTokenHtml}} -
-
- - {{$.locale.Tr "modal.no"}} -
- -
+ {{template "base/delete_modal_actions" .}}
{{end}} @@ -77,16 +68,7 @@ {{$.CsrfTokenHtml}} -
-
- - {{$.locale.Tr "modal.no"}} -
- -
+ {{template "base/delete_modal_actions" .}} {{end}} diff --git a/templates/user/settings/security/twofa.tmpl b/templates/user/settings/security/twofa.tmpl index a4da94762886..1a0a8a6432c0 100644 --- a/templates/user/settings/security/twofa.tmpl +++ b/templates/user/settings/security/twofa.tmpl @@ -13,7 +13,7 @@
{{.CsrfTokenHtml}}

{{.locale.Tr "settings.twofa_disable_note"}}

-
{{$.locale.Tr "settings.twofa_disable"}}
+
{{else}}

{{.locale.Tr "settings.twofa_not_enrolled"}}

diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js index d023e0bc3695..be5aa876a5db 100644 --- a/web_src/js/features/admin/common.js +++ b/web_src/js/features/admin/common.js @@ -198,7 +198,8 @@ export function initAdminCommon() { break; } }); - $('#delete-selection').on('click', function () { + $('#delete-selection').on('click', function (e) { + e.preventDefault(); const $this = $(this); $this.addClass('loading disabled'); const ids = []; diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 4fa6942467ee..0f36ce2bf84f 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -202,7 +202,8 @@ export function initGlobalDropzone() { } export function initGlobalLinkActions() { - function showDeletePopup() { + function showDeletePopup(e) { + e.preventDefault(); const $this = $(this); const dataArray = $this.data(); let filter = ''; @@ -243,10 +244,10 @@ export function initGlobalLinkActions() { }); } }).modal('show'); - return false; } - function showAddAllPopup() { + function showAddAllPopup(e) { + e.preventDefault(); const $this = $(this); let filter = ''; if ($this.attr('id')) { @@ -272,7 +273,6 @@ export function initGlobalLinkActions() { }); } }).modal('show'); - return false; } function linkAction(e) { @@ -318,13 +318,21 @@ export function initGlobalLinkActions() { } export function initGlobalButtons() { - $('.show-panel.button').on('click', function () { + // There are many "cancel button" elements in modal dialogs, Fomantic UI expects they are button-like elements but never submit a form. + // However, Gitea misuses the modal dialog and put the cancel buttons inside forms, so we must prevent the form submission. + // There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content") + $(document).on('click', 'form .ui.cancel.button', (e) => { + e.preventDefault(); + }); + + $('.show-panel.button').on('click', function (e) { + e.preventDefault(); showElem($(this).data('panel')); }); - $('.hide-panel.button').on('click', function (event) { + $('.hide-panel.button').on('click', function (e) { // a `.hide-panel.button` can hide a panel, by `data-panel="selector"` or `data-panel-closest="selector"` - event.preventDefault(); + e.preventDefault(); let sel = $(this).attr('data-panel'); if (sel) { hideElem($(sel)); @@ -339,7 +347,8 @@ export function initGlobalButtons() { alert('Nothing to hide'); }); - $('.show-modal').on('click', function () { + $('.show-modal').on('click', function (e) { + e.preventDefault(); const modalDiv = $($(this).attr('data-modal')); for (const attrib of this.attributes) { if (!attrib.name.startsWith('data-modal-')) { @@ -360,7 +369,8 @@ export function initGlobalButtons() { } }); - $('.delete-post.button').on('click', function () { + $('.delete-post.button').on('click', function (e) { + e.preventDefault(); const $this = $(this); $.post($this.attr('data-request-url'), { _csrf: csrfToken diff --git a/web_src/js/features/common-issue.js b/web_src/js/features/common-issue.js index 0965caef154f..ebc851d67633 100644 --- a/web_src/js/features/common-issue.js +++ b/web_src/js/features/common-issue.js @@ -34,6 +34,7 @@ export function initCommonIssue() { }); $('.issue-action').on('click', async function (e) { + e.preventDefault(); let action = this.getAttribute('data-action'); let elementId = this.getAttribute('data-element-id'); const url = this.getAttribute('data-url'); diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index 41c9dd118f2f..a8a27c257209 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -230,7 +230,8 @@ export function initRepoIssueStatusButton() { const value = easyMDE?.value() || $(this).val(); $statusButton.text($statusButton.data(value.length === 0 ? 'status' : 'status-and-comment')); }); - $statusButton.on('click', () => { + $statusButton.on('click', (e) => { + e.preventDefault(); $('#status').val($statusButton.data('status-val')); $('#comment-form').trigger('submit'); }); diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js index 70542ad883e9..5346a0d27484 100644 --- a/web_src/js/features/repo-legacy.js +++ b/web_src/js/features/repo-legacy.js @@ -412,7 +412,8 @@ async function onEditContent(event) { $saveButton.trigger('click'); }); - $editContentZone.find('.cancel.button').on('click', () => { + $editContentZone.find('.cancel.button').on('click', (e) => { + e.preventDefault(); showElem($renderContent); hideElem($editContentZone); if (dz) { diff --git a/web_src/svg/fontawesome-save.svg b/web_src/svg/fontawesome-save.svg new file mode 100644 index 000000000000..763d26abb1c3 --- /dev/null +++ b/web_src/svg/fontawesome-save.svg @@ -0,0 +1 @@ + \ No newline at end of file