Browse Source

slider update

es6
Urthur 7 years ago
parent
commit
048cef3b16
  1. 17
      bi/slider.js
  2. 17
      dist/slider.js
  3. 17
      src/addons/slider/singleslider/singleslider.js

17
bi/slider.js

@ -46,13 +46,14 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track", baseCls: "bi-single-slider bi-slider-track",
digit: 3 digit: ""
}); });
}, },
_init: function () { _init: function () {
BI.SingleSlider.superclass._init.apply(this, arguments); BI.SingleSlider.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var digitExist = (o.digit === "") ? false : true;
var c = this._constant; var c = this._constant;
this.enable = false; this.enable = false;
this.value = ""; this.value = "";
@ -81,7 +82,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent); self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent); self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent).toFixed(o.digit); var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
self.label.setValue(v); self.label.setValue(v);
self.value = v; self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -118,7 +120,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
} }
var significantPercent = BI.parseFloat(percent.toFixed(1)); var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent); self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent).toFixed(o.digit); var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
self.label.setValue(v); self.label.setValue(v);
self.value = v; self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -140,11 +143,12 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}); });
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () { this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var v = BI.parseFloat(this.getValue()); var v = BI.parseFloat(this.getValue());
this.setValue(v.toFixed(o.digit));
self.value = v.toFixed(o.digit);
var percent = self._getPercentByValue(v); var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1)); var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent); self._setAllPosition(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
this.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}); });
this._setVisible(false); this._setVisible(false);
@ -266,8 +270,9 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
var o = this.options; var o = this.options;
var digitExist = (o.digit === "") ? false : true;
var value = BI.parseFloat(v); var value = BI.parseFloat(v);
value = value.toFixed(o.digit); value = digitExist ? value.toFixed(o.digit) : value;
if ((!isNaN(value))) { if ((!isNaN(value))) {
if (this._checkValidation(value)) { if (this._checkValidation(value)) {
this.value = value; this.value = value;

17
dist/slider.js vendored

@ -46,13 +46,14 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track", baseCls: "bi-single-slider bi-slider-track",
digit: 3 digit: ""
}); });
}, },
_init: function () { _init: function () {
BI.SingleSlider.superclass._init.apply(this, arguments); BI.SingleSlider.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var digitExist = (o.digit === "") ? false : true;
var c = this._constant; var c = this._constant;
this.enable = false; this.enable = false;
this.value = ""; this.value = "";
@ -81,7 +82,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent); self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent); self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent).toFixed(o.digit); var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
self.label.setValue(v); self.label.setValue(v);
self.value = v; self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -118,7 +120,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
} }
var significantPercent = BI.parseFloat(percent.toFixed(1)); var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent); self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent).toFixed(o.digit); var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
self.label.setValue(v); self.label.setValue(v);
self.value = v; self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -140,11 +143,12 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}); });
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () { this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var v = BI.parseFloat(this.getValue()); var v = BI.parseFloat(this.getValue());
this.setValue(v.toFixed(o.digit));
self.value = v.toFixed(o.digit);
var percent = self._getPercentByValue(v); var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1)); var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent); self._setAllPosition(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
this.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}); });
this._setVisible(false); this._setVisible(false);
@ -266,8 +270,9 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
var o = this.options; var o = this.options;
var digitExist = (o.digit === "") ? false : true;
var value = BI.parseFloat(v); var value = BI.parseFloat(v);
value = value.toFixed(o.digit); value = digitExist ? value.toFixed(o.digit) : value;
if ((!isNaN(value))) { if ((!isNaN(value))) {
if (this._checkValidation(value)) { if (this._checkValidation(value)) {
this.value = value; this.value = value;

17
src/addons/slider/singleslider/singleslider.js

@ -14,13 +14,14 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.SingleSlider.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider bi-slider-track", baseCls: "bi-single-slider bi-slider-track",
digit: 3 digit: ""
}); });
}, },
_init: function () { _init: function () {
BI.SingleSlider.superclass._init.apply(this, arguments); BI.SingleSlider.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var digitExist = (o.digit === "") ? false : true;
var c = this._constant; var c = this._constant;
this.enable = false; this.enable = false;
this.value = ""; this.value = "";
@ -49,7 +50,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 var significantPercent = BI.parseFloat(percent.toFixed(1));//直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
self._setBlueTrack(significantPercent); self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent); self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent).toFixed(o.digit); var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
self.label.setValue(v); self.label.setValue(v);
self.value = v; self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -86,7 +88,8 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
} }
var significantPercent = BI.parseFloat(percent.toFixed(1)); var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent); self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent).toFixed(o.digit); var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
self.label.setValue(v); self.label.setValue(v);
self.value = v; self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
@ -108,11 +111,12 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
}); });
this.label.on(BI.SignEditor.EVENT_CONFIRM, function () { this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
var v = BI.parseFloat(this.getValue()); var v = BI.parseFloat(this.getValue());
this.setValue(v.toFixed(o.digit));
self.value = v.toFixed(o.digit);
var percent = self._getPercentByValue(v); var percent = self._getPercentByValue(v);
var significantPercent = BI.parseFloat(percent.toFixed(1)); var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent); self._setAllPosition(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
this.setValue(v);
self.value = v;
self.fireEvent(BI.SingleSlider.EVENT_CHANGE); self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
}); });
this._setVisible(false); this._setVisible(false);
@ -234,8 +238,9 @@ BI.SingleSlider = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
var o = this.options; var o = this.options;
var digitExist = (o.digit === "") ? false : true;
var value = BI.parseFloat(v); var value = BI.parseFloat(v);
value = value.toFixed(o.digit); value = digitExist ? value.toFixed(o.digit) : value;
if ((!isNaN(value))) { if ((!isNaN(value))) {
if (this._checkValidation(value)) { if (this._checkValidation(value)) {
this.value = value; this.value = value;

Loading…
Cancel
Save