Progressbar: Conform to coding standards.

This commit is contained in:
Scott González 2010-02-07 03:40:13 +00:00
parent 573a402d05
commit f349f9080b

View File

@ -18,12 +18,8 @@ $.widget("ui.progressbar", {
value: 0 value: 0
}, },
_create: function() { _create: function() {
this.element this.element
.addClass("ui-progressbar" .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
+ " ui-widget"
+ " ui-widget-content"
+ " ui-corner-all")
.attr({ .attr({
role: "progressbar", role: "progressbar",
"aria-valuemin": this._valueMin(), "aria-valuemin": this._valueMin(),
@ -31,31 +27,23 @@ $.widget("ui.progressbar", {
"aria-valuenow": this._value() "aria-valuenow": this._value()
}); });
this.valueDiv = $('<div class="ui-progressbar-value ui-widget-header ui-corner-left"></div>').appendTo(this.element); this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
.appendTo( this.element );
this._refreshValue(); this._refreshValue();
}, },
destroy: function() { destroy: function() {
this.element this.element
.removeClass("ui-progressbar" .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
+ " ui-widget"
+ " ui-widget-content"
+ " ui-corner-all")
.removeAttr( "role" ) .removeAttr( "role" )
.removeAttr( "aria-valuemin" ) .removeAttr( "aria-valuemin" )
.removeAttr( "aria-valuemax" ) .removeAttr( "aria-valuemax" )
.removeAttr("aria-valuenow") .removeAttr( "aria-valuenow" );
.removeData("progressbar")
.unbind(".progressbar");
this.valueDiv.remove(); this.valueDiv.remove();
$.Widget.prototype.destroy.apply( this, arguments ); $.Widget.prototype.destroy.apply( this, arguments );
return this;
}, },
value: function( newValue ) { value: function( newValue ) {
@ -63,53 +51,53 @@ $.widget("ui.progressbar", {
return this._value(); return this._value();
} }
this._setOption('value', newValue); this._setOption( "value", newValue );
return this; return this;
}, },
_setOption: function( key, value ) { _setOption: function( key, value ) {
switch ( key ) { switch ( key ) {
case 'value': case "value":
this.options.value = value; this.options.value = value;
this._refreshValue(); this._refreshValue();
this._trigger('change', null, {}); this._trigger( "change" );
break; break;
} }
$.Widget.prototype._setOption.apply( this, arguments ); $.Widget.prototype._setOption.apply( this, arguments );
}, },
_value: function() { _value: function() {
var val = this.options.value; var val = this.options.value;
// normalize invalid value // normalize invalid value
if (typeof val != "number") if ( typeof val !== "number" ) {
val = 0; val = 0;
if (val < this._valueMin()) val = this._valueMin(); }
if (val > this._valueMax()) val = this._valueMax(); if ( val < this._valueMin() ) {
val = this._valueMin();
}
if ( val > this._valueMax() ) {
val = this._valueMax();
}
return val; return val;
}, },
_valueMin: function() { _valueMin: function() {
var valueMin = 0; return 0;
return valueMin;
}, },
_valueMax: function() { _valueMax: function() {
var valueMax = 100; return 100;
return valueMax;
}, },
_refreshValue: function() { _refreshValue: function() {
var value = this.value(); var value = this.value();
this.valueDiv[value == this._valueMax() ? 'addClass' : 'removeClass']("ui-corner-right"); this.valueDiv
this.valueDiv.width(value + '%'); [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" )
.width( value + "%" );
this.element.attr( "aria-valuenow", value ); this.element.attr( "aria-valuenow", value );
} }
}); });
$.extend( $.ui.progressbar, { $.extend( $.ui.progressbar, {