Merge "Add ss_active_users in SiteStats::isSane"
[mediawiki.git] / resources / jquery.ui / jquery.ui.progressbar.js
blob7cea1baafe4be98ee634711d2948f4c22801c4f7
1 /*!
2  * jQuery UI Progressbar 1.8.24
3  *
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
7  *
8  * http://docs.jquery.com/UI/Progressbar
9  *
10  * Depends:
11  *   jquery.ui.core.js
12  *   jquery.ui.widget.js
13  */
14 (function( $, undefined ) {
16 $.widget( "ui.progressbar", {
17         options: {
18                 value: 0,
19                 max: 100
20         },
22         min: 0,
24         _create: function() {
25                 this.element
26                         .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
27                         .attr({
28                                 role: "progressbar",
29                                 "aria-valuemin": this.min,
30                                 "aria-valuemax": this.options.max,
31                                 "aria-valuenow": this._value()
32                         });
34                 this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
35                         .appendTo( this.element );
37                 this.oldValue = this._value();
38                 this._refreshValue();
39         },
41         destroy: function() {
42                 this.element
43                         .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
44                         .removeAttr( "role" )
45                         .removeAttr( "aria-valuemin" )
46                         .removeAttr( "aria-valuemax" )
47                         .removeAttr( "aria-valuenow" );
49                 this.valueDiv.remove();
51                 $.Widget.prototype.destroy.apply( this, arguments );
52         },
54         value: function( newValue ) {
55                 if ( newValue === undefined ) {
56                         return this._value();
57                 }
59                 this._setOption( "value", newValue );
60                 return this;
61         },
63         _setOption: function( key, value ) {
64                 if ( key === "value" ) {
65                         this.options.value = value;
66                         this._refreshValue();
67                         if ( this._value() === this.options.max ) {
68                                 this._trigger( "complete" );
69                         }
70                 }
72                 $.Widget.prototype._setOption.apply( this, arguments );
73         },
75         _value: function() {
76                 var val = this.options.value;
77                 // normalize invalid value
78                 if ( typeof val !== "number" ) {
79                         val = 0;
80                 }
81                 return Math.min( this.options.max, Math.max( this.min, val ) );
82         },
84         _percentage: function() {
85                 return 100 * this._value() / this.options.max;
86         },
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" );
95                 }
97                 this.valueDiv
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 );
102         }
105 $.extend( $.ui.progressbar, {
106         version: "1.8.24"
109 })( jQuery );