Fix #6464 - card header
[roojs1] / Roo / bootstrap / Form.js
index e0c2e8d..74aa41b 100644 (file)
@@ -22,6 +22,7 @@
 
 
 Roo.bootstrap.Form = function(config){
+    
     Roo.bootstrap.Form.superclass.constructor.call(this, config);
     
     Roo.bootstrap.Form.popover.apply();
@@ -56,7 +57,6 @@ Roo.bootstrap.Form = function(config){
          */
         actioncomplete : true
     });
-
 };
 
 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
@@ -110,6 +110,11 @@ Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
      * @cfg {Number} maskOffset Default 100
      */
     maskOffset : 100,
+    
+    /**
+     * @cfg {Boolean} maskBody
+     */
+    maskBody : false,
 
     getAutoCreate : function(){
 
@@ -120,7 +125,7 @@ Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
             cls : ''
         };
         if (this.parent().xtype.match(/^Nav/)) {
-            cfg.cls = 'navbar-form navbar-' + this.align;
+            cfg.cls = 'navbar-form form-inline navbar-' + this.align;
 
         }
 
@@ -172,6 +177,9 @@ Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
             if(f.validate()){
                 return;
             }
+            
+            Roo.log('invalid field: ' + f.name);
+            
             valid = false;
 
             if(!target && f.el.isVisible(true)){
@@ -234,9 +242,14 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
     // private
     beforeAction : function(action){
         var o = action.options;
-
+        
         if(this.loadMask){
-            this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
+            
+            if(this.maskBody){
+                Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
+            } else {
+                this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
+            }
         }
         // not really supported yet.. ??
 
@@ -256,8 +269,17 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
         this.activeAction = null;
         var o = action.options;
 
+        if(this.loadMask){
+            
+            if(this.maskBody){
+                Roo.get(document.body).unmask();
+            } else {
+                this.el.unmask();
+            }
+        }
+        
         //if(this.waitMsgTarget === true){
-            this.el.unmask();
+//            this.el.unmask();
         //}else if(this.waitMsgTarget){
         //    this.waitMsgTarget.unmask();
         //}else{
@@ -405,6 +427,10 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
                         sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
                         field.setFromData(sd);
 
+                    } else if(field.setFromData && (field.store && !field.store.isLocal)) {
+                        
+                        field.setFromData(values);
+                        
                     } else {
                         field.setValue(values[id]);
                     }
@@ -457,10 +483,13 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
         var items = this.getItems();
         var ret = {};
         items.each(function(f){
+            
             if (!f.getName()) {
                 return;
             }
+            
             var v = f.getValue();
+            
             if (f.inputType =='radio') {
                 if (typeof(ret[f.getName()]) == 'undefined') {
                     ret[f.getName()] = ''; // empty..
@@ -473,6 +502,10 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
                 v = f.el.dom.value;
 
             }
+            
+            if(f.xtype == 'MoneyField'){
+                ret[f.currencyName] = f.getCurrency();
+            }
 
             // not sure if this supported any more..
             if ((typeof(v) == 'object') && f.getRawValue) {
@@ -499,8 +532,6 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
            f.clearInvalid();
         });
 
-
-
         return this;
     },
 
@@ -521,6 +552,7 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
 
         return this;
     },
+    
     getItems : function()
     {
         var r=new Roo.util.MixedCollection(false, function(o){
@@ -536,16 +568,40 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
             Roo.each(el.items,function(e) {
                 iter(e);
             });
-
-
         };
 
         iter(this);
         return r;
-
-
-
-
+    },
+    
+    hideFields : function(items)
+    {
+        Roo.each(items, function(i){
+            
+            var f = this.findField(i);
+            
+            if(!f){
+                return;
+            }
+            
+            f.hide();
+            
+        }, this);
+    },
+    
+    showFields : function(items)
+    {
+        Roo.each(items, function(i){
+            
+            var f = this.findField(i);
+            
+            if(!f){
+                return;
+            }
+            
+            f.show();
+            
+        }, this);
     }
 
 });
