Browse Source

KERNEL-14093 refactor: widget/editor、numbereditor、numberinterval

es6
Zhenfei.Li 2 years ago
parent
commit
4f4e84c419
  1. 280
      src/widget/editor/editor.search.js
  2. 34
      src/widget/editor/editor.search.small.js
  3. 198
      src/widget/editor/editor.text.js
  4. 34
      src/widget/editor/editor.text.small.js
  5. 4
      src/widget/editor/index.js
  6. 29
      src/widget/index.js
  7. 260
      src/widget/numbereditor/number.editor.js
  8. 570
      src/widget/numberinterval/numberinterval.js
  9. 120
      src/widget/numberinterval/singleeditor/single.editor.js

280
src/widget/editor/editor.search.js

@ -1,26 +1,51 @@
/** import { shortcut, Widget, extend, i18nText, emptyFn, createWidget, toPix, isKey, Controller, Events, HTapeLayout, isEndWithBlank } from "@/core";
* Created by roy on 15/9/14. import { IconButton, Editor, IconLabel } from "@/base";
*/
BI.SearchEditor = BI.inherit(BI.Widget, { @shortcut()
_defaultConfig: function (config) { export class SearchEditor extends Widget {
var conf = BI.SearchEditor.superclass._defaultConfig.apply(this, arguments); static xtype = "bi.search_editor"
return BI.extend(conf, {
baseCls: "bi-search-editor bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_CLICK = "EVENT_CLICK"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_SPACE = "EVENT_SPACE"
static EVENT_BACKSPACE = "EVENT_BACKSPACE"
static EVENT_CLEAR = "EVENT_CLEAR"
static EVENT_START = "EVENT_START"
static EVENT_PAUSE = "EVENT_PAUSE"
static EVENT_STOP = "EVENT_STOP"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_ENTER = "EVENT_ENTER"
static EVENT_RESTRICT = "EVENT_RESTRICT"
static EVENT_REMOVE = "EVENT_REMOVE"
static EVENT_EMPTY = "EVENT_EMPTY"
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: `bi-search-editor bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
height: 24, height: 24,
errorText: "", errorText: "",
watermark: BI.i18nText("BI-Basic_Search"), watermark: i18nText("BI-Basic_Search"),
validationChecker: BI.emptyFn, validationChecker: emptyFn,
quitChecker: BI.emptyFn, quitChecker: emptyFn,
value: "" value: "",
}); });
}, }
_init: function () {
BI.SearchEditor.superclass._init.apply(this, arguments); _init() {
var self = this, o = this.options; super._init(...arguments);
this.editor = BI.createWidget(o.el, { const o = this.options;
type: "bi.editor", this.editor = createWidget(o.el, {
type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark, watermark: o.watermark,
allowBlank: true, allowBlank: true,
hgap: 1, hgap: 1,
@ -30,189 +55,168 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
value: o.value, value: o.value,
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.clear = BI.createWidget({ this.clear = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
stopEvent: true, stopEvent: true,
cls: "close-font", cls: "close-font",
invisible: !BI.isKey(o.value) invisible: !isKey(o.value),
}); });
this.clear.on(BI.IconButton.EVENT_CHANGE, function () { this.clear.on(IconButton.EVENT_CHANGE, () => {
self.setValue(""); this.setValue("");
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT, self.getValue()); this.fireEvent(Controller.EVENT_CHANGE, Events.STOPEDIT, this.getValue());
// 从有内容到无内容的清空也是一次change // 从有内容到无内容的清空也是一次change
self.fireEvent(BI.SearchEditor.EVENT_CHANGE); this.fireEvent(SearchEditor.EVENT_CHANGE);
self.fireEvent(BI.SearchEditor.EVENT_CLEAR); this.fireEvent(SearchEditor.EVENT_CLEAR);
}); });
BI.createWidget({ createWidget({
element: this, element: this,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
type: "bi.htape", type: HTapeLayout.xtype,
items: [ items: [{
{ el: {
el: { type: IconLabel.xtype,
type: "bi.icon_label", cls: "search-font",
cls: "search-font"
},
width: 24
}, },
{ width: 24,
el: self.editor },
}, {
{ el: this.editor,
el: this.clear, },
width: 24 {
} el: this.clear,
] width: 24,
}
],
}); });
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.editor.on(BI.Editor.EVENT_FOCUS, function () { this.editor.on(Editor.EVENT_FOCUS, () => {
self.fireEvent(BI.SearchEditor.EVENT_FOCUS); this.fireEvent(SearchEditor.EVENT_FOCUS);
}); });
this.editor.on(BI.Editor.EVENT_BLUR, function () { this.editor.on(Editor.EVENT_BLUR, () => {
self.fireEvent(BI.SearchEditor.EVENT_BLUR); this.fireEvent(SearchEditor.EVENT_BLUR);
}); });
this.editor.on(BI.Editor.EVENT_CLICK, function () { this.editor.on(Editor.EVENT_CLICK, () => {
self.fireEvent(BI.SearchEditor.EVENT_CLICK); this.fireEvent(SearchEditor.EVENT_CLICK);
}); });
this.editor.on(BI.Editor.EVENT_CHANGE, function () { this.editor.on(Editor.EVENT_CHANGE, () => {
self._checkClear(); this._checkClear();
self.fireEvent(BI.SearchEditor.EVENT_CHANGE); this.fireEvent(SearchEditor.EVENT_CHANGE);
}); });
this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { this.editor.on(Editor.EVENT_KEY_DOWN, v => {
self.fireEvent(BI.SearchEditor.EVENT_KEY_DOWN, v); this.fireEvent(SearchEditor.EVENT_KEY_DOWN, v);
}); });
this.editor.on(BI.Editor.EVENT_SPACE, function () { this.editor.on(Editor.EVENT_SPACE, () => {
self.fireEvent(BI.SearchEditor.EVENT_SPACE); this.fireEvent(SearchEditor.EVENT_SPACE);
}); });
this.editor.on(BI.Editor.EVENT_BACKSPACE, function () { this.editor.on(Editor.EVENT_BACKSPACE, () => {
self.fireEvent(BI.SearchEditor.EVENT_BACKSPACE); this.fireEvent(SearchEditor.EVENT_BACKSPACE);
}); });
this.editor.on(BI.Editor.EVENT_VALID, function () { this.editor.on(Editor.EVENT_VALID, () => {
self.fireEvent(BI.SearchEditor.EVENT_VALID); this.fireEvent(SearchEditor.EVENT_VALID);
}); });
this.editor.on(BI.Editor.EVENT_ERROR, function () { this.editor.on(Editor.EVENT_ERROR, () => {
self.fireEvent(BI.SearchEditor.EVENT_ERROR); this.fireEvent(SearchEditor.EVENT_ERROR);
}); });
this.editor.on(BI.Editor.EVENT_ENTER, function () { this.editor.on(Editor.EVENT_ENTER, () => {
self.fireEvent(BI.SearchEditor.EVENT_ENTER); this.fireEvent(SearchEditor.EVENT_ENTER);
}); });
this.editor.on(BI.Editor.EVENT_RESTRICT, function () { this.editor.on(Editor.EVENT_RESTRICT, () => {
self.fireEvent(BI.SearchEditor.EVENT_RESTRICT); this.fireEvent(SearchEditor.EVENT_RESTRICT);
}); });
this.editor.on(BI.Editor.EVENT_EMPTY, function () { this.editor.on(Editor.EVENT_EMPTY, () => {
self._checkClear(); this._checkClear();
self.fireEvent(BI.SearchEditor.EVENT_EMPTY); this.fireEvent(SearchEditor.EVENT_EMPTY);
}); });
this.editor.on(BI.Editor.EVENT_REMOVE, function () { this.editor.on(Editor.EVENT_REMOVE, () => {
self.fireEvent(BI.SearchEditor.EVENT_REMOVE); this.fireEvent(SearchEditor.EVENT_REMOVE);
}); });
this.editor.on(BI.Editor.EVENT_CONFIRM, function () { this.editor.on(Editor.EVENT_CONFIRM, () => {
self.fireEvent(BI.SearchEditor.EVENT_CONFIRM); this.fireEvent(SearchEditor.EVENT_CONFIRM);
}); });
this.editor.on(BI.Editor.EVENT_CHANGE_CONFIRM, function () { this.editor.on(Editor.EVENT_CHANGE_CONFIRM, () => {
self.fireEvent(BI.SearchEditor.EVENT_CHANGE_CONFIRM); this.fireEvent(SearchEditor.EVENT_CHANGE_CONFIRM);
}); });
this.editor.on(BI.Editor.EVENT_START, function () { this.editor.on(Editor.EVENT_START, () => {
self.fireEvent(BI.SearchEditor.EVENT_START); this.fireEvent(SearchEditor.EVENT_START);
}); });
this.editor.on(BI.Editor.EVENT_PAUSE, function () { this.editor.on(Editor.EVENT_PAUSE, () => {
self.fireEvent(BI.SearchEditor.EVENT_PAUSE); this.fireEvent(SearchEditor.EVENT_PAUSE);
}); });
this.editor.on(BI.Editor.EVENT_STOP, function () { this.editor.on(Editor.EVENT_STOP, () => {
self.fireEvent(BI.SearchEditor.EVENT_STOP); this.fireEvent(SearchEditor.EVENT_STOP);
}); });
}, }
_checkClear: function () { _checkClear() {
if (!this.getValue()) { if (!this.getValue()) {
this.clear.invisible(); this.clear.invisible();
} else { } else {
this.clear.visible(); this.clear.visible();
} }
}, }
setWaterMark: function (v) { setWaterMark(v) {
this.options.watermark = v; this.options.watermark = v;
this.editor.setWaterMark(v); this.editor.setWaterMark(v);
}, }
focus: function () { focus() {
this.editor.focus(); this.editor.focus();
}, }
blur: function () { blur() {
this.editor.blur(); this.editor.blur();
}, }
getValue: function () { getValue() {
if (this.isValid()) { if (this.isValid()) {
return this.editor.getValue(); return this.editor.getValue();
} }
}, }
getKeywords: function () { getKeywords() {
var val = this.editor.getLastChangedValue(); const val = this.editor.getLastChangedValue();
var keywords = val.match(/[\S]+/g); const keywords = val.match(/[\S]+/g);
if (BI.isEndWithBlank(val)) { if (isEndWithBlank(val)) {
return keywords.concat([" "]); return keywords.concat([" "]);
} }
return keywords; return keywords;
}, }
getLastValidValue: function () { getLastValidValue() {
return this.editor.getLastValidValue(); return this.editor.getLastValidValue();
}, }
getLastChangedValue: function () { getLastChangedValue() {
return this.editor.getLastChangedValue(); return this.editor.getLastChangedValue();
}, }
setValue: function (v) { setValue(v) {
this.editor.setValue(v); this.editor.setValue(v);
if (BI.isKey(v)) { if (isKey(v)) {
this.clear.visible(); this.clear.visible();
} }
}, }
isEditing: function () { isEditing() {
return this.editor.isEditing(); return this.editor.isEditing();
}, }
isValid: function () { isValid() {
return this.editor.isValid(); return this.editor.isValid();
}, }
showClearIcon: function () { showClearIcon() {
this.clear.visible(); this.clear.visible();
}, }
hideClearIcon: function () { hideClearIcon() {
this.clear.invisible(); this.clear.invisible();
} }
}); }
BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.SearchEditor.EVENT_FOCUS = "EVENT_FOCUS";
BI.SearchEditor.EVENT_BLUR = "EVENT_BLUR";
BI.SearchEditor.EVENT_CLICK = "EVENT_CLICK";
BI.SearchEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.SearchEditor.EVENT_SPACE = "EVENT_SPACE";
BI.SearchEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE";
BI.SearchEditor.EVENT_CLEAR = "EVENT_CLEAR";
BI.SearchEditor.EVENT_START = "EVENT_START";
BI.SearchEditor.EVENT_PAUSE = "EVENT_PAUSE";
BI.SearchEditor.EVENT_STOP = "EVENT_STOP";
BI.SearchEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.SearchEditor.EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
BI.SearchEditor.EVENT_VALID = "EVENT_VALID";
BI.SearchEditor.EVENT_ERROR = "EVENT_ERROR";
BI.SearchEditor.EVENT_ENTER = "EVENT_ENTER";
BI.SearchEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
BI.SearchEditor.EVENT_REMOVE = "EVENT_REMOVE";
BI.SearchEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.search_editor", BI.SearchEditor);

34
src/widget/editor/editor.search.small.js

@ -1,20 +1,20 @@
/** import { shortcut, extend } from "@/core";
* 小号搜索框 import { SearchEditor } from "./editor.search";
* Created by GUY on 2015/9/29.
* @class BI.SmallSearchEditor @shortcut()
* @extends BI.SearchEditor export class SmallSearchEditor extends SearchEditor {
*/ static xtype = "bi.small_search_editor"
BI.SmallSearchEditor = BI.inherit(BI.SearchEditor, {
_defaultConfig: function () { _defaultConfig() {
var conf = BI.SmallSearchEditor.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(...arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-small-search-editor", return extend(conf, {
height: 20 baseCls: `${conf.baseCls || ""} bi-small-search-editor`,
height: 20,
}); });
}, }
_init: function () { _init() {
BI.SmallSearchEditor.superclass._init.apply(this, arguments); super._init(...arguments);
} }
}); }
BI.shortcut("bi.small_search_editor", BI.SmallSearchEditor);

198
src/widget/editor/editor.text.js

@ -1,36 +1,57 @@
/** import { shortcut, Widget, extend, emptyFn, createWidget, toPix, Controller } from "@/core";
* guy import { Editor } from "@/base";
* @class BI.TextEditor
* @extends BI.Single @shortcut()
*/ export class TextEditor extends Widget {
BI.TextEditor = BI.inherit(BI.Widget, { static xtype = "bi.text_editor"
_defaultConfig: function (config) {
var conf = BI.TextEditor.superclass._defaultConfig.apply(this, arguments); static EVENT_CHANGE = "EVENT_CHANGE"
return BI.extend(conf, { static EVENT_FOCUS = "EVENT_FOCUS"
extraCls: "bi-text-editor bi-focus-shadow " + (config.simple ? "bi-border-bottom" : "bi-border"), static EVENT_BLUR = "EVENT_BLUR"
static EVENT_CLICK = "EVENT_CLICK"
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN"
static EVENT_SPACE = "EVENT_SPACE"
static EVENT_BACKSPACE = "EVENT_BACKSPACE"
static EVENT_START = "EVENT_START"
static EVENT_PAUSE = "EVENT_PAUSE"
static EVENT_STOP = "EVENT_STOP"
static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_ENTER = "EVENT_ENTER"
static EVENT_RESTRICT = "EVENT_RESTRICT"
static EVENT_REMOVE = "EVENT_REMOVE"
static EVENT_EMPTY = "EVENT_EMPTY"
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: `bi-text-editor bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border"}`,
hgap: 4, hgap: 4,
vgap: 2, vgap: 2,
lgap: 0, lgap: 0,
rgap: 0, rgap: 0,
tgap: 0, tgap: 0,
bgap: 0, bgap: 0,
validationChecker: BI.emptyFn, validationChecker: emptyFn,
quitChecker: BI.emptyFn, quitChecker: emptyFn,
allowBlank: false, allowBlank: false,
watermark: "", watermark: "",
errorText: "", errorText: "",
height: 24 height: 24,
}); });
}, }
render: function () { render() {
var self = this, o = this.options; const o = this.options;
var border = o.simple ? 1 : 2; const border = o.simple ? 1 : 2;
this.editor = BI.createWidget({ this.editor = createWidget({
type: "bi.editor", type: Editor.xtype,
element: this, element: this,
width: BI.toPix(o.width, border), width: toPix(o.width, border),
height: BI.toPix(o.height, border), height: toPix(o.height, border),
simple: o.simple, simple: o.simple,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -50,121 +71,100 @@ BI.TextEditor = BI.inherit(BI.Widget, {
autocomplete: o.autocomplete, autocomplete: o.autocomplete,
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(Controller.EVENT_CHANGE, (...args) => {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.editor.on(BI.Editor.EVENT_FOCUS, function () { this.editor.on(Editor.EVENT_FOCUS, () => {
self.fireEvent(BI.TextEditor.EVENT_FOCUS); this.fireEvent(TextEditor.EVENT_FOCUS);
}); });
this.editor.on(BI.Editor.EVENT_BLUR, function () { this.editor.on(Editor.EVENT_BLUR, () => {
self.fireEvent(BI.TextEditor.EVENT_BLUR); this.fireEvent(TextEditor.EVENT_BLUR);
}); });
this.editor.on(BI.Editor.EVENT_CLICK, function () { this.editor.on(Editor.EVENT_CLICK, () => {
self.fireEvent(BI.TextEditor.EVENT_CLICK); this.fireEvent(TextEditor.EVENT_CLICK);
}); });
this.editor.on(BI.Editor.EVENT_CHANGE, function () { this.editor.on(Editor.EVENT_CHANGE, () => {
self.fireEvent(BI.TextEditor.EVENT_CHANGE); this.fireEvent(TextEditor.EVENT_CHANGE);
}); });
this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { this.editor.on(Editor.EVENT_KEY_DOWN, v => {
self.fireEvent(BI.TextEditor.EVENT_KEY_DOWN); this.fireEvent(TextEditor.EVENT_KEY_DOWN);
}); });
this.editor.on(BI.Editor.EVENT_SPACE, function (v) { this.editor.on(Editor.EVENT_SPACE, v => {
self.fireEvent(BI.TextEditor.EVENT_SPACE); this.fireEvent(TextEditor.EVENT_SPACE);
}); });
this.editor.on(BI.Editor.EVENT_BACKSPACE, function (v) { this.editor.on(Editor.EVENT_BACKSPACE, v => {
self.fireEvent(BI.TextEditor.EVENT_BACKSPACE); this.fireEvent(TextEditor.EVENT_BACKSPACE);
}); });
this.editor.on(BI.Editor.EVENT_VALID, function () { this.editor.on(Editor.EVENT_VALID, () => {
self.element.removeClass("error"); this.element.removeClass("error");
self.fireEvent(BI.TextEditor.EVENT_VALID); this.fireEvent(TextEditor.EVENT_VALID);
}); });
this.editor.on(BI.Editor.EVENT_CONFIRM, function () { this.editor.on(Editor.EVENT_CONFIRM, () => {
self.fireEvent(BI.TextEditor.EVENT_CONFIRM); this.fireEvent(TextEditor.EVENT_CONFIRM);
}); });
this.editor.on(BI.Editor.EVENT_CHANGE_CONFIRM, function () { this.editor.on(Editor.EVENT_CHANGE_CONFIRM, () => {
self.fireEvent(BI.TextEditor.EVENT_CHANGE_CONFIRM); this.fireEvent(TextEditor.EVENT_CHANGE_CONFIRM);
}); });
this.editor.on(BI.Editor.EVENT_REMOVE, function (v) { this.editor.on(Editor.EVENT_REMOVE, v => {
self.fireEvent(BI.TextEditor.EVENT_REMOVE); this.fireEvent(TextEditor.EVENT_REMOVE);
}); });
this.editor.on(BI.Editor.EVENT_START, function () { this.editor.on(Editor.EVENT_START, () => {
self.fireEvent(BI.TextEditor.EVENT_START); this.fireEvent(TextEditor.EVENT_START);
}); });
this.editor.on(BI.Editor.EVENT_PAUSE, function () { this.editor.on(Editor.EVENT_PAUSE, () => {
self.fireEvent(BI.TextEditor.EVENT_PAUSE); this.fireEvent(TextEditor.EVENT_PAUSE);
}); });
this.editor.on(BI.Editor.EVENT_STOP, function () { this.editor.on(Editor.EVENT_STOP, () => {
self.fireEvent(BI.TextEditor.EVENT_STOP); this.fireEvent(TextEditor.EVENT_STOP);
}); });
this.editor.on(BI.Editor.EVENT_ERROR, function () { this.editor.on(Editor.EVENT_ERROR, (...args) => {
self.element.addClass("error"); this.element.addClass("error");
self.fireEvent(BI.TextEditor.EVENT_ERROR, arguments); this.fireEvent(TextEditor.EVENT_ERROR, ...args);
}); });
this.editor.on(BI.Editor.EVENT_ENTER, function () { this.editor.on(Editor.EVENT_ENTER, () => {
self.fireEvent(BI.TextEditor.EVENT_ENTER); this.fireEvent(TextEditor.EVENT_ENTER);
}); });
this.editor.on(BI.Editor.EVENT_RESTRICT, function () { this.editor.on(Editor.EVENT_RESTRICT, () => {
self.fireEvent(BI.TextEditor.EVENT_RESTRICT); this.fireEvent(TextEditor.EVENT_RESTRICT);
}); });
this.editor.on(BI.Editor.EVENT_EMPTY, function () { this.editor.on(Editor.EVENT_EMPTY, () => {
self.fireEvent(BI.TextEditor.EVENT_EMPTY); this.fireEvent(TextEditor.EVENT_EMPTY);
}); });
}, }
setWaterMark: function (v) { setWaterMark(v) {
this.options.watermark = v; this.options.watermark = v;
this.editor.setWaterMark(v); this.editor.setWaterMark(v);
}, }
focus: function () { focus() {
this.editor.focus(); this.editor.focus();
}, }
blur: function () { blur() {
this.editor.blur(); this.editor.blur();
}, }
setErrorText: function (text) { setErrorText(text) {
this.editor.setErrorText(text); this.editor.setErrorText(text);
}, }
getErrorText: function () { getErrorText() {
return this.editor.getErrorText(); return this.editor.getErrorText();
}, }
isValid: function () { isValid() {
return this.editor.isValid(); return this.editor.isValid();
}, }
setValue: function (v) { setValue(v) {
this.editor.setValue(v); this.editor.setValue(v);
}, }
getValue: function () { getValue() {
return this.editor.getValue(); return this.editor.getValue();
} }
}); }
BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.TextEditor.EVENT_FOCUS = "EVENT_FOCUS";
BI.TextEditor.EVENT_BLUR = "EVENT_BLUR";
BI.TextEditor.EVENT_CLICK = "EVENT_CLICK";
BI.TextEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.TextEditor.EVENT_SPACE = "EVENT_SPACE";
BI.TextEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE";
BI.TextEditor.EVENT_START = "EVENT_START";
BI.TextEditor.EVENT_PAUSE = "EVENT_PAUSE";
BI.TextEditor.EVENT_STOP = "EVENT_STOP";
BI.TextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.TextEditor.EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
BI.TextEditor.EVENT_VALID = "EVENT_VALID";
BI.TextEditor.EVENT_ERROR = "EVENT_ERROR";
BI.TextEditor.EVENT_ENTER = "EVENT_ENTER";
BI.TextEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
BI.TextEditor.EVENT_REMOVE = "EVENT_REMOVE";
BI.TextEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.text_editor", BI.TextEditor);

34
src/widget/editor/editor.text.small.js

@ -1,20 +1,20 @@
/** import { shortcut, extend } from "@/core";
* 小号搜索框 import { TextEditor } from "./editor.text";
* Created by GUY on 2015/9/29.
* @class BI.SmallTextEditor @shortcut()
* @extends BI.SearchEditor export class SmallTextEditor extends TextEditor {
*/ static xtype = "bi.small_text_editor"
BI.SmallTextEditor = BI.inherit(BI.TextEditor, {
_defaultConfig: function () { _defaultConfig() {
var conf = BI.SmallTextEditor.superclass._defaultConfig.apply(this, arguments); const conf = super._defaultConfig(...arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-small-text-editor", return extend(conf, {
height: 20 baseCls: `${conf.baseCls || ""} bi-small-text-editor`,
height: 20,
}); });
}, }
_init: function () { _init() {
BI.SmallTextEditor.superclass._init.apply(this, arguments); super._init(...arguments);
} }
}); }
BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);

