(context)
| 24191 | instance.$$classCache[INVALID_CLASS] = !(instance.$$classCache[VALID_CLASS] = instance.$$element.hasClass(VALID_CLASS)); |
| 24192 | } |
| 24193 | function addSetValidityMethod(context) { |
| 24194 | var clazz = context.clazz, |
| 24195 | set = context.set, |
| 24196 | unset = context.unset; |
| 24197 | |
| 24198 | clazz.prototype.$setValidity = function(validationErrorKey, state, controller) { |
| 24199 | if (isUndefined(state)) { |
| 24200 | createAndSet(this, '$pending', validationErrorKey, controller); |
| 24201 | } else { |
| 24202 | unsetAndCleanup(this, '$pending', validationErrorKey, controller); |
| 24203 | } |
| 24204 | if (!isBoolean(state)) { |
| 24205 | unset(this.$error, validationErrorKey, controller); |
| 24206 | unset(this.$$success, validationErrorKey, controller); |
| 24207 | } else { |
| 24208 | if (state) { |
| 24209 | unset(this.$error, validationErrorKey, controller); |
| 24210 | set(this.$$success, validationErrorKey, controller); |
| 24211 | } else { |
| 24212 | set(this.$error, validationErrorKey, controller); |
| 24213 | unset(this.$$success, validationErrorKey, controller); |
| 24214 | } |
| 24215 | } |
| 24216 | if (this.$pending) { |
| 24217 | cachedToggleClass(this, PENDING_CLASS, true); |
| 24218 | this.$valid = this.$invalid = undefined; |
| 24219 | toggleValidationCss(this, '', null); |
| 24220 | } else { |
| 24221 | cachedToggleClass(this, PENDING_CLASS, false); |
| 24222 | this.$valid = isObjectEmpty(this.$error); |
| 24223 | this.$invalid = !this.$valid; |
| 24224 | toggleValidationCss(this, '', this.$valid); |
| 24225 | } |
| 24226 | |
| 24227 | // re-read the state as the set/unset methods could have |
| 24228 | // combined state in this.$error[validationError] (used for forms), |
| 24229 | // where setting/unsetting only increments/decrements the value, |
| 24230 | // and does not replace it. |
| 24231 | var combinedState; |
| 24232 | if (this.$pending && this.$pending[validationErrorKey]) { |
| 24233 | combinedState = undefined; |
| 24234 | } else if (this.$error[validationErrorKey]) { |
| 24235 | combinedState = false; |
| 24236 | } else if (this.$$success[validationErrorKey]) { |
| 24237 | combinedState = true; |
| 24238 | } else { |
| 24239 | combinedState = null; |
| 24240 | } |
| 24241 | |
| 24242 | toggleValidationCss(this, validationErrorKey, combinedState); |
| 24243 | this.$$parentForm.$setValidity(validationErrorKey, combinedState, this); |
| 24244 | }; |
| 24245 | |
| 24246 | function createAndSet(ctrl, name, value, controller) { |
| 24247 | if (!ctrl[name]) { |
| 24248 | ctrl[name] = {}; |
| 24249 | } |
| 24250 | set(ctrl[name], value, controller); |
no test coverage detected