(function(){var l={warning:"z-icon-exclamation-circle",info:"z-icon-info-circle",error:"z-icon-times-circle"},m={u:"up",d:"down",l:"left",r:"right"};zul.wgt.Notification=zk.$extends(zul.wgt.Popup,{_keepVisible:!0,$init:function(b,a){this.$supers(zul.wgt.Notification,"$init",arguments);this._msg=b;this._type=a.type;this._ref=a.ref;this._dur=a.dur;this._closable=a.closable},redraw:function(b){var a=this.uuid,c=this.$s("icon");b.push("<div",this.domAttrs_(),">");this._ref&&b.push('<div id="',a,'-p" class="',
this.$s("pointer"),'"></div>');b.push('<i id="',a,'-icon" class="',c," ",l[this._type],'"></i>');b.push('<div id="',a,'-cave" class="',this.$s("content"),'">',this._msg,"</div>");this._closable&&b.push('<div id="',a,'-cls" class="',this.$s("close"),'"><i id="',a,'-clsIcon" class="',c,' z-icon-times"></i></div>');b.push("</div>")},domClass_:function(b){var a=this._type,c=this.$supers(zul.wgt.Notification,"domClass_",arguments);a&&(c+=" "+this.$s(zUtl.encodeXML(a)));return c},doClick_:function(b){var a=
b.domTarget;a==this.$n("cls")||a==this.$n("clsIcon")?this.close():this.$supers("doClick_",arguments)},onFloatUp:function(b,a){if((!a||!a.triggerByFocus)&&this.isVisible()){b=b.origin;for(var c;b;b=b.parent){if(b==this){c||this.setTopmost();return}if(b==this.parent&&b.ignoreDescendantFloatUp_(this))return;c=c||b.isFloating_()}!this._closable&&0>=this._dur&&this.close({sendOnOpen:!0})}},open:function(b,a,c,d){this.$supers(zul.wgt.Notification,"open",arguments);this._fixarrow(b);zk(this).redoCSS(-1,
{fixFontIcon:!0})},position:function(b,a,c,d){if(!b||b.$n())this.$supers(zul.wgt.Notification,"position",arguments),this._fixarrow(b)},_posInfo:function(b,a,c,d){this._fixPadding(c);return this.$supers(zul.wgt.Notification,"_posInfo",arguments)},_fixPadding:function(b){var a=this.$n("p");if(a){var c=this.$n(),d=2+zk(a).borderWidth()/2||0;a=2+zk(a).borderHeight()/2||0;c.style.padding="0";switch(b){case "before_start":case "before_center":case "before_end":this._dir="d";c.style.paddingBottom=a+"px";
break;case "after_start":case "after_center":case "after_end":this._dir="u";c.style.paddingTop=a+"px";break;case "end_before":case "end_center":case "end_after":this._dir="l";c.style.paddingLeft=d+"px";break;case "start_before":case "start_center":case "start_after":this._dir="r";c.style.paddingRight=d+"px";break;case "top_left":case "top_center":case "top_right":case "middle_left":case "middle_center":case "middle_right":case "bottom_left":case "bottom_center":case "bottom_right":case "overlap":case "overlap_end":case "overlap_before":case "overlap_after":this._dir=
"n";break;default:this._dir="n"}}},_fixarrow:function(b){var a=this.$n("p");if(a){var c=this.$s("pointer"),d=this.$n();b=b.$n();var e=this._dir;var g=zk(a);var f=g.borderWidth(),h=g.borderHeight(),k=zk(d).revisedOffset(),n=zk(b).revisedOffset(),l=(b.offsetWidth-f)/2,p=(b.offsetHeight-h)/2;"n"!=e?("u"==e||"d"==e?(g="u"==e,f=(d.offsetWidth-f)/2||0,k=n[0]-k[0]+l||0,a.style.left=(b.offsetWidth>=d.offsetWidth?f:k)+"px",a.style[g?"top":"bottom"]=(2-h/2||0)+"px",a.style[g?"bottom":"top"]=""):(g="l"==e,h=
(d.offsetHeight-h)/2||0,k=n[1]-k[1]+p||0,a.style.top=(b.offsetHeight>=d.offsetHeight?h:k)+"px",a.style[g?"left":"right"]=(2-f/2||0)+"px",a.style[g?"right":"left"]=""),a.className=c+(m[e]?" "+this.$s(m[e]):""),jq(a).show()):(a.className=c,jq(a).hide())}},openAnima_:function(b,a,c,d){var e=this;jq(this.$n()).fadeIn(500,function(){e.afterOpenAnima_(b,a,c,d)})},closeAnima_:function(b){var a=this;jq(this.$n()).fadeOut(500,function(){a.afterCloseAnima_(b)})},afterCloseAnima_:function(b){b&&b.keepVisible?
(this.setVisible(!1),this.setFloating_(!1),b.sendOnOpen&&this.fire("onOpen",{open:!1})):this.detach()},getPositionArgs_:function(){return[this._fakeParent,null,this._nftPos,null]},reposition:function(){this.$supers("reposition",arguments);this._ref&&this._fixarrow(this._ref)}},{show:function(b,a,c){c||(c={});a=zk.Widget.$(a);var d=c.ref,e=c.pos,g=c.dur,f=new zul.wgt.Notification(b,c);b=c.off;var h=!0;d&&(h=d.$n("real")||d.$n(),h=zk(h).isRealScrollIntoView());h&&(e||b||(e=d?"end_center":"middle_center"),
a||(a=zk.Desktop.$().firstChild),a.appendChild(f),f.parent=f._fakeParent=c.ref,f._nftPos=e,f.open(d,b,e),0<g&&setTimeout(function(){f.desktop&&f.close()},g))}})})();
