From 88f7feb35eea8e39d6efe86680baebd03882c9bf Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Mon, 14 Dec 2020 09:17:45 +0000 Subject: [PATCH 1/9] #15262: Round calculated max before compare with max from options. --- ui/widgets/slider.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index e5004573ae0..fe003e19a53 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -550,12 +550,15 @@ return $.widget( "ui.slider", $.ui.mouse, { step = this.options.step, aboveMin = Math.round( ( max - min ) / step ) * step; max = aboveMin + min; - if ( max > this.options.max ) { + // Round the max before compare with max from options. + max = max.toFixed( this._precision() ); + var option_max = this.options.max.toFixed( this._precision() ); + if ( max > option_max ) { //If max is not divisible by step, rounding off may increase its value max -= step; } - this.max = parseFloat( max.toFixed( this._precision() ) ); + this.max = parseFloat(max); }, _precision: function() { From 3304b5452fea7562d811c0bcc09710a4ef1b5b83 Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Mon, 14 Dec 2020 09:28:54 +0000 Subject: [PATCH 2/9] #15262: Correct codestyle. --- ui/widgets/slider.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index fe003e19a53..1f1a8eca3ac 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -550,15 +550,16 @@ return $.widget( "ui.slider", $.ui.mouse, { step = this.options.step, aboveMin = Math.round( ( max - min ) / step ) * step; max = aboveMin + min; + // Round the max before compare with max from options. max = max.toFixed( this._precision() ); - var option_max = this.options.max.toFixed( this._precision() ); - if ( max > option_max ) { + var optionMax = this.options.max.toFixed( this._precision() ); + if ( max > optionMax ) { //If max is not divisible by step, rounding off may increase its value max -= step; } - this.max = parseFloat(max); + this.max = parseFloat( max ); }, _precision: function() { From 0f3a8fa7922de10dddba4482ccd6dbb7bae43649 Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Mon, 14 Dec 2020 10:00:58 +0000 Subject: [PATCH 3/9] #15262: Correct logic to cover failed test. --- ui/widgets/slider.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 1f1a8eca3ac..c5981a613e9 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -548,18 +548,20 @@ return $.widget( "ui.slider", $.ui.mouse, { var max = this.options.max, min = this._valueMin(), step = this.options.step, - aboveMin = Math.round( ( max - min ) / step ) * step; + aboveMin = Math.floor( ( max - min ) / step ) * step; max = aboveMin + min; - - // Round the max before compare with max from options. - max = max.toFixed( this._precision() ); - var optionMax = this.options.max.toFixed( this._precision() ); + // Round the max before compare with max from option. + max = parseFloat( max.toFixed( this._precision() ) ); + var optionMax = parseFloat( this.options.max.toFixed( this._precision() ) ); if ( max > optionMax ) { - - //If max is not divisible by step, rounding off may increase its value + // If max is not divisible by step, rounding off may increase its value max -= step; } - this.max = parseFloat( max ); + // Make sure that max is covered. + else if ( max <= (optionMax - step) ) { + max += step; + } + this.max = max; }, _precision: function() { From 587371ff16171b521a251e29f868528c285ec9d9 Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Mon, 14 Dec 2020 10:05:09 +0000 Subject: [PATCH 4/9] #15262: Correct codestyle. --- ui/widgets/slider.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index c5981a613e9..743152b7ab3 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -550,15 +550,18 @@ return $.widget( "ui.slider", $.ui.mouse, { step = this.options.step, aboveMin = Math.floor( ( max - min ) / step ) * step; max = aboveMin + min; + // Round the max before compare with max from option. max = parseFloat( max.toFixed( this._precision() ) ); var optionMax = parseFloat( this.options.max.toFixed( this._precision() ) ); if ( max > optionMax ) { + // If max is not divisible by step, rounding off may increase its value max -= step; } - // Make sure that max is covered. - else if ( max <= (optionMax - step) ) { + else if ( max <= ( optionMax - step ) ) { + + // Make sure that max is covered. max += step; } this.max = max; From aa710e9eb9b7e0155f99445ce1c4edc41fd17e78 Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Mon, 14 Dec 2020 10:07:38 +0000 Subject: [PATCH 5/9] #15262: Correct codestyle. --- ui/widgets/slider.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 743152b7ab3..882d1167201 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -558,8 +558,7 @@ return $.widget( "ui.slider", $.ui.mouse, { // If max is not divisible by step, rounding off may increase its value max -= step; - } - else if ( max <= ( optionMax - step ) ) { + } else if ( max <= ( optionMax - step ) ) { // Make sure that max is covered. max += step; From 6c2c42444b454a05074a3ac329c738c1115c0d7e Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Fri, 18 Dec 2020 06:34:41 +0000 Subject: [PATCH 6/9] #15262: Add option which allow to define if max should be covered or not. --- ui/widgets/slider.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 882d1167201..c9c4a394ed1 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -50,6 +50,7 @@ return $.widget( "ui.slider", $.ui.mouse, { }, distance: 0, max: 100, + includeMax: false, min: 0, orientation: "horizontal", range: false, @@ -554,15 +555,20 @@ return $.widget( "ui.slider", $.ui.mouse, { // Round the max before compare with max from option. max = parseFloat( max.toFixed( this._precision() ) ); var optionMax = parseFloat( this.options.max.toFixed( this._precision() ) ); - if ( max > optionMax ) { + + if ( this.options.includeMax) { + if (max < optionMax ) { + + // If max is not divisible by step and max from options + // should be covered, add one more step. + max += step; + } + } else if ( max > optionMax ) { // If max is not divisible by step, rounding off may increase its value max -= step; - } else if ( max <= ( optionMax - step ) ) { - - // Make sure that max is covered. - max += step; } + this.max = max; }, From 03ccd3436190132b0e9caadd7968a2db46daa63d Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Fri, 18 Dec 2020 06:59:53 +0000 Subject: [PATCH 7/9] #15262: Correct codestyle. --- ui/widgets/slider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index c9c4a394ed1..356c801bf2a 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -556,8 +556,8 @@ return $.widget( "ui.slider", $.ui.mouse, { max = parseFloat( max.toFixed( this._precision() ) ); var optionMax = parseFloat( this.options.max.toFixed( this._precision() ) ); - if ( this.options.includeMax) { - if (max < optionMax ) { + if ( this.options.includeMax ) { + if ( max < optionMax ) { // If max is not divisible by step and max from options // should be covered, add one more step. From 204fcb1ce55f932f159dbefdc3fa3f07332920d0 Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Fri, 18 Dec 2020 07:05:55 +0000 Subject: [PATCH 8/9] #15262: Correct logic for cover tests. --- ui/widgets/slider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 356c801bf2a..12250e9bf50 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -549,7 +549,7 @@ return $.widget( "ui.slider", $.ui.mouse, { var max = this.options.max, min = this._valueMin(), step = this.options.step, - aboveMin = Math.floor( ( max - min ) / step ) * step; + aboveMin = Math.round( ( max - min ) / step ) * step; max = aboveMin + min; // Round the max before compare with max from option. From c234a2b24f10d69f97c46574ad8518d22b1f4182 Mon Sep 17 00:00:00 2001 From: Tatiana Kiseleva Date: Fri, 18 Dec 2020 07:12:54 +0000 Subject: [PATCH 9/9] #15262: Correct logic for cover tests. --- ui/widgets/slider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 12250e9bf50..916a1f2c679 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -556,7 +556,7 @@ return $.widget( "ui.slider", $.ui.mouse, { max = parseFloat( max.toFixed( this._precision() ) ); var optionMax = parseFloat( this.options.max.toFixed( this._precision() ) ); - if ( this.options.includeMax ) { + if ( this.options.includeMax && this.options.includeMax === true) { if ( max < optionMax ) { // If max is not divisible by step and max from options