parsley-rails 1.1.14.0 → 1.1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/parsley-rails/version.rb +1 -1
- data/vendor/assets/javascripts/parsley.i18n.en.js +47 -0
- data/vendor/assets/javascripts/parsley.i18n.et.js +46 -0
- data/vendor/assets/javascripts/parsley.i18n.it.js +40 -0
- data/vendor/assets/javascripts/parsley.i18n.sv.js +45 -0
- data/vendor/assets/javascripts/parsley.i18n.zh_cn.js +46 -0
- data/vendor/assets/javascripts/parsley.js +92 -76
- metadata +7 -2
@@ -0,0 +1,47 @@
|
|
1
|
+
/**
|
2
|
+
* /!\ This file is just an example template to create/update your own language file /!\
|
3
|
+
*/
|
4
|
+
|
5
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
6
|
+
|
7
|
+
(function ($) {
|
8
|
+
window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
|
9
|
+
messages: {
|
10
|
+
// parsley //////////////////////////////////////
|
11
|
+
defaultMessage: "This value seems to be invalid."
|
12
|
+
, type: {
|
13
|
+
email: "This value should be a valid email."
|
14
|
+
, url: "This value should be a valid url."
|
15
|
+
, urlstrict: "This value should be a valid url."
|
16
|
+
, number: "This value should be a valid number."
|
17
|
+
, digits: "This value should be digits."
|
18
|
+
, dateIso: "This value should be a valid date (YYYY-MM-DD)."
|
19
|
+
, alphanum: "This value should be alphanumeric."
|
20
|
+
, phone: "This value should be a valid phone number."
|
21
|
+
}
|
22
|
+
, notnull: "This value should not be null."
|
23
|
+
, notblank: "This value should not be blank."
|
24
|
+
, required: "This value is required."
|
25
|
+
, regexp: "This value seems to be invalid."
|
26
|
+
, min: "This value should be greater than %s."
|
27
|
+
, max: "This value should be lower than %s."
|
28
|
+
, range: "This value should be between %s and %s."
|
29
|
+
, minlength: "This value is too short. It should have %s characters or more."
|
30
|
+
, maxlength: "This value is too long. It should have %s characters or less."
|
31
|
+
, rangelength: "This value length is invalid. It should be between %s and %s characters long."
|
32
|
+
, mincheck: "You must select at least %s choices."
|
33
|
+
, maxcheck: "You must select %s choices or less."
|
34
|
+
, rangecheck: "You must select between %s and %s choices."
|
35
|
+
, equalto: "This value should be the same."
|
36
|
+
|
37
|
+
// parsley.extend ///////////////////////////////
|
38
|
+
, minwords: "This value should have %s words at least."
|
39
|
+
, maxwords: "This value should have %s words maximum."
|
40
|
+
, rangewords: "This value should have between %s and %s words."
|
41
|
+
, greaterthan: "This value should be greater than %s."
|
42
|
+
, lessthan: "This value should be less than %s."
|
43
|
+
, beforedate: "This date should be before %s."
|
44
|
+
, afterdate: "This date should be after %s."
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}(window.jQuery || window.Zepto));
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/**
|
2
|
+
* Estonian i18n
|
3
|
+
*/
|
4
|
+
|
5
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
6
|
+
|
7
|
+
(function ($) {
|
8
|
+
window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
|
9
|
+
messages: {
|
10
|
+
// parsley //////////////////////////////////////
|
11
|
+
defaultMessage: "Palun kontrolli välja väärtust."
|
12
|
+
, type: {
|
13
|
+
email: "Välja väärtus peaks olema korrektne e-mail."
|
14
|
+
, url: "Välja väärtus peaks olema korrektne internetiaadress."
|
15
|
+
, urlstrict: "Välja väärtus peaks olema korrektne internetiaadress."
|
16
|
+
, number: "Välja väärtus peaks olema korrektne number."
|
17
|
+
, digits: "Välja väärtus peaks olema korrektne täisarv."
|
18
|
+
, dateIso: "Välja väärtus peaks olema korrektne kuupäev (YYYY-MM-DD)."
|
19
|
+
, alphanum: "Välja väärtus peaks sisaldama ainult tähti ja numbreid."
|
20
|
+
}
|
21
|
+
, notnull: "Väli väärtus ei tohiks olla tühi."
|
22
|
+
, notblank: "Välja väärtus peaks olema täidetud."
|
23
|
+
, required: "See väli peaks olema täidetud."
|
24
|
+
, regexp: "Vigane väärtus."
|
25
|
+
, min: "Välja väärtus peaks olema suurem kui %s."
|
26
|
+
, max: "Välja väärtus peaks olema väiksem kui %s."
|
27
|
+
, range: "Välja väärtus peaks olema %s ja %s vahel."
|
28
|
+
, minlength: "Väärtus on liiga lühike, pikkus peaks olema %s või rohkem märki."
|
29
|
+
, maxlength: "Väärtus on liiga pikk, pikkus peaks olema %s või vähem märki."
|
30
|
+
, rangelength: "Välja pikkus peaks olema %s ja %s tähemärgi vahel."
|
31
|
+
, mincheck: "Pead valima minimaalselt %s valikut."
|
32
|
+
, maxcheck: "Pead valima maksimaalselt %s valikut."
|
33
|
+
, rangecheck: "Pead valima %s kuni %s valikut."
|
34
|
+
, equalto: "Välja väärtus peaks kattuma."
|
35
|
+
|
36
|
+
// parsley.extend ///////////////////////////////
|
37
|
+
, minwords: "Välja väärtus peaks sisaldama vähemalt %s sõna."
|
38
|
+
, maxwords: "Välja väärtus ei tohi ületada %s sõna."
|
39
|
+
, rangewords: "Välja väärtus peaks olema %s kuni %s sõna."
|
40
|
+
, greaterthan: "Välja väärtus peaks olema suurem kui %s."
|
41
|
+
, lessthan: "Välja väärtus peaks olema väiksem kui %s."
|
42
|
+
, beforedate: "Kuupäev peaks olema varasem kui %s."
|
43
|
+
, afterdate: "Kuupäev peaks olema hilisem kui %s."
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}(window.jQuery || window.Zepto));
|
@@ -0,0 +1,40 @@
|
|
1
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
2
|
+
|
3
|
+
(function ($) {
|
4
|
+
window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
|
5
|
+
messages: {
|
6
|
+
// parsley //////////////////////////////////////
|
7
|
+
defaultMessage: "Questo valore sembra essere non valido."
|
8
|
+
, type: {
|
9
|
+
email: "Questo valore deve essere un indirizzo email valido."
|
10
|
+
, url: "Questo valore deve essere un URL valido."
|
11
|
+
, urlstrict: "Questo valore deve essere un URL valido."
|
12
|
+
, number: "Questo valore deve essere un numero valido."
|
13
|
+
, digits: "Questo valore deve essere di tipo numerico."
|
14
|
+
, dateIso: "Questo valore deve essere una data valida (YYYY-MM-DD)."
|
15
|
+
, alphanum: "Questo valore deve essere di tipo alfanumerico."
|
16
|
+
}
|
17
|
+
, notnull: "Questo valore non deve essere nullo."
|
18
|
+
, notblank: "Questo valore non deve essere vuoto."
|
19
|
+
, required: "Questo valore è richiesto."
|
20
|
+
, regexp: "Questo valore non è corretto."
|
21
|
+
, min: "Questo valore deve essere maggiore di %s."
|
22
|
+
, max: "Questo valore deve essere minore di %s."
|
23
|
+
, range: "Questo valore deve essere compreso tra %s e %s."
|
24
|
+
, minlength: "Questo valore è troppo corto. La lunghezza minima è di %s caratteri."
|
25
|
+
, maxlength: "Questo valore è troppo lungo. La lunghezza massima è di %s caratteri."
|
26
|
+
, rangelength: "La lunghezza di questo valore deve essere compresa fra %s e %s caratteri."
|
27
|
+
, equalto: "Questo valore deve essere identico."
|
28
|
+
|
29
|
+
// parsley.extend ///////////////////////////////
|
30
|
+
, minwords: "Questo valore deve contenere almeno %s parole."
|
31
|
+
, maxwords: "Questo valore non deve superare le %s parole."
|
32
|
+
, rangewords: "Questo valore deve contenere tra %s e %s parole."
|
33
|
+
, greaterthan: "Questo valore deve essere maggiore di %s."
|
34
|
+
, lessthan: "Questo valore deve essere minore di %s."
|
35
|
+
, beforedate: "Questa data deve essere anteriore al %s."
|
36
|
+
, afterdate: "Questa data deve essere posteriore al %s."
|
37
|
+
, luhn: "Questo valore deve superare il test di Luhn."
|
38
|
+
}
|
39
|
+
});
|
40
|
+
}(window.jQuery || window.Zepto));
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* Swedish i18n.
|
3
|
+
*/
|
4
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
5
|
+
|
6
|
+
(function ($) {
|
7
|
+
window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
|
8
|
+
messages: {
|
9
|
+
// parsley //////////////////////////////////////
|
10
|
+
defaultMessage: "Ogiltigt värde."
|
11
|
+
, type: {
|
12
|
+
email: "Värdet måste vara en giltig e-postadress."
|
13
|
+
, url: "Värdet måste vara en giltig URL."
|
14
|
+
, urlstrict: "Värdet måste vara en giltig URL."
|
15
|
+
, number: "Värdet måste vara ett giltigt nummer."
|
16
|
+
, digits: "Värdet får enbart innehålla siffror."
|
17
|
+
, dateIso: "Värdet måste vara ett giltigt datum (YYYY-MM-DD)."
|
18
|
+
, alphanum: "Värdet får bara innehålla bokstäver och siffror."
|
19
|
+
}
|
20
|
+
, notnull: "Värdet får inte vara null."
|
21
|
+
, notblank: "Fältet får inte vara tomt."
|
22
|
+
, required: "Måste fyllas i."
|
23
|
+
, regexp: "Värdet verkar inte vara giltigt."
|
24
|
+
, min: "Värdet måste vara större än %s."
|
25
|
+
, max: "Värdet måste vara mindre än %s."
|
26
|
+
, range: "Värdet måste vara mellan %s och %s."
|
27
|
+
, minlength: "Värdet är för kort. Det måste innehålla minst %s tecken."
|
28
|
+
, maxlength: "Värdet är för långt. Det får maximalt innehålla %s tecken."
|
29
|
+
, rangelength: "Värdets längd är felaktig. Det måste innehålla mellan %s och %s tecken."
|
30
|
+
, mincheck: "Minst %s värden måste väljas."
|
31
|
+
, maxcheck: "Maximalt %s värden får väljas."
|
32
|
+
, rangecheck: "Du måste göra minst %s och maximalt %s val."
|
33
|
+
, equalto: "Värdet måste vara lika."
|
34
|
+
|
35
|
+
// parsley.extend ///////////////////////////////
|
36
|
+
, minwords: "Fältet måste innehålla minst %s ord."
|
37
|
+
, maxwords: "Fältet får maximalt innehålla %s ord."
|
38
|
+
, rangewords: "Fältet ska innehålla mellan %s och %s ord."
|
39
|
+
, greaterthan: "Värdet måste vara större än %s."
|
40
|
+
, lessthan: "Värdet måste vara mindre än %s."
|
41
|
+
, beforedate: "Datumet måste vara före %s."
|
42
|
+
, afterdate: "Datumet måste vara efter %s."
|
43
|
+
}
|
44
|
+
});
|
45
|
+
}(window.jQuery || window.Zepto));
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/**
|
2
|
+
* /!\ This file is just an example template to create/update your own language file /!\
|
3
|
+
*/
|
4
|
+
|
5
|
+
window.ParsleyConfig = window.ParsleyConfig || {};
|
6
|
+
|
7
|
+
(function ($) {
|
8
|
+
window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
|
9
|
+
messages: {
|
10
|
+
// parsley //////////////////////////////////////
|
11
|
+
defaultMessage: "不正确的值"
|
12
|
+
, type: {
|
13
|
+
email: "字段值应该是一个正确的电子邮件地址"
|
14
|
+
, url: "字段值应该是一个正确的URL地址"
|
15
|
+
, urlstrict: "字段值应该是一个正确的URL地址"
|
16
|
+
, number: "字段值应该是一个合法的数字"
|
17
|
+
, digits: "字段值应该是一个单独的数字"
|
18
|
+
, dateIso: "字段值应该是一个正确的日期描述(YYYY-MM-DD)."
|
19
|
+
, alphanum: "字段值应该是只包含字母和数字"
|
20
|
+
}
|
21
|
+
, notnull: "字段值不可为null"
|
22
|
+
, notblank: "字段值不可为空"
|
23
|
+
, required: "字段值是必填的"
|
24
|
+
, regexp: "字段值不合法"
|
25
|
+
, min: "字段值应该大于 %s"
|
26
|
+
, max: "字段值应该小于 %s."
|
27
|
+
, range: "字段值应该大于 %s 并小于 %s."
|
28
|
+
, minlength: "字段值太短了,长度应该大于等于 %s 个字符"
|
29
|
+
, maxlength: "字段值太长了,长度应该小于等于 %s 个字符"
|
30
|
+
, rangelength: "字段值长度错醋,长度应该在 %s 和 %s 个字符之间"
|
31
|
+
, mincheck: "你至少要选择 %s 个选项"
|
32
|
+
, maxcheck: "你最多只能选择 %s 个选项"
|
33
|
+
, rangecheck: "你只能选择 %s 到 %s 个选项"
|
34
|
+
, equalto: "字段值应该和给定的值一样"
|
35
|
+
|
36
|
+
// parsley.extend ///////////////////////////////
|
37
|
+
, minwords: "字段值应该至少有 %s 个词"
|
38
|
+
, maxwords: "字段值最多只能有 %s 个词"
|
39
|
+
, rangewords: "字段值应该有 %s 到 %s 个词"
|
40
|
+
, greaterthan: "字段值应该大于 %s"
|
41
|
+
, lessthan: "字段值应该小于 %s"
|
42
|
+
, beforedate: "字段值所表示的日期应该早于 %s."
|
43
|
+
, afterdate: "字段值所表示的日期应该晚于 %s."
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}(window.jQuery || window.Zepto));
|
@@ -32,6 +32,7 @@
|
|
32
32
|
, digits: "This value should be digits."
|
33
33
|
, dateIso: "This value should be a valid date (YYYY-MM-DD)."
|
34
34
|
, alphanum: "This value should be alphanumeric."
|
35
|
+
, phone: "This value should be a valid phone number."
|
35
36
|
}
|
36
37
|
, notnull: "This value should not be null."
|
37
38
|
, notblank: "This value should not be blank."
|
@@ -113,6 +114,9 @@
|
|
113
114
|
case 'dateIso':
|
114
115
|
regExp = /^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$/;
|
115
116
|
break;
|
117
|
+
case 'phone':
|
118
|
+
regExp = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
|
119
|
+
break;
|
116
120
|
default:
|
117
121
|
return false;
|
118
122
|
}
|
@@ -121,8 +125,8 @@
|
|
121
125
|
return '' !== val ? regExp.test( val ) : false;
|
122
126
|
}
|
123
127
|
|
124
|
-
, regexp: function ( val, regExp ) {
|
125
|
-
return new RegExp( regExp, '
|
128
|
+
, regexp: function ( val, regExp, self ) {
|
129
|
+
return new RegExp( regExp, self.options.regexpFlag || '' ).test( val );
|
126
130
|
}
|
127
131
|
|
128
132
|
, minlength: function ( val, min ) {
|
@@ -167,10 +171,12 @@
|
|
167
171
|
}
|
168
172
|
|
169
173
|
var manage = function ( isConstraintValid, message ) {
|
170
|
-
// remove error message
|
171
|
-
|
174
|
+
// remove error message if we got a server message, different from previous message
|
175
|
+
if ( 'undefined' !== typeof message && 'undefined' !== typeof self.Validator.messages.remote && message !== self.Validator.messages.remote ) {
|
176
|
+
$( self.ulError + ' .remote' ).remove();
|
177
|
+
}
|
172
178
|
|
173
|
-
self.updtConstraint( { name: 'remote',
|
179
|
+
self.updtConstraint( { name: 'remote', valid: isConstraintValid }, message );
|
174
180
|
self.manageValidationResult();
|
175
181
|
};
|
176
182
|
|
@@ -194,7 +200,6 @@
|
|
194
200
|
$.ajax( $.extend( {}, {
|
195
201
|
url: url
|
196
202
|
, data: data
|
197
|
-
, async: self.async
|
198
203
|
, type: self.options.remoteMethod || 'GET'
|
199
204
|
, success: function ( response ) {
|
200
205
|
response = handleResponse( response );
|
@@ -207,10 +212,6 @@
|
|
207
212
|
}
|
208
213
|
}, dataType ) );
|
209
214
|
|
210
|
-
if ( self.async ) {
|
211
|
-
manage( result );
|
212
|
-
}
|
213
|
-
|
214
215
|
return result;
|
215
216
|
}
|
216
217
|
|
@@ -339,13 +340,13 @@
|
|
339
340
|
*/
|
340
341
|
, init: function ( element, type ) {
|
341
342
|
this.type = type;
|
342
|
-
this.
|
343
|
+
this.valid = true;
|
343
344
|
this.element = element;
|
344
345
|
this.validatedOnce = false;
|
345
346
|
this.$element = $( element );
|
346
347
|
this.val = this.$element.val();
|
347
348
|
this.isRequired = false;
|
348
|
-
this.constraints =
|
349
|
+
this.constraints = {};
|
349
350
|
|
350
351
|
// overriden by ParsleyItemMultiple if radio or checkbox input
|
351
352
|
if ( 'undefined' === typeof this.isRadioOrCheckbox ) {
|
@@ -364,7 +365,7 @@
|
|
364
365
|
this.addConstraints();
|
365
366
|
|
366
367
|
// bind parsley events if validators have been registered
|
367
|
-
if ( this.
|
368
|
+
if ( this.hasConstraints() ) {
|
368
369
|
this.bindValidationEvents();
|
369
370
|
}
|
370
371
|
}
|
@@ -439,11 +440,11 @@
|
|
439
440
|
name = name.toLowerCase();
|
440
441
|
|
441
442
|
if ( 'function' === typeof this.Validator.validators[ name ] ) {
|
442
|
-
this.constraints
|
443
|
+
this.constraints[ name ] = {
|
443
444
|
name: name
|
444
445
|
, requirements: constraint[ name ]
|
445
|
-
,
|
446
|
-
}
|
446
|
+
, valid: null
|
447
|
+
}
|
447
448
|
|
448
449
|
if ( name === 'required' ) {
|
449
450
|
this.isRequired = true;
|
@@ -468,25 +469,22 @@
|
|
468
469
|
*/
|
469
470
|
, updateConstraint: function ( constraint, message ) {
|
470
471
|
for ( var name in constraint ) {
|
471
|
-
this.updtConstraint( { name: name, requirements: constraint[ name ],
|
472
|
+
this.updtConstraint( { name: name, requirements: constraint[ name ], valid: null }, message );
|
472
473
|
}
|
473
474
|
}
|
474
475
|
|
475
476
|
/**
|
476
477
|
* Dynamically update an existing constraint to a field.
|
477
|
-
* Complex API: { name: name, requirements: requirements,
|
478
|
+
* Complex API: { name: name, requirements: requirements, valid: boolean }
|
478
479
|
*
|
479
480
|
* @method updtConstraint
|
480
481
|
* @param {Object} constraint
|
481
482
|
*/
|
482
483
|
, updtConstraint: function ( constraint, message ) {
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
this.Validator.messages[ this.constraints[ i ].name ] = message ;
|
488
|
-
}
|
489
|
-
}
|
484
|
+
this.constraints[ constraint.name ] = $.extend( true, this.constraints[ constraint.name ], constraint );
|
485
|
+
|
486
|
+
if ( 'string' === typeof message ) {
|
487
|
+
this.Validator.messages[ constraint.name ] = message ;
|
490
488
|
}
|
491
489
|
|
492
490
|
// force field validation next check and reset validation events
|
@@ -500,23 +498,16 @@
|
|
500
498
|
* @param {String} constraintName
|
501
499
|
*/
|
502
500
|
, removeConstraint: function ( constraintName ) {
|
503
|
-
var constraintName = constraintName.toLowerCase()
|
504
|
-
, updatedConstraints = [];
|
501
|
+
var constraintName = constraintName.toLowerCase();
|
505
502
|
|
506
|
-
|
507
|
-
if ( this.constraints[ constraint ].name !== constraintName ) {
|
508
|
-
updatedConstraints.push( this.constraints[ constraint ] );
|
509
|
-
}
|
510
|
-
}
|
503
|
+
delete this.constraints[ constraintName ];
|
511
504
|
|
512
505
|
if ( constraintName === 'required' ) {
|
513
506
|
this.isRequired = false;
|
514
507
|
}
|
515
508
|
|
516
|
-
this.constraints = updatedConstraints;
|
517
|
-
|
518
509
|
// if there are no more constraint, destroy parsley instance for this field
|
519
|
-
if (
|
510
|
+
if ( !this.hasConstraints() ) {
|
520
511
|
// in a form context, remove item from parent
|
521
512
|
if ( 'ParsleyForm' === typeof this.getParent() ) {
|
522
513
|
this.getParent().removeItem( this.$element );
|
@@ -556,7 +547,7 @@
|
|
556
547
|
*/
|
557
548
|
, bindValidationEvents: function () {
|
558
549
|
// this field has validation events, that means it has to be validated
|
559
|
-
this.
|
550
|
+
this.valid = null;
|
560
551
|
this.$element.addClass( 'parsley-validated' );
|
561
552
|
|
562
553
|
// remove eventually already binded events
|
@@ -638,7 +629,7 @@
|
|
638
629
|
return true;
|
639
630
|
}
|
640
631
|
|
641
|
-
this.validate( true
|
632
|
+
this.validate( true );
|
642
633
|
}
|
643
634
|
|
644
635
|
/**
|
@@ -647,24 +638,37 @@
|
|
647
638
|
* @method isValid
|
648
639
|
* @return {Boolean} Is field valid or not
|
649
640
|
*/
|
650
|
-
,
|
651
|
-
return this.validate( false
|
641
|
+
, isValid: function () {
|
642
|
+
return this.validate( false );
|
643
|
+
}
|
644
|
+
|
645
|
+
/**
|
646
|
+
* Return if field has constraints
|
647
|
+
*
|
648
|
+
* @method hasConstraints
|
649
|
+
* @return {Boolean} Is field has constraints or not
|
650
|
+
*/
|
651
|
+
, hasConstraints: function () {
|
652
|
+
for ( var constraint in this.constraints ) {
|
653
|
+
return true;
|
654
|
+
}
|
655
|
+
|
656
|
+
return false;
|
652
657
|
}
|
653
658
|
|
654
659
|
/**
|
655
660
|
* Validate a field & display errors
|
656
661
|
*
|
657
662
|
* @method validate
|
658
|
-
* @param {Boolean} errorBubbling set to false if you just want
|
659
|
-
* @param {Boolean} async if false, wait ajax calls returns
|
663
|
+
* @param {Boolean} errorBubbling set to false if you just want valid boolean without error bubbling next to fields
|
660
664
|
* @return {Boolean} Is field valid or not
|
661
665
|
*/
|
662
|
-
, validate: function ( errorBubbling
|
666
|
+
, validate: function ( errorBubbling ) {
|
663
667
|
var val = this.getVal()
|
664
|
-
,
|
668
|
+
, valid = null;
|
665
669
|
|
666
670
|
// do not even bother trying validating a field w/o constraints
|
667
|
-
if ( this.
|
671
|
+
if ( !this.hasConstraints() ) {
|
668
672
|
return null;
|
669
673
|
}
|
670
674
|
|
@@ -676,19 +680,18 @@
|
|
676
680
|
|
677
681
|
// do not validate a field already validated and unchanged !
|
678
682
|
if ( !this.needsValidation( val ) ) {
|
679
|
-
return this.
|
683
|
+
return this.valid;
|
680
684
|
}
|
681
685
|
|
682
686
|
this.errorBubbling = 'undefined' !== typeof errorBubbling ? errorBubbling : true;
|
683
|
-
this.async = 'undefined' !== typeof async ? async : true;
|
684
687
|
|
685
|
-
|
688
|
+
valid = this.applyValidators();
|
686
689
|
|
687
690
|
if ( this.errorBubbling ) {
|
688
691
|
this.manageValidationResult();
|
689
692
|
}
|
690
693
|
|
691
|
-
return
|
694
|
+
return valid;
|
692
695
|
}
|
693
696
|
|
694
697
|
/**
|
@@ -699,7 +702,7 @@
|
|
699
702
|
* @return {Boolean}
|
700
703
|
*/
|
701
704
|
, needsValidation: function ( val ) {
|
702
|
-
if ( !this.options.validateIfUnchanged && this.
|
705
|
+
if ( !this.options.validateIfUnchanged && this.valid !== null && this.val === val && this.validatedOnce ) {
|
703
706
|
return false;
|
704
707
|
}
|
705
708
|
|
@@ -715,21 +718,21 @@
|
|
715
718
|
* @return {Mixed} {Boolean} If field valid or not, null if not validated
|
716
719
|
*/
|
717
720
|
, applyValidators: function () {
|
718
|
-
var
|
721
|
+
var valid = null;
|
719
722
|
|
720
|
-
for ( var constraint
|
723
|
+
for ( var constraint in this.constraints ) {
|
721
724
|
var result = this.Validator.validators[ this.constraints[ constraint ].name ]( this.val, this.constraints[ constraint ].requirements, this );
|
722
725
|
|
723
726
|
if ( false === result ) {
|
724
|
-
|
725
|
-
this.constraints[ constraint ].
|
727
|
+
valid = false;
|
728
|
+
this.constraints[ constraint ].valid = valid;
|
726
729
|
} else if ( true === result ) {
|
727
|
-
this.constraints[ constraint ].
|
728
|
-
|
730
|
+
this.constraints[ constraint ].valid = true;
|
731
|
+
valid = false !== valid;
|
729
732
|
}
|
730
733
|
}
|
731
734
|
|
732
|
-
return
|
735
|
+
return valid;
|
733
736
|
}
|
734
737
|
|
735
738
|
/**
|
@@ -742,32 +745,32 @@
|
|
742
745
|
* @return {Boolean} Is field valid or not
|
743
746
|
*/
|
744
747
|
, manageValidationResult: function () {
|
745
|
-
var
|
748
|
+
var valid = null;
|
746
749
|
|
747
|
-
for ( var constraint
|
748
|
-
if ( false === this.constraints[ constraint ].
|
750
|
+
for ( var constraint in this.constraints ) {
|
751
|
+
if ( false === this.constraints[ constraint ].valid ) {
|
749
752
|
this.manageError( this.constraints[ constraint ] );
|
750
|
-
|
751
|
-
} else if ( true === this.constraints[ constraint ].
|
753
|
+
valid = false;
|
754
|
+
} else if ( true === this.constraints[ constraint ].valid ) {
|
752
755
|
this.removeError( this.constraints[ constraint ].name );
|
753
|
-
|
756
|
+
valid = false !== valid;
|
754
757
|
}
|
755
758
|
}
|
756
759
|
|
757
|
-
this.
|
760
|
+
this.valid = valid;
|
758
761
|
|
759
|
-
if ( true === this.
|
762
|
+
if ( true === this.valid ) {
|
760
763
|
this.removeErrors();
|
761
764
|
this.errorClassHandler.removeClass( this.options.errorClass ).addClass( this.options.successClass );
|
762
765
|
this.options.listeners.onFieldSuccess( this.element, this.constraints, this );
|
763
766
|
return true;
|
764
|
-
} else if ( false === this.
|
767
|
+
} else if ( false === this.valid ) {
|
765
768
|
this.errorClassHandler.removeClass( this.options.successClass ).addClass( this.options.errorClass );
|
766
769
|
this.options.listeners.onFieldError( this.element, this.constraints, this );
|
767
770
|
return false;
|
768
771
|
}
|
769
772
|
|
770
|
-
return
|
773
|
+
return valid;
|
771
774
|
}
|
772
775
|
|
773
776
|
/**
|
@@ -827,11 +830,15 @@
|
|
827
830
|
* @method reset
|
828
831
|
*/
|
829
832
|
, reset: function () {
|
830
|
-
this.
|
833
|
+
this.valid = null;
|
831
834
|
this.removeErrors();
|
832
835
|
this.validatedOnce = false;
|
833
836
|
this.errorClassHandler.removeClass( this.options.successClass ).removeClass( this.options.errorClass );
|
834
837
|
|
838
|
+
for ( var constraint in this.constraints ) {
|
839
|
+
this.constraints[ constraint ].valid = null;
|
840
|
+
}
|
841
|
+
|
835
842
|
return this;
|
836
843
|
}
|
837
844
|
|
@@ -847,6 +854,15 @@
|
|
847
854
|
this.manageErrorContainer();
|
848
855
|
}
|
849
856
|
|
857
|
+
// TODO: refacto properly
|
858
|
+
// if required constraint but field is not null, do not display
|
859
|
+
if ( 'required' === constraint.name && null !== this.getVal() && this.getVal().length > 0 ) {
|
860
|
+
return;
|
861
|
+
// if empty required field and non required constraint fails, do not display
|
862
|
+
} else if ( this.isRequired && 'required' !== constraint.name && ( null === this.getVal() || 0 === this.getVal().length ) ) {
|
863
|
+
return;
|
864
|
+
}
|
865
|
+
|
850
866
|
// TODO: refacto error name w/ proper & readable function
|
851
867
|
var constraintName = constraint.name
|
852
868
|
, liClass = false !== this.options.errorMessage ? 'custom-error-message' : constraintName
|
@@ -882,7 +898,7 @@
|
|
882
898
|
/**
|
883
899
|
* Add custom listeners
|
884
900
|
*
|
885
|
-
* @param {Object} { listener: function () {} }, eg { onFormSubmit: function (
|
901
|
+
* @param {Object} { listener: function () {} }, eg { onFormSubmit: function ( valid, event, focus ) { ... } }
|
886
902
|
*/
|
887
903
|
, addListener: function ( object ) {
|
888
904
|
for ( var listener in object ) {
|
@@ -1008,7 +1024,7 @@
|
|
1008
1024
|
*/
|
1009
1025
|
, bindValidationEvents: function () {
|
1010
1026
|
// this field has validation events, that means it has to be validated
|
1011
|
-
this.
|
1027
|
+
this.valid = null;
|
1012
1028
|
this.$element.addClass( 'parsley-validated' );
|
1013
1029
|
|
1014
1030
|
// remove eventually already binded events
|
@@ -1062,7 +1078,7 @@
|
|
1062
1078
|
/**
|
1063
1079
|
* Add custom listeners
|
1064
1080
|
*
|
1065
|
-
* @param {Object} { listener: function () {} }, eg { onFormSubmit: function (
|
1081
|
+
* @param {Object} { listener: function () {} }, eg { onFormSubmit: function ( valid, event, focus ) { ... } }
|
1066
1082
|
*/
|
1067
1083
|
, addListener: function ( object ) {
|
1068
1084
|
for ( var listener in object ) {
|
@@ -1124,12 +1140,12 @@
|
|
1124
1140
|
* @return {Boolean} Is form valid or not
|
1125
1141
|
*/
|
1126
1142
|
, validate: function ( event ) {
|
1127
|
-
var
|
1143
|
+
var valid = true;
|
1128
1144
|
this.focusedField = false;
|
1129
1145
|
|
1130
1146
|
for ( var item = 0; item < this.items.length; item++ ) {
|
1131
1147
|
if ( 'undefined' !== typeof this.items[ item ] && false === this.items[ item ].validate() ) {
|
1132
|
-
|
1148
|
+
valid = false;
|
1133
1149
|
|
1134
1150
|
if ( !this.focusedField && 'first' === this.options.focus || 'last' === this.options.focus ) {
|
1135
1151
|
this.focusedField = this.items[ item ].$element;
|
@@ -1138,18 +1154,18 @@
|
|
1138
1154
|
}
|
1139
1155
|
|
1140
1156
|
// form is invalid, focus an error field depending on focus policy
|
1141
|
-
if ( this.focusedField && !
|
1157
|
+
if ( this.focusedField && !valid ) {
|
1142
1158
|
this.focusedField.focus();
|
1143
1159
|
}
|
1144
1160
|
|
1145
|
-
this.options.listeners.onFormSubmit(
|
1161
|
+
this.options.listeners.onFormSubmit( valid, event, this );
|
1146
1162
|
|
1147
|
-
return
|
1163
|
+
return valid;
|
1148
1164
|
}
|
1149
1165
|
|
1150
1166
|
, isValid: function () {
|
1151
1167
|
for ( var item = 0; item < this.items.length; item++ ) {
|
1152
|
-
if ( false === this.items[ item ].
|
1168
|
+
if ( false === this.items[ item ].isValid() ) {
|
1153
1169
|
return false;
|
1154
1170
|
}
|
1155
1171
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsley-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.15.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Parsley.js bundled for Rails Asset Pipeline
|
15
15
|
email:
|
@@ -32,19 +32,24 @@ files:
|
|
32
32
|
- vendor/assets/javascripts/parsley.i18n.cs.js
|
33
33
|
- vendor/assets/javascripts/parsley.i18n.cy.js
|
34
34
|
- vendor/assets/javascripts/parsley.i18n.de.js
|
35
|
+
- vendor/assets/javascripts/parsley.i18n.en.js
|
35
36
|
- vendor/assets/javascripts/parsley.i18n.es.js
|
37
|
+
- vendor/assets/javascripts/parsley.i18n.et.js
|
36
38
|
- vendor/assets/javascripts/parsley.i18n.fa.js
|
37
39
|
- vendor/assets/javascripts/parsley.i18n.fi.js
|
38
40
|
- vendor/assets/javascripts/parsley.i18n.fr.js
|
39
41
|
- vendor/assets/javascripts/parsley.i18n.id.js
|
40
42
|
- vendor/assets/javascripts/parsley.i18n.is.js
|
43
|
+
- vendor/assets/javascripts/parsley.i18n.it.js
|
41
44
|
- vendor/assets/javascripts/parsley.i18n.lt.js
|
42
45
|
- vendor/assets/javascripts/parsley.i18n.nl.js
|
43
46
|
- vendor/assets/javascripts/parsley.i18n.no.js
|
44
47
|
- vendor/assets/javascripts/parsley.i18n.pl.js
|
45
48
|
- vendor/assets/javascripts/parsley.i18n.pt_br.js
|
46
49
|
- vendor/assets/javascripts/parsley.i18n.ru.js
|
50
|
+
- vendor/assets/javascripts/parsley.i18n.sv.js
|
47
51
|
- vendor/assets/javascripts/parsley.i18n.vn.js
|
52
|
+
- vendor/assets/javascripts/parsley.i18n.zh_cn.js
|
48
53
|
- vendor/assets/javascripts/parsley.js
|
49
54
|
homepage: https://github.com/mekishizufu/parsley-rails
|
50
55
|
licenses: []
|