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(a,b){this.registerInsertionPoint("main.maintabbar.left",this.createMainTab.createDelegate(this,[a]),this)},this);Zarafa.core.data.SharedComponentType.addProperty("plugins.intranet.panel");if(b.some(function(a){return a.autostart}))container.on("webapploaded",function(){b.filter(function(a){return a.autostart}).forEach(function(a){this.openTab(this.createMainTab(a))},
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:15}],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:15+c}),c++;return b},prepareStyle:function(a){var b="";Ext.each(a,function(a){b+="."+a.iconCls+" { background-image: url("+
a.iconPath+") !important; } \n";b+=".x-tab-strip-text."+a.iconCls+" { background-position: 0 10px !important;} \n";delete a.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}},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){var c=-1;switch(a){case Zarafa.core.data.SharedComponentType["plugins.intranet.panel"]:c=1}return c},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()}.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();nw.Shell.openExternal(a.targetUrl)},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
