More ancient deprecated functions:
[lhc/web/wiklou.git] / resources / jquery.ui / jquery.ui.progressbar.js
1 /*
2 * jQuery UI Progressbar 1.8.2
3 *
4 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
5 * Dual licensed under the MIT (MIT-LICENSE.txt)
6 * and GPL (GPL-LICENSE.txt) licenses.
7 *
8 * http://docs.jquery.com/UI/Progressbar
9 *
10 * Depends:
11 * jquery.ui.core.js
12 * jquery.ui.widget.js
13 */
14 (function( $ ) {
15
16 $.widget( "ui.progressbar", {
17 options: {
18 value: 0
19 },
20 _create: function() {
21 this.element
22 .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
23 .attr({
24 role: "progressbar",
25 "aria-valuemin": this._valueMin(),
26 "aria-valuemax": this._valueMax(),
27 "aria-valuenow": this._value()
28 });
29
30 this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
31 .appendTo( this.element );
32
33 this._refreshValue();
34 },
35
36 destroy: function() {
37 this.element
38 .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
39 .removeAttr( "role" )
40 .removeAttr( "aria-valuemin" )
41 .removeAttr( "aria-valuemax" )
42 .removeAttr( "aria-valuenow" );
43
44 this.valueDiv.remove();
45
46 $.Widget.prototype.destroy.apply( this, arguments );
47 },
48
49 value: function( newValue ) {
50 if ( newValue === undefined ) {
51 return this._value();
52 }
53
54 this._setOption( "value", newValue );
55 return this;
56 },
57
58 _setOption: function( key, value ) {
59 switch ( key ) {
60 case "value":
61 this.options.value = value;
62 this._refreshValue();
63 this._trigger( "change" );
64 break;
65 }
66
67 $.Widget.prototype._setOption.apply( this, arguments );
68 },
69
70 _value: function() {
71 var val = this.options.value;
72 // normalize invalid value
73 if ( typeof val !== "number" ) {
74 val = 0;
75 }
76 if ( val < this._valueMin() ) {
77 val = this._valueMin();
78 }
79 if ( val > this._valueMax() ) {
80 val = this._valueMax();
81 }
82
83 return val;
84 },
85
86 _valueMin: function() {
87 return 0;
88 },
89
90 _valueMax: function() {
91 return 100;
92 },
93
94 _refreshValue: function() {
95 var value = this.value();
96 this.valueDiv
97 [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" )
98 .width( value + "%" );
99 this.element.attr( "aria-valuenow", value );
100 }
101 });
102
103 $.extend( $.ui.progressbar, {
104 version: "1.8.2"
105 });
106
107 })( jQuery );