diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-07-29 05:38:24 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-07-29 05:38:24 -0400 |
commit | f00c03139bf83e573b60376a146ae4584c5f5d17 (patch) | |
tree | 4eca10b09d8e6a040a5ee168e95e5c8ee97d574a /ui/jquery.ui.progressbar.js | |
parent | ee1f5b54de149e10444ba7a3c4084173e851a7a2 (diff) | |
download | jquery-ui-f00c03139bf83e573b60376a146ae4584c5f5d17.tar.gz jquery-ui-f00c03139bf83e573b60376a146ae4584c5f5d17.zip |
Progressbar: cleanup.
Diffstat (limited to 'ui/jquery.ui.progressbar.js')
-rw-r--r-- | ui/jquery.ui.progressbar.js | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index c19860d05..e0b728f1a 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -17,13 +17,17 @@ $.widget( "ui.progressbar", { options: { value: 0 }, + + min: 0, + max: 100, + _create: function() { this.element .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) .attr({ role: "progressbar", - "aria-valuemin": this._valueMin(), - "aria-valuemax": this._valueMax(), + "aria-valuemin": this.min, + "aria-valuemax": this.max, "aria-valuenow": this._value() }); @@ -56,12 +60,10 @@ $.widget( "ui.progressbar", { }, _setOption: function( key, value ) { - switch ( key ) { - case "value": - this.options.value = value; - this._refreshValue(); - this._trigger( "change" ); - break; + if ( key === "value" ) { + this.options.value = value; + this._refreshValue(); + this._trigger( "change" ); } $.Widget.prototype._setOption.apply( this, arguments ); @@ -73,28 +75,13 @@ $.widget( "ui.progressbar", { if ( typeof val !== "number" ) { val = 0; } - if ( val < this._valueMin() ) { - val = this._valueMin(); - } - if ( val > this._valueMax() ) { - val = this._valueMax(); - } - - return val; - }, - - _valueMin: function() { - return 0; - }, - - _valueMax: function() { - return 100; + return Math.min( this.max, Math.max( this.min, val ) ); }, _refreshValue: function() { var value = this.value(); this.valueDiv - [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" ) + .toggleClass( "ui-corner-right", value === this.max ) .width( value + "%" ); this.element.attr( "aria-valuenow", value ); } |