* Copyright (c) 2008 Eduardo Lundgren (braeker)\r
* Dual licensed under the MIT (MIT-LICENSE.txt)\r
* and GPL (GPL-LICENSE.txt) licenses.\r
- * \r
+ *\r
* http://docs.jquery.com/UI/ProgressBar\r
*\r
* Depends:\r
$.extend(o, {\r
stepping: o.stepping > 100 ? 100 : o.stepping\r
});\r
- \r
+\r
$.extend(this, {\r
_step: 0,\r
rangeValue: 0,\r
threads: {},\r
- \r
+\r
wrapper: $('<div class="ui-progressbar-wrap"></div>'),\r
bar: $('<div class="ui-progressbar-bar ui-hidden"></div>').css({\r
width: '0px', overflow: 'hidden', zIndex: 100\r
textBg: $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>').html(text).css({\r
width: this.element.css('width')\r
})\r
- \r
+\r
});\r
- \r
+\r
this.wrapper\r
.append(this.bar.append(this.textElement), this.textBg)\r
.appendTo(this.element);\r
\r
},\r
- \r
+\r
plugins: {},\r
ui: function(e) {\r
return {\r
},\r
destroy: function() {\r
this.reset();\r
- \r
+\r
this.element\r
.removeClass("ui-progressbar ui-progressbar-disabled")\r
.removeData("progressbar").unbind(".progressbar")\r
this.clearThreads();\r
},\r
start: function() {\r
- \r
+\r
if (this.disabled) return false;\r
this.inProgress = true;\r
- \r
+\r
var self = this, o = this.options, el = this.element;\r
this.clearThreads();\r
- \r
+\r
if (typeof o.wait == 'number' && !self.waitThread)\r
self.waitThread = setTimeout(function() {\r
clearInterval(self.waitThread);\r
self.waitThread = null;\r
}, o.wait);\r
- \r
+\r
var frames = Math.ceil(100/o.stepping) || 0, ms = o.duration/frames || 0,\r
- \r
+\r
render = function(step, t) {\r
//clearInterval(t);\r
- \r
+\r
self.progress(o.stepping * step);\r
// on end\r
if (step >= frames) {\r
}\r
};\r
var from = this._step, _step = (this._step - (from - 1));\r
- \r
+\r
/*for(var step = from; step <= frames; step++) {\r
var interval = (step - (from - 1)) * ms;\r
this.threads[step] = setTimeout(render(step, this.threads[step]), interval);\r
}*/\r
- \r
+\r
this.threads[0] = setInterval(function() {\r
render(_step++);\r
}, ms);\r
- \r
+\r
this.propagate('start');\r
return false;\r
},\r
this.threads = {};\r
},\r
stop: function() {\r
- \r
+\r
if (this.disabled) return false;\r
var o = this.options, self = this;\r
- \r
+\r
this.clearThreads();\r
this.propagate('stop');\r
- \r
+\r
this.inProgress = false;\r
return false;\r
- \r
+\r
},\r
reset: function() {\r
- \r
+\r
if (this.disabled) return false;\r
this._step = 0;\r
this.rangeValue = 0;\r
this.progress(0);\r
this.bar.addClass('ui-hidden');\r
return false;\r
- \r
+\r
},\r
progress: function(range) {\r
- \r
+\r
var o = this.options, el = this.element, bar = this.bar;\r
if (this.disabled) return false;\r
- \r
+\r
range = parseInt(range, 10);\r
this.rangeValue = this._fixRange(range);\r
this.pixelRange = Math.round( ((this.rangeValue/100)||0) * (el.innerWidth() - (el.outerWidth() - el.innerWidth()) - (bar.outerWidth() - bar.innerWidth())) );\r
- \r
+\r
this.bar.removeClass('ui-hidden');\r
- \r
+\r
var css = { width: this.pixelRange + 'px' };\r
this.bar.css(css);\r
this.textElement.css(css);\r
- \r
+\r
if (!o.text && o.range) this.text(this.rangeValue + '%');\r
this.propagate('progress', this.rangeValue);\r
return false;\r