2 * jQuery UI Progressbar 1.9.2
5 * Copyright 2012 jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
9 * http://api.jqueryui.com/progressbar/
15 (function( $, undefined ) {
17 $.widget( "ui.progressbar", {
28 .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
31 "aria-valuemin": this.min
,
32 "aria-valuemax": this.options
.max
,
33 "aria-valuenow": this._value()
36 this.valueDiv
= $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
37 .appendTo( this.element
);
39 this.oldValue
= this._value();
43 _destroy: function() {
45 .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
47 .removeAttr( "aria-valuemin" )
48 .removeAttr( "aria-valuemax" )
49 .removeAttr( "aria-valuenow" );
51 this.valueDiv
.remove();
54 value: function( newValue
) {
55 if ( newValue
=== undefined ) {
59 this._setOption( "value", newValue
);
63 _setOption: function( key
, value
) {
64 if ( key
=== "value" ) {
65 this.options
.value
= value
;
67 if ( this._value() === this.options
.max
) {
68 this._trigger( "complete" );
72 this._super( key
, value
);
76 var val
= this.options
.value
;
77 // normalize invalid value
78 if ( typeof val
!== "number" ) {
81 return Math
.min( this.options
.max
, Math
.max( this.min
, val
) );
84 _percentage: function() {
85 return 100 * this._value() / this.options
.max
;
88 _refreshValue: function() {
89 var value
= this.value(),
90 percentage
= this._percentage();
92 if ( this.oldValue
!== value
) {
93 this.oldValue
= value
;
94 this._trigger( "change" );
98 .toggle( value
> this.min
)
99 .toggleClass( "ui-corner-right", value
=== this.options
.max
)
100 .width( percentage
.toFixed(0) + "%" );
101 this.element
.attr( "aria-valuenow", value
);