2015-04-06 18:44:05 +00:00
|
|
|
define( [
|
2016-04-06 13:18:13 +00:00
|
|
|
"qunit",
|
2015-04-06 18:44:05 +00:00
|
|
|
"jquery",
|
2020-05-16 07:16:24 +00:00
|
|
|
"lib/helper",
|
2015-07-15 02:08:11 +00:00
|
|
|
"ui/widgets/slider"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, helper ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
var element, options;
|
2009-09-15 08:25:00 +00:00
|
|
|
|
2009-02-02 05:58:49 +00:00
|
|
|
function handle() {
|
2013-02-07 14:33:26 +00:00
|
|
|
return element.find( ".ui-slider-handle" );
|
2009-02-02 05:58:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
QUnit.module( "slider: options", { afterEach: helper.moduleAfterEach } );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "disabled", function( assert ) {
|
|
|
|
assert.expect( 8 );
|
2013-02-01 02:19:52 +00:00
|
|
|
var count = 0;
|
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element = $( "#slider1" ).slider();
|
2015-05-14 02:01:09 +00:00
|
|
|
element.on( "slidestart", function() {
|
2013-02-01 02:19:52 +00:00
|
|
|
count++;
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
2015-08-21 04:05:36 +00:00
|
|
|
// Enabled
|
2015-01-30 15:55:53 +00:00
|
|
|
assert.lacksClasses( element, "ui-slider-disabled" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "option", "disabled" ), false, "is not disabled" );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
|
|
|
handle().simulate( "drag", { dx: 10 } );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( count, 1, "slider moved" );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( count, 2, "slider moved" );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
2015-08-21 04:05:36 +00:00
|
|
|
// Disabled
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "option", "disabled", true );
|
2015-01-30 15:55:53 +00:00
|
|
|
assert.hasClasses( element, "ui-slider-disabled" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "option", "disabled" ), true, "is disabled" );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
|
|
|
handle().simulate( "drag", { dx: 10 } );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( count, 2, "slider did not move" );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( count, 2, "slider did not move" );
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-02-01 02:19:52 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "max", function( assert ) {
|
|
|
|
assert.expect( 7 );
|
2013-02-07 14:33:26 +00:00
|
|
|
element = $( "<div></div>" );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-02-02 05:58:49 +00:00
|
|
|
options = {
|
|
|
|
max: 37,
|
|
|
|
min: 6,
|
2012-12-26 13:08:48 +00:00
|
|
|
orientation: "horizontal",
|
2009-02-02 05:58:49 +00:00
|
|
|
step: 1,
|
|
|
|
value: 50
|
|
|
|
};
|
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "option", "value" ) === options.value, "value option is not contained by max" );
|
|
|
|
assert.ok( element.slider( "value" ) === options.max, "value method is contained by max" );
|
2015-04-06 18:44:05 +00:00
|
|
|
|
2013-10-19 04:56:20 +00:00
|
|
|
options = {
|
|
|
|
max: 9,
|
|
|
|
min: 1,
|
|
|
|
orientation: "horizontal",
|
|
|
|
step: 3,
|
|
|
|
value: 8.75
|
|
|
|
};
|
|
|
|
|
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "value" ) === 7, "value method is within max, edge Case" );
|
2015-04-06 18:44:05 +00:00
|
|
|
|
2013-10-19 04:56:20 +00:00
|
|
|
options.step = 2;
|
|
|
|
|
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "value" ) === options.max, "value method will max, step is changed" );
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "destroy" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2015-01-10 01:06:32 +00:00
|
|
|
options = {
|
|
|
|
max: 60,
|
|
|
|
min: 50,
|
|
|
|
orientation: "horizontal",
|
|
|
|
step: 0.1,
|
|
|
|
value: 60
|
|
|
|
};
|
|
|
|
|
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "value" ) === options.max, "value method will max, step is changed and step is float" );
|
2015-01-10 01:06:32 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
2016-02-11 19:29:54 +00:00
|
|
|
options = {
|
|
|
|
max: 10.75,
|
|
|
|
min: 1.22,
|
|
|
|
orientation: "horizontal",
|
|
|
|
step: 0.01,
|
|
|
|
value: 10.75
|
|
|
|
};
|
|
|
|
|
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "value" ) === options.max, "value method will max, step is changed, step is float and max is float" );
|
2016-02-11 19:29:54 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
|
|
|
options.max = 10.749999999;
|
|
|
|
|
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "value" ) === 10.74, "value method will max, step is changed, step is float, max is float and not divisible" );
|
2016-02-11 19:29:54 +00:00
|
|
|
element.slider( "destroy" );
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "min", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2013-02-07 14:33:26 +00:00
|
|
|
element = $( "<div></div>" );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-02-02 05:58:49 +00:00
|
|
|
options = {
|
|
|
|
max: 37,
|
|
|
|
min: 6,
|
2012-12-26 13:08:48 +00:00
|
|
|
orientation: "vertical",
|
2009-02-02 05:58:49 +00:00
|
|
|
step: 1,
|
|
|
|
value: 2
|
|
|
|
};
|
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( options );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.ok( element.slider( "option", "value" ) === options.value, "value option is not contained by min" );
|
|
|
|
assert.ok( element.slider( "value" ) === options.min, "value method is contained by min" );
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "destroy" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "orientation", function( assert ) {
|
|
|
|
assert.expect( 14 );
|
2013-02-07 14:33:26 +00:00
|
|
|
element = $( "#slider1" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
max: 2,
|
|
|
|
min: -2,
|
2012-12-26 13:08:48 +00:00
|
|
|
orientation: "vertical",
|
2009-02-02 05:58:49 +00:00
|
|
|
value: 1
|
|
|
|
};
|
|
|
|
|
2015-04-07 14:10:27 +00:00
|
|
|
var newValue, rangeSize,
|
|
|
|
percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100;
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( options ).slider( "option", "orientation", "horizontal" );
|
2015-01-30 15:55:53 +00:00
|
|
|
assert.hasClasses( element, "ui-slider-horizontal" );
|
|
|
|
assert.lacksClasses( element, "ui-slider-vertical" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" )[ 0 ].style.bottom, "", "CSS bottom reset" );
|
|
|
|
assert.equal( handle()[ 0 ].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2021-06-06 22:58:12 +00:00
|
|
|
element.slider( "destroy" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
|
|
|
options = {
|
|
|
|
max: 2,
|
|
|
|
min: -2,
|
2012-12-26 13:08:48 +00:00
|
|
|
orientation: "horizontal",
|
2009-02-02 05:58:49 +00:00
|
|
|
value: -1
|
|
|
|
};
|
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100;
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( options ).slider( "option", "orientation", "vertical" );
|
2015-01-30 15:55:53 +00:00
|
|
|
assert.hasClasses( element, "ui-slider-vertical" );
|
|
|
|
assert.lacksClasses( element, "ui-slider-horizontal" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" )[ 0 ].style.left, "", "CSS left reset" );
|
|
|
|
assert.equal( handle()[ 0 ].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "destroy" );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2015-04-07 14:10:27 +00:00
|
|
|
newValue = 7;
|
2015-08-24 12:58:09 +00:00
|
|
|
rangeSize = 500 - ( 500 * newValue / 10 );
|
|
|
|
element = $( "#slider2" ).slider( {
|
2015-04-07 14:10:27 +00:00
|
|
|
range: "max",
|
|
|
|
min: 0,
|
|
|
|
max: 10
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2015-04-07 14:10:27 +00:00
|
|
|
|
|
|
|
element.slider( "option", "value", newValue );
|
|
|
|
element.slider( "option", "orientation", "vertical" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-range" ).width(), 12,
|
2015-04-07 14:10:27 +00:00
|
|
|
"range should occupy all horizontal space after changing orientation to vertical" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-range" ).height(), rangeSize,
|
2015-04-07 14:10:27 +00:00
|
|
|
"range height of vertical slider should be proportional to the value" );
|
|
|
|
|
|
|
|
element.slider( "option", "orientation", "horizontal" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-range " ).height(), 12,
|
2015-04-07 14:10:27 +00:00
|
|
|
"range should occupy all vertical space after changing orientation to horizontal" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-range" ).width(), rangeSize,
|
2015-04-07 14:10:27 +00:00
|
|
|
"range width of horizontal slider should be proportional to the value" );
|
|
|
|
|
|
|
|
element.slider( "destroy" );
|
|
|
|
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "#slider2" ).slider( {
|
2015-04-07 14:10:27 +00:00
|
|
|
range: true,
|
|
|
|
min: 0,
|
|
|
|
max: 100
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2015-04-07 14:10:27 +00:00
|
|
|
element.slider( "option", { values: [ 60, 70 ] } );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.notEqual( element.find( ".ui-slider-range " ).position().left, 0,
|
2015-04-07 14:10:27 +00:00
|
|
|
"range should not pull over to the track's border" );
|
|
|
|
element.slider( "option", "orientation", "vertical" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-range " ).position().left, 0,
|
2015-04-07 14:10:27 +00:00
|
|
|
"range should pull over to the track's border" );
|
|
|
|
|
|
|
|
element.slider( "destroy" );
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2024-04-26 14:25:34 +00:00
|
|
|
// spec: https://wiki.jqueryui.com/Slider#specs
|
2010-04-01 19:00:45 +00:00
|
|
|
// value option/method: the value option is not restricted by min/max/step.
|
|
|
|
// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple)
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "step", function( assert ) {
|
|
|
|
assert.expect( 9 );
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2010-04-01 19:00:45 +00:00
|
|
|
min: 0,
|
|
|
|
value: 0,
|
|
|
|
step: 10,
|
2011-07-25 15:08:03 +00:00
|
|
|
max: 100
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 0 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "value", 1 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 0 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "value", 9 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 10 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "value", 11 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 10 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "value", 19 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 20 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2010-04-01 19:00:45 +00:00
|
|
|
min: 0,
|
|
|
|
value: 0,
|
|
|
|
step: 20,
|
2011-07-25 15:08:03 +00:00
|
|
|
max: 100
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "value", 0 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "option", "value", 1 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 0 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "option", "value", 9 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 0 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "option", "value", 11 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 20 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "option", "value", 19 );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.slider( "value" ), 20 );
|
2010-04-01 19:00:45 +00:00
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
element.slider( "destroy" );
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
//Test( "value", function() {
|
2013-02-07 14:33:26 +00:00
|
|
|
// ok(false, "missing test - untested code is broken code." );
|
2011-07-28 12:29:29 +00:00
|
|
|
//});
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "values", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2012-12-06 22:11:23 +00:00
|
|
|
|
2015-08-21 04:05:36 +00:00
|
|
|
// Testing multiple ranges on the same page, the object reference to the values
|
2012-12-06 22:11:23 +00:00
|
|
|
// property is preserved via multiple range elements, so updating options.values
|
|
|
|
// of 1 slider updates options.values of all the others
|
2015-08-24 12:58:09 +00:00
|
|
|
var ranges = $( [
|
2013-02-07 14:33:26 +00:00
|
|
|
document.createElement( "div" ),
|
|
|
|
document.createElement( "div" )
|
2015-08-24 12:58:09 +00:00
|
|
|
] ).slider( {
|
2013-03-02 20:31:38 +00:00
|
|
|
range: true,
|
2012-12-06 22:11:23 +00:00
|
|
|
values: [ 25, 75 ]
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2012-12-06 22:11:23 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.notStrictEqual(
|
2013-03-19 15:53:35 +00:00
|
|
|
ranges.eq( 0 ).slider( "instance" ).options.values,
|
|
|
|
ranges.eq( 1 ).slider( "instance" ).options.values,
|
2012-12-06 22:11:23 +00:00
|
|
|
"multiple range sliders should not have a reference to the same options.values array"
|
|
|
|
);
|
|
|
|
|
2013-02-07 14:33:26 +00:00
|
|
|
ranges.eq( 0 ).slider( "values", 0, 10 );
|
2012-12-06 22:11:23 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.notEqual(
|
2013-02-07 14:33:26 +00:00
|
|
|
ranges.eq( 0 ).slider( "values", 0 ),
|
|
|
|
ranges.eq( 1 ).slider( "values", 0 ),
|
2012-12-06 22:11:23 +00:00
|
|
|
"the values for multiple sliders should be different"
|
|
|
|
);
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2009-02-02 05:58:49 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
QUnit.test( "range", function( assert ) {
|
|
|
|
assert.expect( 32 );
|
2013-02-07 14:33:26 +00:00
|
|
|
var range;
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2015-08-21 04:05:36 +00:00
|
|
|
// Min
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: "min",
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range min, one handle" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
2015-08-21 04:05:36 +00:00
|
|
|
// Max
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: "max",
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range max, one handle" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
2015-08-21 04:05:36 +00:00
|
|
|
// True
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: true,
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
|
|
|
range = element.find( ".ui-slider-range" );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" );
|
2015-01-30 15:55:53 +00:00
|
|
|
assert.lacksClasses( range, "ui-slider-range-max ui-slider-range-min" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
|
|
|
// Change range from min to max
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: "min",
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} ).slider( "option", "range", "max" );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from min to max, one handle" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from min to max" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-max" ).length, 1, "range switch from min to max" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
|
|
|
// Change range from max to min
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: "max",
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} ).slider( "option", "range", "min" );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from max to min, one handle" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to min" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from max to min" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
|
|
|
// Change range from max to true
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: "max",
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} ).slider( "option", "range", true );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from max to true, two handles" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to true" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from max to true" );
|
|
|
|
assert.equal( element.slider( "option", "value" ), 0, "option value" );
|
|
|
|
assert.equal( element.slider( "value" ), 1, "value" );
|
|
|
|
assert.deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" );
|
|
|
|
assert.deepEqual( element.slider( "values" ), [ 1, 1 ], "values" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
|
|
|
|
|
|
|
// Change range from true to min
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-01-30 19:07:33 +00:00
|
|
|
range: true,
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} ).slider( "option", "range", "min" );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from true to min, one handle" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from true to min" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from true to min" );
|
|
|
|
assert.equal( element.slider( "option", "value" ), 1, "value" );
|
|
|
|
assert.equal( element.slider( "value" ), 1, "value" );
|
|
|
|
assert.equal( element.slider( "option", "values" ), null, "values" );
|
|
|
|
assert.deepEqual( element.slider( "values" ), [], "values" );
|
2013-01-30 19:07:33 +00:00
|
|
|
element.slider( "destroy" );
|
2013-06-03 19:14:08 +00:00
|
|
|
|
|
|
|
// Change range from true to false
|
2015-08-24 12:58:09 +00:00
|
|
|
element = $( "<div></div>" ).slider( {
|
2013-06-03 19:14:08 +00:00
|
|
|
range: true,
|
|
|
|
min: 1,
|
|
|
|
max: 10,
|
|
|
|
step: 1
|
2015-08-24 12:58:09 +00:00
|
|
|
} ).slider( "option", "range", false );
|
2016-04-06 13:18:13 +00:00
|
|
|
assert.equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from true to false, both handles remain" );
|
|
|
|
assert.equal( element.find( ".ui-slider-range" ).length, 0, "range switch from true to false" );
|
|
|
|
assert.equal( element.slider( "option", "value" ), 0, "option value" );
|
|
|
|
assert.equal( element.slider( "value" ), 1, "value" );
|
|
|
|
assert.deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" );
|
|
|
|
assert.deepEqual( element.slider( "values" ), [ 1, 1 ], "values" );
|
2013-06-03 19:14:08 +00:00
|
|
|
element.slider( "destroy" );
|
2015-08-24 12:58:09 +00:00
|
|
|
} );
|
2013-01-30 19:07:33 +00:00
|
|
|
|
2015-04-06 18:44:05 +00:00
|
|
|
} );
|