Button: Use 'that' instead of 'self'. Partial fix for #5404 - remove uses of 'var self = this;'

This commit is contained in:
Scott González
2012-02-12 09:25:41 -05:00
parent 5c7be4798f
commit 41a1472469

View File

@@ -66,7 +66,7 @@ $.widget( "ui.button", {
this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );
var self = this,
var that = this,
options = this.options,
toggleButton = this.type === "checkbox" || this.type === "radio",
hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
@@ -104,10 +104,10 @@ $.widget( "ui.button", {
this.element
.bind( "focus.button", function() {
// no need to check disabled, focus won't be triggered anyway
self.buttonElement.addClass( focusClass );
that.buttonElement.addClass( focusClass );
})
.bind( "blur.button", function() {
self.buttonElement.removeClass( focusClass );
that.buttonElement.removeClass( focusClass );
});
if ( toggleButton ) {
@@ -115,7 +115,7 @@ $.widget( "ui.button", {
if ( clickDragged ) {
return;
}
self.refresh();
that.refresh();
});
// if mouse moves between mousedown and mouseup (drag) set clickDragged flag
// prevents issue where button state changes but checkbox/radio checked state
@@ -145,7 +145,7 @@ $.widget( "ui.button", {
return false;
}
$( this ).toggleClass( "ui-state-active" );
self.buttonElement.attr( "aria-pressed", self.element[0].checked );
that.buttonElement.attr( "aria-pressed", that.element[0].checked );
});
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click.button", function() {
@@ -153,9 +153,9 @@ $.widget( "ui.button", {
return false;
}
$( this ).addClass( "ui-state-active" );
self.buttonElement.attr( "aria-pressed", "true" );
that.buttonElement.attr( "aria-pressed", "true" );
var radio = self.element[ 0 ];
var radio = that.element[ 0 ];
radioGroup( radio )
.not( radio )
.map(function() {
@@ -172,7 +172,7 @@ $.widget( "ui.button", {
}
$( this ).addClass( "ui-state-active" );
lastActive = this;
self.document.one( "mouseup", function() {
that.document.one( "mouseup", function() {
lastActive = null;
});
})