Browse Source

JSY-30724 feat:区间滑块支持自定义编辑框的宽度

research/test
Claire 1 year ago
parent
commit
f381df071c
  1. 29
      src/widget/intervalslider/intervalslider.js

29
src/widget/intervalslider/intervalslider.js

@ -21,7 +21,9 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
value: { value: {
min: "", min: "",
max: "", max: "",
} },
lAlign: "center",
rAlign: "center",
}, },
beforeMount: function () { beforeMount: function () {
@ -38,6 +40,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
var self = this; var self = this;
var c = this._constant; var c = this._constant;
var o = this.options;
this.enable = false; this.enable = false;
this.valueOne = ""; this.valueOne = "";
this.valueTwo = ""; this.valueTwo = "";
@ -60,8 +63,9 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
cls: "slider-editor-button", cls: "slider-editor-button",
text: this.options.unit, text: this.options.unit,
allowBlank: false, allowBlank: false,
width: BI.toPix(c.EDITOR_WIDTH, 2), width: BI.isNull(o.editorWidth) ? BI.toPix(c.EDITOR_WIDTH, 2) : BI.toPix(o.editorWidth, 2),
height: BI.toPix(c.EDITOR_HEIGHT, 2), height: BI.toPix(c.EDITOR_HEIGHT, 2),
textAlign: o.lAlign,
validationChecker: function (v) { validationChecker: function (v) {
return self._checkValidation(v); return self._checkValidation(v);
} }
@ -88,8 +92,9 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
cls: "slider-editor-button", cls: "slider-editor-button",
text: this.options.unit, text: this.options.unit,
allowBlank: false, allowBlank: false,
width: BI.toPix(c.EDITOR_WIDTH, 2), width: BI.isNull(o.editorWidth) ? BI.toPix(c.EDITOR_WIDTH, 2) : BI.toPix(o.editorWidth, 2),
height: BI.toPix(c.EDITOR_HEIGHT, 2), height: BI.toPix(c.EDITOR_HEIGHT, 2),
textAlign: o.rAlign,
validationChecker: function (v) { validationChecker: function (v) {
return self._checkValidation(v); return self._checkValidation(v);
} }
@ -218,6 +223,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
_createLabelWrapper: function () { _createLabelWrapper: function () {
var c = this._constant; var c = this._constant;
var o = this.options;
return { return {
el: { el: {
type: "bi.vertical", type: "bi.vertical",
@ -227,16 +233,12 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
el: this.labelOne, el: this.labelOne,
top: 0, top: 0,
left: 0, left: 0,
}]
}, { }, {
type: "bi.absolute",
items: [{
el: this.labelTwo, el: this.labelTwo,
top: 0, top: 0,
right: 0, right: 0,
}] }]
}], }],
rgap: c.EDITOR_R_GAP,
height: c.SLIDER_HEIGHT height: c.SLIDER_HEIGHT
}, },
top: 0, top: 0,
@ -359,8 +361,17 @@ BI.IntervalSlider = BI.inherit(BI.Single, {
}, },
_resetLabelPosition: function(needReverse) { _resetLabelPosition: function(needReverse) {
this.labelOne.element.css({left: needReverse ? "100%" : "0%"}); var o = this.options;
this.labelTwo.element.css({left: needReverse ? "0%" : "100%"}); this.labelOne.element.css({
left: needReverse ? "unset" : "0%",
right: needReverse ? "0%" : "unset",
});
this.labelOne.element.children()[0] && (this.labelOne.element.children()[0].style.textAlign = needReverse ? o.rAlign : o.lAlign);
this.labelTwo.element.css({
left: needReverse ? "0%" : "unset",
right: needReverse ? "unset" : "0%",
});
this.labelTwo.element.children()[0] && (this.labelTwo.element.children()[0].style.textAlign = needReverse ? o.lAlign : o.rAlign);
}, },
_setSliderOnePosition: function (percent) { _setSliderOnePosition: function (percent) {

Loading…
Cancel
Save