(context)
| 25079 | instance.$$classCache[INVALID_CLASS] = !(instance.$$classCache[VALID_CLASS] = instance.$$element.hasClass(VALID_CLASS)); |
| 25080 | } |
| 25081 | function addSetValidityMethod(context) { |
| 25082 | var clazz = context.clazz, |
| 25083 | set = context.set, |
| 25084 | unset = context.unset; |
| 25085 | |
| 25086 | clazz.prototype.$setValidity = function(validationErrorKey, state, controller) { |
| 25087 | if (isUndefined(state)) { |
| 25088 | createAndSet(this, '$pending', validationErrorKey, controller); |
| 25089 | } else { |
| 25090 | unsetAndCleanup(this, '$pending', validationErrorKey, controller); |
| 25091 | } |
| 25092 | if (!isBoolean(state)) { |
| 25093 | unset(this.$error, validationErrorKey, controller); |
| 25094 | unset(this.$$success, validationErrorKey, controller); |
| 25095 | } else { |
| 25096 | if (state) { |
| 25097 | unset(this.$error, validationErrorKey, controller); |
| 25098 | set(this.$$success, validationErrorKey, controller); |
| 25099 | } else { |
| 25100 | set(this.$error, validationErrorKey, controller); |
| 25101 | unset(this.$$success, validationErrorKey, controller); |
| 25102 | } |
| 25103 | } |
| 25104 | if (this.$pending) { |
| 25105 | cachedToggleClass(this, PENDING_CLASS, true); |
| 25106 | this.$valid = this.$invalid = undefined; |
| 25107 | toggleValidationCss(this, '', null); |
| 25108 | } else { |
| 25109 | cachedToggleClass(this, PENDING_CLASS, false); |
| 25110 | this.$valid = isObjectEmpty(this.$error); |
| 25111 | this.$invalid = !this.$valid; |
| 25112 | toggleValidationCss(this, '', this.$valid); |
| 25113 | } |
| 25114 | |
| 25115 | // re-read the state as the set/unset methods could have |
| 25116 | // combined state in this.$error[validationError] (used for forms), |
| 25117 | // where setting/unsetting only increments/decrements the value, |
| 25118 | // and does not replace it. |
| 25119 | var combinedState; |
| 25120 | if (this.$pending && this.$pending[validationErrorKey]) { |
| 25121 | combinedState = undefined; |
| 25122 | } else if (this.$error[validationErrorKey]) { |
| 25123 | combinedState = false; |
| 25124 | } else if (this.$$success[validationErrorKey]) { |
| 25125 | combinedState = true; |
| 25126 | } else { |
| 25127 | combinedState = null; |
| 25128 | } |
| 25129 | |
| 25130 | toggleValidationCss(this, validationErrorKey, combinedState); |
| 25131 | this.$$parentForm.$setValidity(validationErrorKey, combinedState, this); |
| 25132 | }; |
| 25133 | |
| 25134 | function createAndSet(ctrl, name, value, controller) { |
| 25135 | if (!ctrl[name]) { |
| 25136 | ctrl[name] = {}; |
| 25137 | } |
| 25138 | set(ctrl[name], value, controller); |
no test coverage detected