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, complete: null,
create: null create: null
} }
}); } );
} ); } );

View File

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

View File

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

View File

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

View File

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

View File

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