Skip to content

Commit

Permalink
Dialog: Batch size-related option settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Sep 27, 2010
1 parent 2dd676e commit e8e3168
Showing 1 changed file with 47 additions and 43 deletions.
90 changes: 47 additions & 43 deletions ui/jquery.ui.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand All @@ -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":
Expand All @@ -553,6 +588,7 @@ $.widget("ui.dialog", {
}
break;
case "draggable":
var isDraggable = uiDialog.is( ":data(draggable)" )
if ( isDraggable && !value ) {
uiDialog.draggable( "destroy" );
}
Expand All @@ -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');
}
Expand All @@ -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() {
Expand Down

0 comments on commit e8e3168

Please sign in to comment.