2008-09-19 17:21:45 +00:00
|
|
|
/*
|
2008-09-20 13:11:01 +00:00
|
|
|
* jQuery UI Progressbar @VERSION
|
2008-09-19 17:21:45 +00:00
|
|
|
*
|
2009-02-27 11:41:40 +00:00
|
|
|
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
|
2008-09-19 17:21:45 +00:00
|
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
|
|
|
* and GPL (GPL-LICENSE.txt) licenses.
|
|
|
|
*
|
2008-09-20 13:11:01 +00:00
|
|
|
* http://docs.jquery.com/UI/Progressbar
|
2008-09-19 17:21:45 +00:00
|
|
|
*
|
|
|
|
* Depends:
|
|
|
|
* ui.core.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
$.widget("ui.progressbar", {
|
2008-11-21 04:12:18 +00:00
|
|
|
|
2008-09-19 17:21:45 +00:00
|
|
|
_init: function() {
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-10-29 16:57:04 +00:00
|
|
|
this.element
|
2008-12-05 15:42:46 +00:00
|
|
|
.addClass("ui-progressbar"
|
2008-12-11 03:03:13 +00:00
|
|
|
+ " ui-widget"
|
2008-12-05 15:42:46 +00:00
|
|
|
+ " ui-widget-content"
|
|
|
|
+ " ui-corner-all")
|
2008-11-07 13:57:31 +00:00
|
|
|
.attr({
|
2009-01-16 02:09:45 +00:00
|
|
|
role: "progressbar",
|
2008-12-05 15:42:46 +00:00
|
|
|
"aria-valuemin": this._valueMin(),
|
|
|
|
"aria-valuemax": this._valueMax(),
|
|
|
|
"aria-valuenow": this._value()
|
2008-11-07 13:57:31 +00:00
|
|
|
});
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-12-23 13:27:57 +00:00
|
|
|
this.valueDiv = $('<div class="ui-progressbar-value ui-widget-header ui-corner-left"></div>').appendTo(this.element);
|
2008-12-05 13:35:11 +00:00
|
|
|
|
|
|
|
this._refreshValue();
|
|
|
|
|
2008-09-19 17:21:45 +00:00
|
|
|
},
|
2008-09-20 11:22:54 +00:00
|
|
|
|
2008-11-21 04:12:18 +00:00
|
|
|
destroy: function() {
|
|
|
|
|
|
|
|
this.element
|
2008-12-05 15:42:46 +00:00
|
|
|
.removeClass("ui-progressbar"
|
2008-12-11 03:03:13 +00:00
|
|
|
+ " ui-widget"
|
2008-12-05 15:42:46 +00:00
|
|
|
+ " ui-widget-content"
|
|
|
|
+ " ui-corner-all")
|
|
|
|
.removeAttr("role")
|
|
|
|
.removeAttr("aria-valuemin")
|
|
|
|
.removeAttr("aria-valuemax")
|
|
|
|
.removeAttr("aria-valuenow")
|
2009-01-16 02:09:45 +00:00
|
|
|
.removeData("progressbar")
|
|
|
|
.unbind(".progressbar");
|
2008-12-05 13:35:11 +00:00
|
|
|
|
|
|
|
this.valueDiv.remove();
|
2008-11-21 04:12:18 +00:00
|
|
|
|
2008-12-10 05:12:08 +00:00
|
|
|
$.widget.prototype.destroy.apply(this, arguments);
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
return this;
|
2008-09-19 17:21:45 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-12-05 13:35:11 +00:00
|
|
|
value: function(newValue) {
|
2009-04-16 01:57:56 +00:00
|
|
|
if (newValue === undefined) {
|
|
|
|
return this._value();
|
|
|
|
}
|
|
|
|
|
|
|
|
this._setData('value', newValue);
|
|
|
|
return this;
|
2008-12-05 13:35:11 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2009-02-11 13:04:18 +00:00
|
|
|
_setData: function(key, value) {
|
|
|
|
|
2008-12-05 13:35:11 +00:00
|
|
|
switch (key) {
|
|
|
|
case 'value':
|
2008-12-05 15:42:46 +00:00
|
|
|
this.options.value = value;
|
|
|
|
this._refreshValue();
|
|
|
|
this._trigger('change', null, {});
|
2008-12-05 13:35:11 +00:00
|
|
|
break;
|
2008-09-20 11:22:54 +00:00
|
|
|
}
|
2008-12-05 13:35:11 +00:00
|
|
|
|
|
|
|
$.widget.prototype._setData.apply(this, arguments);
|
2009-02-11 13:04:18 +00:00
|
|
|
|
2008-09-19 17:21:45 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-12-05 15:42:46 +00:00
|
|
|
_value: function() {
|
|
|
|
var val = this.options.value;
|
2009-09-15 08:38:11 +00:00
|
|
|
// normalize invalid value
|
|
|
|
if (typeof val != "number")
|
|
|
|
val = 0;
|
2008-12-05 15:42:46 +00:00
|
|
|
if (val < this._valueMin()) val = this._valueMin();
|
|
|
|
if (val > this._valueMax()) val = this._valueMax();
|
|
|
|
|
|
|
|
return val;
|
2009-02-11 13:04:18 +00:00
|
|
|
|
2008-12-05 15:42:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_valueMin: function() {
|
|
|
|
var valueMin = 0;
|
|
|
|
return valueMin;
|
|
|
|
},
|
|
|
|
|
|
|
|
_valueMax: function() {
|
|
|
|
var valueMax = 100;
|
|
|
|
return valueMax;
|
|
|
|
},
|
|
|
|
|
2008-12-05 13:35:11 +00:00
|
|
|
_refreshValue: function() {
|
2008-12-05 15:42:46 +00:00
|
|
|
var value = this.value();
|
2008-12-10 05:12:08 +00:00
|
|
|
this.valueDiv[value == this._valueMax() ? 'addClass' : 'removeClass']("ui-corner-right");
|
2008-12-05 15:42:46 +00:00
|
|
|
this.valueDiv.width(value + '%');
|
|
|
|
this.element.attr("aria-valuenow", value);
|
2008-11-17 00:21:36 +00:00
|
|
|
}
|
2008-12-31 08:22:11 +00:00
|
|
|
|
2008-11-17 00:21:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$.extend($.ui.progressbar, {
|
|
|
|
version: "@VERSION",
|
|
|
|
defaults: {
|
2008-12-10 05:12:08 +00:00
|
|
|
value: 0
|
2009-04-18 14:34:20 +00:00
|
|
|
}
|
2008-09-19 17:21:45 +00:00
|
|
|
});
|
|
|
|
|
2008-09-20 01:48:18 +00:00
|
|
|
})(jQuery);
|