Roo/bootstrap/Modal.js
[roojs1] / Roo / bootstrap / Modal.js
index c3ce30c..57f4424 100644 (file)
@@ -84,7 +84,8 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     size: '',
     
     max_width: 0,
-
+    
+    fit_content: false,
 
     onRender : function(ct, position)
     {
@@ -260,38 +261,40 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
 
     resize : function()
     {
-        this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true),  Roo.lib.Dom.getViewHeight(true));
+        this.maskEl.setSize(
+            Roo.lib.Dom.getViewWidth(true),
+            Roo.lib.Dom.getViewHeight(true)
+        );
         
         if (this.fitwindow) {
-            var w = this.width || Roo.lib.Dom.getViewportWidth(true) - 30;
-            var h = this.height || Roo.lib.Dom.getViewportHeight(true) - 60;
-            this.setSize(w,h);
+            this.setSize(
+                this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
+                this.height || Roo.lib.Dom.getViewportHeight(true) - 60
+            );
+            return;
         }
         
-        if(!this.fitwindow && this.max_width !== 0){
-            var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
-            var view_height = Roo.lib.Dom.getViewportHeight(true) - 60; //without padding
+        if(this.max_width !== 0) {
             
-            var body_childs = this.bodyEl.dom.childNodes;
+            var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
             
-            for(var i = 0; i < this.bodyEl.dom.childNodes.length; i++) {
-                
+            if(this.height) {
+                this.setSize(w, this.height);
+                return;
             }
             
-            this.setSize(w, this.height || view_height);
-            
+            if(!this.fit_content) {
+                this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
+                return;
+            }
             
+            var body_childs = this.bodyEl.dom.childNodes;
+            var full_height = this.headerEl.getHeight() + this.footerEl.getHeight();
+            for(var i = 0; i < body_childs.length; i++) {
+                full_height += body_childs[i].offsetHeight;
+            }
             
-            // 
-            // if(
-            //     (
-            //         this.headerEl.getHeight() + 
-            //         this.bodyEl.getHeight() + 
-            //         this.footerEl.getHeight()
-            //     ) > view_height) {
-            // } {
-            //     this.setSize(w,view_height);
-            // }
+            this.setSize(w, Math.min(full_height, Roo.lib.Dom.getViewportHeight(true) - 60));
         }
         
     },