From a129a93a4d3a76e646423b6238459a12c80e22b0 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Thu, 31 Jan 2013 20:19:52 -0600 Subject: [PATCH] Slider: Add disabled tests and remove disabled prop from handles --- tests/unit/slider/slider_options.js | 31 +++++++++++++++++++++++++++++ ui/jquery.ui.slider.js | 3 --- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index d354ef91c..a7bd3ae83 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -11,6 +11,37 @@ function handle() { module("slider: options"); +test( "disabled", function(){ + expect( 8 ); + var count = 0; + + el = $( "#slider1" ).slider(); + el.on( "slidestart", function() { + count++; + }); + + // enabled + ok( !el.hasClass( "ui-slider-disabled" ), "no disabled class" ); + equal( el.slider( "option", "disabled" ), false , "is not disabled" ); + + handle().simulate( "drag", { dx: 10 } ); + equal( count, 1, "slider moved"); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equal( count, 2, "slider moved"); + + // disabled + el.slider( "option", "disabled", true ); + ok( el.hasClass( "ui-slider-disabled" ), "has disabled class" ); + equal( el.slider( "option", "disabled" ), true, "is disabled" ); + + handle().simulate( "drag", { dx: 10 } ); + equal( count, 2, "slider did not move"); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equal( count, 2, "slider did not move"); +}); + test("max", function() { expect( 2 ); el = $("
"); diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 54024af49..ceb8e1320 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -412,9 +412,6 @@ $.widget( "ui.slider", $.ui.mouse, { if ( value ) { this.handles.filter( ".ui-state-focus" ).blur(); this.handles.removeClass( "ui-state-hover" ); - this.handles.prop( "disabled", true ); - } else { - this.handles.prop( "disabled", false ); } break; case "orientation": -- 2.39.5