Ext.namespace("Zarafa.plugins.maps");
Zarafa.plugins.maps.MapsPlugin=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){Zarafa.plugins.maps.MapsPlugin.superclass.initPlugin.apply(this,arguments);this.registerInsertionPoint("context.contact.contactcontentpanel.tabs",this.showContactLocation,this);this.registerInsertionPoint("context.addressbook.abuserdetailcontentpanel.tabs",this.showABUserLocation,this)},showContactLocation:function(){return{xtype:"maps.contactmapstab",itemId:"contact"}},showABUserLocation:function(){return{xtype:"maps.contactmapstab",itemId:"abuser"}}});
Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"maps",displayName:_("Openstreetmap"),pluginConstructor:Zarafa.plugins.maps.MapsPlugin}))});Ext.namespace("Zarafa.plugins.maps");
Zarafa.plugins.maps.MapsTab=Ext.extend(Ext.Panel,{map:void 0,provider:null,mapID:0,constructor:function(a){a=a||{};a.plugins=Ext.value(a.plugins,[]);a.plugins.push("zarafa.recordcomponentupdaterplugin");this.mapID=(new Date).getUTCMilliseconds();Ext.apply(a,{id:"map"+this.mapID,xtype:"container",title:_("Map"),cls:"map"+this.mapID,listeners:{resize:this.resizeMap,scope:this}});Zarafa.plugins.maps.MapsTab.superclass.constructor.call(this,a)},onRender:function(...a){Zarafa.plugins.maps.MapsTab.superclass.onRender.apply(this,
arguments);this.map=this.createGmap();this.provider=new GeoSearch.OpenStreetMapProvider},createGmap:function(a){a=L.map("map"+this.mapID).setView([48.23185800542299,16.412903051527447],13);L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(a);return a},resizeMap:function(){this.map&&this.map.invalidateSize()},update:function(a,b){if(a&&a.isOpened())switch(this.itemId){case "contact":if(b||
a.isModifiedSinceLastUpdate("home_address")||a.isModifiedSinceLastUpdate("business_address")||a.isModifiedSinceLastUpdate("other_address"))b=a.get("home_address"),Ext.isEmpty(b.trim())||this.showOnMap(b,_("Home Address")),b=a.get("business_address"),Ext.isEmpty(b.trim())||this.showOnMap(b,_("Business Address")),a=a.get("other_address"),Ext.isEmpty(a.trim())||this.showOnMap(a,_("Other Address"));break;case "abuser":b&&(a=a.get("street_address")+" "+a.get("state_or_province")+" "+a.get("locality")+
" "+a.get("postal_code")+" "+a.get("country"),Ext.isEmpty(a.trim())||this.showOnMap(a,_("Address")))}},showOnMap:async function(a,b){this.map&&this.provider&&(a=await this.provider.search({query:a})||[],0<a.length&&(a=[a[0].y,a[0].x],L.marker(a,{title:b}).addTo(this.map).bindPopup(b),this.map.setView(a,6)))}});Ext.reg("maps.contactmapstab",Zarafa.plugins.maps.MapsTab);//# sourceMappingURL=maps.js.map
