From 41bd8d0da292d6905ac00202390309dce03da855 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 24 Jun 2021 16:25:37 +0200 Subject: [PATCH] Avoid triggering initial resize if not necessary --- api/js/jsapi/egw.js | 3 ++- api/js/jsapi/jsapi.js | 35 ++++++----------------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/api/js/jsapi/egw.js b/api/js/jsapi/egw.js index b65ad41def..ac4de1baa9 100644 --- a/api/js/jsapi/egw.js +++ b/api/js/jsapi/egw.js @@ -280,6 +280,7 @@ // Don't let the window gets horizental scrollbar var scrollWidth = document.body.scrollWidth - document.body.clientWidth; + var scrollHeight = document.body.scrollHeight - w.height; if (scrollWidth > 0 && scrollWidth + egw_getWindowOuterWidth() < screen.availWidth) delta_width = -scrollWidth; if (delta_height && egw_getWindowOuterHeight() >= egw.availHeight()) @@ -287,7 +288,7 @@ delta_height = 0; } if((delta_width != 0 || delta_height != 0) && - (delta_width >2 || delta_height >2 || delta_width<-2 || delta_height < -2)) + (delta_width >2 || delta_height >2 || delta_width<-2 || delta_height < -2) && (scrollHeight>0 || scrollWidth>0)) { if (window.framework && typeof window.framework.resize_popup != 'undefined') diff --git a/api/js/jsapi/jsapi.js b/api/js/jsapi/jsapi.js index 135789c8f3..8e3473ff41 100644 --- a/api/js/jsapi/jsapi.js +++ b/api/js/jsapi/jsapi.js @@ -19,7 +19,6 @@ if (document.all) navigator.userAgent.toLowerCase().indexOf('msie 5') != -1 ? is_ie5 = true : is_ie5 = false; is_ie = true; is_moz1_6 = false; - is_mozilla = false; is_ns4 = false; } else if (document.getElementById) @@ -27,7 +26,6 @@ else if (document.getElementById) navigator.userAgent.toLowerCase().match('mozilla.*rv[:]1\.6.*gecko') ? is_moz1_6 = true : is_moz1_6 = false; is_ie = false; is_ie5 = false; - is_mozilla = true; is_ns4 = false; } else if (document.layers) @@ -35,7 +33,6 @@ else if (document.layers) is_ie = false; is_ie5 = false; is_moz1_6 = false; - is_mozilla = false; is_ns4 = true; } @@ -399,7 +396,7 @@ function egw_getWindowLeft() { // workaround for Fennec bug https://bugzilla.mozilla.org/show_bug.cgi?format=multiple&id=648250 window.(outerHeight|outerWidth|screenX|screenY) throw exception try { - if(is_mozilla) return window.screenX; + return window.screenX; } catch (e) {} @@ -411,7 +408,7 @@ function egw_getWindowTop() { // workaround for Fennec bug https://bugzilla.mozilla.org/show_bug.cgi?format=multiple&id=648250 window.(outerHeight|outerWidth|screenX|screenY) throw exception try { - if(is_mozilla) return window.screenY; + return window.screenY; } catch (e) {} @@ -421,33 +418,13 @@ function egw_getWindowTop() // get the outerWidth of the browser window. For IE we simply return the innerWidth function egw_getWindowInnerWidth() { - if (is_mozilla) - { - return window.innerWidth; - } - else - { - // works only after the body has parsed - //return document.body.offsetWidth; - return document.body.clientWidth; - //return document.documentElement.clientWidth; - } + return window.innerWidth; } // get the outerHeight of the browser window. For IE we simply return the innerHeight function egw_getWindowInnerHeight() { - if (is_mozilla) - { - return window.innerHeight; - } - else - { - // works only after the body has parsed - //return document.body.offsetHeight; - //return document.body.clientHeight; - return document.documentElement.clientHeight; - } + return window.innerHeight; } // get the outerWidth of the browser window. For IE we simply return the innerWidth @@ -455,7 +432,7 @@ function egw_getWindowOuterWidth() { // workaround for Fennec bug https://bugzilla.mozilla.org/show_bug.cgi?format=multiple&id=648250 window.(outerHeight|outerWidth|screenX|screenY) throw exception try { - if (is_mozilla) return window.outerWidth; + return window.outerWidth; } catch (e) {} @@ -467,7 +444,7 @@ function egw_getWindowOuterHeight() { // workaround for Fennec bug https://bugzilla.mozilla.org/show_bug.cgi?format=multiple&id=648250 window.(outerHeight|outerWidth|screenX|screenY) throw exception try { - if (is_mozilla) return window.outerHeight; + return window.outerHeight; } catch (e) {}