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-overlay" : "" ,
34
+ "ui-progressbar-indeterminate" : "" ,
35
+ "ui-progressbar-complete" : "ui-corner-right"
36
+ } ,
30
37
max : 100 ,
31
38
value : 0 ,
32
39
@@ -40,29 +47,28 @@ return $.widget( "ui.progressbar", {
40
47
// Constrain initial value
41
48
this . oldValue = this . options . value = this . _constrainedValue ( ) ;
42
49
43
- this . element
44
- . addClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
45
- . attr ( {
50
+ this . element . attr ( {
46
51
// Only set static values, aria-valuenow and aria-valuemax are
47
52
// set inside _refreshValue()
48
53
role : "progressbar" ,
49
54
"aria-valuemin" : this . min
50
55
} ) ;
56
+ this . _addClass ( "ui-progressbar" , "ui-widget ui-widget-content" ) ;
51
57
52
- this . valueDiv = $ ( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
53
- . appendTo ( this . element ) ;
54
-
58
+ this . valueDiv = $ ( "<div>" ) . appendTo ( this . element ) ;
59
+ this . _addClass ( this . valueDiv , "ui-progressbar-value" , "ui-widget-header" ) ;
55
60
this . _refreshValue ( ) ;
56
61
} ,
57
62
58
63
_destroy : function ( ) {
59
64
this . element
60
- . removeClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
61
65
. removeAttr ( "role" )
62
66
. removeAttr ( "aria-valuemin" )
63
67
. removeAttr ( "aria-valuemax" )
64
68
. removeAttr ( "aria-valuenow" ) ;
65
69
70
+ this . _removeClass ( "ui-progressbar" , "ui-widget ui-widget-content" ) ;
71
+
66
72
this . valueDiv . remove ( ) ;
67
73
} ,
68
74
@@ -125,15 +131,19 @@ return $.widget( "ui.progressbar", {
125
131
126
132
this . valueDiv
127
133
. toggle ( this . indeterminate || value > this . min )
128
- . toggleClass ( "ui-corner-right" , value === this . options . max )
129
134
. width ( percentage . toFixed ( 0 ) + "%" ) ;
130
135
131
- this . element . toggleClass ( "ui-progressbar-indeterminate" , this . indeterminate ) ;
136
+ this [ ( ( value === this . options . max ) ? "_add" : "_remove" ) + "Class" ]
137
+ ( this . valueDiv , "ui-progressbar-complete" ) ;
138
+
139
+ this [ ( this . indeterminate ? "_add" : "_remove" ) + "Class" ]
140
+ ( "ui-progressbar-indeterminate" ) ;
132
141
133
142
if ( this . indeterminate ) {
134
143
this . element . removeAttr ( "aria-valuenow" ) ;
135
144
if ( ! this . overlayDiv ) {
136
- this . overlayDiv = $ ( "<div class='ui-progressbar-overlay'></div>" ) . appendTo ( this . valueDiv ) ;
145
+ this . overlayDiv = $ ( "<div>" ) . appendTo ( this . valueDiv ) ;
146
+ this . _addClass ( this . overlayDiv , "ui-progressbar-overlay" ) ;
137
147
}
138
148
} else {
139
149
this . element . attr ( {
0 commit comments