roojs-bootstrap.js
authorAlan Knowles <alan@roojs.com>
Thu, 21 Feb 2019 09:02:05 +0000 (17:02 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 21 Feb 2019 09:02:05 +0000 (17:02 +0800)
roojs-bootstrap-debug.js
roojs-calendar.js
roojs-calendar-debug.js

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

index a98bd3c..c5a9b50 100644 (file)
@@ -388,6 +388,10 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     },
     
     
+    
+    
+    
+    
     /**
      * xAddChildren - the 'sub-compentized' version of the above idea..
      */
@@ -413,6 +417,119 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     },
     
     
+    /**
+     * add a child to this element
+     *   - turn the child.cfg into a child_instance
+     *   - call child_instance.render( this { getContainerMethod()} )
+     *   - loop through the children, and call addxtype.. (reall this) on newly created child.
+     *  
+     */
+    
+    xAdd : function (tree, cntr, is_body)
+    {
+        Roo.debug && Roo.log('xadd:' + cntr);
+        var cn = this;
+        cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
+        
+        
+        var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
+                    (typeof(tree['flexy:foreach']) != 'undefined');
+          
+    
+        
+        skip_children = false;
+        // render the element if it's not BODY.
+        if (!is_body) {
+            
+            // if parent was disabled, then do not try and create the children..
+            if(!this[cntr](true)){
+                tree.items = [];
+                return tree;
+            }
+           
+            cn = Roo.factory(tree);
+           
+            cn.parentType = this.xtype; //??
+            cn.parentId = this.id;
+            
+            var build_from_html =  Roo.XComponent.build_from_html;
+            
+            
+            // does the container contain child eleemnts with 'xtype' attributes.
+            // that match this xtype..
+            // note - when we render we create these as well..
+            // so we should check to see if body has xtype set.
+            if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
+               
+                var self_cntr_el = Roo.get(this[cntr](false));
+                var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
+                if (echild) { 
+                    //Roo.log(Roo.XComponent.build_from_html);
+                    //Roo.log("got echild:");
+                    //Roo.log(echild);
+                }
+                // there is a scenario where some of the child elements are flexy:if (and all of the same type)
+                // and are not displayed -this causes this to use up the wrong element when matching.
+                // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
+                
+                
+                if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
+                  //  Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
+                  
+                  
+                  
+                    cn.el = echild;
+                  //  Roo.log("GOT");
+                    //echild.dom.removeAttribute('xtype');
+                } else {
+                    Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
+                    Roo.debug && Roo.log(self_cntr_el);
+                    Roo.debug && Roo.log(echild);
+                    Roo.debug && Roo.log(cn);
+                }
+            }
+           
+            
+           
+            // if object has flexy:if - then it may or may not be rendered.
+            if (build_from_html && has_flexy && !cn.el &&  cn.can_build_overlaid) {
+                // skip a flexy if element.
+                Roo.debug && Roo.log('skipping render');
+                Roo.debug && Roo.log(tree);
+                if (!cn.el) {
+                    Roo.debug && Roo.log('skipping all children');
+                    skip_children = true;
+                }
+                
+             } else {
+                 
+                // actually if flexy:foreach is found, we really want to create 
+                // multiple copies here...
+                //Roo.log('render');
+                //Roo.log(this[cntr]());
+                // some elements do not have render methods.. like the layouts...
+                /*
+                if(this[cntr](true) === false){
+                    cn.items = [];
+                    return cn;
+                }
+                */
+                cn.render && cn.render(this[cntr](true));
+                
+             }
+            // then add the element..
+        }
+        
+       
+       
+        
+        
+       cn.addxtypeChildren(tree.items, skip_children);
+       delete tree.items;
+        return cn;
+    },
+    
+    
     /**
      * Set the element that will be used to show or hide
      */
