From d821a3e2b3887012075cb69e647d0c3e0c1a9159 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 23 Jul 2018 15:49:59 +0800 Subject: [PATCH] =?UTF-8?q?BI-28087=20slider=E6=8E=A7=E4=BB=B6=E5=8F=AF?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=8C=BA=E5=9F=9F=E5=80=BC=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/bundle.js | 35 +++++++++++---------- dist/core.js | 2 +- dist/fineui.js | 35 +++++++++++---------- dist/widget.js | 33 +++++++++---------- src/core/alias.js | 2 +- src/widget/intervalslider/intervalslider.js | 33 +++++++++---------- utils/utils.js | 2 +- 7 files changed, 73 insertions(+), 69 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 94af97ba8..813fe07e7 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -26161,7 +26161,7 @@ BI.ShowAction = BI.inherit(BI.Action, { cv = new Date(cv); } else { // 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); + cv = Date.parseDateTime(cv + "", Date.patterns.ISO8601Long); } } if (!BI.isNull(cv)) { @@ -94144,7 +94144,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { type: "bi.sign_text_editor", cls: "slider-editor-button", text: this.options.unit, - textAlign: "left", allowBlank: false, width: c.EDITOR_WIDTH, validationChecker: function (v) { @@ -94157,13 +94156,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelOne.element.removeClass("bi-border"); }); this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueOne = self.valueOne; var v = BI.parseFloat(this.getValue()); self.valueOne = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份 - self._setLabelOnePosition(significantPercent); self._setSliderOnePosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(oldValueOne, self.valueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -94173,7 +94173,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { text: this.options.unit, allowBlank: false, width: c.EDITOR_WIDTH, - textAlign: "right", validationChecker: function (v) { return self._checkValidation(v); } @@ -94184,13 +94183,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelTwo.element.removeClass("bi-border"); }); this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueTwo = self.valueTwo; var v = BI.parseFloat(this.getValue()); self.valueTwo = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setLabelTwoPosition(significantPercent); self._setSliderTwoPosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(self.valueOne, oldValueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -94238,16 +94238,17 @@ BI.IntervalSlider = BI.inherit(BI.Single, { var v = this._getValueByPercent(significantPercent); v = this._assertValue(v); v = o.digit === false ? v : v.toFixed(o.digit); + var oldValueOne = this.valueOne, oldValueTwo = this.valueTwo; if(isLeft) { - this._setLabelOnePosition(significantPercent); this._setSliderOnePosition(significantPercent); this.labelOne.setValue(v); this.valueOne = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo); }else{ - this._setLabelTwoPosition(significantPercent); this._setSliderTwoPosition(significantPercent); this.labelTwo.setValue(v); this.valueTwo = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v); } this._setBlueTrack(); }, @@ -94422,14 +94423,16 @@ BI.IntervalSlider = BI.inherit(BI.Single, { } }, - _setLabelOnePosition: function (percent) { - // this.labelOne.element.css({left: percent + "%"}); - // this._checkOverlap(); - }, - - _setLabelTwoPosition: function (percent) { - // this.labelTwo.element.css({left: percent + "%"}); - // this._checkOverlap(); + _checkLabelPosition: function (oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) { + oldValueOne = BI.parseFloat(oldValueOne); + oldValueTwo = BI.parseFloat(oldValueTwo); + valueOne = BI.parseFloat(valueOne); + valueTwo = BI.parseFloat(valueTwo); + if((oldValueOne <= oldValueTwo && valueOne > valueTwo) || (oldValueOne >= oldValueTwo && valueOne < valueTwo)) { + var isSliderOneLeft = BI.parseFloat(this.sliderOne.element[0].style.left) < BI.parseFloat(this.sliderTwo.element[0].style.left); + this.labelOne.element.css({left: isSliderOneLeft ? "0%" : "100%"}); + this.labelTwo.element.css({left: isSliderOneLeft ? "100%" : "0%"}); + } }, _setSliderOnePosition: function (percent) { @@ -94462,9 +94465,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { _setAllPosition: function (one, two) { this._setSliderOnePosition(one); - this._setLabelOnePosition(one); this._setSliderTwoPosition(two); - this._setLabelTwoPosition(two); this._setBlueTrack(); }, diff --git a/dist/core.js b/dist/core.js index f16fdc3f6..4467b2003 100644 --- a/dist/core.js +++ b/dist/core.js @@ -26161,7 +26161,7 @@ BI.ShowAction = BI.inherit(BI.Action, { cv = new Date(cv); } else { // 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); + cv = Date.parseDateTime(cv + "", Date.patterns.ISO8601Long); } } if (!BI.isNull(cv)) { diff --git a/dist/fineui.js b/dist/fineui.js index e95854888..871a9bbca 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -26410,7 +26410,7 @@ BI.ShowAction = BI.inherit(BI.Action, { cv = new Date(cv); } else { // 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); + cv = Date.parseDateTime(cv + "", Date.patterns.ISO8601Long); } } if (!BI.isNull(cv)) { @@ -94393,7 +94393,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { type: "bi.sign_text_editor", cls: "slider-editor-button", text: this.options.unit, - textAlign: "left", allowBlank: false, width: c.EDITOR_WIDTH, validationChecker: function (v) { @@ -94406,13 +94405,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelOne.element.removeClass("bi-border"); }); this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueOne = self.valueOne; var v = BI.parseFloat(this.getValue()); self.valueOne = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份 - self._setLabelOnePosition(significantPercent); self._setSliderOnePosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(oldValueOne, self.valueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -94422,7 +94422,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { text: this.options.unit, allowBlank: false, width: c.EDITOR_WIDTH, - textAlign: "right", validationChecker: function (v) { return self._checkValidation(v); } @@ -94433,13 +94432,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelTwo.element.removeClass("bi-border"); }); this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueTwo = self.valueTwo; var v = BI.parseFloat(this.getValue()); self.valueTwo = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setLabelTwoPosition(significantPercent); self._setSliderTwoPosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(self.valueOne, oldValueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -94487,16 +94487,17 @@ BI.IntervalSlider = BI.inherit(BI.Single, { var v = this._getValueByPercent(significantPercent); v = this._assertValue(v); v = o.digit === false ? v : v.toFixed(o.digit); + var oldValueOne = this.valueOne, oldValueTwo = this.valueTwo; if(isLeft) { - this._setLabelOnePosition(significantPercent); this._setSliderOnePosition(significantPercent); this.labelOne.setValue(v); this.valueOne = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo); }else{ - this._setLabelTwoPosition(significantPercent); this._setSliderTwoPosition(significantPercent); this.labelTwo.setValue(v); this.valueTwo = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v); } this._setBlueTrack(); }, @@ -94671,14 +94672,16 @@ BI.IntervalSlider = BI.inherit(BI.Single, { } }, - _setLabelOnePosition: function (percent) { - // this.labelOne.element.css({left: percent + "%"}); - // this._checkOverlap(); - }, - - _setLabelTwoPosition: function (percent) { - // this.labelTwo.element.css({left: percent + "%"}); - // this._checkOverlap(); + _checkLabelPosition: function (oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) { + oldValueOne = BI.parseFloat(oldValueOne); + oldValueTwo = BI.parseFloat(oldValueTwo); + valueOne = BI.parseFloat(valueOne); + valueTwo = BI.parseFloat(valueTwo); + if((oldValueOne <= oldValueTwo && valueOne > valueTwo) || (oldValueOne >= oldValueTwo && valueOne < valueTwo)) { + var isSliderOneLeft = BI.parseFloat(this.sliderOne.element[0].style.left) < BI.parseFloat(this.sliderTwo.element[0].style.left); + this.labelOne.element.css({left: isSliderOneLeft ? "0%" : "100%"}); + this.labelTwo.element.css({left: isSliderOneLeft ? "100%" : "0%"}); + } }, _setSliderOnePosition: function (percent) { @@ -94711,9 +94714,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { _setAllPosition: function (one, two) { this._setSliderOnePosition(one); - this._setLabelOnePosition(one); this._setSliderTwoPosition(two); - this._setLabelTwoPosition(two); this._setBlueTrack(); }, diff --git a/dist/widget.js b/dist/widget.js index 0ac4cd048..d943647a0 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -6248,7 +6248,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { type: "bi.sign_text_editor", cls: "slider-editor-button", text: this.options.unit, - textAlign: "left", allowBlank: false, width: c.EDITOR_WIDTH, validationChecker: function (v) { @@ -6261,13 +6260,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelOne.element.removeClass("bi-border"); }); this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueOne = self.valueOne; var v = BI.parseFloat(this.getValue()); self.valueOne = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份 - self._setLabelOnePosition(significantPercent); self._setSliderOnePosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(oldValueOne, self.valueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -6277,7 +6277,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { text: this.options.unit, allowBlank: false, width: c.EDITOR_WIDTH, - textAlign: "right", validationChecker: function (v) { return self._checkValidation(v); } @@ -6288,13 +6287,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelTwo.element.removeClass("bi-border"); }); this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueTwo = self.valueTwo; var v = BI.parseFloat(this.getValue()); self.valueTwo = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setLabelTwoPosition(significantPercent); self._setSliderTwoPosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(self.valueOne, oldValueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -6342,16 +6342,17 @@ BI.IntervalSlider = BI.inherit(BI.Single, { var v = this._getValueByPercent(significantPercent); v = this._assertValue(v); v = o.digit === false ? v : v.toFixed(o.digit); + var oldValueOne = this.valueOne, oldValueTwo = this.valueTwo; if(isLeft) { - this._setLabelOnePosition(significantPercent); this._setSliderOnePosition(significantPercent); this.labelOne.setValue(v); this.valueOne = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo); }else{ - this._setLabelTwoPosition(significantPercent); this._setSliderTwoPosition(significantPercent); this.labelTwo.setValue(v); this.valueTwo = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v); } this._setBlueTrack(); }, @@ -6526,14 +6527,16 @@ BI.IntervalSlider = BI.inherit(BI.Single, { } }, - _setLabelOnePosition: function (percent) { - // this.labelOne.element.css({left: percent + "%"}); - // this._checkOverlap(); - }, - - _setLabelTwoPosition: function (percent) { - // this.labelTwo.element.css({left: percent + "%"}); - // this._checkOverlap(); + _checkLabelPosition: function (oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) { + oldValueOne = BI.parseFloat(oldValueOne); + oldValueTwo = BI.parseFloat(oldValueTwo); + valueOne = BI.parseFloat(valueOne); + valueTwo = BI.parseFloat(valueTwo); + if((oldValueOne <= oldValueTwo && valueOne > valueTwo) || (oldValueOne >= oldValueTwo && valueOne < valueTwo)) { + var isSliderOneLeft = BI.parseFloat(this.sliderOne.element[0].style.left) < BI.parseFloat(this.sliderTwo.element[0].style.left); + this.labelOne.element.css({left: isSliderOneLeft ? "0%" : "100%"}); + this.labelTwo.element.css({left: isSliderOneLeft ? "100%" : "0%"}); + } }, _setSliderOnePosition: function (percent) { @@ -6566,9 +6569,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { _setAllPosition: function (one, two) { this._setSliderOnePosition(one); - this._setLabelOnePosition(one); this._setSliderTwoPosition(two); - this._setLabelTwoPosition(two); this._setBlueTrack(); }, diff --git a/src/core/alias.js b/src/core/alias.js index c85f1e847..ab73ba362 100644 --- a/src/core/alias.js +++ b/src/core/alias.js @@ -486,7 +486,7 @@ cv = new Date(cv); } else { // 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); + cv = Date.parseDateTime(cv + "", Date.patterns.ISO8601Long); } } if (!BI.isNull(cv)) { diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js index d47e8375b..b56e84508 100644 --- a/src/widget/intervalslider/intervalslider.js +++ b/src/widget/intervalslider/intervalslider.js @@ -48,7 +48,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { type: "bi.sign_text_editor", cls: "slider-editor-button", text: this.options.unit, - textAlign: "left", allowBlank: false, width: c.EDITOR_WIDTH, validationChecker: function (v) { @@ -61,13 +60,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelOne.element.removeClass("bi-border"); }); this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueOne = self.valueOne; var v = BI.parseFloat(this.getValue()); self.valueOne = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份 - self._setLabelOnePosition(significantPercent); self._setSliderOnePosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(oldValueOne, self.valueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -77,7 +77,6 @@ BI.IntervalSlider = BI.inherit(BI.Single, { text: this.options.unit, allowBlank: false, width: c.EDITOR_WIDTH, - textAlign: "right", validationChecker: function (v) { return self._checkValidation(v); } @@ -88,13 +87,14 @@ BI.IntervalSlider = BI.inherit(BI.Single, { self.labelTwo.element.removeClass("bi-border"); }); this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () { + var oldValueTwo = self.valueTwo; var v = BI.parseFloat(this.getValue()); self.valueTwo = v; var percent = self._getPercentByValue(v); var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setLabelTwoPosition(significantPercent); self._setSliderTwoPosition(significantPercent); self._setBlueTrack(); + self._checkLabelPosition(self.valueOne, oldValueTwo, self.valueOne, self.valueTwo); self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); }); @@ -142,16 +142,17 @@ BI.IntervalSlider = BI.inherit(BI.Single, { var v = this._getValueByPercent(significantPercent); v = this._assertValue(v); v = o.digit === false ? v : v.toFixed(o.digit); + var oldValueOne = this.valueOne, oldValueTwo = this.valueTwo; if(isLeft) { - this._setLabelOnePosition(significantPercent); this._setSliderOnePosition(significantPercent); this.labelOne.setValue(v); this.valueOne = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo); }else{ - this._setLabelTwoPosition(significantPercent); this._setSliderTwoPosition(significantPercent); this.labelTwo.setValue(v); this.valueTwo = v; + this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v); } this._setBlueTrack(); }, @@ -326,14 +327,16 @@ BI.IntervalSlider = BI.inherit(BI.Single, { } }, - _setLabelOnePosition: function (percent) { - // this.labelOne.element.css({left: percent + "%"}); - // this._checkOverlap(); - }, - - _setLabelTwoPosition: function (percent) { - // this.labelTwo.element.css({left: percent + "%"}); - // this._checkOverlap(); + _checkLabelPosition: function (oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) { + oldValueOne = BI.parseFloat(oldValueOne); + oldValueTwo = BI.parseFloat(oldValueTwo); + valueOne = BI.parseFloat(valueOne); + valueTwo = BI.parseFloat(valueTwo); + if((oldValueOne <= oldValueTwo && valueOne > valueTwo) || (oldValueOne >= oldValueTwo && valueOne < valueTwo)) { + var isSliderOneLeft = BI.parseFloat(this.sliderOne.element[0].style.left) < BI.parseFloat(this.sliderTwo.element[0].style.left); + this.labelOne.element.css({left: isSliderOneLeft ? "0%" : "100%"}); + this.labelTwo.element.css({left: isSliderOneLeft ? "100%" : "0%"}); + } }, _setSliderOnePosition: function (percent) { @@ -366,9 +369,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { _setAllPosition: function (one, two) { this._setSliderOnePosition(one); - this._setLabelOnePosition(one); this._setSliderTwoPosition(two); - this._setLabelTwoPosition(two); this._setBlueTrack(); }, diff --git a/utils/utils.js b/utils/utils.js index d47a45942..f5b20798b 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -12958,7 +12958,7 @@ _.extend(BI.OB.prototype, { cv = new Date(cv); } else { // 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); + cv = Date.parseDateTime(cv + "", Date.patterns.ISO8601Long); } } if (!BI.isNull(cv)) {