]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Finish refactoring _setOption, getting rid of unnecessary switch (no fallthro...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 15 Nov 2012 21:58:25 +0000 (22:58 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 26 Nov 2012 09:28:22 +0000 (10:28 +0100)
ui/jquery.ui.dialog.js

index 58989847666b40cf3d3384e48bbd4faf876e07ed..70d0f300cd640349ad4f91b10bb3d840a9914ad1 100644 (file)
@@ -578,57 +578,60 @@ $.widget("ui.dialog", {
                        this._createButtons();
                }
 
-               switch ( key ) {
-                       case "closeText":
+               if ( key === "closeText" ) {
+                       this.uiDialogTitlebarClose.button({
                                // ensure that we always pass a string
-                               this.uiDialogTitlebarClose.button({
-                                       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" );
-                               }
+                               label: "" + value
+                       });
+               }
 
-                               if ( !isDraggable && value ) {
-                                       this._makeDraggable();
-                               }
-                               break;
-                       case "position":
-                               this._position( value );
-                               break;
-                       case "resizable":
-                               // currently resizable, becoming non-resizable
-                               isResizable = uiDialog.is( ":data(ui-resizable)" );
-                               if ( isResizable && !value ) {
-                                       uiDialog.resizable( "destroy" );
-                               }
+               if ( key === "disabled" ) {
+                       // TODO use toggleClass( "ui-dialog-disabled", value )
+                       if ( value ) {
+                               uiDialog.addClass( "ui-dialog-disabled" );
+                       } else {
+                               uiDialog.removeClass( "ui-dialog-disabled" );
+                       }
+               }
 
-                               // currently resizable, changing handles
-                               if ( isResizable && typeof value === "string" ) {
-                                       uiDialog.resizable( "option", "handles", value );
-                               }
+               if ( key === "draggable" ) {
+                       isDraggable = uiDialog.is( ":data(ui-draggable)" );
+                       if ( isDraggable && !value ) {
+                               uiDialog.draggable( "destroy" );
+                       }
 
-                               // currently non-resizable, becoming resizable
-                               if ( !isResizable && value !== false ) {
-                                       this._makeResizable( value );
-                               }
-                               break;
-                       case "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 || "&#160;" ) );
-                               break;
+                       if ( !isDraggable && value ) {
+                               this._makeDraggable();
+                       }
+               }
+
+               if ( key === "position" ) {
+                       this._position( value );
+               }
+
+               if ( key === "resizable" ) {
+                       // 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 || "&#160;" ) );
                }
        },