parsley-rails 1.1.10.0 → 1.1.11.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/README.md CHANGED
@@ -28,7 +28,12 @@ Finally, if you want to use a different i18n:
28
28
 
29
29
  //= require parsley.i18n.fr
30
30
 
31
- See complete [Parsley.js documentation](http://parsleyjs.org/documentation.html).
31
+ See the complete [Parsley.js documentation](http://parsleyjs.org/documentation.html).
32
+
33
+ ## Versions
34
+
35
+ The gem follows Parsley.js's versions. If the gem version is `1.1.10.0`, then `1.1.10` is a version of Parsley.js and `0`
36
+ is a patch level of the gem itself.
32
37
 
33
38
  ## Contributing
34
39
 
@@ -1,5 +1,5 @@
1
1
  module Parsley
2
2
  module Rails
3
- VERSION = "1.1.10.0"
3
+ VERSION = "1.1.11.0"
4
4
  end
5
5
  end
@@ -41,6 +41,14 @@ window.ParsleyConfig = window.ParsleyConfig || {};
41
41
 
42
42
  return new Number(val) < new Number($( elem ).val());
43
43
  }
44
+
45
+ , beforedate: function ( val, elem, self) {
46
+ return Date.parse(val) < Date.parse($(elem).val());
47
+ }
48
+
49
+ , afterdate: function ( val, elem, self) {
50
+ return Date.parse($(elem).val()) < Date.parse(val);
51
+ }
44
52
  }
45
53
  , messages: {
46
54
  minwords: "This value should have %s words at least."
@@ -48,6 +56,8 @@ window.ParsleyConfig = window.ParsleyConfig || {};
48
56
  , rangewords: "This value should have between %s and %s words."
49
57
  , greaterthan: "This value should be greater than %s."
50
58
  , lessthan: "This value should be less than %s."
59
+ , beforedate: "This date should be before %s."
60
+ , afterdate: "This date should be after %s."
51
61
  }
52
62
  });
53
63
  }(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: "Aquest valor sembla ser invàlid."
8
+ , type: {
9
+ email: "Aquest valor ha de ser una adreça de correu electrònic vàlida."
10
+ , url: "Aquest valor ha de ser una URL vàlida."
11
+ , urlstrict: "Aquest valor ha de ser una URL vàlida."
12
+ , number: "Aquest valor ha de ser un nombre vàlid."
13
+ , digits: "Aquest valor ha només pot contenir dígits."
14
+ , dateIso: "Aquest valor ha de ser una data vàlida (YYYY-MM-DD)."
15
+ , alphanum: "Aquest valor ha de ser alfanumèric."
16
+ }
17
+ , notnull: "Aquest valor no pot ser nul."
18
+ , notblank: "Aquest valor no pot ser buit."
19
+ , required: "Aquest valor és requerit."
20
+ , regexp: "Aquest valor és incorrecte."
21
+ , min: "Aquest valor no pot ser menor que %s."
22
+ , max: "Aquest valor no pot ser major que %s."
23
+ , range: "Aquest valor ha d'estar entre %s i %s."
24
+ , minlength: "Aquest valor és massa curt. La longitud mínima és de %s caràcters."
25
+ , maxlength: "Aquest valor és massa llarg. La longitud màxima és de %s caràcters."
26
+ , rangelength: "La longitud d'aquest valor ha de ser d'entre %s i %s caràcters."
27
+ , equalto: "Aquest valor ha de ser idèntic."
28
+ , mincheck: "Has de marcar un mínim de %s opcions."
29
+ , maxcheck: "Has de marcar un màxim de %s opcions."
30
+ , rangecheck: "Has de marcar entre %s i %s opcions."
31
+
32
+ // parsley.extend ///////////////////////////////
33
+ , minwords: "Aquest valor ha de tenir %s paraules com a mínim."
34
+ , maxwords: "Aquest valor no pot superar les %s paraules."
35
+ , rangewords: "Aquest valor ha de tenir entre %s i %s paraules."
36
+ , greaterthan: "Aquest valor no pot ser major que %s."
37
+ , lessthan: "Aquest valor no pot ser menor que %s."
38
+ }
39
+ });
40
+ }(window.jQuery || window.Zepto));
@@ -0,0 +1,37 @@
1
+ window.ParsleyConfig = window.ParsleyConfig || {};
2
+
3
+ (function ($) {
4
+ window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
5
+ messages: {
6
+ // parsley //////////////////////////////////////
7
+ defaultMessage: "Tato položka je neplatná."
8
+ , type: {
9
+ email: "Tato položka musí být e-mailová adresa."
10
+ , url: "Tato položka musí být url adresa."
11
+ , urlstrict: "Tato položka musí být url adresa."
12
+ , number: "Tato položka musí být platné číslo."
13
+ , digits: "Tato položka musí být číslice."
14
+ , dateIso: "Tato položka musí být datum ve formátu YYYY-MM-DD."
15
+ , alphanum: "Tato položka musí být alfanumerická."
16
+ }
17
+ , notnull: "Tato položka nesmí být null."
18
+ , notblank: "Tato položka nesmí být prázdná."
19
+ , required: "Tato položka je povinná."
20
+ , regexp: "Tato položka je neplatná."
21
+ , min: "Tato položka musí být větší než %s."
22
+ , max: "Tato položka musí byt menší než %s."
23
+ , range: "Tato položka musí být v rozmezí %s a %s."
24
+ , minlength: "Tato položka je příliš krátká. Musí mít %s nebo více znaků."
25
+ , maxlength: "Tato položka je příliš dlouhá. Musí mít %s nebo méně znaků."
26
+ , rangelength: "Tato položka je mimo rozsah. Musí být rozmezí %s a %s znaků."
27
+ , equalto: "Tato položka by měla být stejná."
28
+
29
+ // parsley.extend ///////////////////////////////
30
+ , minwords: "Tato položka musí obsahovat alespoň %s slov."
31
+ , maxwords: "Tato položka nesmí přesánout %s slov."
32
+ , rangewords: "Tato položka musí obsahovat %s až %s slov."
33
+ , greaterthan: "Tato položka musí být větší než %s."
34
+ , lessthan: "Tato položka musí být menší než %s."
35
+ }
36
+ });
37
+ }(window.jQuery || window.Zepto));
@@ -195,7 +195,7 @@
195
195
  url: url
