Uncommited changes synced
[roojs1] / roojs-bootstrap-debug.js
index 70aaa9c..af5fe74 100644 (file)
@@ -1,4 +1,18 @@
-/*
+/**
+ * set the version of bootstrap based on the stylesheet...
+ *
+ */
+
+Roo.bootstrap.version = (
+        function() {
+                var ret=3;
+                Roo.each(document.styleSheets[0], function(s) {
+                    if (s.href.match(/css-bootstrap4/)) {
+                        ret=4;
+                    }
+                });
+        return ret;
+})();/*
  * - LGPL
  *
  * base class for bootstrap elements.
@@ -540,6 +554,17 @@ Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component,  {
         }
         
         return cfg;
+    },
+    /**
+     * Add a button to the group (similar to NavItem API.)
+     */
+    addItem : function(cfg)
+    {
+        var cn = new Roo.bootstrap.Button(cfg);
+        //this.register(cn);
+        cn.parentId = this.id;
+        cn.onRender(this.el, null);
+        return cn;
     }
    
 });
@@ -917,15 +942,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     {
         return this.el.select('.roo-button-text',true).first().dom.innerHTML;
     },
-    hide: function() {
-       
-     
-        this.el.hide();   
-    },
-    show: function() {
-       
-        this.el.show();   
-    },
+    
     setWeight : function(str)
     {
        this.el.removeClass(this.weightClass);
@@ -1996,6 +2013,8 @@ Roo.bootstrap.Menu = function(config){
     if (this.registerMenu && this.type != 'treeview')  {
         Roo.bootstrap.MenuMgr.register(this);
     }
+    
+    
     this.addEvents({
         /**
          * @event beforeshow
@@ -2113,8 +2132,13 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
         
         this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
         
-        this.triggerEl.addClass('dropdown-toggle');
-        
+       
+       if (this.triggerEl.hasClass('nav-item')) {
+           // dropdown toggle on the 'a' in BS4?
+           this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
+       } else {
+           this.triggerEl.addClass('dropdown-toggle');
+       }
         if (Roo.isTouch) {
             this.el.on('touchstart'  , this.onTouch, this);
         }
@@ -2249,6 +2273,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
         this.hideMenuItems();
         this.hidden = false;
         this.triggerEl.addClass('open');
+       this.el.addClass('show');
         
         // reassign x when hitting right
         if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
@@ -2298,6 +2323,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
                 this.activeItem = null;
             }
             this.triggerEl.removeClass('open');;
+           this.el.removeClass('show');
             this.hidden = true;
             this.fireEvent("hide", this);
         }
@@ -2446,7 +2472,7 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
         if(this.isContainer){
             return {
                 tag: 'li',
-                cls: 'dropdown-menu-item'
+                cls: 'dropdown-menu-item dropdown-item'
             };
         }
         var ctag = {
@@ -2472,7 +2498,7 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
         
         var cfg= {
             tag: 'li',
-            cls: 'dropdown-menu-item',
+            cls: 'dropdown-menu-item dropdown-item',
             cn: [ anc ]
         };
         if (this.parent().type == 'treeview') {
@@ -2633,8 +2659,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     animate : true,
 
     fitwindow: false,
-
-
+    
      // private
     dialogEl: false,
     bodyEl:  false,
@@ -2646,6 +2671,8 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     
     max_width: 0,
     
+    max_height: 0,
+    
     fit_content: false,
 
     onRender : function(ct, position)
@@ -2743,7 +2770,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
         };
 
         var header = [];
-        if (this.allow_close) {
+        if (this.allow_close && Roo.bootstrap.version == 3) {
             header.push({
                 tag: 'button',
                 cls : 'close',
@@ -2753,6 +2780,14 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
 
         header.push(title);
 
+        if (this.allow_close && Roo.bootstrap.version == 4) {
+            header.push({
+                tag: 'button',
+                cls : 'close',
+                html : '&times'
+            });
+        }
+        
         var size = '';
 
         if(this.size.length){
@@ -2839,19 +2874,17 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
             
             var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
             
-            if(
-                this.height &&
-                this.height <= Roo.lib.Dom.getViewportHeight(true) - 60
-            ) {
+            if(this.height) {
                 this.setSize(w, this.height);
                 return;
             }
             
-            if(
-                this.height &&
-                this.height > Roo.lib.Dom.getViewportHeight(true) - 60
-            ) {
-                this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
+            if(this.max_height) {
+                this.setSize(w,Math.min(
+                    this.max_height,
+                    Roo.lib.Dom.getViewportHeight(true) - 60
+                ));
+                
                 return;
             }
             
@@ -2860,14 +2893,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)
+            );
         }
         
     },
@@ -2877,6 +2909,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
         if (!w && !h) {
             return;
         }
+        
         this.resizeTo(w,h);
     },
 
@@ -2888,7 +2921,8 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
 
         //this.el.setStyle('display', 'block');
         this.el.removeClass('hideing');        
-        this.el.addClass('show');
+        this.el.addClass('show d-block');
+        Roo.get(document.body).addClass('modal-open');
  
         if(this.animate){  // element has 'fade'  - so stuff happens after .3s ?- not sure why the delay?
             var _this = this;
@@ -2908,7 +2942,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
         
         this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true),   Roo.lib.Dom.getViewHeight(true));
         this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
-        this.maskEl.addClass('show');
+        this.maskEl.addClass('show d-block');
         
         this.resize();
         
@@ -2928,7 +2962,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     hide : function()
     {
         if(this.fireEvent("beforehide", this) !== false){
-            this.maskEl.removeClass('show');
+            this.maskEl.removeClass('show d-block');
             Roo.get(document.body).removeClass("x-body-masked");
             this.el.removeClass('in');
             this.el.select('.modal-dialog', true).first().setStyle('transform','');
@@ -2939,12 +2973,16 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
                     if (!this.el.hasClass('hideing')) {
                         return; // it's been shown again...
                     }
-                    this.el.removeClass('show');
+                    this.el.removeClass('show d-block');
+
+                    Roo.get(document.body).removeClass('modal-open');
                     this.el.removeClass('hideing');
                 }).defer(150,this);
                 
             }else{
-                 this.el.removeClass('show');
+                this.el.removeClass('show d-block');
+                Roo.get(document.body).removeClass('modal-open');
+
             }
             this.fireEvent('hide', this);
         }
@@ -2990,7 +3028,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
             this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
         }
 
-        this.bodyEl.setHeight(h-this.diff);
+        this.bodyEl.setHeight(h - this.diff);
 
         this.fireEvent('resize', this);
 
@@ -3029,6 +3067,67 @@ 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;
+                                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);
+                                        continue;
+                                    }
+                                    
+                                }
+                                
+                            }
+                            
+                        }
+                    }
+                }
+                continue;
+            }
+            */
+            
+            child_height += child_nodes[i].offsetHeight;
+            // Roo.log(child_nodes[i].offsetHeight);
+        }
+        
+        return child_height;
     }
 
 });
