@@ -36,7 +36,7 @@ $.widget( "ui.progressbar", {
3636 "aria-valuenow" : this . options . value
3737 } ) ;
3838
39- this . valueDiv = $ ( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
39+ this . valueDiv = $ ( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'><div></div>< /div>" )
4040 . appendTo ( this . element ) ;
4141
4242 this . oldValue = this . options . value ;
@@ -71,16 +71,19 @@ $.widget( "ui.progressbar", {
7171 val = newValue ;
7272 }
7373
74+ this . indeterminate = val === false ;
75+
7476 // sanitize value
7577 if ( typeof val !== "number" ) {
7678 val = 0 ;
7779 }
78- return Math . min ( this . options . max , Math . max ( this . min , val ) ) ;
80+ return this . indeterminate ? false : Math . min ( this . options . max , Math . max ( this . min , val ) ) ;
7981 } ,
8082
8183 _setOptions : function ( options ) {
8284 var val = options . value ;
8385
86+ // Ensure "value" option is set after other values (like max)
8487 delete options . value ;
8588 this . _super ( options ) ;
8689
@@ -106,26 +109,36 @@ $.widget( "ui.progressbar", {
106109 } ,
107110
108111 _percentage : function ( ) {
109- return 100 * this . options . value / this . options . max ;
112+ return this . indeterminate ? 100 : 100 * this . options . value / this . options . max ;
110113 } ,
111114
112115 _refreshValue : function ( ) {
113- var percentage = this . _percentage ( ) ;
116+ var value = this . options . value ,
117+ percentage = this . _percentage ( ) ,
118+ overlay = this . valueDiv . children ( ) . eq ( 0 ) ;
119+
120+ overlay . toggleClass ( "ui-progressbar-overlay" , this . indeterminate ) ;
121+ this . valueDiv . toggleClass ( "ui-progressbar-indeterminate" , this . indeterminate ) ;
114122
115- if ( this . oldValue !== this . options . value ) {
116- this . oldValue = this . options . value ;
123+ if ( this . oldValue !== value ) {
124+ this . oldValue = value ;
117125 this . _trigger ( "change" ) ;
118126 }
119- if ( this . options . value === this . options . max ) {
127+ if ( value === this . options . max ) {
120128 this . _trigger ( "complete" ) ;
121129 }
122130
123131 this . valueDiv
124- . toggle ( this . options . value > this . min )
125- . toggleClass ( "ui-corner-right" , this . options . value === this . options . max )
132+ . toggle ( this . indeterminate || value > this . min )
133+ . toggleClass ( "ui-corner-right" , value === this . options . max )
126134 . width ( percentage . toFixed ( 0 ) + "%" ) ;
127- this . element . attr ( "aria-valuemax" , this . options . max ) ;
128- this . element . attr ( "aria-valuenow" , this . options . value ) ;
135+ if ( this . indeterminate ) {
136+ this . element . removeAttr ( "aria-valuemax" ) ;
137+ this . element . removeAttr ( "aria-valuenow" ) ;
138+ } else {
139+ this . element . attr ( "aria-valuemax" , this . options . max ) ;
140+ this . element . attr ( "aria-valuenow" , value ) ;
141+ }
129142 }
130143} ) ;
131144
0 commit comments