From b617847a93655975d4b70e08b061a1e89a1936bd Mon Sep 17 00:00:00 2001 From: john Date: Tue, 2 Oct 2018 13:58:15 +0800 Subject: [PATCH] sync --- Roo/bootstrap/Modal.js | 77 ++++++++++++++++++++++++++++++++++------ roojs-bootstrap-debug.js | 77 ++++++++++++++++++++++++++++++++++------ roojs-bootstrap.js | 20 ++++++----- 3 files changed, 145 insertions(+), 29 deletions(-) diff --git a/Roo/bootstrap/Modal.js b/Roo/bootstrap/Modal.js index c86b429b15..7e63325a35 100644 --- a/Roo/bootstrap/Modal.js +++ b/Roo/bootstrap/Modal.js @@ -292,14 +292,13 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, { return; } - var body_childs = this.bodyEl.dom.childNodes; - // does not seem to give enough space... - var full_height = 60 + this.headerEl.getHeight() + this.footerEl.getHeight(); - for(var i = 0; i < body_childs.length; i++) { - full_height += body_childs[i].offsetHeight; - } - - this.setSize(w, Math.min(full_height, Roo.lib.Dom.getViewportHeight(true) - 60)); + this.setSize(w, Math.min( + 60 + + this.headerEl.getHeight() + + this.footerEl.getHeight() + + this.getChildHeight(this.bodyEl.dom.childNodes), + Roo.lib.Dom.getViewportHeight(true) - 60) + ); } }, @@ -310,8 +309,6 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, { return; } - Roo.log(h); - this.resizeTo(w,h); }, @@ -464,6 +461,66 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, { //code } this.tmpl.overwrite(this.bodyEl, obj); + }, + + getChildHeight : function(child_nodes) + { + if( + !child_nodes || + child_nodes.length == 0 + ) { + return; + } + + var child_height = 0; + + for(var i = 0; i < child_nodes.length; i++) { + + // for modal with tabs... + if(child_nodes[i].classList.contains('roo-layout-panel')) { + + var layout_childs = child_nodes[i].childNodes; + + for(var j = 0; j < layout_childs.length; j++) { + + if(layout_childs[j].classList.contains('roo-layout-panel-body')) { + + var layout_body_childs = layout_childs[j].childNodes; + + for(var k = 0; k < layout_body_childs.length; k++) { + + if(layout_body_childs[k].classList.contains('navbar')) { + child_height += layout_body_childs[k].offsetHeight; + Roo.log('nav height: '+ layout_body_childs[k].offsetHeight); + continue; + } + + if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) { + + var layout_body_tab_childs = layout_body_childs[k].childNodes; + + for(var m = 0; m < layout_body_tab_childs.length; m++) { + + if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) { + child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes); + Roo.log('active panel height: '+this.getChildHeight(layout_body_tab_childs[m].childNodes)); + continue; + } + + } + + } + + } + } + } + continue; + } + + child_height += child_nodes[i].offsetHeight; + } + + return child_height; } }); diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index f19a0515c9..ed57f71a2e 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -2853,14 +2853,13 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, { return; } - var body_childs = this.bodyEl.dom.childNodes; - // does not seem to give enough space... - var full_height = 60 + this.headerEl.getHeight() + this.footerEl.getHeight(); - for(var i = 0; i < body_childs.length; i++) { - full_height += body_childs[i].offsetHeight; - } - - this.setSize(w, Math.min(full_height, Roo.lib.Dom.getViewportHeight(true) - 60)); + this.setSize(w, Math.min( + 60 + + this.headerEl.getHeight() + + this.footerEl.getHeight() + + this.getChildHeight(this.bodyEl.dom.childNodes), + Roo.lib.Dom.getViewportHeight(true) - 60) + ); } }, @@ -2871,8 +2870,6 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, { return; } - Roo.log(h); - this.resizeTo(w,h); }, @@ -3025,6 +3022,66 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, { //code } this.tmpl.overwrite(this.bodyEl, obj); + }, + + getChildHeight : function(child_nodes) + { + if( + !child_nodes || + child_nodes.length == 0 + ) { + return; + } + + var child_height = 0; + + for(var i = 0; i < child_nodes.length; i++) { + + // for modal with tabs... + if(child_nodes[i].classList.contains('roo-layout-panel')) { + + var layout_childs = child_nodes[i].childNodes; + + for(var j = 0; j < layout_childs.length; j++) { + + if(layout_childs[j].classList.contains('roo-layout-panel-body')) { + + var layout_body_childs = layout_childs[j].childNodes; + + for(var k = 0; k < layout_body_childs.length; k++) { + + if(layout_body_childs[k].classList.contains('navbar')) { + child_height += layout_body_childs[k].offsetHeight; + Roo.log('nav height: '+ layout_body_childs[k].offsetHeight); + continue; + } + + if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) { + + var layout_body_tab_childs = layout_body_childs[k].childNodes; + + for(var m = 0; m < layout_body_tab_childs.length; m++) { + + if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) { + child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes); + Roo.log('active panel height: '+this.getChildHeight(layout_body_tab_childs[m].childNodes)); + continue; + } + + } + + } + + } + } + } + continue; + } + + child_height += child_nodes[i].offsetHeight; + } + + return child_height; } }); diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 190346508f..3c8fa8fda0 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -113,15 +113,17 @@ for(var i=0;i