(function(){"use strict";u8.Base.PopupBrowsing=function(){this.id="popupBrowsing";this._popup=null;this._elFrame=null;u8.services.events.bind("u8.services.pages.onPageInit",this._onPageInit.bind(this),this.id).bind("u8.services.history.onChange",this._onHistoryChange.bind(this),this.id).bind("u8.session.onLogout",this._onLogout.bind(this),this.id)};$.extend(u8.Base.PopupBrowsing.prototype,{isPopupOpen:function(){return!!this._popup},getFrameElement:function(){return this._elFrame},createPopup:function(e){if(!this.closePopup()){return null}if(!e){e={}}var t;t=this._elFrame=this._createIFrame();i(t,false);var o={allowClose:true,allowMaximize:true,allowResize:true,allowMove:true,autoClose:false,autoShow:false,position:"center",alignTo:"window",size:{width:e.width||.6,height:e.height||.6},title:e.title,defaultTitle:u8.session.commonTexts.loading,disposeOnClose:true,modal:true,onCreate:this._onPopupCreate.bind(this),onDispose:this._onPopupDispose.bind(this)};if("sizing"in e){o.sizing=e.sizing;if(o.sizing=="fit"){delete o.size}}if("minSize"in e){o.minSize=e.minSize}this._popup=u8.widget("Popup",t,o);this._popup.open();return t.contentWindow},closePopup:function(i){if(this._popup){if(i){this._popup.dispose()}else{this._popup.close()}if(this._popup&&this._popup.isOpen()){return false}this._popup=null}this._removeIFrame();return true},dispose:function(){if(this._isDisposed){return}if(this._popup){this._popup.dispose();this._popup=null}this._removeIFrame();u8.services.events.unbind("u8.services.pages.onPageInit",this.id).unbind("u8.services.history.onChange",this.id).unbind("u8.session.onLogout",this.id);this._isDisposed=true},_createIFrame:function(){var i=u8.application.getMainWindow();var e=i.document.createElement("iframe");e.id="popupWorkFrame";e.name="popupWorkFrame";e.src="about:blank";e.frameBorder="0";e.scrolling="auto";e.style.width="100%";e.style.height="100%";return e},_removeIFrame:function(){var i=this._elFrame;if(!i){return}this._elFrame=null;i.parentNode.removeChild(i)},_updateTitle:function(){if(!this._popup){return}var i=this._getPopupContentWindow();if(!i){return}var e=this._getPopupDefaultTitle(i);if(e){this._popup.setDefaultTitle(e)}},_getPopupDefaultTitle:function(i){var e=u8.services.tabbedBrowsing.getWindowOptions(i);return e&&e.label},_getPopupContentWindow:function(){return this._elFrame&&this._elFrame.contentWindow},_onPopupDispose:function(){this._popup=null;this._elFrame=null},_onPopupCreate:function(e){i(this._elFrame,true);e.autoSizeAndPosition().show();this._updateTitle()},_onPageInit:function(i,e){if(!this._popup){return}var t=e.elWindow;if(!t||t!=this._elFrame.contentWindow||!this._popup){return}var o=$p("work");if(o&&o.process){e.page.process=o.process}this._updateTitle()},_onHistoryChange:function(i,e){if(!this._popup){return}this._updateTitle()},_onLogout:function(i,e){if(!this._popup){return}this.closePopup(true)}});function i(i,e){i.style.opacity=e?1:0}u8.Base.PopupBrowsing.makeClass({name:"PopupBrowsing"});u8.services.add("popupBrowsing")})();