var seToolBox = { goodies: { associativeArrayLength: function (args) { return Object.keys(args).length; } }, templating: { getTemplate: function (template) { var htmlTemplate = ''; var selector = '[data-setbtemplate=' + template + ']'; if ($(selector).length) { var $target = $(selector).clone(); $(selector).remove(); $target.removeAttr('data-setbtemplate').removeClass('ishidden'); htmlTemplate = $target[0].outerHTML; } return htmlTemplate; }, setTemplate: function (htmlSnippet, params) { var htmlTemplate = htmlSnippet; for (var param in params) { var pattern = '[' + param + ']'; htmlTemplate = htmlTemplate.replace(pattern, params[param]); } return htmlTemplate; } }, runner: { forms: { input: { defaultvalue: function () { $("[data-setbrunner*='forms.input.defaultvalue']").each(function (i, item) { var $item = $(item); var defaultValue = $item.val(); $item.focus(function (e) { if ($item.val() == defaultValue) { $item.val(''); } }).blur(function (e) { if ($item.val() == '') { $item.val(defaultValue); } }); }); } } } }, init: function (e) { var seToolBox = this; // execute registered runner functions $('[data-setbrunner]').each(function (i, item) { var runnerFx = $(item).data('setbrunner').split(','); for (var fx in runnerFx) { var fxName = $.trim(runnerFx[fx]); var particles = fxName.split('.'); var reference = seToolBox['runner']; for (var p = 0; p < particles.length; p++) { if (typeof(reference[particles[p]]) != 'undefined') { reference = reference[particles[p]]; } } if (typeof(reference) != 'undefined' && typeof(reference) == 'function') { reference(); } } }); } }; /** * literal for the panel ui changes and states * call with: panelUi.init([panel-class]) */ var panelUi = { panelWidth: 100 / 3, isMobile: false, isTablet: false, $panels: null, /** * @param {string} panelClass * @public */ init: function (panelClass) { this.$panels = $('.' + panelClass); }, /** * @public */ resetPanelsWidth: function () { this.$panels.css('width', ''); }, /** * @public */ updateResultListSize: function () { var hasAssociatedRing = $('.mrgm_associatedring').is(':visible'); $('.mrgm_standorte_listheader').toggleClass('associated', hasAssociatedRing); }, /** * @public */ resetPanels: function () { this.resetPanelsWidth(); this.$panels.removeAttr('style'); }, /** * @param {object} $element * @returns {boolean} * @private */ isEmpty: function ($element) { return !$.trim($element.html()) }, /** * @public */ closeEmptyPanels: function () { /** * @type {panelUi} * @private */ var _this = this; $.each(_this.$panels, function (index, value) { var isEmptyElement = _this.isEmpty($(value)); if (isEmptyElement) { _this.closePanel(index); } }) }, /** * @param {number} panelIndex * @param {number} width * @private */ changePanelWidth: function (panelIndex, width) { $(this.$panels[panelIndex]).css('width', width + '%'); }, /** * @param {number} changedPanelIndex * @private */ updatePanels: function (changedPanelIndex) { var visiblePanelCount = $(this.$panels).filter(":visible").length; // if tablet only manipulate 1 and 2 // or if mobile nothing to manipulate if (this.isTablet && changedPanelIndex == 2 || this.isMobile) { return; } var isChangeShow = $(this.$panels[changedPanelIndex]).is(':visible'); // modifies the visiblePanelCount on tablet // since it should only care about panel 1 and 2 if (this.isTablet && changedPanelIndex == 0 && !isChangeShow) { visiblePanelCount = 1; } switch (visiblePanelCount) { case 3: // all panels shown reset width this.resetPanelsWidth(); break; case 2: // either left or right panel closed this.changePanelWidth(1, panelUi.panelWidth * 2); break; case 1: // all except one panel closed this.changePanelWidth(1, panelUi.panelWidth * 3); break; } app.trigger('mapResize'); }, /** * @param {number} currentPanelIndex * @public */ closePanel: function (currentPanelIndex) { $(this.$panels[currentPanelIndex]).hide(); this.updatePanels(currentPanelIndex); }, /** * @param {number} currentPanelIndex * @public */ openPanel: function (currentPanelIndex) { $(this.$panels[currentPanelIndex]).show(); this.updatePanels(currentPanelIndex); } }; var mrStandorteApplication = function () { seToolBox.init(); var countrycode = $('#mrgm_standorte').data('preselect-country') || ''; if (countrycode === 'ALL') { countrycode = ''; } var alternativedatapool = $('#mrgm_standorte').data('alternativedatapool'); var isExtData = (alternativedatapool != null && alternativedatapool != ''); var seGoogleMapsAPIConfig = { config: { map: { wrapper: '#mrgm_standorte_map' } } }; var dataUserLat = $('#mrgm_standorte').data('userlat'); var dataUserLng = $('#mrgm_standorte').data('userlng'); if ($.isNumeric(dataUserLat) && $.isNumeric(dataUserLng)) { $.extend(true, seGoogleMapsAPIConfig, { config: { user: { center: { lat: dataUserLat, lng: dataUserLng } }, map: { center: { lat: dataUserLat, lng: dataUserLng } } } }); } if (isExtData) { $.extend(true, seGoogleMapsAPIConfig, { config: { cluster: { use: true, options: { gridSize: 40, minimumClusterSize: 3 } } } }); } app = $('#mrgm_standorte').se_googlemapsapi(seGoogleMapsAPIConfig); // mapmode stuff var mapMode = $('#mrgm_standorte').data('mapmode'); if (isExtData) { mapMode = 'Portal'; } if (mapMode == 'Portal' && !isExtData) { $('.mrgmsi_details_section').empty().remove(); } // application stuff app.dom('mapPanel', $('.ring-search__panel-map')); app.dom('infoPanel', $('.ring-search__panel-entry')); app.dom('resultListPanel', $('.ring-search__panel-list')); app.dom('resultList', $('#mrgm_standorte_list')); app.dom('userLocationPanel', $('#mrgm_userlocation')); app.dom('associatedRingPanel', $('#mrgm_associatedring')); app.dom('userLocationDisplay', $('.mrgm_userlocation_value')); app.dom('resultCountDisplay', $('.mrgm_standortecount_value')); app.dom('resultCountDisplayTitle', $('.mrgm_standortecount_title')); app.dom('resultCountDisplayValue', $('.mrgm_standortecount_value')); app.dom('filterPanel', $('#mrgm_filterpanel')); app.dom('filterToggle', $('#mrgm_filtertoggle')); app.dom('filterReset', $('#mrgm_resetfilter')); app.dom('autoCompletionInput', $('#mrgm_autocompletion_input')); app.dom('autoCompletionSubmit', $('#mrgm_autocompletion_input_submit')); app.dom('sortbyRelevance', $('#segm_sortby_relevance')); app.dom('sortbyRange', $('#segm_sortby_range')); app.dom('infoPanelRouteplaner', $('.mrgmsi_route_head')); // routeplaner stuff var directionsService = new google.maps.DirectionsService(); var directionsDisplay = new google.maps.DirectionsRenderer(); // hashTagHandler-Stuff var hth = $('#mrgm_standorte').se_hashtaghandler({config: {hashNamespace: 'mrStandorte'}}); hth.register('hthFilters', hthFilters); hth.register('hthLocation', hthLocation); hth.register('hthLocationLV', hthLocationLV); hth.register('hthAddress', hthAddress); hth.register('hthPanels', hthPanels); hth.register('hthSorting', hthSorting); hth.register('hthMapState', hthMapState); var hthDoHandlePanels = false; var hthDoHandleSorting = false; var $resultListItemTemplate = seToolBox.templating.getTemplate('mrgm_standort_listentry'); var $infoFilterTemplate = seToolBox.templating.getTemplate('mrgms_details_filter'); var $locationInfoTemplate = seToolBox.templating.getTemplate('mrgm_standort_infopanel'); app.on('mapInitEnd', appDataInit); app.on('mapInitEnd', initZipShapes); app.on('mapInitEnd', 'autoCompletionInit', {inputObject: app.dom('autoCompletionInput')}); app.on('mapIdle', mapIdle); app.on('drawZipShapes', drawZipShapes); app.on('markerInitEnd', initApplicationUI); app.on('mapInitEnd', updateUserLocation); app.on('resultlistExpand', resultlistExpand); app.on('resultlistCollapse', resultlistCollapse); app.on('userLocationClicked', userLocationClicked); app.on('userLocationDragBegin', userLocationDragBegin); app.on('userLocationDragEnd', userLocationDragEnd); app.on('markerClicked', markerClicked); app.on('filterClicked', filterClicked); app.on('autoCompletionSuccess', autoCompletionSuccess); app.on('autoCompletionFailure', autoCompletionFailure); app.on('geoCodeByLatLngSuccess', geoCodeByLatLngSuccess); app.on('refreshMarkerDistanceEnd', updateResultlist); app.trigger('mapInit'); // resolverFunctions function handleRouteplaner() { if ($('.mrgmsi_route_head').hasClass('active')) { if (!panelUi.isMobile) { panelUi.closePanel(0); } mapUiset(0); hideZipShapes(); directionsDoQuery(); } else { directionsDisplay.setMap(null); $('#mrgmsi_routeplaner_listing').empty(); } } function directionsDoQuery() { var directionsTravelTypes = [google.maps.TravelMode.DRIVING, google.maps.TravelMode.TRANSIT, google.maps.TravelMode.BICYCLING, google.maps.TravelMode.WALKING]; var printcheatTravelTypes = ['', 'r', 'b', 'w']; var rp_origin = $('.mrgmsi_routeplaner_start').text(); var rp_destination = $('.mrgmsi_routeplaner_end').text(); var directionsTravelType = $('.mrgmsi_routeplaner_mode').index($('.mrgmsi_routeplaner_mode.isactive')); var directionsRequest = { origin: app.objects.user.position, destination: rp_destination, travelMode: directionsTravelTypes[directionsTravelType], provideRouteAlternatives: false }; var printUri = 'https://maps.google.com/maps?f=d&source=s_d&saddr=SADDR&daddr=DADDR&ie=UTF8&z=10&pw=2&hl=de&dirflg=DIRFLAG'; $('.mrgm_routeplaner_print').hide(); directionsDisplay.setMap(null); $('#mrgmsi_routeplaner_listing').empty(); directionsService.route(directionsRequest, function (result, status) { if (status == google.maps.DirectionsStatus.OK) { $('#mrgmsi_routeplaner_listing').html('

Ihre Route

'); directionsDisplay.setOptions({ directions: result, draggable: false, hideRouteList: true, map: app.objects.map, panel: document.getElementById('mrgmsi_routeplaner_listing'), polylineOptions: { strokeColor: '#56aa1c', strokeOpacity: 0.9, strokeWeight: 5, clickable: false }, suppressBicyclingLayer: true, suppressInfoWindows: true, suppressMarkers: true, preserveViewport: true }); window.setTimeout(function () { app.objects.map.fitBounds(result.routes[0].bounds); }, 500); $('.mrgm_routeplaner_print').show().attr('href', printUri.replace('SADDR', encodeURI(directionsRequest.origin)).replace('DADDR', encodeURI(directionsRequest.destination)).replace('DIRFLAG', printcheatTravelTypes[directionsTravelType])); } else { var html = 'Es ist ein Fehler aufgetreten.
directionService.errorCode=' + status; if (status == google.maps.DirectionsStatus.ZERO_RESULTS || status == google.maps.DirectionsStatus.NOT_FOUND) { html = 'Leider konnte keine Route gefunden werden.
Bitte überprüfen Sie Ihre Angaben.'; } if (status == google.maps.DirectionsStatus.NOT_FOUND) { html = 'Ihr gewünschter Startort kann nicht gefunden werden.
Bitte überprüfen Sie Ihre Angaben.'; } $('#mrgmsi_routeplaner_listing').html('

Entschuldigung

' + html); } }); } function initApplicationUI(e) { app.dom('autoCompletionInput').on('blur', function (e) { app.dom('autoCompletionInput').val(''); }); app.dom('associatedRingPanel').click(function (e) { deferredMarkerClicked(getMarkerByID(app.dom('associatedRingPanel').data('id'))); }); app.dom('userLocationPanel').click(function (e) { app.objects.mapcenter = app.objects.userMarker.getPosition(); app.objects.map.setCenter(app.objects.mapcenter); }); app.dom('autoCompletionSubmit').click(function (e) { }); app.dom('filterToggle').click(function (e) { if (app.dom('filterPanel').hasClass('isopen')) { mapUiset(1); } else { mapUiset(4); } }); app.dom('filterReset').click(function (e) { if (mapMode == 'Intranet' || isExtData) { $(app.dom('filterPanel')).find('.mrgm_filtertitle').removeClass('isselected'); } if (mapMode == 'Portal' && !isExtData) { $(app.dom('filterPanel')).find('.mrgm_filtertitle').addClass('isselected'); } updateResultlist(); if (app.dom('infoPanel').is(':visible')) { handleActiveMarker(app.dom('infoPanel').find('.mrgm_standorte_info').data('mrlid'), false); } hth.handle('hthFilters'); }); app.dom('infoPanel').on('click', '.mrgmsi_routeplaner_mode', function (e) { $('.mrgmsi_routeplaner_mode').removeClass('isactive'); $(this).addClass('isactive'); directionsDoQuery() }); app.dom('infoPanel').on('click', '.mrgmsi_route_head', function (e) { handleRouteplaner(); }); app.dom('infoPanel').on('click', '.mrgmsi_route_info img', function (e) { app.dom('userLocationPanel').click(); return false; }); app.dom('infoPanel').on('click', '#mrgm_infoclose', function (e) { panelUi.closePanel(2); mapUiset(5); }); app.dom('infoPanel').on('click', '.showsingleringcontroller', function (e) { var mrId = $(e.target).data('mrid'); app.states.resultlistReady = $.Deferred(); app.dom('filterReset').click(); $.when(app.states.resultlistReady).done(function (e) { deferredMarkerClicked(getMarkerByID(mrId)); }); return false; }); app.dom('infoPanel').on('click', '.showlvcontroller', function (e) { var targetMarker = getMarkerByID(app.dom('infoPanel').find('.showlvcontroller').data('targetId')); if (targetMarker != null && app.dom('resultList').find("[data-mrgmlid='" + targetMarker.markerData.locationId + "']").length) { deferredMarkerClicked(targetMarker); } else { app.states.resultlistReady = $.Deferred(); app.dom('filterReset').click(); $.when(app.states.resultlistReady).done(function () { deferredMarkerClicked(targetMarker); }); } return false; }); app.dom('infoPanel').on('click', '.showallringscontroller', function (e) { var locationId = app.dom('infoPanel').find('.mrgm_standorte_info').data('mrlid'); showAllRingsForLV(locationId); hth.handle('hthLocationLV'); return false; }); app.dom('sortbyRelevance').click(function (e) { app.dom('sortbyRelevance').addClass('isactive'); app.dom('sortbyRange').removeClass('isactive'); app.trigger('refreshMarkerDistance'); hth.handle('hthSorting'); }); app.dom('sortbyRange').click(function (e) { app.dom('sortbyRelevance').removeClass('isactive'); app.dom('sortbyRange').addClass('isactive'); app.trigger('refreshMarkerDistance'); hth.handle('hthSorting'); }); $(app.dom('filterPanel')).on('click', '.mrgm_filtertitle', function (e) { app.trigger('filterClicked', {clickedObject: $(this)}); }); $(app.dom('resultList')).on('click', '.mrgm_standort_listentry', function (e) { var $this = $(this); panelUi.openPanel(2); if ($this.hasClass('isactive')) { mapUiset(5); } else { handleActiveMarker($(this).data('mrgmlid'), true); } }); app.states.mapUIReady.resolve(); } function mapIdle(e) { hth.handle('hthMapState'); } function showAllRingsForLV(locationId) { app.states.resultlistReady = $.Deferred(); app.dom('filterReset').click(); $.when(app.states.mapUISetReady).done(function (e) { mapUiset(0); }); $.when(app.states.resultlistReady).done(function (e) { var bounds = new google.maps.LatLngBounds(); var iconType = ''; app.objects.cluster.setMinimumClusterSize(1000); $(app.objects.markerList).each(function (i, item) { item.applicationData.iconBeforeLV = item.getIcon(); if (item.markerData.locationId != locationId) { if (item.markerData.additionalData.landesverband_id == locationId) { iconType = 'defaultMarkerIconRelevance_4'; bounds.extend(item.getPosition()); } else { iconType = 'defaultMarkerIconRelevance_0'; } var icon = new google.maps.MarkerImage(app.config.marker.icons[iconType].url, new google.maps.Size(app.config.marker.icons[iconType].width, app.config.marker.icons[iconType].height)); item.setIcon(icon); } else { bounds.extend(item.getPosition()); } }); app.objects.map.fitBounds(bounds); app.objects.mapcenter = bounds.getCenter(); app.objects.map.setCenter(app.objects.mapcenter); app.states.endShowLV = $.Deferred(); $.when(app.states.endShowLV).done(function (e) { app.objects.cluster.setMinimumClusterSize(app.config.cluster.options.minimumClusterSize); $(app.objects.markerList).each(function (i, item) { item.setIcon(item.applicationData.iconBeforeLV); }); hideZipShapes(); }); }); } function getMarkerByID(locationID) { var targetMarker = null; for (var m in app.objects.markerList) { var marker = app.objects.markerList[m]; if (marker.markerData.locationId == locationID) { targetMarker = marker; } } return targetMarker; } function autoCompletionSuccess(e) { var autoCompletionLocation = e.args.place.geometry.location; app.objects.mapcenter = new google.maps.LatLng(autoCompletionLocation.lat(), autoCompletionLocation.lng()); app.objects.map.setCenter(app.objects.mapcenter); app.trigger('userLocationDragEnd', {lat: autoCompletionLocation.lat(), lng: autoCompletionLocation.lng()}); } function autoCompletionFailure(e) { } function userLocationClicked(e) { app.dom('sortbyRange').click(); } function filterClicked(e) { var $this = $(e.args.clickedObject); if ($this.hasClass('isselected')) { $this.removeClass('isselected'); } else { $this.addClass('isselected'); } if (mapMode == 'Intranet' || isExtData) { app.dom('sortbyRelevance').click(); } if (mapMode == 'Portal') { updateResultlist(); } if (app.dom('infoPanel').hasClass('isopen')) { handleActiveMarker(app.dom('infoPanel').find('.mrgm_standorte_info').data('mrlid'), false); } hth.handle('hthFilters'); } function deferredMarkerClicked(targetMarker) { if (targetMarker != null && app.dom('resultList').find("[data-mrgmlid='" + targetMarker.markerData.locationId + "']").length) { app.states.zipshapesReady = $.Deferred(); markerClicked({args: {marker: targetMarker}}); $.when(app.states.zipshapesReady).done(function () { var icon = new google.maps.MarkerImage(app.config.marker.icons['activeMarkerIcon'].url, new google.maps.Size(app.config.marker.icons['activeMarkerIcon'].width, app.config.marker.icons['activeMarkerIcon'].height)); targetMarker.setIcon(icon); hth.states.locationHandled.resolve(); }); } else { hth.states.locationHandled.resolve(); } } function markerClicked(e) { handleActiveMarker(e.args.marker.markerData.locationId, true); } function initZipShapes() { app.objects.zipRegions = {}; app.objects.zipShapes = {}; } function handleZipShapes(locationItem) { var markerData = locationItem.markerData; var markerZip = markerData.addressData.zip; var locationId = markerData.locationId; if (typeof(app.objects.zipRegions[locationId]) == 'undefined') { $.ajax({ type: 'GET', url: '/index.php?eID=segooglemapsapiAjaxHandler¶ms[func]=handleZipRegions', data: { locationId: locationId, locationZip: markerZip }, success: function (results) { results = $.parseJSON(results); var regionZips = []; for (var i in results) { var result = results[i]; if (result != null) { var geometryZip = result.zipLevelThree; if (typeof(app.objects.zipShapes[geometryZip]) == 'undefined') { var geometryCityName = result.zipCityName; var geometryObject = result.geometryObject; var polyPaths = []; if (typeof(geometryObject.Polygon) != 'undefined') { polyPaths.push(getPolyPath(geometryObject.Polygon.outerBoundaryIs.LinearRing.coordinates)); } else { for (var j in geometryObject.MultiGeometry.Polygon) { if (typeof(geometryObject.MultiGeometry.Polygon[j].outerBoundaryIs) != 'undefined') { polyPaths.push(getPolyPath(geometryObject.MultiGeometry.Polygon[j].outerBoundaryIs.LinearRing.coordinates)); } } } var zipShape = new google.maps.Polygon({ paths: polyPaths, strokeColor: '#000000', strokeOpacity: 0.75, strokeWeight: 0.25, fillColor: '#000000', fillOpacity: 0.25, map: null, applicationData: { zip: geometryZip, city: geometryCityName }, zIndex: 0 }); google.maps.event.addListener(zipShape, 'mouseover', function () { app.dom('infoPanel').find('[data-mrzip]').removeClass('ishovered'); app.dom('infoPanel').find('[data-mrzip=' + this.applicationData.zip + ']').addClass('ishovered'); this.setOptions({ fillColor: '#56AA1C', strokeColor: '#56AA1C', zIndex: 1, strokeOpacity: 1.0, strokeWeight: 2 }); }); google.maps.event.addListener(zipShape, 'mouseout', function () { this.setOptions({ fillColor: '#000000', strokeColor: '#000000', zIndex: '0', strokeOpacity: 0.75, strokeWeight: 0.25 }); }); google.maps.event.addListener(zipShape, 'click', function () { var bounds = new google.maps.LatLngBounds(); var paths = this.getPath(); for (var i = 0; i < paths.length; i++) { points = new google.maps.LatLng(paths.getAt(i).lat(), paths.getAt(i).lng()); bounds.extend(points); } app.objects.map.fitBounds(bounds); }); app.objects.zipShapes[geometryZip] = zipShape; } regionZips.push(geometryZip); } } app.objects.zipRegions[locationId] = { regionZips: regionZips }; app.trigger('drawZipShapes', {locationItem: locationItem}); } }); } else { app.trigger('drawZipShapes', {locationItem: locationItem}); } function getPolyPath(coordinatesString) { var polyPath = []; var coordinatesPoints = coordinatesString.split(' '); for (var i in coordinatesPoints) { var points = coordinatesPoints[i].split(','); if (!isNaN(points[0]) && !isNaN(points[1])) { var latlng = new google.maps.LatLng(points[1], points[0]); polyPath.push(latlng); } } return polyPath; } } function drawZipShapes(e, forceHide) { var locationItem = e.args.locationItem; var locationId = locationItem.markerData.locationId; var regionZips = []; if (typeof(app.objects.zipRegions[locationId]) != 'undefined') { regionZips = app.objects.zipRegions[locationId]['regionZips']; } if (typeof(forceHide) == 'undefined') { forceHide = false; } for (var i in app.objects.zipShapes) { if (forceHide == false && $.inArray(app.objects.zipShapes[i].applicationData.zip, regionZips) > -1) { app.objects.zipShapes[i].setMap(app.objects.map); } else { app.objects.zipShapes[i].setMap(null); } } if (forceHide == false) { var currentZoom = app.objects.map.getZoom(); app.objects.mapcenter = locationItem.getPosition(); app.objects.map.setCenter(app.objects.mapcenter); if (currentZoom < 8 || currentZoom > 12) { app.objects.map.setZoom(9); } app.states.zipshapesReady.resolve(); } } function hideZipShapes() { for (var i in app.objects.zipShapes) { app.objects.zipShapes[i].setMap(null); } } function handleActiveMarker(locationId, moveResultlist) { var $resultListItem = $(app.dom('resultList')).find('[data-mrgmlid=' + locationId + ']'); app.dom('resultList').find('.isactive').removeClass('isactive'); app.states.endShowLV.resolve(); var locationItem = null; $(app.objects.markerList).each(function (i, item) { if (locationId == item.markerData.locationId) { app.objects.mapcenter = item.getPosition(); app.objects.map.setCenter(app.objects.mapcenter); if (isExtData && app.objects.map.getZoom() < 10) { app.objects.map.setZoom(10); } var icon = new google.maps.MarkerImage(app.config.marker.icons['activeMarkerIcon'].url, new google.maps.Size(app.config.marker.icons['activeMarkerIcon'].width, app.config.marker.icons['activeMarkerIcon'].height)); item.setIcon(icon); item.applicationData.iconIsActive = true; if ($resultListItem.length) { $resultListItem.addClass('isactive'); if (moveResultlist == true) { var sy = $resultListItem.offset().top - app.dom('resultList').offset().top + app.dom('resultList').scrollTop() - 167; $resultListItem.closest('.mrgmslw_overflowhelper').animate({scrollTop: sy + 'px'}, 500); } } locationItem = item; item.setZIndex(2); } else { item.setIcon(item.applicationData.iconBeforeMouseover); item.applicationData.iconIsActive = false; item.setZIndex(1); } }); if (isExtData == false) { handleZipShapes(locationItem); } var filterRenderData = []; app.dom('filterPanel').find('.mrgm_filtercategory').each(function (c, category) { var $category = $(category); var filterCategory = $.trim($category.text()); filterRenderData[filterCategory] = []; app.dom('filterPanel').find("[data-mrgm_filtercategory='" + filterCategory + "']").each(function (f, filter) { var $filter = $(filter); var filterUid = $filter.data('mrgm_filteruid'); var filterTitle = $.trim($filter.text()); if ($.inArray(filterUid, locationItem.markerData.additionalData.filterUids) > -1) { if ($filter.hasClass('isselected')) { filterRenderData[filterCategory].push('' + filterTitle + ''); } else { filterRenderData[filterCategory].push(filterTitle); } } }); }); var filterRenderHtml = ''; for (var filterCategory in filterRenderData) { if (filterRenderData[filterCategory].length > 0) { filterRenderHtml += seToolBox.templating.setTemplate($infoFilterTemplate, { filterTitle: filterCategory, filterFilters: filterRenderData[filterCategory].join(', ') }); } } var regionZips = locationItem.markerData.additionalData.regionZips; var regionZipHTML = []; for (var z in regionZips) { regionZipHTML.push('' + regionZips[z] + ''); } var associatedFacilities = []; var facilitiesLinkHtml = []; if (locationItem.markerData.additionalData.filterCategory == 'lv') { for (var m in app.objects.markerList) { var marker = app.objects.markerList[m]; if (marker.markerData.additionalData.landesverband_id == locationItem.markerData.locationId && marker.markerData.additionalData.landesverband_id != marker.markerData.locationId) { associatedFacilities.push({ mrID: marker.markerData.locationId, mrTitle: marker.markerData.facilityData.facilityTitle }); } } } $(associatedFacilities).each(function (f, facility) { facilitiesLinkHtml.push('
  • ' + facility.mrTitle + '
  • '); }); var facilitiesRenderHtml = facilitiesLinkHtml.join(' '); var $locationDetails = seToolBox.templating.setTemplate($locationInfoTemplate, { markerData_locationId: locationItem.markerData.locationId, markerData_facilityData_facilityTitle: locationItem.markerData.facilityData.facilityTitle, markerData_addressData_street: locationItem.markerData.addressData.street, markerData_addressData_zip: locationItem.markerData.addressData.zip, markerData_addressData_city: locationItem.markerData.addressData.city, markerData_contactData_phoneNumber: (locationItem.markerData.contactData.phoneNumber != null && locationItem.markerData.contactData.phoneNumber != '') ? ('Tel.: ' + locationItem.markerData.contactData.phoneNumber + '
    ') : '', markerData_contactData_faxNumber: (locationItem.markerData.contactData.faxNumber != null && locationItem.markerData.contactData.faxNumber != '') ? ('Fax: ' + locationItem.markerData.contactData.faxNumber + '
    ') : '', markerData_contactData_contactEmail: (locationItem.markerData.contactData.contactEmail != null) ? ('' + locationItem.markerData.contactData.contactEmail + '
    ') : '', markerData_contactData_website: (isExtData == false && locationItem.markerData.contactData.website != null) ? ('Zur Ringseite wechseln') : '', facilitiesRenderHtml: facilitiesRenderHtml, filterRenderHtml: filterRenderHtml, regionZips: regionZipHTML.join(', ') }); app.dom('infoPanel').empty().html($locationDetails); // prepare route planer app.dom('infoPanel').find('.mrgmsi_routeplaner_start').html($('#mrgm_userlocation').find('span').text()); app.dom('infoPanel').find('.mrgmsi_routeplaner_end').html(locationItem.markerData.addressData.zip + ' ' + locationItem.markerData.addressData.city + ', ' + locationItem.markerData.addressData.street); if (filterRenderHtml != '') { app.dom('infoPanel').find('.mrgmsi_details_section').show(); } else { app.dom('infoPanel').find('.mrgmsi_details_section').hide(); } if (regionZips.length > 1) { app.dom('infoPanel').find('.mrgmsi_zip_section').show(); } else { app.dom('infoPanel').find('.mrgmsi_zip_section').hide(); } if (associatedFacilities.length > 0) { app.dom('infoPanel').find('.mrgmsi_rings_section').show(); } else { app.dom('infoPanel').find('.mrgmsi_rings_section').hide(); } if (locationItem.markerData.additionalData.filterCategory != 'lv' && locationItem.markerData.additionalData.landesverband_id !== '') { app.dom('infoPanel').find('.mrgmsi_rings_showlv').show(); app.dom('infoPanel').find('.showlvcontroller').data('targetId', locationItem.markerData.additionalData.landesverband_id); } else { app.dom('infoPanel').find('.mrgmsi_rings_showlv').hide(); } if (mapMode == 'Intranet' || isExtData) { $('.mrgmsi_details_head').click(); } panelUi.openPanel(2); mapUiset(3); app.states.infoPanelReady.resolve(); hth.handle('hthLocation'); handleRouteplaner(); } function geoCodeByLatLngSuccess(e) { var args = e.args; var components = { street: null, number: null, zip: null, city: null, formattedAddress: args.results[0].formatted_address.replace(', Deutschland', '') }; app.objects.userMarker.setPosition(e.args.position); app.dom('userLocationDisplay').text(components.formattedAddress); app.dom('userLocationPanel').removeClass('isintransition'); app.dom('associatedRingPanel').removeClass('isintransition'); var userZip = null; $(args.results[0].address_components).each(function (c, component) { if ($.inArray('postal_code', component.types) != -1) { userZip = component.short_name.toString(); } }); var associatedRing = null; if (userZip != null) { $(app.objects.markerList).each(function (i, item) { if ($.inArray(userZip, item.markerData.additionalData.regionZips) != -1) { associatedRing = item; } }); } if (associatedRing == null) { $('#mrgm_associatedring').data('id', 0).attr('data-id', 0).hide(); $('.mrgm_standorte_list_wrapper').removeClass('hasAssociatedRing'); panelUi.updateResultListSize(); } else { $('.mrgm_standorte_list_wrapper').addClass('hasAssociatedRing'); $('#mrgm_associatedring_ringdata').text(associatedRing.markerData.facilityData.facilityTitle); $('#mrgm_associatedring').data('id', associatedRing.markerData.locationId).attr('data-id', associatedRing.markerData.locationId).show(); panelUi.updateResultListSize(); } app.dom('infoPanel').find('.mrgmsi_routeplaner_start').html(components.formattedAddress); handleRouteplaner(); hth.handle('hthAddress'); } function userLocationDragBegin(e) { app.dom('userLocationPanel').addClass('isintransition'); app.dom('associatedRingPanel').addClass('isintransition'); } function userLocationDragEnd(e) { app.objects.user.position = new google.maps.LatLng(e.args.lat, e.args.lng); app.trigger('geoCodeByLatLng', {lat: e.args.lat, lng: e.args.lng}); app.dom('autoCompletionInput').val('').blur(); app.dom('sortbyRange').click(); } function updateUserLocation() { app.trigger('geoCodeByLatLng', {lat: app.objects.user.position.lat(), lng: app.objects.user.position.lng()}); } function updateResultCount() { if (mapMode == 'Intranet') { app.dom('resultCountDisplayValue').text(app.objects.markerList.length); } if (mapMode == 'Portal') { var resultCount = app.dom('resultList').children('li').length; app.dom('resultCountDisplayValue').text(resultCount); if (resultCount == app.objects.markerList.length) { app.dom('resultCountDisplayTitle').text('Alle Standorte'); } else { app.dom('resultCountDisplayTitle').text('Filter-Ergebnis'); } } } function updateResultlist() { var $html = ''; var filters = []; $(app.dom('filterPanel')).find('.isselected').each(function (f, filter) { filters.push($(filter).data('mrgm_filteruid')); }); var filterOptionsCount = $(app.dom('filterPanel')).find('.mrgm_filtertitle').length; var filterCount = filters.length; app.states.endShowLV.resolve(); if (mapMode == 'Portal' && !isExtData) { $(app.objects.markerList).each(function (i, item) { item.applicationData.filterMatchIndex = null; item.applicationData.filterMatchPercent = 0; item.applicationData.sortIndex = parseFloat(item.applicationData.distanceToUser) * 0.0001; if (filterCount > 0 && $.inArray(item.markerData.additionalData.filterCategory, filters) > -1) { item.applicationData.filterMatchIndex = 4; item.applicationData.filterMatchPercent = 100; } if (item.applicationData.filterMatchPercent == 0) { item.setVisible(false); drawZipShapes({args: {locationItem: item}}, true); } else { item.setVisible(true); } }); app.objects.cluster.setIgnoreHidden(true); app.objects.cluster.repaint(); if (filterCount != filterOptionsCount) { app.dom('filterReset').fadeIn(); } else { app.dom('filterReset').fadeOut(); } } app.objects.markerList.sort(function (a, b) { return a['applicationData']['sortIndex'] - b['applicationData']['sortIndex']; }); $(app.objects.markerList).each(function (i, item) { if (isExtData || mapMode == 'Intranet' || (mapMode == 'Portal' && item.applicationData.filterMatchIndex > 0)) { var params = { markerData_facilityData_facilityTitle: item.markerData.facilityData.facilityTitle, markerData_addressData_street: item.markerData.addressData.street, markerData_addressData_zip: item.markerData.addressData.zip, markerData_addressData_city: item.markerData.addressData.city, applicationData_filterMatchIndex: (mapMode == 'Intranet' || isExtData) ? item.applicationData.filterMatchIndex : 0, applicationData_filterMatchPercent: (item.applicationData.filterMatchPercent == null) ? '' : (item.applicationData.filterMatchPercent + '%') + '/' + item.applicationData.filterHitPercent + '%', applicationData_distanceToUser: item.applicationData.distanceToUser, applicationData_sortIndex: item.applicationData.sortIndex, applicationData_debugMatchCount: item.applicationData.debugMatchCount, applicationData_debugMatchPercent: item.applicationData.debugMatchPercent, markerData_geoData_lat: item.markerData.geoData.lat, markerData_geoData_lng: item.markerData.geoData.lng, markerData_locationId: item.markerData.locationId }; $html += seToolBox.templating.setTemplate($resultListItemTemplate, params); } var iconType = 'defaultMarkerIconRelevance_null'; if (item.applicationData.filterMatchIndex != null) { iconType = 'defaultMarkerIconRelevance_' + item.applicationData.filterMatchIndex; } var icon = new google.maps.MarkerImage(app.config.marker.icons[iconType].url, new google.maps.Size(app.config.marker.icons[iconType].width, app.config.marker.icons[iconType].height)); item.setIcon(icon); item.applicationData.iconBeforeMouseover = icon; }); app.dom('resultList').empty().append($html).closest('.mrgmslw_overflowhelper').animate({scrollTop: '0px'}, 500); updateResultCount(); app.states.resultlistReady.resolve(); } function resultlistExpand(e) { var currentState = app.get('mruistate'); if ($('.segm_expand').hasClass('disabled')) { return; } panelUi.openPanel(0); mapUiset(Math.min(2, currentState + 1)); } function resultlistCollapse(e) { var currentState = app.get('mruistate'); var preventCollapse = (app.dom('filterPanel').hasClass('isopen')) ? 0 : 1; if ($('.segm_collapse').hasClass('disabled')) { return; } panelUi.closePanel(0); mapUiset(Math.max(0, ((currentState < 3) ? (currentState - preventCollapse) : 0))); } function mapUiset(state) { if (app.get('mruitransition') == false) { var mapuiOldState = app.get('mruistate'); app.set('mruitransition', true); app.set('mruistate', state); app.states.mapUISetReady = $.Deferred(); if (state === 0) { app.dom('filterPanel').removeClass('isopen'); app.dom('filterToggle').removeClass('isopen'); app.dom('segm_collapse').addClass('disabled'); app.dom('segm_expand').removeClass('disabled'); $('#segm_zoomin, #segm_zoomout, #segm_zoomall, .mrgmso_sortby_filter, .mrgmso_sortby_range').show(); app.set('mruipanelresults', 0); } if (state === 1) { app.dom('filterPanel').removeClass('isopen'); app.dom('filterToggle').removeClass('isopen'); app.dom('segm_collapse').removeClass('disabled'); app.dom('segm_expand').addClass('disabled'); $('#segm_zoomin, #segm_zoomout, #segm_zoomall, .mrgmso_sortby_filter, .mrgmso_sortby_range').show(); app.set('mruipanelresults', 1); } if (state === 2) { app.dom('filterPanel').removeClass('isopen'); app.dom('filterToggle').removeClass('isopen'); app.dom('segm_collapse').removeClass('disabled'); app.dom('segm_expand').addClass('disabled'); $('#segm_zoomin, #segm_zoomout, #segm_zoomall, .mrgmso_sortby_filter, .mrgmso_sortby_range').hide(); app.set('mruipanelresults', 2); app.set('mruipaneldetails', 0); } if (state === 3) { app.dom('filterPanel').removeClass('isopen'); app.dom('filterToggle').removeClass('isopen'); $('#segm_zoomin, #segm_zoomout, #segm_zoomall, .mrgmso_sortby_filter, .mrgmso_sortby_range').show(); if (mapuiOldState === 0) { app.set('mruistate', 0); } else { app.set('mruistate', 1); } app.set('mruipanelresults', 1); app.set('mruipaneldetails', 1); } if (state === 4) { app.dom('filterPanel').addClass('isopen'); app.dom('filterToggle').addClass('isopen'); $('#segm_zoomin, #segm_zoomout, #segm_zoomall, .mrgmso_sortby_filter, .mrgmso_sortby_range').show(); if ($('.mrgmsi_route_head').hasClass('active')) { $('.mrgmsi_route_head').click(); } app.set('mruistate', 1); app.set('mruipanelresults', 1); app.set('mruipaneldetails', 0); } if (state === 5) { hideZipShapes(); if ($('.mrgmsi_route_head').hasClass('active')) { $('.mrgmsi_route_head').click(); } app.set('mruipaneldetails', 0); } app.set('mruitransition', false); app.states.mapUISetReady.resolve(); hth.handle('hthPanels'); } } function appDataInit(e) { app.trigger('dataInit', { method: 'ajax', url: '/index.php?eID=segooglemapsapiAjaxHandler¶ms[func]=getLocationDataComplete¶ms[alternativedatapool]=' + alternativedatapool + '¶ms[country]=' + countrycode }); $.when(app.states.mapInitReady, app.states.mapIdleReady, app.states.markerInitReady, app.states.mapUIReady).done(function (e) { hth.manageHash(hthManageBookmark); }); } function hthFilters() { var currentFilterSettings = []; app.dom('filterPanel').find('.isselected').each(function (i, item) { currentFilterSettings.push($(item).data('mrgm_filteruid')); }); hth.functions.set('filter', currentFilterSettings); } function hthLocation() { hth.functions.set('location', app.dom('infoPanel').find('.mrgm_standorte_info').data('mrlid')); hth.functions.set('locationLV', null); } function hthLocationLV() { hth.functions.set('location', null); hth.functions.set('locationLV', app.dom('infoPanel').find('.mrgm_standorte_info').data('mrlid')); } function hthAddress() { hth.functions.set('position', {lat: app.objects.user.position.lat(), lng: app.objects.user.position.lng()}); } function hthPanels() { if (hthDoHandlePanels === true) { hth.functions.set('panels', {results: app.get('mruipanelresults'), details: app.get('mruipaneldetails')}); } } function hthMapState() { var mapCenter = app.objects.map.getCenter(); if (typeof(mapCenter) != 'undefined') { hth.functions.set('map', { lat: mapCenter.lat(), lng: mapCenter.lng(), zoom: app.objects.map.getZoom() }); } } function hthSorting() { if (hthDoHandleSorting === true) { if (app.dom('sortbyRelevance').hasClass('isactive')) { hth.functions.set('sorting', 'sortbyRelevance'); } if (app.dom('sortbyRange').hasClass('isactive')) { hth.functions.set('sorting', 'sortbyRange'); } } } function hthManageBookmark(hash) { if (typeof(hash.filter) != 'undefined') { if (mapMode == 'Portal') { app.dom('filterPanel').find('li').removeClass('isselected'); } for (var f in hash.filter) { var filter = hash.filter[f]; app.dom('filterPanel').find("[data-mrgm_filteruid='" + filter + "']").addClass('isselected'); } if (typeof(hash.sorting) == 'undefined') { updateResultlist(); } } if (typeof(hash.position) != 'undefined') { userLocationDragEnd({args: {lat: hash.position.lat, lng: hash.position.lng}}); app.objects.mapcenter = new google.maps.LatLng(hash.position.lat, hash.position.lng); app.objects.map.setCenter(app.objects.mapcenter); } if (typeof(hash.map) != 'undefined') { app.objects.mapcenter = new google.maps.LatLng(hash.map.lat, hash.map.lng); app.objects.map.setCenter(app.objects.mapcenter); app.objects.map.setZoom(hash.map.zoom); } if (typeof(hash.sorting) != 'undefined' && !$.isEmptyObject(hash)) { app.dom(hash.sorting).click(); } else { app.dom('sortbyRange').click(); } if (typeof(hash.location) != 'undefined') { deferredMarkerClicked(getMarkerByID(hash.location)); } if (typeof(hash.locationLV) != 'undefined') { app.states.infoPanelReady = $.Deferred(); deferredMarkerClicked(getMarkerByID(hash.locationLV)); $.when(app.states.infoPanelReady).done(function (e) { app.dom('infoPanel').find('.showallringscontroller').click(); }); } if (typeof(hash.panels) != 'undefined') { app.states.mapUISetReady = $.Deferred(); $.when(app.states.mapUISetReady).done(function (e) { if (typeof(hash.panels.results) != 'undefined') { $.when(hth.states.locationHandled).done(function (e) { mapUiset(hash.panels.results); }); } }); } hthDoHandlePanels = true; hthDoHandleSorting = true; } panelUi.closePanel(2); }; /** * @param {object} mqd */ function updateBreakpointSettings(mqd) { panelUi.isMobile = mqd.breakpointName === 'xs'; panelUi.isTablet = mqd.breakpointName === 'sm'; panelUi.resetPanels(); panelUi.updateResultListSize(); panelUi.closeEmptyPanels(); } $(window).load(function (e) { var app; panelUi.init('js-panel'); $('body') .on('mediaQueryBreakDetector.breakpointChange', $.proxy(updateBreakpointSettings, this)) .mediaQueryBreakDetector(); var mqd = $('body').mediaQueryBreakDetector('getBreakpointData'); updateBreakpointSettings(mqd); mrStandorteApplication(); });