parsley-rails 1.2.0.0 → 1.2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f4d0c0d9261762aa5ac043ab0e05123dddf0234
4
- data.tar.gz: 068a8f50f49b2e1d0c43d31fda81852c3323ef9d
3
+ metadata.gz: e645648c07caf2c092c7d7d1dc94a9097268875d
4
+ data.tar.gz: 86dd883ce8c1944f7dd4232d8a8be8634120a327
5
5
  SHA512:
6
- metadata.gz: 760f5fdda70bc1ec7cef59e6ae8f10a62f98b34d9770348ee46da1fd912bf31e9405592e0af59629d9f5e257e62b48b53e9709415fa0b82dbae6f392a6cf5b4d
7
- data.tar.gz: 50a8cad8e8164b386afe55334783b1c499127d1f8f0e548e3657ce589676b65b57416852e9ebb31ea59355fd1e9581132586cf5af259e04410c19d0273c961f0
6
+ metadata.gz: 79b12de3cf7140818448e70af178d31516702f104d3a07e4c98e454764a735473641f7683a2c449b8f3413501cefa78542023200d3683fcaa850125edac7c4d1
7
+ data.tar.gz: 90ac0960ef5312551f973abf51261eb62404df710ffb841f2f70e5fc8640a5852d6e977463540e0b8d96155b7dd0e81220a01e92e271d916178f8367478ae58d
@@ -1,5 +1,5 @@
1
1
  module Parsley
2
2
  module Rails
3
- VERSION = "1.2.0.0"
3
+ VERSION = "1.2.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,43 @@
1
+ window.ParsleyConfig = window.ParsleyConfig || {};
2
+
3
+ (function ($) {
4
+ window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
5
+ messages: {
6
+ // parsley //////////////////////////////////////
7
+ defaultMessage: "Dette felt er ikke gyldigt."
8
+ , type: {
9
+ email: "Dette felt skal være en gyldig email."
10
+ , url: "Dette felt skal være en gyldig url."
11
+ , urlstrict: "Dette felt skal være en gyldig url."
12
+ , number: "Dette felt skal være et gyldig nummer."
13
+ , digits: "Dette felt skal være tal."
14
+ , dateIso: "Dette felt skal være en gyldig dato (YYYY-MM-DD)."
15
+ , alphanum: "Dette felt skal være bogstaver."
16
+ , phone: "Dette felt skal være et gyldigt telefon nummer."
17
+ }
18
+ , notnull: "Dette felt må ikke være null."
19
+ , notblank: "Dette felt må ikke være tome."
20
+ , required: "Dette felt skal udfyldes."
21
+ , regexp: "Dette felt er ikke gyldigt."
22
+ , min: "Dette felt skal være større end %s."
23
+ , max: "Dette felt skal være mindre end %s."
24
+ , range: "Dette felt skal være mellem %s og %s."
25
+ , minlength: "Dette felt er for kort. Det skal have %s tegn eller mere."
26
+ , maxlength: "Dette felt is too langt. Det skal have %s tegn eller mindre."
27
+ , rangelength: "Længden på dette felt er ikke gyldigt. Det skal være %s og %s tegn langt."
28
+ , mincheck: "Du skal vælge mindst %s valg."
29
+ , maxcheck: "Du skal vælge %s valg eller mindre."
30
+ , rangecheck: "Du skal vælge mellem %s og %s valg."
31
+ , equalto: "Dette felt skal være det samme."
32
+
33
+ // parsley.extend ///////////////////////////////
34
+ , minwords: "Dette felt skal indeholde mindst %s ord."
35
+ , maxwords: "Dette felt skal indeholde højst %s ord."
36
+ , rangewords: "Dette felt skal indeholde mellem %s og %s ord."
37
+ , greaterthan: "Dette felt skal være større end %s."
38
+ , lessthan: "Dette felt skal være mindre end %s."
39
+ , beforedate: "Denne dato skal være før %s."
40
+ , afterdate: "Denne dato skal være efter %s."
41
+ }
42
+ });
43
+ }(window.jQuery || window.Zepto));
@@ -6,32 +6,32 @@ window.ParsleyConfig = window.ParsleyConfig || {};
6
6
  // parsley //////////////////////////////////////
7
7
  defaultMessage: "Tämä arvo on virheellinen."
