]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Batch size-related option settings.
authorScott González <scott.gonzalez@gmail.com>
Mon, 27 Sep 2010 19:15:20 +0000 (15:15 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 27 Sep 2010 19:15:20 +0000 (15:15 -0400)
ui/jquery.ui.dialog.js

index 029f91905cfcbd8ae5b0a43c2f1eb3b668a6d8a9..11cc1960b024e09348214f04d52ea8482deafd54 100644 (file)
 (function( $, undefined ) {
 
 var uiDialogClasses =
-       'ui-dialog ' +
-       'ui-widget ' +
-       'ui-widget-content ' +
-       'ui-corner-all ';
+               'ui-dialog ' +
+               'ui-widget ' +
+               'ui-widget-content ' +
+               'ui-corner-all ',
+       sizeRelatedOptions = {
+               buttons: true,
+               height: true,
+               maxHeight: true,
+               maxWidth: true,
+               minHeight: true,
+               minWidth: true,
+               width: true
+       },
+       resizableRelatedOptions = {
+               maxHeight: true,
+               maxWidth: true,
+               minHeight: true,
+               minWidth: true
+       };
 
 $.widget("ui.dialog", {
        options: {
@@ -518,13 +533,34 @@ $.widget("ui.dialog", {
                }
        },
 
-       _setOption: function(key, value){
+       _setOptions: function( options ) {
                var self = this,
-                       uiDialog = self.uiDialog,
-                       isDraggable = uiDialog.is( ":data(draggable)" ),
-                       isResizable = uiDialog.is( ":data(resizable)" ),
+                       resizableOptions = {},
                        resize = false;
 
+               $.each( options, function( key, value ) {
+                       self._setOption( key, value );
+                       
+                       if ( key in sizeRelatedOptions ) {
+                               resize = true;
+                       }
+                       if ( key in resizableRelatedOptions ) {
+                               resizableOptions[ key ] = value;
+                       }
+               });
+
+               if ( resize ) {
+                       this._size();
+               }
+               if ( this.uiDialog.is( ":data(resizable)" ) ) {
+                       this.uiDialog.resizable( "option", resizableOptions );
+               }
+       },
+
+       _setOption: function(key, value){
+               var self = this,
+                       uiDialog = self.uiDialog;
+
                switch (key) {
                        //handling of deprecated beforeclose (vs beforeClose) option
                        //Ticket #4669 http://dev.jqueryui.com/ticket/4669
@@ -534,10 +570,9 @@ $.widget("ui.dialog", {
                                break;
                        case "buttons":
                                self._createButtons(value);
-                               resize = true;
                                break;
                        case "closeText":
-                               // convert whatever was passed in to a string, for text() to not throw up
+                               // ensure that we always pass a string
                                self.uiDialogTitlebarCloseText.text("" + value);
                                break;
                        case "dialogClass":
@@ -553,6 +588,7 @@ $.widget("ui.dialog", {
                                }
                                break;
                        case "draggable":
+                               var isDraggable = uiDialog.is( ":data(draggable)" )
                                if ( isDraggable && !value ) {
                                        uiDialog.draggable( "destroy" );
                                }
@@ -561,38 +597,12 @@ $.widget("ui.dialog", {
                                        self._makeDraggable();
                                }
                                break;
-                       case "height":
-                               resize = true;
-                               break;
-                       case "maxHeight":
-                               if (isResizable) {
-                                       uiDialog.resizable('option', 'maxHeight', value);
-                               }
-                               resize = true;
-                               break;
-                       case "maxWidth":
-                               if (isResizable) {
-                                       uiDialog.resizable('option', 'maxWidth', value);
-                               }
-                               resize = true;
-                               break;
-                       case "minHeight":
-                               if (isResizable) {
-                                       uiDialog.resizable('option', 'minHeight', value);
-                               }
-                               resize = true;
-                               break;
-                       case "minWidth":
-                               if (isResizable) {
-                                       uiDialog.resizable('option', 'minWidth', value);
-                               }
-                               resize = true;
-                               break;
                        case "position":
                                self._position(value);
                                break;
                        case "resizable":
                                // currently resizable, becoming non-resizable
+                               var isResizable = uiDialog.is( ":data(resizable)" )
                                if (isResizable && !value) {
                                        uiDialog.resizable('destroy');
                                }
@@ -611,15 +621,9 @@ $.widget("ui.dialog", {
                                // convert whatever was passed in o a string, for html() to not throw up
                                $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
                                break;
-                       case "width":
-                               resize = true;
-                               break;
                }
 
                $.Widget.prototype._setOption.apply(self, arguments);
-               if (resize) {
-                       self._size();
-               }
        },
 
        _size: function() {