(context)
| 26911 | |
| 26912 | // helper methods |
| 26913 | function addSetValidityMethod(context) { |
| 26914 | var ctrl = context.ctrl, |
| 26915 | $element = context.$element, |
| 26916 | classCache = {}, |
| 26917 | set = context.set, |
| 26918 | unset = context.unset, |
| 26919 | $animate = context.$animate; |
| 26920 | |
| 26921 | classCache[INVALID_CLASS] = !(classCache[VALID_CLASS] = $element.hasClass(VALID_CLASS)); |
| 26922 | |
| 26923 | ctrl.$setValidity = setValidity; |
| 26924 | |
| 26925 | function setValidity(validationErrorKey, state, controller) { |
| 26926 | if (isUndefined(state)) { |
| 26927 | createAndSet('$pending', validationErrorKey, controller); |
| 26928 | } else { |
| 26929 | unsetAndCleanup('$pending', validationErrorKey, controller); |
| 26930 | } |
| 26931 | if (!isBoolean(state)) { |
| 26932 | unset(ctrl.$error, validationErrorKey, controller); |
| 26933 | unset(ctrl.$$success, validationErrorKey, controller); |
| 26934 | } else { |
| 26935 | if (state) { |
| 26936 | unset(ctrl.$error, validationErrorKey, controller); |
| 26937 | set(ctrl.$$success, validationErrorKey, controller); |
| 26938 | } else { |
| 26939 | set(ctrl.$error, validationErrorKey, controller); |
| 26940 | unset(ctrl.$$success, validationErrorKey, controller); |
| 26941 | } |
| 26942 | } |
| 26943 | if (ctrl.$pending) { |
| 26944 | cachedToggleClass(PENDING_CLASS, true); |
| 26945 | ctrl.$valid = ctrl.$invalid = undefined; |
| 26946 | toggleValidationCss('', null); |
| 26947 | } else { |
| 26948 | cachedToggleClass(PENDING_CLASS, false); |
| 26949 | ctrl.$valid = isObjectEmpty(ctrl.$error); |
| 26950 | ctrl.$invalid = !ctrl.$valid; |
| 26951 | toggleValidationCss('', ctrl.$valid); |
| 26952 | } |
| 26953 | |
| 26954 | // re-read the state as the set/unset methods could have |
| 26955 | // combined state in ctrl.$error[validationError] (used for forms), |
| 26956 | // where setting/unsetting only increments/decrements the value, |
| 26957 | // and does not replace it. |
| 26958 | var combinedState; |
| 26959 | if (ctrl.$pending && ctrl.$pending[validationErrorKey]) { |
| 26960 | combinedState = undefined; |
| 26961 | } else if (ctrl.$error[validationErrorKey]) { |
| 26962 | combinedState = false; |
| 26963 | } else if (ctrl.$$success[validationErrorKey]) { |
| 26964 | combinedState = true; |
| 26965 | } else { |
| 26966 | combinedState = null; |
| 26967 | } |
| 26968 | |
| 26969 | toggleValidationCss(validationErrorKey, combinedState); |
| 26970 | ctrl.$$parentForm.$setValidity(validationErrorKey, combinedState, ctrl); |
no outgoing calls
no test coverage detected