roojs-bootstrap.js
authorAlan Knowles <alan@roojs.com>
Wed, 22 Jan 2014 13:35:23 +0000 (21:35 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 22 Jan 2014 13:35:23 +0000 (21:35 +0800)
roojs-bootstrap-debug.js

roojs-bootstrap-debug.js
roojs-bootstrap.js

index 2dc38bc..edec924 100644 (file)
@@ -72,15 +72,17 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
         return this.el;
     },
     
-    addxtype : function (tree) {
+    addxtype : function (tree, cntr) {
         var cn = this;
+        cntr = typeof(cntr == 'undefined' ) ? 'getChildContainer' : cntr;
+        
         if (tree.xtype != 'Body') {
             
             cn = Roo.factory(tree);
             
             cn.parentType = this.xtype; //??
             cn.parentId = this.id;
-            cn.render(this.getChildContainer());
+            cn.render(this[cntr]());
             // then add the element..
         }
         var nitems = [];
@@ -90,7 +92,14 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
             nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
             
         }
-       
+        if (typeof (tree.buttons) != 'undefined' && typeof(cn.getButtonContainer) == 'function') {
+            
+            for(var i =0;i < items.length;i++) {
+                nitems.push(cn.addxtype(Roo.apply({}, items[i]), 'getButtonContainer'));
+            }
+            
+            
+        }
         if (!tree.items || !tree.items.length) {
             this.items = nitems;
             return this;
@@ -645,6 +654,7 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
     fieldLabel : '',
     inputType : 'text',
     disabled : false,
+    name : false,
     
     getAutoCreate : function(){
         
@@ -666,7 +676,9 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
             placeholder : this.placeholder || '' 
             
         };
-
+        if (this.name) {
+            input.name = name;
+        }
         
         switch(align) {
             case 'left':
@@ -1001,7 +1013,20 @@ Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component,  {
  *
  * page contgainer.
  * 
- */ 
+ */
+
+/**
+ * @class Roo.bootstrap.Modal
+ * @extends Roo.bootstrap.Component
+ * Bootstrap Modal class
+ * @cfg {String} title Title of dialog
+ * @cfg {Array} buttons Array of buttons
+    
+ * @constructor
+ * Create a new Modal Dialog
+ * @param {Object} config The config object
+ */
+
 Roo.bootstrap.Modal = function(config){
     Roo.bootstrap.Modal.superclass.constructor.call(this, config);
 };
@@ -1009,7 +1034,7 @@ Roo.bootstrap.Modal = function(config){
 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
     
     title : 'test dialog',
-    body : 'test body',
+   
        buttons : false,
     onRender : function(ct, position){
         Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
@@ -1067,11 +1092,12 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
                                     ]
                                 },
                                 {
-                                    cls : 'modal-body',
-                                    html : this.body
+                                    cls : 'modal-body'
+                                 
                                 },
                                  {
-                                    cls : 'modal-footer',
+                                    cls : 'modal-footer'
+                                    /*
                                     cn : [
                                         {
                                             tag: 'button',
@@ -1085,6 +1111,7 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
                                         }
                                     
                                     ]
+                                    */
                                 }
                                 
                                 
@@ -1100,7 +1127,15 @@ Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component,  {
         };
           
     },
-    
+    getChildContainer : function() {
+         
+         return this.el.select('.modal-body',true).first();
+        
+    },
+    getButtonContainer : function() {
+         return this.el.select('.modal-footer',true).first();
+        
+    },
     initEvents : function()
     {
         this.el.select('.modal-header .close').on('click', this.hide, this);
@@ -1281,11 +1316,11 @@ Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component,  {
     },
     
     getChildContainer : function() {
-       if (this.bar === true) {
-           return this.el.select('.collapse',true).first();
-       }
-       
-        return this.el;
+        if (this.bar === true) {
+            return this.el.select('.collapse',true).first();
+        }
+        
+           return this.el;
     }
    
 });
index e217c74..d9493ab 100644 (file)
@@ -1,8 +1,8 @@
 //Roo/bootstrap/Component.js
 Roo.bootstrap=Roo.bootstrap||{};Roo.bootstrap.Component=function(A){Roo.bootstrap.Component.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Component,Roo.BoxComponent,{cls:false,style:false,autoCreate:false,initEvents:function(){},parentId:false,parent:function(){return Roo.ComponentMgr.get(this.parentId)},onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(this.el){return;}var B=Roo.apply({},this.getAutoCreate());B.id=Roo.id();if(this.cls){B.cls+=' '+this.cls;}if(this.style){B.style=this.style;}
 this.el=ct.createChild(B,A);if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex);}
-this.initEvents();},getChildContainer:function(){return this.el;},addxtype:function(A){var cn=this;if(A.xtype!='Body'){cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;cn.render(this.getChildContainer());}var B=[];if(typeof(A.menu)!='undefined'){A.menu.parentType=cn.xtype;A.menu.triggerEl=cn.el;B.push(cn.addxtype(Roo.apply({},A.menu)));}if(!A.items||!A.items.length){this.items=B;return this;}var C=A.items;delete A.items;for(var i=0;i<C.length;i++){B.push(cn.addxtype(Roo.apply({},C[i])));}
-this.items=B;return this;}});
+this.initEvents();},getChildContainer:function(){return this.el;},addxtype:function(A,B){var cn=this;B=typeof(B=='undefined')?'getChildContainer':B;if(A.xtype!='Body'){cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;cn.render(this[B]());}var C=[];if(typeof(A.menu)!='undefined'){A.menu.parentType=cn.xtype;A.menu.triggerEl=cn.el;C.push(cn.addxtype(Roo.apply({},A.menu)));}if(typeof(A.buttons)!='undefined'&&typeof(cn.getButtonContainer)=='function'){for(var i=0;i<D.length;i++){C.push(cn.addxtype(Roo.apply({},D[i]),'getButtonContainer'));}}if(!A.items||!A.items.length){this.items=C;return this;}var D=A.items;delete A.items;for(var i=0;i<D.length;i++){C.push(cn.addxtype(Roo.apply({},D[i])));}
+this.items=C;return this;}});
 //Roo/bootstrap/Body.js
 Roo.bootstrap.Body=function(A){Roo.bootstrap.Body.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Body,Roo.bootstrap.Component,{autoCreate:{cls:'container'},onRender:function(ct,A){this.el=Roo.get(document.body);}});
 //Roo/bootstrap/ButtonGroup.js
