diff options
author | Eduardo Lundgren <eduardolundgren@gmail.com> | 2008-09-20 11:22:54 +0000 |
---|---|---|
committer | Eduardo Lundgren <eduardolundgren@gmail.com> | 2008-09-20 11:22:54 +0000 |
commit | 2ea45391123dac81daf495896bc928e5557ded8a (patch) | |
tree | a8c6d765d8bdf3361a3cb4ff50fa6318723e7191 /ui/ui.progressbar.js | |
parent | c784591d8ced58fe59a1295c4919b710069a1f3e (diff) | |
download | jquery-ui-2ea45391123dac81daf495896bc928e5557ded8a.tar.gz jquery-ui-2ea45391123dac81daf495896bc928e5557ded8a.zip |
Progressbar - Source formatting
Diffstat (limited to 'ui/ui.progressbar.js')
-rw-r--r-- | ui/ui.progressbar.js | 137 |
1 files changed, 69 insertions, 68 deletions
diff --git a/ui/ui.progressbar.js b/ui/ui.progressbar.js index b8b9e0b20..9d9c64cb2 100644 --- a/ui/ui.progressbar.js +++ b/ui/ui.progressbar.js @@ -45,18 +45,37 @@ $.widget("ui.progressbar", { .append(this.bar.append(this.textElement.addClass(options.textClass)), this.textBg) .appendTo(this.element); }, - - plugins: {}, - ui: function(e) { - return { - instance: this, - identifier: this.identifier, - options: this.options, - element: this.bar, - textElement: this.textElement, - pixelState: this.pixelState, - percentState: this.percentState - }; + + _animate: function() { + var self = this, + options = this.options, + interval = options.interval; + + this.bar.animate( + { + width: options.width + }, + { + duration: interval, + easing: options.equation || this.identifier, + step: function(step, b) { + var timestamp = new Date().getTime(), elapsedTime = (timestamp - b.startTime); + self.progress( (step/options.width) * 100 ); + options.interval = interval - elapsedTime; + }, + complete: function() { + if (self.active) { + options.interval = self._interval; + self.bar.width(0); + self.textElement.width(0); + self._animate(); + } + else { + delete jQuery.easing[self.identifier]; + } + } + } + ); }, _propagate: function(n,e) { @@ -74,15 +93,37 @@ $.widget("ui.progressbar", { delete jQuery.easing[this.identifier]; }, + + disable: function() { + this.element.addClass("ui-progressbar-disabled"); + this.disabled = true; + }, enable: function() { this.element.removeClass("ui-progressbar-disabled"); this.disabled = false; }, - disable: function() { - this.element.addClass("ui-progressbar-disabled"); - this.disabled = true; + pause: function() { + if (this.disabled) return; + this.bar.stop(); + this._propagate('pause', this.ui()); + }, + + progress: function(percentState) { + if (this.bar.is('.ui-hidden')) { + this.bar.removeClass('ui-hidden'); + } + + this.percentState = percentState > 100 ? 100 : percentState; + this.pixelState = (this.percentState/100) * this.options.width; + this.bar.width(this.pixelState); + this.textElement.width(this.pixelState); + + if (this.options.range && !this.options.text) { + this.textElement.html(Math.round(this.percentState) + '%'); + } + this._propagate('progress', this.ui()); }, start: function() { @@ -119,44 +160,6 @@ $.widget("ui.progressbar", { return false; }, - _animate: function() { - var self = this, - options = this.options, - interval = options.interval; - - this.bar.animate( - { - width: options.width - }, - { - duration: interval, - easing: options.equation || this.identifier, - step: function(step, b) { - var timestamp = new Date().getTime(), elapsedTime = (timestamp - b.startTime); - self.progress( (step/options.width) * 100 ); - options.interval = interval - elapsedTime; - }, - complete: function() { - if (self.active) { - options.interval = self._interval; - self.bar.width(0); - self.textElement.width(0); - self._animate(); - } - else { - delete jQuery.easing[self.identifier]; - } - } - } - ); - }, - - pause: function() { - if (this.disabled) return; - this.bar.stop(); - this._propagate('pause', this.ui()); - }, - stop: function() { this.bar.stop(); this.bar.width(0); @@ -171,21 +174,19 @@ $.widget("ui.progressbar", { this.textBg.html(text); }, - progress: function(percentState) { - if (this.bar.is('.ui-hidden')) { - this.bar.removeClass('ui-hidden'); - } - - this.percentState = percentState > 100 ? 100 : percentState; - this.pixelState = (this.percentState/100) * this.options.width; - this.bar.width(this.pixelState); - this.textElement.width(this.pixelState); - - if (this.options.range && !this.options.text) { - this.textElement.html(Math.round(this.percentState) + '%'); - } - this._propagate('progress', this.ui()); - } + ui: function(e) { + return { + instance: this, + identifier: this.identifier, + options: this.options, + element: this.bar, + textElement: this.textElement, + pixelState: this.pixelState, + percentState: this.percentState + }; + }, + + plugins: {} }); $.ui.progressbar.defaults = { |