diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index ac9e779e9..c0a77c9f6 100644 --- a/src/base/single/editor/editor.js +++ b/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 = [{ - el: { - type: "bi.absolute", - ref: function (_ref) { - self.contentWrapper = _ref; + var items = [ + { + el: { + type: "bi.absolute", + ref: function (_ref) { + self.contentWrapper = _ref; + }, + items: [ + { + el: this.editor, + left: 0, + right: 0, + top: 0, + bottom: 0, + } + ], }, - 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, - }]; + 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: [{ - el: this.watermark, - left: 0, - right: 0, - top: 0, - bottom: 0, - }], + 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 () { diff --git a/src/case/editor/editor.clear.js b/src/case/editor/editor.clear.js index 6fd199a43..e18ab9599 100644 --- a/src/case/editor/editor.clear.js +++ b/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); diff --git a/src/case/editor/editor.defaulttext.js b/src/case/editor/editor.defaulttext.js index 4cfaf59a5..fe88d27bb 100644 --- a/src/case/editor/editor.defaulttext.js +++ b/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; diff --git a/src/case/editor/editor.shelter.js b/src/case/editor/editor.shelter.js index 31883614c..4cb8e4d75 100644 --- a/src/case/editor/editor.shelter.js +++ b/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", diff --git a/src/case/editor/editor.sign.js b/src/case/editor/editor.sign.js index 7a69a5005..0fb65fa0d 100644 --- a/src/case/editor/editor.sign.js +++ b/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", diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js index 8ed915716..9c3f340f9 100644 --- a/src/case/editor/editor.state.js +++ b/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", diff --git a/src/case/editor/editor.state.simple.js b/src/case/editor/editor.state.simple.js index 4d17ab30e..96be87aa1 100644 --- a/src/case/editor/editor.state.simple.js +++ b/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: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] + 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); diff --git a/src/widget/editor/editor.search.js b/src/widget/editor/editor.search.js index 29e4983eb..bd40ae5a9 100644 --- a/src/widget/editor/editor.search.js +++ b/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", diff --git a/src/widget/editor/editor.text.js b/src/widget/editor/editor.text.js index 19f51fd73..022b5f2ad 100644 --- a/src/widget/editor/editor.text.js +++ b/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);