(context)
| 26449 | |
| 26450 | // helper methods |
| 26451 | function addSetValidityMethod(context) { |
| 26452 | var ctrl = context.ctrl, |
| 26453 | $element = context.$element, |
| 26454 | classCache = {}, |
| 26455 | set = context.set, |
| 26456 | unset = context.unset, |
| 26457 | $animate = context.$animate; |
| 26458 | |
| 26459 | classCache[INVALID_CLASS] = !(classCache[VALID_CLASS] = $element.hasClass(VALID_CLASS)); |
| 26460 | |
| 26461 | ctrl.$setValidity = setValidity; |
| 26462 | |
| 26463 | function setValidity(validationErrorKey, state, controller) { |
| 26464 | if (isUndefined(state)) { |
| 26465 | createAndSet('$pending', validationErrorKey, controller); |
| 26466 | } else { |
| 26467 | unsetAndCleanup('$pending', validationErrorKey, controller); |
| 26468 | } |
| 26469 | if (!isBoolean(state)) { |
| 26470 | unset(ctrl.$error, validationErrorKey, controller); |
| 26471 | unset(ctrl.$$success, validationErrorKey, controller); |
| 26472 | } else { |
| 26473 | if (state) { |
| 26474 | unset(ctrl.$error, validationErrorKey, controller); |
| 26475 | set(ctrl.$$success, validationErrorKey, controller); |
| 26476 | } else { |
| 26477 | set(ctrl.$error, validationErrorKey, controller); |
| 26478 | unset(ctrl.$$success, validationErrorKey, controller); |
| 26479 | } |
| 26480 | } |
| 26481 | if (ctrl.$pending) { |
| 26482 | cachedToggleClass(PENDING_CLASS, true); |
| 26483 | ctrl.$valid = ctrl.$invalid = undefined; |
| 26484 | toggleValidationCss('', null); |
| 26485 | } else { |
| 26486 | cachedToggleClass(PENDING_CLASS, false); |
| 26487 | ctrl.$valid = isObjectEmpty(ctrl.$error); |
| 26488 | ctrl.$invalid = !ctrl.$valid; |
| 26489 | toggleValidationCss('', ctrl.$valid); |
| 26490 | } |
| 26491 | |
| 26492 | // re-read the state as the set/unset methods could have |
| 26493 | // combined state in ctrl.$error[validationError] (used for forms), |
| 26494 | // where setting/unsetting only increments/decrements the value, |
| 26495 | // and does not replace it. |
| 26496 | var combinedState; |
| 26497 | if (ctrl.$pending && ctrl.$pending[validationErrorKey]) { |
| 26498 | combinedState = undefined; |
| 26499 | } else if (ctrl.$error[validationErrorKey]) { |
| 26500 | combinedState = false; |
| 26501 | } else if (ctrl.$$success[validationErrorKey]) { |
| 26502 | combinedState = true; |
| 26503 | } else { |
| 26504 | combinedState = null; |
| 26505 | } |
| 26506 | |
| 26507 | toggleValidationCss(validationErrorKey, combinedState); |
| 26508 | ctrl.$$parentForm.$setValidity(validationErrorKey, combinedState, ctrl); |
no outgoing calls
no test coverage detected