@@ -17,13 +17,17 @@ $.widget( "ui.progressbar", {
17
17
options : {
18
18
value : 0
19
19
} ,
20
+
21
+ min : 0 ,
22
+ max : 100 ,
23
+
20
24
_create : function ( ) {
21
25
this . element
22
26
. addClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
23
27
. attr ( {
24
28
role : "progressbar" ,
25
- "aria-valuemin" : this . _valueMin ( ) ,
26
- "aria-valuemax" : this . _valueMax ( ) ,
29
+ "aria-valuemin" : this . min ,
30
+ "aria-valuemax" : this . max ,
27
31
"aria-valuenow" : this . _value ( )
28
32
} ) ;
29
33
@@ -56,12 +60,10 @@ $.widget( "ui.progressbar", {
56
60
} ,
57
61
58
62
_setOption : function ( key , value ) {
59
- switch ( key ) {
60
- case "value" :
61
- this . options . value = value ;
62
- this . _refreshValue ( ) ;
63
- this . _trigger ( "change" ) ;
64
- break ;
63
+ if ( key === "value" ) {
64
+ this . options . value = value ;
65
+ this . _refreshValue ( ) ;
66
+ this . _trigger ( "change" ) ;
65
67
}
66
68
67
69
$ . Widget . prototype . _setOption . apply ( this , arguments ) ;
@@ -73,28 +75,13 @@ $.widget( "ui.progressbar", {
73
75
if ( typeof val !== "number" ) {
74
76
val = 0 ;
75
77
}
76
- if ( val < this . _valueMin ( ) ) {
77
- val = this . _valueMin ( ) ;
78
- }
79
- if ( val > this . _valueMax ( ) ) {
80
- val = this . _valueMax ( ) ;
81
- }
82
-
83
- return val ;
84
- } ,
85
-
86
- _valueMin : function ( ) {
87
- return 0 ;
88
- } ,
89
-
90
- _valueMax : function ( ) {
91
- return 100 ;
78
+ return Math . min ( this . max , Math . max ( this . min , val ) ) ;
92
79
} ,
93
80
94
81
_refreshValue : function ( ) {
95
82
var value = this . value ( ) ;
96
83
this . valueDiv
97
- [ value === this . _valueMax ( ) ? "addClass" : "removeClass" ] ( " ui-corner-right" )
84
+ . toggleClass ( " ui-corner-right", value === this . max )
98
85
. width ( value + "%" ) ;
99
86
this . element . attr ( "aria-valuenow" , value ) ;
100
87
}
0 commit comments