Dialog: Finish refactoring _setOption, getting rid of unnecessary switch (no fallthroughs).

This commit is contained in:
Jörn Zaefferer 2012-11-15 22:58:25 +01:00
parent 7e964be80c
commit 16a79c1b9c

View File

@ -578,22 +578,23 @@ $.widget("ui.dialog", {
this._createButtons(); this._createButtons();
} }
switch ( key ) { if ( key === "closeText" ) {
case "closeText":
// ensure that we always pass a string
this.uiDialogTitlebarClose.button({ this.uiDialogTitlebarClose.button({
// ensure that we always pass a string
label: "" + value label: "" + value
}); });
break; }
case "disabled":
if ( key === "disabled" ) {
// TODO use toggleClass( "ui-dialog-disabled", value ) // TODO use toggleClass( "ui-dialog-disabled", value )
if ( value ) { if ( value ) {
uiDialog.addClass( "ui-dialog-disabled" ); uiDialog.addClass( "ui-dialog-disabled" );
} else { } else {
uiDialog.removeClass( "ui-dialog-disabled" ); uiDialog.removeClass( "ui-dialog-disabled" );
} }
break; }
case "draggable":
if ( key === "draggable" ) {
isDraggable = uiDialog.is( ":data(ui-draggable)" ); isDraggable = uiDialog.is( ":data(ui-draggable)" );
if ( isDraggable && !value ) { if ( isDraggable && !value ) {
uiDialog.draggable( "destroy" ); uiDialog.draggable( "destroy" );
@ -602,11 +603,13 @@ $.widget("ui.dialog", {
if ( !isDraggable && value ) { if ( !isDraggable && value ) {
this._makeDraggable(); this._makeDraggable();
} }
break; }
case "position":
if ( key === "position" ) {
this._position( value ); this._position( value );
break; }
case "resizable":
if ( key === "resizable" ) {
// currently resizable, becoming non-resizable // currently resizable, becoming non-resizable
isResizable = uiDialog.is( ":data(ui-resizable)" ); isResizable = uiDialog.is( ":data(ui-resizable)" );
if ( isResizable && !value ) { if ( isResizable && !value ) {
@ -622,13 +625,13 @@ $.widget("ui.dialog", {
if ( !isResizable && value !== false ) { if ( !isResizable && value !== false ) {
this._makeResizable( value ); this._makeResizable( value );
} }
break; }
case "title":
if ( key === "title" ) {
// convert whatever was passed in to a string, for html() to not throw up // convert whatever was passed in to a string, for html() to not throw up
// TODO deduplicate this (see _create) // TODO deduplicate this (see _create)
$( ".ui-dialog-title", this.uiDialogTitlebar ) $( ".ui-dialog-title", this.uiDialogTitlebar )
.html( "" + ( value || " " ) ); .html( "" + ( value || " " ) );
break;
} }
}, },