sync
authorjohn <john@roojs.com>
Fri, 7 Dec 2018 05:21:33 +0000 (13:21 +0800)
committerjohn <john@roojs.com>
Fri, 7 Dec 2018 05:21:33 +0000 (13:21 +0800)
Roo/bootstrap/Modal.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index 73b5cf3..d3d2608 100644 (file)
@@ -287,9 +287,12 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
         );
         
         if (this.fitwindow) {
+            
+            var view_height = Roo.lib.Dom.getViewportHeight(true);
+            
             this.setSize(
                 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
-                this.height || Roo.lib.Dom.getViewportHeight(true) - 60
+                this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
             );
             return;
         }
@@ -452,22 +455,18 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     {
         //this.el.select('.modal-footer').()
     },
-    diff : false,
 
     resizeTo: function(w,h)
     {
-        // skip.. ?? why??
-
         this.dialogEl.setWidth(w);
-        if (this.diff === false) {
-            this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
-        }
-
-        this.bodyEl.setHeight(h - this.diff);
+        
+        var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 30; // dialog margin-bottom: 30  
 
+        this.bodyEl.setHeight(h - diff);
+        
         this.fireEvent('resize', this);
-
     },
+    
     setContentSize  : function(w, h)
     {
 
index 88785e9..3d4f568 100644 (file)
@@ -2917,9 +2917,15 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
         );
         
         if (this.fitwindow) {
+            
+            var view_height = Roo.lib.Dom.getViewportHeight(true);
+            
+            Roo.log("dialog height: "+this.height);
+            Roo.log("view height:" + view_height);
+            
             this.setSize(
                 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
-                this.height || Roo.lib.Dom.getViewportHeight(true) - 60
+                this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
             );
             return;
         }
@@ -3082,22 +3088,18 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     {
         //this.el.select('.modal-footer').()
     },
-    diff : false,
 
     resizeTo: function(w,h)
     {
-        // skip.. ?? why??
-
         this.dialogEl.setWidth(w);
-        if (this.diff === false) {
-            this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
-        }
-
-        this.bodyEl.setHeight(h - this.diff);
+        
+        var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 30; // dialog margin-bottom: 30  
 
+        this.bodyEl.setHeight(h - diff);
+        
         this.fireEvent('resize', this);
-
     },