@@ -3878,7 +3977,8 @@ Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar,  {
  * - LGPL
  *
  * navbar
- * 
+ * navbar-fixed-top
+ * navbar-expand-md  fixed-top 
  */
 
 /**
@@ -3919,7 +4019,7 @@ Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
         
         var   cfg = {
             tag: this.nav || 'nav',
-            cls: 'navbar',
+            cls: 'navbar navbar-expand-md',
             role: 'navigation',
             cn: []
         };
@@ -3938,7 +4038,7 @@ Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
                     {
                         tag: 'button',
                         type: 'button',
-                        cls: 'navbar-toggle',
+                        cls: 'navbar-toggle navbar-toggler',
                         'data-toggle': 'collapse',
                         cn: [
                             {
@@ -3948,7 +4048,7 @@ Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
                             },
                             {
                                 tag: 'span',
-                                cls: 'icon-bar'
+                                cls: 'icon-bar navbar-toggler-icon'
                             },
                             {
                                 tag: 'span',
@@ -3970,10 +4070,10 @@ Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar,  {
             cn : []
         });
         
-        cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
+        cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
         
         if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
-            cfg.cls += ' navbar-' + this.position;
+            cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
             
             // tag can override this..
             
@@ -4173,15 +4273,17 @@ Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component,  {
             };
             
             if (this.align === 'right') {
-                cfg.cls += ' navbar-right';
+                cfg.cls += ' navbar-right ml-md-auto';
             } else {
                 cfg.cls += ' navbar-left';
             }
         }
         
         if (this.align === 'right') {
-            cfg.cls += ' navbar-right';
-        }
+            cfg.cls += ' navbar-right ml-md-auto';
+        } else {
+           cfg.cls += ' mr-auto';
+       }
         
         if (this.inverse) {
             cfg.cls += ' navbar-inverse';
@@ -4466,7 +4568,9 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component,  {
                     html: this.html || ''
                 }
             ];
-            
+            if (this.tagtype == 'a') {
+               cfg.cn[0].cls = 'nav-link';
+           }
             if (this.icon) {
                 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
             }
@@ -4483,7 +4587,7 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component,  {
             
             if (this.badge !== '') {
                  
-                cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
+                cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
             }
         }
         
@@ -7047,9 +7151,72 @@ Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component,  {
         
         this.onHeaderChange();
         this.onLoad();
+    },
+    
+    setColumnWidth: function(col_index, width)
+    {
+        // width = "md-2 xs-2..."
+        if(!this.colModel.config[col_index]) {
+            return;
+        }
+        
+        var w = width.split(" ");
+        
+        var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
+        
+        var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
         
+        
+        for(var j = 0; j < w.length; j++) {
+            
+            if(!w[j]) {
+                continue;
+            }
+            
+            var size_cls = w[j].split("-");
+            
+            if(!Number.isInteger(size_cls[1] * 1)) {
+                continue;
+            }
+            
+            if(!this.colModel.config[col_index][size_cls[0]]) {
+                continue;
+            }
+            
+            if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
+                continue;
+            }
+            
+            h_row[0].classList.replace(
+                "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
+                "col-"+size_cls[0]+"-"+size_cls[1]
+            );
+            
+            for(var i = 0; i < rows.length; i++) {
+                
+                var size_cls = w[j].split("-");
+                
+                if(!Number.isInteger(size_cls[1] * 1)) {
+                    continue;
+                }
+                
+                if(!this.colModel.config[col_index][size_cls[0]]) {
+                    continue;
+                }
+                
+                if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
+                    continue;
+                }
+                
+                rows[i].classList.replace(
+                    "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
+                    "col-"+size_cls[0]+"-"+size_cls[1]
+                );
+            }
+            
+            this.colModel.config[col_index][size_cls[0]] = size_cls[1];
+        }
     }
-    
 });
 
  
@@ -8263,11 +8430,6 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
                 return;
             }
             
-            if(f.xtype == 'DateField'){
-                f.setVisible(false);
-                return;
-            }
-            
             f.hide();
             
         }, this);
@@ -8283,11 +8445,6 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
                 return;
             }
             
-            if(f.xtype == 'DateField'){
-                f.setVisible(true);
-                return;
-            }
-            
             f.show();
             
         }, this);
@@ -13005,6 +13162,11 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
      */
     useNativeIOS : false,
     
+    /**
+     * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
+     */
+    mobile_restrict_height : false,
+    
     ios_options : false,
     
     //private
@@ -15222,6 +15384,8 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             document.activeElement.blur();
         }, this);
         
