Ext.namespace("Zarafa.plugins.archive"),Zarafa.plugins.archive.Archive=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){var a=container.getSettingsModel().get("zarafa/v1/plugins/archive",!0),e=this.getSiteData(a);Ext.each(e,function(a,e){this.registerInsertionPoint("main.maintabbar.left",this.createMainTab.createDelegate(this,[a]),this)},this),Zarafa.core.data.SharedComponentType.addProperty("plugins.archive.panel"),e.some(function(a){return a.autostart})&&container.on("webapploaded",function(){e.filter(function(a){return a.autostart}).forEach(function(a){this.openTab(this.createMainTab(a))},this),container.getMainPanel().contentPanel.activate(0)},this)},getSiteData:function(a){return[{buttonText:_("Archive"),url:a.url,autostart:a.autostart,iconCls:"icon_archive",tabOrder:20}]},createMainTab:function(a){return{text:_("Archive"),site:a,cls:"mainmenu-button-archive",handler:this.openTab,tabOrderIndex:a.tabOrder}},openTab:function(a){var e;(Ext.each(container.getTabPanel().items.items,function(t,i){t.url===a.site.url&&t.title===a.text&&(e=i)}),Ext.isDefined(e))?container.getMainPanel().contentPanel.activate(e):Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["plugins.archive.panel"],null,{url:a.site.url,title:a.text,iconCls:"icon_archive",tabOrder:a.site.tabOrder})},bidSharedComponent:function(a,e){var t=-1;if(a===Zarafa.core.data.SharedComponentType["plugins.archive.panel"])t=1;return t},getSharedComponent:function(a,e){if(a===Zarafa.core.data.SharedComponentType["plugins.archive.panel"])return Zarafa.plugins.archive.ui.ContentPanel}}),Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"archive",displayName:_("Archive"),pluginConstructor:Zarafa.plugins.archive.Archive}))}),Ext.namespace("Zarafa.plugins.archive.ui"),Zarafa.plugins.archive.ui.ContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{constructor:function(a){a=a||{},Ext.applyIf(a,{xtype:"zarafa.plugins.archive.ui.contentpanel",layout:"fit",iconCls:"icon_archive",border:!1,items:[{xtype:"zarafa.plugins.archive.ui.panel",url:a.url,tabOrder:a.tabOrder}]}),Zarafa.plugins.archive.ui.ContentPanel.superclass.constructor.call(this,a)}}),Ext.reg("zarafa.plugins.archive.ui.contentpanel",Zarafa.plugins.archive.ui.ContentPanel),Ext.namespace("Zarafa.plugins.archive.ui"),Zarafa.plugins.archive.ui.Panel=Ext.extend(Ext.Panel,{iframeId:void 0,isLoadMaskShown:!1,loadMask:void 0,constructor:function(a){a=a||{},this.iframeId="archive-iframe-"+a.tabOrder,this.tag="iframe",Ext.applyIf(a,{xtype:"zarafa.plugins.archive.ui.panel",layout:"fit",header:!1,html:{tag:this.tag,id:this.iframeId,cls:"archive-iframe",src:a.url,style:"display:block",partition:"persist:kw-plugin-archive"},listeners:{afterrender:this.onAfterRender,scope:this}}),Zarafa.plugins.archive.ui.Panel.superclass.constructor.call(this,a)},onAfterRender:function(){this.showLoadMask();var a=document.getElementById(this.iframeId),e="webview"===this.tag?"contentload":"load";a.addEventListener(e,function(){if(this.hideLoadMask(),"webview"===this.tag){var e=this.url;window.chrome.cookies.getAll({url:e,storeId:a.getCookieStoreId()},function(a){for(var t of a)window.chrome.cookies.set({url:e,domain:t.domain,expirationDate:t.expirationDate,httpOnly:t.httpOnly,name:t.name,path:t.path,sameSite:t.sameSite,secure:t.secure,value:t.value})})}}.createDelegate(this)),"webview"===this.tag&&(a.addEventListener("permissionrequest",this.handlePermissionRequests),a.addEventListener("dialog",this.handleDialogRequests,this),a.addEventListener("newwindow",this.handleNewWindowRequests,this))},handleDialogRequests:function(a){if("alert"===a.messageType)window.alert(a.messageText);else if("confirm"===a.messageType){window.confirm(a.messageText)?a.dialog.ok():a.dialog.cancel()}else if("prompt"===a.messageType){var e=window.prompt(a.messageText);null===e?a.dialog.cancel():a.dialog.ok(e)}},handlePermissionRequests:function(a){switch(a.preventDefault(),a.permission){case"download":case"media":case"loadplugin":a.request.allow();break;default:a.request.deny()}},handleNewWindowRequests:function(a){a.window.discard()},showLoadMask:function(a){!0!==this.isLoadMaskShown&&(this.loadMask||(this.loadMask=new Zarafa.common.ui.LoadMask(this.ownerCt.el)),a?this.loadMask.showError():(this.loadMask.show(),this.isLoadMaskShown=!0))},hideLoadMask:function(){!1!==this.isLoadMaskShown&&this.loadMask&&(this.loadMask.hide(),this.isLoadMaskShown=!1)}}),Ext.reg("zarafa.plugins.archive.ui.panel",Zarafa.plugins.archive.ui.Panel);
//# sourceMappingURL=archive.js.map