@@ -28,7 +28,7 @@ $.widget( "ui.progressbar", {
28
28
29
29
_create : function ( ) {
30
30
// Constrain initial value
31
- this . options . value = this . _constrainedValue ( ) ;
31
+ this . oldValue = this . options . value = this . _constrainedValue ( ) ;
32
32
33
33
this . element
34
34
. addClass ( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
@@ -42,7 +42,6 @@ $.widget( "ui.progressbar", {
42
42
this . valueDiv = $ ( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
43
43
. appendTo ( this . element ) ;
44
44
45
- this . oldValue = this . options . value ;
46
45
this . _refreshValue ( ) ;
47
46
} ,
48
47
@@ -62,53 +61,44 @@ $.widget( "ui.progressbar", {
62
61
return this . options . value ;
63
62
}
64
63
65
- this . _setOption ( " value" , this . _constrainedValue ( newValue ) ) ;
66
- return this ;
64
+ this . options . value = this . _constrainedValue ( newValue ) ;
65
+ this . _refreshValue ( ) ;
67
66
} ,
68
67
69
68
_constrainedValue : function ( newValue ) {
70
- var val ;
71
69
if ( newValue === undefined ) {
72
- val = this . options . value ;
73
- } else {
74
- val = newValue ;
70
+ newValue = this . options . value ;
75
71
}
76
72
77
- this . indeterminate = val === false ;
73
+ this . indeterminate = newValue === false ;
78
74
79
75
// sanitize value
80
- if ( typeof val !== "number" ) {
81
- val = 0 ;
76
+ if ( typeof newValue !== "number" ) {
77
+ newValue = 0 ;
82
78
}
83
- return this . indeterminate ? false : Math . min ( this . options . max , Math . max ( this . min , val ) ) ;
79
+
80
+ return this . indeterminate ? false :
81
+ Math . min ( this . options . max , Math . max ( this . min , newValue ) ) ;
84
82
} ,
85
83
86
84
_setOptions : function ( options ) {
87
- var val = options . value ;
88
-
89
85
// Ensure "value" option is set after other values (like max)
86
+ var value = options . value ;
90
87
delete options . value ;
88
+
91
89
this . _super ( options ) ;
92
90
93
- if ( val !== undefined ) {
94
- this . _setOption ( "value" , val ) ;
95
- }
91
+ this . options . value = this . _constrainedValue ( value ) ;
92
+ this . _refreshValue ( ) ;
96
93
} ,
97
94
98
95
_setOption : function ( key , value ) {
99
96
if ( key === "max" ) {
100
97
// Don't allow a max less than min
101
- this . options . max = Math . max ( this . min , value ) ;
102
- this . options . value = this . _constrainedValue ( ) ;
103
- }
104
- if ( key === "value" ) {
105
- this . options . value = this . _constrainedValue ( value ) ;
106
- }
107
- else {
108
- this . _super ( key , value ) ;
98
+ value = Math . max ( this . min , value ) ;
109
99
}
110
100
111
- this . _refreshValue ( ) ;
101
+ this . _super ( key , value ) ;
112
102
} ,
113
103
114
104
_percentage : function ( ) {
0 commit comments