+    
     setContentSize  : function(w, h)
     {
 
index f70eb59..0b57d30 100644 (file)
@@ -117,17 +117,17 @@ i<D.length;i++){C.push(this.addxtype(Roo.apply({},D[i])));}}this.items=C;this.in
 if(this.allow_close&&Roo.bootstrap.version==3){C.push({tag:'button',cls:'close',html:'&times'});}C.push(B);if(this.allow_close&&Roo.bootstrap.version==4){C.push({tag:'button',cls:'close',html:'&times'});}var D='';if(this.size.length){D='modal-'+this.size;
 }var E=Roo.bootstrap.version==3?{cls:'modal-footer',cn:[{tag:'div',cls:'btn-'+this.buttonPosition}]}:{cls:'modal-footer'};var F={cls:"modal",cn:[{cls:"modal-dialog "+D,cn:[{cls:"modal-content",cn:[{cls:'modal-header',cn:C},A,E]}]}]};if(this.animate){F.cls+=' fade';
 }return F;},getChildContainer:function(){return this.bodyEl;},getButtonContainer:function(){return Roo.bootstrap.version==4?this.el.select('.modal-footer',true).first():this.el.select('.modal-footer div',true).first();},initEvents:function(){if(this.allow_close){this.closeEl.on('click',this.hide,this);
-}Roo.EventManager.onWindowResize(this.resize,this,true);},resize:function(){this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true),Roo.lib.Dom.getViewHeight(true));if(this.fitwindow){this.setSize(this.width||Roo.lib.Dom.getViewportWidth(true)-30,this.height||Roo.lib.Dom.getViewportHeight(true)-60);
-return;}if(this.max_width!==0){var w=Math.min(this.max_width,Roo.lib.Dom.getViewportWidth(true)-30);if(this.height){this.setSize(w,this.height);return;}if(this.max_height){this.setSize(w,Math.min(this.max_height,Roo.lib.Dom.getViewportHeight(true)-60));return;
-}if(!this.fit_content){this.setSize(w,Roo.lib.Dom.getViewportHeight(true)-60);return;}this.setSize(w,Math.min(60+this.headerEl.getHeight()+this.footerEl.getHeight()+this.getChildHeight(this.bodyEl.dom.childNodes),Roo.lib.Dom.getViewportHeight(true)-60));}
-},setSize:function(w,h){if(!w&&!h){return;}this.resizeTo(w,h);},show:function(){if(!this.rendered){this.render();}this.el.removeClass('hideing');this.el.dom.style.display='block';Roo.get(document.body).addClass('modal-open');if(this.animate){var A=this;(function(){this.el.addClass('show');
+}Roo.EventManager.onWindowResize(this.resize,this,true);},resize:function(){this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true),Roo.lib.Dom.getViewHeight(true));if(this.fitwindow){var A=Roo.lib.Dom.getViewportHeight(true);Roo.log("dialog height: "+this.height);
+Roo.log("view height:"+A);this.setSize(this.width||Roo.lib.Dom.getViewportWidth(true)-30,this.height||Roo.lib.Dom.getViewportHeight(true));return;}if(this.max_width!==0){var w=Math.min(this.max_width,Roo.lib.Dom.getViewportWidth(true)-30);if(this.height){this.setSize(w,this.height);
+return;}if(this.max_height){this.setSize(w,Math.min(this.max_height,Roo.lib.Dom.getViewportHeight(true)-60));return;}if(!this.fit_content){this.setSize(w,Roo.lib.Dom.getViewportHeight(true)-60);return;}this.setSize(w,Math.min(60+this.headerEl.getHeight()+this.footerEl.getHeight()+this.getChildHeight(this.bodyEl.dom.childNodes),Roo.lib.Dom.getViewportHeight(true)-60));
+}},setSize:function(w,h){if(!w&&!h){return;}this.resizeTo(w,h);},show:function(){if(!this.rendered){this.render();}this.el.removeClass('hideing');this.el.dom.style.display='block';Roo.get(document.body).addClass('modal-open');if(this.animate){var A=this;(function(){this.el.addClass('show');
 this.el.addClass('in');}).defer(50,this);}else{this.el.addClass('show');this.el.addClass('in');}Roo.get(document.body).addClass("x-body-masked");this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true),Roo.lib.Dom.getViewHeight(true));this.maskEl.setStyle('z-index',Roo.bootstrap.Modal.zIndex++);
 this.maskEl.dom.style.display='block';this.maskEl.addClass('show');this.resize();this.fireEvent('show',this);this.el.setStyle('z-index',Roo.bootstrap.Modal.zIndex++);(function(){this.items.forEach(function(e){e.layout?e.layout():false;});}).defer(100,this);
 },hide:function(){if(this.fireEvent("beforehide",this)!==false){this.maskEl.removeClass('show');this.maskEl.dom.style.display='';Roo.get(document.body).removeClass("x-body-masked");this.el.removeClass('in');this.el.select('.modal-dialog',true).first().setStyle('transform','');
 if(this.animate){this.el.addClass('hideing');this.el.removeClass('show');(function(){if(!this.el.hasClass('hideing')){return;}this.el.dom.style.display='';Roo.get(document.body).removeClass('modal-open');this.el.removeClass('hideing');}).defer(150,this);}
 else{this.el.removeClass('show');this.el.dom.style.display='';Roo.get(document.body).removeClass('modal-open');}this.fireEvent('hide',this);}},isVisible:function(){return this.el.hasClass('show')&&!this.el.hasClass('hideing');},addButton:function(A,cb){var b=Roo.apply({}
-,{html:A});b.xns=b.xns||Roo.bootstrap;b.xtype=b.xtype||'Button';if(typeof(b.listeners)=='undefined'){b.listeners={click:cb.createDelegate(this)};}var B=Roo.factory(b);B.render(this.getButtonContainer());return B;},setDefaultButton:function(A){},diff:false,resizeTo:function(w,h){this.dialogEl.setWidth(w);
-if(this.diff===false){this.diff=this.dialogEl.getHeight()-this.bodyEl.getHeight();}this.bodyEl.setHeight(h-this.diff);this.fireEvent('resize',this);},setContentSize:function(w,h){},onButtonClick:function(A,e){this.fireEvent('btnclick',A.name,e);},setTitle:function(A){this.titleEl.dom.innerHTML=A;
+,{html:A});b.xns=b.xns||Roo.bootstrap;b.xtype=b.xtype||'Button';if(typeof(b.listeners)=='undefined'){b.listeners={click:cb.createDelegate(this)};}var B=Roo.factory(b);B.render(this.getButtonContainer());return B;},setDefaultButton:function(A){},resizeTo:function(w,h){this.dialogEl.setWidth(w);
+var A=this.headerEl.getHeight()+this.footerEl.getHeight()+30;this.bodyEl.setHeight(h-A);this.fireEvent('resize',this);},setContentSize:function(w,h){},onButtonClick:function(A,e){this.fireEvent('btnclick',A.name,e);},setTitle:function(A){this.titleEl.dom.innerHTML=A;
 },setBody:function(A){this.bodyEl.dom.innerHTML=A;},applyBody:function(A){if(!this.tmpl){Roo.log("Error - using apply Body without a template");}this.tmpl.overwrite(this.bodyEl,A);},getChildHeight:function(A){if(!A||A.length==0){return;}var B=0;for(var i=0;
 i<A.length;i++){B+=A[i].offsetHeight;}return B;}});Roo.apply(Roo.bootstrap.Modal,{OK:[{name:'ok',weight:'primary',html:'OK'}],YESNO:[{name:'no',html:'No'},{name:'yes',weight:'primary',html:'Yes'}],OKCANCEL:[{name:'cancel',html:'Cancel'},{name:'ok',weight:'primary',html:'OK'}
 ],YESNOCANCEL:[{name:'yes',weight:'primary',html:'Yes'},{name:'no',html:'No'},{name:'cancel',html:'Cancel'}],zIndex:10001});