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

Roo/bootstrap/Component.js
roojs-bootstrap-debug.js
roojs-bootstrap.js
roojs-calendar-debug.js
roojs-calendar.js

index e2555a2..62bf237 100644 (file)
@@ -434,12 +434,8 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
             
         cn.render && cn.render(parent_ctnr);
                 
-             
-       
-        
-        
        cn.xAddChildren(tree.items || cn.items);
-       delete tree.items;
+       delete tree.items; // not really needed?
         return cn;
     },
     
index c5a9b50..e8a2995 100644 (file)
@@ -428,103 +428,31 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     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);
+        cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
+         
+        var parent_ctnr = this[cntr](true);
+       if(parent_ctnr === false){
+           return; // getChildContainer an return false explicitly to block children being added?
+       }
+       if(!parent_ctnr ){
+           throw new Exception("could not find parent Container for item");
+       }
            
-            cn.parentType = this.xtype; //??
-            cn.parentId = this.id;
-            
-            var build_from_html =  Roo.XComponent.build_from_html;
+        var cn = Roo.factory(tree);
+       // at this point items[] array may be set..
+       // constructors should not really be building their children?
+       cn.parentType = this.xtype; //??
+        cn.parentId = this.id;
             
             
-            // 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.
-                
+        cn.render && cn.render(parent_ctnr);
                 
-                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);
+       cn.xAddChildren(tree.items || cn.items);
        delete tree.items;
         return cn;
     },
index 1ca9373..857dfa0 100644 (file)
@@ -13,11 +13,9 @@ 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);},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();
+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);B=(typeof(B)=='undefined')?'getChildContainer':B;
+var D=this[B](true);if(D===false){return;}if(!D){throw new Exception("could not find parent Container for item");}var cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;cn.render&&cn.render(D);cn.xAddChildren(A.items||cn.items);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
index b9c42af..a15ed43 100644 (file)
@@ -414,104 +414,29 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
     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);
+        cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
+         
+        var parent_ctnr = this[cntr](true);
+       if(parent_ctnr === false){
+           return; // getChildContainer an return false explicitly to block children being added?
+       }
+       if(!parent_ctnr ){
+           throw new Exception("could not find parent Container for item");
+       }
            
-            cn.parentType = this.xtype; //??
-            cn.parentId = this.id;
-            
-            var build_from_html =  Roo.XComponent.build_from_html;
-            
+        var cn = Roo.factory(tree);
+       // at this point items[] array may be set..
+       // constructors should not really be building their children?
+       cn.parentType = this.xtype; //??
+        cn.parentId = this.id;
             
-            // 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;
-                }
+        cn.render && cn.render(parent_ctnr);
                 
-             } 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;
+             
+       cn.xAddChildren(tree.items || cn.items);
+       delete tree.items; // not really needeD?
         return cn;
     },
     
index 37bb7d5..75aed5c 100644 (file)
@@ -11,11 +11,9 @@ 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);},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();
+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);B=(typeof(B)=='undefined')?'getChildContainer':B;
+var D=this[B](true);if(D===false){return;}if(!D){throw new Exception("could not find parent Container for item");}var cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;cn.render&&cn.render(D);cn.xAddChildren(A.items||cn.items);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