+        this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
+        
         return;
         
         
@@ -15282,7 +15446,14 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
         }else{
             this.touchViewEl.addClass('in');
         }
-
+        
+        if(this._touchViewMask){
+            Roo.get(document.body).addClass("x-body-masked");
+            this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true),   Roo.lib.Dom.getViewHeight(true));
+            this._touchViewMask.setStyle('z-index', 10000);
+            this._touchViewMask.addClass('show');
+        }
+        
         this.doTouchViewQuery();
         
     },
@@ -15298,6 +15469,10 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             this.touchViewEl.setStyle('display', 'none');
         }
         
+        if(this._touchViewMask){
+            this._touchViewMask.removeClass('show');
+            Roo.get(document.body).removeClass("x-body-masked");
+        }
     },
     
     setTouchViewValue : function()
@@ -15404,7 +15579,11 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
             bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
         }
 
-        var listHeight = this.touchViewListGroup.getHeight();
+        var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
+        
+        if(this.mobile_restrict_height && listHeight < bodyHeight){
+            this.touchViewBodyEl.setHeight(listHeight);
+        }
         
         var _this = this;
         
@@ -19043,7 +19222,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
             case 18: // alt
                 break;
             default :
-                this.hide();
+                this.hidePopup();
                 
         }
     },
@@ -24505,7 +24684,11 @@ Roo.bootstrap.PagingToolbar = function(config)
         this.bind(this.ds);
     }
     
-    this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
+    if (Roo.bootstrap.version == 4) {
+        this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
+    } else {
+        this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
+    }
     
 };
 
