(function(){zul.sel.Treecell=zk.$extends(zul.LabelImageWidget,{setWidth:zk.$void,_colspan:1,$define:{colspan:[function(a){return 1<a?a:1},function(){var a=this.$n();a&&(a.colSpan=this._colspan)}]},getTree:function(){return this.parent?this.parent.getTree():null},domStyle_:function(a){a=zk.copy(a,{width:!0});var b="",c=this.getTreecol();c&&(c._align&&(b+="text-align: "+c._align+";"),c.isVisible()||(a=zk.copy(a,{visible:!0})));return this.$supers("domStyle_",[a])+b},getTreecol:function(){var a=this.getTree();
if(a&&a.treecols){var b=this.getChildIndex();if(b<a.treecols.nChildren)return a.treecols.getChildAt(b)}return null},getLevel:function(){return this.parent?this.parent.getLevel():0},getMaxlength:function(){var a=this.getTreecol();return a?a.getMaxlength():0},domLabel_:function(){return zUtl.encodeXML(this.getLabel(),{maxlength:this.getMaxlength()})},getTextNode:function(){return this.getCaveNode()},domContent_:function(){var a=this.$supers("domContent_",arguments),b=this._colHtmlPre();return a?b?b+
'<span class="'+this.$s("text")+'">'+a+"</span>":a:b},bind_:function(){this.$supers("bind_",arguments);if(this._clearCache){this._clearCache=!1;var a;(a=this.parent)&&a.clearCache()}},doMouseOver_:function(a){var b=this.$n();b&&zk.gecko&&(this._draggable||this.parent._draggable)&&!jq.nodeName(a.domTarget,"input","textarea")&&jq(b).addClass("z-draggable-over");this.$supers("doMouseOver_",arguments)},doMouseOut_:function(a){var b=this.$n();b&&zk.gecko&&(this._draggable||this.parent._draggable)&&!jq.nodeName(a.domTarget,
"input","textarea")&&jq(b).removeClass("z-draggable-over");this.$supers("doMouseOut_",arguments)},doFocus_:function(a){this.$supers("doFocus_",arguments);var b=this.getTree(),c=b?b.frozen:null,d=b&&b._treechildren?b._treechildren.$n():null;if(c&&d){var f=jq(a.domTarget).parents("td");for(var e=0,g=f.length;e<g;e++)if(c=f[e],c.parentNode.parentNode==d){b._moveToHidingFocusCell(c.cellIndex);break}}},_syncIcon:function(a){this.rerender(a?-1:!1);this.parent&&(this._clearCache=!0)},_colHtmlPre:function(){if(this.parent.firstChild==
this){var a=this.parent.parent,b=a.getTree(),c=new zk.Buffer;if(b&&b.isCheckmark()){var d=a.isSelectable(),f=b.isMultiple(),e=f?a.$s("checkbox"):a.$s("radio");f=f?" z-icon-check":" z-icon-radio";c.push('<span id="',this.parent.uuid,'-cm" class="',a.$s("checkable")," ",e);d&&!a.isDisabled()||c.push(" ",a.$s("disabled"));c.push('"');d||c.push(' style="visibility:hidden"');c.push('><i class="',a.$s("icon"),f,'"></i></span>')}d=b?b.getZclass():"";e=0;for(b=this._getTreeitems(a,b).length;e<b;++e)this._appendIcon(c,
d,"spacer",!1);a.isContainer()?(a=a.isOpen()?"open":"close",this._appendIcon(c,d,a,!0)):this._appendIcon(c,d,"spacer",!1);return c.join("")}return""},_getTreeitems:function(a,b){for(var c=[];;){a=a.parent;if(!a)break;a=a.parent;if(!a||a==b)break;c.unshift(a)}return c},_appendIcon:function(a,b,c,d){var f="";a.push('<span class="');if("spacer"==c)a.push(b,"-line ",b,"-",c,'"');else{var e="";if(d){var g=this.parent;g&&(e=g.uuid+"-icon")}a.push(b,'-icon"');g=this.getIconOpenClass_();-1<c.indexOf("close")&&
(g=this.getIconCloseClass_());f+='<i id="'+e+'" class="'+g+" "+b+"-"+c+'"></i>'}d&&(g=this.parent)&&a.push(' id="',g.uuid,'-open"');a.push(">",f,"</span>")},getIconOpenClass_:function(){return"z-icon-caret-down"},getIconCloseClass_:function(){return"z-icon-caret-right"},getWidth:function(){var a=this.getTreecol();return a?a.getWidth():null},domAttrs_:function(){return this.$supers("domAttrs_",arguments)+(1<this._colspan?' colspan="'+this._colspan+'"':"")},domClass_:function(a){var b=this.$supers("domClass_",
arguments),c=this.getTreecol();c&&(c.isVisible()||(b+=" "+this.$s("hidden-col")));return b},updateDomContent_:function(){this.$supers("updateDomContent_",arguments);this.parent&&this.parent.clearCache()},deferRedrawHTML_:function(a){a.push("<td",this.domAttrs_({domClass:1}),' class="z-renderdefer"></td>')}})})();
