roojs-bootstrap.js
[roojs1] / Roo / bootstrap / Form.js
index 225d2b3..c679941 100644 (file)
@@ -8,6 +8,7 @@
 /**
  * @class Roo.bootstrap.Form
  * @extends Roo.bootstrap.Component
+ * @children Roo.bootstrap.Component
  * Bootstrap Form class
  * @cfg {String} method  GET | POST (default POST)
  * @cfg {String} labelAlign top | left (default top)
@@ -22,6 +23,7 @@
 
 
 Roo.bootstrap.Form = function(config){
+    
     Roo.bootstrap.Form.superclass.constructor.call(this, config);
     
     Roo.bootstrap.Form.popover.apply();
@@ -56,7 +58,6 @@ Roo.bootstrap.Form = function(config){
          */
         actioncomplete : true
     });
-
 };
 
 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
@@ -110,6 +111,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 +126,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;
 
         }
 
@@ -168,9 +174,13 @@ Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
         var target = false;
         
         items.each(function(f){
+            
             if(f.validate()){
                 return;
             }
+            
+            Roo.log('invalid field: ' + f.name);
+            
             valid = false;
 
             if(!target && f.el.isVisible(true)){
@@ -233,9 +243,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.. ??
 
@@ -255,8 +270,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{
@@ -509,8 +533,6 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
            f.clearInvalid();
         });
 
-
-
         return this;
     },
 
@@ -531,6 +553,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){
@@ -546,16 +569,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);
     }
 
 });