Ext.namespace("Zarafa.plugins.intranet");Zarafa.plugins.intranet.isDeskApp=function(){return Ext.isFunction(Zarafa.isDeskApp)?Zarafa.isDeskApp():Ext.isDefined(window.nw)};
Zarafa.plugins.intranet.Intranet=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){var a=container.getSettingsModel().get("zarafa/v1/plugins/intranet",!0),b=this.getSiteData(a);this.prepareStyle(b);Ext.each(b,function(c,d){this.registerInsertionPoint("main.maintabbar.left",this.createMainTab.createDelegate(this,[c]),this)},this);Zarafa.core.data.SharedComponentType.addProperty("plugins.intranet.panel");if(b.some(function(c){return c.autostart}))container.on("webapploaded",function(){b.filter(function(c){return c.autostart}).forEach(function(c){this.openTab(this.createMainTab(c))},
this);container.getMainPanel().contentPanel.activate(0)},this)},getSiteData:function(a){for(var b=[{buttonText:a["button-title"],url:a.url,autostart:a.autostart,iconCls:"icon_intranet",iconPath:a.icon,tabOrder:21}],c=1;Ext.isDefined(a["url-"+c]);)b.push({buttonText:a["button-title-"+c],url:a["url-"+c],autostart:a["autostart-"+c],iconCls:"icon_intranet_"+c,iconPath:a["icon-"+c],tabOrder:21+c}),c++;return b},prepareStyle:function(a){var b="";Ext.each(a,function(c){b+="."+c.iconCls+" { background-image: url("+
c.iconPath+") !important; } \n";b+=".x-tab-strip-text."+c.iconCls+" { background-position: 0 10px !important;} \n";delete c.iconPath});Ext.DomHelper.append(Ext.getHead(),{tag:"style",id:"intranet_style",type:"text/css",html:b})},createMainTab:function(a){return{text:a.buttonText,site:a,cls:"mainmenu-button-intranet",handler:this.openTab,tabOrderIndex:a.tabOrder}},openTab:function(a){var b;Ext.each(container.getTabPanel().items.items,function(c,d){c.url===a.site.url&&c.title===a.text&&(b=d)});Ext.isDefined(b)?
container.getMainPanel().contentPanel.activate(b):Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["plugins.intranet.panel"],null,{url:a.site.url,title:a.text,iconCls:a.site.iconCls,tabOrder:a.site.tabOrder})},bidSharedComponent:function(a,b){b=-1;switch(a){case Zarafa.core.data.SharedComponentType["plugins.intranet.panel"]:b=1}return b},getSharedComponent:function(a,b){switch(a){case Zarafa.core.data.SharedComponentType["plugins.intranet.panel"]:return Zarafa.plugins.intranet.ui.ContentPanel}}});
Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"intranet",displayName:_("Intranet"),pluginConstructor:Zarafa.plugins.intranet.Intranet}))});Ext.namespace("Zarafa.plugins.intranet.ui");
Zarafa.plugins.intranet.ui.ContentPanel=Ext.extend(Zarafa.core.ui.ContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"zarafa.plugins.intranet.ui.contentpanel",layout:"fit",iconCls:a.iconCls,border:!1,items:[{xtype:"zarafa.plugins.intranet.ui.panel",url:a.url,tabOrder:a.tabOrder}]});Zarafa.plugins.intranet.ui.ContentPanel.superclass.constructor.call(this,a)}});Ext.reg("zarafa.plugins.intranet.ui.contentpanel",Zarafa.plugins.intranet.ui.ContentPanel);Ext.namespace("Zarafa.plugins.intranet.ui");
Zarafa.plugins.intranet.ui.Panel=Ext.extend(Ext.Panel,{iframeId:void 0,isLoadMaskShown:!1,loadMask:void 0,constructor:function(a){a=a||{};this.iframeId="intranet-iframe-"+a.tabOrder;Zarafa.plugins.intranet.isDeskApp()?this.tag="webview":this.tag="iframe";Ext.applyIf(a,{xtype:"zarafa.plugins.intranet.ui.panel",layout:"fit",header:!1,html:{tag:this.tag,id:this.iframeId,cls:"intranet-iframe",src:a.url,style:"display:block",partition:"persist:kw-plugin-intranet"},listeners:{afterrender:this.onAfterRender,
scope:this}});Zarafa.plugins.intranet.ui.Panel.superclass.constructor.call(this,a)},onAfterRender:function(){this.showLoadMask();var a=document.getElementById(this.iframeId);a.addEventListener("webview"===this.tag?"contentload":"load",function(){this.hideLoadMask();if("webview"===this.tag){var b=this.url;window.chrome.cookies.getAll({url:b,storeId:a.getCookieStoreId()},function(c){for(var d of c)window.chrome.cookies.set({url:b,domain:d.domain,expirationDate:d.expirationDate,httpOnly:d.httpOnly,name:d.name,
path:d.path,sameSite:d.sameSite,secure:d.secure,value:d.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 b=window.prompt(a.messageText);null===b?a.dialog.cancel():a.dialog.ok(b)}},handlePermissionRequests:function(a){a.preventDefault();switch(a.permission){case "download":case "media":case "loadplugin":a.request.allow();break;case "pointerLock":case "fullscreen":case "geolocation":a.request.deny();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.intranet.ui.panel",Zarafa.plugins.intranet.ui.Panel);//# sourceMappingURL=intranet.js.map
