(function(){zul.menu.Menubar=zk.$extends(zul.Widget,{_orient:"horizontal",_bodyScrollLeft:0,$define:{orient:function(){this.rerender()},scrollable:function(a){this.checkScrollable()&&this.rerender()},autodrop:null},setWidth:function(){this.$supers("setWidth",arguments);this._checkScrolling()},domClass_:function(a){var b=this.$supers("domClass_",arguments);a&&a.zclass||(b+=" "+this.$s("vertical"==this.getOrient()?"vertical":"horizontal"));return b},unbind_:function(){if(this.checkScrollable()){var a=
this.$n("left"),b=this.$n("right");a&&b&&this.domUnlisten_(a,"onClick","_doScroll").domUnlisten_(b,"onClick","_doScroll");zWatch.unlisten({onSize:this})}a=this.$n();this.domUnlisten_(a,"onMouseEnter").domUnlisten_(a,"onMouseLeave");this._lastTarget=null;this.$supers(zul.menu.Menubar,"unbind_",arguments)},bind_:function(){this.$supers(zul.menu.Menubar,"bind_",arguments);var a=this.$n();this.domListen_(a,"onMouseEnter").domListen_(a,"onMouseLeave");if(this.checkScrollable()){a=this.$n("left");var b=
this.$n("right");a&&b&&this.domListen_(a,"onClick","_doScroll").domListen_(b,"onClick","_doScroll");zWatch.listen({onSize:this})}},checkScrollable:function(){return this._scrollable&&"horizontal"==this.getOrient()},onSize:function(){this._checkScrolling()},onChildAdded_:function(a){this.$supers("onChildAdded_",arguments);this._checkScrolling()},onChildRemoved_:function(a){this.$supers("onChildRemoved_",arguments);this.childReplacing_||this._checkScrolling()},_checkScrolling:function(){if(this.checkScrollable()){var a=
this.$n();if(a){jq(a).addClass(this.$s("scroll"));for(var b=zk(a).contentWidth(),c=this.$n("body"),d=jq(this.$n("cave")).children().filter(":visible"),e=d.length,g=0,f=e;f--;)g+=jq(d[f]).outerWidth(!0);zk.ie&&(g+=e);g>=b?this._scrolling=!0:(this._scrolling=!1,this._fixBodyScrollLeft(0),c.style.width="");this._fixButtonPos(a);a=b-zk(this.$n("left")).offsetWidth()-zk(this.$n("right")).offsetWidth();this._scrolling&&(c.style.width=jq.px0(a),this._fixScrollPos(d.last()[0]))}}},_fixScrollPos:function(a){a&&
(a=a.offsetLeft,a<this._bodyScrollLeft&&this._fixBodyScrollLeft(a))},_fixButtonPos:function(a){this.getZclass();var b=this.$n("body"),c=this.$n("left"),d=this.$n("right"),e=this._scrolling?"addClass":"removeClass";c.style.display=d.style.display=this._scrolling?"block":"none";jq(a)[e](this.$s("scroll"));b.style.marginLeft=this._scrolling?jq.px(c.offsetWidth):"0";b.style.marginRight=this._scrolling?jq.px(d.offsetWidth):"0"},_forceStyle:function(a,b){0>zk.parseInt(b)||(a.style.width=b)},_doMouseEnter:function(a){this._bOver=
!0;this._noFloatUp=!1},_doMouseLeave:function(a){this._bOver=!1;this._closeOnOut()},_doScroll:function(a){this._scroll(a.domTarget==this.$n("left")||a.domTarget.parentNode==this.$n("left")?"left":"right")},_fixBodyScrollLeft:function(a){this.$n("body").scrollLeft=this._bodyScrollLeft=a},_scroll:function(a){if(this.checkScrollable()&&!this._runId){var b=this,c=this.$n("body"),d=this._bodyScrollLeft,e=jq(this.$n("cave")).children().filter(":visible"),g=e.length,f=0;if(g)switch(a){case "left":for(a=
0;a<g;a++)if(e[a].offsetLeft>=d||e[a].offsetLeft+(e[a].offsetWidth-c.offsetWidth)>=d){d=e[a].previousSibling;if(!d)return;f=d.offsetLeft;if(isNaN(f))return;b._runId=setInterval(function(){b._moveTo(c,f)||b._afterMove()},10);return}break;case "right":var h=d+c.offsetWidth;for(a=0;a<g;a++){var k=e[a].offsetLeft+e[a].offsetWidth;if(k>h){f=d+(k-h);if(isNaN(f))break;b._runId=setInterval(function(){b._moveTo(c,f)||b._afterMove()},10);break}}}}},_moveTo:function(a,b){var c=this._bodyScrollLeft;if(c==b)return!1;
a=c>b?-5:5;c+=a;if(c<b&&0>a||c>b&&0<a)c=b;this._fixBodyScrollLeft(c);return!0},_afterMove:function(){clearInterval(this._runId);this._runId=null},insertChildHTML_:function(a,b,c){var d="vertical"==this.getOrient();b?jq(b.$n("chdextr")||b.$n()).before(this.encloseChildHTML_({child:a,vertical:d})):jq(this.$n("cave")).append(this.encloseChildHTML_({child:a,vertical:d}));a.bind(c)},removeChildHTML_:function(a){this.$supers("removeChildHTML_",arguments);jq(a.$n("chdextr")).remove()},encloseChildHTML_:function(a){var b=
a.out||new zk.Buffer;a.child.redraw(b);if(!a.out)return b.join("")},_closeOnOut:function(){var a=this;a._autodrop&&!zul.Widget.getOpenTooltip()&&setTimeout(function(){a._noFloatUp||a._bOver||!zul.menu._nOpen||zWatch.fire("onFloatUp",a)},200)}})})();
