aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRichard Worth <rdworth@gmail.com>2008-12-10 05:12:08 +0000
committerRichard Worth <rdworth@gmail.com>2008-12-10 05:12:08 +0000
commitc95e3b27a491dd4ef0466e6fcac36e1f684f9671 (patch)
treedfc1e848e078e83543f84b14b32c53e76ca534ff /ui
parent38e213547245bc1186bce70b5b920e9dd7356c76 (diff)
downloadjquery-ui-c95e3b27a491dd4ef0466e6fcac36e1f684f9671.tar.gz
jquery-ui-c95e3b27a491dd4ef0466e6fcac36e1f684f9671.zip
progressbar: Removed all progressbar options except value. Added visual test for disabled progressbar.
Diffstat (limited to 'ui')
-rw-r--r--ui/ui.progressbar.js108
1 files changed, 6 insertions, 102 deletions
diff --git a/ui/ui.progressbar.js b/ui/ui.progressbar.js
index 37f995969..671812512 100644
--- a/ui/ui.progressbar.js
+++ b/ui/ui.progressbar.js
@@ -21,7 +21,6 @@ $.widget("ui.progressbar", {
this.element
.addClass("ui-progressbar"
- + " ui-progressbar-labelalign-" + this._labelAlign()
+ " ui-widget-content"
+ " ui-corner-all")
.attr({
@@ -31,21 +30,9 @@ $.widget("ui.progressbar", {
"aria-valuenow": this._value()
});
- this.element
- .append('<div class="ui-progressbar-label"></div>')
- .append('<div class="ui-progressbar-value ui-state-default ui-corner-left">'
- + '<div class="ui-progressbar-label"></div>'
- + '</div>'
- );
-
- this.valueDiv = this.element.find(".ui-progressbar-value");
- this.valueLabel = this.valueDiv.find(".ui-progressbar-label");
- this.labels = this.element.find(".ui-progressbar-label");
+ this.valueDiv = $('<div class="ui-progressbar-value ui-state-default ui-corner-left"></div>').appendTo(this.element);
- this._refreshLabel();
this._refreshValue();
- this._refreshWidth();
- this._refreshHeight();
},
@@ -53,10 +40,6 @@ $.widget("ui.progressbar", {
this.element
.removeClass("ui-progressbar"
- + " ui-progressbar-disabled"
- + " ui-progressbar-labelalign-left"
- + " ui-progressbar-labelalign-center"
- + " ui-progressbar-labelalign-right"
+ " ui-widget-content"
+ " ui-corner-all")
.removeAttr("role")
@@ -66,81 +49,30 @@ $.widget("ui.progressbar", {
.removeData("progressbar")
.unbind(".progressbar");
- this.labels.remove();
this.valueDiv.remove();
- },
-
- disable: function() {
- this.element.attr("aria-disabled", true);
- },
+ $.widget.prototype.destroy.apply(this, arguments);
- enable: function() {
- this.element.attr("aria-disabled", false);
},
value: function(newValue) {
arguments.length && this._setData("value", newValue);
+
return this._value();
},
_setData: function(key, value){
switch (key) {
- case 'height':
- this.options.height = value;
- this._refreshHeight();
- break;
- case 'label':
- this.options.label = value;
- this._refreshLabel();
- break;
- case 'labelAlign':
- this.options.labelAlign = value;
- this._refreshLabelAlign();
- break;
case 'value':
this.options.value = value;
- this._refreshLabel();
this._refreshValue();
this._trigger('change', null, {});
break;
- case 'width':
- this.options.width = value;
- break;
}
$.widget.prototype._setData.apply(this, arguments);
},
- //Property Getters - these return valid property values without modifying options
- _labelText: function() {
- var labelText;
-
- if (this.options.label === true) {
- labelText = this.value() + '%';
- } else {
- labelText = this.options.label;
- }
-
- return labelText;
- },
-
- _labelAlign: function() {
- var labelAlign;
-
- switch (this.options.labelAlign.toLowerCase()) {
- case 'left':
- case 'center':
- case 'right':
- labelAlign = this.options.labelAlign;
- break;
- default:
- labelAlign = 'left';
- }
-
- return labelAlign.toLowerCase();
- },
-
_value: function() {
var val = this.options.value;
if (val < this._valueMin()) val = this._valueMin();
@@ -161,47 +93,19 @@ $.widget("ui.progressbar", {
return valueMax;
},
- //Refresh Methods - these refresh parts of the widget to match its current state
- _refreshHeight: function() {
- this.element.height(this.options.height);
- },
-
- _refreshLabel: function() {
- var labelText = this._labelText();
-
- // this extra wrapper div is required for padding to work with labelAlign: left and labelAlign: right
- this.labels.html("<div>" + labelText + "</div>");
- },
-
- _refreshLabelAlign: function() {
- var labelAlign = this._labelAlign();
- this.element
- .removeClass("ui-progressbar-labelalign-left"
- + " ui-progressbar-labelalign-center"
- + " ui-progressbar-labelalign-right")
- .addClass("ui-progressbar-labelalign-" + labelAlign);
- },
-
_refreshValue: function() {
var value = this.value();
+ this.valueDiv[value == this._valueMax() ? 'addClass' : 'removeClass']("ui-corner-right");
this.valueDiv.width(value + '%');
this.element.attr("aria-valuenow", value);
- },
-
- _refreshWidth: function() {
- this.element.add(this.valueLabel).width(this.options.width);
}
-
+
});
$.extend($.ui.progressbar, {
version: "@VERSION",
defaults: {
- height: 20,
- label: true,
- labelAlign: 'left',
- value: 0,
- width: 300
+ value: 0
}
});