Browse Source

去掉createWidgets

es6
windy 4 years ago
parent
commit
35b1f89e18
  1. 59
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.js
  2. 59
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js

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

@ -31,29 +31,28 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
var checker = function (v) { var checker = function (v) {
return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
}; };
var Ws = BI.createWidgets([{}, {}, {}], { var Ws = BI.map(BI.range(0, 3), function () {
type: "bi.small_text_editor", return {
cls: "color-picker-editor-input", type: "bi.small_text_editor",
validationChecker: checker, cls: "color-picker-editor-input",
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), validationChecker: checker,
allowBlank: true, errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
value: 255, allowBlank: true,
width: c.RGB_WIDTH, value: 255,
height: 20, width: c.RGB_WIDTH,
listeners: [{ height: 20,
eventName: BI.TextEditor.EVENT_CHANGE, listeners: [{
action: function () { eventName: BI.TextEditor.EVENT_CHANGE,
self._checkEditors(); action: function () {
if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) { self._checkEditors();
self.colorShow.element.css("background-color", self.getValue()); if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) {
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
}
} }
} }]
}] };
}); });
this.R = Ws[0];
this.G = Ws[1];
this.B = Ws[2];
return { return {
type: "bi.absolute", type: "bi.absolute",
@ -98,13 +97,25 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, {
} }
}] }]
}, { }, {
el: this.R, el: BI.extend(Ws[0], {
ref: function (_ref) {
self.R = _ref
}
}),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, { }, {
el: this.G, el: BI.extend(Ws[1], {
ref: function (_ref) {
self.G = _ref
}
}),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, { }, {
el: this.B, el: BI.extend(Ws[2], {
ref: function (_ref) {
self.B = _ref
}
}),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, { }, {
el: { el: {

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

@ -29,29 +29,28 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
var checker = function (v) { var checker = function (v) {
return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
}; };
var Ws = BI.createWidgets([{}, {}, {}], { var Ws = BI.map(BI.range(0, 3), function () {
type: "bi.small_text_editor", return {
cls: "color-picker-editor-input", type: "bi.small_text_editor",
validationChecker: checker, cls: "color-picker-editor-input",
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), validationChecker: checker,
allowBlank: true, errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
value: 255, allowBlank: true,
width: c.RGB_WIDTH, value: 255,
height: 20, width: c.RGB_WIDTH,
listeners: [{ height: 20,
eventName: BI.TextEditor.EVENT_CHANGE, listeners: [{
action: function () { eventName: BI.TextEditor.EVENT_CHANGE,
self._checkEditors(); action: function () {
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { self._checkEditors();
self.colorShow.element.css("background-color", self.getValue()); if (self.R.isValid() && self.G.isValid() && self.B.isValid()) {
self.fireEvent(BI.SimpleColorPickerEditor.EVENT_CHANGE); self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.SimpleColorPickerEditor.EVENT_CHANGE);
}
} }
} }]
}] }
}); });
this.R = Ws[0];
this.G = Ws[1];
this.B = Ws[2];
return { return {
type: "bi.vertical", type: "bi.vertical",
@ -95,13 +94,25 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, {
} }
}] }]
}, { }, {
el: this.R, el: BI.extend(Ws[0], {
ref: function (_ref) {
self.R = _ref
}
}),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, { }, {
el: this.G, el: BI.extend(Ws[1], {
ref: function (_ref) {
self.G = _ref
}
}),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}, { }, {
el: this.B, el: BI.extend(Ws[2], {
ref: function (_ref) {
self.B = _ref
}
}),
width: c.RGB_WIDTH width: c.RGB_WIDTH
}] }]
}, { }, {

Loading…
Cancel
Save