Roo/bootstrap/Modal.js
[roojs1] / roojs-bootstrap-debug.js
index 7723bed..d62a2b2 100644 (file)
@@ -401,6 +401,8 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
          
         this.getVisibilityEl().removeClass('hidden');
         
+        this.fireEvent('show', this);
+        
         
     },
     /**
@@ -414,6 +416,8 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
         
         this.getVisibilityEl().addClass('hidden');
         
+        this.fireEvent('hide', this);
+        
     }
 });
 
@@ -2574,6 +2578,7 @@ Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component,  {
  * @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
@@ -2638,6 +2643,8 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     closeEl:  false,
 
     size: '',
+    
+    max_width: 0,
 
 
     onRender : function(ct, position)
@@ -2716,9 +2723,8 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
 
     },
 
-    getAutoCreate : function(){
-
-
+    getAutoCreate : function()
+    {
         var bdy = {
                 cls : 'modal-body',
                 html : this.html || ''
@@ -2816,11 +2822,48 @@ 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);
+            
+            Roo.log(this.height);
+            
+            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 body_height = 0;
+            for(var i = 0; i < body_childs.length; i++) {
+                body_height += body_childs[i].offsetHeight;
+            }
+            
+            // this.setSize(w, this.height || view_height);
+            
+            
+            
+            // 
+            // if(
+            //     (
+            //         this.headerEl.getHeight() + 
+            //         this.bodyEl.getHeight() + 
+            //         this.footerEl.getHeight()
+            //     ) > view_height) {
+            // } {
+            //     this.setSize(w,view_height);
+            // }
+        }
+        
     },
 
     setSize : function(w,h)
@@ -2848,7 +2891,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..
@@ -5879,7 +5921,7 @@ Roo.LoadMask.prototype = {
  * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
  * @cfg {Roo.bootstrap.PagingToolbar} footer  a paging toolbar
  * @cfg {Boolean} lazyLoad  auto load data while scrolling to the end (default false)
- * @cfg {Boolean} autoHideFooter  auto hide footer if only one page (default false)
+ * @cfg {Boolean} auto_hide_footer  auto hide footer if only one page (default false)
  
  * 
  * @constructor
@@ -6070,7 +6112,7 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
     
     CSS : Roo.util.CSS,
     
-    autoHideFooter : false,
+    auto_hide_footer : false,
     
     getAutoCreate : function()
     {
@@ -6158,9 +6200,9 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         
         //Roo.log('initEvents with ds!!!!');
         
-        this.mainBody = this.el.select('tbody', true).first().setVisibilityMode(Roo.Element.DISPLAY);
-        this.mainHead = this.el.select('thead', true).first().setVisibilityMode(Roo.Element.DISPLAY);
-        this.mainFoot = this.el.select('tfoot', true).first().setVisibilityMode(Roo.Element.DISPLAY);
+        this.mainBody = this.el.select('tbody', true).first();
+        this.mainHead = this.el.select('thead', true).first();
+        this.mainFoot = this.el.select('tfoot', true).first();
         
         
         
@@ -6598,11 +6640,13 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         
         var tfoot = this.el.select('tfoot', true).first();
         
-        if(this.footerShow && this.autoHideFooter && this.mainFoot){
+        if(this.footerShow && this.auto_hide_footer && this.mainFoot){
             
-            this.mainFoot.hide();
+            this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
             
-            if(this.footer.pageSize < ds.getCount()){
+            var total = this.ds.getTotalCount();
+            
+            if(this.footer.pageSize < total){
                 this.mainFoot.show();
             }
         }
@@ -9404,6 +9448,11 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
             
         }
         
+        if(this.indicator){
+            this.indicator.removeClass('visible');
+            this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
+        }
+        
         this.fireEvent('valid', this);
     },
     
@@ -13589,11 +13638,16 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         this.list.on('scroll', this.onViewScroll, this);
         
         if(!this.tpl){
-            this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}" type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
+            this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' + 
+                'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
         }
 
         this.view = new Roo.View(this.list, this.tpl, {
-            singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
+            singleSelect:true,
+            tickable:true,
+            parent:this,
+            store: this.store,
+            selectedClass: this.selectedClass
         });
         
         //this.view.wrapEl.setDisplayed(false);
@@ -18535,7 +18589,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
         this.showMode();
         
         if(this.isInline) {
-            this.show();
+            this.showPopup();
         }
     },
     
@@ -18818,7 +18872,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
     onFocus : function()
     {
         Roo.bootstrap.DateField.superclass.onFocus.call(this);
-        this.show();
+        this.showPopup();
     },
     
     onBlur : function()
@@ -18829,19 +18883,19 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
         
         this.setValue(d);
                 
-        this.hide();
+        this.hidePopup();
     },
     
-    show : function()
+    showPopup : function()
     {
         this.picker().show();
         this.update();
         this.place();
         
-        this.fireEvent('show', this, this.date);
+        this.fireEvent('showpopup', this, this.date);
     },
     
-    hide : function()
+    hidePopup : function()
     {
         if(this.isInline) {
             return;
@@ -18850,7 +18904,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
         this.viewMode = this.startViewMode;
         this.showMode();
         
-        this.fireEvent('hide', this, this.date);
+        this.fireEvent('hidepopup', this, this.date);
         
     },
     
@@ -18898,7 +18952,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
     {
         if (!this.picker().isVisible()){
             if (e.keyCode == 27) { // allow escape to hide and re-show picker
-                this.show();
+                this.showPopup();
             }
             return;
         }
@@ -18909,7 +18963,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
         
         switch(e.keyCode){
             case 27: // escape
-                this.hide();
+                this.hidePopup();
                 e.preventDefault();
                 break;
             case 37: // left
@@ -18969,12 +19023,12 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
                 break;
             case 13: // enter
                 this.setValue(this.formatDate(this.date));
-                this.hide();
+                this.hidePopup();
                 e.preventDefault();
                 break;
             case 9: // tab
                 this.setValue(this.formatDate(this.date));
-                this.hide();
+                this.hidePopup();
                 break;
             case 16: // shift
             case 17: // ctrl
@@ -19029,7 +19083,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
 //                        this.fill()
                         this.setValue(this.formatDate(this.date));
                         
-                        this.hide();
+                        this.hidePopup();
                         break;
                 }
                 break;
@@ -19046,7 +19100,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
                     
                     if(this.singleMode){
                         this.setValue(this.formatDate(this.viewDate));
-                        this.hide();
+                        this.hidePopup();
                         return;
                     }
                     
@@ -19083,7 +19137,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
 //                    this.fill();
                     //Roo.log(this.formatDate(this.date));
                     this.setValue(this.formatDate(this.date));
-                    this.hide();
+                    this.hidePopup();
                 }
                 break;
         }
@@ -19293,21 +19347,6 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
         this.date = this.viewDate = '';
         
         Roo.bootstrap.DateField.superclass.setValue.call(this, '');
-    },
-    
-    setVisible : function(visible)
-    {
-        if(!this.getEl()){
-            return;
-        }
-        
-        this.getEl().removeClass('hidden');
-        
-        if(visible){
-            return;
-        }
-        
-        this.getEl().addClass('hidden');
     }
    
 });
@@ -26200,6 +26239,7 @@ Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component,  {
                 placement = 'top';
             }
             
+            align = this.alignment[placement];
         }
         
         this.el.alignTo(this.bindEl, align[0],align[1]);