\r
var defaults = {\r
autoOpen: true,\r
+ autoResize: true,\r
buttons: {},\r
disabled: false,\r
dialogClass: null,\r
el.remove();\r
});\r
\r
+test("autoResize", function() {\r
+ expect(2);\r
+ el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: false });\r
+ var expected = { height: el.height() };\r
+ var handle = $(".ui-resizable-se", dlg());\r
+ drag(handle, 50, 50);\r
+ var actual = { height: el.height() };\r
+ compare2(actual, expected, '.dialog({ autoResize: false })');\r
+ el.remove();\r
+ el = $('<div>content<br>content<br>content<br>content<br>content</div>').dialog({ autoResize: true });\r
+ var before = { width: el.width(), height: el.height() };\r
+ var handle = $(".ui-resizable-se", dlg());\r
+ drag(handle, 50, 50);\r
+ var expected = { width: before.width + 50, height: before.height + 50 };\r
+ var actual = { width: el.width(), height: el.height() };\r
+ compare2(actual, expected, '.dialog({ autoResize: true })');\r
+ el.remove();\r
+});\r
+\r
test("buttons", function() {\r
expect(14);\r
var buttons = {\r
.wrap('<div/>')
.wrap('<div/>'),
- uiDialogContainer = uiDialogContent.parent()
+ uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent()
.addClass('ui-dialog-container')
- .css({position: 'relative'}),
+ .css({position: 'relative', width: '100%', height: '100%'})),
title = options.title || uiDialogContent.attr('title') || '',
uiDialogTitlebar = (this.uiDialogTitlebar =
(options.resizeStart && options.resizeStart.apply(self.element[0], arguments));
},
resize: function(e, ui) {
+ (options.autoResize && self.size.apply(self));
(options.resize && options.resize.apply(self.element[0], arguments));
},
handles: resizeHandles,
stop: function(e, ui) {
+ (options.autoResize && self.size.apply(self));
(options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
$.ui.dialog.overlay.resize();
}
pTop = Math.max(pTop, minTop);
this.uiDialog.css({top: pTop, left: pLeft});
},
+
+ size: function() {
+ var container = this.uiDialogContainer,
+ titlebar = this.uiDialogTitlebar,
+ content = this.element,
+ tbMargin = parseInt(content.css('margin-top')) + parseInt(content.css('margin-bottom')),
+ lrMargin = parseInt(content.css('margin-left')) + parseInt(content.css('margin-right'));
+ content.height(container.height() - titlebar.outerHeight() - tbMargin);
+ content.width(container.width() - lrMargin);
+ },
open: function() {
this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
this.uiDialog.appendTo('body');
this.position(this.options.position);
this.uiDialog.show(this.options.show);
+ this.options.autoResize && this.size();
this.moveToTop(true);
// CALLBACK: open
$.extend($.ui.dialog, {
defaults: {
autoOpen: true,
+ autoResize: true,
bgiframe: false,
buttons: {},
closeOnEscape: true,