complete: null,
create: null
}
-});
+} );
} );
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" );
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 );
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
equal( element.attr( "aria-valuenow" ), null, "aria-valuenow" );
-});
+} );
} );
test( "create", function() {
expect( 1 );
- $( "#progressbar" ).progressbar({
+ $( "#progressbar" ).progressbar( {
value: 5,
create: function() {
equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
change: function() {
ok( false, "create has triggered change()" );
}
- });
-});
+ } );
+} );
test( "change", function() {
expect( 2 );
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 );
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 );
element.progressbar( "value", value );
value = 100;
element.progressbar( "value", value );
-});
+} );
} );
expect( 1 );
assert.domEqual( "#progressbar", function() {
$( "#progressbar" ).progressbar().progressbar( "destroy" );
- });
-});
+ } );
+} );
test( "disable", function( assert ) {
expect( 3 );
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 );
widgetElement = element.progressbar( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
-});
+} );
} );
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 );
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" );
-});
+} );
} );
},
_setOptions: function( options ) {
+
// Ensure "value" option is set after other values (like max)
var value = options.value;
delete options.value;
_setOption: function( key, value ) {
if ( key === "max" ) {
+
// Don't allow a max less than min
value = Math.max( this.min, value );
}