Socket
Socket
Sign inDemoInstall

angular-form-for

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-form-for - npm Package Compare versions

Comparing version 3.0.3 to 3.0.5

circle.yml

2

bower.json
{
"name": "angular-form-for",
"version": "3.0.3",
"version": "3.0.5",
"main": [

@@ -5,0 +5,0 @@ "./dist/form-for.css",

# Changelog
## 3.0.5
formForIncludeReplace directive now re-compiles included content before replacing. This fixes an issue with jqLite that caused partials (e.g. select-field/_select.html) to become disconnected from their parent directives. This should also remove the jQuery dependency on the Angular Material templates.
## 3.0.4
Patched a bad version of the jQuery definitions file in order to resolve a jqLite-incompatible `element.on()` listener format.
## 3.0.3

@@ -4,0 +10,0 @@ formForBuilder now correctly checks for input[type=button], button, and submitButton directive.

@@ -623,2 +623,3 @@ /**

on(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
on(events: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
on(eventsMap: { [key: string]: any; }, selector?: any, data?: any): JQuery;

@@ -625,0 +626,0 @@

@@ -1,3 +0,3 @@

angular.module("formFor",[]);var formFor;!function(e){var t=function(){function e(){this.restrict="A"}return e.prototype.link=function(e,t,r){e.$watch("model.uid",function(e){r.$set("ariaDescribedby",e+"-error"),r.$set("ariaLabelledby",e+"-label")}),e.$watch("model.error",function(e){r.$set("ariaInvalid",!!e)})},e.prototype.link.$inject=["$scope","$element","$attributes"],e}();e.AriaManager=t,angular.module("formFor").directive("ariaManager",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(){this.autoGenerateLabels_=!1,this.defaultDebounceDuration_=500,this.defaultSubmitComplete_=angular.noop,this.defaultSubmitError_=angular.noop,this.defaultValidationFailed_=angular.noop,this.requiredLabel_=null,this.validationFailedForCustomMessage_="Failed custom validation",this.validationFailedForEmailTypeMessage_="Invalid email format",this.validationFailedForIntegerTypeMessage_="Must be an integer",this.validationFailedForMaxCollectionSizeMessage_="Must be fewer than {{num}} items",this.validationFailedForMaximumMessage_="Must be no more than {{num}}",this.validationFailedForMaxLengthMessage_="Must be fewer than {{num}} characters",this.validationFailedForMinimumMessage_="Must be at least {{num}}",this.validationFailedForMinCollectionSizeMessage_="Must at least {{num}} items",this.validationFailedForMinLengthMessage_="Must be at least {{num}} characters",this.validationFailedForNegativeTypeMessage_="Must be negative",this.validationFailedForNonNegativeTypeMessage_="Must be non-negative",this.validationFailedForNumericTypeMessage_="Must be numeric",this.validationFailedForPatternMessage_="Invalid format",this.validationFailedForPositiveTypeMessage_="Must be positive",this.validationFailedForRequiredMessage_="Required field"}return Object.defineProperty(t.prototype,"autoGenerateLabels",{get:function(){return this.autoGenerateLabels_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultDebounceDuration",{get:function(){return this.defaultDebounceDuration_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultSubmitComplete",{get:function(){return this.defaultSubmitComplete_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultSubmitError",{get:function(){return this.defaultSubmitError_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultValidationFailed",{get:function(){return this.defaultValidationFailed_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"requiredLabel",{get:function(){return this.requiredLabel_},enumerable:!0,configurable:!0}),t.prototype.disableAutoLabels=function(){this.autoGenerateLabels_=!1},t.prototype.enableAutoLabels=function(){this.autoGenerateLabels_=!0},t.prototype.getFailedValidationMessage=function(t){switch(t){case e.ValidationFailureType.CUSTOM:return this.validationFailedForCustomMessage_;case e.ValidationFailureType.COLLECTION_MAX_SIZE:return this.validationFailedForMaxCollectionSizeMessage_;case e.ValidationFailureType.COLLECTION_MIN_SIZE:return this.validationFailedForMinCollectionSizeMessage_;case e.ValidationFailureType.MINIMUM:return this.validationFailedForMinimumMessage_;case e.ValidationFailureType.MAX_LENGTH:return this.validationFailedForMaxLengthMessage_;case e.ValidationFailureType.MAXIMUM:return this.validationFailedForMaximumMessage_;case e.ValidationFailureType.MIN_LENGTH:return this.validationFailedForMinLengthMessage_;case e.ValidationFailureType.PATTERN:return this.validationFailedForPatternMessage_;case e.ValidationFailureType.REQUIRED:return this.validationFailedForRequiredMessage_;case e.ValidationFailureType.TYPE_EMAIL:return this.validationFailedForEmailTypeMessage_;case e.ValidationFailureType.TYPE_INTEGER:return this.validationFailedForIntegerTypeMessage_;case e.ValidationFailureType.TYPE_NEGATIVE:return this.validationFailedForNegativeTypeMessage_;case e.ValidationFailureType.TYPE_NON_NEGATIVE:return this.validationFailedForNonNegativeTypeMessage_;case e.ValidationFailureType.TYPE_NUMERIC:return this.validationFailedForNumericTypeMessage_;case e.ValidationFailureType.TYPE_POSITIVE:return this.validationFailedForPositiveTypeMessage_}},t.prototype.setDefaultDebounceDuration=function(e){this.defaultDebounceDuration_=e},t.prototype.setDefaultSubmitComplete=function(e){this.defaultSubmitComplete_=e},t.prototype.setDefaultSubmitError=function(e){this.defaultSubmitError_=e},t.prototype.setDefaultValidationFailed=function(e){this.defaultValidationFailed_=e},t.prototype.setRequiredLabel=function(e){this.requiredLabel_=e},t.prototype.setValidationFailedForCustomMessage=function(e){this.validationFailedForCustomMessage_=e},t.prototype.setValidationFailedForMaxCollectionSizeMessage=function(e){this.validationFailedForMaxCollectionSizeMessage_=e},t.prototype.setValidationFailedForMaximumMessage=function(e){this.validationFailedForMaximumMessage_=e},t.prototype.setValidationFailedForMaxLengthMessage=function(e){this.validationFailedForMaxLengthMessage_=e},t.prototype.setValidationFailedForMinCollectionSizeMessage=function(e){this.validationFailedForMaxCollectionSizeMessage_=e},t.prototype.setValidationFailedForMinimumMessage=function(e){this.validationFailedForMinimumMessage_=e},t.prototype.setValidationFailedForMinLengthMessage=function(e){this.validationFailedForMinLengthMessage_=e},t.prototype.setValidationFailedForPatternMessage=function(e){this.validationFailedForPatternMessage_=e},t.prototype.setValidationFailedForRequiredMessage=function(e){this.validationFailedForRequiredMessage_=e},t.prototype.setValidationFailedForEmailTypeMessage=function(e){this.validationFailedForEmailTypeMessage_=e},t.prototype.setValidationFailedForIntegerTypeMessage=function(e){this.validationFailedForIntegerTypeMessage_=e},t.prototype.setValidationFailedForNegativeTypeMessage=function(e){this.validationFailedForNegativeTypeMessage_=e},t.prototype.setValidationFailedForNonNegativeTypeMessage=function(e){this.validationFailedForNonNegativeTypeMessage_=e},t.prototype.setValidationFailedForNumericTypeMessage=function(e){this.validationFailedForNumericTypeMessage_=e},t.prototype.setValidationFailedForPositiveTypeMessage=function(e){this.validationFailedForPositiveTypeMessage_=e},t}();e.FormForConfiguration=t,angular.module("formFor").service("FormForConfiguration",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(e){this.formForConfiguration_=e}return t.prototype.manageLabel=function(t,r,i){r.hasOwnProperty("label")&&r.$observe("label",function(e){t.label=e}),this.formForConfiguration_.autoGenerateLabels&&(t.label=e.StringUtil.humanize(i?t.value:t.attribute))},t.prototype.manageFieldRegistration=function(e,t,r){e.$watch("attribute",function(i,o){e.model&&r.unregisterFormField(o),e.model=r.registerFormField(e.attribute),t.uid&&(e.model.uid=t.uid)}),e.$on("$destroy",function(){r.unregisterFormField(e.attribute)})},t}();e.FieldHelper=t,angular.module("formFor").service("FieldHelper",["FormForConfiguration",function(e){return new t(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function e(e,i){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/checkbox-field.html",this.scope={attribute:"@",disable:"=",help:"@?",changed:"@?"},t=e,r=i}return e.$inject=["$log","fieldHelper"],e.prototype.link=function(e,i,o,n){return e.attribute?(e.tabIndex=o.tabIndex||0,e.toggle=function(){e.disable||e.model.disabled||(e.model.bindable=!e.model.bindable)},r.manageLabel(e,o,!1),void r.manageFieldRegistration(e,o,n)):void t.error('Missing required field "attribute"')},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.CheckboxFieldDirective=i,angular.module("formFor").directive("checkboxField",["$log","FieldHelper",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r=function(){function e(e){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/collection-label.html",this.scope={attribute:"@",help:"@?",label:"@"},t=e}return e.$inject=["$sce"],e.prototype.link=function(e,r,i,o){e.$watch("label",function(r){e.bindableLabel=t.trustAsHtml(r)}),e.model=o.registerCollectionLabel(e.attribute)},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.CollectionLabelDirective=r,angular.module("formFor").directive("collectionLabel",["$sce",function(e){return new r(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){this.restrict="EA",this.templateUrl="form-for/templates/field-error.html",this.scope={error:"=",leftAligned:"@?",uid:"@"}}return e.prototype.link=function(){},e.prototype.link.$inject=["$scope"],e}();e.FieldErrorDirective=t,angular.module("formFor").directive("fieldError",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function e(e,i){this.replace=!0,this.restrict="EA",this.templateUrl="form-for/templates/field-label.html",this.scope={inputUid:"@",help:"@?",label:"@",required:"@?",uid:"@"},t=e,r=i}return e.$inject=["$sce","formForConfiguration"],e.prototype.link=function(e,i,o){e.attributes=o,e.$watch("label",function(r){e.bindableLabel=t.trustAsHtml(r)}),e.$watch("required",function(t){e.requiredLabel=e.$eval(t)?r.requiredLabel:null})},e.prototype.link.$inject=["$scope","$element","$attributes"],e}();e.FieldLabelDirective=i,angular.module("formFor").directive("fieldLabel",["$sce","FormForConfiguration",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function i(i,o){this.require="formFor",this.restrict="A",t=i,r=new e.NestedObjectHelper(o)}return i.$inject=["$compile","$parse"],i.prototype.link=function(i,o,n,a){var l;n.formForBuilder?l=i.$eval(n.formForBuilder):n.validationRules?l=i.$eval(n.validationRules):n.$service&&(l=i.$eval(n.$service.validationRules));for(var u=r.flattenObjectKeys(l),s="",d=0,f=u.length;f>d;d++){var c=u[d],p=r.readAttribute(l,c);if(p&&p.hasOwnProperty("inputType")){var m,F=p.help||"",b=p.label||"",h=p.uid||"",v=b?'label="'+b+'"':"";switch(p.inputType){case e.BuilderFieldType.CHECKBOX:s+='<checkbox-field attribute="'+c+'"\n help="'+F+'"\n '+v+'\n uid="'+h+'">\n </checkbox-field>';break;case e.BuilderFieldType.RADIO:m=JSON.stringify(p.values).replace(/"/g,"&quot;"),s+='<radio-field attribute="'+c+'"\n '+v+'\n options="'+m+'"\n uid="'+h+'">\n </radio-field>';break;case e.BuilderFieldType.SELECT:m=JSON.stringify(p.values).replace(/"/g,"&quot;"),s+='<select-field attribute="'+c+'"\n '+(p.allowBlank?"allow-blank":"")+"\n "+(p.enableFiltering?"enable-filtering":"")+'\n help="'+F+'"\n '+v+"\n "+v+'\n multiple="'+!!p.multipleSelection+'"\n options="'+m+'"\n uid="'+h+'"\n value-attribute="'+(p.valueAttribute||"")+'">\n </select-field>';break;case e.BuilderFieldType.NUMBER:case e.BuilderFieldType.PASSWORD:case e.BuilderFieldType.TEXT:s+='<text-field attribute="'+c+'"\n '+v+'\n help="'+F+'"\n ng-attr-multiline="'+!!p.multiline+'"\n rows="'+(p.rows||"")+'"\n type="'+p.inputType+'"\n uid="'+h+'">\n </text-field>'}}}0===o.find("input[type=button], button, submit-button").length&&(s+='<submit-button label="Submit"></submit-button>');var g=t(s),_=g(i,void 0,{transcludeControllers:a});o.prepend(_)},i.prototype.link.$inject=["$scope","$element","$attributes","formForController"],i}();e.FormForBuilderDirective=i,angular.module("formFor").directive("formForBuilder",["$compile","$parse",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o,n=function(){function e(e,n,a,l){this.priority=99,this.require="ngModel",this.restrict="A",this.scope={formForDebounce:"@"},t=e,r=n,i=a,o=l}return e.$inject=["$log","$sniffer","$timeout","formForConfiguration"],e.prototype.link=function(e,n,a,l){if("radio"===a.type||"checkbox"===a.type)return void t.warn("formForDebounce should only be used with <input type=text> and <textarea> elements");var u=a.formForDebounce,s=o.defaultDebounceDuration;void 0!==u&&("false"===u.toString()?s=!1:(u=parseInt(u),angular.isNumber(u)&&!isNaN(u)&&(s=u))),r.hasEvent("input")?n.off("input"):(n.off("keydown"),r.hasEvent("paste")&&n.off("paste"));var d;if(s!==!1){var f=function(){i.cancel(d),d=i(function(){e.$apply(function(){l.$setViewValue(n.val())})},s)};r.hasEvent("input")?n.on("input",void 0,f):(n.on("keydown",void 0,f),r.hasEvent("paste")&&n.on("paste",void 0,f))}n.on("blur",void 0,function(){e.$apply(function(){l.$setViewValue(n.val())})}),e.$on("$destroy",function(){d&&i.cancel(d)})},e.prototype.link.$inject=["$scope","$element","$attributes","ngModelController"],e}();e.FormForDebounceDirective=n,angular.module("formFor").directive("formForDebounce",["$log","$sniffer","$timeout","FormForConfiguration",function(e,t,r,i){return new n(e,t,r,i)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){this.require="ngInclude",this.restrict="A"}return e.prototype.link=function(e,t){t.replaceWith(t.children())},e.prototype.link.$inject=["$scope","$element","$attributes"],e}();e.FormForIncludeReplaceDirective=t,angular.module("formFor").directive("formForIncludeReplace",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(e){this.$parse_=e}return e.prototype.flattenAttribute=function(e){return e.replace(/\[([^\]]+)\]\.{0,1}/g,"___$1___").replace(/\./g,"___")},e.prototype.flattenObjectKeys=function(e){for(var t=[],r=[{object:e,prefix:null}];;){if(0===r.length)break;var i=r.pop(),o=Array.isArray(i.object),n=i.prefix?i.prefix+(o?"[":"."):"",a=o?"]":"";if("object"==typeof i.object)for(var l in i.object){var u=n+l+a,s=i.object[l];t.push(u),r.push({object:s,prefix:u})}}return t},e.prototype.readAttribute=function(e,t){return this.$parse_(t)(e)},e.prototype.writeAttribute=function(e,t,r){this.initializeArraysAndObjectsForParse_(e,t),this.$parse_(t).assign(e,r)},e.prototype.initializeArraysAndObjectsForParse_=function(e,t){for(var r=0;;){if(r=t.indexOf("[",r),0>r)break;var i=t.substr(0,r),o=this.readAttribute(e,i);o||(o=[],this.writeAttribute(e,i,o));var n=t.substr(r).match(/([0-9]+)\]\./);if(n){var a=parseInt(n[1]);o[a]||(o[a]={})}r++}},e}();e.NestedObjectHelper=t}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(e){this.$q_=e}return e.prototype.all=function(e){return this.$q_.all(e)},e.prototype.defer=function(){return this.$q_.defer()},e.prototype.resolve=function(e){var t=this.$q_.defer();return t.resolve(e),t.promise},e.prototype.reject=function(e){return this.$q_.reject(e)},e.prototype.waitForAll=function(e){function t(e,t){o.hasOwnProperty(e)||(o[e]=t,n--),r()}function r(){0===n&&(a?i.reject(o):i.resolve(o))}var i=this.$q_.defer(),o={},n=0,a=!1;return angular.forEach(e,function(e,r){n++,e.then(function(e){t(r,e)},function(e){a=!0,t(r,e)})}),r(),i.promise},e.prototype.when=function(e){return this.$q_.when(e)},e}();e.PromiseUtils=t}(formFor||(formFor={}));var formFor;!function(e){function t(t,r,i,o,n){var a=new e.NestedObjectHelper(r),l=new e.PromiseUtils(i);return t.registerCollectionLabel=function(e){var t=a.flattenAttribute(e),r={error:null,required:n.isCollectionRequired(e,o.$validationRuleset)};o.collectionLabels[t]=r;var i=!1;return o.$watch("formFor."+e+".length",function(){i?o.validateOn&&"change"!==o.validateOn||n.validateCollection(o.formFor,e,o.$validationRuleset).then(function(){o.formForStateHelper.setFieldError(t,null)},function(e){o.formForStateHelper.setFieldError(t,e)}):i=!0}),r},t.registerFormField=function(i){if(!i)throw Error('Invalid field name "'+i+'" provided.');var l=a.flattenAttribute(i);if(o.fields.hasOwnProperty(l))throw Error('Field "'+i+'" has already been registered. Field names must be unique.');var u={bindable:null,disabled:o.disable,error:null,pristine:!0,required:n.isFieldRequired(i,o.$validationRuleset),uid:e.FormForGUID.create()},s={bindableWrapper:u,fieldName:i,formForStateHelper:o.formForStateHelper,unwatchers:[]};o.fields[l]=s;var d=r(i),f=d.assign;s.unwatchers.push(o.$watch("fields."+l+".bindableWrapper.bindable",function(e,t){e!==t&&f(o.formFor,e)}));var c;return s.unwatchers.push(o.$watch("formFor."+i,function(e,r){(e!==s.bindableWrapper.bindable||void 0===r&&""===e||void 0===e)&&(c=!1),s.bindableWrapper.bindable=e,o.validateOn&&"change"!==o.validateOn||t.validateField(i),c||(c=!0,o.formForStateHelper.setFieldHasBeenModified(l,!1)),s.bindableWrapper.pristine=!o.formForStateHelper.hasFieldBeenModified(l)})),u},t.registerSubmitButton=function(){var e={disabled:!1};return o.buttons.push(e),e},t.resetErrors=function(){for(var e in o.fields)o.formForStateHelper.getFieldError(e)&&(o.formForStateHelper.setFieldHasBeenModified(e,!1),o.fields[e].bindableWrapper.pristine=!0);o.formForStateHelper.setFormSubmitted(!1),o.formForStateHelper.resetFieldErrors()},t.resetField=function(e){var t=a.flattenAttribute(e);o.formForStateHelper.getFieldError(t)&&(o.formForStateHelper.setFieldHasBeenModified(t,!1),o.fields[t].bindableWrapper.pristine=!0),o.formForStateHelper.setFieldError(t,null)},t.resetFields=function(){t.resetErrors()},t.setFieldError=function(e,t){var r=a.flattenAttribute(e);o.formForStateHelper.setFieldHasBeenModified(r,!0),o.formForStateHelper.setFieldError(r,t)},t.unregisterFormField=function(e){var t=a.flattenAttribute(e);angular.forEach(o.fields[t].unwatchers,function(e){e()}),delete o.fields[t]},t.updateCollectionErrors=function(e){angular.forEach(o.collectionLabels,function(t,r){var i=a.readAttribute(e,r);o.formForStateHelper.setFieldError(r,i)})},t.updateFieldErrors=function(e){angular.forEach(o.fields,function(t,r){var i=a.readAttribute(e,t.fieldName);o.formForStateHelper.setFieldError(r,i)})},t.validateField=function(e){var t=a.flattenAttribute(e);o.formForStateHelper.setFieldHasBeenModified(t,!0),o.$validationRuleset&&n.validateField(o.formFor,e,o.$validationRuleset).then(function(){o.formForStateHelper.setFieldError(t,null)},function(e){o.formForStateHelper.setFieldError(t,e)})},t.validateForm=function(e){t.updateCollectionErrors({}),t.updateFieldErrors({});var r,i;if(o.$validationRuleset){var u=[];angular.forEach(o.fields,function(e){u.push(e.fieldName)}),i=n.validateFields(o.formFor,u,o.$validationRuleset),i.then(angular.noop,t.updateFieldErrors),u=[],angular.forEach(o.collectionLabels,function(e,t){u.push(t)}),r=n.validateFields(o.formFor,u,o.$validationRuleset),r.then(angular.noop,t.updateCollectionErrors)}else r=l.resolve(),i=l.resolve();var s=l.defer();return l.waitForAll([r,i]).then(s.resolve,function(t){angular.isArray(t[0])&&0===t[0].length&&t.splice(0,1),e&&angular.forEach(t,function(e){var t=a.flattenObjectKeys(e);angular.forEach(t,function(t){var r=a.readAttribute(e,t);if(r){var i=a.flattenAttribute(t);o.formForStateHelper.setFieldHasBeenModified(i,!0)}})}),s.reject(t)}),s.promise},t}e.createFormForController=t}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o,n,a,l,u=function(){function u(u){this.require="form",this.restrict="A",this.scope={controller:"=?",disable:"=?",formFor:"=",service:"@",submitComplete:"&?",submitError:"&?",submitWith:"&?",valid:"=?",validateOn:"=?",validationFailed:"&?",validationRules:"=?"},t=u,r=u.get("$log"),i=u.get("$parse"),o=u.get("$sce"),n=u.get("FormForConfiguration"),a=u.get("ModelValidator"),l=new e.PromiseUtils(u.get("$q"))}return u.$inject=["$injector"],u.prototype.controller=function(n){n.formFor||r.error('The form data object specified by <form form-for=""> is null or undefined.'),n.fields={},n.collectionLabels={},n.buttons=[],n.controller=n.controller||{},n.service&&(n.$service=t.get(n.service)),n.validationRules?n.$validationRuleset=n.validationRules:n.$service&&(n.$validationRuleset=n.$service.validationRules),e.createFormForController(this,i,l,n,a),n.controller&&angular.copy(this,n.controller),n.$watch("disable",function(e){angular.forEach(n.fields,function(t){t.bindableWrapper.disabled=e}),angular.forEach(n.buttons,function(t){t.disabled=e})}),n.formForStateHelper=new e.FormForStateHelper(i,n),n.$watch("formForStateHelper.watchable",function(){var e=n.formForStateHelper.hasFormBeenSubmitted();angular.forEach(n.fields,function(t,r){if(e||n.formForStateHelper.hasFieldBeenModified(r)){var i=n.formForStateHelper.getFieldError(r);t.bindableWrapper.error=i?o.trustAsHtml(i):null}else t.bindableWrapper.error=null}),angular.forEach(n.collectionLabels,function(e,t){var r=n.formForStateHelper.getFieldError(t);e.error=r?o.trustAsHtml(r):null})})},u.prototype.controller.$inject=["$scope"],u.prototype.link=function(e,t,r){t.on("submit",void 0,function(){e.formForStateHelper.setFormSubmitted(!0),e.disable=!0;var t;return t="manual"===e.validateOn?l.resolve():e.controller.validateForm(),t.then(function(){var t;t=r.submitWith?e.submitWith({data:e.formFor}):e.$service&&e.$service.submit?e.$service.submit(e.formFor):l.reject("No submit function provided"),t||(t=l.reject("Submit function did not return a promise")),t.then(function(t){r.submitComplete?e.submitComplete({data:t}):n.defaultSubmitComplete(t)},function(t){angular.isObject(t)&&"manual"!==e.validateOn&&(e.controller.updateCollectionErrors(t),e.controller.updateFieldErrors(t)),r.submitError?e.submitError({error:t}):n.defaultSubmitError(t)}),t["finally"](function(){e.disable=!1})},function(t){e.disable=!1,r.validationFailed?e.validationFailed():n.defaultValidationFailed(t)}),!1})},u.prototype.link.$inject=["$scope","$element","$attributes"],u}();e.FormForDirective=u,angular.module("formFor").directive("formFor",["$injector",function(e){return new u(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){}return e.create=function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)},e}();e.FormForGUID=t}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function i(i,o){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/radio-field.html",this.scope={attribute:"@",disable:"=",help:"@?",options:"=",value:"@"},r=new e.FieldHelper(o),t=i}return i.$inject=["$log","FormForConfiguration"],i.prototype.link=function(i,o,n,a){return i.attribute?(i.labelAttribute=n.labelAttribute||"label",i.valueAttribute=n.valueAttribute||"value",r.manageFieldRegistration(i,n,a),i.uid=n.uid||e.FormForGUID.create(),r.manageLabel(i,n,!0),i.tabIndex=n.tabIndex||0,i.click=function(){!i.disable&&!i.model.disabled},i.$watch("model",function(e){i.model=e}),i.$watch("disable",function(e){i.disable=e}),void i.$watch("model.disabled",function(e){i.model&&(i.model.disabled=e)})):void t.error('Missing required field "attribute"')},i.prototype.link.$inject=["$scope","$element","$attributes","formForController"],i}();e.RadioFieldDirective=i,angular.module("formFor").directive("radioField",["$log","FormForConfiguration",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o,n=10,a=function(){function e(e,n,a,l){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/select-field.html",this.scope={attribute:"@",disable:"=",filterDebounce:"@?",help:"@?",multiple:"=?",options:"="},t=e,r=n,i=a,o=l}return e.$inject=["$document","$log","$timeout","fieldHelper"],e.prototype.link=function(e,a,l,u){if(!e.attribute)return void r.error('Missing required field "attribute"');e.allowBlank=l.hasOwnProperty("allowBlank"),e.enableFiltering=l.hasOwnProperty("enableFiltering"),e.preventDefaultOption=l.hasOwnProperty("preventDefaultOption"),e.labelAttribute=l.labelAttribute||"label",e.valueAttribute=l.valueAttribute||"value",e.placeholder=l.hasOwnProperty("placeholder")?l.placeholder:"Select",e.tabIndex=l.tabIndex||0,e.scopeBuster={},o.manageLabel(e,l,!1),o.manageFieldRegistration(e,l,u);var s,d=function(){s||(s=a.find("input")),i(s.focus.bind(s))};e.close=function(){i(function(){e.isOpen=!1})},e.open=function(){e.disable||e.model.disabled||i(function(){e.isOpen=!0})},e.emptyOption={},e.emptyOption[e.labelAttribute]="",e.emptyOption[e.valueAttribute]=void 0,e.placeholderOption={},e.placeholderOption[e.labelAttribute]=e.placeholder,e.placeholderOption[e.valueAttribute]=void 0,e.filteredOptions=[];var f=function(e){return"string"==typeof e?e.toLowerCase():""},c=function(){var t=e.options||[];if(e.filteredOptions.splice(0),e.enableFiltering&&e.scopeBuster.filter){var r=f(e.scopeBuster.filter);angular.forEach(t,function(t){var i=f(t[e.labelAttribute]).indexOf(r);i>=0&&e.filteredOptions.push(t)})}else angular.copy(t,e.filteredOptions);e.selectedOption||e.multiple||e.enableFiltering?e.allowBlank&&e.filteredOptions.unshift(e.emptyOption):e.filteredOptions.unshift(e.placeholderOption)};e.$watch("scopeBuster.filter",c),e.$watch("options.length",c);var p=function(){var t=e.selectedOption&&e.selectedOption[e.valueAttribute],r=e.options&&e.options.length;t!==e.model.bindable||e.allowBlank||e.preventDefaultOption||!r||(e.model.bindable=e.options[0][e.valueAttribute])};e.$watch("model.bindable",p),e.$watch("options.length",p),e.$watch("model.bindable",function(){var t=null;angular.forEach(e.options,function(r){r[e.valueAttribute]===e.model.bindable&&(t=r)}),t&&(e.selectedOption=t,e.selectedOptionLabel=t[e.labelAttribute]),e.scopeBuster.filter=e.selectedOptionLabel});var m=function(t){t.ignoreFor!==e.model.uid&&e.close()};e.filterTextClick=function(t){e.isOpen&&(t.ignoreFor=e.model.uid)};var F;e.$watch("isOpen",function(){F&&i.cancel(F),F=i(function(){F=null,e.isOpen?t.on("click",void 0,m):t.off("click",void 0,m)},n)}),e.$on("$destroy",function(){t.off("click",m)}),e.setFilterFocus=function(){d()},e.mouseOver=function(t){e.mouseOverIndex=t,e.mouseOverOption=t>=0?e.filteredOptions[t]:null},e.selectOption=function(t){e.model.bindable=t&&t[e.valueAttribute]},e.keyDown=function(t){switch(t.keyCode){case 27:e.close();break;case 13:e.isOpen?(e.selectOption(e.mouseOverOption),e.close()):e.open(),t.preventDefault();break;case 38:e.isOpen?e.mouseOver(e.mouseOverIndex>0?e.mouseOverIndex-1:e.filteredOptions.length-1):e.open();break;case 40:e.isOpen?e.mouseOver(e.mouseOverIndex<e.filteredOptions.length-1?e.mouseOverIndex+1:0):e.open();break;case 9:case 16:e.close();break;default:e.open()}},e.$watchCollection("[isOpen, filteredOptions.length]",function(){e.mouseOver(-1),e.isOpen&&e.enableFiltering&&d()})},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.SelectFieldDirective=a,angular.module("formFor").directive("selectField",["$document","$log","$timeout","FieldHelper",function(e,t,r,i){return new a(e,t,r,i)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r=function(){function e(e){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/submit-button.html",this.scope={disable:"=",icon:"@",label:"@"},t=e}return e.$inject=["$sce"],e.prototype.link=function(e,r,i,o){e.buttonClass=i.buttonClass,e.tabIndex=i.tabIndex||0,e.$watch("label",function(r){e.bindableLabel=t.trustAsHtml(r)}),e.model=o.registerSubmitButton(e)},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.SubmitButtonDirective=r,angular.module("formFor").directive("submitButton",["$sce",function(e){return new r(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o=function(){function e(e,o,n){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/text-field.html",this.scope={attribute:"@",debounce:"@?",disable:"=",focused:"&?",blurred:"&?",help:"@?",iconAfterClicked:"&?",iconBeforeClicked:"&?",placeholder:"@?",rows:"=?"},t=e,r=o,i=n}return e.$inject=["$log","$timeout","fieldHelper"],e.prototype.link=function(e,o,n,a){if(!e.attribute)return void t.error('Missing required field "attribute"');if(e.attributes=n,e.rows=e.rows||3,e.type=n.type||"text",e.multiline=n.hasOwnProperty("multiline")&&"false"!==n.multiline,e.tabIndex=n.tabIndex||0,n.hasOwnProperty("autofocus")&&r(function(){o.find(e.multiline?"textarea":"input")[0].focus()}),i.manageLabel(e,n,!1),i.manageFieldRegistration(e,n,a),n.iconAfter){var l=function(){if(e.model){var t="{"===n.iconAfter.charAt(0)?e.$eval(n.iconAfter):n.iconAfter;e.iconAfter=angular.isObject(t)?e.model.error?t.invalid:e.model.pristine?t.pristine:t.valid:t}};n.$observe("iconAfter",l),e.$watch("model.error",l),e.$watch("model.pristine",l)}if(n.iconBefore){var u=function(){if(e.model){var t="{"===n.iconBefore.charAt(0)?e.$eval(n.iconBefore):n.iconBefore;e.iconBefore=angular.isObject(t)?e.model.error?t.invalid:e.model.pristine?t.pristine:t.valid:t}};n.$observe("iconBefore",u),e.$watch("model.error",u),e.$watch("model.pristine",u)}e.onIconAfterClick=function(){n.hasOwnProperty("iconAfterClicked")&&e.iconAfterClicked()},e.onIconBeforeClick=function(){n.hasOwnProperty("iconBeforeClicked")&&e.iconBeforeClicked()},e.onFocus=function(){n.hasOwnProperty("focused")&&e.focused()},e.onBlur=function(){n.hasOwnProperty("blurred")&&e.blurred()}},e}();e.TextFieldDirective=o,angular.module("formFor").directive("textField",["$log","$timeout","FieldHelper",function(e,t,r){return new o(e,t,r)}])}(formFor||(formFor={}));var formFor;!function(e){!function(e){e[e.CHECKBOX="checkbox"]="CHECKBOX",e[e.NUMBER="number"]="NUMBER",e[e.PASSWORD="password"]="PASSWORD",e[e.RADIO="radio"]="RADIO",e[e.SELECT="select"]="SELECT",e[e.TEXT="text"]="TEXT"}(e.BuilderFieldType||(e.BuilderFieldType={}));e.BuilderFieldType}(formFor||(formFor={}));var formFor;!function(e){!function(e){e[e.COLLECTION_MAX_SIZE="COLLECTION_MAX_SIZE"]="COLLECTION_MAX_SIZE",e[e.COLLECTION_MIN_SIZE="COLLECTION_MIN_SIZE"]="COLLECTION_MIN_SIZE",e[e.CUSTOM="CUSTOM"]="CUSTOM",e[e.MAXIMUM="MAXIMUM"]="MAXIMUM",e[e.MAX_LENGTH="MAX_LENGTH"]="MAX_LENGTH",e[e.MINIMUM="MINIMUM"]="MINIMUM",e[e.MIN_LENGTH="MIN_LENGTH"]="MIN_LENGTH",e[e.PATTERN="PATTERN"]="PATTERN",e[e.REQUIRED="REQUIRED_FIELD"]="REQUIRED",e[e.TYPE_EMAIL="TYPE_EMAIL"]="TYPE_EMAIL",e[e.TYPE_INTEGER="TYPE_INTEGER"]="TYPE_INTEGER",e[e.TYPE_NEGATIVE="TYPE_NEGATIVE"]="TYPE_NEGATIVE",e[e.TYPE_NON_NEGATIVE="TYPE_NON_NEGATIVE"]="TYPE_NON_NEGATIVE",e[e.TYPE_NUMERIC="TYPE_NUMERIC"]="TYPE_NUMERIC",e[e.TYPE_POSITIVE="TYPE_POSITIVE"]="TYPE_POSITIVE"}(e.ValidationFailureType||(e.ValidationFailureType={}));e.ValidationFailureType}(formFor||(formFor={}));var formFor;!function(e){!function(e){e[e.EMAIL="email"]="EMAIL",e[e.INTEGER="integer"]="INTEGER",e[e.NEGATIVE="negative"]="NEGATIVE",e[e.NON_NEGATIVE="nonNegative"]="NON_NEGATIVE",e[e.NUMBER="number"]="NUMBER",e[e.POSITIVE="positive"]="POSITIVE"}(e.ValidationFieldType||(e.ValidationFieldType={}));e.ValidationFieldType}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){}return e}();e.BindableFieldWrapper=t}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(t,r,i,o){this.$interpolate_=t,this.formForConfiguration_=o,this.nestedObjectHelper_=new e.NestedObjectHelper(r),
this.promiseUtils_=new e.PromiseUtils(i)}return t.prototype.isCollectionRequired=function(e,t){var r=this.getRulesFor_(e,t);return r&&r.collection&&r.collection.min?angular.isObject(r.collection.min)?r.collection.min.rule>0:r.collection.min>0:!1},t.prototype.isFieldRequired=function(e,t){var r=this.getRulesFor_(e,t);return r&&r.required?angular.isObject(r.required)?r.required.rule:!!r.required:!1},t.prototype.validateAll=function(e,t){var r=this.nestedObjectHelper_.flattenObjectKeys(e);return this.validateFields(e,r,t)},t.prototype.validateCollection=function(e,t,r){var i=this.getRulesFor_(t,r),o=this.nestedObjectHelper_.readAttribute(e,t);return i&&i.collection?(o=o||[],this.validateCollectionMinLength_(o,i.collection)||this.validateCollectionMaxLength_(o,i.collection)||this.promiseUtils_.resolve()):this.promiseUtils_.resolve()},t.prototype.validateField=function(e,t,r){var i=this.getRulesFor_(t,r),o=this.nestedObjectHelper_.readAttribute(e,t);return i?((void 0===o||null===o)&&(o=""),this.validateFieldRequired_(o,i)||this.validateFieldMinimum_(o,i)||this.validateFieldMinLength_(o,i)||this.validateFieldMaximum_(o,i)||this.validateFieldMaxLength_(o,i)||this.validateFieldType_(o,i)||this.validateFieldPattern_(o,i)||this.validateFieldCustom_(o,e,i)||this.promiseUtils_.resolve()):this.promiseUtils_.resolve()},t.prototype.validateFields=function(e,t,r){var i=this,o=this.promiseUtils_.defer(),n=[],a={};return angular.forEach(t,function(t){var o=i.getRulesFor_(t,r);if(o){var l;l=o.collection?i.validateCollection(e,t,r):i.validateField(e,t,r),l.then(angular.noop,function(e){i.nestedObjectHelper_.writeAttribute(a,t,e)}),n.push(l)}},this),this.promiseUtils_.waitForAll(n).then(o.resolve,function(){o.reject(a)}),o.promise},t.prototype.getRulesFor_=function(e,t){var r=e.replace(/\[[^\]]+\]/g,".collection.fields");return this.nestedObjectHelper_.readAttribute(t,r)},t.prototype.getFieldTypeFailureMessage_=function(e,t){return angular.isObject(e.type)?e.type.message:this.formForConfiguration_.getFailedValidationMessage(t)},t.isConsideredNumeric_=function(e,t){return e&&!isNaN(t)},t.prototype.validateCollectionMinLength_=function(t,r){if(r.min){var i=angular.isObject(r.min)?r.min.rule:r.min;if(t.length<i){var o;return o=angular.isObject(r.min)?r.min.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.COLLECTION_MIN_SIZE))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateCollectionMaxLength_=function(t,r){if(r.max){var i=angular.isObject(r.max)?r.max.rule:r.max;if(t.length>i){var o;return o=angular.isObject(r.max)?r.max.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.COLLECTION_MAX_SIZE))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateFieldCustom_=function(t,r,i){var o=this;if(i.custom){var n,a;angular.isFunction(i.custom)?(n=this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.CUSTOM),a=i.custom):(n=i.custom.message,a=i.custom.rule);try{var l=a(t,r)}catch(u){return this.promiseUtils_.reject(u.message||n)}return angular.isObject(l)&&angular.isFunction(l.then)?l.then(function(e){return o.promiseUtils_.resolve(e)},function(e){return o.promiseUtils_.reject(e||n)}):l?this.promiseUtils_.resolve(l):this.promiseUtils_.reject(n)}return null},t.prototype.validateFieldMaximum_=function(t,r){if(r.maximum){var i=t.toString(),o=Number(t),n=angular.isObject(r.maximum)?r.maximum.rule:r.maximum;if(i&&!isNaN(o)&&o>n){var a;return a=angular.isObject(r.maximum)?r.maximum.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MAXIMUM))({num:n}),this.promiseUtils_.reject(a)}}return null},t.prototype.validateFieldMaxLength_=function(t,r){if(r.maxlength){var i=angular.isObject(r.maxlength)?r.maxlength.rule:r.maxlength;if(t.length>i){var o;return o=angular.isObject(r.maxlength)?r.maxlength.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MAX_LENGTH))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateFieldMinimum_=function(t,r){if(r.minimum){var i=t.toString(),o=Number(t),n=angular.isObject(r.minimum)?r.minimum.rule:r.minimum;if(i&&!isNaN(o)&&n>o){var a;return a=angular.isObject(r.minimum)?r.minimum.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MINIMUM))({num:n}),this.promiseUtils_.reject(a)}}return null},t.prototype.validateFieldMinLength_=function(t,r){if(r.minlength){var i=angular.isObject(r.minlength)?r.minlength.rule:r.minlength;if(t&&t.length<i){var o;return o=angular.isObject(r.minlength)?r.minlength.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MIN_LENGTH))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateFieldRequired_=function(t,r){if(r.required){var i=angular.isObject(r.required)?r.required.rule:r.required,o=t.toString().replace(/\s+$/,""),n=Number(t);if(i&&!o&&!n){var a;return a=angular.isObject(r.required)?r.required.message:this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.REQUIRED),this.promiseUtils_.reject(a)}}return null},t.prototype.validateFieldPattern_=function(t,r){if(r.pattern){var i=r.pattern instanceof RegExp,o=i?r.pattern:r.pattern.rule;if(!o.exec(t)){var n=i?this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.PATTERN):r.pattern.message;return this.promiseUtils_.reject(n)}}return null},t.prototype.validateFieldType_=function(r,i){if(i.type){var o=angular.isObject(i.type)?i.type.rule:i.type,n=r.toString(),a=Number(r);if(o)for(var l=o.split(" "),u=0,s=l.length;s>u;u++){var d=l[u];switch(d){case e.ValidationFieldType.INTEGER:if(n&&(isNaN(a)||a%1!==0))return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_INTEGER));break;case e.ValidationFieldType.NUMBER:if(n&&isNaN(a))return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_NUMERIC));break;case e.ValidationFieldType.NEGATIVE:if(t.isConsideredNumeric_(n,a)&&a>=0)return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_NEGATIVE));break;case e.ValidationFieldType.NON_NEGATIVE:if(t.isConsideredNumeric_(n,a)&&0>a)return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_NON_NEGATIVE));break;case e.ValidationFieldType.POSITIVE:if(t.isConsideredNumeric_(n,a)&&0>=a)return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_POSITIVE));break;case e.ValidationFieldType.EMAIL:if(n&&!n.match(/^.+@.+\..+$/))return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_EMAIL))}}}return null},t}();e.ModelValidator=t,angular.module("formFor").service("ModelValidator",["$interpolate","$parse","$q","FormForConfiguration",function(e,r,i,o){return new t(e,r,i,o)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(t,r){this.formForScope_=r,this.nestedObjectHelper_=new e.NestedObjectHelper(t),this.formForScope_.fieldNameToErrorMap=r.fieldNameToErrorMap||{},this.formForScope_.valid=!0,this.fieldNameToModifiedStateMap_={},this.formSubmitted_=!1,this.fieldNameToErrorMap_={},this.watchable=0}return t.prototype.getFieldError=function(e){return this.nestedObjectHelper_.readAttribute(this.formForScope_.fieldNameToErrorMap,e)},t.prototype.hasFieldBeenModified=function(e){return this.nestedObjectHelper_.readAttribute(this.fieldNameToModifiedStateMap_,e)},t.prototype.hasFormBeenSubmitted=function(){return this.formSubmitted_},t.prototype.isFormInvalid=function(){return!this.isFormValid()},t.prototype.isFormValid=function(){for(var e in this.fieldNameToErrorMap_)return!1;return!0},t.prototype.resetFieldErrors=function(){this.formForScope_.fieldNameToErrorMap={}},t.prototype.setFieldError=function(e,t){var r=this.nestedObjectHelper_.flattenAttribute(e);this.nestedObjectHelper_.writeAttribute(this.formForScope_.fieldNameToErrorMap,e,t),t?this.fieldNameToErrorMap_[r]=t:delete this.fieldNameToErrorMap_[r],this.formForScope_.valid=this.isFormValid(),this.watchable++},t.prototype.setFieldHasBeenModified=function(e,t){this.nestedObjectHelper_.writeAttribute(this.fieldNameToModifiedStateMap_,e,t),this.watchable++},t.prototype.setFormSubmitted=function(e){this.formSubmitted_=e,this.watchable++},t}();e.FormForStateHelper=t}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){}return e.humanize=function(e){return e?(e=e.replace(/[A-Z]/g,function(e){return" "+e}),e=e.replace(/_([a-z])/g,function(e,t){return" "+t.toUpperCase()}),e=e.replace(/\s+/g," "),e=e.trim(),e=e.charAt(0).toUpperCase()+e.slice(1)):""},e}();e.StringUtil=t}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));
angular.module("formFor",[]);var formFor;!function(e){var t=function(){function e(){this.restrict="A"}return e.prototype.link=function(e,t,r){e.$watch("model.uid",function(e){r.$set("ariaDescribedby",e+"-error"),r.$set("ariaLabelledby",e+"-label")}),e.$watch("model.error",function(e){r.$set("ariaInvalid",!!e)})},e.prototype.link.$inject=["$scope","$element","$attributes"],e}();e.AriaManager=t,angular.module("formFor").directive("ariaManager",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(){this.autoGenerateLabels_=!1,this.defaultDebounceDuration_=500,this.defaultSubmitComplete_=angular.noop,this.defaultSubmitError_=angular.noop,this.defaultValidationFailed_=angular.noop,this.requiredLabel_=null,this.validationFailedForCustomMessage_="Failed custom validation",this.validationFailedForEmailTypeMessage_="Invalid email format",this.validationFailedForIntegerTypeMessage_="Must be an integer",this.validationFailedForMaxCollectionSizeMessage_="Must be fewer than {{num}} items",this.validationFailedForMaximumMessage_="Must be no more than {{num}}",this.validationFailedForMaxLengthMessage_="Must be fewer than {{num}} characters",this.validationFailedForMinimumMessage_="Must be at least {{num}}",this.validationFailedForMinCollectionSizeMessage_="Must at least {{num}} items",this.validationFailedForMinLengthMessage_="Must be at least {{num}} characters",this.validationFailedForNegativeTypeMessage_="Must be negative",this.validationFailedForNonNegativeTypeMessage_="Must be non-negative",this.validationFailedForNumericTypeMessage_="Must be numeric",this.validationFailedForPatternMessage_="Invalid format",this.validationFailedForPositiveTypeMessage_="Must be positive",this.validationFailedForRequiredMessage_="Required field"}return Object.defineProperty(t.prototype,"autoGenerateLabels",{get:function(){return this.autoGenerateLabels_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultDebounceDuration",{get:function(){return this.defaultDebounceDuration_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultSubmitComplete",{get:function(){return this.defaultSubmitComplete_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultSubmitError",{get:function(){return this.defaultSubmitError_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultValidationFailed",{get:function(){return this.defaultValidationFailed_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"requiredLabel",{get:function(){return this.requiredLabel_},enumerable:!0,configurable:!0}),t.prototype.disableAutoLabels=function(){this.autoGenerateLabels_=!1},t.prototype.enableAutoLabels=function(){this.autoGenerateLabels_=!0},t.prototype.getFailedValidationMessage=function(t){switch(t){case e.ValidationFailureType.CUSTOM:return this.validationFailedForCustomMessage_;case e.ValidationFailureType.COLLECTION_MAX_SIZE:return this.validationFailedForMaxCollectionSizeMessage_;case e.ValidationFailureType.COLLECTION_MIN_SIZE:return this.validationFailedForMinCollectionSizeMessage_;case e.ValidationFailureType.MINIMUM:return this.validationFailedForMinimumMessage_;case e.ValidationFailureType.MAX_LENGTH:return this.validationFailedForMaxLengthMessage_;case e.ValidationFailureType.MAXIMUM:return this.validationFailedForMaximumMessage_;case e.ValidationFailureType.MIN_LENGTH:return this.validationFailedForMinLengthMessage_;case e.ValidationFailureType.PATTERN:return this.validationFailedForPatternMessage_;case e.ValidationFailureType.REQUIRED:return this.validationFailedForRequiredMessage_;case e.ValidationFailureType.TYPE_EMAIL:return this.validationFailedForEmailTypeMessage_;case e.ValidationFailureType.TYPE_INTEGER:return this.validationFailedForIntegerTypeMessage_;case e.ValidationFailureType.TYPE_NEGATIVE:return this.validationFailedForNegativeTypeMessage_;case e.ValidationFailureType.TYPE_NON_NEGATIVE:return this.validationFailedForNonNegativeTypeMessage_;case e.ValidationFailureType.TYPE_NUMERIC:return this.validationFailedForNumericTypeMessage_;case e.ValidationFailureType.TYPE_POSITIVE:return this.validationFailedForPositiveTypeMessage_}},t.prototype.setDefaultDebounceDuration=function(e){this.defaultDebounceDuration_=e},t.prototype.setDefaultSubmitComplete=function(e){this.defaultSubmitComplete_=e},t.prototype.setDefaultSubmitError=function(e){this.defaultSubmitError_=e},t.prototype.setDefaultValidationFailed=function(e){this.defaultValidationFailed_=e},t.prototype.setRequiredLabel=function(e){this.requiredLabel_=e},t.prototype.setValidationFailedForCustomMessage=function(e){this.validationFailedForCustomMessage_=e},t.prototype.setValidationFailedForMaxCollectionSizeMessage=function(e){this.validationFailedForMaxCollectionSizeMessage_=e},t.prototype.setValidationFailedForMaximumMessage=function(e){this.validationFailedForMaximumMessage_=e},t.prototype.setValidationFailedForMaxLengthMessage=function(e){this.validationFailedForMaxLengthMessage_=e},t.prototype.setValidationFailedForMinCollectionSizeMessage=function(e){this.validationFailedForMaxCollectionSizeMessage_=e},t.prototype.setValidationFailedForMinimumMessage=function(e){this.validationFailedForMinimumMessage_=e},t.prototype.setValidationFailedForMinLengthMessage=function(e){this.validationFailedForMinLengthMessage_=e},t.prototype.setValidationFailedForPatternMessage=function(e){this.validationFailedForPatternMessage_=e},t.prototype.setValidationFailedForRequiredMessage=function(e){this.validationFailedForRequiredMessage_=e},t.prototype.setValidationFailedForEmailTypeMessage=function(e){this.validationFailedForEmailTypeMessage_=e},t.prototype.setValidationFailedForIntegerTypeMessage=function(e){this.validationFailedForIntegerTypeMessage_=e},t.prototype.setValidationFailedForNegativeTypeMessage=function(e){this.validationFailedForNegativeTypeMessage_=e},t.prototype.setValidationFailedForNonNegativeTypeMessage=function(e){this.validationFailedForNonNegativeTypeMessage_=e},t.prototype.setValidationFailedForNumericTypeMessage=function(e){this.validationFailedForNumericTypeMessage_=e},t.prototype.setValidationFailedForPositiveTypeMessage=function(e){this.validationFailedForPositiveTypeMessage_=e},t}();e.FormForConfiguration=t,angular.module("formFor").service("FormForConfiguration",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(e){this.formForConfiguration_=e}return t.prototype.manageLabel=function(t,r,i){r.hasOwnProperty("label")&&r.$observe("label",function(e){t.label=e}),this.formForConfiguration_.autoGenerateLabels&&(t.label=e.StringUtil.humanize(i?t.value:t.attribute))},t.prototype.manageFieldRegistration=function(e,t,r){e.$watch("attribute",function(i,o){e.model&&r.unregisterFormField(o),e.model=r.registerFormField(e.attribute),t.uid&&(e.model.uid=t.uid)}),e.$on("$destroy",function(){r.unregisterFormField(e.attribute)})},t}();e.FieldHelper=t,angular.module("formFor").service("FieldHelper",["FormForConfiguration",function(e){return new t(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function e(e,i){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/checkbox-field.html",this.scope={attribute:"@",disable:"=",help:"@?",changed:"@?"},t=e,r=i}return e.$inject=["$log","fieldHelper"],e.prototype.link=function(e,i,o,n){return e.attribute?(e.tabIndex=o.tabIndex||0,e.toggle=function(){e.disable||e.model.disabled||(e.model.bindable=!e.model.bindable)},r.manageLabel(e,o,!1),void r.manageFieldRegistration(e,o,n)):void t.error('Missing required field "attribute"')},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.CheckboxFieldDirective=i,angular.module("formFor").directive("checkboxField",["$log","FieldHelper",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r=function(){function e(e){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/collection-label.html",this.scope={attribute:"@",help:"@?",label:"@"},t=e}return e.$inject=["$sce"],e.prototype.link=function(e,r,i,o){e.$watch("label",function(r){e.bindableLabel=t.trustAsHtml(r)}),e.model=o.registerCollectionLabel(e.attribute)},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.CollectionLabelDirective=r,angular.module("formFor").directive("collectionLabel",["$sce",function(e){return new r(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){this.restrict="EA",this.templateUrl="form-for/templates/field-error.html",this.scope={error:"=",leftAligned:"@?",uid:"@"}}return e.prototype.link=function(){},e.prototype.link.$inject=["$scope"],e}();e.FieldErrorDirective=t,angular.module("formFor").directive("fieldError",function(){return new t})}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function e(e,i){this.replace=!0,this.restrict="EA",this.templateUrl="form-for/templates/field-label.html",this.scope={inputUid:"@",help:"@?",label:"@",required:"@?",uid:"@"},t=e,r=i}return e.$inject=["$sce","formForConfiguration"],e.prototype.link=function(e,i,o){e.attributes=o,e.$watch("label",function(r){e.bindableLabel=t.trustAsHtml(r)}),e.$watch("required",function(t){e.requiredLabel=e.$eval(t)?r.requiredLabel:null})},e.prototype.link.$inject=["$scope","$element","$attributes"],e}();e.FieldLabelDirective=i,angular.module("formFor").directive("fieldLabel",["$sce","FormForConfiguration",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function i(i,o){this.require="formFor",this.restrict="A",t=i,r=new e.NestedObjectHelper(o)}return i.$inject=["$compile","$parse"],i.prototype.link=function(i,o,n,a){var l;n.formForBuilder?l=i.$eval(n.formForBuilder):n.validationRules?l=i.$eval(n.validationRules):n.$service&&(l=i.$eval(n.$service.validationRules));for(var u=r.flattenObjectKeys(l),s="",d=0,c=u.length;c>d;d++){var f=u[d],p=r.readAttribute(l,f);if(p&&p.hasOwnProperty("inputType")){var m,F=p.help||"",b=p.label||"",h=p.uid||"",v=b?'label="'+b+'"':"";switch(p.inputType){case e.BuilderFieldType.CHECKBOX:s+='<checkbox-field attribute="'+f+'"\n help="'+F+'"\n '+v+'\n uid="'+h+'">\n </checkbox-field>';break;case e.BuilderFieldType.RADIO:m=JSON.stringify(p.values).replace(/"/g,"&quot;"),s+='<radio-field attribute="'+f+'"\n '+v+'\n options="'+m+'"\n uid="'+h+'">\n </radio-field>';break;case e.BuilderFieldType.SELECT:m=JSON.stringify(p.values).replace(/"/g,"&quot;"),s+='<select-field attribute="'+f+'"\n '+(p.allowBlank?"allow-blank":"")+"\n "+(p.enableFiltering?"enable-filtering":"")+'\n help="'+F+'"\n '+v+"\n "+v+'\n multiple="'+!!p.multipleSelection+'"\n options="'+m+'"\n uid="'+h+'"\n value-attribute="'+(p.valueAttribute||"")+'">\n </select-field>';break;case e.BuilderFieldType.NUMBER:case e.BuilderFieldType.PASSWORD:case e.BuilderFieldType.TEXT:s+='<text-field attribute="'+f+'"\n '+v+'\n help="'+F+'"\n ng-attr-multiline="'+!!p.multiline+'"\n rows="'+(p.rows||"")+'"\n type="'+p.inputType+'"\n uid="'+h+'">\n </text-field>'}}}0===o.find("input[type=button], button, submit-button").length&&(s+='<submit-button label="Submit"></submit-button>');var g=t(s),_=g(i,void 0,{transcludeControllers:a});o.prepend(_)},i.prototype.link.$inject=["$scope","$element","$attributes","formForController"],i}();e.FormForBuilderDirective=i,angular.module("formFor").directive("formForBuilder",["$compile","$parse",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o,n=function(){function e(e,n,a,l){this.priority=99,this.require="ngModel",this.restrict="A",this.scope={formForDebounce:"@"},t=e,r=n,i=a,o=l}return e.$inject=["$log","$sniffer","$timeout","formForConfiguration"],e.prototype.link=function(e,n,a,l){if("radio"===a.type||"checkbox"===a.type)return void t.warn("formForDebounce should only be used with <input type=text> and <textarea> elements");var u=a.formForDebounce,s=o.defaultDebounceDuration;void 0!==u&&("false"===u.toString()?s=!1:(u=parseInt(u),angular.isNumber(u)&&!isNaN(u)&&(s=u))),r.hasEvent("input")?n.off("input"):(n.off("keydown"),r.hasEvent("paste")&&n.off("paste"));var d;if(s!==!1){var c=function(){i.cancel(d),d=i(function(){e.$apply(function(){l.$setViewValue(n.val())})},s)};r.hasEvent("input")?n.on("input",c):(n.on("keydown",c),r.hasEvent("paste")&&n.on("paste",c))}n.on("blur",function(){e.$apply(function(){l.$setViewValue(n.val())})}),e.$on("$destroy",function(){d&&i.cancel(d)})},e.prototype.link.$inject=["$scope","$element","$attributes","ngModelController"],e}();e.FormForDebounceDirective=n,angular.module("formFor").directive("formForDebounce",["$log","$sniffer","$timeout","FormForConfiguration",function(e,t,r,i){return new n(e,t,r,i)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r=function(){function e(e){this.require="ngInclude",this.restrict="A",t=e}return e.$inject=["$compile"],e.prototype.link=function(e,r){var i=r.prop("innerHTML"),o=t(i)(e);r.replaceWith(o)},e.prototype.link.$inject=["$scope","$element","$attributes"],e}();e.FormForIncludeReplaceDirective=r,angular.module("formFor").directive("formForIncludeReplace",["$compile",function(e){return new r(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(e){this.$parse_=e}return e.prototype.flattenAttribute=function(e){return e.replace(/\[([^\]]+)\]\.{0,1}/g,"___$1___").replace(/\./g,"___")},e.prototype.flattenObjectKeys=function(e){for(var t=[],r=[{object:e,prefix:null}];;){if(0===r.length)break;var i=r.pop(),o=Array.isArray(i.object),n=i.prefix?i.prefix+(o?"[":"."):"",a=o?"]":"";if("object"==typeof i.object)for(var l in i.object){var u=n+l+a,s=i.object[l];t.push(u),r.push({object:s,prefix:u})}}return t},e.prototype.readAttribute=function(e,t){return this.$parse_(t)(e)},e.prototype.writeAttribute=function(e,t,r){this.initializeArraysAndObjectsForParse_(e,t),this.$parse_(t).assign(e,r)},e.prototype.initializeArraysAndObjectsForParse_=function(e,t){for(var r=0;;){if(r=t.indexOf("[",r),0>r)break;var i=t.substr(0,r),o=this.readAttribute(e,i);o||(o=[],this.writeAttribute(e,i,o));var n=t.substr(r).match(/([0-9]+)\]\./);if(n){var a=parseInt(n[1]);o[a]||(o[a]={})}r++}},e}();e.NestedObjectHelper=t}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(e){this.$q_=e}return e.prototype.all=function(e){return this.$q_.all(e)},e.prototype.defer=function(){return this.$q_.defer()},e.prototype.resolve=function(e){var t=this.$q_.defer();return t.resolve(e),t.promise},e.prototype.reject=function(e){return this.$q_.reject(e)},e.prototype.waitForAll=function(e){function t(e,t){o.hasOwnProperty(e)||(o[e]=t,n--),r()}function r(){0===n&&(a?i.reject(o):i.resolve(o))}var i=this.$q_.defer(),o={},n=0,a=!1;return angular.forEach(e,function(e,r){n++,e.then(function(e){t(r,e)},function(e){a=!0,t(r,e)})}),r(),i.promise},e.prototype.when=function(e){return this.$q_.when(e)},e}();e.PromiseUtils=t}(formFor||(formFor={}));var formFor;!function(e){function t(t,r,i,o,n){var a=new e.NestedObjectHelper(r),l=new e.PromiseUtils(i);return t.registerCollectionLabel=function(e){var t=a.flattenAttribute(e),r={error:null,required:n.isCollectionRequired(e,o.$validationRuleset)};o.collectionLabels[t]=r;var i=!1;return o.$watch("formFor."+e+".length",function(){i?o.validateOn&&"change"!==o.validateOn||n.validateCollection(o.formFor,e,o.$validationRuleset).then(function(){o.formForStateHelper.setFieldError(t,null)},function(e){o.formForStateHelper.setFieldError(t,e)}):i=!0}),r},t.registerFormField=function(i){if(!i)throw Error('Invalid field name "'+i+'" provided.');var l=a.flattenAttribute(i);if(o.fields.hasOwnProperty(l))throw Error('Field "'+i+'" has already been registered. Field names must be unique.');var u={bindable:null,disabled:o.disable,error:null,pristine:!0,required:n.isFieldRequired(i,o.$validationRuleset),uid:e.FormForGUID.create()},s={bindableWrapper:u,fieldName:i,formForStateHelper:o.formForStateHelper,unwatchers:[]};o.fields[l]=s;var d=r(i),c=d.assign;s.unwatchers.push(o.$watch("fields."+l+".bindableWrapper.bindable",function(e,t){e!==t&&c(o.formFor,e)}));var f;return s.unwatchers.push(o.$watch("formFor."+i,function(e,r){(e!==s.bindableWrapper.bindable||void 0===r&&""===e||void 0===e)&&(f=!1),s.bindableWrapper.bindable=e,o.validateOn&&"change"!==o.validateOn||t.validateField(i),f||(f=!0,o.formForStateHelper.setFieldHasBeenModified(l,!1)),s.bindableWrapper.pristine=!o.formForStateHelper.hasFieldBeenModified(l)})),u},t.registerSubmitButton=function(){var e={disabled:!1};return o.buttons.push(e),e},t.resetErrors=function(){for(var e in o.fields)o.formForStateHelper.getFieldError(e)&&(o.formForStateHelper.setFieldHasBeenModified(e,!1),o.fields[e].bindableWrapper.pristine=!0);o.formForStateHelper.setFormSubmitted(!1),o.formForStateHelper.resetFieldErrors()},t.resetField=function(e){var t=a.flattenAttribute(e);o.formForStateHelper.getFieldError(t)&&(o.formForStateHelper.setFieldHasBeenModified(t,!1),o.fields[t].bindableWrapper.pristine=!0),o.formForStateHelper.setFieldError(t,null)},t.resetFields=function(){t.resetErrors()},t.setFieldError=function(e,t){var r=a.flattenAttribute(e);o.formForStateHelper.setFieldHasBeenModified(r,!0),o.formForStateHelper.setFieldError(r,t)},t.unregisterFormField=function(e){var t=a.flattenAttribute(e);angular.forEach(o.fields[t].unwatchers,function(e){e()}),delete o.fields[t]},t.updateCollectionErrors=function(e){angular.forEach(o.collectionLabels,function(t,r){var i=a.readAttribute(e,r);o.formForStateHelper.setFieldError(r,i)})},t.updateFieldErrors=function(e){angular.forEach(o.fields,function(t,r){var i=a.readAttribute(e,t.fieldName);o.formForStateHelper.setFieldError(r,i)})},t.validateField=function(e){var t=a.flattenAttribute(e);o.formForStateHelper.setFieldHasBeenModified(t,!0),o.$validationRuleset&&n.validateField(o.formFor,e,o.$validationRuleset).then(function(){o.formForStateHelper.setFieldError(t,null)},function(e){o.formForStateHelper.setFieldError(t,e)})},t.validateForm=function(e){t.updateCollectionErrors({}),t.updateFieldErrors({});var r,i;if(o.$validationRuleset){var u=[];angular.forEach(o.fields,function(e){u.push(e.fieldName)}),i=n.validateFields(o.formFor,u,o.$validationRuleset),i.then(angular.noop,t.updateFieldErrors),u=[],angular.forEach(o.collectionLabels,function(e,t){u.push(t)}),r=n.validateFields(o.formFor,u,o.$validationRuleset),r.then(angular.noop,t.updateCollectionErrors)}else r=l.resolve(),i=l.resolve();var s=l.defer();return l.waitForAll([r,i]).then(s.resolve,function(t){angular.isArray(t[0])&&0===t[0].length&&t.splice(0,1),e&&angular.forEach(t,function(e){var t=a.flattenObjectKeys(e);angular.forEach(t,function(t){var r=a.readAttribute(e,t);if(r){var i=a.flattenAttribute(t);o.formForStateHelper.setFieldHasBeenModified(i,!0)}})}),s.reject(t)}),s.promise},t}e.createFormForController=t}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o,n,a,l,u=function(){function u(u){this.require="form",this.restrict="A",this.scope={controller:"=?",disable:"=?",formFor:"=",service:"@",submitComplete:"&?",submitError:"&?",submitWith:"&?",valid:"=?",validateOn:"=?",validationFailed:"&?",validationRules:"=?"},t=u,r=u.get("$log"),i=u.get("$parse"),o=u.get("$sce"),n=u.get("FormForConfiguration"),a=u.get("ModelValidator"),l=new e.PromiseUtils(u.get("$q"))}return u.$inject=["$injector"],u.prototype.controller=function(n){n.formFor||r.error('The form data object specified by <form form-for=""> is null or undefined.'),n.fields={},n.collectionLabels={},n.buttons=[],n.controller=n.controller||{},n.service&&(n.$service=t.get(n.service)),n.validationRules?n.$validationRuleset=n.validationRules:n.$service&&(n.$validationRuleset=n.$service.validationRules),e.createFormForController(this,i,l,n,a),n.controller&&angular.copy(this,n.controller),n.$watch("disable",function(e){angular.forEach(n.fields,function(t){t.bindableWrapper.disabled=e}),angular.forEach(n.buttons,function(t){t.disabled=e})}),n.formForStateHelper=new e.FormForStateHelper(i,n),n.$watch("formForStateHelper.watchable",function(){var e=n.formForStateHelper.hasFormBeenSubmitted();angular.forEach(n.fields,function(t,r){if(e||n.formForStateHelper.hasFieldBeenModified(r)){var i=n.formForStateHelper.getFieldError(r);t.bindableWrapper.error=i?o.trustAsHtml(i):null}else t.bindableWrapper.error=null}),angular.forEach(n.collectionLabels,function(e,t){var r=n.formForStateHelper.getFieldError(t);e.error=r?o.trustAsHtml(r):null})})},u.prototype.controller.$inject=["$scope"],u.prototype.link=function(e,t,r){t.on("submit",function(){e.formForStateHelper.setFormSubmitted(!0),e.disable=!0;var t;return t="manual"===e.validateOn?l.resolve():e.controller.validateForm(),t.then(function(){var t;t=r.submitWith?e.submitWith({data:e.formFor}):e.$service&&e.$service.submit?e.$service.submit(e.formFor):l.reject("No submit function provided"),t||(t=l.reject("Submit function did not return a promise")),t.then(function(t){r.submitComplete?e.submitComplete({data:t}):n.defaultSubmitComplete(t)},function(t){angular.isObject(t)&&"manual"!==e.validateOn&&(e.controller.updateCollectionErrors(t),e.controller.updateFieldErrors(t)),r.submitError?e.submitError({error:t}):n.defaultSubmitError(t)}),t["finally"](function(){e.disable=!1})},function(t){e.disable=!1,r.validationFailed?e.validationFailed():n.defaultValidationFailed(t)}),!1})},u.prototype.link.$inject=["$scope","$element","$attributes"],u}();e.FormForDirective=u,angular.module("formFor").directive("formFor",["$injector",function(e){return new u(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){}return e.create=function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)},e}();e.FormForGUID=t}(formFor||(formFor={}));var formFor;!function(e){var t,r,i=function(){function i(i,o){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/radio-field.html",this.scope={attribute:"@",disable:"=",help:"@?",options:"=",value:"@"},r=new e.FieldHelper(o),t=i}return i.$inject=["$log","FormForConfiguration"],i.prototype.link=function(i,o,n,a){return i.attribute?(i.labelAttribute=n.labelAttribute||"label",i.valueAttribute=n.valueAttribute||"value",r.manageFieldRegistration(i,n,a),i.uid=n.uid||e.FormForGUID.create(),r.manageLabel(i,n,!0),i.tabIndex=n.tabIndex||0,i.click=function(){!i.disable&&!i.model.disabled},i.$watch("model",function(e){i.model=e}),i.$watch("disable",function(e){i.disable=e}),void i.$watch("model.disabled",function(e){i.model&&(i.model.disabled=e)})):void t.error('Missing required field "attribute"')},i.prototype.link.$inject=["$scope","$element","$attributes","formForController"],i}();e.RadioFieldDirective=i,angular.module("formFor").directive("radioField",["$log","FormForConfiguration",function(e,t){return new i(e,t)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o,n=10,a=function(){function e(e,n,a,l){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/select-field.html",this.scope={attribute:"@",disable:"=",filterDebounce:"@?",help:"@?",multiple:"=?",options:"="},t=e,r=n,i=a,o=l}return e.$inject=["$document","$log","$timeout","fieldHelper"],e.prototype.link=function(e,a,l,u){if(!e.attribute)return void r.error('Missing required field "attribute"');e.allowBlank=l.hasOwnProperty("allowBlank"),e.enableFiltering=l.hasOwnProperty("enableFiltering"),e.preventDefaultOption=l.hasOwnProperty("preventDefaultOption"),e.labelAttribute=l.labelAttribute||"label",e.valueAttribute=l.valueAttribute||"value",e.placeholder=l.hasOwnProperty("placeholder")?l.placeholder:"Select",e.tabIndex=l.tabIndex||0,e.scopeBuster={},o.manageLabel(e,l,!1),o.manageFieldRegistration(e,l,u);var s,d=function(){s||(s=a.find("input")),i(s.focus.bind(s))};e.close=function(){i(function(){e.isOpen=!1})},e.open=function(){e.disable||e.model.disabled||i(function(){e.isOpen=!0})},e.emptyOption={},e.emptyOption[e.labelAttribute]="",e.emptyOption[e.valueAttribute]=void 0,e.placeholderOption={},e.placeholderOption[e.labelAttribute]=e.placeholder,e.placeholderOption[e.valueAttribute]=void 0,e.filteredOptions=[];var c=function(e){return"string"==typeof e?e.toLowerCase():""},f=function(){var t=e.options||[];if(e.filteredOptions.splice(0),e.enableFiltering&&e.scopeBuster.filter){var r=c(e.scopeBuster.filter);angular.forEach(t,function(t){var i=c(t[e.labelAttribute]).indexOf(r);i>=0&&e.filteredOptions.push(t)})}else angular.copy(t,e.filteredOptions);e.selectedOption||e.multiple||e.enableFiltering?e.allowBlank&&e.filteredOptions.unshift(e.emptyOption):e.filteredOptions.unshift(e.placeholderOption)};e.$watch("scopeBuster.filter",f),e.$watch("options.length",f);var p=function(){var t=e.selectedOption&&e.selectedOption[e.valueAttribute],r=e.options&&e.options.length;t!==e.model.bindable||e.allowBlank||e.preventDefaultOption||!r||(e.model.bindable=e.options[0][e.valueAttribute])};e.$watch("model.bindable",p),e.$watch("options.length",p),e.$watch("model.bindable",function(){var t=null;angular.forEach(e.options,function(r){r[e.valueAttribute]===e.model.bindable&&(t=r)}),t&&(e.selectedOption=t,e.selectedOptionLabel=t[e.labelAttribute]),e.scopeBuster.filter=e.selectedOptionLabel});var m=function(t){t.ignoreFor!==e.model.uid&&e.close()};e.filterTextClick=function(t){e.isOpen&&(t.ignoreFor=e.model.uid)};var F;e.$watch("isOpen",function(){F&&i.cancel(F),F=i(function(){F=null,e.isOpen?t.on("click",m):t.off("click",m)},n)}),e.$on("$destroy",function(){t.off("click",m)}),e.setFilterFocus=function(){d()},e.mouseOver=function(t){e.mouseOverIndex=t,e.mouseOverOption=t>=0?e.filteredOptions[t]:null},e.selectOption=function(t){e.model.bindable=t&&t[e.valueAttribute]},e.keyDown=function(t){switch(t.keyCode){case 27:e.close();break;case 13:e.isOpen?(e.selectOption(e.mouseOverOption),e.close()):e.open(),t.preventDefault();break;case 38:e.isOpen?e.mouseOver(e.mouseOverIndex>0?e.mouseOverIndex-1:e.filteredOptions.length-1):e.open();break;case 40:e.isOpen?e.mouseOver(e.mouseOverIndex<e.filteredOptions.length-1?e.mouseOverIndex+1:0):e.open();break;case 9:case 16:e.close();break;default:e.open()}},e.$watchCollection("[isOpen, filteredOptions.length]",function(){e.mouseOver(-1),e.isOpen&&e.enableFiltering&&d()})},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.SelectFieldDirective=a,angular.module("formFor").directive("selectField",["$document","$log","$timeout","FieldHelper",function(e,t,r,i){return new a(e,t,r,i)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r=function(){function e(e){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/submit-button.html",this.scope={disable:"=",icon:"@",label:"@"},t=e}return e.$inject=["$sce"],e.prototype.link=function(e,r,i,o){e.buttonClass=i.buttonClass,e.tabIndex=i.tabIndex||0,e.$watch("label",function(r){e.bindableLabel=t.trustAsHtml(r)}),e.model=o.registerSubmitButton(e)},e.prototype.link.$inject=["$scope","$element","$attributes","formForController"],e}();e.SubmitButtonDirective=r,angular.module("formFor").directive("submitButton",["$sce",function(e){return new r(e)}])}(formFor||(formFor={}));var formFor;!function(e){var t,r,i,o=function(){function e(e,o,n){this.require="^formFor",this.restrict="EA",this.templateUrl="form-for/templates/text-field.html",this.scope={attribute:"@",debounce:"@?",disable:"=",focused:"&?",blurred:"&?",help:"@?",iconAfterClicked:"&?",iconBeforeClicked:"&?",placeholder:"@?",rows:"=?"},t=e,r=o,i=n}return e.$inject=["$log","$timeout","fieldHelper"],e.prototype.link=function(e,o,n,a){if(!e.attribute)return void t.error('Missing required field "attribute"');if(e.attributes=n,e.rows=e.rows||3,e.type=n.type||"text",e.multiline=n.hasOwnProperty("multiline")&&"false"!==n.multiline,e.tabIndex=n.tabIndex||0,n.hasOwnProperty("autofocus")&&r(function(){o.find(e.multiline?"textarea":"input")[0].focus()}),i.manageLabel(e,n,!1),i.manageFieldRegistration(e,n,a),n.iconAfter){var l=function(){if(e.model){var t="{"===n.iconAfter.charAt(0)?e.$eval(n.iconAfter):n.iconAfter;e.iconAfter=angular.isObject(t)?e.model.error?t.invalid:e.model.pristine?t.pristine:t.valid:t}};n.$observe("iconAfter",l),e.$watch("model.error",l),e.$watch("model.pristine",l)}if(n.iconBefore){var u=function(){if(e.model){var t="{"===n.iconBefore.charAt(0)?e.$eval(n.iconBefore):n.iconBefore;e.iconBefore=angular.isObject(t)?e.model.error?t.invalid:e.model.pristine?t.pristine:t.valid:t}};n.$observe("iconBefore",u),e.$watch("model.error",u),e.$watch("model.pristine",u)}e.onIconAfterClick=function(){n.hasOwnProperty("iconAfterClicked")&&e.iconAfterClicked()},e.onIconBeforeClick=function(){n.hasOwnProperty("iconBeforeClicked")&&e.iconBeforeClicked()},e.onFocus=function(){n.hasOwnProperty("focused")&&e.focused()},e.onBlur=function(){n.hasOwnProperty("blurred")&&e.blurred()}},e}();e.TextFieldDirective=o,angular.module("formFor").directive("textField",["$log","$timeout","FieldHelper",function(e,t,r){return new o(e,t,r)}])}(formFor||(formFor={}));var formFor;!function(e){!function(e){e[e.CHECKBOX="checkbox"]="CHECKBOX",e[e.NUMBER="number"]="NUMBER",e[e.PASSWORD="password"]="PASSWORD",e[e.RADIO="radio"]="RADIO",e[e.SELECT="select"]="SELECT",e[e.TEXT="text"]="TEXT"}(e.BuilderFieldType||(e.BuilderFieldType={}));e.BuilderFieldType}(formFor||(formFor={}));var formFor;!function(e){!function(e){e[e.COLLECTION_MAX_SIZE="COLLECTION_MAX_SIZE"]="COLLECTION_MAX_SIZE",e[e.COLLECTION_MIN_SIZE="COLLECTION_MIN_SIZE"]="COLLECTION_MIN_SIZE",e[e.CUSTOM="CUSTOM"]="CUSTOM",e[e.MAXIMUM="MAXIMUM"]="MAXIMUM",e[e.MAX_LENGTH="MAX_LENGTH"]="MAX_LENGTH",e[e.MINIMUM="MINIMUM"]="MINIMUM",e[e.MIN_LENGTH="MIN_LENGTH"]="MIN_LENGTH",e[e.PATTERN="PATTERN"]="PATTERN",e[e.REQUIRED="REQUIRED_FIELD"]="REQUIRED",e[e.TYPE_EMAIL="TYPE_EMAIL"]="TYPE_EMAIL",e[e.TYPE_INTEGER="TYPE_INTEGER"]="TYPE_INTEGER",e[e.TYPE_NEGATIVE="TYPE_NEGATIVE"]="TYPE_NEGATIVE",e[e.TYPE_NON_NEGATIVE="TYPE_NON_NEGATIVE"]="TYPE_NON_NEGATIVE",e[e.TYPE_NUMERIC="TYPE_NUMERIC"]="TYPE_NUMERIC",e[e.TYPE_POSITIVE="TYPE_POSITIVE"]="TYPE_POSITIVE"}(e.ValidationFailureType||(e.ValidationFailureType={}));e.ValidationFailureType}(formFor||(formFor={}));var formFor;!function(e){!function(e){e[e.EMAIL="email"]="EMAIL",e[e.INTEGER="integer"]="INTEGER",e[e.NEGATIVE="negative"]="NEGATIVE",e[e.NON_NEGATIVE="nonNegative"]="NON_NEGATIVE",e[e.NUMBER="number"]="NUMBER",e[e.POSITIVE="positive"]="POSITIVE"}(e.ValidationFieldType||(e.ValidationFieldType={}));e.ValidationFieldType}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){}return e}();e.BindableFieldWrapper=t}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(t,r,i,o){this.$interpolate_=t,this.formForConfiguration_=o,
this.nestedObjectHelper_=new e.NestedObjectHelper(r),this.promiseUtils_=new e.PromiseUtils(i)}return t.prototype.isCollectionRequired=function(e,t){var r=this.getRulesFor_(e,t);return r&&r.collection&&r.collection.min?angular.isObject(r.collection.min)?r.collection.min.rule>0:r.collection.min>0:!1},t.prototype.isFieldRequired=function(e,t){var r=this.getRulesFor_(e,t);return r&&r.required?angular.isObject(r.required)?r.required.rule:!!r.required:!1},t.prototype.validateAll=function(e,t){var r=this.nestedObjectHelper_.flattenObjectKeys(e);return this.validateFields(e,r,t)},t.prototype.validateCollection=function(e,t,r){var i=this.getRulesFor_(t,r),o=this.nestedObjectHelper_.readAttribute(e,t);return i&&i.collection?(o=o||[],this.validateCollectionMinLength_(o,i.collection)||this.validateCollectionMaxLength_(o,i.collection)||this.promiseUtils_.resolve()):this.promiseUtils_.resolve()},t.prototype.validateField=function(e,t,r){var i=this.getRulesFor_(t,r),o=this.nestedObjectHelper_.readAttribute(e,t);return i?((void 0===o||null===o)&&(o=""),this.validateFieldRequired_(o,i)||this.validateFieldMinimum_(o,i)||this.validateFieldMinLength_(o,i)||this.validateFieldMaximum_(o,i)||this.validateFieldMaxLength_(o,i)||this.validateFieldType_(o,i)||this.validateFieldPattern_(o,i)||this.validateFieldCustom_(o,e,i)||this.promiseUtils_.resolve()):this.promiseUtils_.resolve()},t.prototype.validateFields=function(e,t,r){var i=this,o=this.promiseUtils_.defer(),n=[],a={};return angular.forEach(t,function(t){var o=i.getRulesFor_(t,r);if(o){var l;l=o.collection?i.validateCollection(e,t,r):i.validateField(e,t,r),l.then(angular.noop,function(e){i.nestedObjectHelper_.writeAttribute(a,t,e)}),n.push(l)}},this),this.promiseUtils_.waitForAll(n).then(o.resolve,function(){o.reject(a)}),o.promise},t.prototype.getRulesFor_=function(e,t){var r=e.replace(/\[[^\]]+\]/g,".collection.fields");return this.nestedObjectHelper_.readAttribute(t,r)},t.prototype.getFieldTypeFailureMessage_=function(e,t){return angular.isObject(e.type)?e.type.message:this.formForConfiguration_.getFailedValidationMessage(t)},t.isConsideredNumeric_=function(e,t){return e&&!isNaN(t)},t.prototype.validateCollectionMinLength_=function(t,r){if(r.min){var i=angular.isObject(r.min)?r.min.rule:r.min;if(t.length<i){var o;return o=angular.isObject(r.min)?r.min.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.COLLECTION_MIN_SIZE))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateCollectionMaxLength_=function(t,r){if(r.max){var i=angular.isObject(r.max)?r.max.rule:r.max;if(t.length>i){var o;return o=angular.isObject(r.max)?r.max.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.COLLECTION_MAX_SIZE))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateFieldCustom_=function(t,r,i){var o=this;if(i.custom){var n,a;angular.isFunction(i.custom)?(n=this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.CUSTOM),a=i.custom):(n=i.custom.message,a=i.custom.rule);try{var l=a(t,r)}catch(u){return this.promiseUtils_.reject(u.message||n)}return angular.isObject(l)&&angular.isFunction(l.then)?l.then(function(e){return o.promiseUtils_.resolve(e)},function(e){return o.promiseUtils_.reject(e||n)}):l?this.promiseUtils_.resolve(l):this.promiseUtils_.reject(n)}return null},t.prototype.validateFieldMaximum_=function(t,r){if(r.maximum){var i=t.toString(),o=Number(t),n=angular.isObject(r.maximum)?r.maximum.rule:r.maximum;if(i&&!isNaN(o)&&o>n){var a;return a=angular.isObject(r.maximum)?r.maximum.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MAXIMUM))({num:n}),this.promiseUtils_.reject(a)}}return null},t.prototype.validateFieldMaxLength_=function(t,r){if(r.maxlength){var i=angular.isObject(r.maxlength)?r.maxlength.rule:r.maxlength;if(t.length>i){var o;return o=angular.isObject(r.maxlength)?r.maxlength.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MAX_LENGTH))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateFieldMinimum_=function(t,r){if(r.minimum){var i=t.toString(),o=Number(t),n=angular.isObject(r.minimum)?r.minimum.rule:r.minimum;if(i&&!isNaN(o)&&n>o){var a;return a=angular.isObject(r.minimum)?r.minimum.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MINIMUM))({num:n}),this.promiseUtils_.reject(a)}}return null},t.prototype.validateFieldMinLength_=function(t,r){if(r.minlength){var i=angular.isObject(r.minlength)?r.minlength.rule:r.minlength;if(t&&t.length<i){var o;return o=angular.isObject(r.minlength)?r.minlength.message:this.$interpolate_(this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.MIN_LENGTH))({num:i}),this.promiseUtils_.reject(o)}}return null},t.prototype.validateFieldRequired_=function(t,r){if(r.required){var i=angular.isObject(r.required)?r.required.rule:r.required,o=t.toString().replace(/\s+$/,""),n=Number(t);if(i&&!o&&!n){var a;return a=angular.isObject(r.required)?r.required.message:this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.REQUIRED),this.promiseUtils_.reject(a)}}return null},t.prototype.validateFieldPattern_=function(t,r){if(r.pattern){var i=r.pattern instanceof RegExp,o=i?r.pattern:r.pattern.rule;if(!o.exec(t)){var n=i?this.formForConfiguration_.getFailedValidationMessage(e.ValidationFailureType.PATTERN):r.pattern.message;return this.promiseUtils_.reject(n)}}return null},t.prototype.validateFieldType_=function(r,i){if(i.type){var o=angular.isObject(i.type)?i.type.rule:i.type,n=r.toString(),a=Number(r);if(o)for(var l=o.split(" "),u=0,s=l.length;s>u;u++){var d=l[u];switch(d){case e.ValidationFieldType.INTEGER:if(n&&(isNaN(a)||a%1!==0))return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_INTEGER));break;case e.ValidationFieldType.NUMBER:if(n&&isNaN(a))return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_NUMERIC));break;case e.ValidationFieldType.NEGATIVE:if(t.isConsideredNumeric_(n,a)&&a>=0)return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_NEGATIVE));break;case e.ValidationFieldType.NON_NEGATIVE:if(t.isConsideredNumeric_(n,a)&&0>a)return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_NON_NEGATIVE));break;case e.ValidationFieldType.POSITIVE:if(t.isConsideredNumeric_(n,a)&&0>=a)return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_POSITIVE));break;case e.ValidationFieldType.EMAIL:if(n&&!n.match(/^.+@.+\..+$/))return this.promiseUtils_.reject(this.getFieldTypeFailureMessage_(i,e.ValidationFailureType.TYPE_EMAIL))}}}return null},t}();e.ModelValidator=t,angular.module("formFor").service("ModelValidator",["$interpolate","$parse","$q","FormForConfiguration",function(e,r,i,o){return new t(e,r,i,o)}])}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function t(t,r){this.formForScope_=r,this.nestedObjectHelper_=new e.NestedObjectHelper(t),this.formForScope_.fieldNameToErrorMap=r.fieldNameToErrorMap||{},this.formForScope_.valid=!0,this.fieldNameToModifiedStateMap_={},this.formSubmitted_=!1,this.fieldNameToErrorMap_={},this.watchable=0}return t.prototype.getFieldError=function(e){return this.nestedObjectHelper_.readAttribute(this.formForScope_.fieldNameToErrorMap,e)},t.prototype.hasFieldBeenModified=function(e){return this.nestedObjectHelper_.readAttribute(this.fieldNameToModifiedStateMap_,e)},t.prototype.hasFormBeenSubmitted=function(){return this.formSubmitted_},t.prototype.isFormInvalid=function(){return!this.isFormValid()},t.prototype.isFormValid=function(){for(var e in this.fieldNameToErrorMap_)return!1;return!0},t.prototype.resetFieldErrors=function(){this.formForScope_.fieldNameToErrorMap={}},t.prototype.setFieldError=function(e,t){var r=this.nestedObjectHelper_.flattenAttribute(e);this.nestedObjectHelper_.writeAttribute(this.formForScope_.fieldNameToErrorMap,e,t),t?this.fieldNameToErrorMap_[r]=t:delete this.fieldNameToErrorMap_[r],this.formForScope_.valid=this.isFormValid(),this.watchable++},t.prototype.setFieldHasBeenModified=function(e,t){this.nestedObjectHelper_.writeAttribute(this.fieldNameToModifiedStateMap_,e,t),this.watchable++},t.prototype.setFormSubmitted=function(e){this.formSubmitted_=e,this.watchable++},t}();e.FormForStateHelper=t}(formFor||(formFor={}));var formFor;!function(e){var t=function(){function e(){}return e.humanize=function(e){return e?(e=e.replace(/[A-Z]/g,function(e){return" "+e}),e=e.replace(/_([a-z])/g,function(e,t){return" "+t.toUpperCase()}),e=e.replace(/\s+/g," "),e=e.trim(),e=e.charAt(0).toUpperCase()+e.slice(1)):""},e}();e.StringUtil=t}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));var formFor;!function(){}(formFor||(formFor={}));
//# sourceMappingURL=form-for.min.js.map
{
"name": "angular-form-for",
"version": "3.0.3",
"version": "3.0.5",
"description": "Set of Angular directives to simplify creating and validating HTML forms.",

@@ -63,3 +63,11 @@ "keywords": [

"scripts": {
"unit": "gulp test:unit"
"prestart": "npm install",
"start": "http-server -p 8000",
"unit": "gulp test:unit",
"update-webdriver": "webdriver-manager update",
"preprotractor": "npm run update-webdriver",
"protractor": "protractor protractor.conf.js"
},

@@ -66,0 +74,0 @@ "repository": {

@@ -108,8 +108,8 @@ /// <reference path="../services/form-for-configuration.ts" />

if ($sniffer_.hasEvent('input')) {
$element.on('input', undefined, inputChangeHandler);
$element.on('input', inputChangeHandler);
} else {
$element.on('keydown', undefined, inputChangeHandler);
$element.on('keydown', inputChangeHandler);
if ($sniffer_.hasEvent('paste')) {
$element.on('paste', undefined, inputChangeHandler);
$element.on('paste', inputChangeHandler);
}

@@ -119,3 +119,3 @@ }

$element.on('blur', undefined, () => {
$element.on('blur', () => {
$scope.$apply(function () {

@@ -122,0 +122,0 @@ ngModelController.$setViewValue($element.val());

module formFor {
var $compile_: ng.ICompileService;

@@ -11,2 +12,7 @@ /**

/* @ngInject */
constructor($compile) {
$compile_ = $compile;
}
/* @ngInject */
link($scope:ng.IScope,

@@ -16,9 +22,11 @@ $element:ng.IAugmentedJQuery,

$element.replaceWith($element.children());
var html = $element.prop('innerHTML');
var compiled = $compile_(html)($scope);
$element.replaceWith(compiled);
}
}
angular.module('formFor').directive('formForIncludeReplace', () => {
return new FormForIncludeReplaceDirective();
angular.module('formFor').directive('formForIncludeReplace', ($compile) => {
return new FormForIncludeReplaceDirective($compile);
});
}

@@ -124,3 +124,3 @@ /// <reference path="../utils/form-for-controller.ts" />

link($scope:FormForScope, $element:ng.IAugmentedJQuery, $attributes:ng.IAttributes):void {
$element.on('submit', undefined, // Override form submit to trigger overall validation.
$element.on('submit', // Override form submit to trigger overall validation.
() => {

@@ -127,0 +127,0 @@ $scope.formForStateHelper.setFormSubmitted(true);

@@ -430,5 +430,5 @@ /// <reference path="../services/field-helper.ts" />

if ($scope.isOpen) {
$document_.on('click', undefined, documentClick);
$document_.on('click', documentClick);
} else {
$document_.off('click', undefined, documentClick);
$document_.off('click', documentClick);
}

@@ -435,0 +435,0 @@ }, MIN_TIMEOUT_INTERVAL);

@@ -10,3 +10,9 @@ 'use strict';

this.getCheckbox = function(fieldName) {
var fieldName;
this.setFieldName = function(value) {
fieldName = value;
};
this.getCheckbox = function() {
return element(by.css('[attribute=' + fieldName + ']'));

@@ -17,12 +23,12 @@ };

case 'bootstrap':
this.getClickable = function(fieldName) {
this.getClickable = function() {
return element(by.css('[attribute=' + fieldName + '] input'));
};
this.getErrorText = function(fieldName) {
this.getErrorText = function() {
return element(by.css('[attribute=' + fieldName + '] field-error p'));
};
this.getHoverable = function(fieldName) {
this.getHoverable = function() {
return element(by.css('[attribute=' + fieldName + '] [popover]'));
};
this.getTooltip = function(fieldName) {
this.getTooltip = function() {
return element(by.css('[attribute=' + fieldName + '] [popover-popup]'));

@@ -32,12 +38,12 @@ };

case 'default':
this.getClickable = function(fieldName) {
this.getClickable = function() {
return element(by.css('[attribute=' + fieldName + '] label'));
};
this.getErrorText = function(fieldName) {
this.getErrorText = function() {
return element(by.css('[attribute=' + fieldName + '] field-error p'));
};
this.getHoverable = function(fieldName) {
this.getHoverable = function() {
return element(by.css('[attribute=' + fieldName + '] .form-for-tooltip-icon'));
};
this.getTooltip = function(fieldName) {
this.getTooltip = function() {
return element(by.css('[attribute=' + fieldName + '] .form-for-tooltip-popover'));

@@ -49,12 +55,12 @@ };

this.getClickable = function(fieldName) {
this.getClickable = function() {
return element(by.css('[attribute=' + fieldName + '] md-checkbox'));
};
this.getErrorText = function(fieldName) {
this.getErrorText = function() {
return element(by.css('[attribute=' + fieldName + '] field-error div'));
};
this.getHoverable = function(fieldName) {
this.getHoverable = function() {
return element(by.css('[attribute=' + fieldName + '] label'));
};
this.getTooltip = function(fieldName) {
this.getTooltip = function() {
return element(by.css('md-tooltip'));

@@ -73,2 +79,4 @@ };

facade = new Facade(template);
browser.driver.manage().window().setSize(1600, 1000);
});

@@ -78,4 +86,6 @@

beforeEach(function() {
checkbox = facade.getCheckbox('enabled');
clickable = facade.getClickable('enabled');
facade.setFieldName('enabled');
checkbox = facade.getCheckbox();
clickable = facade.getClickable();
});

@@ -88,3 +98,3 @@

it('should not show an error', function() {
facade.getErrorText('enabled').isDisplayed().then(
facade.getErrorText().isDisplayed().then(
function() {

@@ -108,4 +118,6 @@ throw Error('Element should not be displayed');

beforeEach(function() {
checkbox = facade.getCheckbox('preselected');
clickable = facade.getClickable('preselected');
facade.setFieldName('preselected');
checkbox = facade.getCheckbox();
clickable = facade.getClickable();
});

@@ -126,16 +138,28 @@

// TODO No element found using locator
describe('help', function() {
xit('show not show help text by default', function() {
var tooltip = facade.getTooltip('help');
beforeEach(function() {
facade.setFieldName('help');
});
expect(tooltip.isPresent() && tooltip.isDisplayed()).toBeFalsy();
it('should not show help text by default', function() {
facade.getTooltip().isDisplayed().then(
function() {
return facade.getTooltip().getCssValue('display').then(
function(display) {
if (display !== 'none') {
throw Error('Help text should not be displayed');
}
});
},
function() {});
});
xit('should show help text on hover', function() {
browser.actions().mouseMove(facade.getHoverable('help')).perform();
it('should show help text on hover', function() {
browser.actions().mouseMove(facade.getHoverable()).perform();
var tooltip = facade.getTooltip('help');
var tooltip = facade.getTooltip();
expect(tooltip.isPresent() && tooltip.isDisplayed()).toBeTruthy();
browser.wait(function () {
return tooltip.isPresent() && tooltip.isDisplayed();
}, 1000);
});

@@ -146,6 +170,8 @@ });

beforeEach(function() {
checkbox = facade.getCheckbox('disabled');
clickable = facade.getClickable('disabled');
hoverable = facade.getHoverable('disabled');
tooltip = facade.getTooltip('disabled');
facade.setFieldName('disabled');
checkbox = facade.getCheckbox();
clickable = facade.getClickable();
hoverable = facade.getHoverable();
tooltip = facade.getTooltip();
});

@@ -172,4 +198,6 @@

it('should show an error', function () {
var errorText = facade.getErrorText('invalid');
facade.setFieldName('invalid');
var errorText = facade.getErrorText();
browser.wait(function () {

@@ -176,0 +204,0 @@ return errorText.isPresent() && errorText.isDisplayed();

@@ -8,3 +8,9 @@ 'use strict';

this.getRadio = function(fieldName) {
var fieldName;
this.setFieldName = function(value) {
fieldName = value;
};
this.getRadio = function() {
return element(by.css('[attribute=' + fieldName + ']'));

@@ -15,15 +21,18 @@ };

case 'bootstrap':
this.getClickables = function(fieldName) {
this.getInputs = function() {
return element.all(by.css('[attribute=' + fieldName + '] [ng-repeat] input'));
};
this.getErrorText = function(fieldName) {
this.getLabels = function() {
return element.all(by.css('[attribute=' + fieldName + '] [ng-repeat] label'));
};
this.getErrorText = function() {
return element(by.css('[attribute=' + fieldName + '] field-error p'));
};
this.getGroupLabel = function(fieldName) {
this.getGroupLabel = function() {
return element(by.css('[attribute=' + fieldName + '] label [ng-bind-html]'));
};
this.getHoverable = function(fieldName) {
this.getHoverable = function() {
return element(by.css('[attribute=' + fieldName + '] label [popover]'));
};
this.getTooltip = function(fieldName) {
this.getTooltip = function() {
return element(by.css('[attribute=' + fieldName + '] label [popover-popup]'));

@@ -33,15 +42,18 @@ };

case 'default':
this.getClickables = function(fieldName) {
this.getInputs = function() {
return element.all(by.css('[attribute=' + fieldName + '] [ng-repeat] input'));
};
this.getErrorText = function(fieldName) {
this.getLabels = function() {
return element.all(by.css('[attribute=' + fieldName + '] [ng-repeat]'));
};
this.getErrorText = function() {
return element(by.css('[attribute=' + fieldName + '] field-error p'));
};
this.getGroupLabel = function(fieldName) {
this.getGroupLabel = function() {
return element(by.css('[attribute=' + fieldName + '] label [ng-bind-html]'));
};
this.getHoverable = function(fieldName) {
this.getHoverable = function() {
return element(by.css('[attribute=' + fieldName + '] label .form-for-tooltip'));
};
this.getTooltip = function(fieldName) {
this.getTooltip = function() {
return element(by.css('[attribute=' + fieldName + '] label .form-for-tooltip-popover'));

@@ -53,15 +65,18 @@ };

this.getClickables = function(fieldName) {
this.getInputs = function() {
return element.all(by.css('[attribute=' + fieldName + '] md-radio-group md-radio-button'));
};
this.getErrorText = function(fieldName) {
this.getLabels = function() {
return element.all(by.css('[attribute=' + fieldName + '] md-radio-group md-radio-button'));
};
this.getErrorText = function() {
return element(by.css('[attribute=' + fieldName + '] field-error div'));
};
this.getGroupLabel = function(fieldName) {
this.getGroupLabel = function() {
return element(by.css('[attribute=' + fieldName + '] md-radio-group label'));
};
this.getHoverable = function(fieldName) {
this.getHoverable = function() {
return element(by.css('[attribute=' + fieldName + '] md-radio-group label'));
};
this.getTooltip = function(fieldName) {
this.getTooltip = function() {
return element(by.css('md-tooltip'));

@@ -76,6 +91,8 @@ };

describe(template, function() {
var radio, groupLabel, femaleClickable, maleClickable, facade, hoverable, tooltip;
var radio, groupLabel, femaleInput, femaleLabel, maleInput, maleLabel, facade, hoverable, tooltip;
beforeEach(function() {
facade = new Facade(template);
browser.driver.manage().window().setSize(1600, 1000);
});

@@ -85,6 +102,8 @@

beforeEach(function() {
radio = facade.getRadio('preselected');
groupLabel = facade.getGroupLabel('preselected');
femaleClickable = facade.getClickables('preselected').get(0);
maleClickable = facade.getClickables('preselected').get(1);
facade.setFieldName('preselected');
radio = facade.getRadio();
groupLabel = facade.getGroupLabel();
femaleLabel = facade.getLabels().get(0);
maleLabel = facade.getLabels().get(1);
});

@@ -97,3 +116,3 @@

it('should not show an error', function() {
facade.getErrorText('preselected').isDisplayed().then(
facade.getErrorText().isDisplayed().then(
function() {

@@ -106,35 +125,52 @@ throw Error('Element should not be displayed');

// TODO
xit('should update the model on click', function() {
expect(radio.evaluate('model.bindable')).toBe('f');
it('should show the correct labels', function() {
expect(femaleLabel.getText()).toBe('Female');
expect(maleLabel.getText()).toBe('Male');
});
maleClickable.click();
it('should preselect the correct initial value', function() {
expect(femaleLabel.evaluate('model.bindable')).toBe('f');
expect(maleLabel.evaluate('model.bindable')).toBe('f');
});
expect(radio.evaluate('model.bindable')).toBe('m');
it('should update the model on click', function() {
maleLabel.click();
femaleClickable.click();
expect(radio.evaluate('formData.preselected')).toBe('m');
expect(radio.evaluate('model.bindable')).toBe('f');
femaleLabel.click();
expect(radio.evaluate('formData.preselected')).toBe('f');
});
});
// TODO No element found using locator
describe('help', function() {
beforeEach(function() {
hoverable = facade.getHoverable('help');
tooltip = facade.getTooltip('help');
facade.setFieldName('help');
hoverable = facade.getHoverable();
tooltip = facade.getTooltip();
});
xit('show not show help text by default', function() {
var tooltip = facade.getTooltip('help');
expect(tooltip.isPresent() && tooltip.isDisplayed()).toBeFalsy();
it('should not show help text by default', function() {
facade.getTooltip().isDisplayed().then(
function() {
return facade.getTooltip().getCssValue('display').then(
function(display) {
if (display !== 'none') {
throw Error('Help text should not be displayed');
}
});
},
function() {});
});
xit('should show help text on hover', function() {
browser.actions().mouseMove(facade.getHoverable('help')).perform();
it('should show help text on hover', function() {
browser.actions().mouseMove(facade.getHoverable()).perform();
var tooltip = facade.getTooltip('help');
var tooltip = facade.getTooltip();
expect(tooltip.isPresent() && tooltip.isDisplayed()).toBeTruthy();
browser.wait(function () {
return tooltip.isPresent() && tooltip.isDisplayed();
}, 1000);
});

@@ -145,6 +181,10 @@ });

beforeEach(function() {
radio = facade.getRadio('disabled');
groupLabel = facade.getGroupLabel('disabled');
femaleClickable = facade.getClickables('disabled').get(0);
maleClickable = facade.getClickables('disabled').get(1);
facade.setFieldName('disabled');
radio = facade.getRadio();
groupLabel = facade.getGroupLabel();
femaleInput = facade.getInputs().get(0);
femaleLabel = facade.getLabels().get(0);
maleInput = facade.getInputs().get(1);
maleLabel = facade.getLabels().get(1);
});

@@ -157,12 +197,17 @@

it('should be disabled based on html attributes', function () {
expect(femaleClickable.getAttribute('disabled')).toBe('true');
expect(maleClickable.getAttribute('disabled')).toBe('true');
expect(femaleInput.getAttribute('disabled')).toBe('true');
expect(maleInput.getAttribute('disabled')).toBe('true');
});
// TODO
xit('should not update the model on click', function () {
it('should not update the model on click', function () {
expect(radio.evaluate('model.bindable')).toBeFalsy();
femaleClickable.click();
maleClickable.click();
femaleInput.click().then(
function() {},
function() {}
);
maleInput.click().then(
function() {},
function() {}
);

@@ -173,12 +218,14 @@ expect(radio.evaluate('model.bindable')).toBeFalsy();

describe('invalid', function() {
it('should show an error', function () {
var errorText = facade.getErrorText('invalid');
describe('invalid', function() {
it('should show an error', function () {
facade.setFieldName('invalid');
browser.wait(function () {
return errorText.isPresent() && errorText.isDisplayed();
}, 1000);
});
});
var errorText = facade.getErrorText();
browser.wait(function () {
return errorText.isPresent() && errorText.isDisplayed();
}, 1000);
});
});
});
});

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc