Roo/bootstrap/Modal.js
[roojs1] / Roo / bootstrap / Modal.js
index e7c25a0..d08c050 100644 (file)
@@ -17,6 +17,7 @@
  * @cfg {Boolean} allow_close default true
  * @cfg {Boolean} fitwindow default false
  * @cfg {String} size (sm|lg) default empty
+ * @cfg {Number} max_width set the max width of modal
  *
  *
  * @constructor
@@ -81,6 +82,8 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     closeEl:  false,
 
     size: '',
+    
+    max_width: 0,
 
 
     onRender : function(ct, position)
@@ -161,8 +164,6 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
 
     getAutoCreate : function()
     {
-        Roo.log('test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1');
-
         var bdy = {
                 cls : 'modal-body',
                 html : this.html || ''
@@ -260,11 +261,32 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     resize : function()
     {
         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);
         }
+        
+        if(!this.fitwindow && 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;
+            }
+            
+            var view_height = Roo.lib.Dom.getViewportHeight(true) - 60;
+            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;
+            }
+            
+            this.setSize(w, Math.min(full_height, view_height));
+        }
+        
     },
 
     setSize : function(w,h)
@@ -292,7 +314,6 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
             }).defer(50, this);
         }else{
             this.el.addClass('in');
-
         }
 
         // not sure how we can show data in here..