index a01b766..1ca9373 100644 (file)
@@ -13,9 +13,13 @@ var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefi
 var G=F?F.child('>*[xtype]'):false;if(G){}if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else{Roo.debug&&Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));Roo.debug&&Roo.log(F);Roo.debug&&Roo.log(G);
 Roo.debug&&Roo.log(cn);}}if(E&&D&&!cn.el&&cn.can_build_overlaid){Roo.debug&&Roo.log('skipping render');Roo.debug&&Roo.log(A);if(!cn.el){Roo.debug&&Roo.log('skipping all children');skip_children=true;}}else{cn.render&&cn.render(this[B](true));}}cn.addxtypeChildren(A.items,skip_children);
 delete A.items;return cn;},addxtypeChildren:function(A,B){var C=[];if(!A||!A.length){this.items=C;return;}for(var i=0;i<A.length;i++){if(B){break;}C.push(this.addxtype(Roo.apply({},A[i])));}this.items=C;this.fireEvent('childrenrendered',this);},xAddChildren:function(A,B){var C=[];
-if(!A||!A.length){this.items=C;return;}for(var i=0;i<A.length;i++){if(B){break;}C.push(this.xAdd(Roo.apply({},A[i])));}this.items=C;this.fireEvent('childrenrendered',this);},setVisibilityEl:function(el){this.visibilityEl=el;},getVisibilityEl:function(){if(typeof(this.visibilityEl)=='object'){return this.visibilityEl;
-}if(typeof(this.visibilityEl)=='string'){return this.visibilityEl=='parent'?this.parent().getEl():this.getEl();}return this.getEl();},show:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().removeClass(['hidden','d-none']);this.fireEvent('show',this);
-},hide:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().addClass(['hidden','d-none']);this.fireEvent('hide',this);}});
+if(!A||!A.length){this.items=C;return;}for(var i=0;i<A.length;i++){if(B){break;}C.push(this.xAdd(Roo.apply({},A[i])));}this.items=C;this.fireEvent('childrenrendered',this);},xAdd:function(A,B,C){Roo.debug&&Roo.log('xadd:'+B);var cn=this;B=(typeof(B)=='undefined')?'getChildContainer':B;
+var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefined');skip_children=false;if(!C){if(!this[B](true)){A.items=[];return A;}cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;var E=Roo.XComponent.build_from_html;if(E&&Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body'){var F=Roo.get(this[B](false));
+var G=F?F.child('>*[xtype]'):false;if(G){}if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else{Roo.debug&&Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));Roo.debug&&Roo.log(F);Roo.debug&&Roo.log(G);
+Roo.debug&&Roo.log(cn);}}if(E&&D&&!cn.el&&cn.can_build_overlaid){Roo.debug&&Roo.log('skipping render');Roo.debug&&Roo.log(A);if(!cn.el){Roo.debug&&Roo.log('skipping all children');skip_children=true;}}else{cn.render&&cn.render(this[B](true));}}cn.addxtypeChildren(A.items,skip_children);
+delete A.items;return cn;},setVisibilityEl:function(el){this.visibilityEl=el;},getVisibilityEl:function(){if(typeof(this.visibilityEl)=='object'){return this.visibilityEl;}if(typeof(this.visibilityEl)=='string'){return this.visibilityEl=='parent'?this.parent().getEl():this.getEl();
+}return this.getEl();},show:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().removeClass(['hidden','d-none']);this.fireEvent('show',this);},hide:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().addClass(['hidden','d-none']);
+this.fireEvent('hide',this);}});
 // Roo/bootstrap/Body.js
 Roo.bootstrap.Body=function(A){A=A||{};Roo.bootstrap.Body.superclass.constructor.call(this,A);this.el=Roo.get(A.el?A.el:document.body);if(this.cls&&this.cls.length){Roo.get(document.body).addClass(this.cls);}if(A.do_render){this.onRender(A.do_render,'');this.xAddChildren(A.items);
 }};Roo.extend(Roo.bootstrap.Body,Roo.bootstrap.Component,{do_render:false,is_body:true,autoCreate:{cls:'container'},onRender:function(ct,A){if(!this.do_render){return;}this.el=Roo.get(this.do_render);}});
