@@ -17,13 +17,17 @@ $.widget( "ui.progressbar", {
1717 options : {
1818 value : 0
1919 } ,
20+
21+ min : 0 ,
22+ max : 100 ,
23+
2024 _create : function ( ) {
2125 this . element
2226 . addClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
2327 . attr ( {
2428 role : "progressbar" ,
25- "aria-valuemin" : this . _valueMin ( ) ,
26- "aria-valuemax" : this . _valueMax ( ) ,
29+ "aria-valuemin" : this . min ,
30+ "aria-valuemax" : this . max ,
2731 "aria-valuenow" : this . _value ( )
2832 } ) ;
2933
@@ -56,12 +60,10 @@ $.widget( "ui.progressbar", {
5660 } ,
5761
5862 _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" ) ;
6567 }
6668
6769 $ . Widget . prototype . _setOption . apply ( this , arguments ) ;
@@ -73,28 +75,13 @@ $.widget( "ui.progressbar", {
7375 if ( typeof val !== "number" ) {
7476 val = 0 ;
7577 }
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 ) ) ;
9279 } ,
9380
9481 _refreshValue : function ( ) {
9582 var value = this . value ( ) ;
9683 this . valueDiv
97- [ value === this . _valueMax ( ) ? "addClass" : "removeClass" ] ( " ui-corner-right" )
84+ . toggleClass ( " ui-corner-right", value === this . max )
9885 . width ( value + "%" ) ;
9986 this . element . attr ( "aria-valuenow" , value ) ;
10087 }
0 commit comments