]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Read disabled attribute from original element if disabled option is null...
authorScott González <scott.gonzalez@gmail.com>
Wed, 18 Aug 2010 18:51:30 +0000 (14:51 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 18 Aug 2010 18:51:30 +0000 (14:51 -0400)
tests/unit/button/button_defaults.js
tests/unit/button/button_options.js
ui/jquery.ui.button.js

index e1657854a15a14d7c83553c66e511c0d34c4a1cb..b81fa7cbbe139c3691364cae1cbf65c9e831a935 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 var button_defaults = {
-       disabled: false,
+       disabled: null,
        text: true,
        label: null,
        icons: {
index 6ee8ab541e22ca67fb26ca7b01c1c7c77acf899d..5b25ecd631ac2c4a21bf305536ae22f18d912f2e 100644 (file)
@@ -5,6 +5,30 @@
 
 module("button: options");
 
+test("disabled, explicity value", function() {
+       $("#radio01").button({ disabled: false });
+       same(false, $("#radio01").button("option", "disabled"),
+               "disabled option set to false");
+       same(false, $("#radio01").attr("disabled"), "element is disabled");
+       
+       $("#radio02").button({ disabled: true });
+       same(true, $("#radio02").button("option", "disabled"),
+               "disabled option set to true");
+       same(true, $("#radio02").attr("disabled"), "element is not disabled");
+});
+
+test("disabled, null", function() {
+       $("#radio01").button({ disabled: null });
+       same(false, $("#radio01").button("option", "disabled"),
+               "disabled option set to false");
+       same(false, $("#radio01").attr("disabled"), "element is disabled");
+       
+       $("#radio02").attr("disabled", "disabled").button({ disabled: null });
+       same(true, $("#radio02").button("option", "disabled"),
+               "disabled option set to true");
+       same(true, $("#radio02").attr("disabled"), "element is not disabled");
+});
+
 test("text false without icon", function() {
        $("#button").button({
                text: false
index 7d21fa495b950540e082e53e4bbe3fa1969af71b..5e52fb4cb81be7d54951c9e37d8864d3dd4d7998 100644 (file)
@@ -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" );