summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauréline Guérin <zebuline@entrouvert.com>2019-10-29 08:47:44 (GMT)
committerLauréline Guérin <zebuline@entrouvert.com>2019-10-29 08:47:44 (GMT)
commit3339674f61530ba9247d7aba4654549fd436f2d8 (patch)
treec44b6326d7fa9eef99401b56cd817b7b67396ab3
parent504c3c368c1f8791f99b7b9fbd1a605fd5974bff (diff)
downloadgadjo-wip/37253-close-dialog.zip
gadjo-wip/37253-close-dialog.tar.gz
gadjo-wip/37253-close-dialog.tar.bz2
dialog: add data-autoclose-dialog option (#37253)v0.84wip/37253-close-dialog
-rw-r--r--gadjo/static/js/gadjo.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/gadjo/static/js/gadjo.js b/gadjo/static/js/gadjo.js
index db6c5c0..7d63b3e 100644
--- a/gadjo/static/js/gadjo.js
+++ b/gadjo/static/js/gadjo.js
@@ -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;
};