dialog: add data-autoclose-dialog option (#37253)
gitea/gadjo/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2019-10-29 09:47:44 +01:00
parent 504c3c368c
commit 3339674f61
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 13 additions and 0 deletions

View File

@ -47,6 +47,9 @@ var gadjo_js = gadjo_js || {};
* attribute, a gadjo:dialog-done event is triggered on success, a
* gadjo:dialog-submit-error event is triggered on failure.
*
* Set data-autoclose-dialog="true" to close the dialog box after the
* submit.
*
* Dialog is modal by default, set data-modal="false" for non-modal
* dialogs.
*/
@ -55,6 +58,7 @@ var gadjo_js = gadjo_js || {};
var selector = $anchor.data('selector') || 'form:not(.gadjo-popup-ignore)';
var title_selector = $anchor.data('title-selector') || '#appbar h2';
var inplace_submit = $anchor.data('inplace-submit');
var autoclose_dialog = $anchor.data('autoclose-dialog');
var modal = $anchor.data('modal');
if (url == '#') {
return false;
@ -217,6 +221,15 @@ var gadjo_js = gadjo_js || {};
} else {
$elem.click();
}
var validated = true;
$form.find('input, textarea').each(function() {
if ($(this)[0].checkValidity != undefined) {
validated &= $(this)[0].checkValidity();
}
})
if (autoclose_dialog & validated) {
$content.dialog('destroy');
}
}
return false;
};