parsley-rails 2.0.6.0 → 2.0.7.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: 634825ca2abab6902f5c17a4bdd1bf6ab30e293c
4
- data.tar.gz: 73666d399b9d5d6a02599eac268388dce139128b
3
+ metadata.gz: 70081a7d376d45a533ba1f42c652059d956afa82
4
+ data.tar.gz: 5617ced9800b18ed695a6e5359734dd9ca4592b7
5
5
  SHA512:
6
- metadata.gz: 205319188aab92ca38ce33f767f82f3e6f90dc4dcbf6eee85731c7396077ce85fd19069c7c50cef103ca08384a8bcf3e26e3c6c9ab7041a066b5e93a815903ed
7
- data.tar.gz: ee8a53503db47367780240b7992b6d18cdfb9fa762ceb8e7e5bea4884182208a0b0116849fd60ff4b621be36e711abce66613fd3625930b9b43cd4d41f4c3c77
6
+ metadata.gz: 8441f912c504079239521ebd462552bc8974b559cf97b7fcd72e0f61b4f471e33b8e0d68e97985ce3ad37d48bae3ab6e602842492417b478f21f78041589dcd8
7
+ data.tar.gz: 0a27f5590c4314f0c96cba3fb2f04aedb2fe1d6d581875bc0abf15e044e295590efb6be000d76261fa02b0cd3987ec92098f958f2a44d7684118a784f3998c45
@@ -1,5 +1,5 @@
1
1
  module Parsley
2
2
  module Rails
