mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Progressbar: Conform to coding standards.
This commit is contained in:
parent
573a402d05
commit
f349f9080b
54
ui/jquery.ui.progressbar.js
vendored
54
ui/jquery.ui.progressbar.js
vendored
@ -18,12 +18,8 @@ $.widget("ui.progressbar", {
|
||||
value: 0
|
||||
},
|
||||
_create: function() {
|
||||
|
||||
this.element
|
||||
.addClass("ui-progressbar"
|
||||
+ " ui-widget"
|
||||
+ " ui-widget-content"
|
||||
+ " ui-corner-all")
|
||||
.addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
|
||||
.attr({
|
||||
role: "progressbar",
|
||||
"aria-valuemin": this._valueMin(),
|
||||
@ -31,31 +27,23 @@ $.widget("ui.progressbar", {
|
||||
"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();
|
||||
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
|
||||
this.element
|
||||
.removeClass("ui-progressbar"
|
||||
+ " ui-widget"
|
||||
+ " ui-widget-content"
|
||||
+ " ui-corner-all")
|
||||
.removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
|
||||
.removeAttr( "role" )
|
||||
.removeAttr( "aria-valuemin" )
|
||||
.removeAttr( "aria-valuemax" )
|
||||
.removeAttr("aria-valuenow")
|
||||
.removeData("progressbar")
|
||||
.unbind(".progressbar");
|
||||
.removeAttr( "aria-valuenow" );
|
||||
|
||||
this.valueDiv.remove();
|
||||
|
||||
$.Widget.prototype.destroy.apply( this, arguments );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
value: function( newValue ) {
|
||||
@ -63,53 +51,53 @@ $.widget("ui.progressbar", {
|
||||
return this._value();
|
||||
}
|
||||
|
||||
this._setOption('value', newValue);
|
||||
this._setOption( "value", newValue );
|
||||
return this;
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
|
||||
switch ( key ) {
|
||||
case 'value':
|
||||
case "value":
|
||||
this.options.value = value;
|
||||
this._refreshValue();
|
||||
this._trigger('change', null, {});
|
||||
this._trigger( "change" );
|
||||
break;
|
||||
}
|
||||
|
||||
$.Widget.prototype._setOption.apply( this, arguments );
|
||||
|
||||
},
|
||||
|
||||
_value: function() {
|
||||
var val = this.options.value;
|
||||
// normalize invalid value
|
||||
if (typeof val != "number")
|
||||
if ( typeof val !== "number" ) {
|
||||
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;
|
||||
|
||||
},
|
||||
|
||||
_valueMin: function() {
|
||||
var valueMin = 0;
|
||||
return valueMin;
|
||||
return 0;
|
||||
},
|
||||
|
||||
_valueMax: function() {
|
||||
var valueMax = 100;
|
||||
return valueMax;
|
||||
return 100;
|
||||
},
|
||||
|
||||
_refreshValue: function() {
|
||||
var value = this.value();
|
||||
this.valueDiv[value == this._valueMax() ? 'addClass' : 'removeClass']("ui-corner-right");
|
||||
this.valueDiv.width(value + '%');
|
||||
this.valueDiv
|
||||
[ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" )
|
||||
.width( value + "%" );
|
||||
this.element.attr( "aria-valuenow", value );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$.extend( $.ui.progressbar, {
|
||||
|
Loading…
Reference in New Issue
Block a user