8
8
  , type: {
9
- email: "Tämän arvo pitäisi olla sähköpostiosoite."
10
- , url: "Tämän arvo pitäisi olla URL-osoite."
11
- , urlstrict: "Tämän arvo pitäisi olla URL-osoite."
12
- , number: "Tämän arvo pitäisi olla numero."
13
- , digits: "Tämän arvo pitäisi olla numeroita."
14
- , dateIso: "Tämän arvo pitäisi olla päivämäärä (VVVV-KK-PP)."
15
- , alphanum: "Tämän arvo pitäisi olla alfanumeerinen."
9
+ email: "Tämän arvon pitäisi olla sähköpostiosoite."
10
+ , url: "Tämän arvon pitäisi olla URL-osoite."
11
+ , urlstrict: "Tämän arvon pitäisi olla URL-osoite."
12
+ , number: "Tämän arvon pitäisi olla numero."
13
+ , digits: "Tämän arvon pitäisi olla numeroita."
14
+ , dateIso: "Tämän arvon pitäisi olla päivämäärä (VVVV-KK-PP)."
15
+ , alphanum: "Tämän arvon pitäisi olla alfanumeerinen."
16
16
  }
17
- , notnull: "Tämän arvo ei pitäisi olla nolla."
18
- , notblank: "Tämän arvo ei pitäisi olla tyhjä."
17
+ , notnull: "Tämän arvon ei pitäisi olla nolla."
18
+ , notblank: "Tämän arvon ei pitäisi olla tyhjä."
19
19
  , required: "Tämä arvo on pakollinen."
20
20
  , regexp: "Tämä arvo vaikuttaa virheelliseltä."
21
- , min: "Tämän arvo pitäisi olla suurempi kuin %s."
22
- , max: "Tämän arvo pitäisi olla pienempi kuin %s."
23
- , range: "Tämän arvo pitäisi olla lukujen %s ja %s välillä."
24
- , minlength: "Tämän arvo on liian lyhyt. Tässä pitäisi olla %s merkkiä tai enemmän."
25
- , maxlength: "Tämän arvo on liian pitkä. Tässä pitäisi olla %s merkkiä tai vähemmän."
21
+ , min: "Tämän arvon pitäisi olla suurempi kuin %s."
22
+ , max: "Tämän arvon pitäisi olla pienempi kuin %s."
23
+ , range: "Tämän arvon pitäisi olla lukujen %s ja %s välillä."
24
+ , minlength: "Tämä arvo on liian lyhyt. Tässä pitäisi olla %s merkkiä tai enemmän."
25
+ , maxlength: "Tämä arvo on liian pitkä. Tässä pitäisi olla %s merkkiä tai vähemmän."
26
26
  , rangelength: "Tämän arvon pituus on virheellinen. Tämän pitäisi olla %s-%s merkkiä pitkä."
27
27
  , equalto: "Tämän arvon pitäisi vastata toista arvoa."
28
- , mincheck: "Sinun pitää valita vähintään %s valikoima(a)."
29
- , maxcheck: "Sinun pitää valita %s valikoima(a) tai vähemmän."
30
- , rangecheck: "Sinun pitää valita %s-%s valikoima(a)."
28
+ , mincheck: "Sinun pitää valita vähintään %s."
29
+ , maxcheck: "Sinun pitää valita %s tai vähemmän."
30
+ , rangecheck: "Sinun pitää valita %s-%s."
31
31
 
32
32
  // parsley.extend ///////////////////////////////
33
33
  , minwords: "Tämän arvon pitäisi sisältää vähintään %s sana(a)."
34
- , maxwords: "Tämän arvo voi olla korkeintaan %s sana(a)."
34
+ , maxwords: "Tämä arvo voi olla korkeintaan %s sana(a)."
35
35
  , rangewords: "Tämän arvo pitäisi olla %s-%s sana(a)."
36
36
  , greaterthan: "Tämän arvo pitäisi olla suurempi kuin %s."
37
37
  , lessthan: "Tämän arvo pitäisi olla pienempi kuin %s."
@@ -225,6 +225,13 @@
225
225
  $( self.UI.ulError + ' .remote' ).remove();
226
226
  }
227
227
 
228
+ if (false === isConstraintValid) {
229
+ self.options.listeners.onFieldError( self.element, self.constraints, self );
230
+ } else if (true === isConstraintValid && false === self.options.listeners.onFieldSuccess( self.element, self.constraints, self )) {
231
+ // if onFieldSuccess returns (bool) false, consider that field si invalid
232
+ isConstraintValid = false;
233
+ }
234
+
228
235
  self.updtConstraint( { name: 'remote', valid: isConstraintValid }, message );
229
236
  self.manageValidationResult();
230
237
  };
@@ -335,10 +342,27 @@
335
342
  * Add / override a validator in validators list
336
343
  *
337
344
  * @method addValidator
