Browse Source

Merge pull request #210783 in DEC/fineui from master to feature/x

* commit '64bf3dc9e627064a9f45495fce5e7faf4b828563':
  KERNEL-13782 feat: editor支持autoTrim props控制是否需要自动trim
master
superman 2 years ago
parent
commit
4ae3b6530d
  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, allowBlank: false,
watermark: "", watermark: "",
errorText: "", errorText: "",
autoTrim: true,
}); });
}, },
@ -49,25 +50,29 @@ BI.Editor = BI.inherit(BI.Single, {
margin: "0", margin: "0",
}); });
var items = [{ var items = [
{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: function (_ref) { ref: function (_ref) {
self.contentWrapper = _ref; self.contentWrapper = _ref;
}, },
items: [{ items: [
{
el: this.editor, el: this.editor,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], }
],
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
right: o.hgap + o.rgap, right: o.hgap + o.rgap,
top: o.vgap + o.tgap, top: o.vgap + o.tgap,
bottom: o.vgap + o.bgap, bottom: o.vgap + o.bgap,
}]; }
];
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -248,13 +253,15 @@ BI.Editor = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this.contentWrapper, element: this.contentWrapper,
items: [{ items: [
{
el: this.watermark, el: this.watermark,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], }
],
}); });
} }
this.watermark.setText(v); this.watermark.setText(v);
@ -265,7 +272,7 @@ BI.Editor = BI.inherit(BI.Single, {
var o = this.options; var o = this.options;
var errorText = o.errorText; var errorText = o.errorText;
if (BI.isFunction(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)) { if (!this.disabledError && BI.isKey(errorText)) {
BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, { BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {
@ -330,10 +337,10 @@ BI.Editor = BI.inherit(BI.Single, {
getValue: function () { getValue: function () {
if (!this.isValid()) { 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 () { isEditing: function () {

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

@ -31,7 +31,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
errorText: o.errorText, errorText: o.errorText,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
value: o.value value: o.value,
autoTrim: o.autoTrim,
}); });
this.clear = BI.createWidget({ this.clear = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
@ -54,7 +55,8 @@ BI.ClearEditor = BI.inherit(BI.Widget, {
{ {
el: this.clear, el: this.clear,
width: 24 width: 24
}] }
]
}); });
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); 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, watermark: o.watermark,
errorText: o.errorText, errorText: o.errorText,
invisible: true, invisible: true,
autoTrim: o.autoTrim,
}); });
var showText = BI.isFunction(o.text) ? o.text() : o.text; 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, quitChecker: o.quitChecker,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark, watermark: o.watermark,
errorText: o.errorText errorText: o.errorText,
autoTrim: o.autoTrim,
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",

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

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

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

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

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

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

Loading…
Cancel
Save