index b7a7e0a..b9c42af 100644 (file)
@@ -374,6 +374,10 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     },
     
     
+    
+    
+    
+    
     /**
      * xAddChildren - the 'sub-compentized' version of the above idea..
      */
@@ -399,6 +403,119 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     },
     
     
+    /**
+     * add a child to this element
+     *   - turn the child.cfg into a child_instance
+     *   - call child_instance.render( this { getContainerMethod()} )
+     *   - loop through the children, and call addxtype.. (reall this) on newly created child.
+     *  
+     */
+    
+    xAdd : function (tree, cntr, is_body)
+    {
+        Roo.debug && Roo.log('xadd:' + cntr);
+        var cn = this;
+        cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
+        
+        
+        var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
+                    (typeof(tree['flexy:foreach']) != 'undefined');
+          
+    
+        
+        skip_children = false;
+        // render the element if it's not BODY.
+        if (!is_body) {
+            
+            // if parent was disabled, then do not try and create the children..
+            if(!this[cntr](true)){
+                tree.items = [];
+                return tree;
+            }
+           
+            cn = Roo.factory(tree);
+           
+            cn.parentType = this.xtype; //??
+            cn.parentId = this.id;
+            
+            var build_from_html =  Roo.XComponent.build_from_html;
+            
+            
+            // does the container contain child eleemnts with 'xtype' attributes.
+            // that match this xtype..
+            // note - when we render we create these as well..
+            // so we should check to see if body has xtype set.
+            if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
+               
+                var self_cntr_el = Roo.get(this[cntr](false));
+                var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
+                if (echild) { 
+                    //Roo.log(Roo.XComponent.build_from_html);
+                    //Roo.log("got echild:");
+                    //Roo.log(echild);
+                }
+                // there is a scenario where some of the child elements are flexy:if (and all of the same type)
+                // and are not displayed -this causes this to use up the wrong element when matching.
+                // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
+                
+                
+                if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
+                  //  Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
+                  
+                  
+                  
+                    cn.el = echild;
+                  //  Roo.log("GOT");
+                    //echild.dom.removeAttribute('xtype');
+                } else {
+                    Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
+                    Roo.debug && Roo.log(self_cntr_el);
+                    Roo.debug && Roo.log(echild);
+                    Roo.debug && Roo.log(cn);
+                }
+            }
+           
+            
+           
+            // if object has flexy:if - then it may or may not be rendered.
+            if (build_from_html && has_flexy && !cn.el &&  cn.can_build_overlaid) {
+                // skip a flexy if element.
+                Roo.debug && Roo.log('skipping render');
+                Roo.debug && Roo.log(tree);
+                if (!cn.el) {
+                    Roo.debug && Roo.log('skipping all children');
+                    skip_children = true;
+                }
+                
+             } else {
+                 
+                // actually if flexy:foreach is found, we really want to create 
+                // multiple copies here...
+                //Roo.log('render');
+                //Roo.log(this[cntr]());
+                // some elements do not have render methods.. like the layouts...
+                /*
+                if(this[cntr](true) === false){
+                    cn.items = [];
+                    return cn;
+                }
+                */
+                cn.render && cn.render(this[cntr](true));
+                
+             }
+            // then add the element..
+        }
+        
+       
+       
+        
+        
+       cn.addxtypeChildren(tree.items, skip_children);
+       delete tree.items;
+        return cn;
+    },
+    
+    
     /**
      * Set the element that will be used to show or hide
      */
