var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var b=0;return $jscomp.iteratorPrototype(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})};
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.makeIterator=function(a){$jscomp.initSymbolIterator();var b=a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};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();if("webview"===this.tag){var b=this.url;chrome.cookies.getAll({url:b,storeId:a.getCookieStoreId()},function(a){a=$jscomp.makeIterator(a);for(var c=a.next();!c.done;c=a.next())c=c.value,chrome.cookies.set({url:b,domain:c.domain,expirationDate:c.expirationDate,
httpOnly:c.httpOnly,name:c.name,path:c.path,sameSite:c.sameSite,secure:c.secure,value:c.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();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
