|
|
|
@ -206,14 +206,29 @@ BI.Input = BI.inherit(BI.Single, {
|
|
|
|
|
this._lastValue = this.getValue(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_checkValidationOnValueChange: function () { |
|
|
|
|
var o = this.options; |
|
|
|
|
_checkValidationOnValueChange: function (callback) { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
var v = this.getValue(); |
|
|
|
|
this.setValid( |
|
|
|
|
(o.allowBlank === true && BI.trim(v) == "") || ( |
|
|
|
|
BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
if (o.allowBlank === true && BI.trim(v) == "") { |
|
|
|
|
this.setValid(true); |
|
|
|
|
callback && callback(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (BI.trim(v) == "") { |
|
|
|
|
this.setValid(false); |
|
|
|
|
callback && callback(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var checker = o.validationChecker.apply(this, [BI.trim(v)]); |
|
|
|
|
if (checker instanceof Promise) { |
|
|
|
|
checker.then(function (validate) { |
|
|
|
|
self.setValid(validate !== false); |
|
|
|
|
callback && callback(); |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.setValid(checker !== false); |
|
|
|
|
callback && callback(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
focus: function () { |
|
|
|
@ -245,14 +260,16 @@ BI.Input = BI.inherit(BI.Single, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setValue: function (textValue) { |
|
|
|
|
var self = this; |
|
|
|
|
this.element.val(textValue); |
|
|
|
|
BI.nextTick(BI.bind(function () { |
|
|
|
|
this._checkValidationOnValueChange(); |
|
|
|
|
this._defaultState(); |
|
|
|
|
if (this.isValid()) { |
|
|
|
|
this._lastValidValue = this._lastSubmitValue = this.getValue(); |
|
|
|
|
} |
|
|
|
|
}, this)); |
|
|
|
|
BI.nextTick(function () { |
|
|
|
|
self._checkValidationOnValueChange(function () { |
|
|
|
|
self._defaultState(); |
|
|
|
|
if (self.isValid()) { |
|
|
|
|
self._lastValidValue = self._lastSubmitValue = self.getValue(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getValue: function () { |
|
|
|
|