Skip to content

Commit

Permalink
- K mazání zpráv nedochází v případě, že validace inputu byla zavolán…
Browse files Browse the repository at this point in the history
…a s `onlyCheck === true`. V tu chvíli neovlivňujeme žádným způsobem DOM.
  • Loading branch information
zipper committed Apr 18, 2019
1 parent 0698c70 commit 82493e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $ cat bower.json

## Changelog

### v1.3.9
- K mazání zpráv nedochází v případě, že validace inputu byla zavolána s `onlyCheck === true`. V tu chvíli neovlivňujeme žádným způsobem DOM.

### v1.3.8
- Stisknutím klávesy ESC v průběhu AJAXové validace nedojde k jejímu zrušení ([#10](https://github.com/peckadesign/pdForms/issues/10)).
- Do globálního objektu `pdForms` přidána property `version` obsahující aktuální verzi.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pd-forms",
"title": "pdForms",
"description": "Customization of netteForms for use in PeckaDesign.",
"version": "1.3.8",
"version": "1.3.9",
"author": "PeckaDesign, s.r.o <support@peckadesign.cz>",
"contributors": [
"Radek Šerý <radek.sery@peckadesign.cz>",
Expand Down
18 changes: 10 additions & 8 deletions pdForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Radek Šerý <radek.sery@peckadesign.cz>
* @author Vít Kutný <vit.kutny@peckadesign.cz>
*
* @version 1.3.8
* @version 1.3.9
*
* - adds custom validation rules for optional rule (non-blocking errors, form can be still submitted)
* - changes some netteForms methods
Expand Down Expand Up @@ -127,8 +127,10 @@ pdForms.validateInput = function(e, $inputs) {
pdForms.validateControl = function(elem, rules, onlyCheck) {
// assumes the input is valid, therefore removing all messages except those associated with async rules; this
// prevents flashing of message, when async rule is evaluated - async rules removes their messages when the async
// rule is evaluated
pdForms.removeMessages(elem, false);
// rule is evaluated; when onlyCheck is true, we dont' want to modify DOM at all
if (! onlyCheck) {
pdForms.removeMessages(elem, false);
}

// validate rules one-by-one to know which passed
for (var id = 0, len = rules.length; id < len; id++) {
Expand Down Expand Up @@ -272,11 +274,11 @@ pdForms.asyncEvaluate = function(elem, op, status, payload, arg) {
var onlyCheck = pdForms.asyncQueue[key].onlyCheck;
delete pdForms.asyncQueue[key];

// remove old messages
pdForms.removeMessages(elem, true);

// write validation result message
if (! onlyCheck) {
// remove old messages, only when onlyCheck is false
pdForms.removeMessages(elem, true);

if (status in msg && msg[status]) {
switch (status) {
case 'invalid':
Expand Down Expand Up @@ -567,7 +569,7 @@ Nette.validateControl = function(elem, rules, onlyCheck) {
return true;
}

// convert arg property in rules into Nette compatible format
// convert arg property in rules into Nette format
rules = pdForms.normalizeRulesArg(rules);

return pdForms.validateControl(elem, rules, onlyCheck);
Expand All @@ -578,7 +580,7 @@ Nette.validateControl = function(elem, rules, onlyCheck) {
*
*/
Nette.toggleControl = function(elem, rules, success, firsttime, value) {
// convert arg property in rules into Nette compatible format
// convert arg property in rules into Nette format
rules = pdForms.normalizeRulesArg(rules);

pdForms.Nette.toggleControl(elem, rules, success, firsttime, value);
Expand Down

0 comments on commit 82493e0

Please sign in to comment.