CRM-15507 - Increase dialog percent width on small screens
authorColeman Watts <coleman@civicrm.org>
Wed, 22 Oct 2014 13:16:17 +0000 (09:16 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 22 Oct 2014 13:16:17 +0000 (09:16 -0400)
js/crm.ajax.js

index a5b4e8c87e406fcec73ca9232ed3bd48c3949deb..cb9553dd6089c45bc67f4187a4147f1330afe428 100644 (file)
       if (typeof settings.dialog.height === 'string' && settings.dialog.height.indexOf('%') > 0) {
         settings.dialog.height = parseInt($(window).height() * (parseFloat(settings.dialog.height)/100), 10);
       }
+      // Increase percent width on small screens
+      if (typeof settings.dialog.width === 'string' && settings.dialog.width.indexOf('%') > 0) {
+        var screenWidth = $(window).width(),
+          percentage = parseInt(settings.dialog.width.replace('%', ''), 10),
+          gap = 100-percentage;
+        if (screenWidth < 701) {
+          settings.dialog.width = '100%';
+        }
+        else if (screenWidth < 1400) {
+          settings.dialog.width = '' + parseInt(percentage+gap-((screenWidth - 700)/7*(gap)/100), 10) + '%';
+        }
+      }
       $('<div id="'+ settings.target.substring(1) +'"><div class="crm-loading-element">' + ts('Loading') + '...</div></div>').dialog(settings.dialog);
       $(settings.target)
         .on('dialogclose', function() {