aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.button.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.button.js')
-rw-r--r--ui/jquery.ui.button.js36
1 files changed, 22 insertions, 14 deletions
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index ff2c1ebb6..78134e308 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -1,9 +1,9 @@
/*
* jQuery UI Button @VERSION
*
- * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
*
* http://docs.jquery.com/UI/Button
*
@@ -11,12 +11,12 @@
* jquery.ui.core.js
* jquery.ui.widget.js
*/
-(function( $ ) {
+(function( $, undefined ) {
var lastActive,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
- 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",
+ stateClasses = "ui-state-hover ui-state-active ",
+ typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
formResetHandler = function( event ) {
$( ":ui-button", event.target.form ).each(function() {
var inst = $( this ).data( "button" );
@@ -44,6 +44,7 @@ var lastActive,
$.widget( "ui.button", {
options: {
+ disabled: null,
text: true,
label: null,
icons: {
@@ -56,6 +57,10 @@ $.widget( "ui.button", {
.unbind( "reset.button" )
.bind( "reset.button", formResetHandler );
+ if ( typeof this.options.disabled !== "boolean" ) {
+ this.options.disabled = this.element.attr( "disabled" );
+ }
+
this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );
@@ -196,7 +201,7 @@ $.widget( "ui.button", {
// we don't search against the document in case the element
// is disconnected from the DOM
this.buttonElement = this.element.parents().last()
- .find( "[for=" + this.element.attr("id") + "]" );
+ .find( "label[for=" + this.element.attr("id") + "]" );
this.element.addClass( "ui-helper-hidden-accessible" );
var checked = this.element.is( ":checked" );
@@ -217,7 +222,7 @@ $.widget( "ui.button", {
this.element
.removeClass( "ui-helper-hidden-accessible" );
this.buttonElement
- .removeClass( baseClasses + " " + otherClasses )
+ .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
.removeAttr( "role" )
.removeAttr( "aria-pressed" )
.html( this.buttonElement.find(".ui-button-text").html() );
@@ -278,7 +283,7 @@ $.widget( "ui.button", {
}
return;
}
- var buttonElement = this.buttonElement,
+ var buttonElement = this.buttonElement.removeClass( typeClasses ),
buttonText = $( "<span></span>" )
.addClass( "ui-button-text" )
.html( this.options.label )
@@ -288,7 +293,7 @@ $.widget( "ui.button", {
multipleIcons = icons.primary && icons.secondary;
if ( icons.primary || icons.secondary ) {
buttonElement.addClass( "ui-button-text-icon" +
- ( multipleIcons ? "s" : "" ) );
+ ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
if ( icons.primary ) {
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
}
@@ -298,7 +303,7 @@ $.widget( "ui.button", {
if ( !this.options.text ) {
buttonElement
.addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" )
- .removeClass( "ui-button-text-icons ui-button-text-icon" );
+ .removeClass( "ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary" );
if ( !this.hasTitle ) {
buttonElement.attr( "title", buttonText );
}
@@ -310,9 +315,12 @@ $.widget( "ui.button", {
});
$.widget( "ui.buttonset", {
+ options: {
+ items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
+ },
+
_create: function() {
this.element.addClass( "ui-buttonset" );
- this._init();
},
_init: function() {
@@ -328,7 +336,7 @@ $.widget( "ui.buttonset", {
},
refresh: function() {
- this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" )
+ this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" )
.button( "refresh" )
.end()
@@ -356,7 +364,7 @@ $.widget( "ui.buttonset", {
})
.removeClass( "ui-corner-left ui-corner-right" )
.end()
- .button( "destroy" )
+ .button( "destroy" );
$.Widget.prototype.destroy.call( this );
}