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
|
|
|
*
|
2008-11-21 02:14:03 +00:00
|
|
|
* Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.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-09-19 17:21:45 +00:00
|
|
|
var self = this,
|
2008-12-05 13:35:11 +00:00
|
|
|
options = this.options;
|
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({
|
|
|
|
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")
|
2008-12-05 13:35:11 +00:00
|
|
|
.removeData("progressbar")
|
|
|
|
.unbind(".progressbar");
|
|
|
|
|
|
|
|
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
|
|
|
|
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) {
|
2008-12-05 15:42:46 +00:00
|
|
|
arguments.length && this._setData("value", newValue);
|
2008-12-10 05:12:08 +00:00
|
|
|
|
2008-12-05 15:42:46 +00:00
|
|
|
return this._value();
|
2008-12-05 13:35:11 +00:00
|
|
|
},
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2008-12-05 13:35:11 +00:00
|
|
|
_setData: function(key, value){
|
|
|
|
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);
|
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;
|
|
|
|
if (val < this._valueMin()) val = this._valueMin();
|
|
|
|
if (val > this._valueMax()) val = this._valueMax();
|
|
|
|
|
|
|
|
return val;
|
|
|
|
},
|
|
|
|
|
|
|
|
_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-10 05:12:08 +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
|
2008-12-05 13:35:11 +00:00
|
|
|
}
|
2008-09-19 17:21:45 +00:00
|
|
|
});
|
|
|
|
|
2008-09-20 01:48:18 +00:00
|
|
|
})(jQuery);
|