Skip to main content

Search and Top Navigation

Ticket #3648: dialog-container-r1175.patch


File dialog-container-r1175.patch, 5.9 KB (added by scottgonzalez, December 19, 2008 02:06AM UTC)
Index: /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.dialog.js
===================================================================
--- /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.dialog.js	(revision 1174)
+++ /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.dialog.js	(working copy)
@@ -36,8 +36,39 @@
 		var self = this,
 			options = this.options,
 
+			title = options.title || ' ',
+			titleId = $.ui.dialog.getTitleId(this.element),
+
+			uiDialog = (this.uiDialog = $('
')) + .hide() + .addClass( + 'ui-dialog ' + + 'ui-widget ' + + 'ui-widget-content ' + + 'ui-corner-all ' + + options.dialogClass + ) + .css({ + position: 'absolute', + overflow: 'hidden', + zIndex: options.zIndex + }) + // setting tabIndex makes the div focusable + // setting outline to 0 prevents a border on focus in Mozilla + .attr('tabIndex', -1).css('outline', 0).keydown(function(ev) { + (options.closeOnEscape && ev.keyCode + && ev.keyCode == $.ui.keyCode.ESCAPE && self.close()); + }) + .attr({ + role: 'dialog', + 'aria-labelledby': titleId + }) + .mouseup(function() { + self.moveToTop(); + }) + .appendTo(document.body), + uiDialogContent = this.element - .appendTo(document.body) .removeAttr('title') .addClass( 'ui-dialog-content ' + @@ -42,16 +73,7 @@ .addClass( 'ui-dialog-content ' + 'ui-widget-content') - .wrap('
') - .wrap('
'), - - uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent()) - .addClass('ui-dialog-container') - .css({ - position: 'relative', - width: '100%', - height: '100%' - }), + .appendTo(uiDialog), uiDialogTitlebar = (this.uiDialogTitlebar = $('
')) .addClass( @@ -63,7 +85,7 @@ .mousedown(function() { self.moveToTop(); }) - .prependTo(uiDialogContainer), + .prependTo(uiDialog), uiDialogTitlebarClose = $('') .addClass( @@ -96,8 +118,6 @@ .text(options.closeText) .appendTo(uiDialogTitlebarClose), - title = options.title || ' ', - titleId = $.ui.dialog.getTitleId(this.element), uiDialogTitle = $('') .addClass('ui-dialog-title') .attr('id', titleId) @@ -104,36 +124,6 @@ .html(title) .prependTo(uiDialogTitlebar), - uiDialog = (this.uiDialog = uiDialogContainer.parent()) - .hide() - .addClass( - 'ui-dialog ' + - 'ui-widget ' + - 'ui-widget-content ' + - 'ui-corner-all' - ) - .addClass(options.dialogClass) - .css({ - position: 'absolute', - width: options.width, - height: options.height, - overflow: 'hidden', - zIndex: options.zIndex - }) - // setting tabIndex makes the div focusable - // setting outline to 0 prevents a border on focus in Mozilla - .attr('tabIndex', -1).css('outline', 0).keydown(function(ev) { - (options.closeOnEscape && ev.keyCode - && ev.keyCode == $.ui.keyCode.ESCAPE && self.close()); - }) - .attr({ - role: 'dialog', - 'aria-labelledby': titleId - }) - .mouseup(function() { - self.moveToTop(); - }), - uiDialogButtonPane = (this.uiDialogButtonPane = $('
')) .addClass( 'ui-dialog-buttonpane ' + @@ -140,10 +130,6 @@ 'ui-widget-content ' + 'ui-helper-clearfix' ) - .css({ - position: 'absolute', - bottom: 0 - }) .appendTo(uiDialog); uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); @@ -219,9 +205,9 @@ this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null; (this.uiDialog.next().length && this.uiDialog.appendTo('body')); + this._size(); this._position(this.options.position); this.uiDialog.show(this.options.show); - (this.options.autoResize && this._size()); this.moveToTop(true); // prevent tabbing out of modal dialogs @@ -306,6 +292,7 @@ this.uiDialog.resizable({ cancel: '.ui-dialog-content', + alsoResize: '.ui-dialog-content', helper: options.resizeHelper, maxWidth: options.maxWidth, maxHeight: options.maxHeight, @@ -315,7 +302,6 @@ (options.resizeStart && options.resizeStart.apply(self.element[0], arguments)); }, resize: function() { - (options.autoResize && self._size.apply(self)); (options.resize && options.resize.apply(self.element[0], arguments)); }, handles: resizeHandles, @@ -320,7 +306,6 @@ }, handles: resizeHandles, stop: function() { - (options.autoResize && self._size.apply(self)); (options.resizeStop && options.resizeStop.apply(self.element[0], arguments)); $.ui.dialog.overlay.resize(); } @@ -423,19 +408,28 @@ $.widget.prototype._setData.apply(this, arguments); }, + + _size: function() { + /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content + * divs will both have width and height set + */ - _size: function() { - var container = this.uiDialogContainer, - titlebar = this.uiDialogTitlebar, - content = this.element, - tbMargin = (parseInt(content.css('margin-top'), 10) || 0) - + (parseInt(content.css('margin-bottom'), 10) || 0), - lrMargin = (parseInt(content.css('margin-left'), 10) || 0) - + (parseInt(content.css('margin-right'), 10) || 0); - content.height(container.height() - titlebar.outerHeight() - tbMargin); - content.width(container.width() - lrMargin); + // reset content sizing + this.element.css({ + height: 0, + width: 'auto' + }); + + // reset the wrapper sizing and determine the height of all of the + // non-content elements + var nonContentHeight = this.uiDialog.css({ + height: 'auto', + width: this.options.width + }) + .height(); + + this.element.height(this.options.height - nonContentHeight); } - }); $.extend($.ui.dialog, { @@ -442,7 +436,6 @@ version: "@VERSION", defaults: { autoOpen: true, - autoResize: true, bgiframe: false, buttons: {}, closeOnEscape: true,