(context)
| 25144 | instance.$$classCache[INVALID_CLASS] = !(instance.$$classCache[VALID_CLASS] = instance.$$element.hasClass(VALID_CLASS)); |
| 25145 | } |
| 25146 | function addSetValidityMethod(context) { |
| 25147 | var clazz = context.clazz, |
| 25148 | set = context.set, |
| 25149 | unset = context.unset; |
| 25150 | |
| 25151 | clazz.prototype.$setValidity = function(validationErrorKey, state, controller) { |
| 25152 | if (isUndefined(state)) { |
| 25153 | createAndSet(this, '$pending', validationErrorKey, controller); |
| 25154 | } else { |
| 25155 | unsetAndCleanup(this, '$pending', validationErrorKey, controller); |
| 25156 | } |
| 25157 | if (!isBoolean(state)) { |
| 25158 | unset(this.$error, validationErrorKey, controller); |
| 25159 | unset(this.$$success, validationErrorKey, controller); |
| 25160 | } else { |
| 25161 | if (state) { |
| 25162 | unset(this.$error, validationErrorKey, controller); |
| 25163 | set(this.$$success, validationErrorKey, controller); |
| 25164 | } else { |
| 25165 | set(this.$error, validationErrorKey, controller); |
| 25166 | unset(this.$$success, validationErrorKey, controller); |
| 25167 | } |
| 25168 | } |
| 25169 | if (this.$pending) { |
| 25170 | cachedToggleClass(this, PENDING_CLASS, true); |
| 25171 | this.$valid = this.$invalid = undefined; |
| 25172 | toggleValidationCss(this, '', null); |
| 25173 | } else { |
| 25174 | cachedToggleClass(this, PENDING_CLASS, false); |
| 25175 | this.$valid = isObjectEmpty(this.$error); |
| 25176 | this.$invalid = !this.$valid; |
| 25177 | toggleValidationCss(this, '', this.$valid); |
| 25178 | } |
| 25179 | |
| 25180 | // re-read the state as the set/unset methods could have |
| 25181 | // combined state in this.$error[validationError] (used for forms), |
| 25182 | // where setting/unsetting only increments/decrements the value, |
| 25183 | // and does not replace it. |
| 25184 | var combinedState; |
| 25185 | if (this.$pending && this.$pending[validationErrorKey]) { |
| 25186 | combinedState = undefined; |
| 25187 | } else if (this.$error[validationErrorKey]) { |
| 25188 | combinedState = false; |
| 25189 | } else if (this.$$success[validationErrorKey]) { |
| 25190 | combinedState = true; |
| 25191 | } else { |
| 25192 | combinedState = null; |
| 25193 | } |
| 25194 | |
| 25195 | toggleValidationCss(this, validationErrorKey, combinedState); |
| 25196 | this.$$parentForm.$setValidity(validationErrorKey, combinedState, this); |
| 25197 | }; |
| 25198 | |
| 25199 | function createAndSet(ctrl, name, value, controller) { |
| 25200 | if (!ctrl[name]) { |
| 25201 | ctrl[name] = {}; |
| 25202 | } |
| 25203 | set(ctrl[name], value, controller); |
no test coverage detected