guy 8 years ago
parent
commit
ef97154010
  1. 53
      bi/case.js
  2. 8
      bi/core.js
  3. 53
      docs/case.js
  4. 8
      docs/core.js
  5. 5
      src/case/colorchooser/colorchooser.trigger.js
  6. 48
      src/case/colorchooser/colorpicker/editor.colorpicker.js
  7. 8
      src/core/func/function.js

53
bi/case.js

@ -3940,7 +3940,7 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-card", baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger",
height: 30 height: 30
}) })
}, },
@ -3948,7 +3948,8 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
_init: function () { _init: function () {
BI.ColorChooserTrigger.superclass._init.apply(this, arguments); BI.ColorChooserTrigger.superclass._init.apply(this, arguments);
this.colorContainer = BI.createWidget({ this.colorContainer = BI.createWidget({
type: "bi.layout" type: "bi.layout",
cls: "bi-card"
}); });
var down = BI.createWidget({ var down = BI.createWidget({
@ -4274,7 +4275,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
value: 255, value: 255,
width: 35, width: 32,
height: 20 height: 20
}); });
BI.each(Ws, function (i, w) { BI.each(Ws, function (i, w) {
@ -4290,7 +4291,8 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
this.B = Ws[2]; this.B = Ws[2];
this.none = BI.createWidget({ this.none = BI.createWidget({
type: "bi.checkbox" type: "bi.checkbox",
title: BI.i18nText("BI-Basic_Auto")
}); });
this.none.on(BI.Checkbox.EVENT_CHANGE, function () { this.none.on(BI.Checkbox.EVENT_CHANGE, function () {
if (this.isSelected()) { if (this.isSelected()) {
@ -4305,6 +4307,23 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} }
}); });
this.transparent = BI.createWidget({
type: "bi.checkbox",
title: BI.i18nText("BI-Transparent_Color")
});
this.transparent.on(BI.Checkbox.EVENT_CHANGE, function () {
if (this.isSelected()) {
self.lastColor = self.getValue();
self.setValue("transparent");
} else {
self.setValue(self.lastColor || "#000000");
}
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) {
self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
}
});
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
element: this, element: this,
@ -4314,21 +4333,21 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}, { }, {
el: RGB[0], el: RGB[0],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.R, el: this.R,
width: 32 width: 32
}, { }, {
el: RGB[1], el: RGB[1],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.G, el: this.G,
width: 32 width: 32
}, { }, {
el: RGB[2], el: RGB[2],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.B, el: this.B,
width: 32 width: 32
@ -4337,18 +4356,33 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.none] items: [this.none]
}, },
width: 20 width: 18
}, {
el: {
type: "bi.center_adapt",
items: [this.transparent]
},
width: 18
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
if (color === "transparent") {
this.transparent.setSelected(true);
this.none.setSelected(false);
this.R.setValue("");
this.G.setValue("");
this.B.setValue("");
return;
}
if (!color) { if (!color) {
color = ""; color = "";
this.none.setSelected(true); this.none.setSelected(true);
} else { } else {
this.none.setSelected(false); this.none.setSelected(false);
} }
this.transparent.setSelected(false);
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));
this.R.setValue(BI.isNull(json.r) ? "" : json.r); this.R.setValue(BI.isNull(json.r) ? "" : json.r);
@ -4357,6 +4391,9 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
if (this.transparent.isSelected()) {
return "transparent";
}
return BI.DOM.rgb2hex(BI.DOM.json2rgb({ return BI.DOM.rgb2hex(BI.DOM.json2rgb({
r: this.R.getValue(), r: this.R.getValue(),
g: this.G.getValue(), g: this.G.getValue(),

8
bi/core.js

@ -16840,7 +16840,7 @@ BI.extend(BI.DOM, {
}, },
isDarkColor: function (hex) { isDarkColor: function (hex) {
if (!hex) { if (!hex || !this.isHexColor(hex)) {
return false; return false;
} }
var rgb = this.rgb2json(this.hex2rgb(hex)); var rgb = this.rgb2json(this.hex2rgb(hex));
@ -16880,6 +16880,9 @@ BI.extend(BI.DOM, {
if (!rgbColour) { if (!rgbColour) {
return {}; return {};
} }
if (!this.isRGBColor(rgbColour)) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g); var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return { return {
r: BI.parseInt(rgbValues[0]), r: BI.parseInt(rgbValues[0]),
@ -16925,6 +16928,9 @@ BI.extend(BI.DOM, {
if (!color) { if (!color) {
return ""; return "";
} }
if (!this.isHexColor(color)) {
return color;
}
var tempValue = "rgb(", colorArray; var tempValue = "rgb(", colorArray;
if (color.length === 7) { if (color.length === 7) {

53
docs/case.js

@ -3940,7 +3940,7 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-card", baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger",
height: 30 height: 30
}) })
}, },
@ -3948,7 +3948,8 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
_init: function () { _init: function () {
BI.ColorChooserTrigger.superclass._init.apply(this, arguments); BI.ColorChooserTrigger.superclass._init.apply(this, arguments);
this.colorContainer = BI.createWidget({ this.colorContainer = BI.createWidget({
type: "bi.layout" type: "bi.layout",
cls: "bi-card"
}); });
var down = BI.createWidget({ var down = BI.createWidget({
@ -4274,7 +4275,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
value: 255, value: 255,
width: 35, width: 32,
height: 20 height: 20
}); });
BI.each(Ws, function (i, w) { BI.each(Ws, function (i, w) {
@ -4290,7 +4291,8 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
this.B = Ws[2]; this.B = Ws[2];
this.none = BI.createWidget({ this.none = BI.createWidget({
type: "bi.checkbox" type: "bi.checkbox",
title: BI.i18nText("BI-Basic_Auto")
}); });
this.none.on(BI.Checkbox.EVENT_CHANGE, function () { this.none.on(BI.Checkbox.EVENT_CHANGE, function () {
if (this.isSelected()) { if (this.isSelected()) {
@ -4305,6 +4307,23 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} }
}); });
this.transparent = BI.createWidget({
type: "bi.checkbox",
title: BI.i18nText("BI-Transparent_Color")
});
this.transparent.on(BI.Checkbox.EVENT_CHANGE, function () {
if (this.isSelected()) {
self.lastColor = self.getValue();
self.setValue("transparent");
} else {
self.setValue(self.lastColor || "#000000");
}
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) {
self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
}
});
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
element: this, element: this,
@ -4314,21 +4333,21 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}, { }, {
el: RGB[0], el: RGB[0],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.R, el: this.R,
width: 32 width: 32
}, { }, {
el: RGB[1], el: RGB[1],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.G, el: this.G,
width: 32 width: 32
}, { }, {
el: RGB[2], el: RGB[2],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.B, el: this.B,
width: 32 width: 32
@ -4337,18 +4356,33 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.none] items: [this.none]
}, },
width: 20 width: 18
}, {
el: {
type: "bi.center_adapt",
items: [this.transparent]
},
width: 18
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
if (color === "transparent") {
this.transparent.setSelected(true);
this.none.setSelected(false);
this.R.setValue("");
this.G.setValue("");
this.B.setValue("");
return;
}
if (!color) { if (!color) {
color = ""; color = "";
this.none.setSelected(true); this.none.setSelected(true);
} else { } else {
this.none.setSelected(false); this.none.setSelected(false);
} }
this.transparent.setSelected(false);
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));
this.R.setValue(BI.isNull(json.r) ? "" : json.r); this.R.setValue(BI.isNull(json.r) ? "" : json.r);
@ -4357,6 +4391,9 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
if (this.transparent.isSelected()) {
return "transparent";
}
return BI.DOM.rgb2hex(BI.DOM.json2rgb({ return BI.DOM.rgb2hex(BI.DOM.json2rgb({
r: this.R.getValue(), r: this.R.getValue(),
g: this.G.getValue(), g: this.G.getValue(),

8
docs/core.js

@ -22858,7 +22858,7 @@ BI.extend(BI.DOM, {
}, },
isDarkColor: function (hex) { isDarkColor: function (hex) {
if (!hex) { if (!hex || !this.isHexColor(hex)) {
return false; return false;
} }
var rgb = this.rgb2json(this.hex2rgb(hex)); var rgb = this.rgb2json(this.hex2rgb(hex));
@ -22898,6 +22898,9 @@ BI.extend(BI.DOM, {
if (!rgbColour) { if (!rgbColour) {
return {}; return {};
} }
if (!this.isRGBColor(rgbColour)) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g); var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return { return {
r: BI.parseInt(rgbValues[0]), r: BI.parseInt(rgbValues[0]),
@ -22943,6 +22946,9 @@ BI.extend(BI.DOM, {
if (!color) { if (!color) {
return ""; return "";
} }
if (!this.isHexColor(color)) {
return color;
}
var tempValue = "rgb(", colorArray; var tempValue = "rgb(", colorArray;
if (color.length === 7) { if (color.length === 7) {

5
src/case/colorchooser/colorchooser.trigger.js

@ -10,7 +10,7 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-card", baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger",
height: 30 height: 30
}) })
}, },
@ -18,7 +18,8 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
_init: function () { _init: function () {
BI.ColorChooserTrigger.superclass._init.apply(this, arguments); BI.ColorChooserTrigger.superclass._init.apply(this, arguments);
this.colorContainer = BI.createWidget({ this.colorContainer = BI.createWidget({
type: "bi.layout" type: "bi.layout",
cls: "bi-card"
}); });
var down = BI.createWidget({ var down = BI.createWidget({

48
src/case/colorchooser/colorpicker/editor.colorpicker.js

@ -40,7 +40,7 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
allowBlank: true, allowBlank: true,
value: 255, value: 255,
width: 35, width: 32,
height: 20 height: 20
}); });
BI.each(Ws, function (i, w) { BI.each(Ws, function (i, w) {
@ -56,7 +56,8 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
this.B = Ws[2]; this.B = Ws[2];
this.none = BI.createWidget({ this.none = BI.createWidget({
type: "bi.checkbox" type: "bi.checkbox",
title: BI.i18nText("BI-Basic_Auto")
}); });
this.none.on(BI.Checkbox.EVENT_CHANGE, function () { this.none.on(BI.Checkbox.EVENT_CHANGE, function () {
if (this.isSelected()) { if (this.isSelected()) {
@ -71,6 +72,23 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
} }
}); });
this.transparent = BI.createWidget({
type: "bi.checkbox",
title: BI.i18nText("BI-Transparent_Color")
});
this.transparent.on(BI.Checkbox.EVENT_CHANGE, function () {
if (this.isSelected()) {
self.lastColor = self.getValue();
self.setValue("transparent");
} else {
self.setValue(self.lastColor || "#000000");
}
if (self.R.isValid() && self.G.isValid() && self.B.isValid()) {
self.colorShow.element.css("background-color", self.getValue());
self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
}
});
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
element: this, element: this,
@ -80,21 +98,21 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}, { }, {
el: RGB[0], el: RGB[0],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.R, el: this.R,
width: 32 width: 32
}, { }, {
el: RGB[1], el: RGB[1],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.G, el: this.G,
width: 32 width: 32
}, { }, {
el: RGB[2], el: RGB[2],
lgap: 10, lgap: 10,
width: 20 width: 16
}, { }, {
el: this.B, el: this.B,
width: 32 width: 32
@ -103,18 +121,33 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
type: "bi.center_adapt", type: "bi.center_adapt",
items: [this.none] items: [this.none]
}, },
width: 20 width: 18
}, {
el: {
type: "bi.center_adapt",
items: [this.transparent]
},
width: 18
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
if (color === "transparent") {
this.transparent.setSelected(true);
this.none.setSelected(false);
this.R.setValue("");
this.G.setValue("");
this.B.setValue("");
return;
}
if (!color) { if (!color) {
color = ""; color = "";
this.none.setSelected(true); this.none.setSelected(true);
} else { } else {
this.none.setSelected(false); this.none.setSelected(false);
} }
this.transparent.setSelected(false);
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));
this.R.setValue(BI.isNull(json.r) ? "" : json.r); this.R.setValue(BI.isNull(json.r) ? "" : json.r);
@ -123,6 +156,9 @@ BI.ColorPickerEditor = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
if (this.transparent.isSelected()) {
return "transparent";
}
return BI.DOM.rgb2hex(BI.DOM.json2rgb({ return BI.DOM.rgb2hex(BI.DOM.json2rgb({
r: this.R.getValue(), r: this.R.getValue(),
g: this.G.getValue(), g: this.G.getValue(),

8
src/core/func/function.js

@ -122,7 +122,7 @@ BI.extend(BI.DOM, {
}, },
isDarkColor: function (hex) { isDarkColor: function (hex) {
if (!hex) { if (!hex || !this.isHexColor(hex)) {
return false; return false;
} }
var rgb = this.rgb2json(this.hex2rgb(hex)); var rgb = this.rgb2json(this.hex2rgb(hex));
@ -162,6 +162,9 @@ BI.extend(BI.DOM, {
if (!rgbColour) { if (!rgbColour) {
return {}; return {};
} }
if (!this.isRGBColor(rgbColour)) {
return {};
}
var rgbValues = rgbColour.match(/\d+(\.\d+)?/g); var rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return { return {
r: BI.parseInt(rgbValues[0]), r: BI.parseInt(rgbValues[0]),
@ -207,6 +210,9 @@ BI.extend(BI.DOM, {
if (!color) { if (!color) {
return ""; return "";
} }
if (!this.isHexColor(color)) {
return color;
}
var tempValue = "rgb(", colorArray; var tempValue = "rgb(", colorArray;
if (color.length === 7) { if (color.length === 7) {

Loading…
Cancel
Save