From 897a238332110c5c1a58ee9a0db5bf4e54fc3059 Mon Sep 17 00:00:00 2001 From: Ablay Keldibek Date: Tue, 7 Apr 2015 20:10:27 +0600 Subject: Slider: Range fills all space after changing orientation Resets width/height of range Fixes #12205 Closes gh-1533 --- tests/unit/slider/options.js | 41 +++++++++++++++++++++++++++++++++++++++-- tests/unit/slider/slider.html | 11 +++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/slider/options.js b/tests/unit/slider/options.js index 923c3c1c9..8e43c3e89 100644 --- a/tests/unit/slider/options.js +++ b/tests/unit/slider/options.js @@ -109,7 +109,7 @@ test( "min", function() { }); test( "orientation", function( assert ) { - expect( 8 ); + expect( 14 ); element = $( "#slider1" ); options = { @@ -119,7 +119,8 @@ test( "orientation", function( assert ) { value: 1 }; - var percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100; + var newValue, rangeSize, + percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100; element.slider( options ).slider( "option", "orientation", "horizontal" ); assert.hasClasses( element, "ui-slider-horizontal" ); @@ -146,6 +147,42 @@ test( "orientation", function( assert ) { element.slider( "destroy" ); + newValue = 7; + rangeSize = 500 - (500 * newValue / 10); + element = $( "#slider2" ).slider({ + range: "max", + min: 0, + max: 10 + }); + + element.slider( "option", "value", newValue ); + element.slider( "option", "orientation", "vertical" ); + equal( element.find( ".ui-slider-range" ).width(), 12, + "range should occupy all horizontal space after changing orientation to vertical" ); + equal( element.find( ".ui-slider-range" ).height(), rangeSize, + "range height of vertical slider should be proportional to the value" ); + + element.slider( "option", "orientation", "horizontal" ); + equal( element.find( ".ui-slider-range " ).height(), 12, + "range should occupy all vertical space after changing orientation to horizontal" ); + equal( element.find( ".ui-slider-range" ).width(), rangeSize, + "range width of horizontal slider should be proportional to the value" ); + + element.slider( "destroy" ); + + element = $( "#slider2" ).slider({ + range: true, + min: 0, + max: 100 + }); + element.slider( "option", { values: [ 60, 70 ] } ); + notEqual( element.find( ".ui-slider-range " ).position().left, 0, + "range should not pull over to the track's border" ); + element.slider( "option", "orientation", "vertical" ); + equal( element.find( ".ui-slider-range " ).position().left, 0, + "range should pull over to the track's border" ); + + element.slider( "destroy" ); }); //spec: http://wiki.jqueryui.com/Slider#specs diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index a9ec5324f..39bcd05c3 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -7,6 +7,16 @@ + @@ -14,6 +24,7 @@
+
-- cgit v1.2.3