27
27
return $ . widget ( "ui.progressbar" , {
28
28
version : "@VERSION" ,
29
29
options : {
30
+ classes : {
31
+ "ui-progressbar" : "ui-corner-all" ,
32
+ "ui-progressbar-value" : "ui-corner-left" ,
33
+ "ui-progressbar-complete" : "ui-corner-right"
34
+ } ,
30
35
max : 100 ,
31
36
value : 0 ,
32
37
@@ -40,24 +45,21 @@ return $.widget( "ui.progressbar", {
40
45
// Constrain initial value
41
46
this . oldValue = this . options . value = this . _constrainedValue ( ) ;
42
47
43
- this . element
44
- . addClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
45
- . attr ( {
48
+ this . element . attr ( {
46
49
// Only set static values, aria-valuenow and aria-valuemax are
47
50
// set inside _refreshValue()
48
51
role : "progressbar" ,
49
52
"aria-valuemin" : this . min
50
53
} ) ;
54
+ this . _addClass ( "ui-progressbar" , "ui-widget ui-widget-content" ) ;
51
55
52
- this . valueDiv = $ ( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
53
- . appendTo ( this . element ) ;
54
-
56
+ this . valueDiv = $ ( "<div>" ) . appendTo ( this . element ) ;
57
+ this . _addClass ( this . valueDiv , "ui-progressbar-value" , "ui-widget-header" ) ;
55
58
this . _refreshValue ( ) ;
56
59
} ,
57
60
58
61
_destroy : function ( ) {
59
62
this . element
60
- . removeClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
61
63
. removeAttr ( "role" )
62
64
. removeAttr ( "aria-valuemin" )
63
65
. removeAttr ( "aria-valuemax" )
@@ -108,9 +110,8 @@ return $.widget( "ui.progressbar", {
108
110
value = Math . max ( this . min , value ) ;
109
111
}
110
112
if ( key === "disabled" ) {
111
- this . element
112
- . toggleClass ( "ui-state-disabled" , ! ! value )
113
- . attr ( "aria-disabled" , value ) ;
113
+ this . element . attr ( "aria-disabled" , value ) ;
114
+ this . _toggleClass ( null , "ui-state-disabled" , ! ! value ) ;
114
115
}
115
116
this . _super ( key , value ) ;
116
117
} ,
@@ -125,15 +126,17 @@ return $.widget( "ui.progressbar", {
125
126
126
127
this . valueDiv
127
128
. toggle ( this . indeterminate || value > this . min )
128
- . toggleClass ( "ui-corner-right" , value === this . options . max )
129
129
. width ( percentage . toFixed ( 0 ) + "%" ) ;
130
130
131
- this . element . toggleClass ( "ui-progressbar-indeterminate" , this . indeterminate ) ;
131
+ this . _toggleClass ( this . valueDiv , "ui-progressbar-complete" , null ,
132
+ value === this . options . max )
133
+ . _toggleClass ( "ui-progressbar-indeterminate" , null , this . indeterminate ) ;
132
134
133
135
if ( this . indeterminate ) {
134
136
this . element . removeAttr ( "aria-valuenow" ) ;
135
137
if ( ! this . overlayDiv ) {
136
- this . overlayDiv = $ ( "<div class='ui-progressbar-overlay'></div>" ) . appendTo ( this . valueDiv ) ;
138
+ this . overlayDiv = $ ( "<div>" ) . appendTo ( this . valueDiv ) ;
139
+ this . _addClass ( this . overlayDiv , "ui-progressbar-overlay" ) ;
137
140
}
138
141
} else {
139
142
this . element . attr ( {
0 commit comments