mirror of
https://github.com/jquery/jquery-ui.git
synced 2026-04-20 03:02:41 -04:00
Button: Use 'that' instead of 'self'. Partial fix for #5404 - remove uses of 'var self = this;'
This commit is contained in:
16
ui/jquery.ui.button.js
vendored
16
ui/jquery.ui.button.js
vendored
@@ -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;
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user