Skip to content

Commit f761470

Browse files
committed
Progressbar: Cleanup, byte shaving.
1 parent 9d0df53 commit f761470

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

tests/unit/progressbar/progressbar_core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ test( "accessibility", function() {
2424
element.progressbar( "option", "value", false );
2525
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
2626
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
27-
strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow initially" );
27+
strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow" );
2828
});

ui/jquery.ui.progressbar.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $.widget( "ui.progressbar", {
2828

2929
_create: function() {
3030
// Constrain initial value
31-
this.options.value = this._constrainedValue();
31+
this.oldValue = this.options.value = this._constrainedValue();
3232

3333
this.element
3434
.addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
@@ -42,7 +42,6 @@ $.widget( "ui.progressbar", {
4242
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
4343
.appendTo( this.element );
4444

45-
this.oldValue = this.options.value;
4645
this._refreshValue();
4746
},
4847

@@ -62,53 +61,44 @@ $.widget( "ui.progressbar", {
6261
return this.options.value;
6362
}
6463

65-
this._setOption( "value", this._constrainedValue( newValue ) );
66-
return this;
64+
this.options.value = this._constrainedValue( newValue );
65+
this._refreshValue();
6766
},
6867

6968
_constrainedValue: function( newValue ) {
70-
var val;
7169
if ( newValue === undefined ) {
72-
val = this.options.value;
73-
} else {
74-
val = newValue;
70+
newValue = this.options.value;
7571
}
7672

77-
this.indeterminate = val === false;
73+
this.indeterminate = newValue === false;
7874

7975
// sanitize value
80-
if ( typeof val !== "number" ) {
81-
val = 0;
76+
if ( typeof newValue !== "number" ) {
77+
newValue = 0;
8278
}
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 ) );
8482
},
8583

8684
_setOptions: function( options ) {
87-
var val = options.value;
88-
8985
// Ensure "value" option is set after other values (like max)
86+
var value = options.value;
9087
delete options.value;
88+
9189
this._super( options );
9290

93-
if ( val !== undefined ) {
94-
this._setOption( "value", val );
95-
}
91+
this.options.value = this._constrainedValue( value );
92+
this._refreshValue();
9693
},
9794

9895
_setOption: function( key, value ) {
9996
if ( key === "max" ) {
10097
// 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 );
10999
}
110100

111-
this._refreshValue();
101+
this._super( key, value );
112102
},
113103

114104
_percentage: function() {

0 commit comments

Comments
 (0)