Comparing version 2.0.0-rc1 to 2.0.0-rc2
{ | ||
"name": "parsleyjs", | ||
"version": "2.0.0-rc1", | ||
"version": "2.0.0-rc2", | ||
"ignore": [ | ||
@@ -8,3 +8,6 @@ "**/.*", | ||
"test", | ||
"doc", | ||
"*.md", | ||
".json", | ||
"*.html", | ||
"AUTHORS.txt", | ||
@@ -15,9 +18,7 @@ "Gruntfile.js", | ||
], | ||
"dependencies": { | ||
"devDependencies": { | ||
"jquery": "~1.10.0", | ||
"validator.js": "~0.5.5", | ||
"requirejs": "~2.1.0", | ||
"bootstrap": "~3.0.3" | ||
}, | ||
"devDependencies": { | ||
"bootstrap": "~3.0.3", | ||
"sinonjs": "~1.7.3" | ||
@@ -28,5 +29,10 @@ }, | ||
"form", | ||
"validatation", | ||
"library" | ||
] | ||
} | ||
"validation" | ||
], | ||
"author": { | ||
"name": "Guillaume Potier", | ||
"email": "guillaume@wisembly.com", | ||
"url": "http://guillaumepotier.com/" | ||
}, | ||
"license": "MIT" | ||
} |
208
CHANGELOG.md
#Changelog | ||
**1.2.4** | ||
**master** | ||
- fixed priorityEnabled with triggered events (#510) | ||
- fixed $ conflict (#525) | ||
**1.2.3** | ||
**2.0.0-rc2** | ||
- added useHtml5Constraint option (#459) | ||
- update error message if has changed (#459) | ||
- fixed IE7 `undefined` attribute in `domApi` (#439) | ||
- fixed dynamic excluded fields in `addItem` method (#473) | ||
- removed bootstrap dep in bower, versionned localy | ||
- changed jquery requirement in bower, started test suite | ||
**1.2.2 (current stable)** | ||
- added `data-parsley-validate` W3C compliant support | ||
- removeConstraint does not destroy anymore ParsleyField instance on last | ||
error removal. It just reset UI (#259) | ||
- fixed IE9 `null` attribute in `domApi` (#439) | ||
- fixed IE `prop()` for checking required attribute (#447) | ||
- allow to call public API methods with multiple parameters (#450) | ||
- added some translations | ||
**1.2.1** | ||
- fix `display:block` added to error elements (#230) (PR #413) | ||
- added some more translations | ||
- added `data-parsley-namespace` feature to allow W3C compliant DOM-API (#424) | ||
- fixed options.error.container element (#425) | ||
- fixed priority validator error (#426) | ||
- added HTML5 tel support (#334) | ||
- fixed custom validators error message if priority is not set. (#432) | ||
**1.2.0** | ||
- [BC Break] Added `priorityEnabled` option (default true). Only show highest | ||
priority failing validator error message. Validator structure altered in order | ||
to manage priority. (#189) | ||
- [BC Break] added custom DOM-API `parsley-`. Previous data-API is dropped. (#143) | ||
- Now to validate a form, use `parsley-validate` | ||
- Now to add a validator, use `parsley-<validator>` | ||
- [BC Break] `onFormSubmit` is now called `onFormValidate` | ||
- Dynamic excluded fields management (#410) | ||
**1.1.19** | ||
- added scrollTo feature when going to focus field | ||
- `onFieldSuccess` and onFieldError` are now called once by validation | ||
and not on each validator check | ||
**1.1.18** | ||
- `onFormSubmit` now prevent form submission if returns (bool) false. | ||
It allows adding another custom check on top of Parsley. | ||
- Similarly, `onFieldSuccess` if returns (bool) false would make | ||
field invalid, even if Parsley validators are all green | ||
**1.1.17** | ||
- various localizations updates + new localizations | ||
- Ability to bind Parsley on a DOM elem, not only form (#245) | ||
- accept higher jquery versions in bower.json | ||
- added spanish codes validation in i10n/ | ||
**1.1.16** | ||
- fixed IE7 bug with checkboxes / radio buttons that were always required. | ||
- html error messages could be used (#220) | ||
- fixed show / remove error with data-remote validator (#200) | ||
- added option to silence errors `data-show-errors="false"` | ||
- added / modified some i18n localizations | ||
- Override value by using data-value attribute | ||
- added americanDate validator in parsley.extend | ||
**1.1.15** | ||
- **BC Break** removed `.parsley('isFieldValid');` in favor of `.parsley('isValid');` | ||
(#177) | ||
- added type="phone" validator | ||
- this.constraints is now an object instead of an array. **BC Break** with onFieldError | ||
listener. | ||
- removed default 'i' flag with data-regex validator. Added data-regex-flag attribute | ||
(#168) | ||
- specific behavior when field have required constraint. Do not show required error | ||
along another errors, and reciprocally (#142) | ||
**1.1.14** | ||
- added luhn validator in parsley.extra (#150) | ||
- added inlist validator in parsley.extra (#153) | ||
- added _messages.en.js template in localization folder | ||
- fixed "Uncaught RangeError: Maximum call stack size exceeded" on jQuery `.off()` | ||
Refs #136 | ||
- added $('#form').parsley('isValid') to know if form constraints fails, without | ||
adding DOM errors. Refs #94 | ||
**1.1.13** | ||
- added jquery plugin manifest | ||
**1.1.12** | ||
- added some more localizations | ||
- `reset()` action now totaly reset field behavior, since never validated before | ||
- added `data-error-container` data-attribute to easily specify where to put errors | ||
**1.1.11** | ||
- fixed `fadeIn()` undefined function with standalone version. Had to update Zepto | ||
with fx_module and fx loaded (#137) | ||
- fixed bug "Uncaught RangeError: Maximum call stack size exceeded" on | ||
bindEventValidation (#138) | ||
- fixed remote validator method (#130) | ||
- added `change` auto binded event for select inputs to have same behavior w/ fields | ||
- fixed bug on radio buttons and required constraint | ||
- added afterDate and beforeDate validators in parsley.extend | ||
**1.1.10** | ||
- **BC Break** changed errors.classHandler and errors.container | ||
- animating errors show / hide now | ||
- fixed radio/checkboxes data-trigger behavior (#115) | ||
- added `change` event to quickly remove radio/checkboxes errors (#115) | ||
- added ability to group radio / checkboxes by `data-group` attribute intead of name | ||
**1.1.9** | ||
- added `addItem` and `removeItem` functions to validate dynamically created fields | ||
- added addConstraint, updateConstraint and removeConstraint API to dynamically | ||
update fields constraints (#52) | ||
- `.delete()` method removes now all parsley related classes (#102) | ||
- added validateIfUnchanged option to force fields validation even if value is | ||
unchanged since last validation (#104) | ||
- fixed equalTo, lessThan and greaterThan validators (#78) | ||
**1.1.8** | ||
- ParsleyForm.items are now ParsleyField instances!! | ||
- fixed needsValidation function if element is reseted (#77) | ||
- fixed addListener for onFormSubmit (#72) | ||
- fixed focus 'none' bug (#73) | ||
**1.1.7** | ||
- fixed a lot of typos | ||
- added .parsley( 'destroy' ) method | ||
**1.1.6** | ||
- fixed custom error message bug (displayed once by validator that failed) | ||
- fixed error messages validators overrinding on multiple forms | ||
- added data-API error message customization | ||
- corrected lot of typo / mistakes on doc | ||
**1.1.5** | ||
- added data-error-message="message" customization ability | ||
- fixed inheritence problem with ParsleyField and ParsleyFieldMultiple | ||
**1.1.4** | ||
- passed now ParsleyForm and ParsleyField when appropriated to listeners | ||
- fixed bug on select multiple and required constraint | ||
**1.1.3** | ||
- fixed bug on onFieldValidate listener that do not reseted Parsley validation | ||
on return = false; | ||
**1.1.2** | ||
- added html5 types supports for existing validators | ||
**1.1.1** | ||
- two new parsley.extra validators: greaterthan & lowerthen | ||
**1.1.0** | ||
- added localization and extra validator configuration in external files. | ||
**1.0.0** | ||
- added ajax remote validator and go live ! | ||
**0.2.0** | ||
- heavy radio / checkbox refacto. Now dedicated class `ParsleyFieldMultiple` | ||
- added 3 custom checkbox validators: mincheck, maxcheck and rangecheck | ||
**0.1.4** | ||
- added html5 api required="required" support | ||
- added radio and checkbox required (only) validation support. For now, to display | ||
nice errors, checkbox and radio with same name must be wrapped in a dedicated | ||
DOM parent on which parsley-error class would be binded and ul errors apend | ||
**0.1.3** | ||
- fixed bug on addListener when added after Parsley initialisation. @gmajoulet | ||
**0.1.2** | ||
- renamed listeners and added a public API to add / override these listeners | ||
- added `data-parsley-validate-if-empty` field option (#489) | ||
- fixed select multiple bug (#522) | ||
- allowed checkbox, radio and select multiple inputs to have either a `name` | ||
or an `id` to be binded (instead of just a name) |
/*! | ||
* Parsleyjs | ||
* Guillaume Potier - <guillaume@wisembly.com> | ||
* Version 2.0.0-rc1 - built Thu Feb 27 2014 15:19:20 | ||
* Version 2.0.0-rc2 - built Sun Mar 02 2014 16:29:28 | ||
* MIT Licensed | ||
* | ||
*/ | ||
!function(a,b){var c={attr:function(a,b,c){var d,e={},f=new RegExp("^"+b,"i");if("undefined"==typeof a||"undefined"==typeof a[0])return{};for(var g in a[0].attributes)if(d=a[0].attributes[g],"undefined"!=typeof d&&null!==d&&d.specified&&f.test(d.name)){if("undefined"!=typeof c&&new RegExp(c,"i").test(d.name))return!0;e[this.camelize(d.name.replace(b,""))]=this.deserializeValue(d.value)}return"undefined"==typeof c?e:!1},setAttr:function(a,b,c,d){a[0].setAttribute(this.dasherize(b+c),String(d))},get:function(a,b,c){for(var d=0,e=(b||"").split(".");this.isObject(a)||this.isArray(a);)if(a=a[e[d++]],d===e.length)return a||c;return c},hash:function(a){return String(Math.random()).substring(2,a?a+2:9)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},isObject:function(a){return a===Object(a)},deserializeValue:function(a){var b;try{return a?"true"==a||("false"==a?!1:"null"==a?null:isNaN(b=Number(a))?/^[\[\{]/.test(a)?$.parseJSON(a):a:b):a}catch(c){return a}},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},dasherize:function(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}},d={namespace:"data-parsley-",inputs:"input, textarea, select",excluded:"input[type=button], input[type=submit], input[type=reset]",priorityEnabled:!0,uiEnabled:!0,validationThreshold:3,focus:"first",trigger:!1,errorClass:"parsley-error",successClass:"parsley-success",classHandler:function(){},errorsContainer:function(){},errorsWrapper:'<ul class="parsley-errors-list"></ul>',errorTemplate:"<li></li>"},e=function(){};e.prototype={actualizeOptions:function(){return this.options=this.parsleyInstance.OptionsFactory.get(this),this},validateThroughValidator:function(){return a.ParsleyValidator.validate.apply(a.ParsleyValidator,arguments)},subscribe:function(a,b){return $.listenTo(this,a.toLowerCase(),b),this},unsubscribe:function(a){return $.unsubscribeTo(this,a.toLowerCase()),this},reset:function(){if("ParsleyField"===this.__class__)return $.emit("parsley:field:reset",this);for(var a=0;a<this.fields.length;a++)$.emit("parsley:field:reset",this.fields[a]);$.emit("parsley:form:reset",this)},destroy:function(){if("ParsleyField"===this.__class__)return $.emit("parsley:field:destroy",this),void this.$element.removeData("Parsley");for(var a=0;a<this.fields.length;a++)this.fields[a].destroy();$.emit("parsley:form:destroy",this),this.$element.removeData("Parsley")}},function(a){var b=function(a){return this.__class__="Validator",this.__version__="0.5.5",this.options=a||{},this.bindingKey=this.options.bindingKey||"_validatorjsConstraint",this};b.prototype={constructor:b,validate:function(a,b,c){if("string"!=typeof a&&"object"!=typeof a)throw new Error("You must validate an object or a string");return"string"==typeof a||g(a)?this._validateString(a,b,c):this.isBinded(a)?this._validateBindedObject(a,b):this._validateObject(a,b,c)},bind:function(a,b){if("object"!=typeof a)throw new Error("Must bind a Constraint to an object");return a[this.bindingKey]=new c(b),this},unbind:function(a){return"undefined"==typeof a._validatorjsConstraint?this:(delete a[this.bindingKey],this)},isBinded:function(a){return"undefined"!=typeof a[this.bindingKey]},getBinded:function(a){return this.isBinded(a)?a[this.bindingKey]:null},_validateString:function(a,b,c){var f,h=[];g(b)||(b=[b]);for(var i=0;i<b.length;i++){if(!(b[i]instanceof e))throw new Error("You must give an Assert or an Asserts array to validate a string");f=b[i].check(a,c),f instanceof d&&h.push(f)}return h.length?h:!0},_validateObject:function(a,b,d){if("object"!=typeof b)throw new Error("You must give a constraint to validate an object");return b instanceof c?b.check(a,d):new c(b).check(a,d)},_validateBindedObject:function(a,b){return a[this.bindingKey].check(a,b)}},b.errorCode={must_be_a_string:"must_be_a_string",must_be_an_array:"must_be_an_array",must_be_a_number:"must_be_a_number",must_be_a_string_or_array:"must_be_a_string_or_array"};var c=function(a,b){if(this.__class__="Constraint",this.options=b||{},this.nodes={},a)try{this._bootstrap(a)}catch(c){throw new Error("Should give a valid mapping object to Constraint",c,a)}return this};c.prototype={constructor:c,check:function(a,b){var c,d={};for(var h in this.options.strict?this.nodes:a)if(this.options.strict?this.has(h,a):this.has(h))c=this._check(h,a[h],b),(g(c)&&c.length>0||!g(c)&&!f(c))&&(d[h]=c);else if(this.options.strict)try{(new e).HaveProperty(h).validate(a)}catch(i){d[h]=i}return f(d)?!0:d},add:function(a,b){if(b instanceof e||g(b)&&b[0]instanceof e)return this.nodes[a]=b,this;if("object"==typeof b&&!g(b))return this.nodes[a]=b instanceof c?b:new c(b),this;throw new Error("Should give an Assert, an Asserts array, a Constraint",b)},has:function(a,b){var b="undefined"!=typeof b?b:this.nodes;return"undefined"!=typeof b[a]},get:function(a,b){return this.has(a)?this.nodes[a]:b||null},remove:function(a){var b=[];for(var c in this.nodes)c!==a&&(b[c]=this.nodes[c]);return this.nodes=b,this},_bootstrap:function(a){if(a instanceof c)return this.nodes=a.nodes;for(var b in a)this.add(b,a[b])},_check:function(a,b,d){if(this.nodes[a]instanceof e)return this._checkAsserts(b,[this.nodes[a]],d);if(g(this.nodes[a]))return this._checkAsserts(b,this.nodes[a],d);if(this.nodes[a]instanceof c)return this.nodes[a].check(b,d);throw new Error("Invalid node",this.nodes[a])},_checkAsserts:function(a,b,c){for(var d,e=[],f=0;f<b.length;f++)d=b[f].check(a,c),"undefined"!=typeof d&&!0!==d&&e.push(d);return e}};var d=function(a,b,c){if(this.__class__="Violation",!(a instanceof e))throw new Error("Should give an assertion implementing the Assert interface");this.assert=a,this.value=b,"undefined"!=typeof c&&(this.violation=c)};d.prototype={show:function(){var a={assert:this.assert.__class__,value:this.value};return this.violation&&(a.violation=this.violation),a},__toString:function(){if("undefined"!=typeof this.violation)var a='", '+this.getViolation().constraint+" expected was "+this.getViolation().expected;return this.assert.__class__+' assert failed for "'+this.value+a||""},getViolation:function(){var a,b;for(a in this.violation)b=this.violation[a];return{constraint:a,expected:b}}};var e=function(a){return this.__class__="Assert",this.__parentClass__=this.__class__,this.groups=[],"undefined"!=typeof a&&this.addGroup(a),this};e.prototype={construct:e,check:function(a,b){if(!(b&&!this.hasGroup(b)||!b&&this.hasGroups()))try{return this.validate(a,b)}catch(c){return c}},hasGroup:function(a){return g(a)?this.hasOneOf(a):"Any"===a?!0:this.hasGroups()?-1!==this.groups.indexOf(a):"Default"===a},hasOneOf:function(a){for(var b=0;b<a.length;b++)if(this.hasGroup(a[b]))return!0;return!1},hasGroups:function(){return this.groups.length>0},addGroup:function(a){return g(a)?this.addGroups(a):(this.hasGroup(a)||this.groups.push(a),this)},removeGroup:function(a){for(var b=[],c=0;c<this.groups.length;c++)a!==this.groups[c]&&b.push(this.groups[c]);return this.groups=b,this},addGroups:function(a){for(var b=0;b<a.length;b++)this.addGroup(a[b]);return this},HaveProperty:function(a){return this.__class__="HaveProperty",this.node=a,this.validate=function(a){if("undefined"==typeof a[this.node])throw new d(this,a,{value:this.node});return!0},this},Blank:function(){return this.__class__="Blank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""!==a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Callback:function(a){if(this.__class__="Callback",this.arguments=Array.prototype.slice.call(arguments),1===this.arguments.length?this.arguments=[]:this.arguments.splice(0,1),"function"!=typeof a)throw new Error("Callback must be instanciated with a function");return this.fn=a,this.validate=function(a){var b=[a].concat(this.arguments),c=this.fn.apply(this,b);if(!0!==c)throw new d(this,a,{result:c});return!0},this},Choice:function(a){if(this.__class__="Choice",!g(a)&&"function"!=typeof a)throw new Error("Choice must be instanciated with an array or a function");return this.list=a,this.validate=function(a){for(var b="function"==typeof this.list?this.list():this.list,c=0;c<b.length;c++)if(a===b[c])return!0;throw new d(this,a,{choices:b})},this},Collection:function(a){return this.__class__="Collection",this.constraint="undefined"!=typeof a?new c(a):!1,this.validate=function(a,c){var e,h=new b,i=0,j={},k=this.groups.length?this.groups:c;if(!g(a))throw new d(this,array,{value:b.errorCode.must_be_an_array});for(var l=0;l<a.length;l++)e=this.constraint?h.validate(a[l],this.constraint,k):h.validate(a[l],k),f(e)||(j[i]=e),i++;return f(j)?!0:j},this},Count:function(a){return this.__class__="Count",this.count=a,this.validate=function(a){if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});var c="function"==typeof this.count?this.count(a):this.count;if(isNaN(Number(c)))throw new Error("Count must be a valid interger",c);if(c!==a.length)throw new d(this,a,{count:c});return!0},this},Email:function(){return this.__class__="Email",this.validate=function(a){var c=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Eql:function(a){if(this.__class__="Eql","undefined"==typeof a)throw new Error("Equal must be instanciated with an Array or an Object");return this.eql=a,this.validate=function(a){var b="function"==typeof this.eql?this.eql(a):this.eql;if(!h.eql(b,a))throw new d(this,a,{eql:b});return!0},this},EqualTo:function(a){if(this.__class__="EqualTo","undefined"==typeof a)throw new Error("EqualTo must be instanciated with a value or a function");return this.reference=a,this.validate=function(a){var b="function"==typeof this.reference?this.reference(a):this.reference;if(b!==a)throw new d(this,a,{value:b});return!0},this},GreaterThan:function(a){if(this.__class__="GreaterThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>=a)throw new d(this,a,{threshold:this.threshold});return!0},this},GreaterThanOrEqual:function(a){if(this.__class__="GreaterThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>a)throw new d(this,a,{threshold:this.threshold});return!0},this},InstanceOf:function(a){if(this.__class__="InstanceOf","undefined"==typeof a)throw new Error("InstanceOf must be instanciated with a value");return this.classRef=a,this.validate=function(a){if(!0!=a instanceof this.classRef)throw new d(this,a,{classRef:this.classRef});return!0},this},IPv4:function(){return this.__class__="IPv4",this.validate=function(a){var c=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Length:function(a){if(this.__class__="Length",!a.min&&!a.max)throw new Error("Lenth assert must be instanciated with a { min: x, max: y } object");return this.min=a.min,this.max=a.max,this.validate=function(a){if("string"!=typeof a&&!g(a))throw new d(this,a,{value:b.errorCode.must_be_a_string_or_array});if("undefined"!=typeof this.min&&this.min===this.max&&a.length!==this.min)throw new d(this,a,{min:this.min,max:this.max});if("undefined"!=typeof this.max&&a.length>this.max)throw new d(this,a,{max:this.max});if("undefined"!=typeof this.min&&a.length<this.min)throw new d(this,a,{min:this.min});return!0},this},LessThan:function(a){if(this.__class__="LessThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<=a)throw new d(this,a,{threshold:this.threshold});return!0},this},LessThanOrEqual:function(a){if(this.__class__="LessThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<a)throw new d(this,a,{threshold:this.threshold});return!0},this},Mac:function(){return this.__class__="Mac",this.validate=function(a){var c=/^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},NotNull:function(){return this.__class__="NotNull",this.validate=function(a){if(null===a||"undefined"==typeof a)throw new d(this,a);return!0},this},NotBlank:function(){return this.__class__="NotBlank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""===a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Null:function(){return this.__class__="Null",this.validate=function(a){if(null!==a)throw new d(this,a);return!0},this},Range:function(a,b){if(this.__class__="Range",!a||!b)throw new Error("Range assert expects min and max values");return this.min=a,this.max=b,this.validate=function(a){try{return"string"==typeof a&&isNaN(Number(a))||g(a)?(new e).Length({min:this.min,max:this.max}).validate(a):(new e).GreaterThanOrEqual(this.min).validate(a)&&(new e).LessThanOrEqual(this.max).validate(a),!0}catch(b){throw new d(this,a,b.violation)}return!0},this},Regexp:function(a,c){if(this.__class__="Regexp","undefined"==typeof a)throw new Error("You must give a regexp");return this.regexp=a,this.flag=c||"",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!new RegExp(this.regexp).test(a,this.flag))throw new d(this,a,{regexp:this.regexp,flag:this.flag});return!0},this},Required:function(){return this.__class__="Required",this.validate=function(a){if("undefined"==typeof a)throw new d(this,a);if("string"==typeof a)try{(new e).NotNull().validate(a)&&(new e).NotBlank().validate(a)}catch(b){throw new d(this,a)}return!0},this},Unique:function(a){return this.__class__="Unique","object"==typeof a&&(this.key=a.key),this.validate=function(a){var c,e=[];if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});for(var f=0;f<a.length;f++)if(c="object"==typeof a[f]?a[f][this.key]:a[f],"undefined"!=typeof c){if(-1!==e.indexOf(c))throw new d(this,a,{value:c});e.push(c)}return!0},this}},a.Assert=e,a.Validator=b,a.Violation=d,a.Constraint=c,Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&1/0!=d&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var f=function(a){for(var b in a)return!1;return!0},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={eql:function(a,b){if(a===b)return!0;if("undefined"!=typeof Buffer&&Buffer.isBuffer(a)&&Buffer.isBuffer(b)){if(a.length!==b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}return a instanceof Date&&b instanceof Date?a.getTime()===b.getTime():"object"!=typeof a&&"object"!=typeof b?a==b:this.objEquiv(a,b)},isUndefinedOrNull:function(a){return null===a||"undefined"==typeof a},isArguments:function(a){return"[object Arguments]"==Object.prototype.toString.call(a)},keys:function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b},objEquiv:function(a,b){if(this.isUndefinedOrNull(a)||this.isUndefinedOrNull(b))return!1;if(a.prototype!==b.prototype)return!1;if(this.isArguments(a))return this.isArguments(b)?eql(pSlice.call(a),pSlice.call(b)):!1;try{var c,d,e=this.keys(a),f=this.keys(b)}catch(g){return!1}if(e.length!==f.length)return!1;for(e.sort(),f.sort(),d=e.length-1;d>=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!this.eql(a[c],b[c]))return!1;return!0}};"function"==typeof define&&define.amd&&define("validator",[],function(){return a})}("undefined"==typeof exports?this["undefined"!=typeof validatorjs_ns?validatorjs_ns:"Validator"]={}:exports);var f=function(a,b){this.__class__="ParsleyValidator",this.Validator=Validator,this.locale="en",this.init(a||{},b||{})};f.prototype={init:function(a,b){this.catalog=b;for(var c in a)this.addValidator(c,a[c].fn,a[c].priority);$.emit("parsley:validator:init")},setLocale:function(a){if("undefined"==typeof this.catalog[a])throw new Error(a+" is not available in the catalog");return this.locale=a,this},addCatalog:function(a,b,c){return"object"==typeof b&&(this.catalog[a]=b),!0===c?this.setLocale(a):this},addMessage:function(a,c,d){b===typeof this.catalog[a]&&(this.catalog[a]={}),this.catalog[a][c]=d},validate:function(){return(new this.Validator.Validator).validate.apply(new Validator.Validator,arguments)},addValidator:function(a,b,c){return this.validators[a]=function(a){return $.extend((new Validator.Assert).Callback(b,a),{priority:c})},this},updateValidator:function(a,b,c){return addValidator(a,b,c)},removeValidator:function(a){return delete this.validators[a],this},getErrorMessage:function(b){var c;return c="type"===b.name?a.ParsleyConfig.i18n[this.locale][b.name][b.requirements]:this.formatMesssage(a.ParsleyConfig.i18n[this.locale][b.name],b.requirements),""!==c?c:a.ParsleyConfig.i18n[this.locale].defaultMessage},formatMesssage:function(a,b){if("object"==typeof b){for(var c in b)a=this.formatMesssage(a,b[c]);return a}return"string"==typeof a?a.replace(new RegExp("%s","i"),b):""},validators:{notblank:function(){return $.extend((new Validator.Assert).NotBlank(),{priority:2})},required:function(){return $.extend((new Validator.Assert).Required(),{priority:512})},type:function(a){var b;switch(a){case"email":b=(new Validator.Assert).Email();break;case"number":b=(new Validator.Assert).Regexp("^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$");break;case"integer":b=(new Validator.Assert).Regexp("^-?\\d+$");break;case"digits":b=(new Validator.Assert).Regexp("^\\d+$");break;case"alphanum":b=(new Validator.Assert).Regexp("^\\w+$","i");break;case"url":b=(new Validator.Assert).Regexp("(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)","i");break;default:throw new Error("validator type `"+a+"` is not supported")}return $.extend(b,{priority:256})},pattern:function(a){return $.extend((new Validator.Assert).Regexp(a),{priority:64})},minlength:function(a){return $.extend((new Validator.Assert).Length({min:a}),{priority:30})},maxlength:function(a){return $.extend((new Validator.Assert).Length({max:a}),{priority:30})},length:function(a){return $.extend((new Validator.Assert).Length({min:a[0],max:a[1]}),{priority:32})},mincheck:function(a){return this.minlength(a)},maxcheck:function(a){return this.maxlength(a)},check:function(a){return this.length(a)},min:function(a){return $.extend((new Validator.Assert).GreaterThanOrEqual(a),{priority:30})},max:function(a){return $.extend((new Validator.Assert).LessThanOrEqual(a),{priority:30})},range:function(a){return $.extend((new Validator.Assert).Range(a[0],a[1]),{priority:32})},equalto:function(a){return $.extend((new Validator.Assert).Callback(function(a,b){return a===$(b).val()},a),{priority:256})}}};var g=function(){this.__class__="ParsleyUI"};g.prototype={listen:function(){return $.listen("parsley:form:init",this,this.setupForm),$.listen("parsley:field:init",this,this.setupField),$.listen("parsley:field:validated",this,this.reflow),$.listen("parsley:form:validated",this,this.focus),$.listen("parsley:field:reset",this,this.reset),$.listen("parsley:form:destroy",this,this.destroy),$.listen("parsley:field:destroy",this,this.destroy),this},reflow:function(a){if("undefined"!=typeof a._ui&&!1!==a._ui.active){var b=this._diff(a.validationResult,a._ui.lastValidationResult);a._ui.lastValidationResult=a.validationResult,a._ui.validatedOnce=!0,this.manageStatusClass(a),this.manageErrorsMessages(a,b),this.actualizeTriggers(a),(b.kept.length||b.added.length)&&"undefined"==typeof a._ui.failedOnce&&this.manageFailingFieldTrigger(a)}},manageStatusClass:function(a){!0===a.validationResult?this._successClass(a):a.validationResult.length>0?this._errorClass(a):this._resetClass(a)},manageErrorsMessages:function(a,c){if("undefined"!=typeof a.options.errorMessage)return void(c.added.length||c.kept.length?(0===a._ui.$errorsWrapper.find(".parsley-custom-error-message").length&&a._ui.$errorsWrapper.append($(a.options.errorTemplate).addClass("parsley-custom-error-message")),a._ui.$errorsWrapper.addClass("filled").find(".parsley-custom-error-message").html(a.options.errorMessage)):a._ui.$errorsWrapper.removeClass("filled").find(".parsley-custom-error-message").remove());for(var d=0;d<c.removed.length;d++)this.removeError(a,c.removed[d].assert.name,!0);for(d=0;d<c.added.length;d++)this.addError(a,c.added[d].assert.name,b,c.added[d].assert,!0);for(d=0;d<c.kept.length;d++)this.updateError(a,c.kept[d].assert.name,b,c.kept[d].assert,!0)},addError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").append($(a.options.errorTemplate).addClass("parsley-"+b).html(c||this._getErrorMessage(a,d))),!0!==e&&this._errorClass(a)},updateError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").find(".parsley-"+b).html(c||this._getErrorMessage(a,d)),!0!==e&&this._errorClass(a)},removeError:function(a,b,c){a._ui.$errorsWrapper.removeClass("filled").find(".parsley-"+b).remove(),!0!==c&&this.manageStatusClass(a)},focus:function(a){if(!0===a.validationResult||"none"===a.options.focus)return a._focusedField=null;a._focusedField=null;for(var b=0;b<a.fields.length;b++)if(!0!==a.fields[b].validationResult&&a.fields[b].validationResult.length>0&&"undefined"==typeof a.fields[b].options.noFocus){if("first"===a.options.focus)return a._focusedField=a.fields[b].$element,a._focusedField.focus();a._focusedField=a.fields[b].$element}return null===a._focusedField?null:a._focusedField.focus()},_getErrorMessage:function(b,c){var d=c.name+"Message";return"undefined"!=typeof b.options[d]?b.options[d]:a.ParsleyValidator.getErrorMessage(c)},_diff:function(a,b,c){for(var d=[],e=[],f=0;f<a.length;f++){for(var g=!1,h=0;h<b.length;h++)if(a[f].assert.name===b[h].assert.name){g=!0;break}g?e.push(a[f]):d.push(a[f])}return{kept:e,added:d,removed:c?[]:this._diff(b,a,!0).added}},setupForm:function(a){a.$element.on("submit.Parsley",!1,$.proxy(a.onSubmitValidate,a)),!1!==a.options.uiEnabled&&a.$element.attr("novalidate","")},setupField:function(a){var b={active:!1};!1!==a.options.uiEnabled&&(b.active=!0,a.$element.attr(a.options.namespace+"id",a.__id__),b.$errorClassHandler=this._manageClassHandler(a),b.errorsWrapperId="parsley-id-"+("undefined"!=typeof a.options.multiple?"multiple-"+a.options.multiple:a.__id__),b.$errorsWrapper=$(a.options.errorsWrapper).attr("id",b.errorsWrapperId),b.lastValidationResult=[],b.validatedOnce=!1,b.validationInformationVisible=!1,a._ui=b,this._insertErrorWrapper(a),this.actualizeTriggers(a))},_manageClassHandler:function(a){if("string"==typeof a.options.classHandler&&$(a.options.classHandler).length)return $(a.options.classHandler);var b=a.options.classHandler(a);return"undefined"!=typeof b&&b.length?b:"undefined"==typeof a.options.multiple?a.$element:a.$element.parent()},_insertErrorWrapper:function(a){if("string"==typeof a.options.errorsContainer&&$(a.options.errorsContainer).length)return $(a.options.errorsContainer).append(a._ui.$errorsWrapper);var b=a.options.errorsContainer(a);return"undefined"!=typeof b&&b.length?b.append(a._ui.$errorsWrapper):"undefined"==typeof a.options.multiple?a.$element.after(a._ui.$errorsWrapper):a.$element.parent().after(a._ui.$errorsWrapper)},actualizeTriggers:function(a){if(a.$element.off(".Parsley"),!1!==a.options.trigger){var b=a.options.trigger.replace(/^\s+/g,"").replace(/\s+$/g,"");""!==b&&a.$element.on(b.split(" ").join(".Parsley ")+".Parsley",!1,$.proxy("function"==typeof a.eventValidate?a.eventValidate:this.eventValidate,a))}},eventValidate:function(a){new RegExp("key").test(a.type)&&!this._ui.validationInformationVisible&&this.getValue().length<=this.options.validationThreshold||(this._ui.validatedOnce=!0,this.validate())},manageFailingFieldTrigger:function(a){return a._ui.failedOnce=!0,a.options.multiple&&$("["+a.options.namespace+'multiple="'+a.options.multiple+'"]').each(function(){return new RegExp("change","i").test($(this).parsley().options.trigger||"")?void 0:$(this).parsley().$element.on("change.ParsleyFailedOnce",!1,$.proxy(a.validate,a))}),new RegExp("keyup","i").test(a.options.trigger||"")?void 0:a.$element.on("keyup.ParsleyFailedOnce",!1,$.proxy(a.validate,a))},reset:function(a){a.$element.off(".Parsley"),a.$element.off(".ParsleyFailedOnce"),"ParsleyForm"!==a.__class__&&(a._ui.$errorsWrapper.children().each(function(){$(this).remove()}),this._resetClass(a),a._ui.validatedOnce=!1,a._ui.lastValidationResult=[],a._ui.validationInformationVisible=!1)},destroy:function(a){this.reset(a),"ParsleyForm"!==a.__class__&&(a._ui.$errorsWrapper.remove(),delete a._ui)},_successClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.errorClass).addClass(a.options.successClass)},_errorClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.successClass).addClass(a.options.errorClass)},_resetClass:function(a){a._ui.$errorClassHandler.removeClass(a.options.successClass).removeClass(a.options.errorClass)}};var h=function(a,b,d,e){this.__class__="OptionsFactory",this.__id__=c.hash(4),this.formOptions=null,this.fieldOptions=null,this.staticOptions=$.extend(!0,{},a,b,d,{namespace:e})};h.prototype={get:function(a){if("undefined"==typeof a.__class__)throw new Error("Parsley Instance expected");switch(a.__class__){case"Parsley":return this.staticOptions;case"ParsleyForm":return this.getFormOptions(a);case"ParsleyField":return this.getFieldOptions(a);default:throw new Error("Instance "+a.__class__+" is not supported")}},getFormOptions:function(a){return this.formOptions=c.attr(a.$element,this.staticOptions.namespace),$.extend({},this.staticOptions,this.formOptions)},getFieldOptions:function(a){return this.fieldOptions=c.attr(a.$element,this.staticOptions.namespace),$.extend({},this.staticOptions,this.formOptions,this.fieldOptions)}};var i=function(a,b){if(this.__class__="ParsleyForm",this.__id__=c.hash(4),"Parsley"!==c.get(b,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=b,this.init($(a))};i.prototype={init:function(a){return this.$element=a,this.validationResult=null,this.options=this.parsleyInstance.OptionsFactory.get(this),this._bindFields()},onSubmitValidate:function(a){return this.validate(b,a),!1===this.validationResult&&a instanceof $.Event&&a.preventDefault(),this},validate:function(a,b){this.submitEvent=b,this.validationResult=!0;var c=[];this._refreshFields(),$.emit("parsley:form:validate",this);for(var d=0;d<this.fields.length;d++)a&&a!==this.fields[d].options.group||(c=this.fields[d].validate(),!0!==c&&c.length>0&&this.validationResult&&(this.validationResult=!1));return $.emit("parsley:form:validated",this),this.validationResult},isValid:function(a){this._refreshFields();for(var b=0;b<this.fields.length;b++)if((!a||a===this.fields[b].options.group)&&!1===this.fields[b].isValid())return!1;return!0},_refreshFields:function(){return this.actualizeOptions()._bindFields()},_bindFields:function(){var a=this;return this.fields=[],this.$element.find(this.options.inputs).each(function(){a.addField(this)}),this},addField:function(b){var c=new a.Parsley(b,{},this.parsleyInstance);return"ParsleyField"===c.__class__&&this.fields.push(c),this},removeField:function(){},reset:function(){},destroy:function(){}};var j=function(b,d,e,f,g){if("ParsleyField"!==c.get(b,"__class__"))throw new Error("ParsleyField instance expected");if("function"!=typeof a.ParsleyValidator.validators[d]&&"Assert"!==a.ParsleyValidator.validators[d](e).__parentClass__)throw new Error("Valid validator expected");var h=function(b,d){return"undefined"!=typeof b.options[d+"Priority"]?b.options[d+"Priority"]:c.get(a.ParsleyValidator.validators[d](e),"priority",2)};return f=f||h(b,d),$.extend(a.ParsleyValidator.validators[d](e),{name:d,requirements:e,priority:f,groups:[f],isDomConstraint:g||c.attr(b.$element,b.options.namespace,d)})},k=function(a,b){if(this.__class__="ParsleyField",this.__id__=c.hash(4),"Parsley"!==c.get(b,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=b,this.init($(a),b.options)};k.prototype={init:function(b){if(this.constraints=[],this.$element=b,this.validationResult=[],this.options=this.parsleyInstance.OptionsFactory.get(this),this.$element.is("input[type=radio], input[type=checkbox]")&&"undefined"==typeof this.options.multiple){if("undefined"==typeof this.$element.attr("name"))return a.console&&a.console.warn&&a.console.warn("To be binded by Parsley, a radio or checkbox input must have either a name or a multiple option.",this.$element),this.parsleyInstance;this.options.multiple=this.$element.attr("name").replace(/(:|\.|\[|\]|\$)/g,""),c.setAttr(this.$element,this.options.namespace,"multiple",this.options.multiple)}return this.bindConstraints()},validate:function(){return $.emit("parsley:field:validate",this),$.emit("parsley:field:"+(this.isValid()?"success":"error"),this),$.emit("parsley:field:validated",this),this.validationResult},getConstraintsSortedPriorities:function(){for(var a=[],b=0;b<this.constraints.length;b++)-1===a.indexOf(this.constraints[b].priority)&&a.push(this.constraints[b].priority);return a.sort(function(a,b){return b-a}),a},isValid:function(){var a=this.getConstraintsSortedPriorities(),b=this.getValue();if(this.refreshConstraints(),""===b&&!this.isRequired())return this.validationResult=[];if(!1===this.options.priorityEnabled)return!0===(this.validationResult=this.validateThroughValidator(b,this.constraints,"Any"));for(var c=0;c<a.length;c++)if(!0!==(this.validationResult=this.validateThroughValidator(b,this.constraints,a[c])))return!1;return!0},isRequired:function(){var a=this._constraintIndex("required");return!(-1===a||-1!==a&&!1===this.constraints[a].requirements)},getValue:function(){if("undefined"!=typeof this.options.value)return this.options.value;if(this.$element.is("input[type=radio]"))return $("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').val()||"";if(this.$element.is("input[type=checkbox]")){var a=[];return $("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').each(function(){a.push($(this).val())}),a.length?a:""}return this.$element.val()},refreshConstraints:function(){return this.actualizeOptions().bindConstraints() | ||
},bindConstraints:function(){for(var a=[],b=0;b<this.constraints.length;b++)!1===this.constraints[b].isDomConstraint&&a.push(this.constraints[b]);this.constraints=a;for(var c in this.options)this.addConstraint(c,this.options[c]);return this.bindHtml5Constraints()},bindHtml5Constraints:function(){(this.$element.hasClass("required")||this.$element.attr("required"))&&this.addConstraint("required",!0,b,!0),"string"==typeof this.$element.attr("pattern")&&this.addConstraint("pattern",this.$element.attr("pattern"),b,!0),"undefined"!=typeof this.$element.attr("min")&&"undefined"!=typeof this.$element.attr("max")?this.addConstraint("range",[this.$element.attr("min"),this.$element.attr("max")],b,!0):"undefined"!=typeof this.$element.attr("min")?this.addConstraint("min",this.$element.attr("min"),b,!0):"undefined"!=typeof this.$element.attr("max")&&this.addConstraint("max",this.$element.attr("max"),b,!0);var a=this.$element.attr("type");return"undefined"==typeof a?this:"number"===a?this.addConstraint("type","integer",b,!0):new RegExp(a,"i").test("email url range")?this.addConstraint("type",a,b,!0):void 0},addConstraint:function(b,c,d,e){return b=b.toLowerCase(),"function"==typeof a.ParsleyValidator.validators[b]&&(constraint=new j(this,b,c,d,e),-1!==this._constraintIndex(constraint.name)&&this.removeConstraint(constraint.name),this.constraints.push(constraint)),this},removeConstraint:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name){this.constraints.splice(b,1);break}return this},updateConstraint:function(a,b,c){return this.removeConstraint(a).addConstraint(a,b,c)},_constraintIndex:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name)return b;return-1}};var l=$({}),m={};$.listen=function(a){if("undefined"==typeof m[a]&&(m[a]=[]),"function"==typeof arguments[1])return m[a].push({fn:arguments[1]});if("object"==typeof arguments[1]&&"function"==typeof arguments[2])return m[a].push({fn:arguments[2],ctxt:arguments[1]});throw new Error("Wrong parameters")},$.listenTo=function(a,b,c){if("undefined"==typeof m[b]&&(m[b]=[]),!(a instanceof k||a instanceof i))throw new Error("Must give Parsley instance");if("string"!=typeof b||"function"!=typeof c)throw new Error("Wrong parameters");m[b].push({instance:a,fn:c})},$.unsubscribe=function(a,b){if("undefined"!=typeof m[a]){if("string"!=typeof a||"function"!=typeof b)throw new Error("Wrong arguments");for(var c=0;c<m[a].length;c++)if(m[a][c].fn===b)return m[a].splice(c,1)}},$.unsubscribeTo=function(a,b){if("undefined"!=typeof m[b]){if(!(a instanceof k||a instanceof i))throw new Error("Must give Parsley instance");for(var c=0;c<m[b].length;c++)if("undefined"!=typeof m[b][c].instance&&m[b][c].instance.__id__===a.__id__)return m[b].splice(c,1)}},$.unsubscribeAll=function(a){"undefined"!=typeof m[a]&&delete m[a]},$.emit=function(a,b){if("undefined"!=typeof m[a])for(var c=0;c<m[a].length;c++)if("undefined"!=typeof m[a][c].instance){if(b instanceof k||b instanceof i)if(m[a][c].instance.__id__!==b.__id__){if(m[a][c].instance instanceof i&&b instanceof k)for(var d=0;d<m[a][c].instance.fields.length;d++)if(m[a][c].instance.fields[d].__id__===b.__id__){m[a][c].fn.apply(l,Array.prototype.slice.call(arguments,1));continue}}else m[a][c].fn.apply(l,Array.prototype.slice.call(arguments,1))}else m[a][c].fn.apply("undefined"!=typeof m[a][c].ctxt?m[a][c].ctxt:l,Array.prototype.slice.call(arguments,1))},$.subscribed=function(){return m},a.ParsleyConfig=a.ParsleyConfig||{},a.ParsleyConfig.i18n=a.ParsleyConfig.i18n||{},a.ParsleyConfig.i18n.en=$.extend(a.ParsleyConfig.i18n.en||{},{defaultMessage:"This value seems to be invalid.",type:{email:"This value should be a valid email.",url:"This value should be a valid url.",number:"This value should be a valid number.",integer:"This value should be a valid integer.",digits:"This value should be digits.",alphanum:"This value should be alphanumeric."},notblank:"This value should not be blank.",required:"This value is required.",pattern:"This value seems to be invalid.",min:"This value should be greater than or equal to %s.",max:"This value should be lower than or equal to %s.",range:"This value should be between %s and %s.",minlength:"This value is too short. It should have %s characters or more.",maxlength:"This value is too long. It should have %s characters or less.",length:"This value length is invalid. It should be between %s and %s characters long.",mincheck:"You must select at least %s choices.",maxcheck:"You must select %s choices or less.",check:"You must select between %s and %s choices.",equalto:"This value should be the same."}),"undefined"!=typeof a.ParsleyValidator&&a.ParsleyValidator.addCatalog("en",a.ParsleyConfig.i18n.en,!0);var n=function(a,b,d){if(this.__class__="Parsley",this.__version__="2.0.0-rc1",this.__id__=c.hash(4),"undefined"==typeof a)throw new Error("You must give an element");return this.init($(a),b,d)};n.prototype={init:function(b,e,f){return this.$element=b,this.$element.data("Parsley")?this.$element.data("Parsley"):(this.OptionsFactory=new h(d,c.get(a,"ParsleyConfig",{}),e,this.getNamespace(e)),e=this.OptionsFactory.staticOptions,this.$element.is("form")||c.attr(this.$element,e.namespace,"validate")&&!this.$element.is(e.inputs)?this.bind("parsleyForm",f):this.$element.is(e.inputs)&&!this.$element.is(e.excluded)?this.bind("parsleyField",f):this)},getNamespace:function(b){return"undefined"!=typeof this.$element.data("parsleyNamespace")?this.$element.data("parsleyNamespace"):"undefined"!=typeof c.get(b,"namespace")?b.namespace:"undefined"!=typeof c.get(a,"ParsleyConfig.namespace")?a.ParsleyConfig.namespace:d.namespace},bind:function(b,c){switch(b){case"parsleyForm":parsleyInstance=$.extend(new i(this.$element,c||this),new e,a.ParsleyExtend);break;case"parsleyField":parsleyInstance=$.extend(new k(this.$element,c||this),new e,a.ParsleyExtend);break;default:throw new Error(b+"is not a supported Parsley type")}return this.$element.data("Parsley",parsleyInstance),("ParsleyForm"===parsleyInstance.__class__||"ParsleyField"===parsleyInstance.__class__)&&$.emit("parsley:"+("parsleyForm"===b?"form":"field")+":init",parsleyInstance),parsleyInstance}},$.fn.parsley=$.fn.psly=function(a){return new n(this,a)},a.ParsleyUI="function"==typeof c.get(a.ParsleyConfig,"ParsleyUI")?(new a.ParsleyConfig.ParsleyUI).listen():(new g).listen(),"undefined"==typeof a.ParsleyExtend&&(a.ParsleyExtend={}),"undefined"==typeof a.ParsleyConfig&&(a.ParsleyConfig={}),a.Parsley=a.psly=n,a.ParsleyUtils=c,a.ParsleyValidator=new f(a.ParsleyConfig.validators,a.ParsleyConfig.i18n),!1!==c.get(a,"ParsleyConfig.autoBind")&&$(document).ready(function(){$("[data-parsley-validate]").each(function(){new n(this)})})}(window); | ||
!function(a){var b={attr:function(a,b,c){var d,e={},f=new RegExp("^"+b,"i");if("undefined"==typeof a||"undefined"==typeof a[0])return{};for(var g in a[0].attributes)if(d=a[0].attributes[g],"undefined"!=typeof d&&null!==d&&d.specified&&f.test(d.name)){if("undefined"!=typeof c&&new RegExp(c,"i").test(d.name))return!0;e[this.camelize(d.name.replace(b,""))]=this.deserializeValue(d.value)}return"undefined"==typeof c?e:!1},setAttr:function(a,b,c,d){a[0].setAttribute(this.dasherize(b+c),String(d))},get:function(a,b,c){for(var d=0,e=(b||"").split(".");this.isObject(a)||this.isArray(a);)if(a=a[e[d++]],d===e.length)return a||c;return c},hash:function(a){return String(Math.random()).substring(2,a?a+2:9)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},isObject:function(a){return a===Object(a)},deserializeValue:function(b){var c;try{return b?"true"==b||("false"==b?!1:"null"==b?null:isNaN(c=Number(b))?/^[\[\{]/.test(b)?a.parseJSON(b):b:c):b}catch(d){return b}},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},dasherize:function(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}},c={namespace:"data-parsley-",inputs:"input, textarea, select",excluded:"input[type=button], input[type=submit], input[type=reset]",priorityEnabled:!0,uiEnabled:!0,validationThreshold:3,focus:"first",trigger:!1,errorClass:"parsley-error",successClass:"parsley-success",classHandler:function(){},errorsContainer:function(){},errorsWrapper:'<ul class="parsley-errors-list"></ul>',errorTemplate:"<li></li>"},d=function(){};d.prototype={actualizeOptions:function(){return this.options=this.parsleyInstance.OptionsFactory.get(this),this},validateThroughValidator:function(){return window.ParsleyValidator.validate.apply(window.ParsleyValidator,arguments)},subscribe:function(b,c){return a.listenTo(this,b.toLowerCase(),c),this},unsubscribe:function(b){return a.unsubscribeTo(this,b.toLowerCase()),this},reset:function(){if("ParsleyField"===this.__class__)return a.emit("parsley:field:reset",this);for(var b=0;b<this.fields.length;b++)a.emit("parsley:field:reset",this.fields[b]);a.emit("parsley:form:reset",this)},destroy:function(){if("ParsleyField"===this.__class__)return a.emit("parsley:field:destroy",this),void this.$element.removeData("Parsley");for(var b=0;b<this.fields.length;b++)this.fields[b].destroy();a.emit("parsley:form:destroy",this),this.$element.removeData("Parsley")}},function(a){var b=function(a){return this.__class__="Validator",this.__version__="0.5.5",this.options=a||{},this.bindingKey=this.options.bindingKey||"_validatorjsConstraint",this};b.prototype={constructor:b,validate:function(a,b,c){if("string"!=typeof a&&"object"!=typeof a)throw new Error("You must validate an object or a string");return"string"==typeof a||g(a)?this._validateString(a,b,c):this.isBinded(a)?this._validateBindedObject(a,b):this._validateObject(a,b,c)},bind:function(a,b){if("object"!=typeof a)throw new Error("Must bind a Constraint to an object");return a[this.bindingKey]=new c(b),this},unbind:function(a){return"undefined"==typeof a._validatorjsConstraint?this:(delete a[this.bindingKey],this)},isBinded:function(a){return"undefined"!=typeof a[this.bindingKey]},getBinded:function(a){return this.isBinded(a)?a[this.bindingKey]:null},_validateString:function(a,b,c){var f,h=[];g(b)||(b=[b]);for(var i=0;i<b.length;i++){if(!(b[i]instanceof e))throw new Error("You must give an Assert or an Asserts array to validate a string");f=b[i].check(a,c),f instanceof d&&h.push(f)}return h.length?h:!0},_validateObject:function(a,b,d){if("object"!=typeof b)throw new Error("You must give a constraint to validate an object");return b instanceof c?b.check(a,d):new c(b).check(a,d)},_validateBindedObject:function(a,b){return a[this.bindingKey].check(a,b)}},b.errorCode={must_be_a_string:"must_be_a_string",must_be_an_array:"must_be_an_array",must_be_a_number:"must_be_a_number",must_be_a_string_or_array:"must_be_a_string_or_array"};var c=function(a,b){if(this.__class__="Constraint",this.options=b||{},this.nodes={},a)try{this._bootstrap(a)}catch(c){throw new Error("Should give a valid mapping object to Constraint",c,a)}return this};c.prototype={constructor:c,check:function(a,b){var c,d={};for(var h in this.options.strict?this.nodes:a)if(this.options.strict?this.has(h,a):this.has(h))c=this._check(h,a[h],b),(g(c)&&c.length>0||!g(c)&&!f(c))&&(d[h]=c);else if(this.options.strict)try{(new e).HaveProperty(h).validate(a)}catch(i){d[h]=i}return f(d)?!0:d},add:function(a,b){if(b instanceof e||g(b)&&b[0]instanceof e)return this.nodes[a]=b,this;if("object"==typeof b&&!g(b))return this.nodes[a]=b instanceof c?b:new c(b),this;throw new Error("Should give an Assert, an Asserts array, a Constraint",b)},has:function(a,b){var b="undefined"!=typeof b?b:this.nodes;return"undefined"!=typeof b[a]},get:function(a,b){return this.has(a)?this.nodes[a]:b||null},remove:function(a){var b=[];for(var c in this.nodes)c!==a&&(b[c]=this.nodes[c]);return this.nodes=b,this},_bootstrap:function(a){if(a instanceof c)return this.nodes=a.nodes;for(var b in a)this.add(b,a[b])},_check:function(a,b,d){if(this.nodes[a]instanceof e)return this._checkAsserts(b,[this.nodes[a]],d);if(g(this.nodes[a]))return this._checkAsserts(b,this.nodes[a],d);if(this.nodes[a]instanceof c)return this.nodes[a].check(b,d);throw new Error("Invalid node",this.nodes[a])},_checkAsserts:function(a,b,c){for(var d,e=[],f=0;f<b.length;f++)d=b[f].check(a,c),"undefined"!=typeof d&&!0!==d&&e.push(d);return e}};var d=function(a,b,c){if(this.__class__="Violation",!(a instanceof e))throw new Error("Should give an assertion implementing the Assert interface");this.assert=a,this.value=b,"undefined"!=typeof c&&(this.violation=c)};d.prototype={show:function(){var a={assert:this.assert.__class__,value:this.value};return this.violation&&(a.violation=this.violation),a},__toString:function(){if("undefined"!=typeof this.violation)var a='", '+this.getViolation().constraint+" expected was "+this.getViolation().expected;return this.assert.__class__+' assert failed for "'+this.value+a||""},getViolation:function(){var a,b;for(a in this.violation)b=this.violation[a];return{constraint:a,expected:b}}};var e=function(a){return this.__class__="Assert",this.__parentClass__=this.__class__,this.groups=[],"undefined"!=typeof a&&this.addGroup(a),this};e.prototype={construct:e,check:function(a,b){if(!(b&&!this.hasGroup(b)||!b&&this.hasGroups()))try{return this.validate(a,b)}catch(c){return c}},hasGroup:function(a){return g(a)?this.hasOneOf(a):"Any"===a?!0:this.hasGroups()?-1!==this.groups.indexOf(a):"Default"===a},hasOneOf:function(a){for(var b=0;b<a.length;b++)if(this.hasGroup(a[b]))return!0;return!1},hasGroups:function(){return this.groups.length>0},addGroup:function(a){return g(a)?this.addGroups(a):(this.hasGroup(a)||this.groups.push(a),this)},removeGroup:function(a){for(var b=[],c=0;c<this.groups.length;c++)a!==this.groups[c]&&b.push(this.groups[c]);return this.groups=b,this},addGroups:function(a){for(var b=0;b<a.length;b++)this.addGroup(a[b]);return this},HaveProperty:function(a){return this.__class__="HaveProperty",this.node=a,this.validate=function(a){if("undefined"==typeof a[this.node])throw new d(this,a,{value:this.node});return!0},this},Blank:function(){return this.__class__="Blank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""!==a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Callback:function(a){if(this.__class__="Callback",this.arguments=Array.prototype.slice.call(arguments),1===this.arguments.length?this.arguments=[]:this.arguments.splice(0,1),"function"!=typeof a)throw new Error("Callback must be instanciated with a function");return this.fn=a,this.validate=function(a){var b=[a].concat(this.arguments),c=this.fn.apply(this,b);if(!0!==c)throw new d(this,a,{result:c});return!0},this},Choice:function(a){if(this.__class__="Choice",!g(a)&&"function"!=typeof a)throw new Error("Choice must be instanciated with an array or a function");return this.list=a,this.validate=function(a){for(var b="function"==typeof this.list?this.list():this.list,c=0;c<b.length;c++)if(a===b[c])return!0;throw new d(this,a,{choices:b})},this},Collection:function(a){return this.__class__="Collection",this.constraint="undefined"!=typeof a?new c(a):!1,this.validate=function(a,c){var e,h=new b,i=0,j={},k=this.groups.length?this.groups:c;if(!g(a))throw new d(this,array,{value:b.errorCode.must_be_an_array});for(var l=0;l<a.length;l++)e=this.constraint?h.validate(a[l],this.constraint,k):h.validate(a[l],k),f(e)||(j[i]=e),i++;return f(j)?!0:j},this},Count:function(a){return this.__class__="Count",this.count=a,this.validate=function(a){if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});var c="function"==typeof this.count?this.count(a):this.count;if(isNaN(Number(c)))throw new Error("Count must be a valid interger",c);if(c!==a.length)throw new d(this,a,{count:c});return!0},this},Email:function(){return this.__class__="Email",this.validate=function(a){var c=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Eql:function(a){if(this.__class__="Eql","undefined"==typeof a)throw new Error("Equal must be instanciated with an Array or an Object");return this.eql=a,this.validate=function(a){var b="function"==typeof this.eql?this.eql(a):this.eql;if(!h.eql(b,a))throw new d(this,a,{eql:b});return!0},this},EqualTo:function(a){if(this.__class__="EqualTo","undefined"==typeof a)throw new Error("EqualTo must be instanciated with a value or a function");return this.reference=a,this.validate=function(a){var b="function"==typeof this.reference?this.reference(a):this.reference;if(b!==a)throw new d(this,a,{value:b});return!0},this},GreaterThan:function(a){if(this.__class__="GreaterThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>=a)throw new d(this,a,{threshold:this.threshold});return!0},this},GreaterThanOrEqual:function(a){if(this.__class__="GreaterThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>a)throw new d(this,a,{threshold:this.threshold});return!0},this},InstanceOf:function(a){if(this.__class__="InstanceOf","undefined"==typeof a)throw new Error("InstanceOf must be instanciated with a value");return this.classRef=a,this.validate=function(a){if(!0!=a instanceof this.classRef)throw new d(this,a,{classRef:this.classRef});return!0},this},IPv4:function(){return this.__class__="IPv4",this.validate=function(a){var c=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Length:function(a){if(this.__class__="Length",!a.min&&!a.max)throw new Error("Lenth assert must be instanciated with a { min: x, max: y } object");return this.min=a.min,this.max=a.max,this.validate=function(a){if("string"!=typeof a&&!g(a))throw new d(this,a,{value:b.errorCode.must_be_a_string_or_array});if("undefined"!=typeof this.min&&this.min===this.max&&a.length!==this.min)throw new d(this,a,{min:this.min,max:this.max});if("undefined"!=typeof this.max&&a.length>this.max)throw new d(this,a,{max:this.max});if("undefined"!=typeof this.min&&a.length<this.min)throw new d(this,a,{min:this.min});return!0},this},LessThan:function(a){if(this.__class__="LessThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<=a)throw new d(this,a,{threshold:this.threshold});return!0},this},LessThanOrEqual:function(a){if(this.__class__="LessThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<a)throw new d(this,a,{threshold:this.threshold});return!0},this},Mac:function(){return this.__class__="Mac",this.validate=function(a){var c=/^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},NotNull:function(){return this.__class__="NotNull",this.validate=function(a){if(null===a||"undefined"==typeof a)throw new d(this,a);return!0},this},NotBlank:function(){return this.__class__="NotBlank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""===a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Null:function(){return this.__class__="Null",this.validate=function(a){if(null!==a)throw new d(this,a);return!0},this},Range:function(a,b){if(this.__class__="Range",!a||!b)throw new Error("Range assert expects min and max values");return this.min=a,this.max=b,this.validate=function(a){try{return"string"==typeof a&&isNaN(Number(a))||g(a)?(new e).Length({min:this.min,max:this.max}).validate(a):(new e).GreaterThanOrEqual(this.min).validate(a)&&(new e).LessThanOrEqual(this.max).validate(a),!0}catch(b){throw new d(this,a,b.violation)}return!0},this},Regexp:function(a,c){if(this.__class__="Regexp","undefined"==typeof a)throw new Error("You must give a regexp");return this.regexp=a,this.flag=c||"",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!new RegExp(this.regexp).test(a,this.flag))throw new d(this,a,{regexp:this.regexp,flag:this.flag});return!0},this},Required:function(){return this.__class__="Required",this.validate=function(a){if("undefined"==typeof a)throw new d(this,a);if("string"==typeof a)try{(new e).NotNull().validate(a)&&(new e).NotBlank().validate(a)}catch(b){throw new d(this,a)}return!0},this},Unique:function(a){return this.__class__="Unique","object"==typeof a&&(this.key=a.key),this.validate=function(a){var c,e=[];if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});for(var f=0;f<a.length;f++)if(c="object"==typeof a[f]?a[f][this.key]:a[f],"undefined"!=typeof c){if(-1!==e.indexOf(c))throw new d(this,a,{value:c});e.push(c)}return!0},this}},a.Assert=e,a.Validator=b,a.Violation=d,a.Constraint=c,Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&1/0!=d&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var f=function(a){for(var b in a)return!1;return!0},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={eql:function(a,b){if(a===b)return!0;if("undefined"!=typeof Buffer&&Buffer.isBuffer(a)&&Buffer.isBuffer(b)){if(a.length!==b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}return a instanceof Date&&b instanceof Date?a.getTime()===b.getTime():"object"!=typeof a&&"object"!=typeof b?a==b:this.objEquiv(a,b)},isUndefinedOrNull:function(a){return null===a||"undefined"==typeof a},isArguments:function(a){return"[object Arguments]"==Object.prototype.toString.call(a)},keys:function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b},objEquiv:function(a,b){if(this.isUndefinedOrNull(a)||this.isUndefinedOrNull(b))return!1;if(a.prototype!==b.prototype)return!1;if(this.isArguments(a))return this.isArguments(b)?eql(pSlice.call(a),pSlice.call(b)):!1;try{var c,d,e=this.keys(a),f=this.keys(b)}catch(g){return!1}if(e.length!==f.length)return!1;for(e.sort(),f.sort(),d=e.length-1;d>=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!this.eql(a[c],b[c]))return!1;return!0}};"function"==typeof define&&define.amd&&define("validator",[],function(){return a})}("undefined"==typeof exports?this["undefined"!=typeof validatorjs_ns?validatorjs_ns:"Validator"]={}:exports);var e=function(a,b){this.__class__="ParsleyValidator",this.Validator=Validator,this.locale="en",this.init(a||{},b||{})};e.prototype={init:function(b,c){this.catalog=c;for(var d in b)this.addValidator(d,b[d].fn,b[d].priority);a.emit("parsley:validator:init")},setLocale:function(a){if("undefined"==typeof this.catalog[a])throw new Error(a+" is not available in the catalog");return this.locale=a,this},addCatalog:function(a,b,c){return"object"==typeof b&&(this.catalog[a]=b),!0===c?this.setLocale(a):this},addMessage:function(a,b,c){void 0===typeof this.catalog[a]&&(this.catalog[a]={}),this.catalog[a][b]=c},validate:function(){return(new this.Validator.Validator).validate.apply(new Validator.Validator,arguments)},addValidator:function(b,c,d){return this.validators[b]=function(b){return a.extend((new Validator.Assert).Callback(c,b),{priority:d})},this},updateValidator:function(a,b,c){return addValidator(a,b,c)},removeValidator:function(a){return delete this.validators[a],this},getErrorMessage:function(a){var b;return b="type"===a.name?window.ParsleyConfig.i18n[this.locale][a.name][a.requirements]:this.formatMesssage(window.ParsleyConfig.i18n[this.locale][a.name],a.requirements),""!==b?b:window.ParsleyConfig.i18n[this.locale].defaultMessage},formatMesssage:function(a,b){if("object"==typeof b){for(var c in b)a=this.formatMesssage(a,b[c]);return a}return"string"==typeof a?a.replace(new RegExp("%s","i"),b):""},validators:{notblank:function(){return a.extend((new Validator.Assert).NotBlank(),{priority:2})},required:function(){return a.extend((new Validator.Assert).Required(),{priority:512})},type:function(b){var c;switch(b){case"email":c=(new Validator.Assert).Email();break;case"number":c=(new Validator.Assert).Regexp("^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$");break;case"integer":c=(new Validator.Assert).Regexp("^-?\\d+$");break;case"digits":c=(new Validator.Assert).Regexp("^\\d+$");break;case"alphanum":c=(new Validator.Assert).Regexp("^\\w+$","i");break;case"url":c=(new Validator.Assert).Regexp("(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)","i");break;default:throw new Error("validator type `"+b+"` is not supported")}return a.extend(c,{priority:256})},pattern:function(b){return a.extend((new Validator.Assert).Regexp(b),{priority:64})},minlength:function(b){return a.extend((new Validator.Assert).Length({min:b}),{priority:30})},maxlength:function(b){return a.extend((new Validator.Assert).Length({max:b}),{priority:30})},length:function(b){return a.extend((new Validator.Assert).Length({min:b[0],max:b[1]}),{priority:32})},mincheck:function(a){return this.minlength(a)},maxcheck:function(a){return this.maxlength(a)},check:function(a){return this.length(a)},min:function(b){return a.extend((new Validator.Assert).GreaterThanOrEqual(b),{priority:30})},max:function(b){return a.extend((new Validator.Assert).LessThanOrEqual(b),{priority:30})},range:function(b){return a.extend((new Validator.Assert).Range(b[0],b[1]),{priority:32})},equalto:function(b){return a.extend((new Validator.Assert).Callback(function(b,c){return b===a(c).val()},b),{priority:256})}}};var f=function(){this.__class__="ParsleyUI"};f.prototype={listen:function(){return a.listen("parsley:form:init",this,this.setupForm),a.listen("parsley:field:init",this,this.setupField),a.listen("parsley:field:validated",this,this.reflow),a.listen("parsley:form:validated",this,this.focus),a.listen("parsley:field:reset",this,this.reset),a.listen("parsley:form:destroy",this,this.destroy),a.listen("parsley:field:destroy",this,this.destroy),this},reflow:function(a){if("undefined"!=typeof a._ui&&!1!==a._ui.active){var b=this._diff(a.validationResult,a._ui.lastValidationResult);a._ui.lastValidationResult=a.validationResult,a._ui.validatedOnce=!0,this.manageStatusClass(a),this.manageErrorsMessages(a,b),this.actualizeTriggers(a),(b.kept.length||b.added.length)&&"undefined"==typeof a._ui.failedOnce&&this.manageFailingFieldTrigger(a)}},manageStatusClass:function(a){!0===a.validationResult?this._successClass(a):a.validationResult.length>0?this._errorClass(a):this._resetClass(a)},manageErrorsMessages:function(b,c){if("undefined"!=typeof b.options.errorMessage)return void(c.added.length||c.kept.length?(0===b._ui.$errorsWrapper.find(".parsley-custom-error-message").length&&b._ui.$errorsWrapper.append(a(b.options.errorTemplate).addClass("parsley-custom-error-message")),b._ui.$errorsWrapper.addClass("filled").find(".parsley-custom-error-message").html(b.options.errorMessage)):b._ui.$errorsWrapper.removeClass("filled").find(".parsley-custom-error-message").remove());for(var d=0;d<c.removed.length;d++)this.removeError(b,c.removed[d].assert.name,!0);for(d=0;d<c.added.length;d++)this.addError(b,c.added[d].assert.name,void 0,c.added[d].assert,!0);for(d=0;d<c.kept.length;d++)this.updateError(b,c.kept[d].assert.name,void 0,c.kept[d].assert,!0)},addError:function(b,c,d,e,f){b._ui.$errorsWrapper.addClass("filled").append(a(b.options.errorTemplate).addClass("parsley-"+c).html(d||this._getErrorMessage(b,e))),!0!==f&&this._errorClass(b)},updateError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").find(".parsley-"+b).html(c||this._getErrorMessage(a,d)),!0!==e&&this._errorClass(a)},removeError:function(a,b,c){a._ui.$errorsWrapper.removeClass("filled").find(".parsley-"+b).remove(),!0!==c&&this.manageStatusClass(a)},focus:function(a){if(!0===a.validationResult||"none"===a.options.focus)return a._focusedField=null;a._focusedField=null;for(var b=0;b<a.fields.length;b++)if(!0!==a.fields[b].validationResult&&a.fields[b].validationResult.length>0&&"undefined"==typeof a.fields[b].options.noFocus){if("first"===a.options.focus)return a._focusedField=a.fields[b].$element,a._focusedField.focus();a._focusedField=a.fields[b].$element}return null===a._focusedField?null:a._focusedField.focus()},_getErrorMessage:function(a,b){var c=b.name+"Message";return"undefined"!=typeof a.options[c]?a.options[c]:window.ParsleyValidator.getErrorMessage(b)},_diff:function(a,b,c){for(var d=[],e=[],f=0;f<a.length;f++){for(var g=!1,h=0;h<b.length;h++)if(a[f].assert.name===b[h].assert.name){g=!0;break}g?e.push(a[f]):d.push(a[f])}return{kept:e,added:d,removed:c?[]:this._diff(b,a,!0).added}},setupForm:function(b){b.$element.on("submit.Parsley",!1,a.proxy(b.onSubmitValidate,b)),!1!==b.options.uiEnabled&&b.$element.attr("novalidate","")},setupField:function(b){var c={active:!1};!1!==b.options.uiEnabled&&(c.active=!0,b.$element.attr(b.options.namespace+"id",b.__id__),c.$errorClassHandler=this._manageClassHandler(b),c.errorsWrapperId="parsley-id-"+("undefined"!=typeof b.options.multiple?"multiple-"+b.options.multiple:b.__id__),c.$errorsWrapper=a(b.options.errorsWrapper).attr("id",c.errorsWrapperId),c.lastValidationResult=[],c.validatedOnce=!1,c.validationInformationVisible=!1,b._ui=c,this._insertErrorWrapper(b),this.actualizeTriggers(b))},_manageClassHandler:function(b){if("string"==typeof b.options.classHandler&&a(b.options.classHandler).length)return a(b.options.classHandler);var c=b.options.classHandler(b);return"undefined"!=typeof c&&c.length?c:"undefined"==typeof b.options.multiple?b.$element:b.$element.parent()},_insertErrorWrapper:function(b){if("string"==typeof b.options.errorsContainer&&a(b.options.errorsContainer).length)return a(b.options.errorsContainer).append(b._ui.$errorsWrapper);var c=b.options.errorsContainer(b);return"undefined"!=typeof c&&c.length?c.append(b._ui.$errorsWrapper):"undefined"==typeof b.options.multiple?b.$element.after(b._ui.$errorsWrapper):b.$element.parent().after(b._ui.$errorsWrapper)},actualizeTriggers:function(b){if(b.$element.off(".Parsley"),!1!==b.options.trigger){var c=b.options.trigger.replace(/^\s+/g,"").replace(/\s+$/g,"");""!==c&&b.$element.on(c.split(" ").join(".Parsley ")+".Parsley",!1,a.proxy("function"==typeof b.eventValidate?b.eventValidate:this.eventValidate,b))}},eventValidate:function(a){new RegExp("key").test(a.type)&&!this._ui.validationInformationVisible&&this.getValue().length<=this.options.validationThreshold||(this._ui.validatedOnce=!0,this.validate())},manageFailingFieldTrigger:function(b){return b._ui.failedOnce=!0,b.options.multiple&&a("["+b.options.namespace+'multiple="'+b.options.multiple+'"]').each(function(){return new RegExp("change","i").test(a(this).parsley().options.trigger||"")?void 0:a(this).parsley().$element.on("change.ParsleyFailedOnce",!1,a.proxy(b.validate,b))}),new RegExp("keyup","i").test(b.options.trigger||"")?void 0:b.$element.on("keyup.ParsleyFailedOnce",!1,a.proxy(b.validate,b))},reset:function(b){b.$element.off(".Parsley"),b.$element.off(".ParsleyFailedOnce"),"ParsleyForm"!==b.__class__&&(b._ui.$errorsWrapper.children().each(function(){a(this).remove()}),this._resetClass(b),b._ui.validatedOnce=!1,b._ui.lastValidationResult=[],b._ui.validationInformationVisible=!1)},destroy:function(a){this.reset(a),"ParsleyForm"!==a.__class__&&(a._ui.$errorsWrapper.remove(),delete a._ui)},_successClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.errorClass).addClass(a.options.successClass)},_errorClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.successClass).addClass(a.options.errorClass)},_resetClass:function(a){a._ui.$errorClassHandler.removeClass(a.options.successClass).removeClass(a.options.errorClass)}};var g=function(c,d,e,f){this.__class__="OptionsFactory",this.__id__=b.hash(4),this.formOptions=null,this.fieldOptions=null,this.staticOptions=a.extend(!0,{},c,d,e,{namespace:f})};g.prototype={get:function(a){if("undefined"==typeof a.__class__)throw new Error("Parsley Instance expected");switch(a.__class__){case"Parsley":return this.staticOptions;case"ParsleyForm":return this.getFormOptions(a);case"ParsleyField":return this.getFieldOptions(a);default:throw new Error("Instance "+a.__class__+" is not supported")}},getFormOptions:function(c){return this.formOptions=b.attr(c.$element,this.staticOptions.namespace),a.extend({},this.staticOptions,this.formOptions)},getFieldOptions:function(c){return this.fieldOptions=b.attr(c.$element,this.staticOptions.namespace),a.extend({},this.staticOptions,this.formOptions,this.fieldOptions)}};var h=function(c,d){if(this.__class__="ParsleyForm",this.__id__=b.hash(4),"Parsley"!==b.get(d,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=d,this.init(a(c))};h.prototype={init:function(a){return this.$element=a,this.validationResult=null,this.options=this.parsleyInstance.OptionsFactory.get(this),this._bindFields()},onSubmitValidate:function(b){return this.validate(void 0,b),!1===this.validationResult&&b instanceof a.Event&&b.preventDefault(),this},validate:function(b,c){this.submitEvent=c,this.validationResult=!0;var d=[];this._refreshFields(),a.emit("parsley:form:validate",this);for(var e=0;e<this.fields.length;e++)b&&b!==this.fields[e].options.group||(d=this.fields[e].validate(),!0!==d&&d.length>0&&this.validationResult&&(this.validationResult=!1));return a.emit("parsley:form:validated",this),this.validationResult},isValid:function(a){this._refreshFields();for(var b=0;b<this.fields.length;b++)if((!a||a===this.fields[b].options.group)&&!1===this.fields[b].isValid())return!1;return!0},_refreshFields:function(){return this.actualizeOptions()._bindFields()},_bindFields:function(){var a=this;return this.fields=[],this.$element.find(this.options.inputs).each(function(){var b=new window.Parsley(this,{},a.parsleyInstance);"ParsleyField"===b.__class__&&a.fields.push(b)}),this}};var i=function(c,d,e,f,g){if("ParsleyField"!==b.get(c,"__class__"))throw new Error("ParsleyField instance expected");if("function"!=typeof window.ParsleyValidator.validators[d]&&"Assert"!==window.ParsleyValidator.validators[d](e).__parentClass__)throw new Error("Valid validator expected");var h=function(a,c){return"undefined"!=typeof a.options[c+"Priority"]?a.options[c+"Priority"]:b.get(window.ParsleyValidator.validators[c](e),"priority",2)};return f=f||h(c,d),a.extend(window.ParsleyValidator.validators[d](e),{name:d,requirements:e,priority:f,groups:[f],isDomConstraint:g||b.attr(c.$element,c.options.namespace,d)})},j=function(c,d){if(this.__class__="ParsleyField",this.__id__=b.hash(4),"Parsley"!==b.get(d,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=d,this.init(a(c),d.options)};j.prototype={init:function(a){if(this.constraints=[],this.$element=a,this.validationResult=[],this.options=this.parsleyInstance.OptionsFactory.get(this),this.$element.is("input[type=radio], input[type=checkbox]")&&"undefined"==typeof this.options.multiple||this.$element.is("select")&&"undefined"!=typeof this.$element.attr("multiple")){if("undefined"==typeof this.$element.attr("name")&&"undefined"==typeof this.$element.attr("id"))return window.console&&window.console.warn&&window.console.warn("To be binded by Parsley, a radio, a checkbox and a multiple select input must have either a name, and id or a multiple option.",this.$element),this.parsleyInstance;this.options.multiple=(this.$element.attr("name")||this.$element.attr("id")).replace(/(:|\.|\[|\]|\$)/g,""),b.setAttr(this.$element,this.options.namespace,"multiple",this.options.multiple)}return this.bindConstraints()},validate:function(){return this.value=this.getValue(),a.emit("parsley:field:validate",this),a.emit("parsley:field:"+(this.isValid(this.value)?"success":"error"),this),a.emit("parsley:field:validated",this),this.validationResult},getConstraintsSortedPriorities:function(){for(var a=[],b=0;b<this.constraints.length;b++)-1===a.indexOf(this.constraints[b].priority)&&a.push(this.constraints[b].priority);return a.sort(function(a,b){return b-a}),a},isValid:function(a){var b=this.getConstraintsSortedPriorities();if(a=a||this.getValue(),this.refreshConstraints(),""===a&&!this.isRequired()&&"undefined"==typeof this.options.validateIfEmpty&&"undefined"==typeof this.options.multiple)return this.validationResult=[];if(!1===this.options.priorityEnabled)return!0===(this.validationResult=this.validateThroughValidator(a,this.constraints,"Any"));for(var c=0;c<b.length;c++)if(!0!==(this.validationResult=this.validateThroughValidator(a,this.constraints,b[c])))return!1;return!0},isRequired:function(){var a=this._constraintIndex("required");return!(-1===a||-1!==a&&!1===this.constraints[a].requirements)},getValue:function(){if("undefined"!=typeof this.options.value)return this.options.value;if("undefined"==typeof this.options.multiple)return this.$element.val();if(this.$element.is("input[type=radio]"))return a("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').val()||""; | ||
if(this.$element.is("input[type=checkbox]")){var b=[];return a("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').each(function(){b.push(a(this).val())}),b.length?b:""}return this.$element.is("select")?null===this.$element.val()?"":this.$element.val():void 0},refreshConstraints:function(){return this.actualizeOptions().bindConstraints()},bindConstraints:function(){for(var a=[],b=0;b<this.constraints.length;b++)!1===this.constraints[b].isDomConstraint&&a.push(this.constraints[b]);this.constraints=a;for(var c in this.options)this.addConstraint(c,this.options[c]);return this.bindHtml5Constraints()},bindHtml5Constraints:function(){(this.$element.hasClass("required")||this.$element.attr("required"))&&this.addConstraint("required",!0,void 0,!0),"string"==typeof this.$element.attr("pattern")&&this.addConstraint("pattern",this.$element.attr("pattern"),void 0,!0),"undefined"!=typeof this.$element.attr("min")&&"undefined"!=typeof this.$element.attr("max")?this.addConstraint("range",[this.$element.attr("min"),this.$element.attr("max")],void 0,!0):"undefined"!=typeof this.$element.attr("min")?this.addConstraint("min",this.$element.attr("min"),void 0,!0):"undefined"!=typeof this.$element.attr("max")&&this.addConstraint("max",this.$element.attr("max"),void 0,!0);var a=this.$element.attr("type");return"undefined"==typeof a?this:"number"===a?this.addConstraint("type","integer",void 0,!0):new RegExp(a,"i").test("email url range")?this.addConstraint("type",a,void 0,!0):void 0},addConstraint:function(a,b,c,d){return a=a.toLowerCase(),"function"==typeof window.ParsleyValidator.validators[a]&&(constraint=new i(this,a,b,c,d),-1!==this._constraintIndex(constraint.name)&&this.removeConstraint(constraint.name),this.constraints.push(constraint)),this},removeConstraint:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name){this.constraints.splice(b,1);break}return this},updateConstraint:function(a,b,c){return this.removeConstraint(a).addConstraint(a,b,c)},_constraintIndex:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name)return b;return-1}};var k=a({}),l={};a.listen=function(a){if("undefined"==typeof l[a]&&(l[a]=[]),"function"==typeof arguments[1])return l[a].push({fn:arguments[1]});if("object"==typeof arguments[1]&&"function"==typeof arguments[2])return l[a].push({fn:arguments[2],ctxt:arguments[1]});throw new Error("Wrong parameters")},a.listenTo=function(a,b,c){if("undefined"==typeof l[b]&&(l[b]=[]),!(a instanceof j||a instanceof h))throw new Error("Must give Parsley instance");if("string"!=typeof b||"function"!=typeof c)throw new Error("Wrong parameters");l[b].push({instance:a,fn:c})},a.unsubscribe=function(a,b){if("undefined"!=typeof l[a]){if("string"!=typeof a||"function"!=typeof b)throw new Error("Wrong arguments");for(var c=0;c<l[a].length;c++)if(l[a][c].fn===b)return l[a].splice(c,1)}},a.unsubscribeTo=function(a,b){if("undefined"!=typeof l[b]){if(!(a instanceof j||a instanceof h))throw new Error("Must give Parsley instance");for(var c=0;c<l[b].length;c++)if("undefined"!=typeof l[b][c].instance&&l[b][c].instance.__id__===a.__id__)return l[b].splice(c,1)}},a.unsubscribeAll=function(a){"undefined"!=typeof l[a]&&delete l[a]},a.emit=function(a,b){if("undefined"!=typeof l[a])for(var c=0;c<l[a].length;c++)if("undefined"!=typeof l[a][c].instance){if(b instanceof j||b instanceof h)if(l[a][c].instance.__id__!==b.__id__){if(l[a][c].instance instanceof h&&b instanceof j)for(var d=0;d<l[a][c].instance.fields.length;d++)if(l[a][c].instance.fields[d].__id__===b.__id__){l[a][c].fn.apply(k,Array.prototype.slice.call(arguments,1));continue}}else l[a][c].fn.apply(k,Array.prototype.slice.call(arguments,1))}else l[a][c].fn.apply("undefined"!=typeof l[a][c].ctxt?l[a][c].ctxt:k,Array.prototype.slice.call(arguments,1))},a.subscribed=function(){return l},window.ParsleyConfig=window.ParsleyConfig||{},window.ParsleyConfig.i18n=window.ParsleyConfig.i18n||{},window.ParsleyConfig.i18n.en=a.extend(window.ParsleyConfig.i18n.en||{},{defaultMessage:"This value seems to be invalid.",type:{email:"This value should be a valid email.",url:"This value should be a valid url.",number:"This value should be a valid number.",integer:"This value should be a valid integer.",digits:"This value should be digits.",alphanum:"This value should be alphanumeric."},notblank:"This value should not be blank.",required:"This value is required.",pattern:"This value seems to be invalid.",min:"This value should be greater than or equal to %s.",max:"This value should be lower than or equal to %s.",range:"This value should be between %s and %s.",minlength:"This value is too short. It should have %s characters or more.",maxlength:"This value is too long. It should have %s characters or less.",length:"This value length is invalid. It should be between %s and %s characters long.",mincheck:"You must select at least %s choices.",maxcheck:"You must select %s choices or less.",check:"You must select between %s and %s choices.",equalto:"This value should be the same."}),"undefined"!=typeof window.ParsleyValidator&&window.ParsleyValidator.addCatalog("en",window.ParsleyConfig.i18n.en,!0);var m=function(c,d,e){if(this.__class__="Parsley",this.__version__="2.0.0-rc2",this.__id__=b.hash(4),"undefined"==typeof c)throw new Error("You must give an element");return this.init(a(c),d,e)};m.prototype={init:function(a,d,e){if(!a.length)throw new Error("You must bind Parsley on an existing element.");return this.$element=a,this.$element.data("Parsley")?this.$element.data("Parsley"):(this.OptionsFactory=new g(c,b.get(window,"ParsleyConfig",{}),d,this.getNamespace(d)),d=this.OptionsFactory.staticOptions,this.$element.is("form")||b.attr(this.$element,d.namespace,"validate")&&!this.$element.is(d.inputs)?this.bind("parsleyForm",e):this.$element.is(d.inputs)&&!this.$element.is(d.excluded)?this.bind("parsleyField",e):this)},getNamespace:function(a){return"undefined"!=typeof this.$element.data("parsleyNamespace")?this.$element.data("parsleyNamespace"):"undefined"!=typeof b.get(a,"namespace")?a.namespace:"undefined"!=typeof b.get(window,"ParsleyConfig.namespace")?window.ParsleyConfig.namespace:c.namespace},bind:function(b,c){switch(b){case"parsleyForm":parsleyInstance=a.extend(new h(this.$element,c||this),new d,window.ParsleyExtend);break;case"parsleyField":parsleyInstance=a.extend(new j(this.$element,c||this),new d,window.ParsleyExtend);break;default:throw new Error(b+"is not a supported Parsley type")}return("ParsleyForm"===parsleyInstance.__class__||"ParsleyField"===parsleyInstance.__class__)&&(this.$element.data("Parsley",parsleyInstance),a.emit("parsley:"+("parsleyForm"===b?"form":"field")+":init",parsleyInstance)),parsleyInstance}},a.fn.parsley=a.fn.psly=function(a){return new m(this,a)},window.ParsleyUI="function"==typeof b.get(window.ParsleyConfig,"ParsleyUI")?(new window.ParsleyConfig.ParsleyUI).listen():(new f).listen(),"undefined"==typeof window.ParsleyExtend&&(window.ParsleyExtend={}),"undefined"==typeof window.ParsleyConfig&&(window.ParsleyConfig={}),window.Parsley=window.psly=m,window.ParsleyUtils=b,window.ParsleyValidator=new e(window.ParsleyConfig.validators,window.ParsleyConfig.i18n),!1!==b.get(window,"ParsleyConfig.autoBind")&&a(document).ready(function(){a("[data-parsley-validate]").each(function(){new m(this)})})}(window.jQuery); |
window.ParsleyExtend=$.extend(window.ParsleyExtend||{},{asyncValidate:function(a,b){return"ParsleyForm"===this.__class__?this._asyncValidateForm(a,b):this._asyncValidateField()},asyncIsValid:function(a){return"ParsleyField"===this.__class__?this._asyncIsValidField():this._asyncIsValidForm(a)},onSubmitValidate:function(a){var b=this;return a instanceof $.Event&&a.preventDefault(),this._asyncValidateForm(void 0,a).done(function(){b.$element.off("submit.Parsley").trigger($.Event("submit"))})},eventValidate:function(a){new RegExp("key").test(a.type)&&!this._ui.validationInformationVisible&&this.getValue().length<=this.options.validationThreshold||(this._ui.validatedOnce=!0,this.asyncValidate())},_asyncValidateForm:function(a,b){var c=this,d=[];this.submitEvent=b,this._refreshFields(),$.emit("parsley:form:validate",this);for(var e=0;e<this.fields.length;e++)a&&a!==this.fields[e].options.group||d.push(this.fields[e]._asyncValidateField());return $.when.apply($,d).always(function(){$.emit("parsley:form:validated",c)})},_asyncIsValidForm:function(a){var b=[];this._refreshFields();for(var c=0;c<this.fields.length;c++)a&&a!==this.fields[c].options.group||b.push(this.fields[c]._asyncIsValidField());return $.when.apply($,b)},_asyncValidateField:function(){var a=this;return $.emit("parsley:field:validate",this),this._asyncIsValidField().done(function(){$.emit("parsley:field:success",a)}).fail(function(){$.emit("parsley:field:error",a)}).always(function(){$.emit("parsley:field:validated",a)})},_asyncIsValidField:function(){var a=$.Deferred();return!1===this.isValid()?a.rejectWith(this):-1!==this._constraintIndex("remote")?this._remote(a):a.resolveWith(this),a.promise()},_remote:function(a){var b,c={},d=this,e=this.getValue(),f=e+this.$element.attr(this.options.namespace+"remote-options");"undefined"!=typeof this._remote&&"undefined"!=typeof this._remote[f]?b=this._remote[f]?a.resolveWith(d):a.rejectWith(d):(c[d.$element.attr("name")||d.$element.attr("id")]=e,b=$.ajax($.extend(!0,{},{url:d.options.remote,data:c,type:"GET"},d.options.remoteOptions||{}))),b.done(function(){d._handleRemoteResult(!0,a,f)}).fail(function(){d._handleRemoteResult(!1,a,f)})},_handleRemoteResult:function(a,b,c){return this._remote[c]=a,"undefined"!=typeof this.options.remoteReverse&&!0===this.options.remoteReverse&&(a=!a),a?void b.resolveWith(this):(this.validationResult=[new window.ParsleyValidator.Validator.Violation(this.constraints[this._constraintIndex("remote")],this.getValue(),null)],void b.rejectWith(this))}}),window.ParsleyConfig=$.extend(window.ParsleyConfig||{},{validators:{remote:{fn:function(){return!0},priority:-1}}}),/*! | ||
* Parsleyjs | ||
* Guillaume Potier - <guillaume@wisembly.com> | ||
* Version 2.0.0-rc1 - built Thu Feb 27 2014 15:19:20 | ||
* Version 2.0.0-rc2 - built Sun Mar 02 2014 16:29:28 | ||
* MIT Licensed | ||
* | ||
*/ | ||
function(a,b){var c={attr:function(a,b,c){var d,e={},f=new RegExp("^"+b,"i");if("undefined"==typeof a||"undefined"==typeof a[0])return{};for(var g in a[0].attributes)if(d=a[0].attributes[g],"undefined"!=typeof d&&null!==d&&d.specified&&f.test(d.name)){if("undefined"!=typeof c&&new RegExp(c,"i").test(d.name))return!0;e[this.camelize(d.name.replace(b,""))]=this.deserializeValue(d.value)}return"undefined"==typeof c?e:!1},setAttr:function(a,b,c,d){a[0].setAttribute(this.dasherize(b+c),String(d))},get:function(a,b,c){for(var d=0,e=(b||"").split(".");this.isObject(a)||this.isArray(a);)if(a=a[e[d++]],d===e.length)return a||c;return c},hash:function(a){return String(Math.random()).substring(2,a?a+2:9)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},isObject:function(a){return a===Object(a)},deserializeValue:function(a){var b;try{return a?"true"==a||("false"==a?!1:"null"==a?null:isNaN(b=Number(a))?/^[\[\{]/.test(a)?$.parseJSON(a):a:b):a}catch(c){return a}},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},dasherize:function(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}},d={namespace:"data-parsley-",inputs:"input, textarea, select",excluded:"input[type=button], input[type=submit], input[type=reset]",priorityEnabled:!0,uiEnabled:!0,validationThreshold:3,focus:"first",trigger:!1,errorClass:"parsley-error",successClass:"parsley-success",classHandler:function(){},errorsContainer:function(){},errorsWrapper:'<ul class="parsley-errors-list"></ul>',errorTemplate:"<li></li>"},e=function(){};e.prototype={actualizeOptions:function(){return this.options=this.parsleyInstance.OptionsFactory.get(this),this},validateThroughValidator:function(){return a.ParsleyValidator.validate.apply(a.ParsleyValidator,arguments)},subscribe:function(a,b){return $.listenTo(this,a.toLowerCase(),b),this},unsubscribe:function(a){return $.unsubscribeTo(this,a.toLowerCase()),this},reset:function(){if("ParsleyField"===this.__class__)return $.emit("parsley:field:reset",this);for(var a=0;a<this.fields.length;a++)$.emit("parsley:field:reset",this.fields[a]);$.emit("parsley:form:reset",this)},destroy:function(){if("ParsleyField"===this.__class__)return $.emit("parsley:field:destroy",this),void this.$element.removeData("Parsley");for(var a=0;a<this.fields.length;a++)this.fields[a].destroy();$.emit("parsley:form:destroy",this),this.$element.removeData("Parsley")}},function(a){var b=function(a){return this.__class__="Validator",this.__version__="0.5.5",this.options=a||{},this.bindingKey=this.options.bindingKey||"_validatorjsConstraint",this};b.prototype={constructor:b,validate:function(a,b,c){if("string"!=typeof a&&"object"!=typeof a)throw new Error("You must validate an object or a string");return"string"==typeof a||g(a)?this._validateString(a,b,c):this.isBinded(a)?this._validateBindedObject(a,b):this._validateObject(a,b,c)},bind:function(a,b){if("object"!=typeof a)throw new Error("Must bind a Constraint to an object");return a[this.bindingKey]=new c(b),this},unbind:function(a){return"undefined"==typeof a._validatorjsConstraint?this:(delete a[this.bindingKey],this)},isBinded:function(a){return"undefined"!=typeof a[this.bindingKey]},getBinded:function(a){return this.isBinded(a)?a[this.bindingKey]:null},_validateString:function(a,b,c){var f,h=[];g(b)||(b=[b]);for(var i=0;i<b.length;i++){if(!(b[i]instanceof e))throw new Error("You must give an Assert or an Asserts array to validate a string");f=b[i].check(a,c),f instanceof d&&h.push(f)}return h.length?h:!0},_validateObject:function(a,b,d){if("object"!=typeof b)throw new Error("You must give a constraint to validate an object");return b instanceof c?b.check(a,d):new c(b).check(a,d)},_validateBindedObject:function(a,b){return a[this.bindingKey].check(a,b)}},b.errorCode={must_be_a_string:"must_be_a_string",must_be_an_array:"must_be_an_array",must_be_a_number:"must_be_a_number",must_be_a_string_or_array:"must_be_a_string_or_array"};var c=function(a,b){if(this.__class__="Constraint",this.options=b||{},this.nodes={},a)try{this._bootstrap(a)}catch(c){throw new Error("Should give a valid mapping object to Constraint",c,a)}return this};c.prototype={constructor:c,check:function(a,b){var c,d={};for(var h in this.options.strict?this.nodes:a)if(this.options.strict?this.has(h,a):this.has(h))c=this._check(h,a[h],b),(g(c)&&c.length>0||!g(c)&&!f(c))&&(d[h]=c);else if(this.options.strict)try{(new e).HaveProperty(h).validate(a)}catch(i){d[h]=i}return f(d)?!0:d},add:function(a,b){if(b instanceof e||g(b)&&b[0]instanceof e)return this.nodes[a]=b,this;if("object"==typeof b&&!g(b))return this.nodes[a]=b instanceof c?b:new c(b),this;throw new Error("Should give an Assert, an Asserts array, a Constraint",b)},has:function(a,b){var b="undefined"!=typeof b?b:this.nodes;return"undefined"!=typeof b[a]},get:function(a,b){return this.has(a)?this.nodes[a]:b||null},remove:function(a){var b=[];for(var c in this.nodes)c!==a&&(b[c]=this.nodes[c]);return this.nodes=b,this},_bootstrap:function(a){if(a instanceof c)return this.nodes=a.nodes;for(var b in a)this.add(b,a[b])},_check:function(a,b,d){if(this.nodes[a]instanceof e)return this._checkAsserts(b,[this.nodes[a]],d);if(g(this.nodes[a]))return this._checkAsserts(b,this.nodes[a],d);if(this.nodes[a]instanceof c)return this.nodes[a].check(b,d);throw new Error("Invalid node",this.nodes[a])},_checkAsserts:function(a,b,c){for(var d,e=[],f=0;f<b.length;f++)d=b[f].check(a,c),"undefined"!=typeof d&&!0!==d&&e.push(d);return e}};var d=function(a,b,c){if(this.__class__="Violation",!(a instanceof e))throw new Error("Should give an assertion implementing the Assert interface");this.assert=a,this.value=b,"undefined"!=typeof c&&(this.violation=c)};d.prototype={show:function(){var a={assert:this.assert.__class__,value:this.value};return this.violation&&(a.violation=this.violation),a},__toString:function(){if("undefined"!=typeof this.violation)var a='", '+this.getViolation().constraint+" expected was "+this.getViolation().expected;return this.assert.__class__+' assert failed for "'+this.value+a||""},getViolation:function(){var a,b;for(a in this.violation)b=this.violation[a];return{constraint:a,expected:b}}};var e=function(a){return this.__class__="Assert",this.__parentClass__=this.__class__,this.groups=[],"undefined"!=typeof a&&this.addGroup(a),this};e.prototype={construct:e,check:function(a,b){if(!(b&&!this.hasGroup(b)||!b&&this.hasGroups()))try{return this.validate(a,b)}catch(c){return c}},hasGroup:function(a){return g(a)?this.hasOneOf(a):"Any"===a?!0:this.hasGroups()?-1!==this.groups.indexOf(a):"Default"===a},hasOneOf:function(a){for(var b=0;b<a.length;b++)if(this.hasGroup(a[b]))return!0;return!1},hasGroups:function(){return this.groups.length>0},addGroup:function(a){return g(a)?this.addGroups(a):(this.hasGroup(a)||this.groups.push(a),this)},removeGroup:function(a){for(var b=[],c=0;c<this.groups.length;c++)a!==this.groups[c]&&b.push(this.groups[c]);return this.groups=b,this},addGroups:function(a){for(var b=0;b<a.length;b++)this.addGroup(a[b]);return this},HaveProperty:function(a){return this.__class__="HaveProperty",this.node=a,this.validate=function(a){if("undefined"==typeof a[this.node])throw new d(this,a,{value:this.node});return!0},this},Blank:function(){return this.__class__="Blank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""!==a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Callback:function(a){if(this.__class__="Callback",this.arguments=Array.prototype.slice.call(arguments),1===this.arguments.length?this.arguments=[]:this.arguments.splice(0,1),"function"!=typeof a)throw new Error("Callback must be instanciated with a function");return this.fn=a,this.validate=function(a){var b=[a].concat(this.arguments),c=this.fn.apply(this,b);if(!0!==c)throw new d(this,a,{result:c});return!0},this},Choice:function(a){if(this.__class__="Choice",!g(a)&&"function"!=typeof a)throw new Error("Choice must be instanciated with an array or a function");return this.list=a,this.validate=function(a){for(var b="function"==typeof this.list?this.list():this.list,c=0;c<b.length;c++)if(a===b[c])return!0;throw new d(this,a,{choices:b})},this},Collection:function(a){return this.__class__="Collection",this.constraint="undefined"!=typeof a?new c(a):!1,this.validate=function(a,c){var e,h=new b,i=0,j={},k=this.groups.length?this.groups:c;if(!g(a))throw new d(this,array,{value:b.errorCode.must_be_an_array});for(var l=0;l<a.length;l++)e=this.constraint?h.validate(a[l],this.constraint,k):h.validate(a[l],k),f(e)||(j[i]=e),i++;return f(j)?!0:j},this},Count:function(a){return this.__class__="Count",this.count=a,this.validate=function(a){if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});var c="function"==typeof this.count?this.count(a):this.count;if(isNaN(Number(c)))throw new Error("Count must be a valid interger",c);if(c!==a.length)throw new d(this,a,{count:c});return!0},this},Email:function(){return this.__class__="Email",this.validate=function(a){var c=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Eql:function(a){if(this.__class__="Eql","undefined"==typeof a)throw new Error("Equal must be instanciated with an Array or an Object");return this.eql=a,this.validate=function(a){var b="function"==typeof this.eql?this.eql(a):this.eql;if(!h.eql(b,a))throw new d(this,a,{eql:b});return!0},this},EqualTo:function(a){if(this.__class__="EqualTo","undefined"==typeof a)throw new Error("EqualTo must be instanciated with a value or a function");return this.reference=a,this.validate=function(a){var b="function"==typeof this.reference?this.reference(a):this.reference;if(b!==a)throw new d(this,a,{value:b});return!0},this},GreaterThan:function(a){if(this.__class__="GreaterThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>=a)throw new d(this,a,{threshold:this.threshold});return!0},this},GreaterThanOrEqual:function(a){if(this.__class__="GreaterThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>a)throw new d(this,a,{threshold:this.threshold});return!0},this},InstanceOf:function(a){if(this.__class__="InstanceOf","undefined"==typeof a)throw new Error("InstanceOf must be instanciated with a value");return this.classRef=a,this.validate=function(a){if(!0!=a instanceof this.classRef)throw new d(this,a,{classRef:this.classRef});return!0},this},IPv4:function(){return this.__class__="IPv4",this.validate=function(a){var c=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Length:function(a){if(this.__class__="Length",!a.min&&!a.max)throw new Error("Lenth assert must be instanciated with a { min: x, max: y } object");return this.min=a.min,this.max=a.max,this.validate=function(a){if("string"!=typeof a&&!g(a))throw new d(this,a,{value:b.errorCode.must_be_a_string_or_array});if("undefined"!=typeof this.min&&this.min===this.max&&a.length!==this.min)throw new d(this,a,{min:this.min,max:this.max});if("undefined"!=typeof this.max&&a.length>this.max)throw new d(this,a,{max:this.max});if("undefined"!=typeof this.min&&a.length<this.min)throw new d(this,a,{min:this.min});return!0},this},LessThan:function(a){if(this.__class__="LessThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<=a)throw new d(this,a,{threshold:this.threshold});return!0},this},LessThanOrEqual:function(a){if(this.__class__="LessThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<a)throw new d(this,a,{threshold:this.threshold});return!0},this},Mac:function(){return this.__class__="Mac",this.validate=function(a){var c=/^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},NotNull:function(){return this.__class__="NotNull",this.validate=function(a){if(null===a||"undefined"==typeof a)throw new d(this,a);return!0},this},NotBlank:function(){return this.__class__="NotBlank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""===a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Null:function(){return this.__class__="Null",this.validate=function(a){if(null!==a)throw new d(this,a);return!0},this},Range:function(a,b){if(this.__class__="Range",!a||!b)throw new Error("Range assert expects min and max values");return this.min=a,this.max=b,this.validate=function(a){try{return"string"==typeof a&&isNaN(Number(a))||g(a)?(new e).Length({min:this.min,max:this.max}).validate(a):(new e).GreaterThanOrEqual(this.min).validate(a)&&(new e).LessThanOrEqual(this.max).validate(a),!0}catch(b){throw new d(this,a,b.violation)}return!0},this},Regexp:function(a,c){if(this.__class__="Regexp","undefined"==typeof a)throw new Error("You must give a regexp");return this.regexp=a,this.flag=c||"",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!new RegExp(this.regexp).test(a,this.flag))throw new d(this,a,{regexp:this.regexp,flag:this.flag});return!0},this},Required:function(){return this.__class__="Required",this.validate=function(a){if("undefined"==typeof a)throw new d(this,a);if("string"==typeof a)try{(new e).NotNull().validate(a)&&(new e).NotBlank().validate(a)}catch(b){throw new d(this,a)}return!0},this},Unique:function(a){return this.__class__="Unique","object"==typeof a&&(this.key=a.key),this.validate=function(a){var c,e=[];if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});for(var f=0;f<a.length;f++)if(c="object"==typeof a[f]?a[f][this.key]:a[f],"undefined"!=typeof c){if(-1!==e.indexOf(c))throw new d(this,a,{value:c});e.push(c)}return!0},this}},a.Assert=e,a.Validator=b,a.Violation=d,a.Constraint=c,Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&1/0!=d&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var f=function(a){for(var b in a)return!1;return!0},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={eql:function(a,b){if(a===b)return!0;if("undefined"!=typeof Buffer&&Buffer.isBuffer(a)&&Buffer.isBuffer(b)){if(a.length!==b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}return a instanceof Date&&b instanceof Date?a.getTime()===b.getTime():"object"!=typeof a&&"object"!=typeof b?a==b:this.objEquiv(a,b)},isUndefinedOrNull:function(a){return null===a||"undefined"==typeof a},isArguments:function(a){return"[object Arguments]"==Object.prototype.toString.call(a)},keys:function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b},objEquiv:function(a,b){if(this.isUndefinedOrNull(a)||this.isUndefinedOrNull(b))return!1;if(a.prototype!==b.prototype)return!1;if(this.isArguments(a))return this.isArguments(b)?eql(pSlice.call(a),pSlice.call(b)):!1;try{var c,d,e=this.keys(a),f=this.keys(b)}catch(g){return!1}if(e.length!==f.length)return!1;for(e.sort(),f.sort(),d=e.length-1;d>=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!this.eql(a[c],b[c]))return!1;return!0}};"function"==typeof define&&define.amd&&define("validator",[],function(){return a})}("undefined"==typeof exports?this["undefined"!=typeof validatorjs_ns?validatorjs_ns:"Validator"]={}:exports);var f=function(a,b){this.__class__="ParsleyValidator",this.Validator=Validator,this.locale="en",this.init(a||{},b||{})};f.prototype={init:function(a,b){this.catalog=b;for(var c in a)this.addValidator(c,a[c].fn,a[c].priority);$.emit("parsley:validator:init")},setLocale:function(a){if("undefined"==typeof this.catalog[a])throw new Error(a+" is not available in the catalog");return this.locale=a,this},addCatalog:function(a,b,c){return"object"==typeof b&&(this.catalog[a]=b),!0===c?this.setLocale(a):this},addMessage:function(a,c,d){b===typeof this.catalog[a]&&(this.catalog[a]={}),this.catalog[a][c]=d},validate:function(){return(new this.Validator.Validator).validate.apply(new Validator.Validator,arguments)},addValidator:function(a,b,c){return this.validators[a]=function(a){return $.extend((new Validator.Assert).Callback(b,a),{priority:c})},this},updateValidator:function(a,b,c){return addValidator(a,b,c)},removeValidator:function(a){return delete this.validators[a],this},getErrorMessage:function(b){var c;return c="type"===b.name?a.ParsleyConfig.i18n[this.locale][b.name][b.requirements]:this.formatMesssage(a.ParsleyConfig.i18n[this.locale][b.name],b.requirements),""!==c?c:a.ParsleyConfig.i18n[this.locale].defaultMessage},formatMesssage:function(a,b){if("object"==typeof b){for(var c in b)a=this.formatMesssage(a,b[c]);return a}return"string"==typeof a?a.replace(new RegExp("%s","i"),b):""},validators:{notblank:function(){return $.extend((new Validator.Assert).NotBlank(),{priority:2})},required:function(){return $.extend((new Validator.Assert).Required(),{priority:512})},type:function(a){var b;switch(a){case"email":b=(new Validator.Assert).Email();break;case"number":b=(new Validator.Assert).Regexp("^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$");break;case"integer":b=(new Validator.Assert).Regexp("^-?\\d+$");break;case"digits":b=(new Validator.Assert).Regexp("^\\d+$");break;case"alphanum":b=(new Validator.Assert).Regexp("^\\w+$","i");break;case"url":b=(new Validator.Assert).Regexp("(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)","i");break;default:throw new Error("validator type `"+a+"` is not supported")}return $.extend(b,{priority:256})},pattern:function(a){return $.extend((new Validator.Assert).Regexp(a),{priority:64})},minlength:function(a){return $.extend((new Validator.Assert).Length({min:a}),{priority:30})},maxlength:function(a){return $.extend((new Validator.Assert).Length({max:a}),{priority:30})},length:function(a){return $.extend((new Validator.Assert).Length({min:a[0],max:a[1]}),{priority:32})},mincheck:function(a){return this.minlength(a)},maxcheck:function(a){return this.maxlength(a)},check:function(a){return this.length(a)},min:function(a){return $.extend((new Validator.Assert).GreaterThanOrEqual(a),{priority:30})},max:function(a){return $.extend((new Validator.Assert).LessThanOrEqual(a),{priority:30})},range:function(a){return $.extend((new Validator.Assert).Range(a[0],a[1]),{priority:32})},equalto:function(a){return $.extend((new Validator.Assert).Callback(function(a,b){return a===$(b).val()},a),{priority:256})}}};var g=function(){this.__class__="ParsleyUI"};g.prototype={listen:function(){return $.listen("parsley:form:init",this,this.setupForm),$.listen("parsley:field:init",this,this.setupField),$.listen("parsley:field:validated",this,this.reflow),$.listen("parsley:form:validated",this,this.focus),$.listen("parsley:field:reset",this,this.reset),$.listen("parsley:form:destroy",this,this.destroy),$.listen("parsley:field:destroy",this,this.destroy),this},reflow:function(a){if("undefined"!=typeof a._ui&&!1!==a._ui.active){var b=this._diff(a.validationResult,a._ui.lastValidationResult);a._ui.lastValidationResult=a.validationResult,a._ui.validatedOnce=!0,this.manageStatusClass(a),this.manageErrorsMessages(a,b),this.actualizeTriggers(a),(b.kept.length||b.added.length)&&"undefined"==typeof a._ui.failedOnce&&this.manageFailingFieldTrigger(a)}},manageStatusClass:function(a){!0===a.validationResult?this._successClass(a):a.validationResult.length>0?this._errorClass(a):this._resetClass(a)},manageErrorsMessages:function(a,c){if("undefined"!=typeof a.options.errorMessage)return void(c.added.length||c.kept.length?(0===a._ui.$errorsWrapper.find(".parsley-custom-error-message").length&&a._ui.$errorsWrapper.append($(a.options.errorTemplate).addClass("parsley-custom-error-message")),a._ui.$errorsWrapper.addClass("filled").find(".parsley-custom-error-message").html(a.options.errorMessage)):a._ui.$errorsWrapper.removeClass("filled").find(".parsley-custom-error-message").remove());for(var d=0;d<c.removed.length;d++)this.removeError(a,c.removed[d].assert.name,!0);for(d=0;d<c.added.length;d++)this.addError(a,c.added[d].assert.name,b,c.added[d].assert,!0);for(d=0;d<c.kept.length;d++)this.updateError(a,c.kept[d].assert.name,b,c.kept[d].assert,!0)},addError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").append($(a.options.errorTemplate).addClass("parsley-"+b).html(c||this._getErrorMessage(a,d))),!0!==e&&this._errorClass(a)},updateError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").find(".parsley-"+b).html(c||this._getErrorMessage(a,d)),!0!==e&&this._errorClass(a)},removeError:function(a,b,c){a._ui.$errorsWrapper.removeClass("filled").find(".parsley-"+b).remove(),!0!==c&&this.manageStatusClass(a)},focus:function(a){if(!0===a.validationResult||"none"===a.options.focus)return a._focusedField=null;a._focusedField=null;for(var b=0;b<a.fields.length;b++)if(!0!==a.fields[b].validationResult&&a.fields[b].validationResult.length>0&&"undefined"==typeof a.fields[b].options.noFocus){if("first"===a.options.focus)return a._focusedField=a.fields[b].$element,a._focusedField.focus();a._focusedField=a.fields[b].$element}return null===a._focusedField?null:a._focusedField.focus()},_getErrorMessage:function(b,c){var d=c.name+"Message";return"undefined"!=typeof b.options[d]?b.options[d]:a.ParsleyValidator.getErrorMessage(c)},_diff:function(a,b,c){for(var d=[],e=[],f=0;f<a.length;f++){for(var g=!1,h=0;h<b.length;h++)if(a[f].assert.name===b[h].assert.name){g=!0;break}g?e.push(a[f]):d.push(a[f])}return{kept:e,added:d,removed:c?[]:this._diff(b,a,!0).added}},setupForm:function(a){a.$element.on("submit.Parsley",!1,$.proxy(a.onSubmitValidate,a)),!1!==a.options.uiEnabled&&a.$element.attr("novalidate","")},setupField:function(a){var b={active:!1};!1!==a.options.uiEnabled&&(b.active=!0,a.$element.attr(a.options.namespace+"id",a.__id__),b.$errorClassHandler=this._manageClassHandler(a),b.errorsWrapperId="parsley-id-"+("undefined"!=typeof a.options.multiple?"multiple-"+a.options.multiple:a.__id__),b.$errorsWrapper=$(a.options.errorsWrapper).attr("id",b.errorsWrapperId),b.lastValidationResult=[],b.validatedOnce=!1,b.validationInformationVisible=!1,a._ui=b,this._insertErrorWrapper(a),this.actualizeTriggers(a))},_manageClassHandler:function(a){if("string"==typeof a.options.classHandler&&$(a.options.classHandler).length)return $(a.options.classHandler);var b=a.options.classHandler(a);return"undefined"!=typeof b&&b.length?b:"undefined"==typeof a.options.multiple?a.$element:a.$element.parent()},_insertErrorWrapper:function(a){if("string"==typeof a.options.errorsContainer&&$(a.options.errorsContainer).length)return $(a.options.errorsContainer).append(a._ui.$errorsWrapper);var b=a.options.errorsContainer(a);return"undefined"!=typeof b&&b.length?b.append(a._ui.$errorsWrapper):"undefined"==typeof a.options.multiple?a.$element.after(a._ui.$errorsWrapper):a.$element.parent().after(a._ui.$errorsWrapper)},actualizeTriggers:function(a){if(a.$element.off(".Parsley"),!1!==a.options.trigger){var b=a.options.trigger.replace(/^\s+/g,"").replace(/\s+$/g,"");""!==b&&a.$element.on(b.split(" ").join(".Parsley ")+".Parsley",!1,$.proxy("function"==typeof a.eventValidate?a.eventValidate:this.eventValidate,a))}},eventValidate:function(a){new RegExp("key").test(a.type)&&!this._ui.validationInformationVisible&&this.getValue().length<=this.options.validationThreshold||(this._ui.validatedOnce=!0,this.validate())},manageFailingFieldTrigger:function(a){return a._ui.failedOnce=!0,a.options.multiple&&$("["+a.options.namespace+'multiple="'+a.options.multiple+'"]').each(function(){return new RegExp("change","i").test($(this).parsley().options.trigger||"")?void 0:$(this).parsley().$element.on("change.ParsleyFailedOnce",!1,$.proxy(a.validate,a))}),new RegExp("keyup","i").test(a.options.trigger||"")?void 0:a.$element.on("keyup.ParsleyFailedOnce",!1,$.proxy(a.validate,a))},reset:function(a){a.$element.off(".Parsley"),a.$element.off(".ParsleyFailedOnce"),"ParsleyForm"!==a.__class__&&(a._ui.$errorsWrapper.children().each(function(){$(this).remove()}),this._resetClass(a),a._ui.validatedOnce=!1,a._ui.lastValidationResult=[],a._ui.validationInformationVisible=!1)},destroy:function(a){this.reset(a),"ParsleyForm"!==a.__class__&&(a._ui.$errorsWrapper.remove(),delete a._ui)},_successClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.errorClass).addClass(a.options.successClass)},_errorClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.successClass).addClass(a.options.errorClass)},_resetClass:function(a){a._ui.$errorClassHandler.removeClass(a.options.successClass).removeClass(a.options.errorClass)}};var h=function(a,b,d,e){this.__class__="OptionsFactory",this.__id__=c.hash(4),this.formOptions=null,this.fieldOptions=null,this.staticOptions=$.extend(!0,{},a,b,d,{namespace:e})};h.prototype={get:function(a){if("undefined"==typeof a.__class__)throw new Error("Parsley Instance expected");switch(a.__class__){case"Parsley":return this.staticOptions;case"ParsleyForm":return this.getFormOptions(a);case"ParsleyField":return this.getFieldOptions(a);default:throw new Error("Instance "+a.__class__+" is not supported")}},getFormOptions:function(a){return this.formOptions=c.attr(a.$element,this.staticOptions.namespace),$.extend({},this.staticOptions,this.formOptions)},getFieldOptions:function(a){return this.fieldOptions=c.attr(a.$element,this.staticOptions.namespace),$.extend({},this.staticOptions,this.formOptions,this.fieldOptions)}};var i=function(a,b){if(this.__class__="ParsleyForm",this.__id__=c.hash(4),"Parsley"!==c.get(b,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=b,this.init($(a))};i.prototype={init:function(a){return this.$element=a,this.validationResult=null,this.options=this.parsleyInstance.OptionsFactory.get(this),this._bindFields()},onSubmitValidate:function(a){return this.validate(b,a),!1===this.validationResult&&a instanceof $.Event&&a.preventDefault(),this},validate:function(a,b){this.submitEvent=b,this.validationResult=!0;var c=[];this._refreshFields(),$.emit("parsley:form:validate",this);for(var d=0;d<this.fields.length;d++)a&&a!==this.fields[d].options.group||(c=this.fields[d].validate(),!0!==c&&c.length>0&&this.validationResult&&(this.validationResult=!1));return $.emit("parsley:form:validated",this),this.validationResult},isValid:function(a){this._refreshFields();for(var b=0;b<this.fields.length;b++)if((!a||a===this.fields[b].options.group)&&!1===this.fields[b].isValid())return!1;return!0},_refreshFields:function(){return this.actualizeOptions()._bindFields()},_bindFields:function(){var a=this;return this.fields=[],this.$element.find(this.options.inputs).each(function(){a.addField(this)}),this},addField:function(b){var c=new a.Parsley(b,{},this.parsleyInstance);return"ParsleyField"===c.__class__&&this.fields.push(c),this},removeField:function(){},reset:function(){},destroy:function(){}};var j=function(b,d,e,f,g){if("ParsleyField"!==c.get(b,"__class__"))throw new Error("ParsleyField instance expected");if("function"!=typeof a.ParsleyValidator.validators[d]&&"Assert"!==a.ParsleyValidator.validators[d](e).__parentClass__)throw new Error("Valid validator expected");var h=function(b,d){return"undefined"!=typeof b.options[d+"Priority"]?b.options[d+"Priority"]:c.get(a.ParsleyValidator.validators[d](e),"priority",2)};return f=f||h(b,d),$.extend(a.ParsleyValidator.validators[d](e),{name:d,requirements:e,priority:f,groups:[f],isDomConstraint:g||c.attr(b.$element,b.options.namespace,d)})},k=function(a,b){if(this.__class__="ParsleyField",this.__id__=c.hash(4),"Parsley"!==c.get(b,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=b,this.init($(a),b.options)};k.prototype={init:function(b){if(this.constraints=[],this.$element=b,this.validationResult=[],this.options=this.parsleyInstance.OptionsFactory.get(this),this.$element.is("input[type=radio], input[type=checkbox]")&&"undefined"==typeof this.options.multiple){if("undefined"==typeof this.$element.attr("name"))return a.console&&a.console.warn&&a.console.warn("To be binded by Parsley, a radio or checkbox input must have either a name or a multiple option.",this.$element),this.parsleyInstance;this.options.multiple=this.$element.attr("name").replace(/(:|\.|\[|\]|\$)/g,""),c.setAttr(this.$element,this.options.namespace,"multiple",this.options.multiple)}return this.bindConstraints()},validate:function(){return $.emit("parsley:field:validate",this),$.emit("parsley:field:"+(this.isValid()?"success":"error"),this),$.emit("parsley:field:validated",this),this.validationResult},getConstraintsSortedPriorities:function(){for(var a=[],b=0;b<this.constraints.length;b++)-1===a.indexOf(this.constraints[b].priority)&&a.push(this.constraints[b].priority);return a.sort(function(a,b){return b-a}),a},isValid:function(){var a=this.getConstraintsSortedPriorities(),b=this.getValue();if(this.refreshConstraints(),""===b&&!this.isRequired())return this.validationResult=[];if(!1===this.options.priorityEnabled)return!0===(this.validationResult=this.validateThroughValidator(b,this.constraints,"Any"));for(var c=0;c<a.length;c++)if(!0!==(this.validationResult=this.validateThroughValidator(b,this.constraints,a[c])))return!1;return!0},isRequired:function(){var a=this._constraintIndex("required");return!(-1===a||-1!==a&&!1===this.constraints[a].requirements)},getValue:function(){if("undefined"!=typeof this.options.value)return this.options.value;if(this.$element.is("input[type=radio]"))return $("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').val()||"";if(this.$element.is("input[type=checkbox]")){var a=[];return $("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').each(function(){a.push($(this).val())}),a.length?a:""}return this.$element.val()},refreshConstraints:function(){return this.actualizeOptions().bindConstraints() | ||
},bindConstraints:function(){for(var a=[],b=0;b<this.constraints.length;b++)!1===this.constraints[b].isDomConstraint&&a.push(this.constraints[b]);this.constraints=a;for(var c in this.options)this.addConstraint(c,this.options[c]);return this.bindHtml5Constraints()},bindHtml5Constraints:function(){(this.$element.hasClass("required")||this.$element.attr("required"))&&this.addConstraint("required",!0,b,!0),"string"==typeof this.$element.attr("pattern")&&this.addConstraint("pattern",this.$element.attr("pattern"),b,!0),"undefined"!=typeof this.$element.attr("min")&&"undefined"!=typeof this.$element.attr("max")?this.addConstraint("range",[this.$element.attr("min"),this.$element.attr("max")],b,!0):"undefined"!=typeof this.$element.attr("min")?this.addConstraint("min",this.$element.attr("min"),b,!0):"undefined"!=typeof this.$element.attr("max")&&this.addConstraint("max",this.$element.attr("max"),b,!0);var a=this.$element.attr("type");return"undefined"==typeof a?this:"number"===a?this.addConstraint("type","integer",b,!0):new RegExp(a,"i").test("email url range")?this.addConstraint("type",a,b,!0):void 0},addConstraint:function(b,c,d,e){return b=b.toLowerCase(),"function"==typeof a.ParsleyValidator.validators[b]&&(constraint=new j(this,b,c,d,e),-1!==this._constraintIndex(constraint.name)&&this.removeConstraint(constraint.name),this.constraints.push(constraint)),this},removeConstraint:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name){this.constraints.splice(b,1);break}return this},updateConstraint:function(a,b,c){return this.removeConstraint(a).addConstraint(a,b,c)},_constraintIndex:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name)return b;return-1}};var l=$({}),m={};$.listen=function(a){if("undefined"==typeof m[a]&&(m[a]=[]),"function"==typeof arguments[1])return m[a].push({fn:arguments[1]});if("object"==typeof arguments[1]&&"function"==typeof arguments[2])return m[a].push({fn:arguments[2],ctxt:arguments[1]});throw new Error("Wrong parameters")},$.listenTo=function(a,b,c){if("undefined"==typeof m[b]&&(m[b]=[]),!(a instanceof k||a instanceof i))throw new Error("Must give Parsley instance");if("string"!=typeof b||"function"!=typeof c)throw new Error("Wrong parameters");m[b].push({instance:a,fn:c})},$.unsubscribe=function(a,b){if("undefined"!=typeof m[a]){if("string"!=typeof a||"function"!=typeof b)throw new Error("Wrong arguments");for(var c=0;c<m[a].length;c++)if(m[a][c].fn===b)return m[a].splice(c,1)}},$.unsubscribeTo=function(a,b){if("undefined"!=typeof m[b]){if(!(a instanceof k||a instanceof i))throw new Error("Must give Parsley instance");for(var c=0;c<m[b].length;c++)if("undefined"!=typeof m[b][c].instance&&m[b][c].instance.__id__===a.__id__)return m[b].splice(c,1)}},$.unsubscribeAll=function(a){"undefined"!=typeof m[a]&&delete m[a]},$.emit=function(a,b){if("undefined"!=typeof m[a])for(var c=0;c<m[a].length;c++)if("undefined"!=typeof m[a][c].instance){if(b instanceof k||b instanceof i)if(m[a][c].instance.__id__!==b.__id__){if(m[a][c].instance instanceof i&&b instanceof k)for(var d=0;d<m[a][c].instance.fields.length;d++)if(m[a][c].instance.fields[d].__id__===b.__id__){m[a][c].fn.apply(l,Array.prototype.slice.call(arguments,1));continue}}else m[a][c].fn.apply(l,Array.prototype.slice.call(arguments,1))}else m[a][c].fn.apply("undefined"!=typeof m[a][c].ctxt?m[a][c].ctxt:l,Array.prototype.slice.call(arguments,1))},$.subscribed=function(){return m},a.ParsleyConfig=a.ParsleyConfig||{},a.ParsleyConfig.i18n=a.ParsleyConfig.i18n||{},a.ParsleyConfig.i18n.en=$.extend(a.ParsleyConfig.i18n.en||{},{defaultMessage:"This value seems to be invalid.",type:{email:"This value should be a valid email.",url:"This value should be a valid url.",number:"This value should be a valid number.",integer:"This value should be a valid integer.",digits:"This value should be digits.",alphanum:"This value should be alphanumeric."},notblank:"This value should not be blank.",required:"This value is required.",pattern:"This value seems to be invalid.",min:"This value should be greater than or equal to %s.",max:"This value should be lower than or equal to %s.",range:"This value should be between %s and %s.",minlength:"This value is too short. It should have %s characters or more.",maxlength:"This value is too long. It should have %s characters or less.",length:"This value length is invalid. It should be between %s and %s characters long.",mincheck:"You must select at least %s choices.",maxcheck:"You must select %s choices or less.",check:"You must select between %s and %s choices.",equalto:"This value should be the same."}),"undefined"!=typeof a.ParsleyValidator&&a.ParsleyValidator.addCatalog("en",a.ParsleyConfig.i18n.en,!0);var n=function(a,b,d){if(this.__class__="Parsley",this.__version__="2.0.0-rc1",this.__id__=c.hash(4),"undefined"==typeof a)throw new Error("You must give an element");return this.init($(a),b,d)};n.prototype={init:function(b,e,f){return this.$element=b,this.$element.data("Parsley")?this.$element.data("Parsley"):(this.OptionsFactory=new h(d,c.get(a,"ParsleyConfig",{}),e,this.getNamespace(e)),e=this.OptionsFactory.staticOptions,this.$element.is("form")||c.attr(this.$element,e.namespace,"validate")&&!this.$element.is(e.inputs)?this.bind("parsleyForm",f):this.$element.is(e.inputs)&&!this.$element.is(e.excluded)?this.bind("parsleyField",f):this)},getNamespace:function(b){return"undefined"!=typeof this.$element.data("parsleyNamespace")?this.$element.data("parsleyNamespace"):"undefined"!=typeof c.get(b,"namespace")?b.namespace:"undefined"!=typeof c.get(a,"ParsleyConfig.namespace")?a.ParsleyConfig.namespace:d.namespace},bind:function(b,c){switch(b){case"parsleyForm":parsleyInstance=$.extend(new i(this.$element,c||this),new e,a.ParsleyExtend);break;case"parsleyField":parsleyInstance=$.extend(new k(this.$element,c||this),new e,a.ParsleyExtend);break;default:throw new Error(b+"is not a supported Parsley type")}return this.$element.data("Parsley",parsleyInstance),("ParsleyForm"===parsleyInstance.__class__||"ParsleyField"===parsleyInstance.__class__)&&$.emit("parsley:"+("parsleyForm"===b?"form":"field")+":init",parsleyInstance),parsleyInstance}},$.fn.parsley=$.fn.psly=function(a){return new n(this,a)},a.ParsleyUI="function"==typeof c.get(a.ParsleyConfig,"ParsleyUI")?(new a.ParsleyConfig.ParsleyUI).listen():(new g).listen(),"undefined"==typeof a.ParsleyExtend&&(a.ParsleyExtend={}),"undefined"==typeof a.ParsleyConfig&&(a.ParsleyConfig={}),a.Parsley=a.psly=n,a.ParsleyUtils=c,a.ParsleyValidator=new f(a.ParsleyConfig.validators,a.ParsleyConfig.i18n),!1!==c.get(a,"ParsleyConfig.autoBind")&&$(document).ready(function(){$("[data-parsley-validate]").each(function(){new n(this)})})}(window); | ||
!function(a){var b={attr:function(a,b,c){var d,e={},f=new RegExp("^"+b,"i");if("undefined"==typeof a||"undefined"==typeof a[0])return{};for(var g in a[0].attributes)if(d=a[0].attributes[g],"undefined"!=typeof d&&null!==d&&d.specified&&f.test(d.name)){if("undefined"!=typeof c&&new RegExp(c,"i").test(d.name))return!0;e[this.camelize(d.name.replace(b,""))]=this.deserializeValue(d.value)}return"undefined"==typeof c?e:!1},setAttr:function(a,b,c,d){a[0].setAttribute(this.dasherize(b+c),String(d))},get:function(a,b,c){for(var d=0,e=(b||"").split(".");this.isObject(a)||this.isArray(a);)if(a=a[e[d++]],d===e.length)return a||c;return c},hash:function(a){return String(Math.random()).substring(2,a?a+2:9)},isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},isObject:function(a){return a===Object(a)},deserializeValue:function(b){var c;try{return b?"true"==b||("false"==b?!1:"null"==b?null:isNaN(c=Number(b))?/^[\[\{]/.test(b)?a.parseJSON(b):b:c):b}catch(d){return b}},camelize:function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},dasherize:function(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}},c={namespace:"data-parsley-",inputs:"input, textarea, select",excluded:"input[type=button], input[type=submit], input[type=reset]",priorityEnabled:!0,uiEnabled:!0,validationThreshold:3,focus:"first",trigger:!1,errorClass:"parsley-error",successClass:"parsley-success",classHandler:function(){},errorsContainer:function(){},errorsWrapper:'<ul class="parsley-errors-list"></ul>',errorTemplate:"<li></li>"},d=function(){};d.prototype={actualizeOptions:function(){return this.options=this.parsleyInstance.OptionsFactory.get(this),this},validateThroughValidator:function(){return window.ParsleyValidator.validate.apply(window.ParsleyValidator,arguments)},subscribe:function(b,c){return a.listenTo(this,b.toLowerCase(),c),this},unsubscribe:function(b){return a.unsubscribeTo(this,b.toLowerCase()),this},reset:function(){if("ParsleyField"===this.__class__)return a.emit("parsley:field:reset",this);for(var b=0;b<this.fields.length;b++)a.emit("parsley:field:reset",this.fields[b]);a.emit("parsley:form:reset",this)},destroy:function(){if("ParsleyField"===this.__class__)return a.emit("parsley:field:destroy",this),void this.$element.removeData("Parsley");for(var b=0;b<this.fields.length;b++)this.fields[b].destroy();a.emit("parsley:form:destroy",this),this.$element.removeData("Parsley")}},function(a){var b=function(a){return this.__class__="Validator",this.__version__="0.5.5",this.options=a||{},this.bindingKey=this.options.bindingKey||"_validatorjsConstraint",this};b.prototype={constructor:b,validate:function(a,b,c){if("string"!=typeof a&&"object"!=typeof a)throw new Error("You must validate an object or a string");return"string"==typeof a||g(a)?this._validateString(a,b,c):this.isBinded(a)?this._validateBindedObject(a,b):this._validateObject(a,b,c)},bind:function(a,b){if("object"!=typeof a)throw new Error("Must bind a Constraint to an object");return a[this.bindingKey]=new c(b),this},unbind:function(a){return"undefined"==typeof a._validatorjsConstraint?this:(delete a[this.bindingKey],this)},isBinded:function(a){return"undefined"!=typeof a[this.bindingKey]},getBinded:function(a){return this.isBinded(a)?a[this.bindingKey]:null},_validateString:function(a,b,c){var f,h=[];g(b)||(b=[b]);for(var i=0;i<b.length;i++){if(!(b[i]instanceof e))throw new Error("You must give an Assert or an Asserts array to validate a string");f=b[i].check(a,c),f instanceof d&&h.push(f)}return h.length?h:!0},_validateObject:function(a,b,d){if("object"!=typeof b)throw new Error("You must give a constraint to validate an object");return b instanceof c?b.check(a,d):new c(b).check(a,d)},_validateBindedObject:function(a,b){return a[this.bindingKey].check(a,b)}},b.errorCode={must_be_a_string:"must_be_a_string",must_be_an_array:"must_be_an_array",must_be_a_number:"must_be_a_number",must_be_a_string_or_array:"must_be_a_string_or_array"};var c=function(a,b){if(this.__class__="Constraint",this.options=b||{},this.nodes={},a)try{this._bootstrap(a)}catch(c){throw new Error("Should give a valid mapping object to Constraint",c,a)}return this};c.prototype={constructor:c,check:function(a,b){var c,d={};for(var h in this.options.strict?this.nodes:a)if(this.options.strict?this.has(h,a):this.has(h))c=this._check(h,a[h],b),(g(c)&&c.length>0||!g(c)&&!f(c))&&(d[h]=c);else if(this.options.strict)try{(new e).HaveProperty(h).validate(a)}catch(i){d[h]=i}return f(d)?!0:d},add:function(a,b){if(b instanceof e||g(b)&&b[0]instanceof e)return this.nodes[a]=b,this;if("object"==typeof b&&!g(b))return this.nodes[a]=b instanceof c?b:new c(b),this;throw new Error("Should give an Assert, an Asserts array, a Constraint",b)},has:function(a,b){var b="undefined"!=typeof b?b:this.nodes;return"undefined"!=typeof b[a]},get:function(a,b){return this.has(a)?this.nodes[a]:b||null},remove:function(a){var b=[];for(var c in this.nodes)c!==a&&(b[c]=this.nodes[c]);return this.nodes=b,this},_bootstrap:function(a){if(a instanceof c)return this.nodes=a.nodes;for(var b in a)this.add(b,a[b])},_check:function(a,b,d){if(this.nodes[a]instanceof e)return this._checkAsserts(b,[this.nodes[a]],d);if(g(this.nodes[a]))return this._checkAsserts(b,this.nodes[a],d);if(this.nodes[a]instanceof c)return this.nodes[a].check(b,d);throw new Error("Invalid node",this.nodes[a])},_checkAsserts:function(a,b,c){for(var d,e=[],f=0;f<b.length;f++)d=b[f].check(a,c),"undefined"!=typeof d&&!0!==d&&e.push(d);return e}};var d=function(a,b,c){if(this.__class__="Violation",!(a instanceof e))throw new Error("Should give an assertion implementing the Assert interface");this.assert=a,this.value=b,"undefined"!=typeof c&&(this.violation=c)};d.prototype={show:function(){var a={assert:this.assert.__class__,value:this.value};return this.violation&&(a.violation=this.violation),a},__toString:function(){if("undefined"!=typeof this.violation)var a='", '+this.getViolation().constraint+" expected was "+this.getViolation().expected;return this.assert.__class__+' assert failed for "'+this.value+a||""},getViolation:function(){var a,b;for(a in this.violation)b=this.violation[a];return{constraint:a,expected:b}}};var e=function(a){return this.__class__="Assert",this.__parentClass__=this.__class__,this.groups=[],"undefined"!=typeof a&&this.addGroup(a),this};e.prototype={construct:e,check:function(a,b){if(!(b&&!this.hasGroup(b)||!b&&this.hasGroups()))try{return this.validate(a,b)}catch(c){return c}},hasGroup:function(a){return g(a)?this.hasOneOf(a):"Any"===a?!0:this.hasGroups()?-1!==this.groups.indexOf(a):"Default"===a},hasOneOf:function(a){for(var b=0;b<a.length;b++)if(this.hasGroup(a[b]))return!0;return!1},hasGroups:function(){return this.groups.length>0},addGroup:function(a){return g(a)?this.addGroups(a):(this.hasGroup(a)||this.groups.push(a),this)},removeGroup:function(a){for(var b=[],c=0;c<this.groups.length;c++)a!==this.groups[c]&&b.push(this.groups[c]);return this.groups=b,this},addGroups:function(a){for(var b=0;b<a.length;b++)this.addGroup(a[b]);return this},HaveProperty:function(a){return this.__class__="HaveProperty",this.node=a,this.validate=function(a){if("undefined"==typeof a[this.node])throw new d(this,a,{value:this.node});return!0},this},Blank:function(){return this.__class__="Blank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""!==a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Callback:function(a){if(this.__class__="Callback",this.arguments=Array.prototype.slice.call(arguments),1===this.arguments.length?this.arguments=[]:this.arguments.splice(0,1),"function"!=typeof a)throw new Error("Callback must be instanciated with a function");return this.fn=a,this.validate=function(a){var b=[a].concat(this.arguments),c=this.fn.apply(this,b);if(!0!==c)throw new d(this,a,{result:c});return!0},this},Choice:function(a){if(this.__class__="Choice",!g(a)&&"function"!=typeof a)throw new Error("Choice must be instanciated with an array or a function");return this.list=a,this.validate=function(a){for(var b="function"==typeof this.list?this.list():this.list,c=0;c<b.length;c++)if(a===b[c])return!0;throw new d(this,a,{choices:b})},this},Collection:function(a){return this.__class__="Collection",this.constraint="undefined"!=typeof a?new c(a):!1,this.validate=function(a,c){var e,h=new b,i=0,j={},k=this.groups.length?this.groups:c;if(!g(a))throw new d(this,array,{value:b.errorCode.must_be_an_array});for(var l=0;l<a.length;l++)e=this.constraint?h.validate(a[l],this.constraint,k):h.validate(a[l],k),f(e)||(j[i]=e),i++;return f(j)?!0:j},this},Count:function(a){return this.__class__="Count",this.count=a,this.validate=function(a){if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});var c="function"==typeof this.count?this.count(a):this.count;if(isNaN(Number(c)))throw new Error("Count must be a valid interger",c);if(c!==a.length)throw new d(this,a,{count:c});return!0},this},Email:function(){return this.__class__="Email",this.validate=function(a){var c=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Eql:function(a){if(this.__class__="Eql","undefined"==typeof a)throw new Error("Equal must be instanciated with an Array or an Object");return this.eql=a,this.validate=function(a){var b="function"==typeof this.eql?this.eql(a):this.eql;if(!h.eql(b,a))throw new d(this,a,{eql:b});return!0},this},EqualTo:function(a){if(this.__class__="EqualTo","undefined"==typeof a)throw new Error("EqualTo must be instanciated with a value or a function");return this.reference=a,this.validate=function(a){var b="function"==typeof this.reference?this.reference(a):this.reference;if(b!==a)throw new d(this,a,{value:b});return!0},this},GreaterThan:function(a){if(this.__class__="GreaterThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>=a)throw new d(this,a,{threshold:this.threshold});return!0},this},GreaterThanOrEqual:function(a){if(this.__class__="GreaterThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold>a)throw new d(this,a,{threshold:this.threshold});return!0},this},InstanceOf:function(a){if(this.__class__="InstanceOf","undefined"==typeof a)throw new Error("InstanceOf must be instanciated with a value");return this.classRef=a,this.validate=function(a){if(!0!=a instanceof this.classRef)throw new d(this,a,{classRef:this.classRef});return!0},this},IPv4:function(){return this.__class__="IPv4",this.validate=function(a){var c=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},Length:function(a){if(this.__class__="Length",!a.min&&!a.max)throw new Error("Lenth assert must be instanciated with a { min: x, max: y } object");return this.min=a.min,this.max=a.max,this.validate=function(a){if("string"!=typeof a&&!g(a))throw new d(this,a,{value:b.errorCode.must_be_a_string_or_array});if("undefined"!=typeof this.min&&this.min===this.max&&a.length!==this.min)throw new d(this,a,{min:this.min,max:this.max});if("undefined"!=typeof this.max&&a.length>this.max)throw new d(this,a,{max:this.max});if("undefined"!=typeof this.min&&a.length<this.min)throw new d(this,a,{min:this.min});return!0},this},LessThan:function(a){if(this.__class__="LessThan","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<=a)throw new d(this,a,{threshold:this.threshold});return!0},this},LessThanOrEqual:function(a){if(this.__class__="LessThanOrEqual","undefined"==typeof a)throw new Error("Should give a threshold value");return this.threshold=a,this.validate=function(a){if(""===a||isNaN(Number(a)))throw new d(this,a,{value:b.errorCode.must_be_a_number});if(this.threshold<a)throw new d(this,a,{threshold:this.threshold});return!0},this},Mac:function(){return this.__class__="Mac",this.validate=function(a){var c=/^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i;if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!c.test(a))throw new d(this,a);return!0},this},NotNull:function(){return this.__class__="NotNull",this.validate=function(a){if(null===a||"undefined"==typeof a)throw new d(this,a);return!0},this},NotBlank:function(){return this.__class__="NotBlank",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(""===a.replace(/^\s+/g,"").replace(/\s+$/g,""))throw new d(this,a);return!0},this},Null:function(){return this.__class__="Null",this.validate=function(a){if(null!==a)throw new d(this,a);return!0},this},Range:function(a,b){if(this.__class__="Range",!a||!b)throw new Error("Range assert expects min and max values");return this.min=a,this.max=b,this.validate=function(a){try{return"string"==typeof a&&isNaN(Number(a))||g(a)?(new e).Length({min:this.min,max:this.max}).validate(a):(new e).GreaterThanOrEqual(this.min).validate(a)&&(new e).LessThanOrEqual(this.max).validate(a),!0}catch(b){throw new d(this,a,b.violation)}return!0},this},Regexp:function(a,c){if(this.__class__="Regexp","undefined"==typeof a)throw new Error("You must give a regexp");return this.regexp=a,this.flag=c||"",this.validate=function(a){if("string"!=typeof a)throw new d(this,a,{value:b.errorCode.must_be_a_string});if(!new RegExp(this.regexp).test(a,this.flag))throw new d(this,a,{regexp:this.regexp,flag:this.flag});return!0},this},Required:function(){return this.__class__="Required",this.validate=function(a){if("undefined"==typeof a)throw new d(this,a);if("string"==typeof a)try{(new e).NotNull().validate(a)&&(new e).NotBlank().validate(a)}catch(b){throw new d(this,a)}return!0},this},Unique:function(a){return this.__class__="Unique","object"==typeof a&&(this.key=a.key),this.validate=function(a){var c,e=[];if(!g(a))throw new d(this,a,{value:b.errorCode.must_be_an_array});for(var f=0;f<a.length;f++)if(c="object"==typeof a[f]?a[f][this.key]:a[f],"undefined"!=typeof c){if(-1!==e.indexOf(c))throw new d(this,a,{value:c});e.push(c)}return!0},this}},a.Assert=e,a.Validator=b,a.Violation=d,a.Constraint=c,Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&1/0!=d&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var f=function(a){for(var b in a)return!1;return!0},g=function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={eql:function(a,b){if(a===b)return!0;if("undefined"!=typeof Buffer&&Buffer.isBuffer(a)&&Buffer.isBuffer(b)){if(a.length!==b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}return a instanceof Date&&b instanceof Date?a.getTime()===b.getTime():"object"!=typeof a&&"object"!=typeof b?a==b:this.objEquiv(a,b)},isUndefinedOrNull:function(a){return null===a||"undefined"==typeof a},isArguments:function(a){return"[object Arguments]"==Object.prototype.toString.call(a)},keys:function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b},objEquiv:function(a,b){if(this.isUndefinedOrNull(a)||this.isUndefinedOrNull(b))return!1;if(a.prototype!==b.prototype)return!1;if(this.isArguments(a))return this.isArguments(b)?eql(pSlice.call(a),pSlice.call(b)):!1;try{var c,d,e=this.keys(a),f=this.keys(b)}catch(g){return!1}if(e.length!==f.length)return!1;for(e.sort(),f.sort(),d=e.length-1;d>=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!this.eql(a[c],b[c]))return!1;return!0}};"function"==typeof define&&define.amd&&define("validator",[],function(){return a})}("undefined"==typeof exports?this["undefined"!=typeof validatorjs_ns?validatorjs_ns:"Validator"]={}:exports);var e=function(a,b){this.__class__="ParsleyValidator",this.Validator=Validator,this.locale="en",this.init(a||{},b||{})};e.prototype={init:function(b,c){this.catalog=c;for(var d in b)this.addValidator(d,b[d].fn,b[d].priority);a.emit("parsley:validator:init")},setLocale:function(a){if("undefined"==typeof this.catalog[a])throw new Error(a+" is not available in the catalog");return this.locale=a,this},addCatalog:function(a,b,c){return"object"==typeof b&&(this.catalog[a]=b),!0===c?this.setLocale(a):this},addMessage:function(a,b,c){void 0===typeof this.catalog[a]&&(this.catalog[a]={}),this.catalog[a][b]=c},validate:function(){return(new this.Validator.Validator).validate.apply(new Validator.Validator,arguments)},addValidator:function(b,c,d){return this.validators[b]=function(b){return a.extend((new Validator.Assert).Callback(c,b),{priority:d})},this},updateValidator:function(a,b,c){return addValidator(a,b,c)},removeValidator:function(a){return delete this.validators[a],this},getErrorMessage:function(a){var b;return b="type"===a.name?window.ParsleyConfig.i18n[this.locale][a.name][a.requirements]:this.formatMesssage(window.ParsleyConfig.i18n[this.locale][a.name],a.requirements),""!==b?b:window.ParsleyConfig.i18n[this.locale].defaultMessage},formatMesssage:function(a,b){if("object"==typeof b){for(var c in b)a=this.formatMesssage(a,b[c]);return a}return"string"==typeof a?a.replace(new RegExp("%s","i"),b):""},validators:{notblank:function(){return a.extend((new Validator.Assert).NotBlank(),{priority:2})},required:function(){return a.extend((new Validator.Assert).Required(),{priority:512})},type:function(b){var c;switch(b){case"email":c=(new Validator.Assert).Email();break;case"number":c=(new Validator.Assert).Regexp("^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$");break;case"integer":c=(new Validator.Assert).Regexp("^-?\\d+$");break;case"digits":c=(new Validator.Assert).Regexp("^\\d+$");break;case"alphanum":c=(new Validator.Assert).Regexp("^\\w+$","i");break;case"url":c=(new Validator.Assert).Regexp("(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,4}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)","i");break;default:throw new Error("validator type `"+b+"` is not supported")}return a.extend(c,{priority:256})},pattern:function(b){return a.extend((new Validator.Assert).Regexp(b),{priority:64})},minlength:function(b){return a.extend((new Validator.Assert).Length({min:b}),{priority:30})},maxlength:function(b){return a.extend((new Validator.Assert).Length({max:b}),{priority:30})},length:function(b){return a.extend((new Validator.Assert).Length({min:b[0],max:b[1]}),{priority:32})},mincheck:function(a){return this.minlength(a)},maxcheck:function(a){return this.maxlength(a)},check:function(a){return this.length(a)},min:function(b){return a.extend((new Validator.Assert).GreaterThanOrEqual(b),{priority:30})},max:function(b){return a.extend((new Validator.Assert).LessThanOrEqual(b),{priority:30})},range:function(b){return a.extend((new Validator.Assert).Range(b[0],b[1]),{priority:32})},equalto:function(b){return a.extend((new Validator.Assert).Callback(function(b,c){return b===a(c).val()},b),{priority:256})}}};var f=function(){this.__class__="ParsleyUI"};f.prototype={listen:function(){return a.listen("parsley:form:init",this,this.setupForm),a.listen("parsley:field:init",this,this.setupField),a.listen("parsley:field:validated",this,this.reflow),a.listen("parsley:form:validated",this,this.focus),a.listen("parsley:field:reset",this,this.reset),a.listen("parsley:form:destroy",this,this.destroy),a.listen("parsley:field:destroy",this,this.destroy),this},reflow:function(a){if("undefined"!=typeof a._ui&&!1!==a._ui.active){var b=this._diff(a.validationResult,a._ui.lastValidationResult);a._ui.lastValidationResult=a.validationResult,a._ui.validatedOnce=!0,this.manageStatusClass(a),this.manageErrorsMessages(a,b),this.actualizeTriggers(a),(b.kept.length||b.added.length)&&"undefined"==typeof a._ui.failedOnce&&this.manageFailingFieldTrigger(a)}},manageStatusClass:function(a){!0===a.validationResult?this._successClass(a):a.validationResult.length>0?this._errorClass(a):this._resetClass(a)},manageErrorsMessages:function(b,c){if("undefined"!=typeof b.options.errorMessage)return void(c.added.length||c.kept.length?(0===b._ui.$errorsWrapper.find(".parsley-custom-error-message").length&&b._ui.$errorsWrapper.append(a(b.options.errorTemplate).addClass("parsley-custom-error-message")),b._ui.$errorsWrapper.addClass("filled").find(".parsley-custom-error-message").html(b.options.errorMessage)):b._ui.$errorsWrapper.removeClass("filled").find(".parsley-custom-error-message").remove());for(var d=0;d<c.removed.length;d++)this.removeError(b,c.removed[d].assert.name,!0);for(d=0;d<c.added.length;d++)this.addError(b,c.added[d].assert.name,void 0,c.added[d].assert,!0);for(d=0;d<c.kept.length;d++)this.updateError(b,c.kept[d].assert.name,void 0,c.kept[d].assert,!0)},addError:function(b,c,d,e,f){b._ui.$errorsWrapper.addClass("filled").append(a(b.options.errorTemplate).addClass("parsley-"+c).html(d||this._getErrorMessage(b,e))),!0!==f&&this._errorClass(b)},updateError:function(a,b,c,d,e){a._ui.$errorsWrapper.addClass("filled").find(".parsley-"+b).html(c||this._getErrorMessage(a,d)),!0!==e&&this._errorClass(a)},removeError:function(a,b,c){a._ui.$errorsWrapper.removeClass("filled").find(".parsley-"+b).remove(),!0!==c&&this.manageStatusClass(a)},focus:function(a){if(!0===a.validationResult||"none"===a.options.focus)return a._focusedField=null;a._focusedField=null;for(var b=0;b<a.fields.length;b++)if(!0!==a.fields[b].validationResult&&a.fields[b].validationResult.length>0&&"undefined"==typeof a.fields[b].options.noFocus){if("first"===a.options.focus)return a._focusedField=a.fields[b].$element,a._focusedField.focus();a._focusedField=a.fields[b].$element}return null===a._focusedField?null:a._focusedField.focus()},_getErrorMessage:function(a,b){var c=b.name+"Message";return"undefined"!=typeof a.options[c]?a.options[c]:window.ParsleyValidator.getErrorMessage(b)},_diff:function(a,b,c){for(var d=[],e=[],f=0;f<a.length;f++){for(var g=!1,h=0;h<b.length;h++)if(a[f].assert.name===b[h].assert.name){g=!0;break}g?e.push(a[f]):d.push(a[f])}return{kept:e,added:d,removed:c?[]:this._diff(b,a,!0).added}},setupForm:function(b){b.$element.on("submit.Parsley",!1,a.proxy(b.onSubmitValidate,b)),!1!==b.options.uiEnabled&&b.$element.attr("novalidate","")},setupField:function(b){var c={active:!1};!1!==b.options.uiEnabled&&(c.active=!0,b.$element.attr(b.options.namespace+"id",b.__id__),c.$errorClassHandler=this._manageClassHandler(b),c.errorsWrapperId="parsley-id-"+("undefined"!=typeof b.options.multiple?"multiple-"+b.options.multiple:b.__id__),c.$errorsWrapper=a(b.options.errorsWrapper).attr("id",c.errorsWrapperId),c.lastValidationResult=[],c.validatedOnce=!1,c.validationInformationVisible=!1,b._ui=c,this._insertErrorWrapper(b),this.actualizeTriggers(b))},_manageClassHandler:function(b){if("string"==typeof b.options.classHandler&&a(b.options.classHandler).length)return a(b.options.classHandler);var c=b.options.classHandler(b);return"undefined"!=typeof c&&c.length?c:"undefined"==typeof b.options.multiple?b.$element:b.$element.parent()},_insertErrorWrapper:function(b){if("string"==typeof b.options.errorsContainer&&a(b.options.errorsContainer).length)return a(b.options.errorsContainer).append(b._ui.$errorsWrapper);var c=b.options.errorsContainer(b);return"undefined"!=typeof c&&c.length?c.append(b._ui.$errorsWrapper):"undefined"==typeof b.options.multiple?b.$element.after(b._ui.$errorsWrapper):b.$element.parent().after(b._ui.$errorsWrapper)},actualizeTriggers:function(b){if(b.$element.off(".Parsley"),!1!==b.options.trigger){var c=b.options.trigger.replace(/^\s+/g,"").replace(/\s+$/g,"");""!==c&&b.$element.on(c.split(" ").join(".Parsley ")+".Parsley",!1,a.proxy("function"==typeof b.eventValidate?b.eventValidate:this.eventValidate,b))}},eventValidate:function(a){new RegExp("key").test(a.type)&&!this._ui.validationInformationVisible&&this.getValue().length<=this.options.validationThreshold||(this._ui.validatedOnce=!0,this.validate())},manageFailingFieldTrigger:function(b){return b._ui.failedOnce=!0,b.options.multiple&&a("["+b.options.namespace+'multiple="'+b.options.multiple+'"]').each(function(){return new RegExp("change","i").test(a(this).parsley().options.trigger||"")?void 0:a(this).parsley().$element.on("change.ParsleyFailedOnce",!1,a.proxy(b.validate,b))}),new RegExp("keyup","i").test(b.options.trigger||"")?void 0:b.$element.on("keyup.ParsleyFailedOnce",!1,a.proxy(b.validate,b))},reset:function(b){b.$element.off(".Parsley"),b.$element.off(".ParsleyFailedOnce"),"ParsleyForm"!==b.__class__&&(b._ui.$errorsWrapper.children().each(function(){a(this).remove()}),this._resetClass(b),b._ui.validatedOnce=!1,b._ui.lastValidationResult=[],b._ui.validationInformationVisible=!1)},destroy:function(a){this.reset(a),"ParsleyForm"!==a.__class__&&(a._ui.$errorsWrapper.remove(),delete a._ui)},_successClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.errorClass).addClass(a.options.successClass)},_errorClass:function(a){a._ui.validationInformationVisible=!0,a._ui.$errorClassHandler.removeClass(a.options.successClass).addClass(a.options.errorClass)},_resetClass:function(a){a._ui.$errorClassHandler.removeClass(a.options.successClass).removeClass(a.options.errorClass)}};var g=function(c,d,e,f){this.__class__="OptionsFactory",this.__id__=b.hash(4),this.formOptions=null,this.fieldOptions=null,this.staticOptions=a.extend(!0,{},c,d,e,{namespace:f})};g.prototype={get:function(a){if("undefined"==typeof a.__class__)throw new Error("Parsley Instance expected");switch(a.__class__){case"Parsley":return this.staticOptions;case"ParsleyForm":return this.getFormOptions(a);case"ParsleyField":return this.getFieldOptions(a);default:throw new Error("Instance "+a.__class__+" is not supported")}},getFormOptions:function(c){return this.formOptions=b.attr(c.$element,this.staticOptions.namespace),a.extend({},this.staticOptions,this.formOptions)},getFieldOptions:function(c){return this.fieldOptions=b.attr(c.$element,this.staticOptions.namespace),a.extend({},this.staticOptions,this.formOptions,this.fieldOptions)}};var h=function(c,d){if(this.__class__="ParsleyForm",this.__id__=b.hash(4),"Parsley"!==b.get(d,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=d,this.init(a(c))};h.prototype={init:function(a){return this.$element=a,this.validationResult=null,this.options=this.parsleyInstance.OptionsFactory.get(this),this._bindFields()},onSubmitValidate:function(b){return this.validate(void 0,b),!1===this.validationResult&&b instanceof a.Event&&b.preventDefault(),this},validate:function(b,c){this.submitEvent=c,this.validationResult=!0;var d=[];this._refreshFields(),a.emit("parsley:form:validate",this);for(var e=0;e<this.fields.length;e++)b&&b!==this.fields[e].options.group||(d=this.fields[e].validate(),!0!==d&&d.length>0&&this.validationResult&&(this.validationResult=!1));return a.emit("parsley:form:validated",this),this.validationResult},isValid:function(a){this._refreshFields();for(var b=0;b<this.fields.length;b++)if((!a||a===this.fields[b].options.group)&&!1===this.fields[b].isValid())return!1;return!0},_refreshFields:function(){return this.actualizeOptions()._bindFields()},_bindFields:function(){var a=this;return this.fields=[],this.$element.find(this.options.inputs).each(function(){var b=new window.Parsley(this,{},a.parsleyInstance);"ParsleyField"===b.__class__&&a.fields.push(b)}),this}};var i=function(c,d,e,f,g){if("ParsleyField"!==b.get(c,"__class__"))throw new Error("ParsleyField instance expected");if("function"!=typeof window.ParsleyValidator.validators[d]&&"Assert"!==window.ParsleyValidator.validators[d](e).__parentClass__)throw new Error("Valid validator expected");var h=function(a,c){return"undefined"!=typeof a.options[c+"Priority"]?a.options[c+"Priority"]:b.get(window.ParsleyValidator.validators[c](e),"priority",2)};return f=f||h(c,d),a.extend(window.ParsleyValidator.validators[d](e),{name:d,requirements:e,priority:f,groups:[f],isDomConstraint:g||b.attr(c.$element,c.options.namespace,d)})},j=function(c,d){if(this.__class__="ParsleyField",this.__id__=b.hash(4),"Parsley"!==b.get(d,"__class__"))throw new Error("You must give a Parsley instance");return this.parsleyInstance=d,this.init(a(c),d.options)};j.prototype={init:function(a){if(this.constraints=[],this.$element=a,this.validationResult=[],this.options=this.parsleyInstance.OptionsFactory.get(this),this.$element.is("input[type=radio], input[type=checkbox]")&&"undefined"==typeof this.options.multiple||this.$element.is("select")&&"undefined"!=typeof this.$element.attr("multiple")){if("undefined"==typeof this.$element.attr("name")&&"undefined"==typeof this.$element.attr("id"))return window.console&&window.console.warn&&window.console.warn("To be binded by Parsley, a radio, a checkbox and a multiple select input must have either a name, and id or a multiple option.",this.$element),this.parsleyInstance;this.options.multiple=(this.$element.attr("name")||this.$element.attr("id")).replace(/(:|\.|\[|\]|\$)/g,""),b.setAttr(this.$element,this.options.namespace,"multiple",this.options.multiple)}return this.bindConstraints()},validate:function(){return this.value=this.getValue(),a.emit("parsley:field:validate",this),a.emit("parsley:field:"+(this.isValid(this.value)?"success":"error"),this),a.emit("parsley:field:validated",this),this.validationResult},getConstraintsSortedPriorities:function(){for(var a=[],b=0;b<this.constraints.length;b++)-1===a.indexOf(this.constraints[b].priority)&&a.push(this.constraints[b].priority);return a.sort(function(a,b){return b-a}),a},isValid:function(a){var b=this.getConstraintsSortedPriorities();if(a=a||this.getValue(),this.refreshConstraints(),""===a&&!this.isRequired()&&"undefined"==typeof this.options.validateIfEmpty&&"undefined"==typeof this.options.multiple)return this.validationResult=[];if(!1===this.options.priorityEnabled)return!0===(this.validationResult=this.validateThroughValidator(a,this.constraints,"Any"));for(var c=0;c<b.length;c++)if(!0!==(this.validationResult=this.validateThroughValidator(a,this.constraints,b[c])))return!1;return!0},isRequired:function(){var a=this._constraintIndex("required");return!(-1===a||-1!==a&&!1===this.constraints[a].requirements)},getValue:function(){if("undefined"!=typeof this.options.value)return this.options.value;if("undefined"==typeof this.options.multiple)return this.$element.val();if(this.$element.is("input[type=radio]"))return a("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').val()||""; | ||
if(this.$element.is("input[type=checkbox]")){var b=[];return a("["+this.options.namespace+'multiple="'+this.options.multiple+'"]:checked').each(function(){b.push(a(this).val())}),b.length?b:""}return this.$element.is("select")?null===this.$element.val()?"":this.$element.val():void 0},refreshConstraints:function(){return this.actualizeOptions().bindConstraints()},bindConstraints:function(){for(var a=[],b=0;b<this.constraints.length;b++)!1===this.constraints[b].isDomConstraint&&a.push(this.constraints[b]);this.constraints=a;for(var c in this.options)this.addConstraint(c,this.options[c]);return this.bindHtml5Constraints()},bindHtml5Constraints:function(){(this.$element.hasClass("required")||this.$element.attr("required"))&&this.addConstraint("required",!0,void 0,!0),"string"==typeof this.$element.attr("pattern")&&this.addConstraint("pattern",this.$element.attr("pattern"),void 0,!0),"undefined"!=typeof this.$element.attr("min")&&"undefined"!=typeof this.$element.attr("max")?this.addConstraint("range",[this.$element.attr("min"),this.$element.attr("max")],void 0,!0):"undefined"!=typeof this.$element.attr("min")?this.addConstraint("min",this.$element.attr("min"),void 0,!0):"undefined"!=typeof this.$element.attr("max")&&this.addConstraint("max",this.$element.attr("max"),void 0,!0);var a=this.$element.attr("type");return"undefined"==typeof a?this:"number"===a?this.addConstraint("type","integer",void 0,!0):new RegExp(a,"i").test("email url range")?this.addConstraint("type",a,void 0,!0):void 0},addConstraint:function(a,b,c,d){return a=a.toLowerCase(),"function"==typeof window.ParsleyValidator.validators[a]&&(constraint=new i(this,a,b,c,d),-1!==this._constraintIndex(constraint.name)&&this.removeConstraint(constraint.name),this.constraints.push(constraint)),this},removeConstraint:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name){this.constraints.splice(b,1);break}return this},updateConstraint:function(a,b,c){return this.removeConstraint(a).addConstraint(a,b,c)},_constraintIndex:function(a){for(var b=0;b<this.constraints.length;b++)if(a===this.constraints[b].name)return b;return-1}};var k=a({}),l={};a.listen=function(a){if("undefined"==typeof l[a]&&(l[a]=[]),"function"==typeof arguments[1])return l[a].push({fn:arguments[1]});if("object"==typeof arguments[1]&&"function"==typeof arguments[2])return l[a].push({fn:arguments[2],ctxt:arguments[1]});throw new Error("Wrong parameters")},a.listenTo=function(a,b,c){if("undefined"==typeof l[b]&&(l[b]=[]),!(a instanceof j||a instanceof h))throw new Error("Must give Parsley instance");if("string"!=typeof b||"function"!=typeof c)throw new Error("Wrong parameters");l[b].push({instance:a,fn:c})},a.unsubscribe=function(a,b){if("undefined"!=typeof l[a]){if("string"!=typeof a||"function"!=typeof b)throw new Error("Wrong arguments");for(var c=0;c<l[a].length;c++)if(l[a][c].fn===b)return l[a].splice(c,1)}},a.unsubscribeTo=function(a,b){if("undefined"!=typeof l[b]){if(!(a instanceof j||a instanceof h))throw new Error("Must give Parsley instance");for(var c=0;c<l[b].length;c++)if("undefined"!=typeof l[b][c].instance&&l[b][c].instance.__id__===a.__id__)return l[b].splice(c,1)}},a.unsubscribeAll=function(a){"undefined"!=typeof l[a]&&delete l[a]},a.emit=function(a,b){if("undefined"!=typeof l[a])for(var c=0;c<l[a].length;c++)if("undefined"!=typeof l[a][c].instance){if(b instanceof j||b instanceof h)if(l[a][c].instance.__id__!==b.__id__){if(l[a][c].instance instanceof h&&b instanceof j)for(var d=0;d<l[a][c].instance.fields.length;d++)if(l[a][c].instance.fields[d].__id__===b.__id__){l[a][c].fn.apply(k,Array.prototype.slice.call(arguments,1));continue}}else l[a][c].fn.apply(k,Array.prototype.slice.call(arguments,1))}else l[a][c].fn.apply("undefined"!=typeof l[a][c].ctxt?l[a][c].ctxt:k,Array.prototype.slice.call(arguments,1))},a.subscribed=function(){return l},window.ParsleyConfig=window.ParsleyConfig||{},window.ParsleyConfig.i18n=window.ParsleyConfig.i18n||{},window.ParsleyConfig.i18n.en=a.extend(window.ParsleyConfig.i18n.en||{},{defaultMessage:"This value seems to be invalid.",type:{email:"This value should be a valid email.",url:"This value should be a valid url.",number:"This value should be a valid number.",integer:"This value should be a valid integer.",digits:"This value should be digits.",alphanum:"This value should be alphanumeric."},notblank:"This value should not be blank.",required:"This value is required.",pattern:"This value seems to be invalid.",min:"This value should be greater than or equal to %s.",max:"This value should be lower than or equal to %s.",range:"This value should be between %s and %s.",minlength:"This value is too short. It should have %s characters or more.",maxlength:"This value is too long. It should have %s characters or less.",length:"This value length is invalid. It should be between %s and %s characters long.",mincheck:"You must select at least %s choices.",maxcheck:"You must select %s choices or less.",check:"You must select between %s and %s choices.",equalto:"This value should be the same."}),"undefined"!=typeof window.ParsleyValidator&&window.ParsleyValidator.addCatalog("en",window.ParsleyConfig.i18n.en,!0);var m=function(c,d,e){if(this.__class__="Parsley",this.__version__="2.0.0-rc2",this.__id__=b.hash(4),"undefined"==typeof c)throw new Error("You must give an element");return this.init(a(c),d,e)};m.prototype={init:function(a,d,e){if(!a.length)throw new Error("You must bind Parsley on an existing element.");return this.$element=a,this.$element.data("Parsley")?this.$element.data("Parsley"):(this.OptionsFactory=new g(c,b.get(window,"ParsleyConfig",{}),d,this.getNamespace(d)),d=this.OptionsFactory.staticOptions,this.$element.is("form")||b.attr(this.$element,d.namespace,"validate")&&!this.$element.is(d.inputs)?this.bind("parsleyForm",e):this.$element.is(d.inputs)&&!this.$element.is(d.excluded)?this.bind("parsleyField",e):this)},getNamespace:function(a){return"undefined"!=typeof this.$element.data("parsleyNamespace")?this.$element.data("parsleyNamespace"):"undefined"!=typeof b.get(a,"namespace")?a.namespace:"undefined"!=typeof b.get(window,"ParsleyConfig.namespace")?window.ParsleyConfig.namespace:c.namespace},bind:function(b,c){switch(b){case"parsleyForm":parsleyInstance=a.extend(new h(this.$element,c||this),new d,window.ParsleyExtend);break;case"parsleyField":parsleyInstance=a.extend(new j(this.$element,c||this),new d,window.ParsleyExtend);break;default:throw new Error(b+"is not a supported Parsley type")}return("ParsleyForm"===parsleyInstance.__class__||"ParsleyField"===parsleyInstance.__class__)&&(this.$element.data("Parsley",parsleyInstance),a.emit("parsley:"+("parsleyForm"===b?"form":"field")+":init",parsleyInstance)),parsleyInstance}},a.fn.parsley=a.fn.psly=function(a){return new m(this,a)},window.ParsleyUI="function"==typeof b.get(window.ParsleyConfig,"ParsleyUI")?(new window.ParsleyConfig.ParsleyUI).listen():(new f).listen(),"undefined"==typeof window.ParsleyExtend&&(window.ParsleyExtend={}),"undefined"==typeof window.ParsleyConfig&&(window.ParsleyConfig={}),window.Parsley=window.psly=m,window.ParsleyUtils=b,window.ParsleyValidator=new e(window.ParsleyConfig.validators,window.ParsleyConfig.i18n),!1!==b.get(window,"ParsleyConfig.autoBind")&&a(document).ready(function(){a("[data-parsley-validate]").each(function(){new m(this)})})}(window.jQuery); |
@@ -11,2 +11,3 @@ module.exports = function (grunt) { | ||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
grunt.loadNpmTasks('grunt-npm2bower-sync'); | ||
@@ -23,2 +24,12 @@ grunt.loadNpmTasks('grunt-docco'); | ||
sync: { | ||
all: { | ||
options: { | ||
sync: ['author', 'name', 'version', 'license', 'main', 'keywords'], | ||
from: 'package.json', | ||
to: 'bower.json' | ||
} | ||
} | ||
}, | ||
docco: { | ||
@@ -178,3 +189,3 @@ source: { | ||
grunt.registerTask('build-annotated-source', ['docco:source', 'replace:annotated']); | ||
grunt.registerTask('build-all', ['clean:dist', 'build', 'build-remote', 'build-annotated-source']); | ||
grunt.registerTask('build-all', ['clean:dist', 'build', 'build-remote', 'build-annotated-source', 'sync']); | ||
}; | ||
@@ -181,0 +192,0 @@ |
{ | ||
"name": "parsleyjs", | ||
"version": "2.0.0-rc1", | ||
"version": "2.0.0-rc2", | ||
"license": "MIT", | ||
@@ -28,3 +28,4 @@ "description": "Validate your forms, frontend, without writing a single line of javascript!", | ||
"grunt-contrib-watch": "~0.5.3", | ||
"grunt-contrib-concat": "~0.3.0" | ||
"grunt-contrib-concat": "~0.3.0", | ||
"grunt-npm2bower-sync": "~0.3.0" | ||
}, | ||
@@ -31,0 +32,0 @@ "scripts": { |
@@ -9,3 +9,3 @@ # Parsley | ||
2.0.0-rc1 | ||
2.0.0-rc2 | ||
@@ -12,0 +12,0 @@ ## Doc |
@@ -46,2 +46,5 @@ // Parsley.js @@version | ||
init: function ($element, options, parsleyInstance) { | ||
if (!$element.length) | ||
throw new Error('You must bind Parsley on an existing element.'); | ||
this.$element = $element; | ||
@@ -94,8 +97,9 @@ | ||
// Store for later access the freshly binded instance in DOM element itself using jQuery `data()` | ||
this.$element.data('Parsley', parsleyInstance); | ||
if ('ParsleyForm' === parsleyInstance.__class__ || 'ParsleyField' === parsleyInstance.__class__) { | ||
// Store for later access the freshly binded instance in DOM element itself using jQuery `data()` | ||
this.$element.data('Parsley', parsleyInstance); | ||
// Tell the world we got a new ParsleyForm or Field instance! | ||
if ('ParsleyForm' === parsleyInstance.__class__ || 'ParsleyField' === parsleyInstance.__class__) | ||
// Tell the world we got a new ParsleyForm or ParsleyField instance! | ||
$.emit('parsley:' + ('parsleyForm' === type ? 'form' : 'field') + ':init', parsleyInstance); | ||
} | ||
@@ -102,0 +106,0 @@ return parsleyInstance; |
@@ -0,1 +1,7 @@ | ||
// `window.ParsleyExtend`, like `ParsleyAbstract`, is inherited by `ParsleyField` and `ParsleyForm` | ||
// That way, we could add new methods or redefine some for these both classes. In particular case | ||
// We are adding async validation methods that returns promises, bind them properly to triggered | ||
// Events like onkeyup when field is invalid or on form submit. These validation methods adds an | ||
// Extra `remote` validator which could not be simply added like other `ParsleyExtra` validators | ||
// Because returns promises instead of booleans. | ||
window.ParsleyExtend = $.extend(window.ParsleyExtend || {}, { | ||
@@ -134,2 +140,3 @@ asyncValidate: function (group, event) { | ||
// All `$.ajax(options)` could be overriden or extended directly from DOM in `data-parsley-remote-options` | ||
promise = $.ajax($.extend(true, {}, { | ||
@@ -153,3 +160,3 @@ url: that.options.remote, | ||
_handleRemoteResult: function (status, deferred, csr) { | ||
// Store remote call result to avoid next calls | ||
// Store remote call result to avoid next calls with exact same parameters | ||
this._remote[csr] = status; | ||
@@ -180,6 +187,7 @@ | ||
// Remote validator is just an always true sync validator with lowest (-1) priority possible | ||
// It will be overloaded in `validateThroughValidator()` that will do the heavy async work | ||
// This 'hack' is needed not to mess up too much with error messages and stuff in `ParsleyUI` | ||
window.ParsleyConfig = $.extend(window.ParsleyConfig || {}, { | ||
validators: { | ||
// Remote validator is just an always true sync validator with lowest (-1) priority possible | ||
// It will be overloaded in `validateThroughValidator()` that will do the heavy async work | ||
remote: { | ||
@@ -186,0 +194,0 @@ fn: function () { |
@@ -24,7 +24,7 @@ define('parsley/field', [ | ||
// Select / checkbox multiple inputs hack | ||
if (this.$element.is('input[type=radio], input[type=checkbox]') && 'undefined' === typeof this.options.multiple) { | ||
if ('undefined' === typeof this.$element.attr('name')) { | ||
// Select / radio / checkbox multiple inputs hack | ||
if ((this.$element.is('input[type=radio], input[type=checkbox]') && 'undefined' === typeof this.options.multiple) || (this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple'))) { | ||
if ('undefined' === typeof this.$element.attr('name') && 'undefined' === typeof this.$element.attr('id')) { | ||
if (window.console && window.console.warn) | ||
window.console.warn('To be binded by Parsley, a radio or checkbox input must have either a name or a multiple option.', this.$element); | ||
window.console.warn('To be binded by Parsley, a radio, a checkbox and a multiple select input must have either a name, and id or a multiple option.', this.$element); | ||
@@ -34,3 +34,3 @@ return this.parsleyInstance; | ||
this.options.multiple = this.$element.attr('name').replace(/(:|\.|\[|\]|\$)/g, ''); | ||
this.options.multiple = (this.$element.attr('name') || this.$element.attr('id')).replace(/(:|\.|\[|\]|\$)/g, ''); | ||
ParsleyUtils.setAttr(this.$element, this.options.namespace, 'multiple', this.options.multiple); | ||
@@ -47,4 +47,10 @@ } | ||
validate: function () { | ||
this.value = this.getValue(); | ||
// Field Validate event. `this.value` could be altered for custom needs | ||
$.emit('parsley:field:validate', this); | ||
$.emit('parsley:field:' + (this.isValid() ? 'success' : 'error'), this); | ||
$.emit('parsley:field:' + (this.isValid(this.value) ? 'success' : 'error'), this); | ||
// Field validated event. `this.validationResult` could be altered for custom needs too | ||
$.emit('parsley:field:validated', this); | ||
@@ -70,7 +76,9 @@ | ||
// Same @return as `validate()` | ||
isValid: function () { | ||
isValid: function (value) { | ||
// Sort priorities to validate more important first | ||
var priorities = this.getConstraintsSortedPriorities(), | ||
value = this.getValue(); | ||
var priorities = this.getConstraintsSortedPriorities(); | ||
// Value could be passed as argument, needed to add more power to 'parsley:field:validate' | ||
value = value || this.getValue(); | ||
// Recompute options and rebind constraints to have latest changes | ||
@@ -80,4 +88,6 @@ this.refreshConstraints(); | ||
// If a field is empty and not required, leave it alone, it's just fine | ||
if ('' === value && !this.isRequired()) | ||
return this.validationResult = []; | ||
// Except if `data-parsley-validate-if-empty` explicitely added, useful for some custom validators | ||
// And if multiple field | ||
if ('' === value && !this.isRequired() && 'undefined' === typeof this.options.validateIfEmpty && 'undefined' === typeof this.options.multiple) | ||
return this.validationResult = []; | ||
@@ -108,2 +118,6 @@ // If we want to validate field against all constraints, just call Validator and let it do the job | ||
// Regular input, textarea and simple select | ||
if ('undefined' === typeof this.options.multiple) | ||
return this.$element.val(); | ||
// Radio input case | ||
@@ -124,3 +138,5 @@ if (this.$element.is('input[type=radio]')) | ||
return this.$element.val(); | ||
// Select multiple case | ||
if (this.$element.is('select')) | ||
return null === this.$element.val() ? '' : this.$element.val(); | ||
}, | ||
@@ -127,0 +143,0 @@ |
@@ -43,2 +43,3 @@ define('parsley/form', [ | ||
// Refresh form DOM options and form's fields that could have changed | ||
this._refreshFields(); | ||
@@ -92,21 +93,11 @@ | ||
this.$element.find(this.options.inputs).each(function () { | ||
self.addField(this); | ||
var fieldInstance = new window.Parsley(this, {}, self.parsleyInstance); | ||
// only add valid field children | ||
if ('ParsleyField' === fieldInstance.__class__) | ||
self.fields.push(fieldInstance); | ||
}); | ||
return this; | ||
}, | ||
addField: function (field) { | ||
var fieldInstance = new window.Parsley(field, {}, this.parsleyInstance); | ||
// only add valid field children | ||
if ('ParsleyField' === fieldInstance.__class__) | ||
this.fields.push(fieldInstance); | ||
return this; | ||
}, | ||
removeField: function (field) {}, | ||
reset: function () {}, | ||
destroy: function () {} | ||
} | ||
}; | ||
@@ -113,0 +104,0 @@ |
@@ -1,1 +0,1 @@ | ||
})(window); | ||
})(window.jQuery); |
@@ -9,2 +9,2 @@ /*! | ||
(function(window, undefined) { | ||
!(function($) { |
@@ -47,2 +47,16 @@ define(function () { | ||
}); | ||
it('should support select multiple', function () { | ||
$('body').append( | ||
'<select multiple id="element" >' + | ||
'<option value="1">1</option>' + | ||
'<option value="2">2</option>' + | ||
'<option value="3">3</option>' + | ||
'</select>'); | ||
var parsleyField = new Parsley($('#element')); | ||
expect(parsleyField.__class__).to.be('ParsleyField'); | ||
expect(parsleyField.options.multiple).to.be('element'); | ||
expect(parsleyField.getValue()).to.be(''); | ||
$('#element option[value="1"]').attr('selected', 'selected'); | ||
expect(parsleyField.getValue()).to.be.eql(['1']); | ||
}); | ||
it('should have a proper updateConstraint() javascript method', function () { | ||
@@ -200,2 +214,18 @@ $('body').append('<input type="text" id="element" />'); | ||
}); | ||
it('should have validateIfEmpty option', function () { | ||
$('body').append('<input type="email" data-parsley-rangelength="[5, 10]" id="element" />'); | ||
expect($('#element').psly().isValid()).to.be.eql([]); | ||
$('#element').attr('data-parsley-validate-if-empty', ''); | ||
expect($('#element').psly().isValid()).to.be.eql(false); | ||
}); | ||
it('should allow `this.value` alteration with parsley:field:validate event', function () { | ||
$('body').append('<input type="email" required id="element" />'); | ||
expect($('#element').parsley().validate()).not.to.be(true); | ||
$('#element').parsley().subscribe('parsley:field:validate', function (fieldInstance) { | ||
fieldInstance.value = 'foo@bar.baz'; | ||
}); | ||
expect($('#element').parsley().validate()).to.be(true); | ||
}); | ||
afterEach(function () { | ||
@@ -202,0 +232,0 @@ window.ParsleyConfig = { i18n: window.ParsleyConfig.i18n, validators: window.ParsleyConfig.validators }; |
@@ -83,8 +83,18 @@ define(function () { | ||
}); | ||
it('should not bind radio or checkboxes withoud a name or a multiple option', function () { | ||
$('body').append('<input type="radio" id="element" required />'); | ||
it('should not bind radio or checkboxes withoud a name, an id or a multiple option', function () { | ||
$('body').append('<input type="radio" value="foo" />'); | ||
window.console.warn = sinon.spy(); | ||
parsleyInstance = $('#element').psly(); | ||
parsleyInstance = $('input[type=radio]').psly(); | ||
expect(parsleyInstance.__class__).to.be('Parsley'); | ||
expect(window.console.warn.called).to.be(true); | ||
$('input[type=radio]').attr('id', 'element'); | ||
parsleyInstance = $('#element').parsley(); | ||
expect(parsleyInstance.__class__).to.be('ParsleyField'); | ||
expect(parsleyInstance.options.multiple).to.be('element'); | ||
parsleyInstance.destroy(); | ||
$('input[type=radio]').attr('name', 'element'); | ||
parsleyInstance = $('input[name=element]').parsley(); | ||
expect(parsleyInstance.__class__).to.be('ParsleyField'); | ||
expect(parsleyInstance.options.multiple).to.be('element'); | ||
$('input[name=element]').remove(); | ||
}); | ||
@@ -91,0 +101,0 @@ afterEach(function () { |
@@ -36,4 +36,23 @@ # UPGRADE FROM 1.x to 2.0 | ||
validators | ||
- types `phone`, `urlstrict`, `dateIso` have been removed. They could be | ||
crafted and submitted by someone in `extra/` | ||
## UI/UX | ||
- `.parsley-validated` class is not added anymore on binded fields | ||
- `novalidate` attr is now automatically added to `<form>` | ||
- `.parsley-error-list` is now `.parsley-errors-list` | ||
- to customize `type` validator error message, you do not need anymore to add | ||
the precise type. | ||
eg: `parsley-type-email-message="msg"` becomes | ||
`data-parsley-type-message="msg"` | ||
## Javascript | ||
- `.parsley('method')` API is deprecated. Use .parsley().method() now | ||
eg: `$('#form').parsley('validate')` is now `$('#form').parsley().validate()` | ||
## Listeners | ||
@@ -46,2 +65,3 @@ | ||
## Misc | ||
@@ -48,0 +68,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67
494733
13
7424