Browse Source

无JIRA "bi.number_editor" 支持水印

research/test
zsmj 2 years ago
parent
commit
331d271019
  1. 3
      demo/js/widget/numbereditor/demo.number_editor.js
  2. 48
      src/widget/numbereditor/number.editor.js

3
demo/js/widget/numbereditor/demo.number_editor.js

@ -14,7 +14,8 @@ Demo.FileManager = BI.inherit(BI.Widget, {
}, },
height: 24, height: 24,
width: 150, width: 150,
errorText: "hahah" errorText: "hahah",
watermark: "每个人都是自己健康的第一责任人",
}); });
editor1.on(BI.NumberEditor.EVENT_CHANGE, function () { editor1.on(BI.NumberEditor.EVENT_CHANGE, function () {
if (BI.parseFloat(this.getValue()) < 1) { if (BI.parseFloat(this.getValue()) < 1) {

48
src/widget/numbereditor/number.editor.js

@ -18,7 +18,8 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
errorText: "", errorText: "",
step: 1, step: 1,
min: BI.MIN, min: BI.MIN,
max: BI.MAX max: BI.MAX,
watermark: "",
}); });
}, },
@ -30,6 +31,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
height: BI.toPix(o.height, 2), height: BI.toPix(o.height, 2),
simple: o.simple, simple: o.simple,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark,
value: o.valueFormatter(o.value), value: o.valueFormatter(o.value),
validationChecker: function (v) { validationChecker: function (v) {
// 不设置validationChecker就自动检测 // 不设置validationChecker就自动检测
@ -89,23 +91,27 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
type: "bi.htape", type: "bi.htape",
height: BI.toPix(o.height, 2), height: BI.toPix(o.height, 2),
element: this, element: this,
items: [this.editor, { items: [
el: { this.editor, {
type: "bi.grid", el: {
columns: 1, type: "bi.grid",
rows: 2, columns: 1,
items: [{ rows: 2,
column: 0, items: [
row: 0, {
el: this.topBtn column: 0,
}, { row: 0,
column: 0, el: this.topBtn
row: 1, }, {
el: this.bottomBtn column: 0,
}] row: 1,
}, el: this.bottomBtn
width: 23 }
}] ]
},
width: 23
}
]
}); });
}, },
@ -117,13 +123,13 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
return this.editor.isEditing(); return this.editor.isEditing();
}, },
_checkValueInRange: function(v) { _checkValueInRange: function (v) {
var o = this.options; var o = this.options;
return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max); return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max);
}, },
_checkAdjustDisabled: function(v) { _checkAdjustDisabled: function (v) {
if(this.options.validationChecker === BI.emptyFn) { if (this.options.validationChecker === BI.emptyFn) {
this.bottomBtn.setEnable(BI.parseFloat(v) > this.options.min); this.bottomBtn.setEnable(BI.parseFloat(v) > this.options.min);
this.topBtn.setEnable(BI.parseFloat(v) < this.options.max); this.topBtn.setEnable(BI.parseFloat(v) < this.options.max);
} }

Loading…
Cancel
Save