index 7f9e0b5..37bb7d5 100644 (file)
@@ -11,9 +11,13 @@ var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefi
 var G=F?F.child('>*[xtype]'):false;if(G){}if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else{Roo.debug&&Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));Roo.debug&&Roo.log(F);Roo.debug&&Roo.log(G);
 Roo.debug&&Roo.log(cn);}}if(E&&D&&!cn.el&&cn.can_build_overlaid){Roo.debug&&Roo.log('skipping render');Roo.debug&&Roo.log(A);if(!cn.el){Roo.debug&&Roo.log('skipping all children');skip_children=true;}}else{cn.render&&cn.render(this[B](true));}}cn.addxtypeChildren(A.items,skip_children);
 delete A.items;return cn;},addxtypeChildren:function(A,B){var C=[];if(!A||!A.length){this.items=C;return;}for(var i=0;i<A.length;i++){if(B){break;}C.push(this.addxtype(Roo.apply({},A[i])));}this.items=C;this.fireEvent('childrenrendered',this);},xAddChildren:function(A,B){var C=[];
-if(!A||!A.length){this.items=C;return;}for(var i=0;i<A.length;i++){if(B){break;}C.push(this.xAdd(Roo.apply({},A[i])));}this.items=C;this.fireEvent('childrenrendered',this);},setVisibilityEl:function(el){this.visibilityEl=el;},getVisibilityEl:function(){if(typeof(this.visibilityEl)=='object'){return this.visibilityEl;
-}if(typeof(this.visibilityEl)=='string'){return this.visibilityEl=='parent'?this.parent().getEl():this.getEl();}return this.getEl();},show:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().removeClass(['hidden','d-none']);this.fireEvent('show',this);
-},hide:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().addClass(['hidden','d-none']);this.fireEvent('hide',this);}});
+if(!A||!A.length){this.items=C;return;}for(var i=0;i<A.length;i++){if(B){break;}C.push(this.xAdd(Roo.apply({},A[i])));}this.items=C;this.fireEvent('childrenrendered',this);},xAdd:function(A,B,C){Roo.debug&&Roo.log('xadd:'+B);var cn=this;B=(typeof(B)=='undefined')?'getChildContainer':B;
+var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefined');skip_children=false;if(!C){if(!this[B](true)){A.items=[];return A;}cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;var E=Roo.XComponent.build_from_html;if(E&&Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body'){var F=Roo.get(this[B](false));
+var G=F?F.child('>*[xtype]'):false;if(G){}if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else{Roo.debug&&Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));Roo.debug&&Roo.log(F);Roo.debug&&Roo.log(G);
+Roo.debug&&Roo.log(cn);}}if(E&&D&&!cn.el&&cn.can_build_overlaid){Roo.debug&&Roo.log('skipping render');Roo.debug&&Roo.log(A);if(!cn.el){Roo.debug&&Roo.log('skipping all children');skip_children=true;}}else{cn.render&&cn.render(this[B](true));}}cn.addxtypeChildren(A.items,skip_children);
+delete A.items;return cn;},setVisibilityEl:function(el){this.visibilityEl=el;},getVisibilityEl:function(){if(typeof(this.visibilityEl)=='object'){return this.visibilityEl;}if(typeof(this.visibilityEl)=='string'){return this.visibilityEl=='parent'?this.parent().getEl():this.getEl();
+}return this.getEl();},show:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().removeClass(['hidden','d-none']);this.fireEvent('show',this);},hide:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().addClass(['hidden','d-none']);
+this.fireEvent('hide',this);}});
 // Roo/bootstrap/Calendar.js
 Roo.bootstrap=Roo.bootstrap||{};Roo.bootstrap.Calendar=function(A){Roo.bootstrap.Calendar.superclass.constructor.call(this,A);this.addEvents({'select':true,'monthchange':true,'evententer':true,'eventleave':true,'eventclick':true});};Roo.extend(Roo.bootstrap.Calendar,Roo.bootstrap.Component,{startDay:0,loadMask:false,header:false,getAutoCreate:function(){var A=function(H,I,J,K){return Roo.apply({}
 ,{tag:'span',cls:'fc-button fc-button-'+H+' fc-state-default '+(I.length?'fc-corner-'+I.split(' ').join(' fc-corner-'):''),html:'<SPAN class="fc-text-'+J+'">'+K+'</SPAN>',unselectable:'on'});};var B={};if(!this.header){B={tag:'table',cls:'fc-header',style:'width:100%',cn:[{tag:'tr',cn:[{tag:'td',cls:'fc-header-left',cn:[A('prev','left','arrow','&#8249;'),A('next','right','arrow','&#8250;'),{tag:'span',cls:'fc-header-space'}