Permalink
Browse files

Progressbar: Add ability to set value: false for an indeterminate pro…

…gressbar. Fixes #7624 - Progressbar: Support value: false for indeterminate progressbar
  • Loading branch information...
1 parent adbc273 commit 7b482b6e0770061112758a313b7a66f9b054f469 @kborchers committed Mar 27, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -8,4 +8,5 @@
* http://docs.jquery.com/UI/Progressbar#theming
*/
.ui-progressbar { height:2em; text-align: left; overflow: hidden; }
-.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
+.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
+.ui-progressbar .ui-progressbar-animated { background: url("images/ui-bg_animated_progress_50x50.gif"); }
@@ -16,7 +16,7 @@
$.widget( "ui.progressbar", {
version: "@VERSION",
options: {
- value: 0,
+ value: false,
max: 100
},
@@ -35,7 +35,12 @@ $.widget( "ui.progressbar", {
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
.appendTo( this.element );
- this.oldValue = this._value();
+ if ( this.options.value !== false ) {
+ this.oldValue = this._value();
+ } else {
+ this.oldValue = false;
+ this.valueDiv.addClass( "ui-progressbar-animated" );
+ }
this._refreshValue();
},
@@ -62,6 +67,11 @@ $.widget( "ui.progressbar", {
_setOption: function( key, value ) {
if ( key === "value" ) {
this.options.value = value;
+ if ( value !== false ) {
+ this.valueDiv.removeClass( "ui-progressbar-animated" );
+ } else {
+ this.valueDiv.addClass( "ui-progressbar-animated" );
+ }
this._refreshValue();
if ( this._value() === this.options.max ) {
this._trigger( "complete" );
@@ -74,8 +84,10 @@ $.widget( "ui.progressbar", {
_value: function() {
var val = this.options.value;
// normalize invalid value
- if ( typeof val !== "number" ) {
+ if ( typeof val !== "number" && val !== false ) {
val = 0;
+ } else if( val === false ) {
+ val = 100;
}
return Math.min( this.options.max, Math.max( this.min, val ) );
},

0 comments on commit 7b482b6

Please sign in to comment.