@@ -625,6 +681,8 @@ Roo.apply(Roo.bootstrap.Form, {
             
             var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
             
+            Roo.log(scrollable);
+            
             var ot = this.target.el.calcOffsetsTo(scrollable);
             
             var scrollTo = ot[1] - this.form.maskOffset;
@@ -638,61 +696,58 @@ Roo.apply(Roo.bootstrap.Form, {
             var zIndex = Roo.bootstrap.Modal.zIndex++;
 
             
-//            this.maskEl.top.setStyle('position', 'fixed');
+            this.maskEl.top.setStyle('position', 'absolute');
             this.maskEl.top.setStyle('z-index', zIndex);
             this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
-            
-            this.maskEl.top.dom.style.top = 0;
-            this.maskEl.top.dom.style.left = 0;
+            this.maskEl.top.setLeft(0);
+            this.maskEl.top.setTop(0);
             this.maskEl.top.show();
             
-            
-//            Roo.log(test.position());
-
-//            this.maskEl.left.setStyle('position', 'fixed');
-//            this.maskEl.left.setStyle('z-index', zIndex);
-//            this.maskEl.left.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
-//            this.maskEl.left.setXY([box.right + this.padding, box.y - this.padding]);
-//            this.maskEl.left.show();
-//
-//            this.maskEl.bottom.setStyle('position', 'fixed');
-//            this.maskEl.bottom.setStyle('z-index', zIndex);
-//            this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
-//            this.maskEl.bottom.setXY([0, box.bottom + this.padding]);
-//            this.maskEl.bottom.show();
-//
-//            this.maskEl.right.setStyle('position', 'fixed');
-//            this.maskEl.right.setStyle('z-index', zIndex);
-//            this.maskEl.right.setSize(box.x - this.padding, box.height + this.padding * 2);
-//            this.maskEl.right.setXY([0, box.y - this.padding]);
-//            this.maskEl.right.show();
-
-//            Roo.log([Roo.lib.Dom.getDocumentWidth(), box.y - this.padding, 0, 0]);
-//            Roo.log([Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2, box.right + this.padding, box.y - this.padding]);
-//            Roo.log([Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding, 0, box.bottom + this.padding]);
-//            Roo.log([box.x - this.padding, box.height + this.padding * 2, 0, box.y - this.padding]);
-            
+            this.maskEl.left.setStyle('position', 'absolute');
+            this.maskEl.left.setStyle('z-index', zIndex);
+            this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
+            this.maskEl.left.setLeft(0);
+            this.maskEl.left.setTop(box.y - this.padding);
+            this.maskEl.left.show();
+
+            this.maskEl.bottom.setStyle('position', 'absolute');
+            this.maskEl.bottom.setStyle('z-index', zIndex);
+            this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
+            this.maskEl.bottom.setLeft(0);
+            this.maskEl.bottom.setTop(box.bottom + this.padding);
+            this.maskEl.bottom.show();
+
+            this.maskEl.right.setStyle('position', 'absolute');
+            this.maskEl.right.setStyle('z-index', zIndex);
+            this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
+            this.maskEl.right.setLeft(box.right + this.padding);
+            this.maskEl.right.setTop(box.y - this.padding);
+            this.maskEl.right.show();
+
             this.toolTip.bindEl = this.target.el;
 
             this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
 
             var tip = this.target.blankText;
 
-            if(this.target.getValue() !== '' && this.target.regexText.length){
-                tip = this.target.regexText;
+            if(this.target.getValue() !== '' ) {
+                
+                if (this.target.invalidText.length) {
+                    tip = this.target.invalidText;
+                } else if (this.target.regexText.length){
+                    tip = this.target.regexText;
+                }
             }
 
             this.toolTip.show(tip);
 
             this.intervalID = window.setInterval(function() {
-//                Roo.bootstrap.Form.popover.unmask();
+                Roo.bootstrap.Form.popover.unmask();
             }, 10000);
 
             window.onwheel = function(){ return false;};
             
             (function(){ this.isMasked = true; }).defer(500, this);
-                
-            
             
         },