text: YUI.add("widget-parent",function(C){var B=C.Lang;function A(D){this.publish("addChild",{defaultTargetOnly:true,defaultFn:this._defAddChildFn});this.publish("removeChild",{defaultTargetOnly:true,defaultFn:this._defRemoveChildFn});this._items=[];var E,F;if(D&&D.children){E=D.children;F=this.after("initializedChange",function(G){this._add(E);F.detach();});}C.after(this._renderChildren,this,"renderUI");C.after(this._bindUIParent,this,"bindUI");C.before(this._destroyChildren,this,"destructor");this.after("selectionChange",this._afterSelectionChange);this.after("selectedChange",this._afterParentSelectedChange);this.after("activeItemChange",this._afterActiveItemChange);this._hDestroyChild=this.after("*:destroy",this._afterDestroyChild);this.after("*:focusedChange",this._updateActiveItem);}A.ATTRS={defaultChildType:{setter:function(F){var D=C.Attribute.INVALID_VALUE,E=B.isString(F)?C[F]:F;if(B.isFunction(E)){D=E;}return D;}},activeItem:{readOnly:true},multiple:{value:false,validator:B.isBoolean,writeOnce:true,getter:function(E){var D=this.get("root");return(D&&D!=this)?D.get("multiple"):E;}},selection:{readOnly:true,setter:"_setSelection",getter:function(E){var D=B.isArray(E)?(new C.ArrayList(E)):E;return D;}},selected:{setter:function(E){var D=E;if(E===1&&!this.get("multiple")){D=C.Attribute.INVALID_VALUE;}return D;}}};A.prototype={_afterDestroyChild:function(D){var E=D.target;if(E.get("parent")==this){E.remove();}},_afterSelectionChange:function(F){if(F.target==this&&F.src!=this){var D=F.newVal,E=0;if(D){E=2;if((D instanceof C.ArrayList)&&(D.size()===this.size())){E=1;}}this.set("selected",E,{src:this});}},_afterActiveItemChange:function(E){var D;if(E.target==this){D=this.get("parent");if(D){D._set("activeItem",this);}}},_afterParentSelectedChange:function(D){var E=D.newVal;if(this==D.target&&D.src!=this&&(E===0||E===1)){this.each(function(F){F.set("selected",E,{src:this});},this);}},_setSelection:function(F){var E=null,D;if(this.get("multiple")&&!this.isEmpty()){D=[];this.each(function(G){if(G.get("selected")>0){D.push(G);}});if(D.length>0){E=D;}}else{if(F.get("selected")>0){E=F;}}return E;},_updateSelection:function(E){var F=E.target,D;if(F.get("parent")==this){if(E.src!="_updateSelection"){D=this.get("selection");if(!this.get("multiple")&&D&&E.newVal>0){D.set("selected",0,{src:"_updateSelection"});}this._set("selection",F);}if(E.src==this){this._set("selection",F,{src:this});}}},_updateActiveItem:function(D){var F=D.target,E=null;if(F.get("parent")==this){if(D.newVal===true){E=D.target;}this._set("activeItem",E);}},_createChild:function(D){var I=this.get("defaultChildType"),F=D.type,H,E,G;if(F){E=B.isString(F)?C[F]:F;if(B.isFunction(E)){G=E;}}else{if(I){G=I;}}if(G){H=new G(D);}else{C.error("Could not create a child instance because its constructor is either undefined or invalid.");}return H;},_defAddChildFn:function(F){var G=F.child,D=F.index,E=this._items;if(G.get("parent")){G.remove();}if(B.isNumber(D)){E.splice(D,0,G);}else{E.push(G);}G._set("parent",this);G.addTarget(this);G.after("selectedChange",C.bind(this._updateSelection,this));},_defRemoveChildFn:function(F){var G=F.child,D=F.index,E=this._items;if(G.get("focused")){G.set("focused",false);}if(G.get("selected")){G.set("selected",0);}E.splice(D,1);G.removeTarget(this);G._set("parent",null);},_add:function(H,D){var E,G,F;if(B.isArray(H)){E=[];C.each(H,function(J,I){G=this._add(J,(D+I));if(G){E.push(G);}},this);if(E.length>0){F=E;}}else{if(H instanceof C.Widget){G=H;}else{G=this._createChild(H);}if(G&&this.fire("addChild",{child:G,index:D})){F=G;}}return F;},add:function(){var E=this._add.apply(this,arguments),D=E?(B.isArray(E)?E:[E]):[];return(new C.ArrayList(D));},remove:function(D){var F=this._items[D],E;if(F&&this.fire("removeChild",{child:F,index:D})){E=F;}return E;},removeAll:function(){var D=[],E;C.each(this._items.concat(),function(){E=this.remove(0);if(E){D.push(E);}},this);return(new C.ArrayList(D));},selectChild:function(D){this.item(D).set("selected",1);},selectAll:function(){this.set("selected",1);},deselectAll:function(){this.set("selected",0);},_uiAddChild:function(F,D,E){F.render(D);if(B.isNumber(E)){D.insert(F.get("boundingBox"),E);}},_uiRemoveChild:function(D){D.get("boundingBox").remove();},_afterAddChild:function(D){var E=D.child;if(E.get("parent")==this){this._uiAddChild(E,this.get("contentBox"),D.index);}},_afterRemoveChild:function(D){var E=D.child;if(E.get("parent")==this){this._uiRemoveChild(E);}},_bindUIParent:function(){this.after("addChild",this._afterAddChild);this.after("removeChild",this._afterRemoveChild);},_renderChildren:function(){var D=this.get("contentBox");this.each(function(E){E.render(D);});},_destroyChildren:function(){this._hDestroyChild.detach();this.each(function(D){D.destroy();});}};C.augment(A,C.ArrayList);C.WidgetParent=A;},"@VERSION@",{requires:["widget","arraylist"]});