Subversion Repositories Sites.obs-saisons.fr

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
40 aurelien 1
/*
2
 * jQuery UI Progressbar 1.8.5
3
 *
4
 * Copyright 2010, 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 ) {
15
 
16
$.widget( "ui.progressbar", {
17
	options: {
18
		value: 0
19
	},
20
 
21
	min: 0,
22
	max: 100,
23
 
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.max,
31
				"aria-valuenow": this._value()
32
			});
33
 
34
		this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
35
			.appendTo( this.element );
36
 
37
		this._refreshValue();
38
	},
39
 
40
	destroy: function() {
41
		this.element
42
			.removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
43
			.removeAttr( "role" )
44
			.removeAttr( "aria-valuemin" )
45
			.removeAttr( "aria-valuemax" )
46
			.removeAttr( "aria-valuenow" );
47
 
48
		this.valueDiv.remove();
49
 
50
		$.Widget.prototype.destroy.apply( this, arguments );
51
	},
52
 
53
	value: function( newValue ) {
54
		if ( newValue === undefined ) {
55
			return this._value();
56
		}
57
 
58
		this._setOption( "value", newValue );
59
		return this;
60
	},
61
 
62
	_setOption: function( key, value ) {
63
		if ( key === "value" ) {
64
			this.options.value = value;
65
			this._refreshValue();
66
			this._trigger( "change" );
67
		}
68
 
69
		$.Widget.prototype._setOption.apply( this, arguments );
70
	},
71
 
72
	_value: function() {
73
		var val = this.options.value;
74
		// normalize invalid value
75
		if ( typeof val !== "number" ) {
76
			val = 0;
77
		}
78
		return Math.min( this.max, Math.max( this.min, val ) );
79
	},
80
 
81
	_refreshValue: function() {
82
		var value = this.value();
83
		this.valueDiv
84
			.toggleClass( "ui-corner-right", value === this.max )
85
			.width( value + "%" );
86
		this.element.attr( "aria-valuenow", value );
87
	}
88
});
89
 
90
$.extend( $.ui.progressbar, {
91
	version: "1.8.5"
92
});
93
 
94
})( jQuery );