]> source.dussan.org Git - jquery-ui.git/commitdiff
dialog: fixed enable and disable methods
authorRichard Worth <rdworth@gmail.com>
Sat, 19 Sep 2009 09:35:53 +0000 (09:35 +0000)
committerRichard Worth <rdworth@gmail.com>
Sat, 19 Sep 2009 09:35:53 +0000 (09:35 +0000)
tests/unit/dialog/dialog_methods.js
ui/jquery.ui.dialog.js

index e6ffb14d6357e207a176996e489f8bc6297020cf..7826979fca416e9262a9daaf5d21f77e38f3215a 100644 (file)
@@ -68,14 +68,22 @@ test("enable", function() {
        var expected = $('<div></div>').dialog(),
                actual = expected.dialog('enable');
        equals(actual, expected, 'enable is chainable');
-       ok(false, 'missing test - untested code is broken code');
+       
+       el = $('<div></div>').dialog({ disabled: true });
+       el.dialog('enable');
+       equals(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
+       ok(!el.parents('.ui-dialog').hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element');
 });
 
 test("disable", function() {
        var expected = $('<div></div>').dialog(),
                actual = expected.dialog('disable');
        equals(actual, expected, 'disable is chainable');
-       ok(false, 'missing test - untested code is broken code');
+       
+       el = $('<div></div>').dialog({ disabled: false });
+       el.dialog('disable');
+       equals(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
+       ok(el.parents('.ui-dialog').hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element');
 });
 
 test("close", function() {
index 07d1defb1db6a49383f0d759b688d9b64ab9ec3b..ddeeda7c680f251352545652049219005141e5bb 100644 (file)
@@ -442,6 +442,11 @@ $.widget("ui.dialog", {
                                        .removeClass(self.options.dialogClass)
                                        .addClass(uiDialogClasses + value);
                                break;
+                       case "disabled":
+                               (value
+                                       ? uiDialog.addClass('ui-dialog-disabled')
+                                       : uiDialog.removeClass('ui-dialog-disabled'));
+                               break;
                        case "draggable":
                                (value
                                        ? self._makeDraggable()