(context)
| 24330 | instance.$$classCache[INVALID_CLASS] = !(instance.$$classCache[VALID_CLASS] = instance.$$element.hasClass(VALID_CLASS)); |
| 24331 | } |
| 24332 | function addSetValidityMethod(context) { |
| 24333 | var clazz = context.clazz, |
| 24334 | set = context.set, |
| 24335 | unset = context.unset; |
| 24336 | |
| 24337 | clazz.prototype.$setValidity = function(validationErrorKey, state, controller) { |
| 24338 | if (isUndefined(state)) { |
| 24339 | createAndSet(this, '$pending', validationErrorKey, controller); |
| 24340 | } else { |
| 24341 | unsetAndCleanup(this, '$pending', validationErrorKey, controller); |
| 24342 | } |
| 24343 | if (!isBoolean(state)) { |
| 24344 | unset(this.$error, validationErrorKey, controller); |
| 24345 | unset(this.$$success, validationErrorKey, controller); |
| 24346 | } else { |
| 24347 | if (state) { |
| 24348 | unset(this.$error, validationErrorKey, controller); |
| 24349 | set(this.$$success, validationErrorKey, controller); |
| 24350 | } else { |
| 24351 | set(this.$error, validationErrorKey, controller); |
| 24352 | unset(this.$$success, validationErrorKey, controller); |
| 24353 | } |
| 24354 | } |
| 24355 | if (this.$pending) { |
| 24356 | cachedToggleClass(this, PENDING_CLASS, true); |
| 24357 | this.$valid = this.$invalid = undefined; |
| 24358 | toggleValidationCss(this, '', null); |
| 24359 | } else { |
| 24360 | cachedToggleClass(this, PENDING_CLASS, false); |
| 24361 | this.$valid = isObjectEmpty(this.$error); |
| 24362 | this.$invalid = !this.$valid; |
| 24363 | toggleValidationCss(this, '', this.$valid); |
| 24364 | } |
| 24365 | |
| 24366 | // re-read the state as the set/unset methods could have |
| 24367 | // combined state in this.$error[validationError] (used for forms), |
| 24368 | // where setting/unsetting only increments/decrements the value, |
| 24369 | // and does not replace it. |
| 24370 | var combinedState; |
| 24371 | if (this.$pending && this.$pending[validationErrorKey]) { |
| 24372 | combinedState = undefined; |
| 24373 | } else if (this.$error[validationErrorKey]) { |
| 24374 | combinedState = false; |
| 24375 | } else if (this.$$success[validationErrorKey]) { |
| 24376 | combinedState = true; |
| 24377 | } else { |
| 24378 | combinedState = null; |
| 24379 | } |
| 24380 | |
| 24381 | toggleValidationCss(this, validationErrorKey, combinedState); |
| 24382 | this.$$parentForm.$setValidity(validationErrorKey, combinedState, this); |
| 24383 | }; |
| 24384 | |
| 24385 | function createAndSet(ctrl, name, value, controller) { |
| 24386 | if (!ctrl[name]) { |
| 24387 | ctrl[name] = {}; |
| 24388 | } |
| 24389 | set(ctrl[name], value, controller); |
no test coverage detected