+ })
+ // Auto-resize dialogs when loading content
+ .on('crmLoad dialogopen', 'div.ui-dialog.ui-resizable.crm-container', function(e) {
+ var
+ $wrapper = $(this),
+ $dialog = $wrapper.children('.ui-dialog-content');
+ // small delay to allow contents to render
+ window.setTimeout(function() {
+ var currentHeight = $wrapper.outerHeight(),
+ padding = currentHeight - $dialog.height(),
+ newHeight = $dialog.prop('scrollHeight') + padding,
+ menuHeight = $('#civicrm-menu').outerHeight(),
+ maxHeight = $(window).height() - menuHeight;
+ newHeight = newHeight > maxHeight ? maxHeight : newHeight;
+ if (newHeight > (currentHeight + 15)) {
+ $dialog.dialog('option', {
+ position: {my: 'center', at: 'center center+' + (menuHeight / 2), of: window},
+ height: newHeight
+ });
+ }
+ }, 500);