From d4551bc3b8dfbfd925700dcb9f71e7729b125889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 7 Dec 2012 16:57:03 -0500 Subject: [PATCH] Dialog: Respect maxHeight when determining size on open. Fixes #4820 - Dialog: Auto height does not respect the maxHeight option. --- tests/unit/dialog/dialog_common.js | 4 ++-- ui/jquery.ui.dialog.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 9657a9887..1a9b4e109 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -10,8 +10,8 @@ TestHelpers.commonWidgetTests( "dialog", { draggable: true, height: 'auto', hide: null, - maxHeight: false, - maxWidth: false, + maxHeight: null, + maxWidth: null, minHeight: 150, minWidth: 150, modal: false, diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 939571a68..2553109ba 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -48,8 +48,8 @@ $.widget("ui.dialog", { draggable: true, hide: null, height: "auto", - maxHeight: false, - maxWidth: false, + maxHeight: null, + maxWidth: null, minHeight: 150, minWidth: 150, modal: false, @@ -89,6 +89,7 @@ $.widget("ui.dialog", { display: this.element[0].style.display, width: this.element[0].style.width, minHeight: this.element[0].style.minHeight, + maxHeight: this.element[0].style.maxHeight, height: this.element[0].style.height }; this.originalTitle = this.element.attr( "title" ); @@ -632,16 +633,16 @@ $.widget("ui.dialog", { }, _size: function() { - // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content // divs will both have width and height set, so we need to reset them - var nonContentHeight, minContentHeight, + var nonContentHeight, minContentHeight, maxContentHeight, options = this.options; // reset content sizing this.element.show().css({ width: "auto", minHeight: 0, + maxHeight: "none", height: 0 }); @@ -657,14 +658,18 @@ $.widget("ui.dialog", { }) .outerHeight(); minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); + maxContentHeight = typeof options.maxHeight === "number" ? + Math.max( 0, options.maxHeight - nonContentHeight ) : + "none"; if ( options.height === "auto" ) { this.element.css({ minHeight: minContentHeight, + maxHeight: maxContentHeight, height: "auto" }); } else { - this.element.height( Math.max( options.height - nonContentHeight, 0 ) ); + this.element.height( Math.max( 0, options.height - nonContentHeight ) ); } if (this.uiDialog.is( ":data(ui-resizable)" ) ) { -- 2.39.5