Browse Source

Pull request #3246: KERNEL-13782 feat: editor支持autoTrim props控制是否需要自动trim

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit 'd14d460d4ccf2f3338f03cd2e83f5b82fc054de1':
  KERNEL-13782 feat: editor支持autoTrim props控制是否需要自动trim
es6
Dailer-刘荣歆 2 years ago
parent
commit
64bf3dc9e6
  1. 25
      src/base/single/editor/editor.js
  2. 6
      src/case/editor/editor.clear.js
  3. 1
      src/case/editor/editor.defaulttext.js
  4. 3
      src/case/editor/editor.shelter.js
  5. 3
      src/case/editor/editor.sign.js
  6. 3
      src/case/editor/editor.state.js
  7. 9
      src/case/editor/editor.state.simple.js
  8. 3
      src/widget/editor/editor.search.js
  9. 3
      src/widget/editor/editor.text.js

25
src/base/single/editor/editor.js

@ -23,6 +23,7 @@ BI.Editor = BI.inherit(BI.Single, {
allowBlank: false,
watermark: "",
errorText: "",
autoTrim: true,
});
},
@ -49,25 +50,29 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0",
});
var items = [{
var items = [
{
el: {
type: "bi.absolute",
ref: function (_ref) {
self.contentWrapper = _ref;
},
items: [{
items: [
{
el: this.editor,
left: 0,
right: 0,
top: 0,
bottom: 0,
}],
}
],
},
left: o.hgap + o.lgap,
right: o.hgap + o.rgap,
top: o.vgap + o.tgap,
bottom: o.vgap + o.bgap,
}];
}
];
BI.createWidget({
type: "bi.absolute",
@ -248,13 +253,15 @@ BI.Editor = BI.inherit(BI.Single, {
BI.createWidget({
type: "bi.absolute",
element: this.contentWrapper,
items: [{
items: [
{
el: this.watermark,
left: 0,
right: 0,
top: 0,
bottom: 0,
}],
}
],
});
}
this.watermark.setText(v);
@ -265,7 +272,7 @@ BI.Editor = BI.inherit(BI.Single, {
var o = this.options;
var errorText = o.errorText;
if (BI.isFunction(errorText)) {
errorText = errorText(BI.trim(this.editor.getValue()));
errorText = errorText(o.autoTrim ? BI.trim(this.editor.getValue()) : this.editor.getValue());
}
if (!this.disabledError && BI.isKey(errorText)) {
BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {
@ -330,10 +337,10 @@ BI.Editor = BI.inherit(BI.Single, {
getValue: function () {
if (!this.isValid()) {
return BI.trim(this.editor.getLastValidValue());
return this.options.autoTrim ? BI.trim(this.editor.getLastValidValue()) : this.editor.getLastValidValue();
}
return BI.trim(this.editor.getValue());
return this.options.autoTrim ? BI.trim(this.editor.getValue()) : this.editor.getValue();
},
isEditing: function () {

6
src/case/editor/editor.clear.js

@ -31,7 +31,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
errorText: o.errorText,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
value: o.value
value: o.value,
autoTrim: o.autoTrim,
});
this.clear = BI.createWidget({
type: "bi.icon_button",
@ -54,7 +55,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
{
el: this.clear,
width: 24
}]
}
]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

1
src/case/editor/editor.defaulttext.js

@ -45,6 +45,7 @@ BI.DefaultTextEditor = BI.inherit(BI.Widget, {
watermark: o.watermark,
errorText: o.errorText,
invisible: true,
autoTrim: o.autoTrim,
});
var showText = BI.isFunction(o.text) ? o.text() : o.text;

3
src/case/editor/editor.shelter.js

@ -46,7 +46,8 @@ BI.ShelterEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",

3
src/case/editor/editor.sign.js

@ -46,7 +46,8 @@ BI.SignEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",

3
src/case/editor/editor.state.js

@ -45,7 +45,8 @@ BI.StateEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",

9
src/case/editor/editor.state.simple.js

@ -45,7 +45,8 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
quitChecker: o.quitChecker,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
errorText: o.errorText,
autoTrim: o.autoTrim,
});
this.text = BI.createWidget({
type: "bi.text_button",
@ -68,13 +69,15 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
items: [
{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
}
]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

3
src/widget/editor/editor.search.js

@ -27,7 +27,8 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
errorText: o.errorText,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
value: o.value
value: o.value,
autoTrim: o.autoTrim,
});
this.clear = BI.createWidget({
type: "bi.icon_button",

3
src/widget/editor/editor.text.js

@ -47,7 +47,8 @@ BI.TextEditor = BI.inherit(BI.Widget, {
watermark: o.watermark,
errorText: o.errorText,
inputType: o.inputType,
autocomplete: o.autocomplete
autocomplete: o.autocomplete,
autoTrim: o.autoTrim,
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);

Loading…
Cancel
Save