Progressbar: Style updates

Ref #14246
This commit is contained in:
Alexander Schmitz 2015-08-24 08:58:48 -04:00
parent 5850a5c755
commit 12be35562a
6 changed files with 41 additions and 39 deletions

View File

@ -19,6 +19,6 @@ common.testWidget( "progressbar", {
complete: null,
create: null
}
});
} );
} );

View File

@ -19,11 +19,11 @@ test( "markup structure", function( assert ) {
element.progressbar( "option", "value", 100 );
assert.hasClasses( value, "ui-progressbar-complete ui-widget-header ui-progressbar-value" );
equal( element.children().children().length, 0, "no overlay div" );
});
} );
test( "markup structure - indeterminate", function( assert ) {
expect( 5 );
var element = $( "#progressbar" ).progressbar({ value: false }),
var element = $( "#progressbar" ).progressbar( { value: false } ),
children = element.children();
assert.hasClasses( element, "ui-progressbar ui-progressbar-indeterminate ui-widget ui-widget-content" );
@ -32,7 +32,7 @@ test( "markup structure - indeterminate", function( assert ) {
assert.hasClasses( children[ 0 ], "ui-progressbar-value" );
equal( children.children( ".ui-progressbar-overlay" ).length, 1,
"Value has class ui-progressbar-overlay" );
});
} );
test( "accessibility", function() {
expect( 11 );
@ -59,6 +59,6 @@ test( "accessibility", function() {
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
equal( element.attr( "aria-valuenow" ), null, "aria-valuenow" );
});
} );
} );

View File

@ -7,7 +7,7 @@ module( "progressbar: events" );
test( "create", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
$( "#progressbar" ).progressbar( {
value: 5,
create: function() {
equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
@ -15,8 +15,8 @@ test( "create", function() {
change: function() {
ok( false, "create has triggered change()" );
}
});
});
} );
} );
test( "change", function() {
expect( 2 );
@ -24,19 +24,19 @@ test( "change", function() {
element.one( "progressbarchange", function() {
equal( element.progressbar( "value" ), 5, "change triggered for middle value" );
});
} );
element.progressbar( "value", 5 );
element.one( "progressbarchange", function() {
equal( element.progressbar( "value" ), 100, "change triggered for final value" );
});
} );
element.progressbar( "value", 100 );
});
} );
test( "complete", function() {
expect( 5 );
var value,
changes = 0,
element = $( "#progressbar" ).progressbar({
element = $( "#progressbar" ).progressbar( {
change: function() {
changes++;
equal( element.progressbar( "value" ), value, "change at " + value );
@ -45,7 +45,7 @@ test( "complete", function() {
equal( changes, 3, "complete triggered after change and not on indeterminate" );
equal( element.progressbar( "value" ), 100, "value is 100" );
}
});
} );
value = 5;
element.progressbar( "value", value );
@ -53,6 +53,6 @@ test( "complete", function() {
element.progressbar( "value", value );
value = 100;
element.progressbar( "value", value );
});
} );
} );

View File

@ -9,8 +9,8 @@ test( "destroy", function( assert ) {
expect( 1 );
assert.domEqual( "#progressbar", function() {
$( "#progressbar" ).progressbar().progressbar( "destroy" );
});
});
} );
} );
test( "disable", function( assert ) {
expect( 3 );
@ -20,16 +20,16 @@ test( "disable", function( assert ) {
assert.hasClasses( element.progressbar( "widget" ), "ui-state-disabled" );
ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" );
assert.hasClasses( element.progressbar( "widget" ), "ui-progressbar-disabled" );
});
} );
test( "value", function() {
expect( 3 );
var element = $( "<div>" ).progressbar({ value: 20 });
var element = $( "<div>" ).progressbar( { value: 20 } );
equal( element.progressbar( "value" ), 20, "correct value as getter" );
strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" );
equal( element.progressbar( "option", "value" ), 30, "correct value after setter" );
});
} );
test( "widget", function() {
expect( 2 );
@ -37,6 +37,6 @@ test( "widget", function() {
widgetElement = element.progressbar( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
});
} );
} );

View File

@ -9,14 +9,14 @@ test( "{ value: 0 }, default", function() {
expect( 1 );
$( "#progressbar" ).progressbar();
equal( $( "#progressbar" ).progressbar( "value" ), 0 );
});
} );
// Ticket #7231 - valueDiv should be hidden when value is at 0%
test( "value: visibility of valueDiv", function() {
expect( 4 );
var element = $( "#progressbar" ).progressbar({
var element = $( "#progressbar" ).progressbar( {
value: 0
});
} );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is initialized at 0" );
element.progressbar( "value", 1 );
@ -28,52 +28,52 @@ test( "value: visibility of valueDiv", function() {
element.progressbar( "value", 0 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is set to 0" );
});
} );
test( "{ value: 5 }", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
$( "#progressbar" ).progressbar( {
value: 5
});
} );
equal( $( "#progressbar" ).progressbar( "value" ), 5 );
});
} );
test( "{ value: -5 }", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
$( "#progressbar" ).progressbar( {
value: -5
});
} );
equal( $( "#progressbar" ).progressbar( "value" ), 0,
"value constrained at min" );
});
} );
test( "{ value: 105 }", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
$( "#progressbar" ).progressbar( {
value: 105
});
} );
equal( $( "#progressbar" ).progressbar( "value" ), 100,
"value constrained at max" );
});
} );
test( "{ value: 10, max: 5 }", function() {
expect( 1 );
$("#progressbar").progressbar({
$( "#progressbar" ).progressbar( {
max: 5,
value: 10
});
} );
equal( $( "#progressbar" ).progressbar( "value" ), 5,
"value constrained at max" );
});
} );
test( "change max below value", function() {
expect( 1 );
$("#progressbar").progressbar({
$( "#progressbar" ).progressbar( {
max: 10,
value: 10
}).progressbar( "option", "max", 5 );
} ).progressbar( "option", "max", 5 );
equal( $( "#progressbar" ).progressbar( "value" ), 5,
"value constrained at max" );
});
} );
} );

View File

@ -100,6 +100,7 @@ return $.widget( "ui.progressbar", {
},
_setOptions: function( options ) {
// Ensure "value" option is set after other values (like max)
var value = options.value;
delete options.value;
@ -112,6 +113,7 @@ return $.widget( "ui.progressbar", {
_setOption: function( key, value ) {
if ( key === "max" ) {
// Don't allow a max less than min
value = Math.max( this.min, value );
}