mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Dialog: Finish refactoring _setOption, getting rid of unnecessary switch (no fallthroughs).
This commit is contained in:
parent
7e964be80c
commit
16a79c1b9c
97
ui/jquery.ui.dialog.js
vendored
97
ui/jquery.ui.dialog.js
vendored
@ -578,57 +578,60 @@ $.widget("ui.dialog", {
|
|||||||
this._createButtons();
|
this._createButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( key ) {
|
if ( key === "closeText" ) {
|
||||||
case "closeText":
|
this.uiDialogTitlebarClose.button({
|
||||||
// ensure that we always pass a string
|
// ensure that we always pass a string
|
||||||
this.uiDialogTitlebarClose.button({
|
label: "" + value
|
||||||
label: "" + value
|
});
|
||||||
});
|
}
|
||||||
break;
|
|
||||||
case "disabled":
|
|
||||||
// TODO use toggleClass( "ui-dialog-disabled", value )
|
|
||||||
if ( value ) {
|
|
||||||
uiDialog.addClass( "ui-dialog-disabled" );
|
|
||||||
} else {
|
|
||||||
uiDialog.removeClass( "ui-dialog-disabled" );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "draggable":
|
|
||||||
isDraggable = uiDialog.is( ":data(ui-draggable)" );
|
|
||||||
if ( isDraggable && !value ) {
|
|
||||||
uiDialog.draggable( "destroy" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !isDraggable && value ) {
|
if ( key === "disabled" ) {
|
||||||
this._makeDraggable();
|
// TODO use toggleClass( "ui-dialog-disabled", value )
|
||||||
}
|
if ( value ) {
|
||||||
break;
|
uiDialog.addClass( "ui-dialog-disabled" );
|
||||||
case "position":
|
} else {
|
||||||
this._position( value );
|
uiDialog.removeClass( "ui-dialog-disabled" );
|
||||||
break;
|
}
|
||||||
case "resizable":
|
}
|
||||||
// currently resizable, becoming non-resizable
|
|
||||||
isResizable = uiDialog.is( ":data(ui-resizable)" );
|
|
||||||
if ( isResizable && !value ) {
|
|
||||||
uiDialog.resizable( "destroy" );
|
|
||||||
}
|
|
||||||
|
|
||||||
// currently resizable, changing handles
|
if ( key === "draggable" ) {
|
||||||
if ( isResizable && typeof value === "string" ) {
|
isDraggable = uiDialog.is( ":data(ui-draggable)" );
|
||||||
uiDialog.resizable( "option", "handles", value );
|
if ( isDraggable && !value ) {
|
||||||
}
|
uiDialog.draggable( "destroy" );
|
||||||
|
}
|
||||||
|
|
||||||
// currently non-resizable, becoming resizable
|
if ( !isDraggable && value ) {
|
||||||
if ( !isResizable && value !== false ) {
|
this._makeDraggable();
|
||||||
this._makeResizable( value );
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "title":
|
if ( key === "position" ) {
|
||||||
// convert whatever was passed in to a string, for html() to not throw up
|
this._position( value );
|
||||||
// TODO deduplicate this (see _create)
|
}
|
||||||
$( ".ui-dialog-title", this.uiDialogTitlebar )
|
|
||||||
.html( "" + ( value || " " ) );
|
if ( key === "resizable" ) {
|
||||||
break;
|
// currently resizable, becoming non-resizable
|
||||||
|
isResizable = uiDialog.is( ":data(ui-resizable)" );
|
||||||
|
if ( isResizable && !value ) {
|
||||||
|
uiDialog.resizable( "destroy" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// currently resizable, changing handles
|
||||||
|
if ( isResizable && typeof value === "string" ) {
|
||||||
|
uiDialog.resizable( "option", "handles", value );
|
||||||
|
}
|
||||||
|
|
||||||
|
// currently non-resizable, becoming resizable
|
||||||
|
if ( !isResizable && value !== false ) {
|
||||||
|
this._makeResizable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( key === "title" ) {
|
||||||
|
// convert whatever was passed in to a string, for html() to not throw up
|
||||||
|
// TODO deduplicate this (see _create)
|
||||||
|
$( ".ui-dialog-title", this.uiDialogTitlebar )
|
||||||
|
.html( "" + ( value || " " ) );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user