From a0716865f8b531d56ad8b5141f1762ce3539461c Mon Sep 17 00:00:00 2001 From: Urthur Date: Sat, 30 Sep 2017 09:46:20 +0800 Subject: [PATCH] =?UTF-8?q?slider=20=E4=BF=AE=E6=94=B9digit=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/singleslider/singleslider.label.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/addons/sliders/js/singleslider/singleslider.label.js b/src/addons/sliders/js/singleslider/singleslider.label.js index 53b79eec64..4410f2a5f1 100644 --- a/src/addons/sliders/js/singleslider/singleslider.label.js +++ b/src/addons/sliders/js/singleslider/singleslider.label.js @@ -14,7 +14,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-single-slider-label bi-slider-track", - digit: "", + digit: false, unit: "" }); }, @@ -22,7 +22,6 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, { BI.SingleSliderLabel.superclass._init.apply(this, arguments); var self = this, o = this.options; - var digitExist = (o.digit === "") ? false : true; var c = this._constant; this.enable = false; this.value = ""; @@ -52,7 +51,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, { self._setBlueTrack(significantPercent); self._setLabelPosition(significantPercent); var v = self._getValueByPercent(significantPercent); - v = digitExist ? v.toFixed(o.digit) : v; + v = o.digit === false ? v : v.toFixed(o.digit); self.label.setText(v + o.unit); self.value = v; self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); @@ -90,7 +89,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, { var significantPercent = BI.parseFloat(percent.toFixed(1)); self._setAllPosition(significantPercent); var v = self._getValueByPercent(significantPercent); - v = digitExist ? v.toFixed(o.digit) : v; + v = o.digit === false ? v : v.toFixed(o.digit); self.label.setText(v + o.unit); self.value = v; self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); @@ -221,17 +220,16 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, { setValue: function (v) { var o = this.options; - var digitExist = (o.digit === "") ? false : true; - var value = BI.parseFloat(v); - value = digitExist ? value.toFixed(o.digit) : value; - if ((!isNaN(value))) { - if (this._checkValidation(value)) { - this.value = value; + v = BI.parseFloat(v); + v = o.digit === false ? v : v.toFixed(o.digit); + if ((!isNaN(v))) { + if (this._checkValidation(v)) { + this.value = v; } - if (value > this.max) { + if (v > this.max) { this.value = this.max; } - if (value < this.min) { + if (v < this.min) { this.value = this.min; } }