zul.wgt.Toolbar=zk.$extends(zul.Widget,{_orient:"horizontal",_align:"start",_overflowPopupIconSclass:"z-icon-ellipsis-h",$define:{align:_zkf=function(){this.rerender()},orient:_zkf,overflowPopup:function(){this.rerender()},overflowPopupIconSclass:function(){var b=this.$n("overflowpopup-button");this.desktop&&b&&(b.className=this._getOverflowPopupBtnClass())}},bind_:function(){this.$supers("bind_",arguments);this.isOverflowPopup()&&(zWatch.listen({onFloatUp:this,onCommandReady:this,onSize:this}),this.domListen_(this.$n("overflowpopup-button"),
"onClick","_openPopup"))},unbind_:function(){this.$n("pp")&&(this.domUnlisten_(this.$n("overflowpopup-button"),"onClick","_openPopup"),zWatch.unlisten({onFloatUp:this,onCommandReady:this,onSize:this}));this.$supers("unbind_",arguments)},_getOverflowPopupBtnClass:function(){return this.$s("overflowpopup-button")+" "+this.getOverflowPopupIconSclass()+" z-icon-fw"},_openPopup:function(b){if(!this._open){this._open=!0;b=this.$n("pp");this.setFloating_(!0,{node:b});zWatch.fire("onFloatUp",this);var a=
this.setTopmost();b.style.zIndex=0<a?a:1;jq(b).removeClass(this.$s("popup-close")).addClass(this.$s("popup-open")).zk.makeVParent();this._syncPopupPosition()}},_syncPopupPosition:function(){zk(this.$n("pp")).position(this.$n(),"after_end")},onFloatUp:function(b){zUtl.isAncestor(this,b.origin)||this._closePopup()},_closePopup:function(){this._open&&(this._open=!1,jq(this.$n("pp")).removeClass(this.$s("popup-open")).addClass(this.$s("popup-close")).zk.undoVParent(),this.setFloating_(!1))},onCommandReady:function(){this.desktop&&
this.isOverflowPopup()&&this._adjustContent()},onSize:function(){this.$supers("onSize",arguments);this.desktop&&this.isOverflowPopup()&&(this._adjustContent(),this._open&&this._syncPopupPosition())},_adjustContent:function(){if(zUtl.isImageLoading())setTimeout(this.proxy(this._adjustContent),20);else{for(var b=jq(this),a=b.width()-jq(this.$n("overflowpopup-button")).width(),d=this.$n("pp"),e=this.$n("cave"),f=jq(e).children().toArray(),g=jq(d).children().toArray(),h=f.concat(g),l=h.length,m=0,k=0,
c=0;c<l;c++)if(m+=jq(h[c]).outerWidth(!0),m>=a){k=l-c;break}if(a=k-g.length)if(c=this.$s("overflowpopup-on"),h=this.$s("overflowpopup-off"),k)if(b.removeClass(h).addClass(c),0<a)for(c=0;c<a;c++)d.insertBefore(f.pop(),d.children[0]);else for(c=0;c<-a;c++)e.appendChild(g.shift());else for(b.removeClass(c).addClass(h),this._open&&this._closePopup();g.length;)e.appendChild(g.shift())}},domClass_:function(b){var a=this.$supers("domClass_",arguments);if(!b||!b.zclass){var d=this.parent&&zk.isLoaded("zul.tab")&&
this.parent.$instanceof(zul.tab.Tabbox)?this.$s("tabs"):"";d&&(a+=" "+d);this.inPanelMold()&&(a+=" "+this.$s("panel"));"vertical"==this.getOrient()&&(a+=" "+this.$s("vertical"));this.isOverflowPopup()&&(a+=" "+this.$s("overflowpopup")+" "+this.$s("overflowpopup-off"))}return a},setFlexSizeW_:function(b,a,d,e){this.$supers("setFlexSizeW_",arguments);if(!e&&"start"==this.getAlign()){var f=this.$n("cave");f&&(f.style.width=jq.px0(zk(this.$n()).contentWidth()))}},inPanelMold:function(){return"panel"==
this._mold},appendChild:function(b){this.$supers("appendChild",arguments);var a=this.$n("pp");a&&0<a.children.length&&a.appendChild(b.$n())},removeChild:function(b){var a=this.$n("pp"),d=b.$n();a&&d&&d.parentNode==a&&1==a.children.length&&(jq(this.$n()).removeClass(this.$s("overflowpopup-on")).addClass(this.$s("overflowpopup-off")),this._closePopup());this.$supers("removeChild",arguments)},onChildAdded_:function(){this.$supers("onChildAdded_",arguments);this.inPanelMold()&&this.rerender()},onChildRemoved_:function(){this.$supers("onChildRemoved_",
arguments);!this.childReplacing_&&this.inPanelMold()&&this.rerender()}});
