Comparing version
@@ -5,3 +5,3 @@ { | ||
"description": "Customization of netteForms for use in PeckaDesign.", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"author": "PeckaDesign, s.r.o <support@peckadesign.cz>", | ||
@@ -8,0 +8,0 @@ "contributors": [ |
/** | ||
* @name pdForms | ||
* @author Radek Šerý <radek.sery@peckadesign.cz> | ||
* @version 4.2.0 | ||
* @version 4.2.1 | ||
* | ||
@@ -48,3 +48,3 @@ * Features: | ||
pdForms.version = '4.2.0'; | ||
pdForms.version = '4.2.1'; | ||
@@ -58,3 +58,4 @@ | ||
toggleControl: Nette.toggleControl, | ||
initForm: Nette.initForm | ||
initForm: Nette.initForm, | ||
validateForm: Nette.validateForm | ||
}; | ||
@@ -624,2 +625,22 @@ | ||
pdForms.removeFormMessages = function(form) { | ||
var radios = {}; | ||
for (var i = 0; i < form.elements.length; i++) { | ||
var elem = form.elements[i]; | ||
if (elem.tagName && !(elem.tagName.toLowerCase() in {input: 1, select: 1, textarea: 1, button: 1})) { | ||
continue; | ||
} else if (elem.type === 'radio') { | ||
if (radios[elem.name]) { | ||
continue; | ||
} | ||
radios[elem.name] = true; | ||
} | ||
pdForms.removeMessages(elem, false); | ||
} | ||
} | ||
/** | ||
@@ -632,7 +653,2 @@ * Optional rules are defined using "optional" property in "arg". We have to convert arg into Nette format before | ||
// assumes the input is valid, therefore removing all messages except those associated with ajax rules; this | ||
// prevents flashing of message, when ajax rule is evaluated - ajax rules removes their messages when the ajax | ||
// rule is evaluated | ||
pdForms.removeMessages(elem, false); | ||
if (! rules) { | ||
@@ -665,2 +681,12 @@ rules = JSON.parse(elem.getAttribute('data-nette-rules') || '[]'); | ||
Nette.validateForm = function(sender, onlyCheck) { | ||
// Assumes the form is valid, therefore removing all messages except those associated with ajax rules. This | ||
// prevents flashing of messages when the ajax rule is evaluated - ajax rules removes their messages when the | ||
// ajax rule is evaluated. | ||
pdForms.removeFormMessages(sender.form || sender); | ||
return pdForms.Nette.validateForm(sender, onlyCheck); | ||
} | ||
/** | ||
@@ -667,0 +693,0 @@ * As a side effect of live validation, errors are shown directly in validateControl. This method is used only for |
92463
0.67%971
2%