(function(){zul.sel.ItemWidget=zk.$extends(zul.Widget,{_selectable:!0,$define:{checkable:function(b){this.setSelectable(b)},selectable:function(){this.desktop&&this.rerender()},disabled:function(){this.desktop&&this.rerender()},value:null},setSelected:function(b){if(this._selected!=b){var a=this.getMeshWidget();a&&a.toggleItemSelection(this);this._setSelectedDirectly(b)}},_setSelectedDirectly:function(b){var a=this.$n();this._selected=b;a&&(jq(a)[b?"addClass":"removeClass"](this.$s("selected")),this._updHeaderCM())},
getLabel:function(){return this.firstChild?this.firstChild.getLabel():null},isSelected:function(){return this._selected},isStripeable_:function(){return!0},getMeshWidget:function(){return this.parent},_getVisibleChild:function(b){for(var a=0,c=b.cells.length;a<c;a++)if(zk(b.cells[a]).isVisible())return b.cells[a];return b},setVisible:function(b){if(this._visible!=b&&(this.$supers("setVisible",arguments),this.isStripeable_())){var a=this.getMeshWidget();a&&a.stripe()}},domClass_:function(b){var a=
this.$supers("domClass_",arguments);b&&b.zclass||(this.getZclass(),this.isDisabled()&&(a+=(a?" ":"")+this.$s("disabled")),zk.isLoaded("zkex.sel")&&this.$instanceof(zkex.sel.Listgroup)||zk.isLoaded("zkex.sel")&&this.$instanceof(zkex.sel.Listgroupfoot)?this.getMeshWidget().groupSelect&&this.isSelected()&&(a+=(a?" ":"")+this.$s("selected")):this.isSelected()&&(a+=(a?" ":"")+this.$s("selected")));return a},focus_:function(b){var a=this.getMeshWidget();this._doFocusIn();a._syncFocus(this);a.focusA_(a.$n("a"),
b);return!0},_doFocusIn:function(){var b=this.$n(),a=this.getMeshWidget();if(b){var c=this.$s("focus"),d=a?a._focusItem:null,e;d&&(e=d.$n())&&jq(e).removeClass(c);jq(b).addClass(c)}a&&(a._focusItem=this)},_doFocusOut:function(){var b=this.$n();if(b){var a=this.$s("focus");jq(b).removeClass(a);jq(b.cells).removeClass(a)}},_updHeaderCM:function(b){var a;if((a=this.getMeshWidget())&&a._headercm&&a._multiple)if(b)a._updHeaderCM();else{b=zk.Widget.$(a._headercm).$s("checked");var c=jq(a._headercm);this.isSelected()||
void 0!=a.$$selectAll&&!this._userSelection?c.hasClass(b)||a._updHeaderCM():c.removeClass(b)}},getDragMessage_:function(){var b=this.getMeshWidget().itemIterator(),a=2;if(!this.isSelected())return zUtl.encodeXML(this.getLabel());for(;b.hasNext();){var c=b.next();if(c.isSelected()){c=c.getLabel();9<c.length&&(c=c.substring(0,9)+"...");c=zUtl.encodeXML(c);var d=d?d+('</div><div class="z-drop-content"><span id="zk_ddghost-img'+a++ +'" class="z-drop-icon"></span>&nbsp;'+c):c}}return d},cloneDrag_:function(b,
a){var c=this.getDragMessage_();a=zk.DnD.ghost(b,a,c);b._orgcursor=document.body.style.cursor;document.body.style.cursor="pointer";jq(this.getDragNode()).addClass("z-dragged");b._dragImg=jq('span[id^="zk_ddghost-img"]');return a},beforeParentChanged_:function(b){if(!b){var a=this.getMeshWidget();a&&(a._shallSyncCM=!0)}this.$supers("beforeParentChanged_",arguments)},afterParentChanged_:function(){if(this.parent){var b=this.getMeshWidget();b&&(b._shallSyncCM=!0)}this.$supers("afterParentChanged_",arguments)},
doSelect_:function(b){if(!this.isDisabled()&&this.isSelectable())try{this._userSelection=!0,b.itemSelected||(this.getMeshWidget()._doItemSelect(this,b),b.itemSelected=!0),this.$supers("doSelect_",arguments)}finally{this._userSelection=null}},doKeyDown_:function(b){var a=this.getMeshWidget();jq.nodeName(b.domTarget,"input","textarea")||(this._disableSelection_=!0,zk(a.$n()).disableSelection());a._doKeyDown(b);this.$supers("doKeyDown_",arguments)},doKeyUp_:function(b){var a=this.getMeshWidget();this._disableSelection_&&
(zk(a.$n()).enableSelection(),this._disableSelection_=!1);a._doKeyUp(b);this.$supers("doKeyUp_",arguments)},deferRedrawHTML_:function(b){b.push("<tr",this.domAttrs_({domClass:1}),' class="z-renderdefer"></tr>')},compareItemPos_:function(b){return 0}})})();
