(function(){function d(a,b){if(a){a=a.firstChild;for(var c;a;a=a.nextSibling)(c=a.treerow)&&b<c.nChildren&&c.getChildAt(b).rerender(),d(a.treechildren,b)}}function l(a,b,c,m,d){for(var g=[],f=0,n=0,e=a.firstChild;e;e=e.nextSibling,n++){e.treechildren&&l(e.treechildren,b,c,m,d);for(var h=0,k=e.getFirstCell();k;k=k.nextSibling,h++)h==b&&(g[f++]={wgt:k,index:n})}var p="ascending"==c?-1:1;g.sort(function(a,b){var c=m(a.wgt,b.wgt,d)*p;0==c&&(c=a.index<b.index?-1:1);return c});f=0;for(h=g.length;f<h;f++)a.appendChild(g[f].wgt.parent.parent)}
zul.sel.Treecol=zk.$extends(zul.mesh.SortWidget,{getTree:function(){return this.parent?this.parent.parent:null},getMeshBody:function(){var a=this.getTree();return a?a.treechildren:null},checkClientSort_:function(a){var b;return!(!this.getMeshBody()||!(b=this.getTree())||"paging"==b._mold)&&this.$supers("checkClientSort_",arguments)},replaceCavedChildrenInOrder_:function(a){var b=this.getMeshWidget(),c=this.getMeshBody(),d=c.desktop;try{c.unbind(),l(c,this.getChildIndex(),this.getSortDirection(),this.sorting,
"client(number)"==this[a?"_sortAscending":"_sortDescending"]),this._fixDirection(a)}finally{a=b._syncingbodyrows;b._syncingbodyrows=!0;try{b.clearCache(),jq(b.$n("rows")).replaceWith(c.redrawHTML_()),c.bind(d),b._bindDomNode()}finally{b._syncingbodyrows=a}}},$define:{maxlength:[function(a){return!a||0>a?0:a},function(){this.desktop&&(this.rerender(),this.updateCells_())}]},updateCells_:function(){var a=this.getTree();if(a){var b=this.getChildIndex(),c=a.treefoot;d(a.treechildren,b);c&&b<c.nChildren&&
c.getChildAt(b).rerender()}},bind_:function(){this.$supers(zul.sel.Treecol,"bind_",arguments);var a;(a=this.$n())&&this.domListen_(a,"onMouseOver","_doSortMouseEvt").domListen_(a,"onMouseOut","_doSortMouseEvt")},unbind_:function(){var a;(a=this.$n())&&this.domUnlisten_(a,"onMouseOver","_doSortMouseEvt").domUnlisten_(a,"onMouseOut","_doSortMouseEvt");this.$supers(zul.sel.Treecol,"unbind_",arguments)},_doSortMouseEvt:function(a){if("none"!=this.getSortAscending())jq(this.$n())["onMouseOver"==a.name?
"addClass":"removeClass"](this.getZclass()+"-sort-over")},domLabel_:function(){return zUtl.encodeXML(this.getLabel(),{maxlength:this._maxlength})}})})();
