(function(){function d(a){if(a.desktop){var b=a.$n("empty"),c=0;if(a.rows&&a.rows.nChildren)b.style.display="none";else{if(a.columns)for(var f=a.columns.firstChild;f;f=f.nextSibling)c++;b.colSpan=c||1;b.style.display="table-cell"}}a._shallFixEmpty=!1}var e=zul.grid.Grid=zk.$extends(zul.mesh.MeshWidget,{_scrollbar:null,$define:{emptyMessage:function(a){if(this.desktop){var b=jq(this.$n("empty-content")),c=this.$s("emptybody-content");a&&0!=a.trim().length?b.addClass(c):b.removeClass(c);b.html(a)}}},
getCell:function(a,b){var c;if(!(c=this.rows)||c.nChildren<=a)return null;a=c.getChildAt(a);return a.nChildren<=b?null:a.getChildAt(b)},getOddRowSclass:function(){return null==this._scOddRow?this.$s("odd"):this._scOddRow},setOddRowSclass:function(a){a||(a=null);this._scOddRow!=a&&(this._scOddRow=a,this.$n()&&this.rows&&this.rows.stripe());return this},rerender:function(){this.$supers(e,"rerender",arguments);this.rows&&this.rows._syncStripe();return this},insertBefore:function(a,b,c){if(this.$super("insertBefore",
a,b,!this.z_rod))return this._fixOnAdd(a,c,c),!0},appendChild:function(a,b){if(this.$super("appendChild",a,!this.z_rod))return this.insertingBefore_||this._fixOnAdd(a,b,b),!0},_fixOnAdd:function(a,b,c){a.$instanceof(zul.grid.Rows)?(this.rows=a,this._syncEmpty()):a.$instanceof(zul.grid.Columns)?(this.columns=a,this._syncEmpty()):a.$instanceof(zul.grid.Foot)?this.foot=a:a.$instanceof(zul.mesh.Paging)?this.paging=a:a.$instanceof(zul.mesh.Frozen)&&(this.frozen=a);b||this.rerender();c||this._syncSize()},
onChildRemoved_:function(a){this.$supers("onChildRemoved_",arguments);if(a==this.rows){this.rows=null;var b=!0;this._syncEmpty()}else a==this.columns?(this.columns=null,this._syncEmpty()):a==this.foot?this.foot=null:a==this.paging?this.paging=null:a==this.frozen&&(this.frozen=null,this.destroyBar_());b||this.childReplacing_||this._syncSize()},redrawEmpty_:function(a){a.push('<tbody class="',this.$s("emptybody"),'"><tr><td id="',this.uuid,'-empty" style="display:none">','<div id="',this.uuid,'-empty-content"');
this._emptyMessage&&0!=this._emptyMessage.trim().length&&a.push('class="',this.$s("emptybody-content"),'"');a.push(">",this._emptyMessage,"</div></td></tr></tbody>")},bind_:function(a,b,c){this.$supers(e,"bind_",arguments);var f=this;c.push(function(){d(f)})},unbind_:function(){this.destroyBar_();this.$supers(e,"unbind_",arguments)},onSize:function(){this.$supers(e,"onSize",arguments);var a=this,b=this.desktop&&!this._nativebar;!this._scrollbar&&b&&(!zk.mobile||zk.mobile&&(this.getHeight()||this.getVflex()))&&
(this._scrollbar=zul.mesh.Scrollbar.init(this));setTimeout(function(){b&&a.refreshBar_()},200)},destroyBar_:function(){var a=this._scrollbar;a&&(a.destroy(),this._scrollbar=null)},onResponse:function(a,b){this.desktop&&this._shallFixEmpty&&d(this);this.$supers(e,"onResponse",arguments)},_syncEmpty:function(){this._shallFixEmpty=!0},onChildAdded_:function(a){this.$supers(e,"onChildAdded_",arguments);this.childReplacing_&&this._fixOnAdd(a,!0)},insertChildHTML_:function(a,b,c){if(a.$instanceof(zul.grid.Rows)){this.rows=
a;if(b=this.$n("rows")){jq(b).replaceWith(a.redrawHTML_());a.bind(c);this.ebodyrows=a.$n();return}if(b=this.$n("tpad")){jq(b).after(a.redrawHTML_());a.bind(c);this.ebodyrows=a.$n();return}if(this.ebodytbl){jq(this.ebodytbl).append(a.redrawHTML_());a.bind(c);this.ebodyrows=a.$n();return}}this.rerender()},getHeadWidgetClass:function(){return zul.grid.Columns},getBodyWidgetIterator:function(a){return new zul.grid.RowIter(this,a)},hasGroup:function(){return this.rows&&this.rows.hasGroup()},scrollToIndex:function(a,
b){var c=this;this.waitForRendered_().then(function(){c._scrollToIndex(a,b)})},_getFirstItemIndex:function(){return this.rows.firstChild._index},_getLastItemIndex:function(){return this.rows.lastChild._index}})})();
zul.grid.RowIter=zk.$extends(zk.Object,{$init:function(d,e){this.grid=d;this.opts=e},_init:function(){if(!this._isInit){this._isInit=!0;var d=this.grid.rows?this.grid.rows.firstChild:null;if(this.opts&&this.opts.skipHidden)for(;d&&!d.isVisible();d=d.nextSibling);this.p=d}},hasNext:function(){this._init();return this.p},next:function(){this._init();var d=this.p,e=d?d.nextSibling:null;if(this.opts&&this.opts.skipHidden)for(;e&&!e.isVisible();e=e.nextSibling);d&&(this.p=e);return d}});
