More accurate dialog size calculations
authorColeman Watts <coleman@civicrm.org>
Thu, 28 Aug 2014 15:52:34 +0000 (16:52 +0100)
committerColeman Watts <coleman@civicrm.org>
Thu, 28 Aug 2014 15:52:34 +0000 (16:52 +0100)
js/Common.js
js/crm.ajax.js

index d24689ebe5ee12378385ededf2ff18d0937563df..1a614e3e411ad128c6f7dd27f4c2fbff1433f952 100644 (file)
@@ -551,12 +551,12 @@ CRM.strings = CRM.strings || {};
             $el.dialog('option', $el.data('origSize'));
             $el.data('origSize', null);
           } else {
+            var menuHeight = $('#civicrm-menu').outerHeight();
             $el.data('origSize', {
-              position: {my: 'center', at: 'center', of: window},
+              position: {my: 'center', at: 'center center+' + (menuHeight / 2), of: window},
               width: $el.dialog('option', 'width'),
               height: $el.dialog('option', 'height')
             });
-            var menuHeight = $('#civicrm-menu').height();
             $el.dialog('option', {width: '100%', height: ($(window).height() - menuHeight), position: {my: "top", at: "top+"+menuHeight, of: window}});
           }
           e.preventDefault();
index 0f1cad924249d4c503d072b9d81ee07bcf1ba1ad..2dbcdb738fea73dccf1f9e46204a87cf7ba8a28f 100644 (file)
           }
           // Adjust height to fit content (small delay to allow elements to render)
           window.setTimeout(function() {
-            var currentHeight = $(settings.target).parent().height(),
+            var currentHeight = $(settings.target).parent().outerHeight(),
               padding = currentHeight - $(settings.target).height(),
               newHeight = $(settings.target).prop('scrollHeight') + padding,
-              menuHeight = $('#civicrm-menu').height(),
+              menuHeight = $('#civicrm-menu').outerHeight(),
               maxHeight = $(window).height() - menuHeight;
             newHeight = newHeight > maxHeight ? maxHeight : newHeight;
             if (newHeight > (currentHeight + 15)) {