diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-09-27 15:15:20 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-09-27 15:15:20 -0400 |
commit | e8e3168a3930bcd6689a079e5e210877f836a977 (patch) | |
tree | 98214d6db79cdd96a4b4d91a5f0efd85c1931914 /ui/jquery.ui.dialog.js | |
parent | 2dd676e18a8d230513c4d66fce79f1b0072f89e6 (diff) | |
download | jquery-ui-e8e3168a3930bcd6689a079e5e210877f836a977.tar.gz jquery-ui-e8e3168a3930bcd6689a079e5e210877f836a977.zip |
Dialog: Batch size-related option settings.
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r-- | ui/jquery.ui.dialog.js | 90 |
1 files changed, 47 insertions, 43 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 029f91905..11cc1960b 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -19,10 +19,25 @@ (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 || ' ')); break; - case "width": - resize = true; - break; } $.Widget.prototype._setOption.apply(self, arguments); - if (resize) { - self._size(); - } }, _size: function() { |