(function(){var e=u8.device.pointer?window.navigator.pointerEnabled?"pointerdown":"MSPointerDown":u8.device.mouse?"mousedown":"touchstart";u8.Base.Popups=function(e){$.extend(this,u8.Base.Popups.defaults,e);this.id="popups";this._onDocumentMouseDown=this._onDocumentMouseDown.bind(this);u8.services.events.bind("u8.services.pages.onPageInit",this._onPageInit.bind(this),this.id)};u8.Base.Popups.makeClass("Popups");$.extend(u8.Base.Popups.prototype,{autoClose:function(e){u8.services.events.raise("u8.services.popups.onAutoClose",this,e||{})},dispose:function(){if(this._isDisposed){return}this._isDisposed=true;u8.services.events.unbind("u8.services.pages.onPageInit",this.id)},_onPageInit:function(t){t.elWindow.document.addEventListener(e,this._onDocumentMouseDown,true);t.bind("Unload",this._onPageUnload.bind(this),this.id)},_onPageUnload:function(t){t.elWindow.document.removeEventListener(e,this._onDocumentMouseDown,true)},_onDocumentMouseDown:function(e){var t=e!=null&&e.target!=null?e.target.clientWidth:0;var n=e!=null&&e.target!=null?e.target.offsetWidth:0;var o=e&&e.target&&e.target.nodeName=="UL";var s=e&&e.target&&u8.Base.Widgets.Tools.closest(e.target,"ContextMenu")&&u8.Base.Widgets.Tools.closest(e.target,"ContextMenu").isParentOf(e.target);if(t!=n&&(o||s)){function i(e){e=e||window.event;var t=e.target||e.srcElement,n=t.currentStyle||window.getComputedStyle(t,null),o=parseInt(n["borderLeftWidth"],10),s=t.getBoundingClientRect(),i=e.clientX-o-s.left;return i}var u=e.offsetX||i(e);if(t<=u&&u<=n){return}}u8.services.popups.autoClose({reason:"click",elEvent:e})}});u8.services.add({name:"popups",scope:"Application",ctor:u8.Base.Popups})})();