summaryrefslogtreecommitdiffstats
path: root/web_src/js/features/common-global.js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/features/common-global.js')
-rw-r--r--web_src/js/features/common-global.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index 4fa6942467..0f36ce2bf8 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