196
196
  , data: data
197
197
  , async: self.async
198
- , method: self.options.remoteMethod || 'GET'
198
+ , type: self.options.remoteMethod || 'GET'
199
199
  , success: function ( response ) {
200
200
  response = handleResponse( response );
201
201
  manage( 1 === response || true === response || ( 'object' === typeof response && null !== response && 'undefined' !== typeof response.success ), manageErrorMessage( response )
@@ -401,6 +401,11 @@
401
401
  }
402
402
  }
403
403
  }
404
+
405
+ if ( 'string' === typeof this.$element.attr( 'pattern' ) && this.$element.attr( 'pattern' ).length ) {
406
+ this.options.regexp = this.$element.attr( 'pattern' );
407
+ }
408
+
404
409
  }
405
410
 
406
411
  /**
@@ -549,14 +554,21 @@
549
554
  this.$element.addClass( 'parsley-validated' );
550
555
 
551
556
  // remove eventually already binded events
552
- this.$element.off( '.' + this.type );
557
+ if ( this.$element.data( 'events' ) ) {
558
+ this.$element.off( '.' + this.type );
559
+ }
560
+
561
+ // force add 'change' event if async remote validator here to have result before form submitting
562
+ if ( this.options.remote && !new RegExp( 'change', 'i' ).test( this.options.trigger ) ) {
563
+ this.options.trigger = !this.options.trigger ? 'change' : ' change';
564
+ }
553
565
 
554
566
  // alaways bind keyup event, for better UX when a field is invalid
555
567
  var triggers = ( !this.options.trigger ? '' : this.options.trigger + ' ' )
556
568
  + ( new RegExp( 'key', 'i' ).test( this.options.trigger ) ? '' : 'keyup' );
557
569
 
558
- // force add 'change' event if async remote validator here to have result before form submitting
559
- if ( this.options.remote ) {
570
+ // alaways bind change event, for better UX when a select is invalid
571
+ if ( this.$element.is( 'select' ) ) {
560
572
  triggers += new RegExp( 'change', 'i' ).test( triggers ) ? '' : ' change';
561
573
  }
562
574
 
@@ -609,6 +621,11 @@
609
621
  return true;
610
622
  }
611
623
 
624
+ // do nothing on change event if not explicitely passed as data-trigger and if field has not already been validated once
625
+ if ( event.type === 'change' && !/change/i.test( this.options.trigger ) && !this.validatedOnce ) {
626
+ return true;
627
+ }
628
+
612
629
  // start validation process only if field has enough chars and validation never started
613
630
  if ( !this.isRadioOrCheckbox && val.length < this.options.validationMinlength && !this.validatedOnce ) {
614
631
  return true;
@@ -639,6 +656,11 @@
639
656
  var val = this.getVal()
640
657
  , isValid = null;
641
658
 
659
+ // do not even bother trying validating a field w/o constraints
660
+ if ( this.constraints.length === 0 ) {
661
+ return null;
662
+ }
663
+
642
664
  // reset Parsley validation if onFieldValidate returns true, or if field is empty and not required
643
665
  if ( this.options.listeners.onFieldValidate( this.element, this ) || ( '' === val && !this.isRequired ) ) {
644
666
  this.reset();
@@ -982,7 +1004,9 @@
982
1004
  this.$element.addClass( 'parsley-validated' );
983
1005
 
984
1006
  // remove eventually already binded events
985
- this.$element.off( '.' + this.type );
1007
+ if ( this.$element.data( 'events' ) ) {
1008
+ this.$element.off( '.' + this.type );
1009
+ }
986
1010
 
987
1011
  // alaways bind keyup event, for better UX when a field is invalid
988
1012
  var self = this
@@ -994,22 +1018,6 @@
994
1018
  $( this ).on( triggers.split( ' ' ).join( '.' + self.type + ' ' ), false, $.proxy( self.eventValidation, self ) );
995
1019
  } )
996
1020
  }
997
-
998
- /**
999
- * Called when validation is triggered by an event
1000
- * Do nothing if never validated. validate on change otherwise
1001
- *
1002
- * @method eventValidation
1003
- * @param {Object} event jQuery event
1004
- */
1005
- , eventValidation: function ( event ) {
1006
- // start validation process only if field has enough chars and validation never started
1007
- if ( !this.validatedOnce ) {
1008
- return true;
1009
- }
1010
-
1011
- this.validate( true, false );
1012
- }
1013
1021
  };
1014
1022
 
1015
1023
  /**
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.10.0
4
+ version: 1.1.11.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-02-15 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Parsley.js bundled for Rails Asset Pipeline
15
15
  email:
@@ -28,6 +28,8 @@ files:
28
28
  - parsley-rails.gemspec
29
29
  - update.sh
30
30
  - vendor/assets/javascripts/parsley.extend.js
31
+ - vendor/assets/javascripts/parsley.i18n.ca.js
32
+ - vendor/assets/javascripts/parsley.i18n.cs.js
31
33
  - vendor/assets/javascripts/parsley.i18n.cy.js
32
34
  - vendor/assets/javascripts/parsley.i18n.de.js
33
35
  - vendor/assets/javascripts/parsley.i18n.es.js