338
- * @param {String} name Validator name. Will automatically bindable through data-name=''
339
- * @param {Function} fn Validator function. Must return { validator: fn(), priority: int }
345
+ * @param {String} name Validator name.
346
+ * @param {Function} fn Validator. Must return { validator: fn(), priority: int }
340
347
  */
341
348
  , addValidator: function ( name, fn ) {
349
+ if ('undefined' === typeof fn().validate) {
350
+ throw new Error( 'Validator `' + name + '` must have a validate method. See more here: http://parsleyjs.org/documentation.html#javascript-general' );
351
+ }
352
+
353
+ // add default prioirty if not given.
354
+ if ('undefined' === typeof fn().priority) {
355
+ fn = {
356
+ validate: fn().validate
357
+ , priority: 32
358
+ };
359
+
360
+ // Warn if possible
361
+ if (window.console && window.console.warn) {
362
+ window.console.warn( 'Validator `' + name + '` should have a priority. Default priority 32 given' );
363
+ }
364
+ }
365
+
342
366
  this.validators[ name ] = fn;
343
367
  }
344
368
 
@@ -498,8 +522,8 @@
498
522
  * @method manageErrorContainer
499
523
  */
500
524
  , manageErrorContainer: function () {
501
- var errorContainer = this.options.errorContainer || this.options.errors.container( this.element, this.ParsleyInstance.isRadioOrCheckbox )
502
- , ulTemplate = this.options.animate ? this.ulTemplate.show() : this.ulTemplate;
525
+ var errorContainer = this.options.errorContainer || this.options.errors.container( this.ParsleyInstance.element, this.ParsleyInstance.isRadioOrCheckbox )
526
+ , ulTemplate = this.options.animate ? this.ulTemplate.css('display', '') : this.ulTemplate;
503
527
 
504
528
  if ( 'undefined' !== typeof errorContainer ) {
505
529
  $( errorContainer ).append( ulTemplate );
@@ -593,8 +617,9 @@
593
617
  }
594
618
 
595
619
  // add html5 supported types & options
596
- if ( 'undefined' !== typeof this.$element.attr( 'type' ) && new RegExp( this.$element.attr( 'type' ), 'i' ).test( 'email url number range' ) ) {
597
- this.options.type = this.$element.attr( 'type' );
620
+ var type = this.$element.attr( 'type' );
621
+ if ( 'undefined' !== typeof type && new RegExp( type, 'i' ).test( 'email url number range tel' ) ) {
622
+ this.options.type = 'tel' === type ? 'phone' : type;
598
623
 
599
624
  // number and range types could have min and/or max values
600
625
  if ( new RegExp( this.options.type, 'i' ).test( 'number range' ) ) {
@@ -803,8 +828,8 @@
803
828
  * @returns {String} val
804
829
  */
805
830
  , getVal: function () {
806
- if ('undefined' !== typeof this.$element.domApi()[ 'value' ]) {
807
- return this.$element.domApi()[ 'value' ];
831
+ if ('undefined' !== typeof this.$element.domApi( this.options.namespace )[ 'value' ]) {
832
+ return this.$element.domApi( this.options.namespace )[ 'value' ];
808
833
  }
809
834
 
810
835
  return this.$element.val();
@@ -979,7 +1004,6 @@
979
1004
  for ( var constraint in this.constraints ) {
980
1005
  if ( false === this.constraints[ constraint ].valid ) {
981
1006
  errors.push( this.constraints[ constraint ]);
982
- // this.UI.manageError( this.constraints[ constraint ] );
983
1007
  valid = false;
984
1008
  } else if ( true === this.constraints[ constraint ].valid ) {
985
1009
  this.UI.removeError( this.constraints[ constraint ].name );
@@ -996,10 +1020,15 @@
996
1020
  return true;
997
1021
  } else if ( false === this.valid ) {
998
1022
  if ( true === this.options.priorityEnabled ) {
999
- var maxPriority = 0, constraint;
1000
- for ( var i = 0; i < errors.length; i++ )
1001
- if ( this.Validator.validators[ errors[ i ].name ]().priority > maxPriority )
1023
+ var maxPriority = 0, constraint, priority;
1024
+ for ( var i = 0; i < errors.length; i++ ) {
1025
+ priority = this.Validator.validators[ errors[ i ].name ]().priority;
1026
+
1027
+ if ( priority > maxPriority ) {
1002
1028
  constraint = errors[ i ];
1029
+ maxPriority = priority;
1030
+ }
1031
+ }
1003
1032
  this.UI.manageError( constraint );
1004
1033
  } else {
1005
1034
  for ( var i = 0; i < errors.length; i++ )
@@ -1364,7 +1393,8 @@
1364
1393
  * @return {Mixed} public class method return
1365
1394
  */
1366
1395
  $.fn.parsley = function ( option, fn ) {
1367
- var options = $.extend( true, {}, $.fn.parsley.defaults, 'undefined' !== typeof window.ParsleyConfig ? window.ParsleyConfig : {}, option, this.domApi() )
1396
+ var namespace = { namespace: $( this ).data( 'parsleyNamespace' ) ? $( this ).data( 'parsleyNamespace' ) : ( 'undefined' !== typeof option && 'undefined' !== typeof option.namespace ? option.namespace : $.fn.parsley.defaults.namespace ) }
1397
+ , options = $.extend( true, {}, $.fn.parsley.defaults, 'undefined' !== typeof window.ParsleyConfig ? window.ParsleyConfig : {}, option, this.domApi( namespace.namespace ) )
1368
1398
  , newInstance = null;
1369
1399
 
1370
1400
  function bind ( self, type ) {
@@ -1400,7 +1430,7 @@
1400
1430
  }
1401
1431
 
1402
1432
  // if a form elem is given, bind all its input children
1403
- if ( $( this ).is( 'form' ) || 'undefined' !== typeof $( this ).domApi()[ 'bind' ] ) {
1433
+ if ( $( this ).is( 'form' ) || 'undefined' !== typeof $( this ).domApi( namespace.namespace )[ 'bind' ] ) {
1404
1434
  newInstance = bind ( $( this ), 'parsleyForm' );
1405
1435
 
1406
1436
  // if it is a Parsley supported single element, bind it too, except inputs type hidden
@@ -1412,8 +1442,6 @@
1412
1442
  return 'function' === typeof fn ? fn() : newInstance;
1413
1443
  };
1414
1444
 
1415
- $.fn.parsley.Constructor = ParsleyForm;
1416
-
1417
1445
  /* PARSLEY auto-binding
1418
1446
  * =================================================== */
1419
1447
  $( window ).on( 'load', function () {
@@ -1424,13 +1452,21 @@
1424
1452
 
1425
1453
  /* PARSLEY DOM API
1426
1454
  * =================================================== */
1427
- $.fn.domApi = function () {
1428
- var obj = {};
1429
- $.each( this[0].attributes, function () {
1430
- if ( this.specified && /^parsley-/i.test( this.name ) ) {
1431
- obj[ camelize( this.name.replace( 'parsley-', '' ) ) ] = deserializeValue( this.value );
1455
+ $.fn.domApi = function ( namespace ) {
1456
+ var attribute,
1457
+ obj = {}
1458
+ , regex = new RegExp("^" + namespace, 'i');
1459
+
1460
+ if ( 'undefined' === typeof this[ 0 ] ) {
1461
+ return {};
1462
+ }
1463
+
1464
+ for ( var i in this[ 0 ].attributes ) {
1465
+ attribute = this[ 0 ].attributes[ i ];
1466
+ if ( attribute.specified && regex.test( attribute.name ) ) {
1467
+ obj[ camelize( attribute.name.replace( namespace, '' ) ) ] = deserializeValue( attribute.value );
1432
1468
  }
1433
- } );
1469
+ }
1434
1470
 
1435
1471
  return obj;
1436
1472
  };
@@ -1483,7 +1519,8 @@
1483
1519
  */
1484
1520
  $.fn.parsley.defaults = {
1485
1521
  // basic data-api overridable properties here..
1486
- inputs: 'input, textarea, select' // Default supported inputs.
1522
+ namespace: 'parsley-' // DOM-API, default 'parsley-'. W3C valid would be 'data-parsley-' but quite ugly
1523
+ , inputs: 'input, textarea, select' // Default supported inputs.
1487
1524
  , excluded: 'input[type=hidden], input[type=file], :disabled' // Do not validate input[type=hidden] & :disabled.
1488
1525
  , priorityEnabled: true // Will display only one error at the time depending on validators priorities
1489
1526
  , trigger: false // $.Event() that will trigger validation. eg: keyup, change..
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsley-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.0
4
+ version: 1.2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiri Pospisil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parsley.js bundled for Rails Asset Pipeline
14
14
  email:
@@ -31,6 +31,7 @@ files:
31
31
  - vendor/assets/javascripts/parsley.i18n.ca.js
32
32
  - vendor/assets/javascripts/parsley.i18n.cs.js
33
33
  - vendor/assets/javascripts/parsley.i18n.cy.js
34
+ - vendor/assets/javascripts/parsley.i18n.da.js
34
35
  - vendor/assets/javascripts/parsley.i18n.de.js
35
36
  - vendor/assets/javascripts/parsley.i18n.en.js
36
37
  - vendor/assets/javascripts/parsley.i18n.es.js