4
src/widget/editor/index.js

@ -0,0 +1,4 @@
export { SearchEditor } from "./editor.search";
export { SmallSearchEditor } from "./editor.search.small";
export { TextEditor } from "./editor.text";
export { SmallTextEditor } from "./editor.text.small";

29
src/widget/index.js

@ -6,11 +6,14 @@ import * as datetime from "./datetime";
import * as datetimepane from "./datetimepane"; import * as datetimepane from "./datetimepane";
import * as dynamicdatetime from "./dynamicdatetime"; import * as dynamicdatetime from "./dynamicdatetime";
import * as time from "./time"; import * as time from "./time";
import * as editor from "./editor";
import { SelectTreeCombo } from "./selecttree/selecttree.combo"; import { SelectTreeCombo } from "./selecttree/selecttree.combo";
import { SingleTreeCombo } from "./singletree/singletree.combo"; import { SingleTreeCombo } from "./singletree/singletree.combo";
import { MultiTreeCombo } from "/multitree/multi.tree.combo"; import { MultiTreeCombo } from "./multitree/multi.tree.combo";
import { MultiTreeInsertCombo } from "/multitree/multi.tree.insert.combo"; import { MultiTreeInsertCombo } from "./multitree/multi.tree.insert.combo";
import { MultiTreeListCombo } from "/multitree/multi.tree.list.combo"; import { MultiTreeListCombo } from "./multitree/multi.tree.list.combo";
import { NumberEditor } from "./numbereditor/number.editor";
import { NumberInterval } from "./numberinterval/numberinterval";
Object.assign(BI, { Object.assign(BI, {
Collapse, Collapse,
@ -21,11 +24,14 @@ Object.assign(BI, {
...datetimepane, ...datetimepane,
...dynamicdatetime, ...dynamicdatetime,
...time, ...time,
...editor,
SelectTreeCombo, SelectTreeCombo,
SingleTreeCombo, SingleTreeCombo,
MultiTreeCombo, MultiTreeCombo,
MultiTreeInsertCombo, MultiTreeInsertCombo,
MultiTreeListCombo MultiTreeListCombo,
NumberEditor,
NumberInterval,
}); });
export * from "./date/calendar"; export * from "./date/calendar";
@ -35,11 +41,14 @@ export * from "./datetime";
export * from "./datetimepane"; export * from "./datetimepane";
export * from "./dynamicdatetime"; export * from "./dynamicdatetime";
export * from "./time"; export * from "./time";
export { SelectTreeCombo } from "./selecttree/selecttree.combo"; export * from "./editor";
export { SingleTreeCombo } from "./singletree/singletree.combo";
export { MultiTreeCombo } from "/multitree/multi.tree.combo";
export { MultiTreeInsertCombo } from "/multitree/multi.tree.insert.combo";
export { MultiTreeListCombo } from "/multitree/multi.tree.list.combo";
export { export {
Collapse Collapse,
NumberEditor,
NumberInterval,
SelectTreeCombo,
SingleTreeCombo,
MultiTreeCombo,
MultiTreeInsertCombo,
MultiTreeListCombo
}; };

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

@ -1,202 +1,204 @@
/** import { shortcut, Widget, extend, emptyFn, createWidget, toPix, parseFloat, HTapeLayout, GridLayout, isNumeric, clamp, MIN, MAX, KeyCode, add } from "@/core";
* Created by windy on 2017/3/13. import { SignEditor } from "@/case";
* 数值微调器 import { TextEditor } from "../editor";
*/ import { IconButton } from "@/base";
BI.NumberEditor = BI.inherit(BI.Widget, {
_defaultConfig: function (conf) { @shortcut()
return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this, arguments), { export class NumberEditor extends Widget {
baseCls: "bi-number-editor bi-focus-shadow " + (conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"), static xtype = "bi.number_editor"
validationChecker: BI.emptyFn,
valueFormatter: function (v) { static EVENT_CONFIRM = "EVENT_CONFIRM"
static EVENT_CHANGE = "EVENT_CHANGE"
_defaultConfig(conf) {
return extend(super._defaultConfig(...arguments), {
baseCls: `bi-number-editor bi-focus-shadow ${conf.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
validationChecker: emptyFn,
valueFormatter (v) {
return v; return v;
}, },
valueParser: function (v) { valueParser (v) {
return v; return v;
}, },
value: 0, value: 0,
allowBlank: false, allowBlank: false,
errorText: "", errorText: "",
step: 1, step: 1,
min: BI.MIN, min: MIN,
max: BI.MAX, max: MAX,
watermark: "", watermark: "",
}); });
}, }
_init: function () { _init() {
BI.NumberEditor.superclass._init.apply(this, arguments); super._init(...arguments);
var self = this, o = this.options; const o = this.options;
this.editor = BI.createWidget({ this.editor = createWidget({
type: "bi.sign_editor", type: SignEditor.xtype,
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
simple: o.simple, simple: o.simple,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark, watermark: o.watermark,
value: o.valueFormatter(o.value), value: o.valueFormatter(o.value),
validationChecker: function (v) { validationChecker: v => {
// 不设置validationChecker就自动检测 // 不设置validationChecker就自动检测
var parsedValue = o.valueParser(v); const parsedValue = o.valueParser(v);
if (o.validationChecker === BI.emptyFn && !self._checkValueInRange(parsedValue)) { if (o.validationChecker === emptyFn && !this._checkValueInRange(parsedValue)) {
return false; return false;
} }
return o.validationChecker(parsedValue); return o.validationChecker(parsedValue);
}, },
errorText: o.errorText, errorText: o.errorText,
listeners: [ listeners: [{
{ eventName: SignEditor.EVENT_QUICK_DOWN,
eventName: BI.SignEditor.EVENT_QUICK_DOWN, action: e => {
action: e => { if ([KeyCode.UP, KeyCode.DOWN].includes(e.keyCode)) {
if ([BI.KeyCode.UP, BI.KeyCode.DOWN].includes(e.keyCode)) { e.preventDefault();
e.preventDefault(); }
}
},
}, },
{ },
eventName: BI.SignEditor.EVENT_KEY_DOWN, {
action: (keycode) => { eventName: SignEditor.EVENT_KEY_DOWN,
if (keycode === BI.KeyCode.UP) { action: keycode => {
this._finetuning(o.step); if (keycode === KeyCode.UP) {
this._finetuning(o.step);
return;
} return;
if (keycode === BI.KeyCode.DOWN) { }
this._finetuning(-o.step); if (keycode === KeyCode.DOWN) {
} this._finetuning(-o.step);
}, }
} },
}
], ],
}); });
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { this.editor.on(TextEditor.EVENT_CHANGE, () => {
// 大多数时候valueFormatter往往需要配合valueParser一起使用 // 大多数时候valueFormatter往往需要配合valueParser一起使用
var value = this.getValue(); const value = this.editor.getValue();
var parsedValue = o.valueParser(value); const parsedValue = o.valueParser(value);
this.setValue(o.valueFormatter(parsedValue)); this.editor.setValue(o.valueFormatter(parsedValue));
self.fireEvent(BI.NumberEditor.EVENT_CHANGE); this.fireEvent(NumberEditor.EVENT_CHANGE);
}); });
this.editor.on(BI.TextEditor.EVENT_ERROR, function () { this.editor.on(TextEditor.EVENT_ERROR, () => {
o.value = BI.parseFloat(this.getLastValidValue()); o.value = parseFloat(this.editor.getLastValidValue());
self._checkAdjustDisabled(o.value); this._checkAdjustDisabled(o.value);
self.element.addClass("error"); this.element.addClass("error");
}); });
this.editor.on(BI.TextEditor.EVENT_VALID, function () { this.editor.on(TextEditor.EVENT_VALID, () => {
o.value = BI.parseFloat(this.getValue()); o.value = parseFloat(this.editor.getValue());
self._checkAdjustDisabled(o.value); this._checkAdjustDisabled(o.value);
self.element.removeClass("error"); this.element.removeClass("error");
}); });
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { this.editor.on(TextEditor.EVENT_CONFIRM, () => {
self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); this.fireEvent(NumberEditor.EVENT_CONFIRM);
}); });
this.topBtn = BI.createWidget({ this.topBtn = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
forceNotSelected: true, forceNotSelected: true,
trigger: "lclick,", trigger: "lclick,",
debounce: false, debounce: false,
cls: (o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left ") + "top-button bi-list-item-active2 icon-size-12", cls: `${o.simple ? "solid-triangle-top-font " : "add-up-font bi-border-left "}top-button bi-list-item-active2 icon-size-12`,
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { this.topBtn.on(IconButton.EVENT_CHANGE, () => {
self._finetuning(o.step); this._finetuning(o.step);
self.fireEvent(BI.NumberEditor.EVENT_CHANGE); this.fireEvent(NumberEditor.EVENT_CHANGE);
self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); this.fireEvent(NumberEditor.EVENT_CONFIRM);
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
trigger: "lclick,", trigger: "lclick,",
forceNotSelected: true, forceNotSelected: true,
debounce: false, debounce: false,
cls: (o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left ") + "bottom-button bi-list-item-active2 icon-size-12", cls: `${o.simple ? "solid-triangle-bottom-font " : "minus-down-font bi-border-left "}bottom-button bi-list-item-active2 icon-size-12`,
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { this.bottomBtn.on(IconButton.EVENT_CHANGE, () => {
self._finetuning(-o.step); this._finetuning(-o.step);
self.fireEvent(BI.NumberEditor.EVENT_CHANGE); this.fireEvent(NumberEditor.EVENT_CHANGE);
self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); this.fireEvent(NumberEditor.EVENT_CONFIRM);
}); });
BI.createWidget({ createWidget({
type: "bi.htape", type: HTapeLayout.xtype,
height: BI.toPix(o.height, 2), height: toPix(o.height, 2),
element: this, element: this,
items: [ items: [
this.editor, { this.editor, {
el: { el: {
type: "bi.grid", type: GridLayout.xtype,
columns: 1, columns: 1,
rows: 2, rows: 2,
items: [ items: [{
{ column: 0,
column: 0, row: 0,
row: 0, el: this.topBtn,
el: this.topBtn, }, {
}, { column: 0,
column: 0, row: 1,
row: 1, el: this.bottomBtn,
el: this.bottomBtn, }],
}
],
}, },
width: 23, width: 23,
} }
], ],
}); });
}, }
focus: function () { focus() {
this.editor.focus(); this.editor.focus();
}, }
isEditing: function () { isEditing() {
return this.editor.isEditing(); return this.editor.isEditing();
}, }
_checkValueInRange: function (v) { _checkValueInRange(v) {
var o = this.options; const o = this.options;
return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max); return !!(isNumeric(v) && parseFloat(v) >= o.min && parseFloat(v) <= o.max);
}, }
_checkAdjustDisabled: function (v) { _checkAdjustDisabled(v) {
if (this.options.validationChecker === BI.emptyFn) { if (this.options.validationChecker === emptyFn) {
this.bottomBtn.setEnable(BI.parseFloat(v) > this.options.min); this.bottomBtn.setEnable(parseFloat(v) > this.options.min);
this.topBtn.setEnable(BI.parseFloat(v) < this.options.max); this.topBtn.setEnable(parseFloat(v) < this.options.max);
} }
}, }
// 微调 _finetuning(addValue) {
_finetuning: function (add) { const {
const { max, min } = this.options; max,
let v = BI.parseFloat(this.getValue()); min,
v = BI.add(v, add); } = this.options;
v = BI.clamp(v, min, max); let v = parseFloat(this.getValue());
v = add(v, addValue);
v = clamp(v, min, max);
this.setValue(v); this.setValue(v);
}, }
setUpEnable: function (v) { setUpEnable(v) {
this.topBtn.setEnable(!!v); this.topBtn.setEnable(!!v);
}, }
setDownEnable: function (v) { setDownEnable(v) {
this.bottomBtn.setEnable(!!v); this.bottomBtn.setEnable(!!v);
}, }
getLastValidValue: function () { getLastValidValue() {
return this.editor.getLastValidValue(); return this.editor.getLastValidValue();
}, }
getLastChangedValue: function () { getLastChangedValue() {
return this.editor.getLastChangedValue(); return this.editor.getLastChangedValue();
}, }
getValue: function () { getValue() {
return this.options.value; return this.options.value;
}, }
setValue: function (v) { setValue(v) {
var o = this.options; const o = this.options;
o.value = v; o.value = v;
this.editor.setValue(o.valueFormatter(v)); this.editor.setValue(o.valueFormatter(v));
this._checkAdjustDisabled(o.value); this._checkAdjustDisabled(o.value);
}, }
}
});
BI.NumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.NumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.number_editor", BI.NumberEditor);

570
src/widget/numberinterval/numberinterval.js

@ -1,11 +1,13 @@
// 小于号的值为:0,小于等于号的值为:1 import { shortcut, extend, i18nText, createWidget, toPix, isNumeric, AbsoluteLayout, isEmptyString, isNotNull, isNull, isIE, getIEVersion } from "@/core";
// closeMIn:最小值的符号,closeMax:最大值的符号 import { Single, Label, Bubbles } from "@/base";
/** import { IconCombo } from "@/case";
* Created by roy on 15/9/17. import { NumberIntervalSingleEidtor } from "./singleeditor/single.editor";
*
*/ @shortcut()
BI.NumberInterval = BI.inherit(BI.Single, { export class NumberInterval extends Single {
constants: { static xtype = "bi.number_interval"
constants = {
typeError: "typeBubble", typeError: "typeBubble",
numberError: "numberBubble", numberError: "numberBubble",
signalError: "signalBubble", signalError: "signalBubble",
@ -18,160 +20,174 @@ BI.NumberInterval = BI.inherit(BI.Single, {
less: 0, less: 0,
less_equal: 1, less_equal: 1,
numTip: "", numTip: "",
adjustYOffset: 2 adjustYOffset: 2,
}, };
_defaultConfig: function () {
var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments); static EVENT_CHANGE = "EVENT_CHANGE"
return BI.extend(conf, { static EVENT_CONFIRM = "EVENT_CONFIRM"
extraCls: "bi-number-interval" + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), static EVENT_VALID = "EVENT_VALID"
static EVENT_ERROR = "EVENT_ERROR"
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
extraCls: `bi-number-interval${(isIE() && getIEVersion() < 10) ? " hack" : ""}`,
height: 24, height: 24,
validation: "valid", validation: "valid",
closeMin: true, closeMin: true,
allowBlank: true, allowBlank: true,
watermark: BI.i18nText("BI-Basic_Unrestricted") watermark: i18nText("BI-Basic_Unrestricted"),
}); });
}, }
_init: function () {
var self = this, c = this.constants, o = this.options; _init() {
BI.NumberInterval.superclass._init.apply(this, arguments); const self = this,
this.smallEditor = BI.createWidget({ c = this.constants,
o = this.options;
super._init(...arguments);
this.smallEditor = createWidget({
type: "bi.number_interval_single_editor", type: "bi.number_interval_single_editor",
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark, watermark: o.watermark,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
value: o.min, value: o.min,
level: "warning", level: "warning",
tipType: "success", tipType: "success",
title: function () { title () {
return self.smallEditor && self.smallEditor.getValue(); return self.smallEditor && self.smallEditor.getValue();
}, },
quitChecker: function () { quitChecker () {
return false; return false;
}, },
validationChecker: function (v) { validationChecker (v) {
if (!BI.isNumeric(v)) { if (!isNumeric(v)) {
self.smallEditorBubbleType = c.typeError; self.smallEditorBubbleType = c.typeError;
return false; return false;
} }
return true; return true;
}, },
cls: "number-interval-small-editor bi-focus-shadow " + (o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius") cls: `number-interval-small-editor bi-focus-shadow ${o.simple ? "bi-border-bottom" : "bi-border bi-border-corner-left-radius"}`,
}); });
this.smallTip = BI.createWidget({ this.smallTip = createWidget({
type: "bi.label", type: Label.xtype,
text: o.numTip, text: o.numTip,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
invisible: true invisible: true,
}); });
BI.createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this.smallEditor, element: this.smallEditor,
items: [{ items: [{
el: this.smallTip, el: this.smallTip,
top: 0, top: 0,
right: 5 right: 5,
}] }],
}); });
this.bigEditor = BI.createWidget({ this.bigEditor = createWidget({
type: "bi.number_interval_single_editor", type: "bi.number_interval_single_editor",
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
watermark: o.watermark, watermark: o.watermark,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
value: o.max, value: o.max,
title: function () { title () {
return self.bigEditor && self.bigEditor.getValue(); return self.bigEditor && self.bigEditor.getValue();
}, },
quitChecker: function () { quitChecker () {
return false; return false;
}, },
validationChecker: function (v) { validationChecker (v) {
if (!BI.isNumeric(v)) { if (!isNumeric(v)) {
self.bigEditorBubbleType = c.typeError; self.bigEditorBubbleType = c.typeError;
return false; return false;
} }
return true; return true;
}, },
cls: "number-interval-big-editor bi-focus-shadow" + (o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius") cls: `number-interval-big-editor bi-focus-shadow${o.simple ? " bi-border-bottom" : " bi-border bi-border-corner-right-radius"}`,
}); });
this.bigTip = BI.createWidget({ this.bigTip = createWidget({
type: "bi.label", type: Label.xtype,
text: o.numTip, text: o.numTip,
height: BI.toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
invisible: true invisible: true,
}); });
BI.createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this.bigEditor, element: this.bigEditor,
items: [{ items: [{
el: this.bigTip, el: this.bigTip,
top: 0, top: 0,
right: 5 right: 5,
}] }],
}); });
this.smallCombo = BI.createWidget({ this.smallCombo = createWidget({
type: "bi.icon_combo", type: IconCombo.xtype,
cls: "number-interval-small-combo" + (o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"), cls: `number-interval-small-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-right bi-border-corner-right-radius"}`,
height: BI.toPix(o.height, o.simple ? 0 : 2), height: toPix(o.height, o.simple ? 0 : 2),
width: BI.toPix(c.width, c.border), width: toPix(c.width, c.border),
items: [{ items: [{
text: "(" + BI.i18nText("BI-Less_Than") + ")", text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font", iconCls: "less-font",
value: 0 value: 0,
}, { }, {
text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1, value: 1,
iconCls: "less-equal-font" iconCls: "less-equal-font",
}] }],
}); });
if (o.closeMin === true) { if (o.closeMin === true) {
this.smallCombo.setValue(1); this.smallCombo.setValue(1);
} else { } else {
this.smallCombo.setValue(0); this.smallCombo.setValue(0);
} }
this.bigCombo = BI.createWidget({ this.bigCombo = createWidget({
type: "bi.icon_combo", type: IconCombo.xtype,
cls: "number-interval-big-combo" + (o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"), cls: `number-interval-big-combo${o.simple ? "" : " bi-border-top bi-border-bottom bi-border-left bi-border-corner-left-radius"}`,
height: BI.toPix(o.height, o.simple ? 0 : 2), height: toPix(o.height, o.simple ? 0 : 2),
width: BI.toPix(c.width, c.border), width: toPix(c.width, c.border),
items: [{ items: [{
text: "(" + BI.i18nText("BI-Less_Than") + ")", text: `(${i18nText("BI-Less_Than")})`,
iconCls: "less-font", iconCls: "less-font",
value: 0 value: 0,
}, { }, {
text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", text: `(${i18nText("BI-Less_And_Equal")})`,
value: 1, value: 1,
iconCls: "less-equal-font" iconCls: "less-equal-font",
}] }],
}); });
if (o.closeMax === true) { if (o.closeMax === true) {
this.bigCombo.setValue(1); this.bigCombo.setValue(1);
} else { } else {
this.bigCombo.setValue(0); this.bigCombo.setValue(0);
} }
this.label = BI.createWidget({ this.label = createWidget({
type: "bi.label", type: Label.xtype,
text: BI.i18nText("BI-Basic_Value"), text: i18nText("BI-Basic_Value"),
textHeight: o.height, textHeight: o.height,
// width: BI.toPix(o.width, o.simple ? 0 : c.border * 2), // width: toPix(o.width, o.simple ? 0 : c.border * 2),
hgap: 5, hgap: 5,
height: o.height, height: o.height,
level: "warning", level: "warning",
tipType: "warning" tipType: "warning",
}); });
this.left = BI.createWidget({ this.left = createWidget({
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: ["fill", ""], columnSize: ["fill", ""],
items: [{ items: [{
el: self.smallEditor el: self.smallEditor,
}, { }, {
el: self.smallCombo, el: self.smallCombo,
}] }],
}); });
this.right = BI.createWidget({ this.right = createWidget({
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: ["", "fill"], columnSize: ["", "fill"],
items: [{ items: [{
@ -180,38 +196,38 @@ BI.NumberInterval = BI.inherit(BI.Single, {
el: self.bigEditor, el: self.bigEditor,
// BI-23883 间距考虑边框 // BI-23883 间距考虑边框
// lgap: 1 // lgap: 1
}] }],
}); });
BI.createWidget({ createWidget({
element: self, element: self,
type: "bi.horizontal_fill", type: "bi.horizontal_fill",
columnSize: ["fill", "", "fill"], columnSize: ["fill", "", "fill"],
items: [{ items: [{
el: self.left el: self.left,
}, { }, {
el: self.label el: self.label,
}, { }, {
el: self.right el: self.right,
}] }],
}); });
// BI.createWidget({ // createWidget({
// element: self, // element: self,
// type: "bi.horizontal_auto", // type: HorizontalAutoLayout.xtype,
// items: [ // items: [
// self.label // self.label
// ] // ]
// }); // });
// BI.createWidget({ // createWidget({
// element: self, // element: self,
// type: "bi.center", // type: CenterLayout.xtype,
// hgap: 15, // hgap: 15,
// height: o.height, // height: o.height,
// items: [ // items: [
// { // {
// type: "bi.absolute", // type: AbsoluteLayout.xtype,
// items: [{ // items: [{
// el: self.left, // el: self.left,
// left: -15, // left: -15,
@ -220,7 +236,7 @@ BI.NumberInterval = BI.inherit(BI.Single, {
// bottom: 0 // bottom: 0
// }] // }]
// }, { // }, {
// type: "bi.absolute", // type: AbsoluteLayout.xtype,
// items: [{ // items: [{
// el: self.right, // el: self.right,
// left: 0, // left: 0,
@ -246,264 +262,274 @@ BI.NumberInterval = BI.inherit(BI.Single, {
self._setEditorValueChangedEvent(self.smallEditor); self._setEditorValueChangedEvent(self.smallEditor);
self._checkValidation(); self._checkValidation();
}, }
_checkValidation: function () { _checkValidation() {
var self = this, c = this.constants, o = this.options; const self = this,
c = this.constants,
o = this.options;
self._setTitle(""); self._setTitle("");
BI.Bubbles.hide(c.typeError); Bubbles.hide(c.typeError);
BI.Bubbles.hide(c.numberError); Bubbles.hide(c.numberError);
BI.Bubbles.hide(c.signalError); Bubbles.hide(c.signalError);
if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) { if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.typeError; return c.typeError;
} }
if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { if (isEmptyString(self.smallEditor.getValue()) || isEmptyString(self.bigEditor.getValue())) {
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "valid"; o.validation = "valid";
return ""; return "";
} }
var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()), const smallValue = parseFloat(self.smallEditor.getValue()),
bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue(); bigValue = parseFloat(self.bigEditor.getValue()),
bigComboValue = self.bigCombo.getValue(),
smallComboValue = self.smallCombo.getValue();
if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) { if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) {
if (smallValue > bigValue) { if (smallValue > bigValue) {
self.element.addClass("number-error"); self.element.addClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.numberError; return c.numberError;
} }
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "valid"; o.validation = "valid";
return ""; return "";
} }
if (smallValue > bigValue) { if (smallValue > bigValue) {
self.element.addClass("number-error"); self.element.addClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.numberError; return c.numberError;
} else if (smallValue === bigValue) { } else if (smallValue === bigValue) {
self.element.addClass("number-error"); self.element.addClass("number-error");
o.validation = "invalid"; o.validation = "invalid";
return c.signalError; return c.signalError;
} }
self.element.removeClass("number-error"); self.element.removeClass("number-error");
o.validation = "valid"; o.validation = "valid";
return ""; return "";
}
_setTitle(v) {
},
_setTitle: function (v) {
this.label.setTitle(v); this.label.setTitle(v);
}, }
_setFocusEvent: function (w) { _setFocusEvent(w) {
var self = this, c = this.constants; const self = this,
w.on(BI.NumberIntervalSingleEidtor.EVENT_FOCUS, function () { c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_FOCUS, () => {
self._setTitle(""); self._setTitle("");
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.numberError: case c.numberError:
BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.signalError: case c.signalError:
BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
break; break;
default : default:
return; return;
} }
}); });
}, }
_setBlurEvent: function (w) {
var c = this.constants, self = this; _setBlurEvent(w) {
w.on(BI.NumberIntervalSingleEidtor.EVENT_BLUR, function () { const c = this.constants,
BI.Bubbles.hide(c.typeError); self = this;
BI.Bubbles.hide(c.numberError); w.on(NumberIntervalSingleEidtor.EVENT_BLUR, () => {
BI.Bubbles.hide(c.signalError); Bubbles.hide(c.typeError);
Bubbles.hide(c.numberError);
Bubbles.hide(c.signalError);
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
break; break;
case c.numberError: case c.numberError:
self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
break; break;
case c.signalError: case c.signalError:
self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
break; break;
default: default:
self._setTitle(""); self._setTitle("");
} }
}); });
}, }
_setErrorEvent: function (w) { _setErrorEvent(w) {
var c = this.constants, self = this; const c = this.constants,
w.on(BI.NumberIntervalSingleEidtor.EVENT_ERROR, function () { self = this;
w.on(NumberIntervalSingleEidtor.EVENT_ERROR, () => {
self._checkValidation(); self._checkValidation();
BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
self.fireEvent(BI.NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
}); });
}, }
_setValidEvent: function (w) { _setValidEvent(w) {
var self = this, c = this.constants; const self = this,
w.on(BI.NumberIntervalSingleEidtor.EVENT_VALID, function () { c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_VALID, () => {
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.numberError: case c.numberError:
BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
self.fireEvent(BI.NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
case c.signalError: case c.signalError:
BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
self.fireEvent(BI.NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
default: default:
self.fireEvent(BI.NumberInterval.EVENT_VALID); self.fireEvent(NumberInterval.EVENT_VALID);
} }
}); });
}, }
_setEditorValueChangedEvent: function (w) { _setEditorValueChangedEvent(w) {
var self = this, c = this.constants; const self = this,
w.on(BI.NumberIntervalSingleEidtor.EVENT_CHANGE, function () { c = this.constants;
w.on(NumberIntervalSingleEidtor.EVENT_CHANGE, () => {
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { Bubbles.show(c.typeError, i18nText("BI-Numerical_Interval_Input_Data"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.numberError: case c.numberError:
BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { Bubbles.show(c.numberError, i18nText("BI-Numerical_Interval_Number_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
break; break;
case c.signalError: case c.signalError:
BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { Bubbles.show(c.signalError, i18nText("BI-Numerical_Interval_Signal_Value"), self, {
offsetStyle: "left", offsetStyle: "left",
adjustYOffset: c.adjustYOffset adjustYOffset: c.adjustYOffset,
}); });
break; break;
default : default:
break; break;
} }
self.fireEvent(BI.NumberInterval.EVENT_CHANGE); self.fireEvent(NumberInterval.EVENT_CHANGE);
}); });
w.on(BI.NumberIntervalSingleEidtor.EVENT_CONFIRM, function () { w.on(NumberIntervalSingleEidtor.EVENT_CONFIRM, () => {
self.fireEvent(BI.NumberInterval.EVENT_CONFIRM); self.fireEvent(NumberInterval.EVENT_CONFIRM);
}); });
}, }
_setComboValueChangedEvent: function (w) { _setComboValueChangedEvent(w) {
var self = this, c = this.constants; const self = this,
w.on(BI.IconCombo.EVENT_CHANGE, function () { c = this.constants;
w.on(IconCombo.EVENT_CHANGE, () => {
switch (self._checkValidation()) { switch (self._checkValidation()) {
case c.typeError: case c.typeError:
self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); self._setTitle(i18nText("BI-Numerical_Interval_Input_Data"));
self.fireEvent(BI.NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
case c.numberError: case c.numberError:
self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Number_Value"));
self.fireEvent(BI.NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
case c.signalError: case c.signalError:
self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); self._setTitle(i18nText("BI-Numerical_Interval_Signal_Value"));
self.fireEvent(BI.NumberInterval.EVENT_ERROR); self.fireEvent(NumberInterval.EVENT_ERROR);
break; break;
default : default:
self.fireEvent(BI.NumberInterval.EVENT_CHANGE); self.fireEvent(NumberInterval.EVENT_CHANGE);
self.fireEvent(BI.NumberInterval.EVENT_CONFIRM); self.fireEvent(NumberInterval.EVENT_CONFIRM);
self.fireEvent(BI.NumberInterval.EVENT_VALID); self.fireEvent(NumberInterval.EVENT_VALID);
} }
}); });
}, }
isStateValid: function () { isStateValid() {
return this.options.validation === "valid"; return this.options.validation === "valid";
}, }
setMinEnable: function (b) { setMinEnable(b) {
this.smallEditor.setEnable(b); this.smallEditor.setEnable(b);
}, }
setCloseMinEnable: function (b) { setCloseMinEnable(b) {
this.smallCombo.setEnable(b); this.smallCombo.setEnable(b);
}, }
setMaxEnable: function (b) { setMaxEnable(b) {
this.bigEditor.setEnable(b); this.bigEditor.setEnable(b);
}, }
setCloseMaxEnable: function (b) { setCloseMaxEnable(b) {
this.bigCombo.setEnable(b); this.bigCombo.setEnable(b);
}, }
showNumTip: function () { showNumTip() {
this.smallTip.setVisible(true); this.smallTip.setVisible(true);
this.bigTip.setVisible(true); this.bigTip.setVisible(true);
}, }
hideNumTip: function () { hideNumTip() {
this.smallTip.setVisible(false); this.smallTip.setVisible(false);
this.bigTip.setVisible(false); this.bigTip.setVisible(false);
}, }
setNumTip: function (numTip) { setNumTip(numTip) {
this.smallTip.setText(numTip); this.smallTip.setText(numTip);
this.bigTip.setText(numTip); this.bigTip.setText(numTip);
}, }
getNumTip: function () { getNumTip() {
return this.smallTip.getText(); return this.smallTip.getText();
}, }
setValue: function (data) { setValue(data) {
data = data || {}; data = data || {};
var self = this, combo_value; const self = this;
if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) { let combo_value;
if (isNumeric(data.min) || isEmptyString(data.min)) {
self.smallEditor.setValue(data.min); self.smallEditor.setValue(data.min);
} }
if (!BI.isNotNull(data.min)) { if (!isNotNull(data.min)) {
self.smallEditor.setValue(""); self.smallEditor.setValue("");
} }
if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) { if (isNumeric(data.max) || isEmptyString(data.max)) {
self.bigEditor.setValue(data.max); self.bigEditor.setValue(data.max);
} }
if (!BI.isNotNull(data.max)) { if (!isNotNull(data.max)) {
self.bigEditor.setValue(""); self.bigEditor.setValue("");
} }
if (!BI.isNull(data.closeMin)) { if (!isNull(data.closeMin)) {
if (data.closeMin === true) { if (data.closeMin === true) {
combo_value = 1; combo_value = 1;
} else { } else {
@ -512,7 +538,7 @@ BI.NumberInterval = BI.inherit(BI.Single, {
self.smallCombo.setValue(combo_value); self.smallCombo.setValue(combo_value);
} }
if (!BI.isNull(data.closeMax)) { if (!isNull(data.closeMax)) {
if (data.closeMax === true) { if (data.closeMax === true) {
combo_value = 1; combo_value = 1;
} else { } else {
@ -522,11 +548,13 @@ BI.NumberInterval = BI.inherit(BI.Single, {
} }
this._checkValidation(); this._checkValidation();
}, }
getValue: function () { getValue() {
var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue(); const self = this,
value = {},
minComboValue = self.smallCombo.getValue(),
maxComboValue = self.bigCombo.getValue();
value.min = self.smallEditor.getValue(); value.min = self.smallEditor.getValue();
value.max = self.bigEditor.getValue(); value.max = self.bigEditor.getValue();
if (minComboValue[0] === 0) { if (minComboValue[0] === 0) {
@ -540,26 +568,22 @@ BI.NumberInterval = BI.inherit(BI.Single, {
} else { } else {
value.closeMax = true; value.closeMax = true;
} }
return value; return value;
}, }
focusMinEditor: function () { focusMinEditor() {
this.smallEditor.focus(); this.smallEditor.focus();
}, }
focusMaxEditor: function () { focusMaxEditor() {
this.bigEditor.focus(); this.bigEditor.focus();
}, }
destroyed: function () { destroyed() {
var c = this.constants; const c = this.constants;
BI.Bubbles.remove(c.typeError); Bubbles.remove(c.typeError);
BI.Bubbles.remove(c.numberError); Bubbles.remove(c.numberError);
BI.Bubbles.remove(c.signalError); Bubbles.remove(c.signalError);
} }
}); }
BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE";
BI.NumberInterval.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.NumberInterval.EVENT_VALID = "EVENT_VALID";
BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR";
BI.shortcut("bi.number_interval", BI.NumberInterval);

120
src/widget/numberinterval/singleeditor/single.editor.js

@ -1,19 +1,34 @@
BI.NumberIntervalSingleEidtor = BI.inherit(BI.Single, { import { shortcut, VerticalLayout } from "@/core";
props: { import { Single, Editor } from "@/base";
@shortcut()
export class NumberIntervalSingleEidtor extends Single {
static xtype = "bi.number_interval_single_editor"
static EVENT_FOCUS = "EVENT_FOCUS"
static EVENT_BLUR = "EVENT_BLUR"
static EVENT_ERROR = "EVENT_ERROR"
static EVENT_VALID = "EVENT_VALID"
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM"
static EVENT_CONFIRM = "EVENT_CONFIRM"
props = {
baseCls: "bi-number-interval-single-editor", baseCls: "bi-number-interval-single-editor",
tipType: "success", tipType: "success",
title: "" title: "",
}, };
render: function () { render() {
var self = this, o = this.options; const self = this,
o = this.options;
return { return {
type: "bi.vertical", type: VerticalLayout.xtype,
items: [{ items: [{
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
ref: function (_ref) { ref (_ref) {
self.editor = _ref; self.editor = _ref;
}, },
height: o.height, height: o.height,
@ -23,67 +38,58 @@ BI.NumberIntervalSingleEidtor = BI.inherit(BI.Single, {
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
listeners: [{ listeners: [{
eventName: BI.Editor.EVENT_ERROR, eventName: Editor.EVENT_ERROR,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_ERROR, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_ERROR, arguments);
} },
}, { }, {
eventName: BI.Editor.EVENT_FOCUS, eventName: Editor.EVENT_FOCUS,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_FOCUS, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_FOCUS, arguments);
} },
}, { }, {
eventName: BI.Editor.EVENT_BLUR, eventName: Editor.EVENT_BLUR,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_BLUR, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_BLUR, arguments);
} },
}, { }, {
eventName: BI.Editor.EVENT_VALID, eventName: Editor.EVENT_VALID,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_VALID, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_VALID, arguments);
} },
}, { }, {
eventName: BI.Editor.EVENT_CHANGE, eventName: Editor.EVENT_CHANGE,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_CHANGE, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE, arguments);
} },
}, { }, {
eventName: BI.Editor.EVENT_CONFIRM, eventName: Editor.EVENT_CONFIRM,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_CONFIRM, arguments);
} },
}, { }, {
eventName: BI.Editor.EVENT_CHANGE_CONFIRM, eventName: Editor.EVENT_CHANGE_CONFIRM,
action: function () { action () {
self.fireEvent(BI.NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments); self.fireEvent(NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM, arguments);
} },
}] }],
}] }],
}; };
}, }
isValid: function () { isValid() {
return this.editor.isValid(); return this.editor.isValid();
}, }
getValue: function () { getValue() {
return this.editor.getValue(); return this.editor.getValue();
}, }
setValue: function (v) { setValue(v) {
return this.editor.setValue(v); return this.editor.setValue(v);
}, }
focus: function () { focus() {
this.editor.focus(); this.editor.focus();
} }
}); }
BI.NumberIntervalSingleEidtor.EVENT_FOCUS = "EVENT_FOCUS";
BI.NumberIntervalSingleEidtor.EVENT_BLUR = "EVENT_BLUR";
BI.NumberIntervalSingleEidtor.EVENT_ERROR = "EVENT_ERROR";
BI.NumberIntervalSingleEidtor.EVENT_VALID = "EVENT_VALID";
BI.NumberIntervalSingleEidtor.EVENT_CHANGE = "EVENT_CHANGE";
BI.NumberIntervalSingleEidtor.EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
BI.NumberIntervalSingleEidtor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.number_interval_single_editor", BI.NumberIntervalSingleEidtor);

Loading…
Cancel
Save