@@ -20,7 +20,7 @@ Roo.bootstrap.Form=function(A){Roo.bootstrap.Form.superclass.constructor.call(th
 //Roo/bootstrap/Img.js
 Roo.bootstrap.Img=function(A){Roo.bootstrap.Img.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Img,Roo.bootstrap.Component,{imgResponsive:true,border:'',src:'',autoCreate:{tag:'img',cls:'img-responsive',html:null},getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.Img.superclass.getAutoCreate.call(this));A.html=this.html||A.html;A.src=this.src||A.src;if(['rounded','circle','thumbnail'].indexOf(this.border)>-1){A.cls+=' img-'+this.border;}if(this.alt){A.alt=this.alt;}return A;}});
 //Roo/bootstrap/Input.js
-Roo.bootstrap.Input=function(A){Roo.bootstrap.Input.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Input,Roo.bootstrap.Component,{fieldLabel:'',inputType:'text',disabled:false,getAutoCreate:function(){var A=this.parent();var B=A.labelAlign;var id=Roo.id();var C={cls:'form-group'};var D={tag:'input',id:id,type:this.inputType,cls:'form-control',placeholder:this.placeholder||''};switch(B){case 'left':C.cn=[{tag:'label','for':id,cls:'col-sm-2 control-label',html:this.fieldLabel},{cls:"col-sm-10",cn:[D]}];break;default:C.cn=[{tag:'label',html:this.fieldLabel},D];break;}if(this.disabled){D.disabled=true;}return C;},setDisabled:function(v){var i=this.el.select('input',true).dom;if(v){i.removeAttribute('disabled');return;}
+Roo.bootstrap.Input=function(A){Roo.bootstrap.Input.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Input,Roo.bootstrap.Component,{fieldLabel:'',inputType:'text',disabled:false,name:false,getAutoCreate:function(){var A=this.parent();var B=A.labelAlign;var id=Roo.id();var C={cls:'form-group'};var D={tag:'input',id:id,type:this.inputType,cls:'form-control',placeholder:this.placeholder||''};if(this.name){D.name=name;}switch(B){case 'left':C.cn=[{tag:'label','for':id,cls:'col-sm-2 control-label',html:this.fieldLabel},{cls:"col-sm-10",cn:[D]}];break;default:C.cn=[{tag:'label',html:this.fieldLabel},D];break;}if(this.disabled){D.disabled=true;}return C;},setDisabled:function(v){var i=this.el.select('input',true).dom;if(v){i.removeAttribute('disabled');return;}
 i.setAttribute('disabled','true');}});
 //Roo/bootstrap/Header.js
 Roo.bootstrap.Header=function(A){Roo.bootstrap.Header.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Header,Roo.bootstrap.Component,{html:false,level:1,getAutoCreate:function(){var A={tag:'h'+(1*this.level),html:this.html||'fill in html'};return A;}});
@@ -32,9 +32,9 @@ Roo.bootstrap.MenuItem=function(A){Roo.bootstrap.MenuItem.superclass.constructor
 //Roo/bootstrap/MenuSeparator.js
 Roo.bootstrap.MenuSeparator=function(A){Roo.bootstrap.MenuSeparator.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.MenuSeparator,Roo.bootstrap.Component,{getAutoCreate:function(){var A={cls:'divider',tag:'li'};return A;}});
 //Roo/bootstrap/Modal.js
-Roo.bootstrap.Modal=function(A){Roo.bootstrap.Modal.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Modal,Roo.bootstrap.Component,{title:'test dialog',body:'test body',buttons:false,onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(!this.el){var B=Roo.apply({},this.getAutoCreate());B.id=Roo.id();if(this.cls){B.cls+=' '+this.cls;}if(this.style){B.style=this.style;}
+Roo.bootstrap.Modal=function(A){Roo.bootstrap.Modal.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Modal,Roo.bootstrap.Component,{title:'test dialog',buttons:false,onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(!this.el){var B=Roo.apply({},this.getAutoCreate());B.id=Roo.id();if(this.cls){B.cls+=' '+this.cls;}if(this.style){B.style=this.style;}
 this.el=Roo.get(document.body).createChild(B,A);}if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex);}
-this.initEvents();},getAutoCreate:function(){return {cls:"modal fade",cn:[{cls:"modal-dialog",cn:[{cls:"modal-content",cn:[{cls:'modal-header',cn:[{tag:'button',cls:'close',html:'&times'},{tag:'h4',cls:'modal-title',html:this.title}]},{cls:'modal-body',html:this.body},{cls:'modal-footer',cn:[{tag:'button',cls:'btn btn-default',html:'Close'},{tag:'button',cls:'btn btn-primary',html:'Save'}]}]}]}]};},initEvents:function(){this.el.select('.modal-header .close').on('click',this.hide,this);},show:function(){this.el.addClass('on');this.el.removeClass('fade');this.el.setStyle('display','block');},hide:function(){this.el.removeClass('on');this.el.addClass('fade');this.el.setStyle('display','none');}});
+this.initEvents();},getAutoCreate:function(){return {cls:"modal fade",cn:[{cls:"modal-dialog",cn:[{cls:"modal-content",cn:[{cls:'modal-header',cn:[{tag:'button',cls:'close',html:'&times'},{tag:'h4',cls:'modal-title',html:this.title}]},{cls:'modal-body'},{cls:'modal-footer'}]}]}]};},getChildContainer:function(){return this.el.select('.modal-body',true).first();},getButtonContainer:function(){return this.el.select('.modal-footer',true).first();},initEvents:function(){this.el.select('.modal-header .close').on('click',this.hide,this);},show:function(){this.el.addClass('on');this.el.removeClass('fade');this.el.setStyle('display','block');},hide:function(){this.el.removeClass('on');this.el.addClass('fade');this.el.setStyle('display','none');}});
 //Roo/bootstrap/Navbar.js
 Roo.bootstrap.Navbar=function(A){Roo.bootstrap.Navbar.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Navbar,Roo.bootstrap.Component,{sidebar:false,bar:false,brand:'',inverse:false,position:'',align:false,type:'nav',arrangement:'',getAutoCreate:function(){var A={cls:'navbar'};if(this.sidebar===true){A={tag:'div',cls:'sidebar-nav'};return A;}if(this.bar===true){A={tag:'nav',cls:'navbar',role:'navigation',cn:[{tag:'div',cls:'navbar-header',cn:[{tag:'button',type:'button',cls:'navbar-toggle','data-toggle':'collapse',cn:[{tag:'span',cls:'sr-only',html:'Toggle navigation'},{tag:'span',cls:'icon-bar'},{tag:'span',cls:'icon-bar'},{tag:'span',cls:'icon-bar'}]}]},{tag:'div',cls:'collapse navbar-collapse'}]}
 A.cls+=this.inverse?' navbar-inverse':' navbar-default';if(['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1){A.cls+=' navbar-'+this.position;A.tag=this.position=='fixed-bottom'?'footer':'header';}if(this.brand!==''){A.cn[0].cn.push({tag:'a',href:'#',cls:'navbar-brand',cn:[this.brand]});}return A;}else if(this.bar===false){}else {Roo.log('Property \'bar\' in of Navbar must be either true or false')}