]> source.dussan.org Git - jquery-ui.git/commitdiff
Slider: Add disabled tests and remove disabled prop from handles 905/head
authorDavid Petersen <public@petersendidit.com>
Fri, 1 Feb 2013 02:19:52 +0000 (20:19 -0600)
committerDavid Petersen <public@petersendidit.com>
Mon, 4 Feb 2013 20:43:56 +0000 (14:43 -0600)
tests/unit/slider/slider_options.js
ui/jquery.ui.slider.js

index d354ef91c8d55a0ed2f75c1175dcbc0260a09628..a7bd3ae8315afa6c5b6d411dbd03a5338499a5a2 100644 (file)
@@ -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 = $("<div></div>");
index 54024af493ca3188d334c617ec78795ebf31120c..ceb8e1320b1f6471fd7e135833a2941bc2f298b2 100644 (file)
@@ -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":