YUI.add("widget-modality",function(l,t){var e,h,i,o,s,a,n,d,r,u,c,f,g;function _(t){}e="widget",h="boundingBox",i="visible",o="zIndex",s="Change",a=l.Lang.isBoolean,n=l.ClassNameManager.getClassName,d="maskHide",f=l.config.doc,g=null,f.createElement&&(c=f.createElement("div"))&&c.style&&(c.style.position="fixed",f=f.body)&&f.appendChild&&f.removeChild&&(f.appendChild(c),g="fixed"===c.style.position,f.removeChild(c)),r=g,u={modal:n(e,"modal"),mask:n(e,"mask")},_.ATTRS={maskNode:{getter:"_getMaskNode",readOnly:!0},modal:{value:!1,validator:a},focusOn:{valueFn:function(){return[{eventName:"clickoutside"},{eventName:"focusoutside"}]},validator:l.Lang.isArray}},_.CLASSES=u,_._MASK=null,_._GET_MASK=function(){var t=_._MASK,e=l.one("win");return t&&null!==t.getDOMNode()&&t.inDoc()||(t=l.Node.create("<div></div>").addClass(u.mask),_._MASK=t,r?t.setStyles({position:"fixed",width:"100%",height:"100%",top:"0",left:"0",display:"block"}):t.setStyles({position:"absolute",width:e.get("winWidth")+"px",height:e.get("winHeight")+"px",top:"0",left:"0",display:"block"})),t},_.STACK=[],_.prototype={initializer:function(){l.after(this._renderUIModal,this,"renderUI"),l.after(this._syncUIModal,this,"syncUI"),l.after(this._bindUIModal,this,"bindUI")},destructor:function(){this._uiSetHostVisibleModal(!1)},_uiHandlesModal:null,_renderUIModal:function(){var t=this.get(h);this._repositionMask(this),t.addClass(u.modal)},_bindUIModal:function(){this.after(i+s,this._afterHostVisibleChangeModal),this.after(o+s,this._afterHostZIndexChangeModal),this.after("focusOnChange",this._afterFocusOnChange),(!r||l.UA.ios&&l.UA.ios<5||l.UA.android&&l.UA.android<3)&&l.one("win").on("scroll",this._resyncMask,this)},_syncUIModal:function(){this._uiSetHostVisibleModal(this.get(i))},_focus:function(){var t=this.get(h),e=t.get("tabIndex");t.set("tabIndex",0<=e?e:0),this.focus()},_blur:function(){this.blur()},_getMaskNode:function(){return _._GET_MASK()},_uiSetHostVisibleModal:function(t){var e=_.STACK,i=this.get("maskNode"),s=this.get("modal");t?(l.Array.each(e,function(t){t._detachUIHandlesModal(),t._blur()}),e.unshift(this),this._repositionMask(this),this._uiSetHostZIndexModal(this.get(o)),s&&(i.show(),l.later(1,this,"_attachUIHandlesModal"),this._focus(),this._blockIFrameFocus())):(0<=(t=l.Array.indexOf(e,this))&&e.splice(t,1),this._detachUIHandlesModal(),this._blur(),e.length?(s=e[0],this._repositionMask(s),s._uiSetHostZIndexModal(s.get(o)),s.get("modal")&&(l.later(1,s,"_attachUIHandlesModal"),s._focus())):"block"===i.getStyle("display")&&i.hide(),this._unblockIFrameFocus())},_blockIFrameFocus:function(){var t=this.get(h);l.all("iframe").each(function(){t.contains(this)||(this.setAttribute("data-tabindex",this.get("tabIndex")),this.set("tabIndex",-1))})},_unblockIFrameFocus:function(){l.all("iframe").each(function(){this.hasAttribute("data-tabindex")&&(this.set("tabIndex",this.getAttribute("data-tabindex")),this.removeAttribute("data-tabindex"))})},_uiSetHostZIndexModal:function(t){this.get("modal")&&this.get("maskNode").setStyle(o,t||0)},_attachUIHandlesModal:function(){if(!this._uiHandlesModal&&_.STACK[0]===this){for(var t,e=this.get(h),i=this.get("maskNode"),s=this.get("focusOn"),o=l.bind(this._focus,this),a=[],n=0,d=s.length;n<d;n++)(t={}).node=s[n].node,t.ev=s[n].eventName,t.keyCode=s[n].keyCode,t.node||t.keyCode||!t.ev?t.node&&!t.keyCode&&t.ev?a.push(t.node.on(t.ev,o)):t.node&&t.keyCode&&t.ev&&a.push(t.node.on(t.ev,o,t.keyCode)):a.push(e.on(t.ev,o));r||a.push(l.one("win").on("scroll",l.bind(function(){i.setStyle("top",i.get("docScrollY"))},this))),this._uiHandlesModal=a}},_detachUIHandlesModal:function(){l.each(this._uiHandlesModal,function(t){t.detach()}),this._uiHandlesModal=null},_afterHostVisibleChangeModal:function(t){this._uiSetHostVisibleModal(t.newVal)},_afterHostZIndexChangeModal:function(t){this._uiSetHostZIndexModal(t.newVal)},isNested:function(){return 1<_.STACK.length},_repositionMask:function(t){var e=this.get("modal"),i=t.get("modal"),s=this.get("maskNode");e&&!i?(s.remove(),this.fire(d)):(!e&&i||e&&i)&&(s.remove(),this.fire(d),(e=t.get(h).get("parentNode")||l.one("body")).insert(s,e.get("firstChild")),this.fire("maskShow"))},_resyncMask:function(t){var t=t.currentTarget,e=t.get("docScrollX"),i=t.get("docScrollY"),s=t.get("innerWidth")||t.get("winWidth"),t=t.get("innerHeight")||t.get("winHeight");this.get("maskNode").setStyles({top:i+"px",left:e+"px",width:s+"px",height:t+"px"})},_afterFocusOnChange:function(){this._detachUIHandlesModal(),this.get(i)&&this._attachUIHandlesModal()}},l.WidgetModality=_},"patched-v3.18.7",{requires:["base-build","event-outside","widget"],skinnable:!0});