3
- VERSION = "2.0.6.0"
3
+ VERSION = "2.0.7.0"
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ window.ParsleyConfig = window.ParsleyConfig || {};
2
+ window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
3
+
4
+ window.ParsleyConfig.i18n.cs = $.extend(window.ParsleyConfig.i18n.cs || {}, {
5
+ dateiso: "Tato položka musí být datum ve formátu RRRR-MM-DD.",
6
+ minwords: "Tato položka musí mít délku nejméně %s slov.",
7
+ maxwords: "Tato položka musí mít délku nejvíce %s slov.",
8
+ words: "Tato položka musí být od %s do %s slov dlouhá.",
9
+ gt: "Tato hodnota musí být větší.",
10
+ gte: "Tato hodnota musí být větší nebo rovna.",
11
+ lt: "Tato hodnota musí být menší.",
12
+ lte: "Tato hodnota musí být menší nebo rovna."
13
+ });
@@ -0,0 +1,33 @@
1
+ // ParsleyConfig definition if not already set
2
+ window.ParsleyConfig = window.ParsleyConfig || {};
3
+ window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
4
+
5
+ // Define then the messages
6
+ window.ParsleyConfig.i18n.cs = $.extend(window.ParsleyConfig.i18n.cs || {}, {
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 platná URL adresa.",
11
+ number: "Tato položka musí být číslo.",
12
+ integer: "Tato položka musí být celé číslo.",
13
+ digits: "Tato položka musí být kladné celé číslo.",
14
+ alphanum: "Tato položka musí být alfanumerická."
15
+ },
16
+ notblank: "Tato položka nesmí být prázdná.",
17
+ required: "Tato položka je povinná.",
18
+ pattern: "Tato položka je neplatná.",
19
+ min: "Tato položka musí být menší nebo rovna %s.",
20
+ max: "Tato položka musí být větší nebo rovna %s.",
21
+ range: "Tato položka musí být v rozsahu od %s do %s.",
22
+ minlength: "Tato položka musí mít nejméně %s znaků.",
23
+ maxlength: "Tato položka musí mít nejvíce %s znaků.",
24
+ length: "Tato položka musí mít délku od %s do %s znaků.",
25
+ mincheck: "Je nutné vybrat alespoň %s možností.",
26
+ maxcheck: "Je nutné vybrat nejvýše %s možností.",
27
+ check: "Je nutné vybrat od %s do %s možností.",
28
+ equalto: "Tato položka musí být stejná."
29
+ });
30
+
31
+ // If file is loaded after Parsley main file, auto-load locale
32
+ if ('undefined' !== typeof window.ParsleyValidator)
33
+ window.ParsleyValidator.addCatalog('cs', window.ParsleyConfig.i18n.cs, true);
@@ -0,0 +1,13 @@
1
+ window.ParsleyConfig = window.ParsleyConfig || {};
2
+ window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
3
+
4
+ window.ParsleyConfig.i18n.de = $.extend(window.ParsleyConfig.i18n.de || {}, {
5
+ dateiso: "Die Eingabe muss ein gültiges Datum sein (YYYY-MM-DD).",
6
+ minwords: "Die Eingabe ist zu kurz. Sie muss aus %s oder mehr Wörtern bestehen.",
7
+ maxwords: "Die Eingabe ist zu lang. Sie muss aus %s oder weniger Wörtern bestehen.",
8
+ words: "Die Länge der Eingabe ist ungültig. Sie muss zwischen %s und %s Wörter enthalten.",
9
+ gt: "Die Eingabe muss größer sein.",
10
+ gte: "Die Eingabe muss größer oder gleich sein.",
11
+ lt: "Die Eingabe muss kleiner sein.",
12
+ lte: "Die Eingabe muss kleiner oder gleich sein."
13
+ });
@@ -16,7 +16,7 @@ window.ParsleyConfig.i18n.fr = $.extend(window.ParsleyConfig.i18n.fr || {}, {
16
16
  notblank: "Cette valeur ne peut pas être vide.",
17
17
  required: "Ce champ est requis.",
18
18
  pattern: "Cette valeur semble non valide.",
19
- min: "Cette valeur ne doit pas être inféreure à %s.",
19
+ min: "Cette valeur ne doit pas être inférieure à %s.",
20
20
  max: "Cette valeur ne doit pas excéder %s.",
21
21
  range: "Cette valeur doit être comprise entre %s et %s.",
22
22
  minlength: "Cette chaîne est trop courte. Elle doit avoir au minimum %s caractères.",
@@ -25,7 +25,7 @@ window.ParsleyConfig.i18n.fr = $.extend(window.ParsleyConfig.i18n.fr || {}, {
25
25
  mincheck: "Vous devez sélectionner au moins %s choix.",
26
26
  maxcheck: "Vous devez sélectionner %s choix maximum.",
27
27
  check: "Vous devez sélectionner entre %s et %s choix.",
28
- equalto: "Cette valeur devrait être identique"
28
+ equalto: "Cette valeur devrait être identique."
29
29
  });
30
30
 
31
31
  // If file is loaded after Parsley main file, auto-load locale
@@ -7,7 +7,7 @@ window.ParsleyConfig.i18n['pt-br'] = $.extend(window.ParsleyConfig.i18n['pt-br']
7
7
  defaultMessage: "Este valor parece ser inválido.",
8
8
  type: {
9
9
  email: "Este campo deve ser um email válido.",
10
- url: "Este campo deve ser uma URL válida.",
10
+ url: "Este campo deve ser um URL válida.",
11
11
  number: "Este campo deve ser um número válido.",
12
12
  integer: "Este campo deve ser um inteiro válido.",
13
13
  digits: "Este campo deve conter apenas dígitos.",
@@ -0,0 +1,33 @@
1
+ // ParsleyConfig definition if not already set
2
+ window.ParsleyConfig = window.ParsleyConfig || {};
3
+ window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
4
+
5
+ // Define then the messages
6
+ window.ParsleyConfig.i18n.zh_tw = $.extend(window.ParsleyConfig.i18n.zh_tw || {}, {
7
+ defaultMessage: "這個值似乎是無效的。",
8
+ type: {
9
+ email: "請輸入一個有效的email。",
10
+ url: "請輸入一個有效的網址。",
11
+ number: "這個值應該是一個數字。",
12
+ integer: "這個值應該是一個整數數字。",
13
+ digits: "這個值應該是一個號碼。",
14
+ alphanum: "這個值應該是字母或數字。"
15
+ },
16
+ notblank: "這個值不應該為空值。",
17
+ required: "這個空格必須填寫。",
18
+ pattern: "這個值似乎是無效的。",
19
+ min: "輸入的值應該大於或等於 %s",
20
+ max: "輸入的值應該小於或等於 %s",
21
+ range: "這個值應該在 %s 和 %s 之間。",
22
+ minlength: "這個值至少要 %s 字元。",
23
+ maxlength: "這個值最多要 %s 字元。",
24
+ length: "字元長度應該在 %s 和 %s",
25
+ mincheck: "你至少要選擇 %s 個項目。",
26
+ maxcheck: "你最多可選擇 %s 個項目。",
27
+ check: "你必須選擇 %s 到 %s 個項目。",
28
+ equalto: "輸入值不同"
29
+ });
30
+
31
+ // If file is loaded after Parsley main file, auto-load locale
32
+ if ('undefined' !== typeof window.ParsleyValidator)
33
+ window.ParsleyValidator.addCatalog('zh_tw', window.ParsleyConfig.i18n.zh_tw, true);
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Parsleyjs
3
3
  * Guillaume Potier - <guillaume@wisembly.com>
4
- * Version 2.0.6 - built Tue Dec 02 2014 17:12:12
4
+ * Version 2.0.6 - built Sat Jan 24 2015 14:44:37
5
5
  * MIT Licensed
6
6
  *
7
7
  */
@@ -127,7 +127,7 @@
127
127
  validationThreshold: 3,
128
128
  // Focused field on form validation error. 'fist'|'last'|'none'
129
129
  focus: 'first',
130
- // `$.Event()` that will trigger validation. eg: `keyup`, `change`..
130
+ // `$.Event()` that will trigger validation. eg: `keyup`, `change`...
131
131
  trigger: false,
132
132
  // Class that would be added on every failing validation Parsley field
133
133
  errorClass: 'parsley-error',
@@ -154,7 +154,7 @@
154
154
  },
155
155
  // ParsleyValidator validate proxy function . Could be replaced by third party scripts
156
156
  validateThroughValidator: function (value, constraints, priority) {
157
- return window.ParsleyValidator.validate.apply(window.ParsleyValidator, [value, constraints, priority]);
157
+ return window.ParsleyValidator.validate(value, constraints, priority);
158
158
  },
159
159
  // Subscribe an event and a handler for a specific field or a specific form
160
160
  // If on a ParsleyForm instance, it will be attached to form instance and also
@@ -197,7 +197,7 @@
197
197
  /*!
198
198
  * validator.js
199
199
  * Guillaume Potier - <guillaume@wisembly.com>
200
- * Version 1.0.0 - built Sun Aug 03 2014 17:42:31
200
+ * Version 1.0.1 - built Mon Aug 25 2014 16:10:10
201
201
  * MIT Licensed
202
202
  *
203
203
  */
@@ -208,7 +208,7 @@ var Validator = ( function ( ) {
208
208
  */
209
209
  var Validator = function ( options ) {
210
210
  this.__class__ = 'Validator';
211
- this.__version__ = '1.0.0';
211
+ this.__version__ = '1.0.1';
212
212
  this.options = options || {};
213
213
  this.bindingKey = this.options.bindingKey || '_validatorjsConstraint';
214
214
  };
@@ -553,7 +553,7 @@ var Validator = ( function ( ) {
553
553
  this.validate = function ( collection, group ) {
554
554
  var result, validator = new Validator(), count = 0, failures = {}, groups = this.groups.length ? this.groups : group;
555
555
  if ( !_isArray( collection ) )
556
- throw new Violation( this, array, { value: Validator.errorCode.must_be_an_array } );
556
+ throw new Violation( this, collection, { value: Validator.errorCode.must_be_an_array } );
557
557
  for ( var i = 0; i < collection.length; i++ ) {
558
558
  result = this.constraint ?
559
559
  validator.validate( collection[ i ], this.constraint, groups ) :
@@ -861,7 +861,7 @@ var Validator = ( function ( ) {
861
861
  window[ 'undefined' !== typeof validatorjs_ns ? validatorjs_ns : 'Validator' ] = exports;
862
862
  }
863
863
 
864
- return exports;
864
+ return exports;
865
865
  } )( );
866
866
 
867
867
  // This is needed for Browserify usage that requires Validator.js through module.exports
@@ -971,7 +971,7 @@ var Validator = ( function ( ) {
971
971
  assert = new Validator.Assert().Regexp('^\\w+$', 'i');
972
972
  break;
973
973
  case 'url':
974
- assert = new Validator.Assert().Regexp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)', 'i');
974
+ assert = new Validator.Assert().Regexp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,24}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)', 'i');
975
975
  break;
976
976
  default:
977
977
  throw new Error('validator type `' + type + '` is not supported');
@@ -1078,7 +1078,7 @@ var Validator = ( function ( ) {
1078
1078
  var diff = this._diff(fieldInstance.validationResult, fieldInstance._ui.lastValidationResult);
1079
1079
  // Then store current validation result for next reflow
1080
1080
  fieldInstance._ui.lastValidationResult = fieldInstance.validationResult;
1081
- // Field have been validated at least once if here. Useful for binded key events..
1081
+ // Field have been validated at least once if here. Useful for binded key events...
1082
1082
  fieldInstance._ui.validatedOnce = true;
1083
1083
  // Handle valid / invalid / none field class
1084
1084
  this.manageStatusClass(fieldInstance);
@@ -1116,8 +1116,10 @@ var Validator = ( function ( ) {
1116
1116
  if ((diff.added.length || diff.kept.length)) {
1117
1117
  if (0 === fieldInstance._ui.$errorsWrapper.find('.parsley-custom-error-message').length)
1118
1118
  fieldInstance._ui.$errorsWrapper
1119
- .append($(fieldInstance.options.errorTemplate)
1120
- .addClass('parsley-custom-error-message'));
1119
+ .append(
1120
+ $(fieldInstance.options.errorTemplate)
1121
+ .addClass('parsley-custom-error-message')
1122
+ );
1121
1123
  return fieldInstance._ui.$errorsWrapper
1122
1124
  .addClass('filled')
1123
1125
  .find('.parsley-custom-error-message')
@@ -1137,13 +1139,15 @@ var Validator = ( function ( ) {
1137
1139
  this.updateError(fieldInstance, diff.kept[i].assert.name, undefined, diff.kept[i].assert, true);
1138
1140
  },
1139
1141
  // TODO: strange API here, intuitive for manual usage with addError(pslyInstance, 'foo', 'bar')
1140
- // but a little bit complex for above internal usage, with forced undefined parametter..
1142
+ // but a little bit complex for above internal usage, with forced undefined parameter...
1141
1143
  addError: function (fieldInstance, name, message, assert, doNotUpdateClass) {
1142
1144
  fieldInstance._ui.$errorsWrapper
1143
1145
  .addClass('filled')
1144
- .append($(fieldInstance.options.errorTemplate)
1145
- .addClass('parsley-' + name)
1146
- .html(message || this._getErrorMessage(fieldInstance, assert)));
1146
+ .append(
1147
+ $(fieldInstance.options.errorTemplate)
1148
+ .addClass('parsley-' + name)
1149
+ .html(message || this._getErrorMessage(fieldInstance, assert))
1150
+ );
1147
1151
  if (true !== doNotUpdateClass)
1148
1152
  this._errorClass(fieldInstance);
1149
1153
  },
@@ -1256,7 +1260,7 @@ var Validator = ( function ( ) {
1256
1260
  // If this function returned a valid existing DOM element, go for it
1257
1261
  if ('undefined' !== typeof $handler && $handler.length)
1258
1262
  return $handler;
1259
- // Otherwise, if simple element (input, texatrea, select..) it will perfectly host the classes
1263
+ // Otherwise, if simple element (input, texatrea, select...) it will perfectly host the classes
1260
1264
  if ('undefined' === typeof fieldInstance.options.multiple || fieldInstance.$element.is('select'))
1261
1265
  return fieldInstance.$element;
1262
1266
  // But if multiple element (radio, checkbox), that would be their parent
@@ -1277,14 +1281,11 @@ var Validator = ( function ( ) {
1277
1281
  return 'undefined' === typeof fieldInstance.options.multiple ? fieldInstance.$element.after(fieldInstance._ui.$errorsWrapper) : fieldInstance.$element.parent().after(fieldInstance._ui.$errorsWrapper);
1278
1282
  },
1279
1283
  actualizeTriggers: function (fieldInstance) {
1280
- var that = this;
1281
- // Remove Parsley events already binded on this field
1284
+ var $toBind = fieldInstance.$element;
1282
1285
  if (fieldInstance.options.multiple)
1283
- $('[' + fieldInstance.options.namespace + 'multiple="' + fieldInstance.options.multiple + '"]').each(function () {
1284
- $(this).off('.Parsley');
1285
- });
1286
- else
1287
- fieldInstance.$element.off('.Parsley');
1286
+ $toBind = $('[' + fieldInstance.options.namespace + 'multiple="' + fieldInstance.options.multiple + '"]')
1287
+ // Remove Parsley events already binded on this field
1288
+ $toBind.off('.Parsley');
1288
1289
  // If no trigger is set, all good
1289
1290
  if (false === fieldInstance.options.trigger)
1290
1291
  return;
@@ -1292,23 +1293,13 @@ var Validator = ( function ( ) {
1292
1293
  if ('' === triggers)
1293
1294
  return;
1294
1295
  // Bind fieldInstance.eventValidate if exists (for parsley.ajax for example), ParsleyUI.eventValidate otherwise
1295
- if (fieldInstance.options.multiple)
1296
- $('[' + fieldInstance.options.namespace + 'multiple="' + fieldInstance.options.multiple + '"]').each(function () {
1297
- $(this).on(
1298
- triggers.split(' ').join('.Parsley ') + '.Parsley',
1299
- false,
1300
- $.proxy('function' === typeof fieldInstance.eventValidate ? fieldInstance.eventValidate : that.eventValidate, fieldInstance));
1301
- });
1302
- else
1303
- fieldInstance.$element
1304
- .on(
1305
- triggers.split(' ').join('.Parsley ') + '.Parsley',
1306
- false,
1307
- $.proxy('function' === typeof fieldInstance.eventValidate ? fieldInstance.eventValidate : this.eventValidate, fieldInstance));
1296
+ $toBind.on(
1297
+ triggers.split(' ').join('.Parsley ') + '.Parsley',
1298
+ $.proxy('function' === typeof fieldInstance.eventValidate ? fieldInstance.eventValidate : this.eventValidate, fieldInstance));
1308
1299
  },
1309
1300
  // Called through $.proxy with fieldInstance. `this` context is ParsleyField
1310
1301
  eventValidate: function(event) {
1311
- // For keyup, keypress, keydown.. events that could be a little bit obstrusive
1302
+ // For keyup, keypress, keydown... events that could be a little bit obstrusive
1312
1303
  // do not validate if val length < min threshold on first validation. Once field have been validated once and info
1313
1304
  // about success or failure have been displayed, always validate with this trigger to reflect every yalidation change.
1314
1305
  if (new RegExp('key').test(event.type))
@@ -1437,9 +1428,9 @@ var Validator = ( function ( ) {
1437
1428
  this.submitEvent = event;
1438
1429
  this.validationResult = true;
1439
1430
  var fieldValidationResult = [];
1431
+ $.emit('parsley:form:validate', this);
1440
1432
  // Refresh form DOM options and form's fields that could have changed
1441
1433
  this._refreshFields();
1442
- $.emit('parsley:form:validate', this);
1443
1434
  // loop through fields to validate them one by one
1444
1435
  for (var i = 0; i < this.fields.length; i++) {
1445
1436
  // do not validate a field if not the same as given validation group
@@ -1449,6 +1440,7 @@ var Validator = ( function ( ) {
1449
1440
  if (true !== fieldValidationResult && fieldValidationResult.length > 0 && this.validationResult)
1450
1441
  this.validationResult = false;
1451
1442
  }
1443
+ $.emit('parsley:form:' + (this.validationResult ? 'success' : 'error'), this);
1452
1444
  $.emit('parsley:form:validated', this);
1453
1445
  return this.validationResult;
1454
1446
  },
@@ -1490,21 +1482,26 @@ var Validator = ( function ( ) {
1490
1482
  };
1491
1483
 
1492
1484
  var ConstraintFactory = function (parsleyField, name, requirements, priority, isDomConstraint) {
1485
+ var assert = {};
1493
1486
  if (!new RegExp('ParsleyField').test(ParsleyUtils.get(parsleyField, '__class__')))
1494
1487
  throw new Error('ParsleyField or ParsleyFieldMultiple instance expected');
1495
- if ('function' !== typeof window.ParsleyValidator.validators[name] &&
1496
- 'Assert' !== window.ParsleyValidator.validators[name](requirements).__parentClass__)
1488
+ if ('function' === typeof window.ParsleyValidator.validators[name])
1489
+ assert = window.ParsleyValidator.validators[name](requirements);
1490
+ if ('Assert' !== assert.__parentClass__)
1497
1491
  throw new Error('Valid validator expected');
1498
- var getPriority = function (parsleyField, name) {
1492
+ var getPriority = function () {
1499
1493
  if ('undefined' !== typeof parsleyField.options[name + 'Priority'])
1500
1494
  return parsleyField.options[name + 'Priority'];
1501
- return ParsleyUtils.get(window.ParsleyValidator.validators[name](requirements), 'priority') || 2;
1495
+ return ParsleyUtils.get(assert, 'priority') || 2;
1502
1496
  };
1503
- priority = priority || getPriority(parsleyField, name);
1497
+ priority = priority || getPriority();
1504
1498
  // If validator have a requirementsTransformer, execute it
1505
- if ('function' === typeof window.ParsleyValidator.validators[name](requirements).requirementsTransformer)
1506
- requirements = window.ParsleyValidator.validators[name](requirements).requirementsTransformer();
1507
- return $.extend(window.ParsleyValidator.validators[name](requirements), {
1499
+ if ('function' === typeof assert.requirementsTransformer) {
1500
+ requirements = assert.requirementsTransformer();
1501
+ // rebuild assert with new requirements
1502
+ assert = window.ParsleyValidator.validators[name](requirements);
1503
+ }
1504
+ return $.extend(assert, {
1508
1505
  name: name,
1509
1506
  requirements: requirements,
1510
1507
  priority: priority,
@@ -1538,9 +1535,9 @@ var Validator = ( function ( ) {
1538
1535
  // # Public API
1539
1536
  // Validate field and $.emit some events for mainly `ParsleyUI`
1540
1537
  // @returns validationResult:
1541
- // - `true` if all constraint passes
1538
+ // - `true` if all constraints pass
1542
1539
  // - `[]` if not required field and empty (not validated)
1543
- // - `[Violation, [Violation..]]` if there were validation errors
1540
+ // - `[Violation, [Violation...]]` if there were validation errors
1544
1541
  validate: function (force) {
1545
1542
  this.value = this.getValue();
1546
1543
  // Field Validate event. `this.value` could be altered for custom needs
@@ -1560,7 +1557,8 @@ var Validator = ( function ( ) {
1560
1557
  if (0 === priorities.length)
1561
1558
  return this.validationResult = [];
1562
1559
  // Value could be passed as argument, needed to add more power to 'parsley:field:validate'
1563
- value = value || this.getValue();
1560
+ if ('undefined' === typeof value || null === value)
1561
+ value = this.getValue();
1564
1562
  // If a field is empty and not required, leave it alone, it's just fine
1565
1563
  // Except if `data-parsley-validate-if-empty` explicitely added, useful for some custom validators
1566
1564
  if (!value.length && !this._isRequired() && 'undefined' === typeof this.options.validateIfEmpty && true !== force)
@@ -1668,6 +1666,17 @@ var Validator = ( function ( ) {
1668
1666
  // HTML5 max
1669
1667
  else if ('undefined' !== typeof this.$element.attr('max'))
1670
1668
  this.addConstraint('max', this.$element.attr('max'), undefined, true);
1669
+
1670
+ // length
1671
+ if ('undefined' !== typeof this.$element.attr('minlength') && 'undefined' !== typeof this.$element.attr('maxlength'))
1672
+ this.addConstraint('length', [this.$element.attr('minlength'), this.$element.attr('maxlength')], undefined, true);
1673
+ // HTML5 minlength
1674
+ else if ('undefined' !== typeof this.$element.attr('minlength'))
1675
+ this.addConstraint('minlength', this.$element.attr('minlength'), undefined, true);
1676
+ // HTML5 maxlength
1677
+ else if ('undefined' !== typeof this.$element.attr('maxlength'))
1678
+ this.addConstraint('maxlength', this.$element.attr('maxlength'), undefined, true);
1679
+
1671
1680
  // html5 types
1672
1681
  var type = this.$element.attr('type');
1673
1682
  if ('undefined' === typeof type)
@@ -1813,7 +1822,7 @@ var Validator = ( function ( ) {
1813
1822
  delete subscribed[name];
1814
1823
  };
1815
1824
  // $.emit(name [, arguments...]);
1816
- // $.emit(name, instance [, arguments..]);
1825
+ // $.emit(name, instance [, arguments...]);
1817
1826
  $.emit = function (name, instance) {
1818
1827
  if ('undefined' === typeof subscribed[name])
1819
1828
  return;
@@ -1885,7 +1894,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
1885
1894
  this.__class__ = 'Parsley';
1886
1895
  this.__version__ = '2.0.6';
1887
1896
  this.__id__ = ParsleyUtils.hash(4);
1888
- // Parsley must be instanciated with a DOM element or jQuery $element
1897
+ // Parsley must be instantiated with a DOM element or jQuery $element
1889
1898
  if ('undefined' === typeof element)
1890
1899
  throw new Error('You must give an element');
1891
1900
  if ('undefined' !== typeof parsleyFormInstance && 'ParsleyForm' !== parsleyFormInstance.__class__)
@@ -1920,7 +1929,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
1920
1929
  return (this.$element.is('input[type=radio], input[type=checkbox]') && 'undefined' === typeof this.options.multiple) || (this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple'));
1921
1930
  },
1922
1931
  // Multiples fields are a real nightmare :(
1923
- // Maybe some refacto would be appreciated here..
1932
+ // Maybe some refacto would be appreciated here...
1924
1933
  handleMultiple: function (parsleyFormInstance) {
1925
1934
  var
1926
1935
  that = this,
@@ -104,6 +104,12 @@ window.ParsleyExtend = $.extend(window.ParsleyExtend, {
104
104
  }
105
105
 
106
106
  return $.when.apply($, promises)
107
+ .done(function () {
108
+ $.emit('parsley:form:success', that);
109
+ })
110
+ .fail(function () {
111
+ $.emit('parsley:form:error', that);
112
+ })
107
113
  .always(function () {
108
114
  $.emit('parsley:form:validated', that);
109
115
  });
@@ -259,7 +265,7 @@ window.ParsleyConfig.validators.remote = {
259
265
  /*!
260
266
  * Parsleyjs
261
267
  * Guillaume Potier - <guillaume@wisembly.com>
262
- * Version 2.0.6 - built Tue Dec 02 2014 17:12:12
268
+ * Version 2.0.6 - built Sat Jan 24 2015 14:44:37
263
269
  * MIT Licensed
264
270
  *
265
271
  */
@@ -385,7 +391,7 @@ window.ParsleyConfig.validators.remote = {
385
391
  validationThreshold: 3,
386
392
  // Focused field on form validation error. 'fist'|'last'|'none'
387
393
  focus: 'first',
388
- // `$.Event()` that will trigger validation. eg: `keyup`, `change`..
394
+ // `$.Event()` that will trigger validation. eg: `keyup`, `change`...
389
395
  trigger: false,
390
396
  // Class that would be added on every failing validation Parsley field
391
397
  errorClass: 'parsley-error',
@@ -412,7 +418,7 @@ window.ParsleyConfig.validators.remote = {
412
418
  },
413
419
  // ParsleyValidator validate proxy function . Could be replaced by third party scripts
414
420
  validateThroughValidator: function (value, constraints, priority) {
415
- return window.ParsleyValidator.validate.apply(window.ParsleyValidator, [value, constraints, priority]);
421
+ return window.ParsleyValidator.validate(value, constraints, priority);
416
422
  },
417
423
  // Subscribe an event and a handler for a specific field or a specific form
418
424
  // If on a ParsleyForm instance, it will be attached to form instance and also
@@ -455,7 +461,7 @@ window.ParsleyConfig.validators.remote = {
455
461
  /*!
456
462
  * validator.js
457
463
  * Guillaume Potier - <guillaume@wisembly.com>
458
- * Version 1.0.0 - built Sun Aug 03 2014 17:42:31
464
+ * Version 1.0.1 - built Mon Aug 25 2014 16:10:10
459
465
  * MIT Licensed
460
466
  *
461
467
  */
@@ -466,7 +472,7 @@ var Validator = ( function ( ) {
466
472
  */
467
473
  var Validator = function ( options ) {
468
474
  this.__class__ = 'Validator';
469
- this.__version__ = '1.0.0';
475
+ this.__version__ = '1.0.1';
470
476
  this.options = options || {};
471
477
  this.bindingKey = this.options.bindingKey || '_validatorjsConstraint';
472
478
  };
@@ -811,7 +817,7 @@ var Validator = ( function ( ) {
811
817
  this.validate = function ( collection, group ) {
812
818
  var result, validator = new Validator(), count = 0, failures = {}, groups = this.groups.length ? this.groups : group;
813
819
  if ( !_isArray( collection ) )
814
- throw new Violation( this, array, { value: Validator.errorCode.must_be_an_array } );
820
+ throw new Violation( this, collection, { value: Validator.errorCode.must_be_an_array } );
815
821
  for ( var i = 0; i < collection.length; i++ ) {
816
822
  result = this.constraint ?
817
823
  validator.validate( collection[ i ], this.constraint, groups ) :
@@ -1119,7 +1125,7 @@ var Validator = ( function ( ) {
1119
1125
  window[ 'undefined' !== typeof validatorjs_ns ? validatorjs_ns : 'Validator' ] = exports;
1120
1126
  }
1121
1127
 
1122
- return exports;
1128
+ return exports;
1123
1129
  } )( );
1124
1130
 
1125
1131
  // This is needed for Browserify usage that requires Validator.js through module.exports
@@ -1229,7 +1235,7 @@ var Validator = ( function ( ) {
1229
1235
  assert = new Validator.Assert().Regexp('^\\w+$', 'i');
1230
1236
  break;
1231
1237
  case 'url':
1232
- assert = new Validator.Assert().Regexp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)', 'i');
1238
+ assert = new Validator.Assert().Regexp('(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,24}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)', 'i');
1233
1239
  break;
1234
1240
  default:
1235
1241
  throw new Error('validator type `' + type + '` is not supported');
@@ -1336,7 +1342,7 @@ var Validator = ( function ( ) {
1336
1342
  var diff = this._diff(fieldInstance.validationResult, fieldInstance._ui.lastValidationResult);
1337
1343
  // Then store current validation result for next reflow
1338
1344
  fieldInstance._ui.lastValidationResult = fieldInstance.validationResult;
1339
- // Field have been validated at least once if here. Useful for binded key events..
1345
+ // Field have been validated at least once if here. Useful for binded key events...
1340
1346
  fieldInstance._ui.validatedOnce = true;
1341
1347
  // Handle valid / invalid / none field class
1342
1348
  this.manageStatusClass(fieldInstance);
@@ -1374,8 +1380,10 @@ var Validator = ( function ( ) {
1374
1380
  if ((diff.added.length || diff.kept.length)) {
1375
1381
  if (0 === fieldInstance._ui.$errorsWrapper.find('.parsley-custom-error-message').length)
1376
1382
  fieldInstance._ui.$errorsWrapper
1377
- .append($(fieldInstance.options.errorTemplate)
1378
- .addClass('parsley-custom-error-message'));
1383
+ .append(
1384
+ $(fieldInstance.options.errorTemplate)
1385
+ .addClass('parsley-custom-error-message')
1386
+ );
1379
1387
  return fieldInstance._ui.$errorsWrapper
1380
1388
  .addClass('filled')
1381
1389
  .find('.parsley-custom-error-message')
@@ -1395,13 +1403,15 @@ var Validator = ( function ( ) {
1395
1403
  this.updateError(fieldInstance, diff.kept[i].assert.name, undefined, diff.kept[i].assert, true);
1396
1404
  },
1397
1405
  // TODO: strange API here, intuitive for manual usage with addError(pslyInstance, 'foo', 'bar')
1398
- // but a little bit complex for above internal usage, with forced undefined parametter..
1406
+ // but a little bit complex for above internal usage, with forced undefined parameter...
1399
1407
  addError: function (fieldInstance, name, message, assert, doNotUpdateClass) {
1400
1408
  fieldInstance._ui.$errorsWrapper
1401
1409
  .addClass('filled')
1402
- .append($(fieldInstance.options.errorTemplate)
1403
- .addClass('parsley-' + name)
1404
- .html(message || this._getErrorMessage(fieldInstance, assert)));
1410
+ .append(
1411
+ $(fieldInstance.options.errorTemplate)
1412
+ .addClass('parsley-' + name)
1413
+ .html(message || this._getErrorMessage(fieldInstance, assert))
1414
+ );
1405
1415
  if (true !== doNotUpdateClass)
1406
1416
  this._errorClass(fieldInstance);
1407
1417
  },
@@ -1514,7 +1524,7 @@ var Validator = ( function ( ) {
1514
1524
  // If this function returned a valid existing DOM element, go for it
1515
1525
  if ('undefined' !== typeof $handler && $handler.length)
1516
1526
  return $handler;
1517
- // Otherwise, if simple element (input, texatrea, select..) it will perfectly host the classes
1527
+ // Otherwise, if simple element (input, texatrea, select...) it will perfectly host the classes
1518
1528
  if ('undefined' === typeof fieldInstance.options.multiple || fieldInstance.$element.is('select'))
1519
1529
  return fieldInstance.$element;
1520
1530
  // But if multiple element (radio, checkbox), that would be their parent
@@ -1535,14 +1545,11 @@ var Validator = ( function ( ) {
1535
1545
  return 'undefined' === typeof fieldInstance.options.multiple ? fieldInstance.$element.after(fieldInstance._ui.$errorsWrapper) : fieldInstance.$element.parent().after(fieldInstance._ui.$errorsWrapper);
1536
1546
  },
1537
1547
  actualizeTriggers: function (fieldInstance) {
1538
- var that = this;
1539
- // Remove Parsley events already binded on this field
1548
+ var $toBind = fieldInstance.$element;
1540
1549
  if (fieldInstance.options.multiple)
1541
- $('[' + fieldInstance.options.namespace + 'multiple="' + fieldInstance.options.multiple + '"]').each(function () {
1542
- $(this).off('.Parsley');
1543
- });
1544
- else
1545
- fieldInstance.$element.off('.Parsley');
1550
+ $toBind = $('[' + fieldInstance.options.namespace + 'multiple="' + fieldInstance.options.multiple + '"]')
1551
+ // Remove Parsley events already binded on this field
1552
+ $toBind.off('.Parsley');
1546
1553
  // If no trigger is set, all good
1547
1554
  if (false === fieldInstance.options.trigger)
1548
1555
  return;
@@ -1550,23 +1557,13 @@ var Validator = ( function ( ) {
1550
1557
  if ('' === triggers)
1551
1558
  return;
1552
1559
  // Bind fieldInstance.eventValidate if exists (for parsley.ajax for example), ParsleyUI.eventValidate otherwise
1553
- if (fieldInstance.options.multiple)
1554
- $('[' + fieldInstance.options.namespace + 'multiple="' + fieldInstance.options.multiple + '"]').each(function () {
1555
- $(this).on(
1556
- triggers.split(' ').join('.Parsley ') + '.Parsley',
1557
- false,
1558
- $.proxy('function' === typeof fieldInstance.eventValidate ? fieldInstance.eventValidate : that.eventValidate, fieldInstance));
1559
- });
1560
- else
1561
- fieldInstance.$element
1562
- .on(
1563
- triggers.split(' ').join('.Parsley ') + '.Parsley',
1564
- false,
1565
- $.proxy('function' === typeof fieldInstance.eventValidate ? fieldInstance.eventValidate : this.eventValidate, fieldInstance));
1560
+ $toBind.on(
1561
+ triggers.split(' ').join('.Parsley ') + '.Parsley',
1562
+ $.proxy('function' === typeof fieldInstance.eventValidate ? fieldInstance.eventValidate : this.eventValidate, fieldInstance));
1566
1563
  },
1567
1564
  // Called through $.proxy with fieldInstance. `this` context is ParsleyField
1568
1565
  eventValidate: function(event) {
1569
- // For keyup, keypress, keydown.. events that could be a little bit obstrusive
1566
+ // For keyup, keypress, keydown... events that could be a little bit obstrusive
1570
1567
  // do not validate if val length < min threshold on first validation. Once field have been validated once and info
1571
1568
  // about success or failure have been displayed, always validate with this trigger to reflect every yalidation change.
1572
1569
  if (new RegExp('key').test(event.type))
@@ -1695,9 +1692,9 @@ var Validator = ( function ( ) {
1695
1692
  this.submitEvent = event;
1696
1693
  this.validationResult = true;
1697
1694
  var fieldValidationResult = [];
1695
+ $.emit('parsley:form:validate', this);
1698
1696
  // Refresh form DOM options and form's fields that could have changed
1699
1697
  this._refreshFields();
1700
- $.emit('parsley:form:validate', this);
1701
1698
  // loop through fields to validate them one by one
1702
1699
  for (var i = 0; i < this.fields.length; i++) {
1703
1700
  // do not validate a field if not the same as given validation group
@@ -1707,6 +1704,7 @@ var Validator = ( function ( ) {
1707
1704
  if (true !== fieldValidationResult && fieldValidationResult.length > 0 && this.validationResult)
1708
1705
  this.validationResult = false;
1709
1706
  }
1707
+ $.emit('parsley:form:' + (this.validationResult ? 'success' : 'error'), this);
1710
1708
  $.emit('parsley:form:validated', this);
1711
1709
  return this.validationResult;
1712
1710
  },
@@ -1748,21 +1746,26 @@ var Validator = ( function ( ) {
1748
1746
  };
1749
1747
 
1750
1748
  var ConstraintFactory = function (parsleyField, name, requirements, priority, isDomConstraint) {
1749
+ var assert = {};
1751
1750
  if (!new RegExp('ParsleyField').test(ParsleyUtils.get(parsleyField, '__class__')))
1752
1751
  throw new Error('ParsleyField or ParsleyFieldMultiple instance expected');
1753
- if ('function' !== typeof window.ParsleyValidator.validators[name] &&
1754
- 'Assert' !== window.ParsleyValidator.validators[name](requirements).__parentClass__)
1752
+ if ('function' === typeof window.ParsleyValidator.validators[name])
1753
+ assert = window.ParsleyValidator.validators[name](requirements);
1754
+ if ('Assert' !== assert.__parentClass__)
1755
1755
  throw new Error('Valid validator expected');
1756
- var getPriority = function (parsleyField, name) {
1756
+ var getPriority = function () {
1757
1757
  if ('undefined' !== typeof parsleyField.options[name + 'Priority'])
1758
1758
  return parsleyField.options[name + 'Priority'];
1759
- return ParsleyUtils.get(window.ParsleyValidator.validators[name](requirements), 'priority') || 2;
1759
+ return ParsleyUtils.get(assert, 'priority') || 2;
1760
1760
  };
1761
- priority = priority || getPriority(parsleyField, name);
1761
+ priority = priority || getPriority();
1762
1762
  // If validator have a requirementsTransformer, execute it
1763
- if ('function' === typeof window.ParsleyValidator.validators[name](requirements).requirementsTransformer)
1764
- requirements = window.ParsleyValidator.validators[name](requirements).requirementsTransformer();
1765
- return $.extend(window.ParsleyValidator.validators[name](requirements), {
1763
+ if ('function' === typeof assert.requirementsTransformer) {
1764
+ requirements = assert.requirementsTransformer();
1765
+ // rebuild assert with new requirements
1766
+ assert = window.ParsleyValidator.validators[name](requirements);
1767
+ }
1768
+ return $.extend(assert, {
1766
1769
  name: name,
1767
1770
  requirements: requirements,
1768
1771
  priority: priority,
@@ -1796,9 +1799,9 @@ var Validator = ( function ( ) {
1796
1799
  // # Public API
1797
1800
  // Validate field and $.emit some events for mainly `ParsleyUI`
1798
1801
  // @returns validationResult:
1799
- // - `true` if all constraint passes
1802
+ // - `true` if all constraints pass
1800
1803
  // - `[]` if not required field and empty (not validated)
1801
- // - `[Violation, [Violation..]]` if there were validation errors
1804
+ // - `[Violation, [Violation...]]` if there were validation errors
1802
1805
  validate: function (force) {
1803
1806
  this.value = this.getValue();
1804
1807
  // Field Validate event. `this.value` could be altered for custom needs
@@ -1818,7 +1821,8 @@ var Validator = ( function ( ) {
1818
1821
  if (0 === priorities.length)
1819
1822
  return this.validationResult = [];
1820
1823
  // Value could be passed as argument, needed to add more power to 'parsley:field:validate'
1821
- value = value || this.getValue();
1824
+ if ('undefined' === typeof value || null === value)
1825
+ value = this.getValue();
1822
1826
  // If a field is empty and not required, leave it alone, it's just fine
1823
1827
  // Except if `data-parsley-validate-if-empty` explicitely added, useful for some custom validators
1824
1828
  if (!value.length && !this._isRequired() && 'undefined' === typeof this.options.validateIfEmpty && true !== force)
@@ -1926,6 +1930,17 @@ var Validator = ( function ( ) {
1926
1930
  // HTML5 max
1927
1931
  else if ('undefined' !== typeof this.$element.attr('max'))
1928
1932
  this.addConstraint('max', this.$element.attr('max'), undefined, true);
1933
+
1934
+ // length
1935
+ if ('undefined' !== typeof this.$element.attr('minlength') && 'undefined' !== typeof this.$element.attr('maxlength'))
1936
+ this.addConstraint('length', [this.$element.attr('minlength'), this.$element.attr('maxlength')], undefined, true);
1937
+ // HTML5 minlength
1938
+ else if ('undefined' !== typeof this.$element.attr('minlength'))
1939
+ this.addConstraint('minlength', this.$element.attr('minlength'), undefined, true);
1940
+ // HTML5 maxlength
1941
+ else if ('undefined' !== typeof this.$element.attr('maxlength'))
1942
+ this.addConstraint('maxlength', this.$element.attr('maxlength'), undefined, true);
1943
+
1929
1944
  // html5 types
1930
1945
  var type = this.$element.attr('type');
1931
1946
  if ('undefined' === typeof type)
@@ -2071,7 +2086,7 @@ var Validator = ( function ( ) {
2071
2086
  delete subscribed[name];
2072
2087
  };
2073
2088
  // $.emit(name [, arguments...]);
2074
- // $.emit(name, instance [, arguments..]);
2089
+ // $.emit(name, instance [, arguments...]);
2075
2090
  $.emit = function (name, instance) {
2076
2091
  if ('undefined' === typeof subscribed[name])
2077
2092
  return;
@@ -2143,7 +2158,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
2143
2158
  this.__class__ = 'Parsley';
2144
2159
  this.__version__ = '2.0.6';
2145
2160
  this.__id__ = ParsleyUtils.hash(4);
2146
- // Parsley must be instanciated with a DOM element or jQuery $element
2161
+ // Parsley must be instantiated with a DOM element or jQuery $element
2147
2162
  if ('undefined' === typeof element)
2148
2163
  throw new Error('You must give an element');
2149
2164
  if ('undefined' !== typeof parsleyFormInstance && 'ParsleyForm' !== parsleyFormInstance.__class__)
@@ -2178,7 +2193,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
2178
2193
  return (this.$element.is('input[type=radio], input[type=checkbox]') && 'undefined' === typeof this.options.multiple) || (this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple'));
2179
2194
  },
2180
2195
  // Multiples fields are a real nightmare :(
2181
- // Maybe some refacto would be appreciated here..
2196
+ // Maybe some refacto would be appreciated here...
2182
2197
  handleMultiple: function (parsleyFormInstance) {
2183
2198
  var
2184
2199
  that = this,
@@ -21,8 +21,6 @@ textarea.parsley-error {
21
21
  font-size: 0.9em;
22
22
  line-height: 0.9em;
23
23
  opacity: 0;
24
- -moz-opacity: 0;
25
- -webkit-opacity: 0;
26
24
 
27
25
  transition: all .3s ease-in;
28
26
  -o-transition: all .3s ease-in;
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: 2.0.6.0
4
+ version: 2.0.7.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: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2015-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -42,7 +42,10 @@ files:
42
42
  - update.sh
43
43
  - vendor/assets/javascripts/parsley.i18n.ar.js
44
44
  - vendor/assets/javascripts/parsley.i18n.bg.js
45
+ - vendor/assets/javascripts/parsley.i18n.cs.extra.js
46
+ - vendor/assets/javascripts/parsley.i18n.cs.js
45
47
  - vendor/assets/javascripts/parsley.i18n.da.js
48
+ - vendor/assets/javascripts/parsley.i18n.de.extra.js
46
49
  - vendor/assets/javascripts/parsley.i18n.de.js
47
50
  - vendor/assets/javascripts/parsley.i18n.en.extra.js
48
51
  - vendor/assets/javascripts/parsley.i18n.en.js
@@ -74,6 +77,7 @@ files:
74
77
  - vendor/assets/javascripts/parsley.i18n.tr.js
75
78
  - vendor/assets/javascripts/parsley.i18n.zh_cn.extra.js
76
79
  - vendor/assets/javascripts/parsley.i18n.zh_cn.js
80
+ - vendor/assets/javascripts/parsley.i18n.zh_tw.js
77
81
  - vendor/assets/javascripts/parsley.js
78
82
  - vendor/assets/javascripts/parsley.remote.js
79
83
  - vendor/assets/stylesheets/parsley.css
@@ -97,8 +101,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
101
  version: '0'
98
102
  requirements: []
99
103
  rubyforge_project:
100
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.4.5
101
105
  signing_key:
102
106
  specification_version: 4
103
107
  summary: Parsley.js bundled for Rails Asset Pipeline
104
108
  test_files: []
109
+ has_rdoc: