From 60011b644c0029500bbfde0c4fe9cf9c7788f7d7 Mon Sep 17 00:00:00 2001
From: Hadi Nategh <hn@stylite.de>
Date: Thu, 1 Oct 2015 13:17:41 +0000
Subject: [PATCH] Resize popup window till not getting horizontal scrollbar

---
 phpgwapi/js/jsapi/egw.js | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js
index 46388f6697..7b5345b276 100644
--- a/phpgwapi/js/jsapi/egw.js
+++ b/phpgwapi/js/jsapi/egw.js
@@ -241,6 +241,11 @@
 			// to take padding/margin into account
 			var delta_width = w.width - ($et2.outerWidth(true) + ($main_div.outerWidth(true) - $main_div.width()));
 			var delta_height = w.height - ($et2.outerHeight(true) + ($main_div.outerHeight(true) - $main_div.height()));
+			
+			// Don't let the window gets horizental scrollbar
+			var scrollWidth = document.body.scrollWidth - document.body.clientWidth;
+			if (scrollWidth > 0 && scrollWidth + egw_getWindowOuterWidth() < screen.availWidth) delta_width = -scrollWidth;
+			
 			if (delta_height && egw_getWindowOuterHeight() >= egw.availHeight())
 			{
 				delta_height = 0;