@@ -24604,8 +24787,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         this.first = this.navgroup.addItem({
             tooltip: this.firstText,
-            cls: "prev",
-            icon : 'fa fa-backward',
+            cls: "prev btn-outline-secondary",
+            html : ' <i class="fa fa-step-backward"></i>',
             disabled: true,
             preventDefault: true,
             listeners : { click : this.onClick.createDelegate(this, ["first"]) }
@@ -24613,8 +24796,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         this.prev =  this.navgroup.addItem({
             tooltip: this.prevText,
-            cls: "prev",
-            icon : 'fa fa-step-backward',
+            cls: "prev btn-outline-secondary",
+            html : ' <i class="fa fa-backward"></i>',
             disabled: true,
             preventDefault: true,
             listeners : { click :  this.onClick.createDelegate(this, ["prev"]) }
@@ -24624,8 +24807,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         
         var field = this.navgroup.addItem( {
             tagtype : 'span',
-            cls : 'x-paging-position',
-            
+            cls : 'x-paging-position  btn-outline-secondary',
+             disabled: true,
             html : this.beforePageText  +
                 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
                 '<span class="x-paging-after">' +  String.format(this.afterPageText, 1) + '</span>'
@@ -24641,16 +24824,16 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
         //this.addSeparator();
         this.next = this.navgroup.addItem({
             tooltip: this.nextText,
-            cls: "next",
-            html : ' <i class="fa fa-step-forward">',
+            cls: "next btn-outline-secondary",
+            html : ' <i class="fa fa-forward"></i>',
             disabled: true,
             preventDefault: true,
             listeners : { click :  this.onClick.createDelegate(this, ["next"]) }
         });
         this.last = this.navgroup.addItem({
             tooltip: this.lastText,
-            icon : 'fa fa-forward',
-            cls: "next",
+            html : ' <i class="fa fa-step-forward"></i>',
+            cls: "next btn-outline-secondary",
             disabled: true,
             preventDefault: true,
             listeners : { click :  this.onClick.createDelegate(this, ["last"]) }
@@ -24658,7 +24841,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
     //this.addSeparator();
         this.loading = this.navgroup.addItem({
             tooltip: this.refreshText,
-            icon: 'fa fa-refresh',
+            cls: "btn-outline-secondary",
+            html : ' <i class="fa fa-refresh"></i>',
             preventDefault: true,
             listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
         });
@@ -31916,7 +32100,7 @@ Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component,  {
         var cn = new Roo.bootstrap.MasonryBrick(cfg);
         //this.register(cn);
         cn.parentId = this.id;
-        cn.onRender(this.el, null);
+        cn.render(this.el);
         return cn;
     },
     
@@ -39751,6 +39935,8 @@ Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
         
         allowed: '0123456789',
         
+        max_length: 15,
+        
         /**
          * @cfg {String} defaultDialCode The default dial code when initializing the input
          */
@@ -39795,6 +39981,8 @@ Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
             var input =  {
                 tag: 'input',
                 id : id,
+                // type: 'number', -- do not use number - we get the flaky up/down arrows.
+                maxlength: this.max_length,
                 cls : 'form-control tel-input',
                 autocomplete: 'new-password'
             };
@@ -40008,6 +40196,7 @@ Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
             this.list.on('mouseover', this.onViewOver, this);
             this.list.on('mousemove', this.onViewMove, this);
             this.inputEl().on("keyup", this.onKeyUp, this);
+            this.inputEl().on("keypress", this.onKeyPress, this);
             
             this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
 
@@ -40257,26 +40446,15 @@ Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
             return this.el.select('input.hidden-tel-input',true).first();
         },
         
+        // after setting val
         onKeyUp : function(e){
-            
-            var k = e.getKey();
-            var c = e.getCharCode();
-            
-            if(
-                    (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
-                    this.allowed.indexOf(String.fromCharCode(c)) === -1
-            ){
-                e.stopEvent();
-            }
-            
-            // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
-            //     return;
-            // }
-            if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
+            this.setValue(this.getValue());
+        },
+        
+        onKeyPress : function(e){
+            if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
                 e.stopEvent();
             }
-            
-            this.setValue(this.getValue());
         }
         
 });
@@ -40352,7 +40530,10 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
      * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
      */
     thousandsDelimiter : false,
-    
+    /**
+     * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
+     */
+    max_length: false,
     
     inputlg : 9,
     inputmd : 9,
@@ -40386,6 +40567,10 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
             cls: 'hidden-number-input'
         };
         
+        if(this.max_length) {
+            input.maxlength = this.max_length; 
+        }
+        
         if (this.name) {
             hiddenInput.name = this.name;
         }