From: Richard Worth Date: Sat, 19 Sep 2009 09:35:53 +0000 (+0000) Subject: dialog: fixed enable and disable methods X-Git-Tag: 1.8a2~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=af178c00f160a38dbbaf2fba630ecf9c0ca5ec0b;p=jquery-ui.git dialog: fixed enable and disable methods --- diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index e6ffb14d6..7826979fc 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -68,14 +68,22 @@ test("enable", function() { var expected = $('
').dialog(), actual = expected.dialog('enable'); equals(actual, expected, 'enable is chainable'); - ok(false, 'missing test - untested code is broken code'); + + el = $('
').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 = $('
').dialog(), actual = expected.dialog('disable'); equals(actual, expected, 'disable is chainable'); - ok(false, 'missing test - untested code is broken code'); + + el = $('
').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() { diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 07d1defb1..ddeeda7c6 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -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()