Button: Conform to coding standards.

This commit is contained in:
Scott González 2010-03-11 20:10:43 +00:00
parent d3cb190377
commit 057e156e62

View File

@ -18,10 +18,10 @@ var lastActive,
otherClasses = "ui-state-hover ui-state-active " +
"ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon ui-button-text-only",
formResetHandler = function( event ) {
$(':ui-button', event.target.form).each(function() {
var inst = $(this).data('button');
$( ":ui-button", event.target.form ).each(function() {
var inst = $( this ).data( "button" );
setTimeout(function() {
inst.refresh()
inst.refresh();
}, 1 );
});
},
@ -52,7 +52,9 @@ $.widget( "ui.button", {
}
},
_create: function() {
this.element.closest('form').unbind('reset.button').bind('reset.button', formResetHandler);
this.element.closest( "form" )
.unbind( "reset.button" )
.bind( "reset.button", formResetHandler );
this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );
@ -94,8 +96,7 @@ $.widget( "ui.button", {
});
if ( toggleButton ) {
var self = this;
this.element.bind('change.button', function() {
this.element.bind( "change.button", function() {
self.refresh();
});
}
@ -151,11 +152,12 @@ $.widget( "ui.button", {
.bind( "keyup.button", function() {
$( this ).removeClass( "ui-state-active" );
});
if ( this.buttonElement.is("a") ) {
this.buttonElement.keyup(function(event) {
if (event.keyCode == $.ui.keyCode.SPACE) {
if ( event.keyCode === $.ui.keyCode.SPACE ) {
// TODO pass through original event correctly (just as 2nd argument doesn't work)
$(this).trigger("click");
$( this ).click();
}
});
}
@ -224,25 +226,25 @@ $.widget( "ui.button", {
refresh: function() {
if ( this.type === "radio" ) {
radioGroup( this.element[0] ).each(function() {
if ( $(this).is(':checked') ) {
$(this).button('widget')
.addClass('ui-state-active')
.attr('aria-pressed', true);
if ( $( this ).is( ":checked" ) ) {
$( this ).button( "widget" )
.addClass( "ui-state-active" )
.attr( "aria-pressed", true );
} else {
$(this).button('widget')
.removeClass('ui-state-active')
.attr('aria-pressed', false);
$( this ).button( "widget" )
.removeClass( "ui-state-active" )
.attr( "aria-pressed", false );
}
});
} else if ( this.type === "checkbox" ) {
if ( this.element.is(':checked') ) {
if ( this.element.is( ":checked" ) ) {
this.buttonElement
.addClass('ui-state-active')
.attr('aria-pressed', true);
.addClass( "ui-state-active" )
.attr( "aria-pressed", true );
} else {
this.buttonElement
.removeClass('ui-state-active')
.attr('aria-pressed', false);
.removeClass( "ui-state-active" )
.attr( "aria-pressed", false );
}
}
},