Browse Source

BI-76966 hex允许输入为空

master
windy 4 years ago
parent
commit
6065834eb7
  1. 1
      changelog.md
  2. 3
      i18n/i18n.cn.js
  3. 21
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.js
  4. 20
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2020-11) 2.0(2020-11)
- 修复了颜色选择器hex框不能输入为空的问题
- 增加纯文本组件bi.pure_text - 增加纯文本组件bi.pure_text
- store支持webworker,引入多线程机制 - store支持webworker,引入多线程机制
- 修复了Popover小屏幕上看不完整的问题 - 修复了Popover小屏幕上看不完整的问题

3
i18n/i18n.cn.js

@ -9,7 +9,7 @@ BI.i18n = {
"BI-Basic_Altogether": "共", "BI-Basic_Altogether": "共",
"BI-Basic_Sunday": "星期日", "BI-Basic_Sunday": "星期日",
"BI-Widget_Background_Colour": "组件背景", "BI-Widget_Background_Colour": "组件背景",
"BI-Color_Picker_Error_Text": "请输入0~255的正整数", "BI-Color_Picker_Error_Text": "请输入0-255的正整数",
"BI-Multi_Date_Month": "月", "BI-Multi_Date_Month": "月",
"BI-No_Selected_Item": "没有可选项", "BI-No_Selected_Item": "没有可选项",
"BI-Multi_Date_Year_Begin": "年初", "BI-Multi_Date_Year_Begin": "年初",
@ -91,6 +91,7 @@ BI.i18n = {
"BI-Summary_Values": "汇总", "BI-Summary_Values": "汇总",
"BI-Basic_Clear": "清除", "BI-Basic_Clear": "清除",
"BI-Upload_File_Size_Error": "文件大小不支持", "BI-Upload_File_Size_Error": "文件大小不支持",
"BI-Upload_File_Count_Error": "超出上传数量上限,请重新上传",
"BI-Up_Page": "向上翻页", "BI-Up_Page": "向上翻页",
"BI-Basic_Simple_Sunday": "日", "BI-Basic_Simple_Sunday": "日",
"BI-Multi_Date_Relative_Current_Time": "相对当前时间", "BI-Multi_Date_Relative_Current_Time": "相对当前时间",

21
src/case/colorchooser/colorpicker/editor.colorpicker.hex.js

@ -85,16 +85,20 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
}, },
cls: "color-picker-editor-input", cls: "color-picker-editor-input",
validationChecker: this._hexChecker, validationChecker: this._hexChecker,
allowBlank: true,
errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"), errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"),
width: c.HEX_WIDTH, width: c.HEX_WIDTH,
height: 20, height: 20,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
self.setValue("#" + this.getValue()); self._checkHexEditor();
if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) {
self.colorShow.element.css("background-color", self.getValue()); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
}
}] }]
}, { }, {
el: BI.extend(Ws[0], { el: BI.extend(Ws[0], {
@ -238,6 +242,21 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
return BI.isEmptyString(this.storeValue.r) && BI.isEmptyString(this.storeValue.g) && BI.isEmptyString(this.storeValue.b); return BI.isEmptyString(this.storeValue.r) && BI.isEmptyString(this.storeValue.g) && BI.isEmptyString(this.storeValue.b);
}, },
_checkHexEditor: function () {
if (BI.isEmptyString(this.hexEditor.getValue())) {
this.hexEditor.setValue("000000");
}
var json = BI.DOM.rgb2json(BI.DOM.hex2rgb("#" + this.hexEditor.getValue()));
this.storeValue = {
r: json.r || 0,
g: json.g || 0,
b: json.b || 0,
};
this.R.setValue(this.storeValue.r);
this.G.setValue(this.storeValue.g);
this.B.setValue(this.storeValue.b);
},
_showPreColor: function (color) { _showPreColor: function (color) {
if (color === "") { if (color === "") {
this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-normal-background"); this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-normal-background");

20
src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js

@ -82,16 +82,19 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
}, },
cls: "color-picker-editor-input", cls: "color-picker-editor-input",
validationChecker: this._hexChecker, validationChecker: this._hexChecker,
allowBlank: true,
errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"), errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"),
width: c.HEX_WIDTH, width: c.HEX_WIDTH,
height: 20, height: 20,
listeners: [{ listeners: [{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: function () { action: function () {
self.setValue("#" + this.getValue()); self._checkHexEditor();
if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) {
self.colorShow.element.css("background-color", self.getValue()); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
} }
}
}] }]
}, { }, {
el: BI.extend(Ws[0], { el: BI.extend(Ws[0], {
@ -157,6 +160,21 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
this.hexEditor.setValue(this.getValue().slice(this.constants.HEX_PREFIX_POSITION)); this.hexEditor.setValue(this.getValue().slice(this.constants.HEX_PREFIX_POSITION));
}, },
_checkHexEditor: function () {
if (BI.isEmptyString(this.hexEditor.getValue())) {
this.hexEditor.setValue("000000");
}
var json = BI.DOM.rgb2json(BI.DOM.hex2rgb("#" + this.hexEditor.getValue()));
this.storeValue = {
r: json.r || 0,
g: json.g || 0,
b: json.b || 0,
};
this.R.setValue(this.storeValue.r);
this.G.setValue(this.storeValue.g);
this.B.setValue(this.storeValue.b);
},
setValue: function (color) { setValue: function (color) {
this.colorShow.element.css({"background-color": color}); this.colorShow.element.css({"background-color": color});
var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color)); var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color));

Loading…
Cancel
Save