2
* jQuery UI ProgressBar @VERSION
4
* Copyright (c) 2008 Eduardo Lundgren
5
* Dual licensed under the MIT (MIT-LICENSE.txt)
6
* and GPL (GPL-LICENSE.txt) licenses.
8
* http://docs.jquery.com/UI/ProgressBar
15
$.widget("ui.progressbar", {
18
this._interval = this.options.interval;
21
options = this.options,
22
id = (new Date()).getTime()+Math.random(),
23
text = options.text || '0%';
25
this.element.addClass("ui-progressbar").width(options.width);
32
bar: $('<div class="ui-progressbar-bar ui-hidden"></div>').css({
33
width: '0px', overflow: 'hidden', zIndex: 100
35
textElement: $('<div class="ui-progressbar-text"></div>').html(text).css({
36
width: '0px', overflow: 'hidden'
38
textBg: $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>').html(text).css({
39
width: this.element.width()
41
wrapper: $('<div class="ui-progressbar-wrap"></div>')
45
.append(this.bar.append(this.textElement.addClass(options.textClass)), this.textBg)
46
.appendTo(this.element);
53
identifier: this.identifier,
54
options: this.options,
56
textElement: this.textElement,
57
pixelState: this.pixelState,
58
percentState: this.percentState
62
_propagate: function(n,e) {
63
$.ui.plugin.call(this, n, [e, this.ui()]);
64
this.element.triggerHandler(n == "progressbar" ? n : ["progressbar", n].join(""), [e, this.ui()], this.options[n]);
71
.removeClass("ui-progressbar ui-progressbar-disabled")
72
.removeData("progressbar").unbind(".progressbar")
73
.find('.ui-progressbar-wrap').remove();
75
delete jQuery.easing[this.identifier];
79
this.element.removeClass("ui-progressbar-disabled");
80
this.disabled = false;
84
this.element.addClass("ui-progressbar-disabled");
89
var self = this, options = this.options;
95
jQuery.easing[this.identifier] = function (x, t, b, c, d) {
96
var inc = options.increment,
97
width = options.width,
98
step = ((inc > width ? width : inc)/width),
99
state = Math.round(x/step)*step;
100
return state > 1 ? 1 : state;
114
this._propagate('start', this.ui());
118
_animate: function() {
120
options = this.options,
121
interval = options.interval;
129
easing: this.identifier,
130
step: function(step, b) {
131
self.progress((step/options.width)*100);
132
var timestamp = new Date().getTime(), elapsedTime = (timestamp - b.startTime);
133
options.interval = interval - elapsedTime;
135
complete: function() {
136
delete jQuery.easing[self.identifier];
148
if (this.disabled) return;
150
this._propagate('pause', this.ui());
156
this.textElement.width(0);
157
this.bar.addClass('ui-hidden');
158
this.options.interval = this._interval;
159
this._propagate('stop', this.ui());
162
text: function(text){
163
this.textElement.html(text);
164
this.textBg.html(text);
167
progress: function(percentState) {
168
if (this.bar.is('.ui-hidden')) {
169
this.bar.removeClass('ui-hidden');
172
this.percentState = percentState > 100 ? 100 : percentState;
173
this.pixelState = (this.percentState/100)*this.options.width;
174
this.bar.width(this.pixelState);
175
this.textElement.width(this.pixelState);
177
if (this.options.range && !this.options.text) {
178
this.textElement.html(Math.round(this.percentState) + '%');
180
this._propagate('progress', this.ui());
184
$.ui.progressbar.defaults = {
b'\\ No newline at end of file'