Permalink
Browse files

Slider: Set/unset class "ui-state-disabled" in sync with disabled option

Fixes gh-6857
  • Loading branch information...
gabrielschulhof committed Jan 10, 2014
1 parent d14b90d commit dfc5d32aad67dba223c343cf4fbde26bbaa20911
Showing with 30 additions and 2 deletions.
  1. +3 −1 js/widgets/forms/slider.js
  2. +5 −0 tests/unit/slider/index.html
  3. +22 −1 tests/unit/slider/slider_core.js
@@ -581,7 +581,9 @@ $.widget( "mobile.slider", $.extend( {
_setDisabled: function( value ) {
value = !!value;
this.element.prop( "disabled", value );
this.slider.toggleClass( "ui-state-disabled" ).attr( "aria-disabled", value );
this.slider
.toggleClass( "ui-state-disabled", value )
.attr( "aria-disabled", value );
}
}, $.mobile.behaviors.formReset ) );
@@ -117,6 +117,11 @@ <h2 id="qunit-userAgent"></h2>
<label for="remove-events-slider">Input slider:</label>
<input type="range" name="remove-events-slider" id="remove-events-slider" value="25" min="0" max="100"/>
</div>
<label>Input slider:
<input type="range" name="disable-test" id="disable-test" value="17" min="0" max="100"/>
</label>
</div>
<div id="enhancetest">
@@ -66,7 +66,28 @@
test( "slider input is not wrapped in div.ui-input-text", function() {
ok( ! $( "#textinput-test" ).parents().is( "div.ui-input-text" ), "slider input is not wrapped in div.ui-input-text" );
});
test( "slider is enabled/disabled correctly", function() {
var slider = $( "#disable-test" ),
track = slider.siblings( "div" );
testDisabled = function( prefix, expectedDisabled ) {
deepEqual( !!track.attr( "aria-disabled" ), expectedDisabled,
prefix + "'aria-disabled' is " + expectedDisabled );
deepEqual( !!slider.attr( "disabled" ), expectedDisabled,
prefix + "'disabled' property is " + expectedDisabled );
deepEqual( track.hasClass( "ui-state-disabled" ), expectedDisabled,
prefix + "track class 'ui-state-disabled' is " +
( expectedDisabled ? "on" : "off" ) );
};
testDisabled( "Initially: ", false );
slider.slider( "option", "disabled", true );
testDisabled( "After setting option 'disabled' to true: ", true );
slider.slider( "option", "disabled", true );
testDisabled( "After setting option 'disabled' to true a second time: ", true );
});
test( "refresh is triggered on mouseup", function() {
expect( 1 );
var slider = $( "#mouseup-refresh" );

0 comments on commit dfc5d32

Please sign in to comment.