2 * jQuery UI Progressbar 1.8.21
4 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
5 * Dual licensed under the MIT or GPL Version 2 licenses.
6 * http://jquery.org/license
8 * http://docs.jquery.com/UI/Progressbar
14 (function( $, undefined ) {
16 $.widget( "ui.progressbar", {
26 .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
29 "aria-valuemin": this.min
,
30 "aria-valuemax": this.options
.max
,
31 "aria-valuenow": this._value()
34 this.valueDiv
= $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
35 .appendTo( this.element
);
37 this.oldValue
= this._value();
43 .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
45 .removeAttr( "aria-valuemin" )
46 .removeAttr( "aria-valuemax" )
47 .removeAttr( "aria-valuenow" );
49 this.valueDiv
.remove();
51 $.Widget
.prototype.destroy
.apply( this, arguments
);
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 $.Widget
.prototype._setOption
.apply( this, arguments
);
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 var 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
);
105 $.extend( $.ui
.progressbar
, {