corrade-http-templates – Blame information for rev 62
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
62 | office | 1 | /*! |
2 | * jQuery UI Progressbar 1.12.1 |
||
3 | * http://jqueryui.com |
||
4 | * |
||
5 | * Copyright jQuery Foundation and other contributors |
||
6 | * Released under the MIT license. |
||
7 | * http://jquery.org/license |
||
8 | */ |
||
9 | |||
10 | //>>label: Progressbar |
||
11 | //>>group: Widgets |
||
12 | // jscs:disable maximumLineLength |
||
13 | //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators. |
||
14 | // jscs:enable maximumLineLength |
||
15 | //>>docs: http://api.jqueryui.com/progressbar/ |
||
16 | //>>demos: http://jqueryui.com/progressbar/ |
||
17 | //>>css.structure: ../../themes/base/core.css |
||
18 | //>>css.structure: ../../themes/base/progressbar.css |
||
19 | //>>css.theme: ../../themes/base/theme.css |
||
20 | |||
21 | ( function( factory ) { |
||
22 | if ( typeof define === "function" && define.amd ) { |
||
23 | |||
24 | // AMD. Register as an anonymous module. |
||
25 | define( [ |
||
26 | "jquery", |
||
27 | "../version", |
||
28 | "../widget" |
||
29 | ], factory ); |
||
30 | } else { |
||
31 | |||
32 | // Browser globals |
||
33 | factory( jQuery ); |
||
34 | } |
||
35 | }( function( $ ) { |
||
36 | |||
37 | return $.widget( "ui.progressbar", { |
||
38 | version: "1.12.1", |
||
39 | options: { |
||
40 | classes: { |
||
41 | "ui-progressbar": "ui-corner-all", |
||
42 | "ui-progressbar-value": "ui-corner-left", |
||
43 | "ui-progressbar-complete": "ui-corner-right" |
||
44 | }, |
||
45 | max: 100, |
||
46 | value: 0, |
||
47 | |||
48 | change: null, |
||
49 | complete: null |
||
50 | }, |
||
51 | |||
52 | min: 0, |
||
53 | |||
54 | _create: function() { |
||
55 | |||
56 | // Constrain initial value |
||
57 | this.oldValue = this.options.value = this._constrainedValue(); |
||
58 | |||
59 | this.element.attr( { |
||
60 | |||
61 | // Only set static values; aria-valuenow and aria-valuemax are |
||
62 | // set inside _refreshValue() |
||
63 | role: "progressbar", |
||
64 | "aria-valuemin": this.min |
||
65 | } ); |
||
66 | this._addClass( "ui-progressbar", "ui-widget ui-widget-content" ); |
||
67 | |||
68 | this.valueDiv = $( "<div>" ).appendTo( this.element ); |
||
69 | this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" ); |
||
70 | this._refreshValue(); |
||
71 | }, |
||
72 | |||
73 | _destroy: function() { |
||
74 | this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" ); |
||
75 | |||
76 | this.valueDiv.remove(); |
||
77 | }, |
||
78 | |||
79 | value: function( newValue ) { |
||
80 | if ( newValue === undefined ) { |
||
81 | return this.options.value; |
||
82 | } |
||
83 | |||
84 | this.options.value = this._constrainedValue( newValue ); |
||
85 | this._refreshValue(); |
||
86 | }, |
||
87 | |||
88 | _constrainedValue: function( newValue ) { |
||
89 | if ( newValue === undefined ) { |
||
90 | newValue = this.options.value; |
||
91 | } |
||
92 | |||
93 | this.indeterminate = newValue === false; |
||
94 | |||
95 | // Sanitize value |
||
96 | if ( typeof newValue !== "number" ) { |
||
97 | newValue = 0; |
||
98 | } |
||
99 | |||
100 | return this.indeterminate ? false : |
||
101 | Math.min( this.options.max, Math.max( this.min, newValue ) ); |
||
102 | }, |
||
103 | |||
104 | _setOptions: function( options ) { |
||
105 | |||
106 | // Ensure "value" option is set after other values (like max) |
||
107 | var value = options.value; |
||
108 | delete options.value; |
||
109 | |||
110 | this._super( options ); |
||
111 | |||
112 | this.options.value = this._constrainedValue( value ); |
||
113 | this._refreshValue(); |
||
114 | }, |
||
115 | |||
116 | _setOption: function( key, value ) { |
||
117 | if ( key === "max" ) { |
||
118 | |||
119 | // Don't allow a max less than min |
||
120 | value = Math.max( this.min, value ); |
||
121 | } |
||
122 | this._super( key, value ); |
||
123 | }, |
||
124 | |||
125 | _setOptionDisabled: function( value ) { |
||
126 | this._super( value ); |
||
127 | |||
128 | this.element.attr( "aria-disabled", value ); |
||
129 | this._toggleClass( null, "ui-state-disabled", !!value ); |
||
130 | }, |
||
131 | |||
132 | _percentage: function() { |
||
133 | return this.indeterminate ? |
||
134 | 100 : |
||
135 | 100 * ( this.options.value - this.min ) / ( this.options.max - this.min ); |
||
136 | }, |
||
137 | |||
138 | _refreshValue: function() { |
||
139 | var value = this.options.value, |
||
140 | percentage = this._percentage(); |
||
141 | |||
142 | this.valueDiv |
||
143 | .toggle( this.indeterminate || value > this.min ) |
||
144 | .width( percentage.toFixed( 0 ) + "%" ); |
||
145 | |||
146 | this |
||
147 | ._toggleClass( this.valueDiv, "ui-progressbar-complete", null, |
||
148 | value === this.options.max ) |
||
149 | ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate ); |
||
150 | |||
151 | if ( this.indeterminate ) { |
||
152 | this.element.removeAttr( "aria-valuenow" ); |
||
153 | if ( !this.overlayDiv ) { |
||
154 | this.overlayDiv = $( " |
||
155 |
|
||
156 |
|
||
157 |
|
||
158 |
|
||
159 |
|
||
160 |
|
||
161 |
|
||
162 |
|
||
163 |
|
||
164 |
|
||
165 |
|
||
166 |
|
||
167 | |||
168 |
|
||
169 |
|
||
170 |
|
||
171 |
|
||
172 |
|
||
173 |
|
||
174 |
|
||
175 |
|
||
176 |
|
||
177 | |||
178 |
|