@@ -2,7 +2,7 @@ angular_ui_form_validations = (function(){
22
33 var customValidations , createValidationFormatterLink , customValidationsModule , getValidationPriorityIndex , getValidationAttributeValue ,
44 getValidatorByAttribute , getCustomTemplate , customTemplates , isCurrentlyDisplayingAnErrorMessageInATemplate ,
5- currentlyDisplayedTemplate , dynamicallyDefinedValidation , defaultFieldIsValidSuccessFn ;
5+ currentlyDisplayedTemplate , dynamicallyDefinedValidation , defaultFieldIsValidSuccessFn , $q , $timeout , $log ;
66
77 customTemplates = [ ] ;
88
@@ -21,8 +21,7 @@ angular_ui_form_validations = (function(){
2121 } ,
2222 validator : function ( errorMessageElement , val , attr , element , model , modelCtrl , scope ) {
2323 var valid , hydrateDynamicallyDefinedValidation , scopeValidations ,
24- setErrorIdentifier , setValidity , validatorArgs ;
25-
24+ setErrorIdentifier , setValidity , validatorArgs , deferred ;
2625 validatorArgs = arguments ;
2726 scopeValidations = scope [ attr ] ;
2827
@@ -174,8 +173,11 @@ angular_ui_form_validations = (function(){
174173 return index ;
175174 } ;
176175
177- createValidationFormatterLink = function ( formatterArgs , templateRetriever , $q , $timeout , $log ) {
178-
176+ createValidationFormatterLink = function ( formatterArgs , templateRetriever , q , timeout , log ) {
177+ $q = q ;
178+ $timeout = timeout ;
179+ $log = log ;
180+
179181 return function ( $scope , $element , $attrs , ngModelController ) {
180182 var customErrorMessage , errorMessage , errorMessageElement , modelName , model , propertyName , runCustomValidations , validationAttributeValue , customErrorTemplate ;
181183 $timeout ( function ( ) {
@@ -325,39 +327,39 @@ angular_ui_form_validations = (function(){
325327 if ( ! currentlyDisplayingAnErrorMessage ) {
326328 $element . siblings ( '.CustomValidationError.' + formatterArgs . customValidationAttribute + '.' + propertyName + 'property:first' )
327329 . toggle ( ! isValid ) ;
328- } else if ( ! isCurrentlyDisplayingAnErrorMessageInATemplate ( $element ) ) {
330+ } else if ( ! isCurrentlyDisplayingAnErrorMessageInATemplate ( $element ) ) {
329331 currentErrorMessageValidator = getValidatorByAttribute ( currentErrorMessage . attr ( 'data-custom-validation-attribute' ) ) ;
330332 currentErrorMessageIsStale = currentErrorMessageValidator ( errorMessageElement . clone ( ) , value , $attrs [ currentErrorMessage . attr ( 'data-custom-validation-attribute' ) ] , $element , model , ngModelController , $scope ) ;
331-
333+
332334 currentErrorMessagePriorityIndex = parseInt ( currentErrorMessage . attr ( 'data-custom-validation-priorityIndex' ) , 10 ) ;
333335 currentErrorMessageIsOfALowerPriority = currentErrorMessagePriorityIndex >= getValidationPriorityIndex ( formatterArgs . customValidationAttribute ) ;
334-
336+
335337 if ( currentErrorMessageIsStale || ( ! currentErrorMessageIsStale && currentErrorMessageIsOfALowerPriority && ! isValid ) ) {
336338 currentErrorMessage . hide ( ) ;
337339 $element . siblings ( '.CustomValidationError.' + formatterArgs . customValidationAttribute + '.' + propertyName + 'property:first' )
338- . toggle ( ! isValid ) ;
339- }
340+ . toggle ( ! isValid ) ;
341+ }
340342 }
341343
342344 if ( isCurrentlyDisplayingAnErrorMessageInATemplate ( $element ) ) {
343345 currentErrorMessageValidator = getValidatorByAttribute ( currentErrorMessage . attr ( 'data-custom-validation-attribute' ) ) ;
344346 currentErrorMessageIsStale = currentErrorMessageValidator (
345347 errorMessageElement ,
346- value ,
347- getValidationAttributeValue ( $attrs [ currentErrorMessage . attr ( 'data-custom-validation-attribute' ) ] ) ,
348+ value ,
349+ getValidationAttributeValue ( $attrs [ currentErrorMessage . attr ( 'data-custom-validation-attribute' ) ] ) ,
348350 $element , model , ngModelController
349351 ) ;
350-
352+
351353 currentErrorMessagePriorityIndex = parseInt ( currentErrorMessage . attr ( 'data-custom-validation-priorityIndex' ) , 10 ) ;
352354 currentErrorMessageIsOfALowerPriority = currentErrorMessagePriorityIndex >= getValidationPriorityIndex ( formatterArgs . customValidationAttribute ) ;
353-
354- if ( currentErrorMessageIsStale || ( ! currentErrorMessageIsStale && currentErrorMessageIsOfALowerPriority && ! isValid
355+
356+ if ( currentErrorMessageIsStale || ( ! currentErrorMessageIsStale && currentErrorMessageIsOfALowerPriority && ! isValid
355357 && currentlyDisplayedTemplate . children ( ) . attr ( 'class' ) . indexOf ( formatterArgs . customValidationAttribute ) === - 1 ) ) {
356358 currentErrorMessage . hide ( ) ;
357359 $element . siblings ( '.CustomValidationError.' + formatterArgs . customValidationAttribute + '.' + propertyName + 'property:first' )
358- . toggle ( ! isValid ) ;
360+ . toggle ( ! isValid ) ;
359361 $scope . $broadcast ( 'errorMessageToggled' ) ;
360- }
362+ }
361363 }
362364
363365 $scope . $broadcast ( 'customValidationComplete' , customValidationBroadcastArg ) ;
0 commit comments