From: Alan Knowles Date: Thu, 21 Feb 2019 09:06:02 +0000 (+0800) Subject: roojs-bootstrap.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=afd244aea746486e90280a85e9d6b1b3618166ad roojs-bootstrap.js roojs-bootstrap-debug.js roojs-calendar.js roojs-calendar-debug.js Roo/bootstrap/Component.js --- diff --git a/Roo/bootstrap/Component.js b/Roo/bootstrap/Component.js index e2555a21c0..62bf237687 100644 --- a/Roo/bootstrap/Component.js +++ b/Roo/bootstrap/Component.js @@ -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; }, diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index c5a9b503af..e8a2995e6d 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -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; }, diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 1ca9373c2e..857dfa014a 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -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*[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*[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; }, diff --git a/roojs-calendar.js b/roojs-calendar.js index 37bb7d51bf..75aed5c536 100644 --- a/roojs-calendar.js +++ b/roojs-calendar.js @@ -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*[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