diff --git a/public/img/svg/fontawesome-save.svg b/public/img/svg/fontawesome-save.svg new file mode 100644 index 000000000..f7beb90d9 --- /dev/null +++ b/public/img/svg/fontawesome-save.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index d64ee188a..c798be02f 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -433,7 +433,7 @@
-
{{.locale.Tr "admin.auths.delete"}}
+
diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index 091f5011f..d8fa986cf 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 a2c7ca2f6..34bd83a21 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 5dd1f531f..73017e1b1 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 fb4d31270..29bf5f92f 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 669e393e1..69e226f41 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 5436bcba0..e04b39127 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 dc12fb820..875bf852b 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 4a21c0fd2..89c52dee6 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 686730951..b776f89ef 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 a093c19de..7e8bf348a 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 185b34173..f00bab885 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 f19a4d422..ace5a4108 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 afd471368..e0c58896f 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 992ccee8e..431033e18 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 bbd5c2dbd..75a8b5d68 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 82cfcd071..0a25d9c87 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 450061e83..38a948172 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 62f7155b7..c937f28e8 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 ca05264e7..36faf8611 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 bc08d7fde..b79b7ae2b 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 e58f94aff..165dca7e0 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 6d36a9b45..49e4467dc 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 f0ac1e021..2a8381b0b 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 a3552610c..cd3c5e754 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 f066f84ea..6833b7d78 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 bef9cb9bf..0248b9c6d 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 d7c580fed..8c4df98d1 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 22fddeb4d..ea4fba240 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 566a701ef..9a38d3234 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 8eebc6e87..67021ba6c 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 030c77b88..be07aeb0f 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 fdc49ada4..f45589966 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 d55bd0150..12eff6aeb 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 eabddbb30..30c52c01b 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 9105b7ad9..4aa5f0ccd 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 c906db3e0..060b67527 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 447d289a2..b6467de1a 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 9a57bd572..53f7d021e 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 b0cd37d44..18132c4a7 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 c80890940..93ca12a08 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 cc1152b73..8012b874c 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 891959d35..1ff4dab34 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 902b3fb2f..2e107ca7f 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 a4da94762..1a0a8a643 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 d023e0bc3..be5aa876a 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 4fa694246..0f36ce2bf 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 0965caef1..ebc851d67 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 41c9dd118..a8a27c257 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 70542ad88..5346a0d27 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 000000000..763d26abb --- /dev/null +++ b/web_src/svg/fontawesome-save.svg @@ -0,0 +1 @@ + \ No newline at end of file