From 1a2fe7eea19077def74588ae301d3f5758562966 Mon Sep 17 00:00:00 2001 From: Ionel Nicolenco Date: Thu, 8 Sep 2016 14:19:28 +0100 Subject: [PATCH] Added validationAttachTo attribute --- .../customvalidation/customValidations.js | 185 ++++++++++-------- dist/angular-ui-form-validation.js | 4 +- 2 files changed, 101 insertions(+), 88 deletions(-) diff --git a/app/scripts/directives/customvalidation/customValidations.js b/app/scripts/directives/customvalidation/customValidations.js index 36d9a3f..02aeae5 100644 --- a/app/scripts/directives/customvalidation/customValidations.js +++ b/app/scripts/directives/customvalidation/customValidations.js @@ -1,4 +1,4 @@ -angular_ui_form_validations = (function(){ +angular_ui_form_validations = (function () { var customValidations, createValidationFormatterLink, customValidationsModule, getValidationPriorityIndex, getValidationAttributeValue, getValidatorByAttribute, getCustomTemplateIfDefined, customTemplates, isCurrentlyDisplayingAnErrorMessageInATemplate, @@ -9,13 +9,13 @@ angular_ui_form_validations = (function(){ customValidations = []; var submitLink = function ($scope, $element, $attrs, ngModelController) { - if(typeof($attrs['validationSubmit']) === 'undefined') { + if (typeof ($attrs['validationSubmit']) === 'undefined') { return; } var validationSubmit = getValidationAttributeValue($attrs['validationSubmit'], 'onSubmit', true); var formName = getValidationAttributeValue($attrs['validationSubmit'], 'formName', true); - var form = angular.element('[name='+ formName +']'); - if(form.length === 0){ + var form = angular.element('[name=' + formName + ']'); + if (form.length === 0) { form = $element.parents('[name=' + formName + ']'); } validationSubmit = validationSubmit.substring(0, validationSubmit.indexOf('(')); @@ -49,7 +49,7 @@ angular_ui_form_validations = (function(){ }; var formValidityChangeListener = function (currentValidValue, previousValidValue) { - console.log('Entering formValidityChangeListener', {args: arguments}); + console.log('Entering formValidityChangeListener', { args: arguments }); var valid = currentValidValue; if (valid === true) { @@ -61,19 +61,19 @@ angular_ui_form_validations = (function(){ }; var isFormValid = function (scope) { - console.log('Entering isFormValid', {args: arguments}); + console.log('Entering isFormValid', { args: arguments }); var valid = false; var hasMissingRequiredField = false; var fields = form.children('input, select'); fields.each(function (index, field) { - if(field.value.trim() === "" && $(field).attr('validation-field-required') === "true") { + if (field.value.trim() === "" && $(field).attr('validation-field-required') === "true") { hasMissingRequiredField = true; false; } }); - if(hasMissingRequiredField === true) { + if (hasMissingRequiredField === true) { return false; } @@ -83,14 +83,14 @@ angular_ui_form_validations = (function(){ var numTotalFields = fields.length; var numValidatedFields = form.children('.ValidationLiveSuccess').length; - if(numTotalFields - numValidatedFields === 0) { + if (numTotalFields - numValidatedFields === 0) { valid = true; } return valid; }; - $scope.$watch( function (scope) { + $scope.$watch(function (scope) { console.log('Entering validation submit directive watch expression', { args: arguments }); @@ -109,9 +109,9 @@ angular_ui_form_validations = (function(){ }); $element.on('click', function () { - if(formIsValid === true){ - submitFunction.apply($scope, []); - } + if (formIsValid === true) { + submitFunction.apply($scope, []); + } }); formValidityChangeListener(isFormValid($scope)); @@ -122,7 +122,7 @@ angular_ui_form_validations = (function(){ errorCount: 0, latestElement: null, _errorMessage: 'Field is invalid', - _success: function () {}, + _success: function () { }, success: function () { return dynamicallyDefinedValidation._success && dynamicallyDefinedValidation._success.apply(this, arguments); }, @@ -145,7 +145,7 @@ angular_ui_form_validations = (function(){ var identifier, clone; identifier = 'validationdynamicallydefined'; - if(validation.identifier && validation.identifier !== '' && validation.identifier !== null) { + if (validation.identifier && validation.identifier !== '' && validation.identifier !== null) { identifier += validation.identifier.charAt(0).toUpperCase() + validation.identifier.slice(1).toLowerCase(); } else { identifier += index; @@ -168,8 +168,8 @@ angular_ui_form_validations = (function(){ .map(hydrateDynamicallyDefinedValidation) .map(setErrorIdentifier) .map(setValidity) - .each(function(valid){ - if(valid === false){ + .each(function (valid) { + if (valid === false) { dynamicallyDefinedValidation.errorCount++; dynamicallyDefinedValidation.latestElement = element; return false; @@ -182,7 +182,7 @@ angular_ui_form_validations = (function(){ }; onValidationComplete = function (fieldIsValid, value, validationAttributeValue, $element, model, ngModelController, $scope, customOnSuccess) { - if(fieldIsValid) { + if (fieldIsValid) { $element.addClass('ValidationLiveSuccess'); $element.addClass($element.attr('validation-live-success-cls')); $element.removeClass($element.attr('validation-live-fail-cls')); @@ -198,8 +198,8 @@ angular_ui_form_validations = (function(){ isCurrentlyDisplayingAnErrorMessageInATemplate = function (inputElement) { var isCurrentlyDisplayingAnErrorMessageInATemplate = false; Lazy(customTemplates) - .each(function(template){ - if(template.attr('templateUid') === inputElement.attr('templateUid')){ + .each(function (template) { + if (template.attr('templateUid') === inputElement.attr('templateUid')) { isCurrentlyDisplayingAnErrorMessageInATemplate = true; currentlyDisplayedTemplate = template; return false; @@ -211,33 +211,33 @@ angular_ui_form_validations = (function(){ getValidationAttributeValue = function (attr, property, strict) { var value; - if(attr === undefined) { + if (attr === undefined) { return undefined; } property = property || 'value'; value = attr; - try{ + try { var json = JSOL.parse(attr); } catch (e) { } - if(json !== null && typeof(json) === 'object'){ + if (json !== null && typeof (json) === 'object') { - if(json.hasOwnProperty(property)){ + if (json.hasOwnProperty(property)) { hasProperty = true; value = json[property]; } else { hasProperty = false; value = undefined; - if(strict !== true){ + if (strict !== true) { value = json.value; } } return value; - } else if(strict === true){ //strict assumes you must be passing in an object attr + } else if (strict === true) { //strict assumes you must be passing in an object attr return undefined; } @@ -247,7 +247,7 @@ angular_ui_form_validations = (function(){ getValidationAttributeByPropertyName = function (attr, property) { var value; - try{ + try { value = JSOL.parse(attr)[property]; } catch (e) { value = null; @@ -263,9 +263,9 @@ angular_ui_form_validations = (function(){ promise = deferred.promise; - try{ + try { templateUrl = JSOL.parse(attr)['template']; - if(templateUrl === undefined || templateUrl === null || templateUrl === '') { + if (templateUrl === undefined || templateUrl === null || templateUrl === '') { deferred.reject('No template url specified.'); } else { promise = templateRetriever.getTemplate(templateUrl); @@ -283,7 +283,7 @@ angular_ui_form_validations = (function(){ Lazy(customValidations) .each(function (validation) { - if(validation.customValidationAttribute === customValidationAttribute){ + if (validation.customValidationAttribute === customValidationAttribute) { validator = validation.validator; return false; } @@ -297,8 +297,8 @@ angular_ui_form_validations = (function(){ var index; Lazy(customValidations) - .each(function(validation, i){ - if(validation.customValidationAttribute === customValidationAttribute){ + .each(function (validation, i) { + if (validation.customValidationAttribute === customValidationAttribute) { index = i; return false; } @@ -313,53 +313,65 @@ angular_ui_form_validations = (function(){ $timeout = timeout; $log = log; - return function($scope, $element, $attrs, ngModelController) { + return function ($scope, $element, $attrs, ngModelController) { var customErrorMessage, errorMessage, errorMessageElement, modelName, model, propertyName, runCustomValidations, validationAttributeValue, customErrorTemplate; - $timeout(function() { + $timeout(function () { var getErrorMessageElement, addWatcherForDynamicallyDefinedValidations, addWatcherToWrapErrorInCustomTemplate, isValidValidationAttributeValue, getFormatterArgsErrorMessage, installErrorMessageElement, installSpecialErrorCases; var rawCustomValidationAttribute = $attrs[formatterArgs.customValidationAttribute]; validationAttributeValue = getValidationAttributeValue(rawCustomValidationAttribute); - isValidValidationAttributeValue = ( validationAttributeValue && ( validationAttributeValue !== 'undefined' ) - && ( validationAttributeValue !== 'false' ) ); + isValidValidationAttributeValue = (validationAttributeValue && (validationAttributeValue !== 'undefined') + && (validationAttributeValue !== 'false')); getErrorMessageElement = function () { var ifCheckboxOrRadio = ''; - if((/checkbox|radio/).test($element[0].type)){ + if ((/checkbox|radio/).test($element[0].type)) { ifCheckboxOrRadio = 'checkboxradioerror '; } return angular.element( - '' + + '' + errorMessage + ''); }; addWatcherForDynamicallyDefinedValidations = function () { - $scope.$watch(function(){ return dynamicallyDefinedValidation.errorCount; }, function () { + $scope.$watch(function () { return dynamicallyDefinedValidation.errorCount; }, function () { if (dynamicallyDefinedValidation.errorCount === 0) { return; } var currentElementFieldName = errorMessageElement.attr('data-custom-field-name'); var latestValidatedFieldName = dynamicallyDefinedValidation.latestElement.attr('name'); - if(latestValidatedFieldName === currentElementFieldName) { + if (latestValidatedFieldName === currentElementFieldName) { errorMessageElement.html(dynamicallyDefinedValidation.errorMessage()); } }); }; + function getMessageTargetElement(originalElement) { + var targetElement = originalElement; + //This will enable to declare a target element by id to use for attaching the message + if (typeof $attrs.validationAttachTo != 'undefined') { + targetElement = $('#' + $attrs.validationAttachTo); + if (targetElement.length === 0) { + targetElement = originalElement; + } + } + return targetElement; + } + addWatcherToWrapErrorInCustomTemplate = function (template) { var errorMessageToggled; customErrorTemplate = angular.element(template); customErrorTemplate.html(''); errorMessageToggled = function () { var templateUid = Math.random(); - if(errorMessageElement.css('display') === 'inline' || errorMessageElement.css('display') === 'block') { + if (errorMessageElement.css('display') === 'inline' || errorMessageElement.css('display') === 'block') { $log.log('error showing'); $element.attr('templateUid', templateUid); customErrorTemplate.attr('templateUid', templateUid); @@ -368,13 +380,13 @@ angular_ui_form_validations = (function(){ } else { $log.log('error NOT showing'); $element.removeAttr('templateUid'); - if(errorMessageElement.parent().is('.' + customErrorTemplate.attr('class'))){ + if (errorMessageElement.parent().is('.' + customErrorTemplate.attr('class'))) { errorMessageElement.unwrap(customErrorTemplate); } } }; - $scope.$watch(function (){ + $scope.$watch(function () { return errorMessageElement.css('display'); }, errorMessageToggled); $scope.$on('errorMessageToggled', errorMessageToggled); @@ -383,7 +395,7 @@ angular_ui_form_validations = (function(){ getFormatterArgsErrorMessage = function () { var errorMessage; - if(typeof(formatterArgs.errorMessage) === 'function'){ + if (typeof (formatterArgs.errorMessage) === 'function') { errorMessage = formatterArgs.errorMessage(validationAttributeValue); } else { errorMessage = formatterArgs.errorMessage; @@ -396,11 +408,11 @@ angular_ui_form_validations = (function(){ errorMessageElement = getErrorMessageElement(); - $element.after(errorMessageElement); + getMessageTargetElement($element).after(errorMessageElement); errorMessageElement.hide(); - if(formatterArgs.customValidationAttribute === 'validationDynamicallyDefined') { + if (formatterArgs.customValidationAttribute === 'validationDynamicallyDefined') { addWatcherForDynamicallyDefinedValidations(); } @@ -410,15 +422,15 @@ angular_ui_form_validations = (function(){ }); customErrorMessage = getValidationAttributeByPropertyName($attrs[formatterArgs.customValidationAttribute], 'message'); - if(customErrorMessage !== null) { + if (customErrorMessage !== null) { errorMessageElement.html(customErrorMessage); } }; installSpecialErrorCases = function () { - if (formatterArgs.customValidationAttribute === 'validationNoSpace') { - $element.keyup(function (event){ + if (formatterArgs.customValidationAttribute === 'validationNoSpace') { + $element.keyup(function (event) { if (event.keyCode === 8) { model[propertyName] = ($element.val().replace(/\s+$/, '')); } @@ -435,7 +447,7 @@ angular_ui_form_validations = (function(){ $($element.parent()).on('keyup blur', validationConfirmPasswordHandlerSelector, function (target) { - console.log('Entering validationConfirmPassword keyup blur handler', {args: arguments}); + console.log('Entering validationConfirmPassword keyup blur handler', { args: arguments }); console.log('validationConfirmPassword handler selector' + validationConfirmPasswordHandlerSelector); var passwordMatch, confirmPasswordIsDirty; @@ -443,17 +455,17 @@ angular_ui_form_validations = (function(){ confirmPasswordIsDirty = /dirty/.test(confirmPasswordElement.attr('class')); - if(confirmPasswordIsDirty === false) { + if (confirmPasswordIsDirty === false) { return; } - passwordMatch = passwordElement.val() === $element.val(); + passwordMatch = passwordElement.val() === $element.val(); console.log('--- validationConfirmPassword keyup blur handler passwordMatch', passwordMatch); ngModelController.$setValidity('validationconfirmpassword', passwordMatch); - confirmPasswordElement.siblings('.CustomValidationError.validationConfirmPassword:first').toggle(! passwordMatch); + confirmPasswordElement.siblings('.CustomValidationError.validationConfirmPassword:first').toggle(!passwordMatch); onValidationComplete(passwordMatch, passwordMatch, validationAttributeValue, $element, model, ngModelController, $scope, function () { console.log('Entering validationConfirmPassword onCustomSuccess callback'); @@ -467,7 +479,7 @@ angular_ui_form_validations = (function(){ } if (formatterArgs.customValidationAttribute === 'validationFieldRequired') { - $element.parents('form').find('label[for='+$element.attr('id')+']').addClass('requiredFieldLabel'); + $element.parents('form').find('label[for=' + $element.attr('id') + ']').addClass('requiredFieldLabel'); } }; @@ -483,9 +495,9 @@ angular_ui_form_validations = (function(){ //assuming non-blur events suggest a keypress/keyup/keydown/input event //only blur and runCustomValidations events are always evaluated automatically regardless of validateWhileEntering - if(eventType !== 'blur' && eventType !== 'runCustomValidations') { + if (eventType !== 'blur' && eventType !== 'runCustomValidations') { //validating non-blur events only when formatterArgs have specified to validateWhileEntering - if(formatterArgs.validateWhileEntering && formatterArgs.validateWhileEntering === true) { + if (formatterArgs.validateWhileEntering && formatterArgs.validateWhileEntering === true) { //Do nothing continue on } else { //TOOD: figure out why returning here is causing the cursor to be set to last position and @@ -498,45 +510,45 @@ angular_ui_form_validations = (function(){ value = getElementValue(); //Do not validate if input is pristine, i.e nothing entered by user yet - if($element.hasClass('ng-pristine') && eventType !=='runCustomValidations'){ + if ($element.hasClass('ng-pristine') && eventType !== 'runCustomValidations') { console.log('--- runCustomValidations not validating because pristine'); return value; } - successFn = formatterArgs.success || function(){}; + successFn = formatterArgs.success || function () { }; - function getCurrentlyDisplayingErrorMessage () { + function getCurrentlyDisplayingErrorMessage() { var fieldNameSelector, selector; - fieldNameSelector = '[data-custom-field-name="'+ $element.attr('name') +'"]'; - selector = '.CustomValidationError[style="display: inline;"]'+fieldNameSelector+', '+ - '.CustomValidationError[style="display: block;"]'+fieldNameSelector; + fieldNameSelector = '[data-custom-field-name="' + $element.attr('name') + '"]'; + selector = '.CustomValidationError[style="display: inline;"]' + fieldNameSelector + ', ' + + '.CustomValidationError[style="display: block;"]' + fieldNameSelector; - if(isCurrentlyDisplayingAnErrorMessageInATemplate($element)) { + if (isCurrentlyDisplayingAnErrorMessageInATemplate($element)) { return currentlyDisplayedTemplate.children(selector); } else { - return $element.siblings(selector); + return getMessageTargetElement($element).siblings(selector); } } function getElementValue() { var value = $element.val().replace(/\s+$/, ''); - if((/select/).test($element[0].type)){ + if ((/select/).test($element[0].type)) { value = $element[0].options[$element[0].selectedIndex].innerHTML; } - if((/checkbox|radio/).test($element[0].type)){ - value = $element[0].checked === true? 'true' : ''; + if ((/checkbox|radio/).test($element[0].type)) { + value = $element[0].checked === true ? 'true' : ''; } return value; } function toggleRequiredLabelClass() { - if(value === '') { - $element.parents('form').find('label[for='+$element.attr('id')+']').addClass('requiredFieldLabel'); + if (value === '') { + $element.parents('form').find('label[for=' + $element.attr('id') + ']').addClass('requiredFieldLabel'); } else { - $element.parents('form').find('label[for='+$element.attr('id')+']').removeClass('requiredFieldLabel'); + $element.parents('form').find('label[for=' + $element.attr('id') + ']').removeClass('requiredFieldLabel'); } } @@ -546,18 +558,19 @@ angular_ui_form_validations = (function(){ ngModelController, $scope, rawCustomValidationAttribute); } - function getPropertyNameClass (pname) { + function getPropertyNameClass(pname) { return pname.replace('.', '\\.'); } function whenIsNotCurrentlyDisplayingAnErrorMessage() { $log.log('is not currently displaying an error message', customValidationBroadcastArg); - var classNames = ".CustomValidationError."+ formatterArgs.customValidationAttribute + "." + getPropertyNameClass(propertyName) + "property:first"; + var classNames = ".CustomValidationError." + formatterArgs.customValidationAttribute + "." + getPropertyNameClass(propertyName) + "property:first"; $log.log(classNames); - $element.siblings(classNames).toggle(!isValid); + + getMessageTargetElement($element).siblings(classNames).toggle(!isValid); } - function whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate(){ + function whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate() { $log.log('is not currently displaying an error message in a template', customValidationBroadcastArg); currentErrorMessageValidator = getValidatorByAttribute(currentErrorMessage.attr('data-custom-validation-attribute')); currentErrorMessageIsStale = currentErrorMessageValidator(errorMessageElement.clone(), value, $attrs[currentErrorMessage.attr('data-custom-validation-attribute')], $element, model, ngModelController, $scope, rawCustomValidationAttribute); @@ -567,12 +580,12 @@ angular_ui_form_validations = (function(){ if (currentErrorMessageIsStale || (!currentErrorMessageIsStale && currentErrorMessageIsOfALowerPriority && !isValid)) { currentErrorMessage.hide(); - $element.siblings('.CustomValidationError.'+ formatterArgs.customValidationAttribute + '.' + getPropertyNameClass(propertyName) + 'property:first') + getMessageTargetElement($element).siblings('.CustomValidationError.' + formatterArgs.customValidationAttribute + '.' + getPropertyNameClass(propertyName) + 'property:first') .toggle(!isValid); } } - function whenIsCurrentlyDisplayingAnErrorMessageInATemplate(){ + function whenIsCurrentlyDisplayingAnErrorMessageInATemplate() { $log.log('is currently displaying an error message in a template', customValidationBroadcastArg); currentErrorMessageValidator = getValidatorByAttribute(currentErrorMessage.attr('data-custom-validation-attribute')); currentErrorMessageIsStale = currentErrorMessageValidator( @@ -588,7 +601,7 @@ angular_ui_form_validations = (function(){ if (currentErrorMessageIsStale || (!currentErrorMessageIsStale && currentErrorMessageIsOfALowerPriority && !isValid && currentlyDisplayedTemplate.children().attr('class').indexOf(formatterArgs.customValidationAttribute) === -1)) { currentErrorMessage.hide(); - $element.siblings('.CustomValidationError.'+ formatterArgs.customValidationAttribute + '.' + getPropertyNameClass(propertyName) + 'property:first') + getMessageTargetElement($element).siblings('.CustomValidationError.' + formatterArgs.customValidationAttribute + '.' + getPropertyNameClass(propertyName) + 'property:first') .toggle(!isValid); $scope.$broadcast('errorMessageToggled'); } @@ -628,13 +641,13 @@ angular_ui_form_validations = (function(){ console.log('--- runCustomValidations currentlyDisplayingAnErrorMessage ' + currentlyDisplayingAnErrorMessage); - if(! currentlyDisplayingAnErrorMessage) { + if (!currentlyDisplayingAnErrorMessage) { whenIsNotCurrentlyDisplayingAnErrorMessage(); - } else if(! isCurrentlyDisplayingAnErrorMessageInATemplate($element)){ + } else if (!isCurrentlyDisplayingAnErrorMessageInATemplate($element)) { whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate(); } - if(isCurrentlyDisplayingAnErrorMessageInATemplate($element)) { + if (isCurrentlyDisplayingAnErrorMessageInATemplate($element)) { console.log('--- runCustomValidations isCurrentlyDisplayingAnErrorMessageInATemplate'); whenIsCurrentlyDisplayingAnErrorMessageInATemplate(); } @@ -657,7 +670,7 @@ angular_ui_form_validations = (function(){ installSpecialErrorCases(); - ngModelController.$parsers.push(function() { + ngModelController.$parsers.push(function () { return runCustomValidations('input'); }); @@ -712,10 +725,10 @@ angular_ui_form_validations = (function(){ customValidationAttribute: 'validationFieldRequired', validateWhileEntering: true, errorMessage: 'This is a required field', - validator: function (errorMessageElement, val){ + validator: function (errorMessageElement, val) { return (/\S/).test(val); } - }) + }) }; }) diff --git a/dist/angular-ui-form-validation.js b/dist/angular-ui-form-validation.js index 3026397..02cb8af 100644 --- a/dist/angular-ui-form-validation.js +++ b/dist/angular-ui-form-validation.js @@ -1,3 +1,3 @@ !function(context){function Lazy(source){if(source instanceof Array)return new ArrayWrapper(source);if("string"==typeof source)return new StringWrapper(source);if(source instanceof Sequence)return source;if(Lazy.extensions){for(var result,extensions=Lazy.extensions,length=extensions.length;!result&&length--;)result=extensions[length](source);if(result)return result}return new ObjectWrapper(source)}function Sequence(){}function Iterator(sequence){this.sequence=sequence,this.index=-1}function MemoizedSequence(parent){this.parent=parent}function MappedSequence(parent,mapFn){this.parent=parent,this.mapFn=mapFn}function MappingIterator(sequence,mapFn){this.iterator=sequence.getIterator(),this.mapFn=mapFn,this.index=-1}function FilteredSequence(parent,filterFn){this.parent=parent,this.filterFn=filterFn}function FilteringIterator(sequence,filterFn){this.iterator=sequence.getIterator(),this.filterFn=filterFn,this.index=0}function ReversedSequence(parent){this.parent=parent}function ReversedIterator(sequence){this.sequence=sequence}function ConcatenatedSequence(parent,arrays){this.parent=parent,this.arrays=arrays}function TakeSequence(parent,count){this.parent=parent,this.count=count}function TakeIterator(sequence,count){this.iterator=sequence.getIterator(),this.count=count}function TakeWhileSequence(parent,predicate){this.parent=parent,this.predicate=predicate}function DropSequence(parent,count){this.parent=parent,this.count="number"==typeof count?count:1}function DropWhileSequence(parent,predicate){this.parent=parent,this.predicate=predicate}function SortedSequence(parent,sortFn){this.parent=parent,this.sortFn=sortFn}function GroupedSequence(parent,keyFn){this.parent=parent,this.keyFn=keyFn}function CountedSequence(parent,keyFn){this.parent=parent,this.keyFn=keyFn}function UniqueSequence(parent,keyFn){this.parent=parent,this.keyFn=keyFn}function ZippedSequence(parent,arrays){this.parent=parent,this.arrays=arrays}function ShuffledSequence(parent){this.parent=parent}function FlattenedSequence(parent){this.parent=parent}function WithoutSequence(parent,values){this.parent=parent,this.values=values}function IntersectionSequence(parent,arrays){this.parent=parent,this.arrays=arrays}function UniqueMemoizer(iterator){this.iterator=iterator,this.set=new Set,this.memo=[],this.currentValue=void 0}function ChunkedSequence(parent,size){this.parent=parent,this.chunkSize=size}function ChunkedIterator(sequence,size){this.iterator=sequence.getIterator(),this.size=size}function TappedSequence(parent,callback){this.parent=parent,this.callback=callback}function SimpleIntersectionSequence(parent,array){this.parent=parent,this.array=array,this.each=getEachForIntersection(array)}function getEachForIntersection(source){return source.length<40?SimpleIntersectionSequence.prototype.eachArrayCache:SimpleIntersectionSequence.prototype.eachMemoizerCache}function SimpleZippedSequence(parent,array){this.parent=parent,this.array=array}function ArrayLikeSequence(){}function IndexedIterator(sequence){this.sequence=sequence,this.index=-1}function IndexedMappedSequence(parent,mapFn){this.parent=parent,this.mapFn=mapFn}function IndexedFilteredSequence(parent,filterFn){this.parent=parent,this.filterFn=filterFn}function IndexedReversedSequence(parent){this.parent=parent}function IndexedTakeSequence(parent,count){this.parent=parent,this.count=count}function IndexedDropSequence(parent,count){this.parent=parent,this.count="number"==typeof count?count:1}function IndexedConcatenatedSequence(parent,other){this.parent=parent,this.other=other}function IndexedUniqueSequence(parent,keyFn){this.parent=parent,this.each=getEachForParent(parent),this.keyFn=keyFn}function getEachForParent(parent){return parent.length()<100?IndexedUniqueSequence.prototype.eachArrayCache:UniqueSequence.prototype.each}function ArrayWrapper(source){this.source=source}function MappedArrayWrapper(parent,mapFn){this.parent=parent,this.mapFn=mapFn}function FilteredArrayWrapper(parent,filterFn){this.parent=parent,this.filterFn=filterFn}function UniqueArrayWrapper(parent,keyFn){this.parent=parent,this.each=getEachForSource(parent.source),this.keyFn=keyFn}function getEachForSource(source){return source.length<40?UniqueArrayWrapper.prototype.eachNoCache:source.length<100?UniqueArrayWrapper.prototype.eachArrayCache:UniqueArrayWrapper.prototype.eachSetCache}function ConcatArrayWrapper(parent,other){this.parent=parent,this.other=other}function ObjectLikeSequence(){}function AssignSequence(parent,other){this.parent=parent,this.other=other}function DefaultsSequence(parent,defaults){this.parent=parent,this.defaults=defaults}function InvertedSequence(parent){this.parent=parent}function MergedSequence(parent,others,mergeFn){this.parent=parent,this.others=others,this.mergeFn=mergeFn}function mergeObjects(a,b){if("undefined"==typeof b)return a;if("object"!=typeof a||null===a||"object"!=typeof b||null===b)return b;var prop,merged={};for(prop in a)merged[prop]=mergeObjects(a[prop],b[prop]);for(prop in b)merged[prop]||(merged[prop]=b[prop]);return merged}function PickSequence(parent,properties){this.parent=parent,this.properties=properties}function OmitSequence(parent,properties){this.parent=parent,this.properties=properties}function ObjectWrapper(source){this.source=source}function StringLikeSequence(){}function CharIterator(source){this.source=Lazy(source),this.index=-1}function StringSegment(parent,start,stop){this.parent=parent,this.start=Math.max(0,start),this.stop=stop}function MappedStringLikeSequence(parent,mapFn){this.parent=parent,this.mapFn=mapFn}function ReversedStringLikeSequence(parent){this.parent=parent}function StringMatchSequence(source,pattern){this.source=source,this.pattern=pattern}function StringMatchIterator(source,pattern){this.source=source,this.pattern=cloneRegex(pattern)}function SplitStringSequence(source,pattern){this.source=source,this.pattern=pattern}function SplitWithRegExpIterator(source,pattern){this.source=source,this.pattern=cloneRegex(pattern)}function SplitWithStringIterator(source,delimiter){this.source=source,this.delimiter=delimiter}function StringWrapper(source){this.source=source}function GeneratedSequence(generatorFn,length){this.get=generatorFn,this.fixedLength=length}function GeneratedIterator(sequence){this.sequence=sequence,this.index=0,this.currentValue=null}function AsyncSequence(parent,interval){if(parent instanceof AsyncSequence)throw"Sequence is already asynchronous!";this.parent=parent,this.interval=interval,this.onNextCallback=getOnNextCallback(interval)}function AsyncHandle(interval){this.cancelCallback=getCancelCallback(interval)}function getOnNextCallback(interval){return"undefined"==typeof interval&&"function"==typeof setImmediate?setImmediate:(interval=interval||0,function(fn){return setTimeout(fn,interval)})}function getCancelCallback(interval){return"undefined"==typeof interval&&"function"==typeof clearImmediate?clearImmediate:clearTimeout}function WatchedPropertySequence(object,propertyNames){this.listeners=[],propertyNames?propertyNames instanceof Array||(propertyNames=[propertyNames]):propertyNames=Lazy(object).keys().toArray();var listeners=this.listeners,index=0;Lazy(propertyNames).each(function(propertyName){var propertyValue=object[propertyName];Object.defineProperty(object,propertyName,{get:function(){return propertyValue},set:function(value){for(var i=listeners.length-1;i>=0;--i)listeners[i]({property:propertyName,value:value},index)===!1&&listeners.splice(i,1);propertyValue=value,++index}})})}function StreamLikeSequence(){}function SplitStreamSequence(parent,delimiter){this.parent=parent,this.delimiter=delimiter}function MatchedStreamSequence(parent,pattern){this.parent=parent,this.pattern=cloneRegex(pattern)}function createCallback(callback,defaultValue){switch(typeof callback){case"function":return callback;case"string":return function(e){return e[callback]};case"object":return function(e){return Lazy(callback).all(function(value,key){return e[key]===value})};case"undefined":return defaultValue?function(){return defaultValue}:Lazy.identity;default:throw"Don't know how to make a callback from a "+typeof callback+"!"}}function createSet(values){var set=new Set;return Lazy(values||[]).flatten().each(function(e){set.add(e)}),set}function compare(x,y,fn){return"function"==typeof fn?compare(fn(x),fn(y)):x===y?0:x>y?1:-1}function forEach(array,fn){for(var i=-1,len=array.length;++i=cachedIndex.length()-1?!1:(++this.index,!0)},Sequence.prototype.toArray=function(){return this.reduce(function(arr,element){return arr.push(element),arr},[])},Sequence.prototype.getIndex=function(){return this.cachedIndex||(this.cachedIndex=new ArrayWrapper(this.toArray())),this.cachedIndex},Sequence.prototype.memoize=function(){return new MemoizedSequence(this)},Sequence.prototype.toObject=function(){return this.reduce(function(object,pair){return object[pair[0]]=pair[1],object},{})},Sequence.prototype.each=function(fn){for(var iterator=this.getIterator(),i=-1;iterator.moveNext();)if(fn(iterator.current(),++i)===!1)return!1;return!0},Sequence.prototype.forEach=function(fn){return this.each(fn)},Sequence.prototype.map=function(mapFn){return new MappedSequence(this,createCallback(mapFn))},Sequence.prototype.collect=function(mapFn){return this.map(mapFn)},MappedSequence.prototype=new Sequence,MappedSequence.prototype.getIterator=function(){return new MappingIterator(this.parent,this.mapFn)},MappedSequence.prototype.each=function(fn){var mapFn=this.mapFn;return this.parent.each(function(e,i){return fn(mapFn(e,i),i)})},MappingIterator.prototype.current=function(){return this.mapFn(this.iterator.current(),this.index)},MappingIterator.prototype.moveNext=function(){return this.iterator.moveNext()?(++this.index,!0):!1},Sequence.prototype.pluck=function(property){return this.map(property)},Sequence.prototype.invoke=function(methodName){return this.map(function(e){return e[methodName]()})},Sequence.prototype.filter=function(filterFn){return new FilteredSequence(this,createCallback(filterFn))},Sequence.prototype.select=function(filterFn){return this.filter(filterFn)},FilteredSequence.prototype=new Sequence,FilteredSequence.prototype.getIterator=function(){return new FilteringIterator(this.parent,this.filterFn)},FilteredSequence.prototype.each=function(fn){var filterFn=this.filterFn;return this.parent.each(function(e,i){return filterFn(e,i)?fn(e,i):void 0})},FilteredSequence.prototype.reverse=function(){return this.parent.reverse().filter(this.filterFn)},FilteringIterator.prototype.current=function(){return this.value},FilteringIterator.prototype.moveNext=function(){for(var value,iterator=this.iterator,filterFn=this.filterFn;iterator.moveNext();)if(value=iterator.current(),filterFn(value,this.index++))return this.value=value,!0;return this.value=void 0,!1},Sequence.prototype.reject=function(rejectFn){return rejectFn=createCallback(rejectFn),this.filter(function(e){return!rejectFn(e)})},Sequence.prototype.ofType=function(type){return this.filter(function(e){return typeof e===type})},Sequence.prototype.where=function(properties){return this.filter(properties)},Sequence.prototype.reverse=function(){return new ReversedSequence(this)},ReversedSequence.prototype=new Sequence,ReversedSequence.prototype.getIterator=function(){return new ReversedIterator(this.parent)},ReversedIterator.prototype.current=function(){return this.sequence.getIndex().get(this.index)},ReversedIterator.prototype.moveNext=function(){var indexed=this.sequence.getIndex(),length=indexed.length();return"undefined"==typeof this.index&&(this.index=length),--this.index>=0},Sequence.prototype.concat=function(var_args){return new ConcatenatedSequence(this,arraySlice.call(arguments,0))},ConcatenatedSequence.prototype=new Sequence,ConcatenatedSequence.prototype.each=function(fn){var done=!1,i=0;this.parent.each(function(e){return fn(e,i++)===!1?(done=!0,!1):void 0}),done||Lazy(this.arrays).flatten().each(function(e){return fn(e,i++)===!1?!1:void 0})},Sequence.prototype.first=function(count){return"undefined"==typeof count?getFirst(this):new TakeSequence(this,count)},Sequence.prototype.head=Sequence.prototype.take=function(count){return this.first(count)},TakeSequence.prototype=new Sequence,TakeSequence.prototype.getIterator=function(){return new TakeIterator(this.parent,this.count)},TakeSequence.prototype.each=function(fn){var count=this.count,i=0;this.parent.each(function(e){var result;return count>i&&(result=fn(e,i)),++i>=count?!1:result})},TakeIterator.prototype.current=function(){return this.iterator.current()},TakeIterator.prototype.moveNext=function(){return--this.count>=0&&this.iterator.moveNext()},Sequence.prototype.takeWhile=function(predicate){return new TakeWhileSequence(this,predicate)},TakeWhileSequence.prototype=new Sequence,TakeWhileSequence.prototype.each=function(fn){var predicate=this.predicate;this.parent.each(function(e){return predicate(e)&&fn(e)})},Sequence.prototype.initial=function(count){return"undefined"==typeof count&&(count=1),this.take(this.getIndex().length()-count)},Sequence.prototype.last=function(count){return"undefined"==typeof count?this.reverse().first():this.reverse().take(count).reverse()},Sequence.prototype.findWhere=function(properties){return this.where(properties).first()},Sequence.prototype.rest=function(count){return new DropSequence(this,count)},Sequence.prototype.skip=Sequence.prototype.tail=Sequence.prototype.drop=function(count){return this.rest(count)},DropSequence.prototype=new Sequence,DropSequence.prototype.each=function(fn){var count=this.count,dropped=0,i=0;this.parent.each(function(e){return dropped++i&&group.push(arrays[j][i]);return fn(group,i++)})},Sequence.prototype.shuffle=function(){return new ShuffledSequence(this)},ShuffledSequence.prototype=new Sequence,ShuffledSequence.prototype.each=function(fn){for(var shuffled=this.parent.toArray(),floor=Math.floor,random=Math.random,j=0,i=shuffled.length-1;i>0;--i)if(swap(shuffled,i,floor(random()*i)+1),fn(shuffled[i],j++)===!1)return;fn(shuffled[0],j)},Sequence.prototype.flatten=function(){return new FlattenedSequence(this)},FlattenedSequence.prototype=new Sequence,FlattenedSequence.prototype.each=function(fn){var index=0;return this.parent.each(function recurseVisitor(e){return e instanceof Array?forEach(e,recurseVisitor):e instanceof Sequence?e.each(recurseVisitor):fn(e,index++)})},Sequence.prototype.compact=function(){return this.filter(function(e){return!!e})},Sequence.prototype.without=function(var_args){return new WithoutSequence(this,arraySlice.call(arguments,0))},Sequence.prototype.difference=function(var_args){return this.without.apply(this,arguments)},WithoutSequence.prototype=new Sequence,WithoutSequence.prototype.each=function(fn){var set=createSet(this.values),i=0;return this.parent.each(function(e){return set.contains(e)?void 0:fn(e,i++)})},Sequence.prototype.union=function(var_args){return this.concat(var_args).uniq()},Sequence.prototype.intersection=function(var_args){return 1===arguments.length&&arguments[0]instanceof Array?new SimpleIntersectionSequence(this,var_args):new IntersectionSequence(this,arraySlice.call(arguments,0))},IntersectionSequence.prototype=new Sequence,IntersectionSequence.prototype.each=function(fn){var sets=Lazy(this.arrays).map(function(values){return new UniqueMemoizer(Lazy(values).getIterator())}),setIterator=new UniqueMemoizer(sets.getIterator()),i=0;return this.parent.each(function(e){var includedInAll=!0;return setIterator.each(function(set){return set.contains(e)?void 0:(includedInAll=!1,!1)}),includedInAll?fn(e,i++):void 0})},UniqueMemoizer.prototype.current=function(){return this.currentValue},UniqueMemoizer.prototype.moveNext=function(){for(var current,iterator=this.iterator,set=this.set,memo=this.memo;iterator.moveNext();)if(current=iterator.current(),set.add(current))return memo.push(current),this.currentValue=current,!0;return!1},UniqueMemoizer.prototype.each=function(fn){for(var memo=this.memo,length=memo.length,i=-1;++ilower;)i=lower+upper>>>1,-1===compare(indexed.get(i),value)?lower=i+1:upper=i;return lower},Sequence.prototype.contains=function(value){return-1!==this.indexOf(value)},Sequence.prototype.reduce=function(aggregator,memo){return arguments.length<2?this.tail().reduce(aggregator,this.head()):(this.each(function(e,i){memo=aggregator(memo,e,i)}),memo)},Sequence.prototype.inject=Sequence.prototype.foldl=function(aggregator,memo){return this.reduce(aggregator,memo)},Sequence.prototype.reduceRight=function(aggregator,memo){if(arguments.length<2)return this.initial(1).reduceRight(aggregator,this.last());var i=this.getIndex().length()-1;return this.reverse().reduce(function(m,e){return aggregator(m,e,i--)},memo)},Sequence.prototype.foldr=function(aggregator,memo){return this.reduceRight(aggregator,memo)},Sequence.prototype.consecutive=function(count){var queue=new Queue(count),segments=this.map(function(element){return queue.add(element).count===count?queue.toArray():void 0});return segments.compact()},Sequence.prototype.chunk=function(size){if(1>size)throw"You must specify a positive chunk size.";return new ChunkedSequence(this,size)},ChunkedSequence.prototype=new Sequence,ChunkedSequence.prototype.getIterator=function(){return new ChunkedIterator(this.parent,this.chunkSize)},ChunkedIterator.prototype.current=function(){return this.currentChunk},ChunkedIterator.prototype.moveNext=function(){for(var iterator=this.iterator,chunkSize=this.size,chunk=[];chunk.lengthy?y:x},1/0)},Sequence.prototype.minBy=function(valueFn){return valueFn=createCallback(valueFn),this.reduce(function(x,y){return valueFn(y)x?y:x},-(1/0))},Sequence.prototype.maxBy=function(valueFn){return valueFn=createCallback(valueFn),this.reduce(function(x,y){return valueFn(y)>valueFn(x)?y:x})},Sequence.prototype.sum=function(valueFn){return"undefined"!=typeof valueFn?this.sumBy(valueFn):this.reduce(function(x,y){return x+y},0)},Sequence.prototype.sumBy=function(valueFn){return valueFn=createCallback(valueFn),this.reduce(function(x,y){return x+valueFn(y)},0)},Sequence.prototype.join=function(delimiter){return delimiter="string"==typeof delimiter?delimiter:",",this.reduce(function(str,e){return str.length>0&&(str+=delimiter),str+e},"")},Sequence.prototype.toString=function(delimiter){return this.join(delimiter)},Sequence.prototype.async=function(interval){return new AsyncSequence(this,interval)},SimpleIntersectionSequence.prototype=new Sequence,SimpleIntersectionSequence.prototype.eachMemoizerCache=function(fn){var iterator=new UniqueMemoizer(Lazy(this.array).getIterator()),i=0;return this.parent.each(function(e){return iterator.contains(e)?fn(e,i++):void 0})},SimpleIntersectionSequence.prototype.eachArrayCache=function(fn){var array=this.array,find=arrayContains,i=0;return this.parent.each(function(e){return find(array,e)?fn(e,i++):void 0})},SimpleZippedSequence.prototype=new Sequence,SimpleZippedSequence.prototype.each=function(fn){var array=this.array;return this.parent.each(function(e,i){return fn([e,array[i]],i)})},ArrayLikeSequence.prototype=new Sequence,ArrayLikeSequence.define=function(methodName,overrides){if(!overrides||"function"!=typeof overrides.get)throw"A custom array-like sequence must implement *at least* get!";return defineSequenceType(ArrayLikeSequence,methodName,overrides)},ArrayLikeSequence.prototype.get=function(i){return this.parent.get(i)},ArrayLikeSequence.prototype.length=function(){return this.parent.length()},ArrayLikeSequence.prototype.getIndex=function(){return this},ArrayLikeSequence.prototype.getIterator=function(){return new IndexedIterator(this)},IndexedIterator.prototype.current=function(){return this.sequence.get(this.index)},IndexedIterator.prototype.moveNext=function(){return this.index>=this.sequence.length()-1?!1:(++this.index,!0)},ArrayLikeSequence.prototype.each=function(fn){for(var length=this.length(),i=-1;++ibegin&&(begin=length+begin);var result=this.drop(begin);return"number"==typeof end&&(0>end&&(end=length+end),result=result.take(end-begin)),result},ArrayLikeSequence.prototype.map=function(mapFn){return new IndexedMappedSequence(this,createCallback(mapFn))},IndexedMappedSequence.prototype=new ArrayLikeSequence,IndexedMappedSequence.prototype.get=function(i){return 0>i||i>=this.parent.length()?void 0:this.mapFn(this.parent.get(i),i)},ArrayLikeSequence.prototype.filter=function(filterFn){return new IndexedFilteredSequence(this,createCallback(filterFn))},IndexedFilteredSequence.prototype=new FilteredSequence,IndexedFilteredSequence.prototype.each=function(fn){for(var e,parent=this.parent,filterFn=this.filterFn,length=this.parent.length(),i=-1;++ii?this.parent.get(i):this.other[i-parentLength]},IndexedConcatenatedSequence.prototype.length=function(){return this.parent.length()+this.other.length},ArrayLikeSequence.prototype.uniq=function(keyFn){return new IndexedUniqueSequence(this,createCallback(keyFn))},IndexedUniqueSequence.prototype=new Sequence,IndexedUniqueSequence.prototype.eachArrayCache=function(fn){for(var key,value,parent=this.parent,keyFn=this.keyFn,length=parent.length(),cache=[],find=arrayContains,i=-1,j=0;++ii||i>=source.length?void 0:this.mapFn(source[i])},MappedArrayWrapper.prototype.length=function(){return this.parent.source.length},MappedArrayWrapper.prototype.each=function(fn){for(var source=this.parent.source,length=source.length,mapFn=this.mapFn,i=-1;++ii?source[i]:this.other[i-sourceLength]},ConcatArrayWrapper.prototype.length=function(){return this.parent.source.length+this.other.length},ConcatArrayWrapper.prototype.each=function(fn){for(var source=this.parent.source,sourceLength=source.length,other=this.other,otherLength=other.length,i=0,j=-1;++j1&&"function"==typeof arguments[arguments.length-1]?arrayPop.call(arguments):null;return new MergedSequence(this,arraySlice.call(arguments,0),mergeFn)},MergedSequence.prototype=new ObjectLikeSequence,MergedSequence.prototype.each=function(fn){var others=this.others,mergeFn=this.mergeFn||mergeObjects,keys={},iteratedFullSource=this.parent.each(function(value,key){var merged=value;return forEach(others,function(other){key in other&&(merged=mergeFn(merged,other[key]))}),keys[key]=!0,fn(merged,key)});if(iteratedFullSource===!1)return!1;var remaining={};return forEach(others,function(other){for(var k in other)keys[k]||(remaining[k]=mergeFn(remaining[k],other[k]))}),Lazy(remaining).each(fn)},ObjectLikeSequence.prototype.functions=function(){return this.filter(function(v,k){return"function"==typeof v}).map(function(v,k){return k})},ObjectLikeSequence.prototype.methods=function(){return this.functions()},ObjectLikeSequence.prototype.pick=function(properties){return new PickSequence(this,properties)},PickSequence.prototype=new ObjectLikeSequence,PickSequence.prototype.get=function(key){return arrayContains(this.properties,key)?this.parent.get(key):void 0},PickSequence.prototype.each=function(fn){var inArray=arrayContains,properties=this.properties;return this.parent.each(function(value,key){return inArray(properties,key)?fn(value,key):void 0})},ObjectLikeSequence.prototype.omit=function(properties){return new OmitSequence(this,properties)},OmitSequence.prototype=new ObjectLikeSequence,OmitSequence.prototype.get=function(key){return arrayContains(this.properties,key)?void 0:this.parent.get(key)},OmitSequence.prototype.each=function(fn){var inArray=arrayContains,properties=this.properties;return this.parent.each(function(value,key){return inArray(properties,key)?void 0:fn(value,key)})},ObjectLikeSequence.prototype.pairs=function(){return this.map(function(v,k){return[k,v]})},ObjectLikeSequence.prototype.toArray=function(){return this.pairs().toArray()},ObjectLikeSequence.prototype.toObject=function(){return this.reduce(function(object,value,key){return object[key]=value,object},{})},GroupedSequence.prototype=new ObjectLikeSequence,GroupedSequence.prototype.each=function(fn){var keyFn=createCallback(this.keyFn),grouped={};this.parent.each(function(e){var key=keyFn(e);grouped[key]?grouped[key].push(e):grouped[key]=[e]});for(var key in grouped)if(fn(grouped[key],key)===!1)return!1;return!0},CountedSequence.prototype=new ObjectLikeSequence,CountedSequence.prototype.each=function(fn){var keyFn=createCallback(this.keyFn),counted={};this.parent.each(function(e){var key=keyFn(e);counted[key]?counted[key]+=1:counted[key]=1});for(var key in counted)if(fn(counted[key],key)===!1)return!1;return!0},ObjectLikeSequence.prototype.watch=function(propertyNames){throw"You can only call #watch on a directly wrapped object."},ObjectWrapper.prototype=new ObjectLikeSequence,ObjectWrapper.prototype.root=function(){return this},ObjectWrapper.prototype.get=function(key){return this.source[key]},ObjectWrapper.prototype.each=function(fn){var key,source=this.source;for(key in source)if(fn(source[key],key)===!1)return!1;return!0},StringLikeSequence.prototype=new ArrayLikeSequence,StringLikeSequence.define=function(methodName,overrides){if(!overrides||"function"!=typeof overrides.get)throw"A custom string-like sequence must implement *at least* get!";return defineSequenceType(StringLikeSequence,methodName,overrides)},StringLikeSequence.prototype.value=function(){return this.toString()},StringLikeSequence.prototype.getIterator=function(){return new CharIterator(this)},CharIterator.prototype.current=function(){return this.source.charAt(this.index)},CharIterator.prototype.moveNext=function(){return++this.indexi;)if(fn(generatorFn(i++))===!1)return!1;return!0},GeneratedSequence.prototype.getIterator=function(){return new GeneratedIterator(this)},GeneratedIterator.prototype.current=function(){return this.currentValue},GeneratedIterator.prototype.moveNext=function(){var sequence=this.sequence;return"number"==typeof sequence.fixedLength&&this.index>=sequence.fixedLength?!1:(this.currentValue=sequence.get(this.index++),!0)},AsyncSequence.prototype=new Sequence,AsyncSequence.prototype.getIterator=function(){throw"An AsyncSequence does not support synchronous iteration."},AsyncSequence.prototype.each=function(fn){var iterator=this.parent.getIterator(),onNextCallback=this.onNextCallback,i=0,handle=new AsyncHandle(this.interval);return handle.id=onNextCallback(function iterate(){try{iterator.moveNext()&&fn(iterator.current(),i++)!==!1?handle.id=onNextCallback(iterate):handle.completeCallback()}catch(e){handle.errorCallback(e)}}),handle},AsyncHandle.prototype.cancel=function(){var cancelCallback=this.cancelCallback;this.id&&(cancelCallback(this.id),this.id=null)},AsyncHandle.prototype.onError=function(callback){this.errorCallback=callback},AsyncHandle.prototype.errorCallback=Lazy.noop,AsyncHandle.prototype.onComplete=function(callback){this.completeCallback=callback},AsyncHandle.prototype.completeCallback=Lazy.noop,AsyncSequence.prototype.reverse=function(){return this.parent.reverse().async()},AsyncSequence.prototype.reduce=function(aggregator,memo){var handle=this.each(function(e,i){memo="undefined"==typeof memo&&0===i?e:aggregator(memo,e,i)});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(memo)}},handle},AsyncSequence.prototype.find=function(predicate){var found,handle=this.each(function(e,i){return predicate(e,i)?(found=e,!1):void 0});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(found)}},handle},AsyncSequence.prototype.indexOf=function(value){var foundIndex=-1,handle=this.each(function(e,i){return e===value?(foundIndex=i,!1):void 0});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(foundIndex)}},handle},AsyncSequence.prototype.contains=function(value){var found=!1,handle=this.each(function(e){return e===value?(found=!0,!1):void 0});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(found)}},handle},AsyncSequence.prototype.async=function(){return this},ObjectWrapper.prototype.watch=function(propertyNames){return new WatchedPropertySequence(this.source,propertyNames)},WatchedPropertySequence.prototype=new AsyncSequence,WatchedPropertySequence.prototype.each=function(fn){this.listeners.push(fn)},StreamLikeSequence.prototype=new AsyncSequence,StreamLikeSequence.prototype.split=function(delimiter){return new SplitStreamSequence(this,delimiter)},SplitStreamSequence.prototype=new Sequence,SplitStreamSequence.prototype.each=function(fn){var delimiter=this.delimiter,done=!1,i=0;return this.parent.each(function(chunk){return Lazy(chunk).split(delimiter).each(function(piece){return fn(piece,i++)===!1?(done=!0,!1):void 0}),!done})},StreamLikeSequence.prototype.lines=function(){return this.split("\n")},StreamLikeSequence.prototype.match=function(pattern){return new MatchedStreamSequence(this,pattern)},MatchedStreamSequence.prototype=new AsyncSequence,MatchedStreamSequence.prototype.each=function(fn){var pattern=this.pattern,done=!1,i=0;return this.parent.each(function(chunk){return Lazy(chunk).match(pattern).each(function(match){return fn(match,i++)===!1?(done=!0,!1):void 0}),!done})},Lazy.createWrapper=function(initializer){var ctor=function(){this.listeners=[]};return ctor.prototype=new StreamLikeSequence,ctor.prototype.each=function(listener){this.listeners.push(listener)},ctor.prototype.emit=function(data){for(var listeners=this.listeners,len=listeners.length,i=len-1;i>=0;--i)listeners[i](data)===!1&&listeners.splice(i,1)},function(){var sequence=new ctor;return initializer.apply(sequence,arguments),sequence}},Lazy.generate=function(generatorFn,length){return new GeneratedSequence(generatorFn,length)},Lazy.range=function(){var start=arguments.length>1?arguments[0]:0,stop=arguments.length>1?arguments[1]:arguments[0],step=arguments.length>2?arguments[2]:1;return this.generate(function(i){return start+step*i}).take(Math.floor((stop-start)/step))},Lazy.repeat=function(value,count){return Lazy.generate(function(){return value},count)},Lazy.Sequence=Sequence,Lazy.ArrayLikeSequence=ArrayLikeSequence,Lazy.ObjectLikeSequence=ObjectLikeSequence,Lazy.StringLikeSequence=StringLikeSequence,Lazy.StreamLikeSequence=StreamLikeSequence,Lazy.GeneratedSequence=GeneratedSequence,Lazy.AsyncSequence=AsyncSequence,Lazy.AsyncHandle=AsyncHandle,Lazy.deprecate=function(message,fn){return function(){return fn.apply(this,arguments)}};var arrayPop=Array.prototype.pop,arraySlice=Array.prototype.slice;Set.prototype.add=function(value){var objects,table=this.table,type=typeof value;switch(type){case"number":case"boolean":case"undefined":return table[value]?!1:(table[value]=!0,!0);case"string":switch(value.charAt(0)){case"_":case"f":case"t":case"c":case"u":case"@":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"N":value="@"+value}return table[value]?!1:(table[value]=!0,!0);default:return objects=this.objects,arrayContains(objects,value)?!1:(objects.push(value),!0)}},Set.prototype.contains=function(value){var type=typeof value;switch(type){case"number":case"boolean":case"undefined":return!!this.table[value];case"string":switch(value.charAt(0)){case"_":case"f":case"t":case"c":case"u":case"@":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"N":value="@"+value}return!!this.table[value];default:return arrayContains(this.objects,value)}},Queue.prototype.add=function(element){var contents=this.contents,capacity=contents.length,start=this.start;return this.count===capacity?(contents[start]=element,this.start=(start+1)%capacity):contents[this.count++]=element,this},Queue.prototype.toArray=function(){var contents=this.contents,start=this.start,count=this.count,snapshot=contents.slice(start,start+count);return snapshot.length'+errorMessage+"")},addWatcherForDynamicallyDefinedValidations=function(){$scope.$watch(function(){return dynamicallyDefinedValidation.errorCount},function(){if(0!==dynamicallyDefinedValidation.errorCount){var currentElementFieldName=errorMessageElement.attr("data-custom-field-name"),latestValidatedFieldName=dynamicallyDefinedValidation.latestElement.attr("name");latestValidatedFieldName===currentElementFieldName&&errorMessageElement.html(dynamicallyDefinedValidation.errorMessage())}})},addWatcherToWrapErrorInCustomTemplate=function(template){var errorMessageToggled;customErrorTemplate=angular.element(template),customErrorTemplate.html(""),errorMessageToggled=function(){var templateUid=Math.random();"inline"===errorMessageElement.css("display")||"block"===errorMessageElement.css("display")?($element.attr("templateUid",templateUid),customErrorTemplate.attr("templateUid",templateUid),errorMessageElement.wrap(customErrorTemplate),customTemplates.push(angular.element(errorMessageElement.parents()[0]))):($element.removeAttr("templateUid"),errorMessageElement.parent().is("."+customErrorTemplate.attr("class"))&&errorMessageElement.unwrap(customErrorTemplate))},$scope.$watch(function(){return errorMessageElement.css("display")},errorMessageToggled),$scope.$on("errorMessageToggled",errorMessageToggled)},getFormatterArgsErrorMessage=function(){var errorMessage;return errorMessage="function"==typeof formatterArgs.errorMessage?formatterArgs.errorMessage(validationAttributeValue):formatterArgs.errorMessage},installErrorMessageElement=function(){errorMessage=getFormatterArgsErrorMessage(),errorMessageElement=getErrorMessageElement(),$element.after(errorMessageElement),errorMessageElement.hide(),"validationDynamicallyDefined"===formatterArgs.customValidationAttribute&&addWatcherForDynamicallyDefinedValidations(),getCustomTemplateIfDefined($attrs[formatterArgs.customValidationAttribute],templateRetriever).then(function(template){addWatcherToWrapErrorInCustomTemplate(template)}),customErrorMessage=getValidationAttributeByPropertyName($attrs[formatterArgs.customValidationAttribute],"message"),null!==customErrorMessage&&errorMessageElement.html(customErrorMessage)},installSpecialErrorCases=function(){if("validationNoSpace"===formatterArgs.customValidationAttribute&&$element.keyup(function(event){8===event.keyCode&&(model[propertyName]=$element.val().replace(/\s+$/,""))}),"validationConfirmPassword"===formatterArgs.customValidationAttribute){var passwordFieldId=$element.attr("passwordFieldId")||"password",passwordFieldSelector="#"+passwordFieldId,validationConfirmPasswordHandlerSelector=passwordFieldSelector+", #"+$element[0].id,confirmPasswordElement=$element,passwordElement=$element.parent().children(passwordFieldSelector);return void $($element.parent()).on("keyup blur",validationConfirmPasswordHandlerSelector,function(target){var passwordMatch,confirmPasswordIsDirty;confirmPasswordIsDirty=/dirty/.test(confirmPasswordElement.attr("class")),confirmPasswordIsDirty!==!1&&(passwordMatch=passwordElement.val()===$element.val(),ngModelController.$setValidity("validationconfirmpassword",passwordMatch),confirmPasswordElement.siblings(".CustomValidationError.validationConfirmPassword:first").toggle(!passwordMatch),onValidationComplete(passwordMatch,passwordMatch,validationAttributeValue,$element,model,ngModelController,$scope,function(){formatterArgs.success&&formatterArgs.success()}))})}"validationFieldRequired"===formatterArgs.customValidationAttribute&&$element.parents("form").find("label[for="+$element.attr("id")+"]").addClass("requiredFieldLabel")},runCustomValidations=function(eventType){function getCurrentlyDisplayingErrorMessage(){var fieldNameSelector,selector;return fieldNameSelector='[data-custom-field-name="'+$element.attr("name")+'"]',selector='.CustomValidationError[style="display: inline;"]'+fieldNameSelector+', .CustomValidationError[style="display: block;"]'+fieldNameSelector,isCurrentlyDisplayingAnErrorMessageInATemplate($element)?currentlyDisplayedTemplate.children(selector):$element.siblings(selector)}function getElementValue(){var value=$element.val().replace(/\s+$/,"");return/select/.test($element[0].type)&&(value=$element[0].options[$element[0].selectedIndex].innerHTML),/checkbox|radio/.test($element[0].type)&&(value=$element[0].checked===!0?"true":""),value}function toggleRequiredLabelClass(){""===value?$element.parents("form").find("label[for="+$element.attr("id")+"]").addClass("requiredFieldLabel"):$element.parents("form").find("label[for="+$element.attr("id")+"]").removeClass("requiredFieldLabel")}function runValidation(){return formatterArgs.validator(errorMessageElement,value,validationAttributeValue,$element,model,ngModelController,$scope,rawCustomValidationAttribute)}function getPropertyNameClass(pname){return pname.replace(".","\\.")}function whenIsNotCurrentlyDisplayingAnErrorMessage(){var classNames=".CustomValidationError."+formatterArgs.customValidationAttribute+"."+getPropertyNameClass(propertyName)+"property:first";$element.siblings(classNames).toggle(!isValid)}function whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate(){ -currentErrorMessageValidator=getValidatorByAttribute(currentErrorMessage.attr("data-custom-validation-attribute")),currentErrorMessageIsStale=currentErrorMessageValidator(errorMessageElement.clone(),value,$attrs[currentErrorMessage.attr("data-custom-validation-attribute")],$element,model,ngModelController,$scope,rawCustomValidationAttribute),currentErrorMessagePriorityIndex=parseInt(currentErrorMessage.attr("data-custom-validation-priorityIndex"),10),currentErrorMessageIsOfALowerPriority=currentErrorMessagePriorityIndex>=getValidationPriorityIndex(formatterArgs.customValidationAttribute),(currentErrorMessageIsStale||!currentErrorMessageIsStale&¤tErrorMessageIsOfALowerPriority&&!isValid)&&(currentErrorMessage.hide(),$element.siblings(".CustomValidationError."+formatterArgs.customValidationAttribute+"."+getPropertyNameClass(propertyName)+"property:first").toggle(!isValid))}function whenIsCurrentlyDisplayingAnErrorMessageInATemplate(){currentErrorMessageValidator=getValidatorByAttribute(currentErrorMessage.attr("data-custom-validation-attribute")),currentErrorMessageIsStale=currentErrorMessageValidator(errorMessageElement,value,getValidationAttributeValue($attrs[currentErrorMessage.attr("data-custom-validation-attribute")]),$element,model,ngModelController),currentErrorMessagePriorityIndex=parseInt(currentErrorMessage.attr("data-custom-validation-priorityIndex"),10),currentErrorMessageIsOfALowerPriority=currentErrorMessagePriorityIndex>=getValidationPriorityIndex(formatterArgs.customValidationAttribute),(currentErrorMessageIsStale||!currentErrorMessageIsStale&¤tErrorMessageIsOfALowerPriority&&!isValid&&-1===currentlyDisplayedTemplate.children().attr("class").indexOf(formatterArgs.customValidationAttribute))&&(currentErrorMessage.hide(),$element.siblings(".CustomValidationError."+formatterArgs.customValidationAttribute+"."+getPropertyNameClass(propertyName)+"property:first").toggle(!isValid),$scope.$broadcast("errorMessageToggled"))}var isValid,value,customValidationBroadcastArg,currentlyDisplayingAnErrorMessage,currentErrorMessage,currentErrorMessageIsStale,currentErrorMessageValidator,currentErrorMessagePriorityIndex,currentErrorMessageIsOfALowerPriority,successFn,evaluateAsValid=!1;if("blur"!==eventType&&"runCustomValidations"!==eventType&&(formatterArgs.validateWhileEntering&&formatterArgs.validateWhileEntering===!0||(evaluateAsValid=!0)),value=getElementValue(),$element.hasClass("ng-pristine")&&"runCustomValidations"!==eventType)return value;successFn=formatterArgs.success||function(){},currentErrorMessage=getCurrentlyDisplayingErrorMessage(),currentlyDisplayingAnErrorMessage=currentErrorMessage.length>0,"validationFieldRequired"===formatterArgs.customValidationAttribute&&toggleRequiredLabelClass(),isValid=evaluateAsValid===!0?!0:runValidation(),ngModelController.$setValidity(formatterArgs.customValidationAttribute.toLowerCase(),isValid);var status=isValid===!0?" passed":" failed";return customValidationBroadcastArg={isValid:isValid,validation:$element.attr("id")+" "+formatterArgs.customValidationAttribute+status,model:model,controller:ngModelController,element:$element},currentlyDisplayingAnErrorMessage?isCurrentlyDisplayingAnErrorMessageInATemplate($element)||whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate():whenIsNotCurrentlyDisplayingAnErrorMessage(),isCurrentlyDisplayingAnErrorMessageInATemplate($element)&&whenIsCurrentlyDisplayingAnErrorMessageInATemplate(),$scope.$broadcast("customValidationComplete",customValidationBroadcastArg),onValidationComplete(!(currentlyDisplayingAnErrorMessage||isCurrentlyDisplayingAnErrorMessageInATemplate($element)||!isValid),value,validationAttributeValue,$element,model,ngModelController,$scope,successFn),value},isValidValidationAttributeValue===!0&&(modelName=$attrs.ngModel.substring(0,$attrs.ngModel.indexOf(".")),propertyName=$attrs.ngModel.substring($attrs.ngModel.indexOf(".")+1),model=$scope[modelName],installErrorMessageElement(),installSpecialErrorCases(),ngModelController.$parsers.push(function(){return runCustomValidations("input")}),$element.on("blur",function(event){runCustomValidations(event.type)}),$scope.$on("runCustomValidations",function(){runCustomValidations("runCustomValidations")}))})}},customValidationsModule=angular.module("directives.customvalidation.customValidations",["directives.invalidinputformatter.invalidInputFormatter","services.templateRetriever"]).factory("customValidationUtil",["templateRetriever","$q","$timeout","$log",function(templateRetriever,$q,$timeout,$log){return{createValidationLink:function(customValidation){return customValidations.push(customValidation),createValidationFormatterLink(customValidation,templateRetriever,$q,$timeout,$log)}}}]).directive("input",["customValidationUtil",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(dynamicallyDefinedValidation)}}]).directive("select",["customValidationUtil",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(dynamicallyDefinedValidation)}}]).directive("select",["customValidationUtil",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink({customValidationAttribute:"validationFieldRequired",validateWhileEntering:!0,errorMessage:"This is a required field",validator:function(errorMessageElement,val){return/\S/.test(val)}})}}]).directive("button",["customValidationUtil",function(customValidationUtil){return{restrict:"E",link:submitLink}}]).directive("a",["customValidationUtil",function(customValidationUtil){return{restrict:"E",link:submitLink}}]),{getValidationAttributeValue:getValidationAttributeValue}}(),function(){var extendCustomValidations=angular.module("directives.customvalidation.customValidationTypes",["directives.customvalidation.customValidations"]);extendCustomValidations.provider("myValidations",function(){getValidationAttributeValue=angular_ui_form_validations.getValidationAttributeValue;var outOfBoxValidations=[{customValidationAttribute:"validationFieldRequired",errorMessage:"This is a required field",validator:function(errorMessageElement,val){return/\S/.test(val)}},{customValidationAttribute:"validationConfirmPassword",errorMessage:"Passwords do not match.",validator:function(errorMessageElement,val,attr,element,model,modelCtrl){return!0}},{customValidationAttribute:"validationEmail",errorMessage:"Please enter a valid email",validator:function(errorMessageElement,val){return/^.*@.*\..*[a-z]$/i.test(val)}},{customValidationAttribute:"validationNoSpace",errorMessage:"Cannot contain any spaces",validateWhileEntering:!0,validator:function(errorMessageElement,val){return"undefined"!=typeof val&&""===val.trim()?!0:""!==val&&/^[^\s]+$/.test(val)}},{customValidationAttribute:"validationSetLength",errorMessage:"",validator:function(errorMessageElement,val,attr,$element,model,ngModelController,$scope,rawAttr){var customMessage=getValidationAttributeValue(rawAttr,"message",!0);return val.length===parseInt(getValidationAttributeValue(rawAttr),10)?!0:(errorMessageElement.html(customMessage||"Set number of characters allowed is "+getValidationAttributeValue(rawAttr)),!1)}},{customValidationAttribute:"validationMinLength",errorMessage:function(attr){return"Minimum of "+getValidationAttributeValue(attr)+" characters"},validator:function(errorMessageElement,val,attr){return val.length>=parseInt(getValidationAttributeValue(attr),10)}},{customValidationAttribute:"validationMaxLength",errorMessage:"",validateWhileEntering:!0,validator:function(errorMessageElement,val,attr,$element,model,ngModelController,$scope,rawAttr){var customMessage=getValidationAttributeValue(rawAttr,"message",!0);return val.length<=parseInt(getValidationAttributeValue(rawAttr),10)?!0:(errorMessageElement.html(customMessage||"Maximum of "+getValidationAttributeValue(rawAttr)+" characters"),!1)}},{customValidationAttribute:"validationOnlyAlphabets",errorMessage:"Valid characters are: A-Z, a-z",validateWhileEntering:!0,validator:function(errorMessageElement,val){return/^[a-z]*$/i.test(val)}},{customValidationAttribute:"validationOneUpperCaseLetter",errorMessage:"Must contain at least one uppercase letter",validator:function(errorMessageElement,val){return/^(?=.*[A-Z]).+$/.test(val)}},{customValidationAttribute:"validationOnlyNumbers",errorMessage:"Must contain only numbers",validator:function(errorMessageElement,val){return/^[0-9]*$/i.test(val)}},{customValidationAttribute:"validationOneNumber",errorMessage:"Must contain at least one number",validator:function(errorMessageElement,val){return/^(?=.*[0-9]).+$/.test(val)}},{customValidationAttribute:"validationOneAlphabet",errorMessage:"Must contain at least one alphabet",validator:function(errorMessageElement,val){return/^(?=.*[a-z]).+$/i.test(val)}},{customValidationAttribute:"validationNoSpecialChars",validateWhileEntering:!0,errorMessage:"Valid characters are: A-Z, a-z, 0-9",validator:function(errorMessageElement,val){return/^[a-z0-9_\-\s]*$/i.test(val)}},{customValidationAttribute:"validationDateBeforeToday",errorMessage:"Must be prior to today",validator:function(errorMessageElement,val){var now,dateValue;return now=new Date,dateValue=new Date(val),dateValue.setDate(dateValue.getDate()+1),now>dateValue}},{customValidationAttribute:"validationDateBefore",errorMessage:function(attr){return"Must be before "+getValidationAttributeValue(attr)},validator:function(errorMessageElement,val,beforeDate){var dateValue=new Date(val);return dateValue.setDate(dateValue.getDate()+1),dateValuenew Date(afterDate)}}],userCustomValidations=[];this.addCustomValidations=function(validations){userCustomValidations=userCustomValidations.concat(validations)};var compileProvider;this.setCompileProvider=function(cp){compileProvider=cp};var Validations=function(){this.compileDirective=function(name,constructor){compileProvider.directive.apply(null,[name,constructor])},this.fetch=function(){return userCustomValidations.concat(outOfBoxValidations)}};this.$get=function(){return new Validations}}),extendCustomValidations.config(["$compileProvider","myValidationsProvider",function($compileProvider,myValidationsProvider){myValidationsProvider.setCompileProvider($compileProvider)}]),extendCustomValidations.run(["myValidations",function(myValidations){angular.forEach(myValidations.fetch(),function(customValidation){myValidations.compileDirective("input",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(customValidation)}}),myValidations.compileDirective("textarea",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(customValidation)}})})}])}(),angular.module("directives.invalidinputformatter.invalidInputFormatter",[]).directive("input",function(){return{require:"?ngModel",restrict:"E",link:function($scope,$element,$attrs,ngModelController){var inputType=angular.lowercase($attrs.type);ngModelController&&"radio"!==inputType&&"checkbox"!==inputType&&ngModelController.$formatters.unshift(function(value){return ngModelController.$invalid&&angular.isUndefined(value)&&"string"==typeof ngModelController.$modelValue?ngModelController.$modelValue:value})}}}); \ No newline at end of file +key=keyFn(value),!find(cache,key)&&(cache.push(key),fn(value,j++)===!1))return!1}else for(;++ii?source[i]:this.other[i-sourceLength]},ConcatArrayWrapper.prototype.length=function(){return this.parent.source.length+this.other.length},ConcatArrayWrapper.prototype.each=function(fn){for(var source=this.parent.source,sourceLength=source.length,other=this.other,otherLength=other.length,i=0,j=-1;++j1&&"function"==typeof arguments[arguments.length-1]?arrayPop.call(arguments):null;return new MergedSequence(this,arraySlice.call(arguments,0),mergeFn)},MergedSequence.prototype=new ObjectLikeSequence,MergedSequence.prototype.each=function(fn){var others=this.others,mergeFn=this.mergeFn||mergeObjects,keys={},iteratedFullSource=this.parent.each(function(value,key){var merged=value;return forEach(others,function(other){key in other&&(merged=mergeFn(merged,other[key]))}),keys[key]=!0,fn(merged,key)});if(iteratedFullSource===!1)return!1;var remaining={};return forEach(others,function(other){for(var k in other)keys[k]||(remaining[k]=mergeFn(remaining[k],other[k]))}),Lazy(remaining).each(fn)},ObjectLikeSequence.prototype.functions=function(){return this.filter(function(v,k){return"function"==typeof v}).map(function(v,k){return k})},ObjectLikeSequence.prototype.methods=function(){return this.functions()},ObjectLikeSequence.prototype.pick=function(properties){return new PickSequence(this,properties)},PickSequence.prototype=new ObjectLikeSequence,PickSequence.prototype.get=function(key){return arrayContains(this.properties,key)?this.parent.get(key):void 0},PickSequence.prototype.each=function(fn){var inArray=arrayContains,properties=this.properties;return this.parent.each(function(value,key){return inArray(properties,key)?fn(value,key):void 0})},ObjectLikeSequence.prototype.omit=function(properties){return new OmitSequence(this,properties)},OmitSequence.prototype=new ObjectLikeSequence,OmitSequence.prototype.get=function(key){return arrayContains(this.properties,key)?void 0:this.parent.get(key)},OmitSequence.prototype.each=function(fn){var inArray=arrayContains,properties=this.properties;return this.parent.each(function(value,key){return inArray(properties,key)?void 0:fn(value,key)})},ObjectLikeSequence.prototype.pairs=function(){return this.map(function(v,k){return[k,v]})},ObjectLikeSequence.prototype.toArray=function(){return this.pairs().toArray()},ObjectLikeSequence.prototype.toObject=function(){return this.reduce(function(object,value,key){return object[key]=value,object},{})},GroupedSequence.prototype=new ObjectLikeSequence,GroupedSequence.prototype.each=function(fn){var keyFn=createCallback(this.keyFn),grouped={};this.parent.each(function(e){var key=keyFn(e);grouped[key]?grouped[key].push(e):grouped[key]=[e]});for(var key in grouped)if(fn(grouped[key],key)===!1)return!1;return!0},CountedSequence.prototype=new ObjectLikeSequence,CountedSequence.prototype.each=function(fn){var keyFn=createCallback(this.keyFn),counted={};this.parent.each(function(e){var key=keyFn(e);counted[key]?counted[key]+=1:counted[key]=1});for(var key in counted)if(fn(counted[key],key)===!1)return!1;return!0},ObjectLikeSequence.prototype.watch=function(propertyNames){throw"You can only call #watch on a directly wrapped object."},ObjectWrapper.prototype=new ObjectLikeSequence,ObjectWrapper.prototype.root=function(){return this},ObjectWrapper.prototype.get=function(key){return this.source[key]},ObjectWrapper.prototype.each=function(fn){var key,source=this.source;for(key in source)if(fn(source[key],key)===!1)return!1;return!0},StringLikeSequence.prototype=new ArrayLikeSequence,StringLikeSequence.define=function(methodName,overrides){if(!overrides||"function"!=typeof overrides.get)throw"A custom string-like sequence must implement *at least* get!";return defineSequenceType(StringLikeSequence,methodName,overrides)},StringLikeSequence.prototype.value=function(){return this.toString()},StringLikeSequence.prototype.getIterator=function(){return new CharIterator(this)},CharIterator.prototype.current=function(){return this.source.charAt(this.index)},CharIterator.prototype.moveNext=function(){return++this.indexi;)if(fn(generatorFn(i++))===!1)return!1;return!0},GeneratedSequence.prototype.getIterator=function(){return new GeneratedIterator(this)},GeneratedIterator.prototype.current=function(){return this.currentValue},GeneratedIterator.prototype.moveNext=function(){var sequence=this.sequence;return"number"==typeof sequence.fixedLength&&this.index>=sequence.fixedLength?!1:(this.currentValue=sequence.get(this.index++),!0)},AsyncSequence.prototype=new Sequence,AsyncSequence.prototype.getIterator=function(){throw"An AsyncSequence does not support synchronous iteration."},AsyncSequence.prototype.each=function(fn){var iterator=this.parent.getIterator(),onNextCallback=this.onNextCallback,i=0,handle=new AsyncHandle(this.interval);return handle.id=onNextCallback(function iterate(){try{iterator.moveNext()&&fn(iterator.current(),i++)!==!1?handle.id=onNextCallback(iterate):handle.completeCallback()}catch(e){handle.errorCallback(e)}}),handle},AsyncHandle.prototype.cancel=function(){var cancelCallback=this.cancelCallback;this.id&&(cancelCallback(this.id),this.id=null)},AsyncHandle.prototype.onError=function(callback){this.errorCallback=callback},AsyncHandle.prototype.errorCallback=Lazy.noop,AsyncHandle.prototype.onComplete=function(callback){this.completeCallback=callback},AsyncHandle.prototype.completeCallback=Lazy.noop,AsyncSequence.prototype.reverse=function(){return this.parent.reverse().async()},AsyncSequence.prototype.reduce=function(aggregator,memo){var handle=this.each(function(e,i){memo="undefined"==typeof memo&&0===i?e:aggregator(memo,e,i)});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(memo)}},handle},AsyncSequence.prototype.find=function(predicate){var found,handle=this.each(function(e,i){return predicate(e,i)?(found=e,!1):void 0});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(found)}},handle},AsyncSequence.prototype.indexOf=function(value){var foundIndex=-1,handle=this.each(function(e,i){return e===value?(foundIndex=i,!1):void 0});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(foundIndex)}},handle},AsyncSequence.prototype.contains=function(value){var found=!1,handle=this.each(function(e){return e===value?(found=!0,!1):void 0});return handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(found)}},handle},AsyncSequence.prototype.async=function(){return this},ObjectWrapper.prototype.watch=function(propertyNames){return new WatchedPropertySequence(this.source,propertyNames)},WatchedPropertySequence.prototype=new AsyncSequence,WatchedPropertySequence.prototype.each=function(fn){this.listeners.push(fn)},StreamLikeSequence.prototype=new AsyncSequence,StreamLikeSequence.prototype.split=function(delimiter){return new SplitStreamSequence(this,delimiter)},SplitStreamSequence.prototype=new Sequence,SplitStreamSequence.prototype.each=function(fn){var delimiter=this.delimiter,done=!1,i=0;return this.parent.each(function(chunk){return Lazy(chunk).split(delimiter).each(function(piece){return fn(piece,i++)===!1?(done=!0,!1):void 0}),!done})},StreamLikeSequence.prototype.lines=function(){return this.split("\n")},StreamLikeSequence.prototype.match=function(pattern){return new MatchedStreamSequence(this,pattern)},MatchedStreamSequence.prototype=new AsyncSequence,MatchedStreamSequence.prototype.each=function(fn){var pattern=this.pattern,done=!1,i=0;return this.parent.each(function(chunk){return Lazy(chunk).match(pattern).each(function(match){return fn(match,i++)===!1?(done=!0,!1):void 0}),!done})},Lazy.createWrapper=function(initializer){var ctor=function(){this.listeners=[]};return ctor.prototype=new StreamLikeSequence,ctor.prototype.each=function(listener){this.listeners.push(listener)},ctor.prototype.emit=function(data){for(var listeners=this.listeners,len=listeners.length,i=len-1;i>=0;--i)listeners[i](data)===!1&&listeners.splice(i,1)},function(){var sequence=new ctor;return initializer.apply(sequence,arguments),sequence}},Lazy.generate=function(generatorFn,length){return new GeneratedSequence(generatorFn,length)},Lazy.range=function(){var start=arguments.length>1?arguments[0]:0,stop=arguments.length>1?arguments[1]:arguments[0],step=arguments.length>2?arguments[2]:1;return this.generate(function(i){return start+step*i}).take(Math.floor((stop-start)/step))},Lazy.repeat=function(value,count){return Lazy.generate(function(){return value},count)},Lazy.Sequence=Sequence,Lazy.ArrayLikeSequence=ArrayLikeSequence,Lazy.ObjectLikeSequence=ObjectLikeSequence,Lazy.StringLikeSequence=StringLikeSequence,Lazy.StreamLikeSequence=StreamLikeSequence,Lazy.GeneratedSequence=GeneratedSequence,Lazy.AsyncSequence=AsyncSequence,Lazy.AsyncHandle=AsyncHandle,Lazy.deprecate=function(message,fn){return function(){return fn.apply(this,arguments)}};var arrayPop=Array.prototype.pop,arraySlice=Array.prototype.slice;Set.prototype.add=function(value){var objects,table=this.table,type=typeof value;switch(type){case"number":case"boolean":case"undefined":return table[value]?!1:(table[value]=!0,!0);case"string":switch(value.charAt(0)){case"_":case"f":case"t":case"c":case"u":case"@":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"N":value="@"+value}return table[value]?!1:(table[value]=!0,!0);default:return objects=this.objects,arrayContains(objects,value)?!1:(objects.push(value),!0)}},Set.prototype.contains=function(value){var type=typeof value;switch(type){case"number":case"boolean":case"undefined":return!!this.table[value];case"string":switch(value.charAt(0)){case"_":case"f":case"t":case"c":case"u":case"@":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"N":value="@"+value}return!!this.table[value];default:return arrayContains(this.objects,value)}},Queue.prototype.add=function(element){var contents=this.contents,capacity=contents.length,start=this.start;return this.count===capacity?(contents[start]=element,this.start=(start+1)%capacity):contents[this.count++]=element,this},Queue.prototype.toArray=function(){var contents=this.contents,start=this.start,count=this.count,snapshot=contents.slice(start,start+count);return snapshot.length'+errorMessage+"")},addWatcherForDynamicallyDefinedValidations=function(){$scope.$watch(function(){return dynamicallyDefinedValidation.errorCount},function(){if(0!==dynamicallyDefinedValidation.errorCount){var currentElementFieldName=errorMessageElement.attr("data-custom-field-name"),latestValidatedFieldName=dynamicallyDefinedValidation.latestElement.attr("name");latestValidatedFieldName===currentElementFieldName&&errorMessageElement.html(dynamicallyDefinedValidation.errorMessage())}})},addWatcherToWrapErrorInCustomTemplate=function(template){var errorMessageToggled;customErrorTemplate=angular.element(template),customErrorTemplate.html(""),errorMessageToggled=function(){var templateUid=Math.random();"inline"===errorMessageElement.css("display")||"block"===errorMessageElement.css("display")?($element.attr("templateUid",templateUid),customErrorTemplate.attr("templateUid",templateUid),errorMessageElement.wrap(customErrorTemplate),customTemplates.push(angular.element(errorMessageElement.parents()[0]))):($element.removeAttr("templateUid"),errorMessageElement.parent().is("."+customErrorTemplate.attr("class"))&&errorMessageElement.unwrap(customErrorTemplate))},$scope.$watch(function(){return errorMessageElement.css("display")},errorMessageToggled),$scope.$on("errorMessageToggled",errorMessageToggled)},getFormatterArgsErrorMessage=function(){var errorMessage;return errorMessage="function"==typeof formatterArgs.errorMessage?formatterArgs.errorMessage(validationAttributeValue):formatterArgs.errorMessage},installErrorMessageElement=function(){errorMessage=getFormatterArgsErrorMessage(),errorMessageElement=getErrorMessageElement(),getMessageTargetElement($element).after(errorMessageElement),errorMessageElement.hide(),"validationDynamicallyDefined"===formatterArgs.customValidationAttribute&&addWatcherForDynamicallyDefinedValidations(),getCustomTemplateIfDefined($attrs[formatterArgs.customValidationAttribute],templateRetriever).then(function(template){addWatcherToWrapErrorInCustomTemplate(template)}),customErrorMessage=getValidationAttributeByPropertyName($attrs[formatterArgs.customValidationAttribute],"message"),null!==customErrorMessage&&errorMessageElement.html(customErrorMessage)},installSpecialErrorCases=function(){if("validationNoSpace"===formatterArgs.customValidationAttribute&&$element.keyup(function(event){8===event.keyCode&&(model[propertyName]=$element.val().replace(/\s+$/,""))}),"validationConfirmPassword"===formatterArgs.customValidationAttribute){var passwordFieldId=$element.attr("passwordFieldId")||"password",passwordFieldSelector="#"+passwordFieldId,validationConfirmPasswordHandlerSelector=passwordFieldSelector+", #"+$element[0].id,confirmPasswordElement=$element,passwordElement=$element.parent().children(passwordFieldSelector);return void $($element.parent()).on("keyup blur",validationConfirmPasswordHandlerSelector,function(target){var passwordMatch,confirmPasswordIsDirty;confirmPasswordIsDirty=/dirty/.test(confirmPasswordElement.attr("class")),confirmPasswordIsDirty!==!1&&(passwordMatch=passwordElement.val()===$element.val(),ngModelController.$setValidity("validationconfirmpassword",passwordMatch),confirmPasswordElement.siblings(".CustomValidationError.validationConfirmPassword:first").toggle(!passwordMatch),onValidationComplete(passwordMatch,passwordMatch,validationAttributeValue,$element,model,ngModelController,$scope,function(){formatterArgs.success&&formatterArgs.success()}))})}"validationFieldRequired"===formatterArgs.customValidationAttribute&&$element.parents("form").find("label[for="+$element.attr("id")+"]").addClass("requiredFieldLabel")},runCustomValidations=function(eventType){function getCurrentlyDisplayingErrorMessage(){var fieldNameSelector,selector;return fieldNameSelector='[data-custom-field-name="'+$element.attr("name")+'"]',selector='.CustomValidationError[style="display: inline;"]'+fieldNameSelector+', .CustomValidationError[style="display: block;"]'+fieldNameSelector,isCurrentlyDisplayingAnErrorMessageInATemplate($element)?currentlyDisplayedTemplate.children(selector):getMessageTargetElement($element).siblings(selector)}function getElementValue(){var value=$element.val().replace(/\s+$/,"");return/select/.test($element[0].type)&&(value=$element[0].options[$element[0].selectedIndex].innerHTML),/checkbox|radio/.test($element[0].type)&&(value=$element[0].checked===!0?"true":""),value}function toggleRequiredLabelClass(){""===value?$element.parents("form").find("label[for="+$element.attr("id")+"]").addClass("requiredFieldLabel"):$element.parents("form").find("label[for="+$element.attr("id")+"]").removeClass("requiredFieldLabel")}function runValidation(){return formatterArgs.validator(errorMessageElement,value,validationAttributeValue,$element,model,ngModelController,$scope,rawCustomValidationAttribute)}function getPropertyNameClass(pname){return pname.replace(".","\\."); +}function whenIsNotCurrentlyDisplayingAnErrorMessage(){var classNames=".CustomValidationError."+formatterArgs.customValidationAttribute+"."+getPropertyNameClass(propertyName)+"property:first";getMessageTargetElement($element).siblings(classNames).toggle(!isValid)}function whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate(){currentErrorMessageValidator=getValidatorByAttribute(currentErrorMessage.attr("data-custom-validation-attribute")),currentErrorMessageIsStale=currentErrorMessageValidator(errorMessageElement.clone(),value,$attrs[currentErrorMessage.attr("data-custom-validation-attribute")],$element,model,ngModelController,$scope,rawCustomValidationAttribute),currentErrorMessagePriorityIndex=parseInt(currentErrorMessage.attr("data-custom-validation-priorityIndex"),10),currentErrorMessageIsOfALowerPriority=currentErrorMessagePriorityIndex>=getValidationPriorityIndex(formatterArgs.customValidationAttribute),(currentErrorMessageIsStale||!currentErrorMessageIsStale&¤tErrorMessageIsOfALowerPriority&&!isValid)&&(currentErrorMessage.hide(),getMessageTargetElement($element).siblings(".CustomValidationError."+formatterArgs.customValidationAttribute+"."+getPropertyNameClass(propertyName)+"property:first").toggle(!isValid))}function whenIsCurrentlyDisplayingAnErrorMessageInATemplate(){currentErrorMessageValidator=getValidatorByAttribute(currentErrorMessage.attr("data-custom-validation-attribute")),currentErrorMessageIsStale=currentErrorMessageValidator(errorMessageElement,value,getValidationAttributeValue($attrs[currentErrorMessage.attr("data-custom-validation-attribute")]),$element,model,ngModelController),currentErrorMessagePriorityIndex=parseInt(currentErrorMessage.attr("data-custom-validation-priorityIndex"),10),currentErrorMessageIsOfALowerPriority=currentErrorMessagePriorityIndex>=getValidationPriorityIndex(formatterArgs.customValidationAttribute),(currentErrorMessageIsStale||!currentErrorMessageIsStale&¤tErrorMessageIsOfALowerPriority&&!isValid&&-1===currentlyDisplayedTemplate.children().attr("class").indexOf(formatterArgs.customValidationAttribute))&&(currentErrorMessage.hide(),getMessageTargetElement($element).siblings(".CustomValidationError."+formatterArgs.customValidationAttribute+"."+getPropertyNameClass(propertyName)+"property:first").toggle(!isValid),$scope.$broadcast("errorMessageToggled"))}var isValid,value,customValidationBroadcastArg,currentlyDisplayingAnErrorMessage,currentErrorMessage,currentErrorMessageIsStale,currentErrorMessageValidator,currentErrorMessagePriorityIndex,currentErrorMessageIsOfALowerPriority,successFn,evaluateAsValid=!1;if("blur"!==eventType&&"runCustomValidations"!==eventType&&(formatterArgs.validateWhileEntering&&formatterArgs.validateWhileEntering===!0||(evaluateAsValid=!0)),value=getElementValue(),$element.hasClass("ng-pristine")&&"runCustomValidations"!==eventType)return value;successFn=formatterArgs.success||function(){},currentErrorMessage=getCurrentlyDisplayingErrorMessage(),currentlyDisplayingAnErrorMessage=currentErrorMessage.length>0,"validationFieldRequired"===formatterArgs.customValidationAttribute&&toggleRequiredLabelClass(),isValid=evaluateAsValid===!0?!0:runValidation(),ngModelController.$setValidity(formatterArgs.customValidationAttribute.toLowerCase(),isValid);var status=isValid===!0?" passed":" failed";return customValidationBroadcastArg={isValid:isValid,validation:$element.attr("id")+" "+formatterArgs.customValidationAttribute+status,model:model,controller:ngModelController,element:$element},currentlyDisplayingAnErrorMessage?isCurrentlyDisplayingAnErrorMessageInATemplate($element)||whenIsNotCurrentlyDisplayingAnErrorMessageInATemplate():whenIsNotCurrentlyDisplayingAnErrorMessage(),isCurrentlyDisplayingAnErrorMessageInATemplate($element)&&whenIsCurrentlyDisplayingAnErrorMessageInATemplate(),$scope.$broadcast("customValidationComplete",customValidationBroadcastArg),onValidationComplete(!(currentlyDisplayingAnErrorMessage||isCurrentlyDisplayingAnErrorMessageInATemplate($element)||!isValid),value,validationAttributeValue,$element,model,ngModelController,$scope,successFn),value},isValidValidationAttributeValue===!0&&(modelName=$attrs.ngModel.substring(0,$attrs.ngModel.indexOf(".")),propertyName=$attrs.ngModel.substring($attrs.ngModel.indexOf(".")+1),model=$scope[modelName],installErrorMessageElement(),installSpecialErrorCases(),ngModelController.$parsers.push(function(){return runCustomValidations("input")}),$element.on("blur",function(event){runCustomValidations(event.type)}),$scope.$on("runCustomValidations",function(){runCustomValidations("runCustomValidations")}))})}},customValidationsModule=angular.module("directives.customvalidation.customValidations",["directives.invalidinputformatter.invalidInputFormatter","services.templateRetriever"]).factory("customValidationUtil",["templateRetriever","$q","$timeout","$log",function(templateRetriever,$q,$timeout,$log){return{createValidationLink:function(customValidation){return customValidations.push(customValidation),createValidationFormatterLink(customValidation,templateRetriever,$q,$timeout,$log)}}}]).directive("input",["customValidationUtil",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(dynamicallyDefinedValidation)}}]).directive("select",["customValidationUtil",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(dynamicallyDefinedValidation)}}]).directive("select",["customValidationUtil",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink({customValidationAttribute:"validationFieldRequired",validateWhileEntering:!0,errorMessage:"This is a required field",validator:function(errorMessageElement,val){return/\S/.test(val)}})}}]).directive("button",["customValidationUtil",function(customValidationUtil){return{restrict:"E",link:submitLink}}]).directive("a",["customValidationUtil",function(customValidationUtil){return{restrict:"E",link:submitLink}}]),{getValidationAttributeValue:getValidationAttributeValue}}(),function(){var extendCustomValidations=angular.module("directives.customvalidation.customValidationTypes",["directives.customvalidation.customValidations"]);extendCustomValidations.provider("myValidations",function(){getValidationAttributeValue=angular_ui_form_validations.getValidationAttributeValue;var outOfBoxValidations=[{customValidationAttribute:"validationFieldRequired",errorMessage:"This is a required field",validator:function(errorMessageElement,val){return/\S/.test(val)}},{customValidationAttribute:"validationConfirmPassword",errorMessage:"Passwords do not match.",validator:function(errorMessageElement,val,attr,element,model,modelCtrl){return!0}},{customValidationAttribute:"validationEmail",errorMessage:"Please enter a valid email",validator:function(errorMessageElement,val){return/^.*@.*\..*[a-z]$/i.test(val)}},{customValidationAttribute:"validationNoSpace",errorMessage:"Cannot contain any spaces",validateWhileEntering:!0,validator:function(errorMessageElement,val){return"undefined"!=typeof val&&""===val.trim()?!0:""!==val&&/^[^\s]+$/.test(val)}},{customValidationAttribute:"validationSetLength",errorMessage:"",validator:function(errorMessageElement,val,attr,$element,model,ngModelController,$scope,rawAttr){var customMessage=getValidationAttributeValue(rawAttr,"message",!0);return val.length===parseInt(getValidationAttributeValue(rawAttr),10)?!0:(errorMessageElement.html(customMessage||"Set number of characters allowed is "+getValidationAttributeValue(rawAttr)),!1)}},{customValidationAttribute:"validationMinLength",errorMessage:function(attr){return"Minimum of "+getValidationAttributeValue(attr)+" characters"},validator:function(errorMessageElement,val,attr){return val.length>=parseInt(getValidationAttributeValue(attr),10)}},{customValidationAttribute:"validationMaxLength",errorMessage:"",validateWhileEntering:!0,validator:function(errorMessageElement,val,attr,$element,model,ngModelController,$scope,rawAttr){var customMessage=getValidationAttributeValue(rawAttr,"message",!0);return val.length<=parseInt(getValidationAttributeValue(rawAttr),10)?!0:(errorMessageElement.html(customMessage||"Maximum of "+getValidationAttributeValue(rawAttr)+" characters"),!1)}},{customValidationAttribute:"validationOnlyAlphabets",errorMessage:"Valid characters are: A-Z, a-z",validateWhileEntering:!0,validator:function(errorMessageElement,val){return/^[a-z]*$/i.test(val)}},{customValidationAttribute:"validationOneUpperCaseLetter",errorMessage:"Must contain at least one uppercase letter",validator:function(errorMessageElement,val){return/^(?=.*[A-Z]).+$/.test(val)}},{customValidationAttribute:"validationOnlyNumbers",errorMessage:"Must contain only numbers",validator:function(errorMessageElement,val){return/^[0-9]*$/i.test(val)}},{customValidationAttribute:"validationOneNumber",errorMessage:"Must contain at least one number",validator:function(errorMessageElement,val){return/^(?=.*[0-9]).+$/.test(val)}},{customValidationAttribute:"validationOneAlphabet",errorMessage:"Must contain at least one alphabet",validator:function(errorMessageElement,val){return/^(?=.*[a-z]).+$/i.test(val)}},{customValidationAttribute:"validationNoSpecialChars",validateWhileEntering:!0,errorMessage:"Valid characters are: A-Z, a-z, 0-9",validator:function(errorMessageElement,val){return/^[a-z0-9_\-\s]*$/i.test(val)}},{customValidationAttribute:"validationDateBeforeToday",errorMessage:"Must be prior to today",validator:function(errorMessageElement,val){var now,dateValue;return now=new Date,dateValue=new Date(val),dateValue.setDate(dateValue.getDate()+1),now>dateValue}},{customValidationAttribute:"validationDateBefore",errorMessage:function(attr){return"Must be before "+getValidationAttributeValue(attr)},validator:function(errorMessageElement,val,beforeDate){var dateValue=new Date(val);return dateValue.setDate(dateValue.getDate()+1),dateValuenew Date(afterDate)}}],userCustomValidations=[];this.addCustomValidations=function(validations){userCustomValidations=userCustomValidations.concat(validations)};var compileProvider;this.setCompileProvider=function(cp){compileProvider=cp};var Validations=function(){this.compileDirective=function(name,constructor){compileProvider.directive.apply(null,[name,constructor])},this.fetch=function(){return userCustomValidations.concat(outOfBoxValidations)}};this.$get=function(){return new Validations}}),extendCustomValidations.config(["$compileProvider","myValidationsProvider",function($compileProvider,myValidationsProvider){myValidationsProvider.setCompileProvider($compileProvider)}]),extendCustomValidations.run(["myValidations",function(myValidations){angular.forEach(myValidations.fetch(),function(customValidation){myValidations.compileDirective("input",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(customValidation)}}),myValidations.compileDirective("textarea",function(customValidationUtil){return{require:"?ngModel",restrict:"E",link:customValidationUtil.createValidationLink(customValidation)}})})}])}(),angular.module("directives.invalidinputformatter.invalidInputFormatter",[]).directive("input",function(){return{require:"?ngModel",restrict:"E",link:function($scope,$element,$attrs,ngModelController){var inputType=angular.lowercase($attrs.type);ngModelController&&"radio"!==inputType&&"checkbox"!==inputType&&ngModelController.$formatters.unshift(function(value){return ngModelController.$invalid&&angular.isUndefined(value)&&"string"==typeof ngModelController.$modelValue?ngModelController.$modelValue:value})}}}); \ No newline at end of file