]> source.dussan.org Git - jquery-ui.git/commitdiff
Progressbar: Cleanup, byte shaving.
authorScott González <scott.gonzalez@gmail.com>
Thu, 6 Dec 2012 15:10:07 +0000 (10:10 -0500)
committerScott González <scott.gonzalez@gmail.com>
Thu, 6 Dec 2012 15:10:07 +0000 (10:10 -0500)
tests/unit/progressbar/progressbar_core.js
ui/jquery.ui.progressbar.js

index 54a33cc9d7da0d3613d223ee88a137b0c43eec89..cffd84d2111865dde2c6be4ca954439ba2cc4b84 100644 (file)
@@ -24,5 +24,5 @@ test( "accessibility", function() {
        element.progressbar( "option", "value", false );
        equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
        equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
-       strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow initially" );
+       strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow" );
 });
index 348f1d0610313bcb2cf6bfcb9ad347ec4b447bb0..46051d2c927167835c4f38c79115926bca7fb595 100644 (file)
@@ -28,7 +28,7 @@ $.widget( "ui.progressbar", {
 
        _create: function() {
                // Constrain initial value
-               this.options.value = this._constrainedValue();
+               this.oldValue = this.options.value = this._constrainedValue();
 
                this.element
                        .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
@@ -42,7 +42,6 @@ $.widget( "ui.progressbar", {
                this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
                        .appendTo( this.element );
 
-               this.oldValue = this.options.value;
                this._refreshValue();
        },
 
@@ -62,53 +61,44 @@ $.widget( "ui.progressbar", {
                        return this.options.value;
                }
 
-               this._setOption( "value", this._constrainedValue( newValue ) );
-               return this;
+               this.options.value = this._constrainedValue( newValue );
+               this._refreshValue();
        },
 
        _constrainedValue: function( newValue ) {
-               var val;
                if ( newValue === undefined ) {
-                       val = this.options.value;
-               } else {
-                       val = newValue;
+                       newValue = this.options.value;
                }
 
-               this.indeterminate = val === false;
+               this.indeterminate = newValue === false;
 
                // sanitize value
-               if ( typeof val !== "number" ) {
-                       val = 0;
+               if ( typeof newValue !== "number" ) {
+                       newValue = 0;
                }
-               return this.indeterminate ? false : Math.min( this.options.max, Math.max( this.min, val ) );
+
+               return this.indeterminate ? false :
+                       Math.min( this.options.max, Math.max( this.min, newValue ) );
        },
 
        _setOptions: function( options ) {
-               var val = options.value;
-
                // Ensure "value" option is set after other values (like max)
+               var value = options.value;
                delete options.value;
+
                this._super( options );
 
-               if ( val !== undefined ) {
-                       this._setOption( "value", val );
-               }
+               this.options.value = this._constrainedValue( value );
+               this._refreshValue();
        },
 
        _setOption: function( key, value ) {
                if ( key === "max" ) {
                        // Don't allow a max less than min
-                       this.options.max = Math.max( this.min, value );
-                       this.options.value = this._constrainedValue();
-               }
-               if ( key === "value" ) {
-                       this.options.value = this._constrainedValue( value );
-               }
-               else {
-                       this._super( key, value );
+                       value = Math.max( this.min, value );
                }
 
-               this._refreshValue();
+               this._super( key, value );
        },
 
        _percentage: function() {