Dialog: Refactor _setOption to call _super early. Move dialogClass update above that to access old option value.

This commit is contained in:
Jörn Zaefferer 2012-11-15 22:51:26 +01:00
parent 83a9f219bf
commit fed2972027
2 changed files with 12 additions and 8 deletions

View File

@ -148,7 +148,7 @@ test("closeText", function() {
});
test("dialogClass", function() {
expect(4);
expect( 6 );
var el = $('<div></div>').dialog();
equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added');
@ -156,6 +156,9 @@ test("dialogClass", function() {
el = $('<div></div>').dialog({ dialogClass: "foo" });
equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added');
el.dialog( "option", "dialogClass", "foobar" );
equal( el.dialog('widget').is(".foo"), false, "dialogClass changed, previous one was removed" );
equal( el.dialog('widget').is(".foobar"), true, "dialogClass changed, new one was added" );
el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo bar" });

View File

@ -565,6 +565,14 @@ $.widget("ui.dialog", {
var isDraggable, isResizable,
uiDialog = this.uiDialog;
if ( key === "dialogClass" ) {
uiDialog
.removeClass( this.options.dialogClass )
.addClass( value );
}
this._super( key, value );
switch ( key ) {
case "buttons":
this._createButtons( value );
@ -575,11 +583,6 @@ $.widget("ui.dialog", {
label: "" + value
});
break;
case "dialogClass":
uiDialog
.removeClass( this.options.dialogClass )
.addClass( value );
break;
case "disabled":
// TODO use toggleClass( "ui-dialog-disabled", value )
if ( value ) {
@ -625,8 +628,6 @@ $.widget("ui.dialog", {
.html( "" + ( value || "&#160;" ) );
break;
}
this._super( key, value );
},
_size: function() {