You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
5.6 KiB
JavaScript
1 line
5.6 KiB
JavaScript
8 months ago
|
(()=>{"use strict";var t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=jQuery;var r=t.n(e);const o=lodash;function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function a(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(a=o.key,i=void 0,i=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(a,"string"),"symbol"===n(i)?i:String(i)),o)}var a,i}var i=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.markers={},this.categorySelector=r()("#rank-math-select-category"),this.mapWrapper=r()(".rank-math-local-map"),this.storeLocator=r()("#rank-math-local-store-locator"),this.directionsWrapper=r()(".rank-math-directions-wrapper"),this.address=r()("#rank-math-search-address"),this.currentLocation=r()("#rank-math-current-location"),this.initMap(),this.initStoreLocator(),this.categoryFilter(),this.detectLocation()}var e,n,i;return e=t,(n=[{key:"initMap",value:function(){var t=this;if(!this.mapWrapper.length)return!1;r()(".rank-math-local-map").each((function(e,n){var a=r()(n).data("map-options");if(!(0,o.isUndefined)(a)){var i="rank-math-local-map-"+e;r()(n).attr("id",i),r()(n).removeAttr("data-map-options"),t.initializeMap(i,a)}}))}},{key:"initializeMap",value:function(t,e){var r=this,n=new google.maps.LatLngBounds,a=e.locations,i=Object.keys(a).length>1,s={zoom:parseInt(e.zoom_level),zoomControl:e.allow_zoom,draggable:e.allow_dragging,mapTypeId:e.map_style};i||(s.center={lat:Number(a[Object.keys(a)[0]].lat),lng:Number(a[Object.keys(a)[0]].lng)});var l=new google.maps.Map(document.getElementById(t),s),c=new google.maps.InfoWindow;(0,o.forEach)(a,(function(t,o){var i=new google.maps.Marker({position:new google.maps.LatLng(t.lat,t.lng),map:l,type:t.terms});n.extend(i.position),a[o].content=t.content,e.show_infowindow&&google.maps.event.addListener(i,"click",function(t,e){return function(){c.setContent(a[e].content),c.setOptions({maxWidth:200}),c.open(l,t)}}(i,o)),r.markers[o]=i})),i&&l.fitBounds(n),e.show_clustering&&this.markerClusterer(l),this.getRoute(l)}},{key:"markerClusterer",value:function(t){new MarkerClusterer(t,this.markers,{imagePath:"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m"})}},{key:"categoryFilter",value:function(){var t=this;if(!this.categorySelector.length)return!1;this.categorySelector.on("change",(function(){var e=parseInt(t.categorySelector.val());(0,o.forEach)(t.markers,(function(n,a){isNaN(e)?t.markers[a].setVisible(!0):(0,o.isUndefined)(n.type)||-1===r().inArray(e,n.type)?t.markers[a].setVisible(!1):t.markers[a].setVisible(!0)}))}))}},{key:"initStoreLocator",value:function(){if(this.storeLocator.length){var t=new google.maps.Geocoder,e=1;r()("#rank-math-local-store-locator").on("submit",(function(o){var n=this;if(1===e){o.preventDefault();var a=r()(this).find("#rank-math-search-address").val();return t.geocode({address:a},(function(t,o){"OK"===o?(r()(n).find("#rank-math-lat").val(t[0].geometry.location.lat()),r()(n).find("#rank-math-lng").val(t[0].geometry.location.lng()),e++,r()(n).trigger("submit")):console.error("Geocode was not successful for the following reason: "+o)})),!1}}))}}},{key:"detectLocation",value:function(){var t=this;this.currentLocation.length&&navigator.geolocation&&this.currentLocation.on("click",(function(e){return e.preventDefault(),navigator.geolocation.getCurrentPosition((function(e){var r={lat:parseFloat(e.coord
|