define("arale/overlay/1.1.1/overlay",["$","arale/position/1.0.1/position","arale/iframe-shim/1.0.2/iframe-shim","arale/widget/1.1.1/widget","arale/base/1.1.1/base","arale/class/1.1.0/class","arale/events/1.1.0/events"],function(a,b,c){function d(a){return g.contains(document.documentElement,a)}function e(a){g(k.blurOverlays).each(function(b,c){if(c&&c.get("visible")){for(var d=0;d<c._relativeElements.length;d++){var e=g(c._relativeElements[d])[0];if(e===a.target||g.contains(e,a.target))return}c.hide()}})}function f(a,b){for(var c=0;c<b.length;c++)if(a===b[c])return b.splice(c,1),b}var g=a("$"),h=a("arale/position/1.0.1/position"),i=a("arale/iframe-shim/1.0.2/iframe-shim"),j=a("arale/widget/1.1.1/widget"),k=j.extend({attrs:{width:null,height:null,zIndex:99,visible:!1,align:{selfXY:[0,0],baseElement:h.VIEWPORT,baseXY:[0,0]},parentNode:document.body},show:function(){return this.rendered||this.render(),this.set("visible",!0),this},hide:function(){return this.set("visible",!1),this},setup:function(){var a=this;this._setupShim(),this._setupResize(),this.after("show",function(){a._setPosition()})},destroy:function(){return f(this,k.allOverlays),f(this,k.blurOverlays),k.superclass.destroy.call(this)},_setPosition:function(a){if(d(this.element[0])&&(a||(a=this.get("align")),a)){var b="none"===this.element.css("display");return b&&this.element.css({visibility:"hidden",display:"block"}),h.pin({element:this.element,x:a.selfXY[0],y:a.selfXY[1]},{element:a.baseElement,x:a.baseXY[0],y:a.baseXY[1]}),b&&this.element.css({visibility:"",display:"none"}),this}},_setupShim:function(){var a=new i(this.element);this.after("hide _setPosition",a.sync,a);var b=["width","height"];for(var c in b)b.hasOwnProperty(c)&&this.on("change:"+c,a.sync,a);this.before("destroy",a.destroy,a)},_setupResize:function(){k.allOverlays.push(this)},_blurHide:function(a){a=g.makeArray(a),a.push(this.element),this._relativeElements=a,k.blurOverlays.push(this)},_onRenderWidth:function(a){this.element.css("width",a)},_onRenderHeight:function(a){this.element.css("height",a)},_onRenderZIndex:function(a){this.element.css("zIndex",a)},_onRenderAlign:function(a){this._setPosition(a)},_onRenderVisible:function(a){this.element[a?"show":"hide"]()}});k.blurOverlays=[],g(document).on("click",function(a){e(a)});var l;k.allOverlays=[],g(window).resize(function(){l&&clearTimeout(l),l=setTimeout(function(){g(k.allOverlays).each(function(a,b){b&&b.get("visible")&&b._setPosition()})},80)}),c.exports=k});
