(function(){var l={u:"up",d:"down",l:"left",r:"right"};zul.inp.Errorbox=zk.$extends(zul.wgt.Notification,{_defaultPos:"end_before",$init:function(a,b){this.$supers("$init",[b,{ref:a}]);this.parent=a;this.parent.__ebox=this;this.msg=b;this.sclass=a._errorboxSclass;this.iconSclass=a._errorboxIconSclass||"z-icon-exclamation-triangle"},domClass_:function(a){var b=this.sclass,c=this.$supers(zul.inp.Errorbox,"domClass_",arguments);b&&(c+=" "+b);return c},show:function(){this.$n()||jq(document.body).append(this);
var a=this,b=this.parent._cst&&this.parent._cst._pos;this.parent.isRealVisible()&&setTimeout(function(){a.parent&&zul.inp.InputWidget._isInView(a)&&a.open(a.parent,null,b||a._defaultPos,{dodgeRef:!b})},50);zWatch.listen({onHide:[this.parent,this.onParentHide]})},destroy:function(){this.parent&&(zWatch.unlisten({onHide:[this.parent,this.onParentHide]}),delete this.parent.__ebox);this.close();this.unbind();jq(this).remove();this.parent=null},onParentHide:function(){this.__ebox&&(this.__ebox.setFloating_(!1),
this.__ebox.close())},bind_:function(){this.$supers(zul.inp.Errorbox,"bind_",arguments);var a=zul.inp.Errorbox;this._drag=new zk.Draggable(this,null,{starteffect:zk.$void,endeffect:a._enddrag,ignoredrag:a._ignoredrag,change:a._change});zWatch.listen({onMove:this})},unbind_:function(){var a=this._drag;this._drag=null;a&&a.destroy();zWatch.unlisten({onMove:this});this.parent&&zWatch.unlisten({onHide:[this.parent,this.onParentHide]});this.$supers(zul.inp.Errorbox,"unbind_",arguments)},getInputNode:function(){return this.parent?
this.parent.$n():null},onMove:function(){this.isOpen()&&(this.reposition(),this._fixarrow())},onSize:function(){this.$supers("onSize",arguments);this.isOpen()&&this._fixarrow()},setDomVisible_:function(a,b){this.$supers("setDomVisible_",arguments);var c=this._stackup;c&&(c.style.display=b?"":"none")},doClick_:function(a){var b=a.domTarget;b==this.$n("cls")||b==this.$n("clsIcon")?(b=this.parent)&&b.clearErrorMessage?(b.clearErrorMessage(!0,!0),b.focus(0)):zAu.wrongValue_(b,!1):(this.$supers("doClick_",
arguments),this.parent.focus(0))},open:function(){this.$supers("open",arguments);this.setTopmost();this._fixarrow()},afterCloseAnima_:function(a){a=zk.copy(a,{keepVisible:!0});this.$supers("afterCloseAnima_",arguments)},redraw:function(a){var b=this.uuid,c=this.$s("icon"),d=this.iconSclass;a.push("<div",this.domAttrs_(),'><div id="',b,'-p" class="',this.$s("pointer"),'"></div><i id="',b,'-icon" class="',c," ",d,'"></i><div id="',b,'-cave" class="',this.$s("content"),'" title="',zUtl.encodeXML(msgzk.GOTO_ERROR_FIELD),
'">',zUtl.encodeXML(this.msg,{multiline:!0}),'</div><div id="',b,'-cls" class="',this.$s("close"),'"><i id="',b,'-clsIcon" class="',c,' z-icon-times"></i></div></div>')},onFloatUp:function(a){a=a.origin;if(a==this)this.setTopmost();else if(a&&a!=this.parent&&this.isVisible()){for(var b=this,c=a;(b=b.parent)&&!b.isFloating_();)if(b==a)return;for(;c&&!c.isFloating_();c=c.parent);b==c&&(a=a.$n())&&this._uncover(a)}},_uncover:function(a){var b=zk(a).revisedOffset(),c=this.$n(),d=zk(c).cmOffset();if(jq.isOverlapped(b,
[a.offsetWidth,a.offsetHeight],d,[c.offsetWidth,c.offsetHeight])){var e=this.parent.$n();d=zk(e).cmOffset();e=d[1]+e.offsetHeight;a=b[1]+a.offsetHeight<=e?e:d[1]-c.offsetHeight;a=zk(c).toStyleOffset(0,a);c.style.top=a[1]+"px";this._fixarrow()}},_fixarrow:function(){var a=this.parent.$n(),b=this.$n(),c=this.$n("p"),d=zk(a).revisedOffset(),e=zk(b).revisedOffset(),h=e[0]-d[0],g=e[1]-d[1];e=b.style;var k=2+zk(c).borderWidth()/2||0,f=2+zk(c).borderHeight()/2||0;d=h>=a.offsetWidth-k?g<f-b.offsetHeight?
"ld":g>=a.offsetHeight-f?"lu":"l":h<k-b.offsetWidth?g<f-b.offsetHeight?"rd":g>=a.offsetHeight-f?"ru":"r":0>g?"d":"u";b.style.padding="0";if("d"==d||"u"==d)a=(Math.max(h,0)+Math.min(b.offsetWidth+h,a.offsetWidth))/2-h-6,b=b.offsetWidth-11,c.style.left=(a>b?b:1>a?1:a)+"px","d"==d?(c.style.top=null,c.style.bottom="-4px",e.paddingBottom=f+"px"):(c.style.top="-4px",e.paddingTop=f+"px");else if("l"==d||"r"==d)a=(Math.max(g,0)+Math.min(b.offsetHeight+g,a.offsetHeight))/2-g-6,b=b.offsetHeight-11,c.style.top=
(a>b?b:1>a?1:a)+"px","r"==d?(c.style.left=null,c.style.right="-4px",e.paddingRight=k+"px"):(c.style.left="-4px",e.paddingLeft=k+"px");else{b=c.style;b.left=b.top=b.right=b.bottom=null;switch(d){case "lu":b.left="0px";b.top="-4px";e.paddingTop=f+"px";break;case "ld":b.left="0px";b.bottom="-4px";e.paddingBottom=f+"px";break;case "ru":b.right="0px";b.top="-4px";e.paddingTop=f+"px";break;case "rd":b.right="0px",b.bottom="-4px",e.paddingBottom=f+"px"}d="ru"==d||"lu"==d?"u":"d"}c.className=this.$s("pointer")+
(l[d]?" "+this.$s(l[d]):"");jq(c).show()},isInView_:function(){return zul.inp.InputWidget._isInView(this)},getPositionArgs_:function(){var a=this.parent,b=a?a._cst&&a._cst._pos:!1;return[a,null,b||"end_before",{dodgeRef:!b}]}},{_enddrag:function(a){a=a.control;a.setTopmost();a._fixarrow()},_ignoredrag:function(a,b,c){return zul.inp.InputCtrl.isIgnoredDragForErrorbox(a,b,c)},_change:function(a){a=a.control;var b=a._stackup,c=a.$n();b&&(b.style.top=c.style.top,b.style.left=c.style.left);a._fixarrow();
zk.mobile&&zk(c).redoCSS()}})})();
