|
|
|
@ -6,16 +6,16 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
|
|
|
|
|
_defaultConfig: function () { |
|
|
|
|
return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this, arguments), { |
|
|
|
|
baseCls: "bi-number-editor bi-border bi-focus-shadow", |
|
|
|
|
validationChecker: function () { |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
validationChecker: BI.emptyFn, |
|
|
|
|
valueFormatter: function (v) { |
|
|
|
|
return v; |
|
|
|
|
}, |
|
|
|
|
value: 0, |
|
|
|
|
allowBlank: false, |
|
|
|
|
errorText: "", |
|
|
|
|
step: 1 |
|
|
|
|
step: 1, |
|
|
|
|
min: BI.MIN, |
|
|
|
|
max: BI.MAX |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -27,7 +27,13 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
|
|
|
|
|
height: o.height - 2, |
|
|
|
|
allowBlank: o.allowBlank, |
|
|
|
|
value: o.valueFormatter(o.value), |
|
|
|
|
validationChecker: o.validationChecker, |
|
|
|
|
validationChecker: function (v) { |
|
|
|
|
// 不设置validationChecker就自动检测
|
|
|
|
|
if(o.validationChecker === BI.emptyFn && !self._checkValueInRange(v)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return o.validationChecker(v); |
|
|
|
|
}, |
|
|
|
|
errorText: o.errorText |
|
|
|
|
}); |
|
|
|
|
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { |
|
|
|
@ -35,9 +41,11 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
|
|
|
|
|
}); |
|
|
|
|
this.editor.on(BI.TextEditor.EVENT_ERROR, function () { |
|
|
|
|
o.value = BI.parseFloat(this.getLastValidValue()); |
|
|
|
|
self._checkAdjustDisabled(o.value); |
|
|
|
|
}); |
|
|
|
|
this.editor.on(BI.TextEditor.EVENT_VALID, function () { |
|
|
|
|
o.value = BI.parseFloat(this.getValue()); |
|
|
|
|
self._checkAdjustDisabled(o.value); |
|
|
|
|
}); |
|
|
|
|
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { |
|
|
|
|
self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); |
|
|
|
@ -96,6 +104,18 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
|
|
|
|
|
return this.editor.isEditing(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_checkValueInRange: function(v) { |
|
|
|
|
var o = this.options; |
|
|
|
|
return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_checkAdjustDisabled: function(v) { |
|
|
|
|
if(this.options.validationChecker === BI.emptyFn) { |
|
|
|
|
this.bottomBtn.setEnable(BI.parseFloat(v) > this.options.min); |
|
|
|
|
this.topBtn.setEnable(BI.parseFloat(v) < this.options.max); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 微调
|
|
|
|
|
_finetuning: function (add) { |
|
|
|
|
var v = BI.parseFloat(this.getValue()); |
|
|
|
|