aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.progressbar.js
diff options
context:
space:
mode:
authorKris Borchers <kris.borchers@gmail.com>2012-11-29 22:12:02 -0600
committerKris Borchers <kris.borchers@gmail.com>2012-11-29 22:13:39 -0600
commitf2ee4c51aa919c7bc3db9f93a4f79479ef062bf9 (patch)
tree58047e936f977efc951fd73f8a305de0a7cab85b /ui/jquery.ui.progressbar.js
parentd7bff010691b542d918245bac11beac2b93b3462 (diff)
downloadjquery-ui-f2ee4c51aa919c7bc3db9f93a4f79479ef062bf9.tar.gz
jquery-ui-f2ee4c51aa919c7bc3db9f93a4f79479ef062bf9.zip
Progressbar: Create and destroy indeterminate overlay as needed and code cleanup.
Diffstat (limited to 'ui/jquery.ui.progressbar.js')
-rw-r--r--ui/jquery.ui.progressbar.js40
1 files changed, 23 insertions, 17 deletions
diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js
index 0b1ee8aba..0f97bc3fe 100644
--- a/ui/jquery.ui.progressbar.js
+++ b/ui/jquery.ui.progressbar.js
@@ -36,7 +36,7 @@ $.widget( "ui.progressbar", {
"aria-valuenow": this.options.value
});
- this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'><div></div></div>" )
+ this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
.appendTo( this.element );
this.oldValue = this.options.value;
@@ -114,11 +114,29 @@ $.widget( "ui.progressbar", {
_refreshValue: function() {
var value = this.options.value,
- percentage = this._percentage(),
- overlay = this.valueDiv.children().eq( 0 );
+ percentage = this._percentage();
- overlay.toggleClass( "ui-progressbar-overlay", this.indeterminate );
- this.valueDiv.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
+ this.valueDiv
+ .toggle( this.indeterminate || value > this.min )
+ .toggleClass( "ui-corner-right", value === this.options.max )
+ .toggleClass( "ui-progressbar-indeterminate", this.indeterminate )
+ .width( percentage.toFixed(0) + "%" );
+
+ if ( this.indeterminate ) {
+ this.element.removeAttr( "aria-valuemax" ).removeAttr( "aria-valuenow" );
+ if ( !this.overlayDiv ) {
+ this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
+ }
+ } else {
+ this.element.attr({
+ "aria-valuemax": this.options.max,
+ "aria-valuenow": value
+ });
+ if ( this.overlayDiv ) {
+ this.overlayDiv.remove();
+ this.overlayDiv = null;
+ }
+ }
if ( this.oldValue !== value ) {
this.oldValue = value;
@@ -127,18 +145,6 @@ $.widget( "ui.progressbar", {
if ( value === this.options.max ) {
this._trigger( "complete" );
}
-
- this.valueDiv
- .toggle( this.indeterminate || value > this.min )
- .toggleClass( "ui-corner-right", value === this.options.max )
- .width( percentage.toFixed(0) + "%" );
- if ( this.indeterminate ) {
- this.element.removeAttr( "aria-valuemax" );
- this.element.removeAttr( "aria-valuenow" );
- } else {
- this.element.attr( "aria-valuemax", this.options.max );
- this.element.attr( "aria-valuenow", value );
- }
}
});