WP Store Locator - Version 2.2.1

Version Description

Download this release

Release Info

Developer tijmensmit
Plugin Icon 128x128 WP Store Locator
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.2 to 2.2.1

Files changed (4) hide show
  1. js/wpsl-gmap.js +6 -11
  2. js/wpsl-gmap.min.js +1 -1
  3. readme.txt +6 -3
  4. wp-store-locator.php +2 -2
js/wpsl-gmap.js CHANGED
@@ -598,7 +598,8 @@ function handleGeolocationQuery( startLatLng, position, resetMap, infoWindow ) {
598
  * @returns {void}
599
  */
600
  function searchLocationBtn( infoWindow ) {
601
- $( "#wpsl-search-btn" ).on( "click", function() {
 
602
  var keepStartMarker = false;
603
 
604
  $( "#wpsl-search-input" ).removeClass();
@@ -630,7 +631,7 @@ function searchLocationBtn( infoWindow ) {
630
  codeAddress( infoWindow );
631
  }
632
  }
633
-
634
  return false;
635
  });
636
  }
@@ -1227,6 +1228,9 @@ function makeAjaxRequest( startLatLng, resetMap, autoLoad, infoWindow ) {
1227
 
1228
  $( "#wpsl-result-list" ).off( "click", ".wpsl-directions" );
1229
 
 
 
 
1230
  // Add the html for the store listing to the <ul>.
1231
  $storeList.append( storeData );
1232
 
@@ -2048,15 +2052,6 @@ function directionErrors( status ) {
2048
  alert( msg );
2049
  }
2050
 
2051
- // Trigger the search when the user presses "enter" on the keyboard.
2052
- $( "#wpsl-search-input" ).keydown( function ( event ) {
2053
- var keypressed = event.keyCode || event.which;
2054
-
2055
- if ( keypressed == 13 ) {
2056
- $( "#wpsl-search-btn" ).trigger( "click" );
2057
- }
2058
- });
2059
-
2060
  $( "#wpsl-stores" ).on( "click", ".wpsl-store-details", function() {
2061
  var i, len,
2062
  $parentLi = $( this ).parents( "li" ),
598
  * @returns {void}
599
  */
600
  function searchLocationBtn( infoWindow ) {
601
+
602
+ $( "#wpsl-search-btn" ).unbind( "click" ).bind( "click", function( e ) {
603
  var keepStartMarker = false;
604
 
605
  $( "#wpsl-search-input" ).removeClass();
631
  codeAddress( infoWindow );
632
  }
633
  }
634
+
635
  return false;
636
  });
637
  }
1228
 
1229
  $( "#wpsl-result-list" ).off( "click", ".wpsl-directions" );
1230
 
1231
+ // Remove the old search results.
1232
+ $storeList.empty();
1233
+
1234
  // Add the html for the store listing to the <ul>.
1235
  $storeList.append( storeData );
1236
 
2052
  alert( msg );
2053
  }
2054
 
 
 
 
 
 
 
 
 
 
2055
  $( "#wpsl-stores" ).on( "click", ".wpsl-store-details", function() {
2056
  var i, len,
2057
  $parentLi = $( this ).parents( "li" ),
js/wpsl-gmap.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(e){function t(t,l){var d,u,f,h,S,b,y,L=Number(wpslSettings.autoZoomLevel);u=n(l),f=i(),X=new google.maps.Geocoder,te=new google.maps.DirectionsRenderer,se=new google.maps.DirectionsService,d={zoom:Number(u.zoomLevel),center:u.startLatLng,mapTypeId:google.maps.MapTypeId[u.mapType.toUpperCase()],mapTypeControl:Number(u.mapTypeControl)?!0:!1,scrollwheel:Number(u.scrollWheel)?!0:!1,streetViewControl:Number(u.streetView)?!0:!1,zoomControlOptions:{position:google.maps.ControlPosition[u.controlPosition.toUpperCase()+"_TOP"]}},we=r(),ee=new google.maps.Map(document.getElementById(t),d),a(ee),p(u.mapStyle),"undefined"!=typeof window["wpslMap_"+l]&&"undefined"!=typeof window["wpslMap_"+l].locations&&(S=new google.maps.LatLngBounds,b=window["wpslMap_"+l].locations,y=b.length,e.each(b,function(e){h=new google.maps.LatLng(b[e].lat,b[e].lng),B(h,b[e].id,b[e],!1,f),S.extend(h)}),ee.fitBounds(S),google.maps.event.addListenerOnce(ee,"bounds_changed",function(e){return function(){e.getZoom()>L&&e.setZoom(L)}}(ee))),e("#wpsl-gmap").length&&(1==wpslSettings.autoComplete&&s(),!w()&&e(".wpsl-dropdown").length&&1==wpslSettings.enableStyledDropdowns?Q():(e("#wpsl-search-wrap select").show(),w()?e("#wpsl-wrap").addClass("wpsl-mobile"):e("#wpsl-wrap").addClass("wpsl-default-filters")),e(".wpsl-search").hasClass("wpsl-widget")||(1==wpslSettings.autoLocate?g(u.startLatLng,f):1==wpslSettings.autoLoad&&c(u.startLatLng,f)),1!=wpslSettings.mouseFocus||w()||e("#wpsl-search-input").focus(),m(f),v(u,ee,f),J()),o()}function s(){var t,s,o,n={};"undefined"==typeof wpslSettings.geocodeComponents||e.isEmptyObject(wpslSettings.geocodeComponents)||(n.componentRestrictions=wpslSettings.geocodeComponents),t=document.getElementById("wpsl-search-input"),s=new google.maps.places.Autocomplete(t,n),s.addListener("place_changed",function(){o=s.getPlace(),o.geometry&&(ne=o.geometry.location)})}function o(){"undefined"!=typeof wpslSettings.markerZoomTo&&1==wpslSettings.markerZoomTo&&google.maps.event.addListener(ee,"zoom_changed",function(){A()})}function n(e){var t,s,o,n=["zoomLevel","mapType","mapTypeControl","mapStyle","streetView","scrollWheel","controlPosition"],i={zoomLevel:wpslSettings.zoomLevel,mapType:wpslSettings.mapType,mapTypeControl:wpslSettings.mapTypeControl,mapStyle:wpslSettings.mapStyle,streetView:wpslSettings.streetView,scrollWheel:wpslSettings.scrollWheel,controlPosition:wpslSettings.controlPosition};if("undefined"!=typeof window["wpslMap_"+e]&&"undefined"!=typeof window["wpslMap_"+e].shortCode)for(t=0,s=n.length;s>t;t++)o=window["wpslMap_"+e].shortCode[n[t]],"undefined"!=typeof o&&(i[n[t]]=o);return i.startLatLng=l(e),i}function l(e){var t,s,o="";return"undefined"!=typeof window["wpslMap_"+e]&&"undefined"!=typeof window["wpslMap_"+e].locations&&(o=window["wpslMap_"+e].locations[0]),"undefined"!=typeof o&&"undefined"!=typeof o.lat&&"undefined"!=typeof o.lng?t=new google.maps.LatLng(o.lat,o.lng):""!==wpslSettings.startLatlng?(s=wpslSettings.startLatlng.split(","),t=new google.maps.LatLng(s[0],s[1])):t=new google.maps.LatLng(0,0),t}function i(){var e,t,s={};return"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle?(e=wpslSettings.infoBoxClearance.split(","),t=wpslSettings.infoBoxPixelOffset.split(","),s={alignBottom:!0,boxClass:wpslSettings.infoBoxClass,closeBoxMargin:wpslSettings.infoBoxCloseMargin,closeBoxURL:wpslSettings.infoBoxCloseUrl,content:"",disableAutoPan:Number(wpslSettings.infoBoxDisableAutoPan)?!0:!1,enableEventPropagation:Number(wpslSettings.infoBoxEnableEventPropagation)?!0:!1,infoBoxClearance:new google.maps.Size(Number(e[0]),Number(e[1])),pixelOffset:new google.maps.Size(Number(t[0]),Number(t[1])),zIndex:Number(wpslSettings.infoBoxZindex)},ie=new InfoBox(s)):ie=new google.maps.InfoWindow,ie}function a(t){var s=parseInt(wpslSettings.draggable.disableRes),o={draggable:Boolean(wpslSettings.draggable.enabled)};"NaN"!==s&&o.draggable&&(o.draggable=e(document).width()>s?!0:!1),t.setOptions(o)}function r(){var e,t=wpslSettings.markerIconProps,s={};"undefined"!=typeof t.url?s.url=t.url:s.url=wpslSettings.url+"img/markers/";for(var o in t)t.hasOwnProperty(o)&&(e=t[o].split(","),2==e.length&&(s[o]=e));return s}function p(e){e=d(e),e&&ee.setOptions({styles:e})}function d(e){try{var t=JSON.parse(e);if(t&&"object"==typeof t&&null!==t)return t}catch(s){}return!1}function c(e,t){B(e,0,"",!0,t),M(e,fe,he,t)}function w(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function g(t,s){if(navigator.geolocation){var o,n,l=!1,i=Number(wpslSettings.geoLocationTimout);o=setInterval(function(){e(".wpsl-icon-direction").toggleClass("wpsl-active-icon")},600),n=setTimeout(function(){u(o),c(t,s)},i),navigator.geolocation.getCurrentPosition(function(e){u(o),clearTimeout(n),F(l),f(t,e,fe,s)},function(o){if(e(".wpsl-icon-direction").hasClass("wpsl-user-activated")){switch(o.code){case o.PERMISSION_DENIED:alert(wpslGeolocationErrors.denied);break;case o.POSITION_UNAVAILABLE:alert(wpslGeolocationErrors.unavailable);break;case o.TIMEOUT:alert(wpslGeolocationErrors.timeout);break;default:alert(wpslGeolocationErrors.generalError)}e(".wpsl-icon-direction").removeClass("wpsl-active-icon")}else clearTimeout(n),c(t,s)},{maximumAge:6e4,timeout:i,enableHighAccuracy:!0})}else alert(wpslGeolocationErrors.unavailable),c(t,s)}function u(t){clearInterval(t),e(".wpsl-icon-direction").removeClass("wpsl-active-icon")}function f(e,t,s,o){if("undefined"==typeof t)c(e,o);else{var n=new google.maps.LatLng(t.coords.latitude,t.coords.longitude);oe=t,N(n),ee.setCenter(n),B(n,0,"",!0,o),M(n,s,he,o)}}function m(t){e("#wpsl-search-btn").on("click",function(){var s=!1;return e("#wpsl-search-input").removeClass(),e("#wpsl-search-input").val()?(e("#wpsl-result-list ul").empty(),e("#wpsl-stores").show(),e(".wpsl-direction-before, .wpsl-direction-after").remove(),e("#wpsl-direction-details").hide(),fe=!1,h(),F(s),b(),1==wpslSettings.autoComplete&&"undefined"!=typeof ne?x(ne,t):I(t)):e("#wpsl-search-input").addClass("wpsl-error").focus(),!1})}function h(){"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle&&"undefined"!=typeof de[0]&&de[0].close()}function v(t,s,o){google.maps.event.addListenerOnce(s,"tilesloaded",function(){e(".gm-style").append(wpslSettings.mapControls),e(".wpsl-icon-reset, #wpsl-reset-map").length>0&&(S(t.startLatLng,o),e(".wpsl-icon-reset").hide()),e(".wpsl-icon-direction").on("click",function(){e(this).addClass("wpsl-user-activated"),g(t.startLatLng,o)})})}function S(t,s){e(".wpsl-icon-reset, #wpsl-reset-map").on("click",function(){var o=!1,n=!0;e(this).hasClass("wpsl-in-progress")||(1==wpslSettings.autoLoad&&(he=1),(ee.getCenter().lat()!==ue.centerLatlng.lat()||ee.getCenter().lng()!==ue.centerLatlng.lng()||ee.getZoom()!==ue.zoomLevel)&&(F(o),e("#wpsl-search-input").val("").removeClass(),e(".wpsl-icon-reset").addClass("wpsl-in-progress"),ae&&ae.clearMarkers(),b(),y(),1==wpslSettings.autoLocate?f(t,oe,n,s):c(t,s)),e("#wpsl-stores").show(),e("#wpsl-direction-details").hide())})}function b(){"undefined"!=typeof re&&""!==re&&(re.setMap(null),re="")}function y(){var t,s,o,n,l,i,a,r,p=e("#wpsl-wrap").hasClass("wpsl-default-filters"),d=[wpslSettings.searchRadius+" "+wpslSettings.distanceUnit,wpslSettings.maxResults],c=["wpsl-radius","wpsl-results"];for(t=0,s=c.length;s>t;t++)e("#"+c[t]+" select").val(parseInt(d[t])),e("#"+c[t]+" li").removeClass(),"wpsl-radius"==c[t]?o=wpslSettings.searchRadius:"wpsl-results"==c[t]&&(o=wpslSettings.maxResults),e("#"+c[t]+" li").each(function(){e(this).text()===d[t]&&(e(this).addClass("wpsl-selected-dropdown"),e("#"+c[t]+" .wpsl-selected-item").html(d[t]).attr("data-value",o))});e("#wpsl-category").length&&(e("#wpsl-category select").val(0),e("#wpsl-category li").removeClass(),e("#wpsl-category li:first-child").addClass("wpsl-selected-dropdown"),n=e("#wpsl-category li:first-child").text(),e("#wpsl-category .wpsl-selected-item").html(n).attr("data-value",0)),e(".wpsl-custom-dropdown").length>0&&e(".wpsl-custom-dropdown").each(function(t){p?e(this).find("option").removeAttr("selected"):(l=e(this).siblings("div"),i=l.find("li:first-child"),a=i.text(),r=i.attr("data-value"),l.find("li").removeClass(),l.prev().html(a).attr("data-value",r))})}function L(t){var s,o,n,l,i;for(h(),i=t.parents("li").length>0?t.parents("li").data("store-id"):t.parents(".wpsl-info-window").data("store-id"),"undefined"!=typeof re&&""!==re&&(o=re.getPosition()),ge={centerLatlng:ee.getCenter(),zoomLevel:ee.getZoom()},s=0,l=ce.length;l>s;s++)0!=ce[s].storeId||"undefined"!=typeof o&&""!==o?ce[s].storeId==i&&(n=ce[s].getPosition()):o=ce[s].getPosition();o&&n?(e("#wpsl-direction-details ul").empty(),e(".wpsl-direction-before, .wpsl-direction-after").remove(),k(o,n)):alert(wpslLabels.generalError)}function C(e,t){var s,o,n;for(s=0,o=ce.length;o>s;s++)ce[s].storeId==e&&(n=ce[s],"start"==t?n.setAnimation(google.maps.Animation.BOUNCE):n.setAnimation(null))}function k(t,s){var o,n,l,i,a,r,p,d,c,w="",g={};d="km"==wpslSettings.distanceUnit?"METRIC":"IMPERIAL",g={origin:t,destination:s,travelMode:google.maps.DirectionsTravelMode.DRIVING,unitSystem:google.maps.UnitSystem[d]},se.route(g,function(t,s){if(s==google.maps.DirectionsStatus.OK){if(te.setMap(ee),te.setDirections(t),t.routes.length>0){for(a=t.routes[0],r=0;r<a.legs.length;r++)for(o=a.legs[r],p=0,n=o.steps.length;n>p;p++)l=o.steps[p],i=p+1,w=w+"<li><div class='wpsl-direction-index'>"+i+"</div><div class='wpsl-direction-txt'>"+l.instructions+"</div><div class='wpsl-direction-distance'>"+l.distance.text+"</div></li>";for(e("#wpsl-direction-details ul").append(w).before("<div class='wpsl-direction-before'><a class='wpsl-back' id='wpsl-direction-start' href='#'>"+wpslLabels.back+"</a><div><span class='wpsl-total-distance'>"+a.legs[0].distance.text+"</span> - <span class='wpsl-total-durations'>"+a.legs[0].duration.text+"</span></div></div>").after("<p class='wpsl-direction-after'>"+t.routes[0].copyrights+"</p>"),e("#wpsl-direction-details").show(),r=0,n=ce.length;n>r;r++)ce[r].setMap(null);ae&&ae.clearMarkers(),"undefined"!=typeof re&&""!==re&&re.setMap(null),e("#wpsl-stores").hide(),1==wpslSettings.templateId&&(c=e("#wpsl-gmap").offset(),e(window).scrollTop(c.top))}}else q(s)})}function I(t){var s,o={address:e("#wpsl-search-input").val()};"undefined"==typeof wpslSettings.geocodeComponents||e.isEmptyObject(wpslSettings.geocodeComponents)||(o.componentRestrictions=wpslSettings.geocodeComponents),X.geocode(o,function(e,o){o==google.maps.GeocoderStatus.OK?(s=e[0].geometry.location,x(s,t)):H(o)})}function x(e,t){var s=!1;B(e,0,"",!0,t),M(e,fe,s,t)}function N(t){var s;X.geocode({latLng:t},function(t,o){o==google.maps.GeocoderStatus.OK?(s=E(t),""!==s&&e("#wpsl-search-input").val(s)):H(o)})}function E(e){var t,s,o,n=e[0].address_components.length;for(o=0;n>o;o++)s=e[0].address_components[o].types,(/^postal_code$/.test(s)||/^postal_code_prefix,postal_code$/.test(s))&&(t=e[0].address_components[o].long_name);return t}function M(e,t,s,o){1==wpslSettings.directionRedirect?R(e,function(){P(e,t,s,o)}):P(e,t,s,o)}function R(e,t){X.geocode({latLng:e},function(e,s){s==google.maps.GeocoderStatus.OK?(pe=e[0].formatted_address,t()):H(s)})}function P(t,s,o,n){var l,i,a={},r="",p=!1,d=e("#wpsl-listing-template").html(),c=e("#wpsl-stores ul"),g=wpslSettings.url+"img/ajax-loader.gif";a=O(t,s,o),c.empty().append("<li class='wpsl-preloader'><img src='"+g+"'/>"+wpslLabels.preloader+"</li>"),e.get(wpslSettings.ajaxurl,a,function(s){e(".wpsl-preloader, .no-results").remove(),s.length>0?(e.each(s,function(e){_.extend(s[e],Ce),l=new google.maps.LatLng(s[e].lat,s[e].lng),B(l,s[e].id,s[e],p,n),r+=_.template(d)(s[e])}),e("#wpsl-result-list").off("click",".wpsl-directions"),c.append(r),e("#wpsl-result-list").on("click",".wpsl-directions",function(){return 1!=wpslSettings.directionRedirect?(L(e(this)),!1):void 0}),Z(),e("#wpsl-result-list p:empty").remove()):(B(t,0,"",!0,n),i=T(),c.html("<li class='no-results'>"+i+"</li>")),K(),1==wpslSettings.resetMap&&(e.isEmptyObject(ue)&&google.maps.event.addListenerOnce(ee,"tilesloaded",function(){ue={centerLatlng:ee.getCenter(),zoomLevel:ee.getZoom()},e("#wpsl-map-controls").addClass("wpsl-reset-exists"),e(".wpsl-icon-reset, #wpsl-reset-map").show()}),e(".wpsl-icon-reset").removeClass("wpsl-in-progress"))}),1!=wpslSettings.mouseFocus||w()||e("#wpsl-search-input").focus()}function O(t,s,o){var n,l,i,a,r="",p=e("#wpsl-wrap").hasClass("wpsl-mobile"),d=e("#wpsl-wrap").hasClass("wpsl-default-filters"),c={action:"store_search",lat:t.lat(),lng:t.lng()};return s?(c.max_results=wpslSettings.maxResults,c.radius=wpslSettings.searchRadius):(p||d?(n=parseInt(e("#wpsl-results .wpsl-dropdown").val()),l=parseInt(e("#wpsl-radius .wpsl-dropdown").val())):(n=parseInt(e("#wpsl-results .wpsl-selected-item").attr("data-value")),l=parseInt(e("#wpsl-radius .wpsl-selected-item").attr("data-value"))),isNaN(n)?c.max_results=wpslSettings.maxResults:c.max_results=n,isNaN(l)?c.radius=wpslSettings.searchRadius:c.radius=l,"undefined"!=typeof wpslSettings.categoryIds?c.filter=wpslSettings.categoryIds:e("#wpsl-category").length>0?(r=p||d?parseInt(e("#wpsl-category .wpsl-dropdown").val()):parseInt(e("#wpsl-category .wpsl-selected-item").attr("data-value")),isNaN(r)||0===r||(c.filter=r)):e("#wpsl-checkbox-filter").length>0&&e("#wpsl-checkbox-filter input:checked").length>0&&(c.filter=z()),e(".wpsl-custom-dropdown").length>0&&e(".wpsl-custom-dropdown").each(function(t){i="",a="",p||d?(i=e(this).attr("name"),a=e(this).val()):(i=e(this).attr("name"),a=e(this).next(".wpsl-selected-item").attr("data-value")),i&&a&&(c[i]=a)})),1==o&&("undefined"!=typeof oe?c.skip_cache=1:(c.autoload=1,"undefined"!=typeof wpslSettings.categoryIds&&(c.filter=wpslSettings.categoryIds))),c}function T(){var e;return e="undefined"!=typeof wpslSettings.noResults&&""!==wpslSettings.noResults?wpslSettings.noResults:wpslLabels.noResults}function z(){var t=e("#wpsl-checkbox-filter input:checked").map(function(){return e(this).val()});return t=t.get(),t=t.join(",")}function Z(){if(1==wpslSettings.markerClusters){var e=Number(wpslSettings.clusterZoom),t=Number(wpslSettings.clusterSize);isNaN(e)&&(e=""),isNaN(t)&&(t=""),ae=new MarkerClusterer(ee,ce,{gridSize:t,maxZoom:e})}}function B(e,t,s,o,n){var l,i,a,r=!0;0===t?(s={store:wpslLabels.startPoint},l=we.url+wpslSettings.startMarker):l=we.url+wpslSettings.storeMarker,i={url:l,scaledSize:new google.maps.Size(Number(we.scaledSize[0]),Number(we.scaledSize[1])),origin:new google.maps.Point(Number(we.origin[0]),Number(we.origin[1])),anchor:new google.maps.Point(Number(we.anchor[0]),Number(we.anchor[1]))},a=new google.maps.Marker({position:e,map:ee,optimized:!1,title:V(s.store),draggable:o,storeId:t,icon:i}),ce.push(a),google.maps.event.addListener(a,"click",function(o){return function(){0!=t?"undefined"!=typeof wpslSettings.markerStreetView&&1==wpslSettings.markerStreetView?G(e,function(){$(a,j(s),n,o)}):$(a,j(s),n,o):$(a,wpslLabels.startPoint,n,o),google.maps.event.clearListeners(n,"domready"),google.maps.event.addListener(n,"domready",function(){U(a,o),A()})}}(ee)),o&&google.maps.event.addListener(a,"dragend",function(e){F(r),ee.setCenter(e.latLng),N(e.latLng),M(e.latLng,fe,he=!1,n)})}function V(e){return e?e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(t)}):void 0}function $(e,t,s,o){de.length=0,s.setContent(t),s.open(o,e),de.push(s),"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle&&1==wpslSettings.markerClusters&&(le=e.storeId,s.setVisible(!0))}function U(t,s){e(".wpsl-info-actions a").on("click",function(o){var n=Number(wpslSettings.autoZoomLevel);if(o.stopImmediatePropagation(),e(this).hasClass("wpsl-directions")){if(1==wpslSettings.directionRedirect)return!0;L(e(this))}else e(this).hasClass("wpsl-streetview")?W(t,s):e(this).hasClass("wpsl-zoom-here")&&(s.setCenter(t.getPosition()),s.setZoom(n));return!1})}function A(){var t=ee.getZoom();t>=wpslSettings.autoZoomLevel?e(".wpsl-zoom-here").hide():e(".wpsl-zoom-here").show()}function W(t,s){var o=s.getStreetView();o.setPosition(t.getPosition()),o.setVisible(!0),e("#wpsl-map-controls").hide(),D(o,s)}function D(t,s){google.maps.event.addListener(t,"visible_changed",function(){if(!t.getVisible()){var o=s.getZoom();e("#wpsl-map-controls").show(),s.setZoom(o-1),s.setZoom(o)}})}function G(e,t){var s=new google.maps.StreetViewService;s.getPanoramaByLocation(e,50,function(e,s){me=s==google.maps.StreetViewStatus.OK?!0:!1,t()})}function j(t){var s,o;return o=e("#wpsl-base-gmap_0").length?e("#wpsl-cpt-info-window-template").html():e("#wpsl-info-window-template").html(),s=_.template(o)(t)}function K(){var e,t,s=Number(wpslSettings.autoZoomLevel),o=new google.maps.LatLngBounds;for(google.maps.event.addListenerOnce(ee,"bounds_changed",function(e){this.getZoom()>s&&this.setZoom(s)}),e=0,t=ce.length;t>e;e++)o.extend(ce[e].position);ee.fitBounds(o)}function F(e){var t,s;if(te.setMap(null),ce){for(s=0,t=ce.length;t>s;s++)e?1!=ce[s].draggable?ce[s].setMap(null):re=ce[s]:ce[s].setMap(null);ce.length=0}ae&&ae.clearMarkers()}function H(e){var t;switch(e){case"ZERO_RESULTS":t=wpslLabels.noResults;break;case"OVER_QUERY_LIMIT":t=wpslLabels.queryLimit;break;default:t=wpslLabels.generalError}alert(t)}function q(e){var t;switch(e){case"NOT_FOUND":case"ZERO_RESULTS":t=wpslLabels.noDirectionsFound;break;case"OVER_QUERY_LIMIT":t=wpslLabels.queryLimit;break;default:t=wpslLabels.generalError}alert(t)}function Q(){var t=Number(wpslSettings.maxDropdownHeight);e(".wpsl-dropdown").each(function(s){var o,n,l=e(this);l.$dropdownWrap=l.wrap("<div class='wpsl-dropdown'></div>").parent(),l.$selectedVal=l.val(),l.$dropdownElem=e("<div><ul/></div>").appendTo(l.$dropdownWrap),l.$dropdown=l.$dropdownElem.find("ul"),l.$options=l.$dropdownWrap.find("option"),l.hide().removeClass("wpsl-dropdown"),e.each(l.$options,function(){o=e(this).val()==l.$selectedVal?'class="wpsl-selected-dropdown"':"",l.$dropdown.append("<li data-value="+e(this).val()+" "+o+">"+e(this).text()+"</li>")}),l.$dropdownElem.before("<span data-value="+l.find(":selected").val()+" class='wpsl-selected-item'>"+l.find(":selected").text()+"</span>"),l.$dropdownItem=l.$dropdownElem.find("li"),l.$dropdownWrap.on("click",function(s){return e(this).hasClass("wpsl-active")?void e(this).removeClass("wpsl-active"):(Y(),e(this).toggleClass("wpsl-active"),n=0,e(this).hasClass("wpsl-active")?(l.$dropdownItem.each(function(t){n+=e(this).outerHeight()}),l.$dropdownElem.css("height",n+2+"px")):l.$dropdownElem.css("height",0),n>t&&(e(this).addClass("wpsl-scroll-required"),l.$dropdownElem.css("height",t+"px")),void s.stopPropagation())}),l.$dropdownItem.on("click",function(t){l.$dropdownWrap.find(e(".wpsl-selected-item")).html(e(this).text()).attr("data-value",e(this).attr("data-value")),l.$dropdownItem.removeClass("wpsl-selected-dropdown"),e(this).addClass("wpsl-selected-dropdown"),Y(),t.stopPropagation()})}),e(document).click(function(){Y()})}function Y(){e(".wpsl-dropdown").removeClass("wpsl-active"),e(".wpsl-dropdown div").css("height",0)}function J(){e(".wpsl-search").hasClass("wpsl-widget")&&(e("#wpsl-search-btn").trigger("click"),e(".wpsl-search").removeClass("wpsl-widget"))}var X,ee,te,se,oe,ne,le,ie,ae,re,pe,de=[],ce=[],we={},ge={},ue={},fe=!1,me=!1,he="undefined"!=typeof wpslSettings?wpslSettings.autoLoad:"";if(_.templateSettings={evaluate:/\<\%(.+?)\%\>/g,interpolate:/\<\%=(.+?)\%\>/g,escape:/\<\%-(.+?)\%\>/g},e(".wpsl-gmap-canvas").length&&(e("<img />").attr("src",wpslSettings.url+"img/ajax-loader.gif"),e(".wpsl-gmap-canvas").each(function(s){var o=e(this).attr("id");t(o,s)})),e("#wpsl-result-list").on("click",".wpsl-back",function(){var t,s;for(te.setMap(null),t=0,s=ce.length;s>t;t++)ce[t].setMap(ee);return"undefined"!=typeof re&&""!==re&&re.setMap(ee),ae&&Z(),ee.setCenter(ge.centerLatlng),ee.setZoom(ge.zoomLevel),e(".wpsl-direction-before, .wpsl-direction-after").remove(),e("#wpsl-stores").show(),e("#wpsl-direction-details").hide(),!1}),e("#wpsl-gmap").length&&("bounce"==wpslSettings.markerEffect?(e("#wpsl-stores").on("mouseenter","li",function(){C(e(this).data("store-id"),"start")}),e("#wpsl-stores").on("mouseleave","li",function(){C(e(this).data("store-id"),"stop")})):"info_window"==wpslSettings.markerEffect&&e("#wpsl-stores").on("mouseenter","li",function(){var t,s;for(t=0,s=ce.length;s>t;t++)ce[t].storeId==e(this).data("store-id")&&(google.maps.event.trigger(ce[t],"click"),ee.setCenter(ce[t].position))})),"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle&&1==wpslSettings.markerClusters){var ve,Se,be,ye,Le;google.maps.event.addListener(ee,"zoom_changed",function(){google.maps.event.addListenerOnce(ee,"idle",function(){if("undefined"!=typeof ae&&(ve=ae.clusters_,ve.length))for(ye=0,Se=ve.length;Se>ye;ye++)for(Le=0,be=ve[ye].markers_.length;be>Le;Le++)if(ve[ye].markers_[Le].storeId==le){ie.getVisible()&&null===ve[ye].markers_[Le].map?ie.setVisible(!1):ie.getVisible()||null===ve[ye].markers_[Le].map||ie.setVisible(!0);break}})})}var Ce={formatPhoneNumber:function(e){return 1==wpslSettings.phoneUrl&&w()&&(e="<a href='tel:"+Ce.formatClickablePhoneNumber(e)+"'>"+e+"</a>"),e},formatClickablePhoneNumber:function(e){return-1!=e.indexOf("+")&&-1!=e.indexOf("(0)")&&(e=e.replace("(0)","")),e.replace(/(-| |\(|\)|\.|)/g,"")},createInfoWindowActions:function(t){var s,o="",n="";return e("#wpsl-gmap").length&&(me&&(o="<a class='wpsl-streetview' href='#'>"+wpslLabels.streetView+"</a>"),1==wpslSettings.markerZoomTo&&(n="<a class='wpsl-zoom-here' href='#'>"+wpslLabels.zoomHere+"</a>"),s="<div class='wpsl-info-actions'>"+Ce.createDirectionUrl(t)+o+n+"</div>"),s},createDirectionUrl:function(t){var s,o,n,l={};return 1==wpslSettings.directionRedirect?("undefined"==typeof pe&&(pe=""),l.target="target='_blank'","undefined"!=typeof t?l.src=e("[data-store-id="+t+"] .wpsl-directions").attr("href"):(n=this.zip?this.zip+", ":"",o=this.address+", "+this.city+", "+n+this.country,l.src="https://maps.google.com/maps?saddr="+Ce.rfc3986EncodeURIComponent(pe)+"&daddr="+Ce.rfc3986EncodeURIComponent(o))):l={src:"#",target:""},s="<a class='wpsl-directions' "+l.target+" href='"+l.src+"'>"+wpslLabels.directions+"</a>"},rfc3986EncodeURIComponent:function(e){return encodeURIComponent(e).replace(/[!'()*]/g,escape)}};if(e("#wpsl-search-input").keydown(function(t){var s=t.keyCode||t.which;13==s&&e("#wpsl-search-btn").trigger("click")}),e("#wpsl-stores").on("click",".wpsl-store-details",function(){var t,s,o=e(this).parents("li"),n=o.data("store-id");if("info window"==wpslSettings.moreInfoLocation)for(t=0,s=ce.length;s>t;t++)ce[t].storeId==n&&google.maps.event.trigger(ce[t],"click");else o.find(".wpsl-more-info-listings").is(":visible")?e(this).removeClass("wpsl-active-details"):e(this).addClass("wpsl-active-details"),o.siblings().find(".wpsl-store-details").removeClass("wpsl-active-details"),o.siblings().find(".wpsl-more-info-listings").hide(),o.find(".wpsl-more-info-listings").toggle();return"default"!=wpslSettings.templateId||"store listings"==wpslSettings.moreInfoLocation?!1:void 0}),e("a[href='#"+wpslSettings.mapTabAnchor+"']").length){var ke,Ie,xe=Number(wpslSettings.mapTabAnchorReturn)?!0:!1,_e=e("a[href='#"+wpslSettings.mapTabAnchor+"']");_e.on("click",function(){return setTimeout(function(){ke=ee.getZoom(),Ie=ee.getCenter(),google.maps.event.trigger(ee,"resize"),ee.setZoom(ke),ee.setCenter(Ie),K()},50),xe})}});
1
+ jQuery(document).ready(function(e){function t(t,l){var d,u,f,h,S,b,y,L=Number(wpslSettings.autoZoomLevel);u=n(l),f=i(),X=new google.maps.Geocoder,te=new google.maps.DirectionsRenderer,se=new google.maps.DirectionsService,d={zoom:Number(u.zoomLevel),center:u.startLatLng,mapTypeId:google.maps.MapTypeId[u.mapType.toUpperCase()],mapTypeControl:Number(u.mapTypeControl)?!0:!1,scrollwheel:Number(u.scrollWheel)?!0:!1,streetViewControl:Number(u.streetView)?!0:!1,zoomControlOptions:{position:google.maps.ControlPosition[u.controlPosition.toUpperCase()+"_TOP"]}},we=r(),ee=new google.maps.Map(document.getElementById(t),d),a(ee),p(u.mapStyle),"undefined"!=typeof window["wpslMap_"+l]&&"undefined"!=typeof window["wpslMap_"+l].locations&&(S=new google.maps.LatLngBounds,b=window["wpslMap_"+l].locations,y=b.length,e.each(b,function(e){h=new google.maps.LatLng(b[e].lat,b[e].lng),B(h,b[e].id,b[e],!1,f),S.extend(h)}),ee.fitBounds(S),google.maps.event.addListenerOnce(ee,"bounds_changed",function(e){return function(){e.getZoom()>L&&e.setZoom(L)}}(ee))),e("#wpsl-gmap").length&&(1==wpslSettings.autoComplete&&s(),!w()&&e(".wpsl-dropdown").length&&1==wpslSettings.enableStyledDropdowns?Q():(e("#wpsl-search-wrap select").show(),w()?e("#wpsl-wrap").addClass("wpsl-mobile"):e("#wpsl-wrap").addClass("wpsl-default-filters")),e(".wpsl-search").hasClass("wpsl-widget")||(1==wpslSettings.autoLocate?g(u.startLatLng,f):1==wpslSettings.autoLoad&&c(u.startLatLng,f)),1!=wpslSettings.mouseFocus||w()||e("#wpsl-search-input").focus(),m(f),v(u,ee,f),J()),o()}function s(){var t,s,o,n={};"undefined"==typeof wpslSettings.geocodeComponents||e.isEmptyObject(wpslSettings.geocodeComponents)||(n.componentRestrictions=wpslSettings.geocodeComponents),t=document.getElementById("wpsl-search-input"),s=new google.maps.places.Autocomplete(t,n),s.addListener("place_changed",function(){o=s.getPlace(),o.geometry&&(ne=o.geometry.location)})}function o(){"undefined"!=typeof wpslSettings.markerZoomTo&&1==wpslSettings.markerZoomTo&&google.maps.event.addListener(ee,"zoom_changed",function(){A()})}function n(e){var t,s,o,n=["zoomLevel","mapType","mapTypeControl","mapStyle","streetView","scrollWheel","controlPosition"],i={zoomLevel:wpslSettings.zoomLevel,mapType:wpslSettings.mapType,mapTypeControl:wpslSettings.mapTypeControl,mapStyle:wpslSettings.mapStyle,streetView:wpslSettings.streetView,scrollWheel:wpslSettings.scrollWheel,controlPosition:wpslSettings.controlPosition};if("undefined"!=typeof window["wpslMap_"+e]&&"undefined"!=typeof window["wpslMap_"+e].shortCode)for(t=0,s=n.length;s>t;t++)o=window["wpslMap_"+e].shortCode[n[t]],"undefined"!=typeof o&&(i[n[t]]=o);return i.startLatLng=l(e),i}function l(e){var t,s,o="";return"undefined"!=typeof window["wpslMap_"+e]&&"undefined"!=typeof window["wpslMap_"+e].locations&&(o=window["wpslMap_"+e].locations[0]),"undefined"!=typeof o&&"undefined"!=typeof o.lat&&"undefined"!=typeof o.lng?t=new google.maps.LatLng(o.lat,o.lng):""!==wpslSettings.startLatlng?(s=wpslSettings.startLatlng.split(","),t=new google.maps.LatLng(s[0],s[1])):t=new google.maps.LatLng(0,0),t}function i(){var e,t,s={};return"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle?(e=wpslSettings.infoBoxClearance.split(","),t=wpslSettings.infoBoxPixelOffset.split(","),s={alignBottom:!0,boxClass:wpslSettings.infoBoxClass,closeBoxMargin:wpslSettings.infoBoxCloseMargin,closeBoxURL:wpslSettings.infoBoxCloseUrl,content:"",disableAutoPan:Number(wpslSettings.infoBoxDisableAutoPan)?!0:!1,enableEventPropagation:Number(wpslSettings.infoBoxEnableEventPropagation)?!0:!1,infoBoxClearance:new google.maps.Size(Number(e[0]),Number(e[1])),pixelOffset:new google.maps.Size(Number(t[0]),Number(t[1])),zIndex:Number(wpslSettings.infoBoxZindex)},ie=new InfoBox(s)):ie=new google.maps.InfoWindow,ie}function a(t){var s=parseInt(wpslSettings.draggable.disableRes),o={draggable:Boolean(wpslSettings.draggable.enabled)};"NaN"!==s&&o.draggable&&(o.draggable=e(document).width()>s?!0:!1),t.setOptions(o)}function r(){var e,t=wpslSettings.markerIconProps,s={};"undefined"!=typeof t.url?s.url=t.url:s.url=wpslSettings.url+"img/markers/";for(var o in t)t.hasOwnProperty(o)&&(e=t[o].split(","),2==e.length&&(s[o]=e));return s}function p(e){e=d(e),e&&ee.setOptions({styles:e})}function d(e){try{var t=JSON.parse(e);if(t&&"object"==typeof t&&null!==t)return t}catch(s){}return!1}function c(e,t){B(e,0,"",!0,t),M(e,fe,he,t)}function w(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function g(t,s){if(navigator.geolocation){var o,n,l=!1,i=Number(wpslSettings.geoLocationTimout);o=setInterval(function(){e(".wpsl-icon-direction").toggleClass("wpsl-active-icon")},600),n=setTimeout(function(){u(o),c(t,s)},i),navigator.geolocation.getCurrentPosition(function(e){u(o),clearTimeout(n),F(l),f(t,e,fe,s)},function(o){if(e(".wpsl-icon-direction").hasClass("wpsl-user-activated")){switch(o.code){case o.PERMISSION_DENIED:alert(wpslGeolocationErrors.denied);break;case o.POSITION_UNAVAILABLE:alert(wpslGeolocationErrors.unavailable);break;case o.TIMEOUT:alert(wpslGeolocationErrors.timeout);break;default:alert(wpslGeolocationErrors.generalError)}e(".wpsl-icon-direction").removeClass("wpsl-active-icon")}else clearTimeout(n),c(t,s)},{maximumAge:6e4,timeout:i,enableHighAccuracy:!0})}else alert(wpslGeolocationErrors.unavailable),c(t,s)}function u(t){clearInterval(t),e(".wpsl-icon-direction").removeClass("wpsl-active-icon")}function f(e,t,s,o){if("undefined"==typeof t)c(e,o);else{var n=new google.maps.LatLng(t.coords.latitude,t.coords.longitude);oe=t,N(n),ee.setCenter(n),B(n,0,"",!0,o),M(n,s,he,o)}}function m(t){e("#wpsl-search-btn").unbind("click").bind("click",function(s){var o=!1;return e("#wpsl-search-input").removeClass(),e("#wpsl-search-input").val()?(e("#wpsl-result-list ul").empty(),e("#wpsl-stores").show(),e(".wpsl-direction-before, .wpsl-direction-after").remove(),e("#wpsl-direction-details").hide(),fe=!1,h(),F(o),b(),1==wpslSettings.autoComplete&&"undefined"!=typeof ne?x(ne,t):I(t)):e("#wpsl-search-input").addClass("wpsl-error").focus(),!1})}function h(){"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle&&"undefined"!=typeof de[0]&&de[0].close()}function v(t,s,o){google.maps.event.addListenerOnce(s,"tilesloaded",function(){e(".gm-style").append(wpslSettings.mapControls),e(".wpsl-icon-reset, #wpsl-reset-map").length>0&&(S(t.startLatLng,o),e(".wpsl-icon-reset").hide()),e(".wpsl-icon-direction").on("click",function(){e(this).addClass("wpsl-user-activated"),g(t.startLatLng,o)})})}function S(t,s){e(".wpsl-icon-reset, #wpsl-reset-map").on("click",function(){var o=!1,n=!0;e(this).hasClass("wpsl-in-progress")||(1==wpslSettings.autoLoad&&(he=1),(ee.getCenter().lat()!==ue.centerLatlng.lat()||ee.getCenter().lng()!==ue.centerLatlng.lng()||ee.getZoom()!==ue.zoomLevel)&&(F(o),e("#wpsl-search-input").val("").removeClass(),e(".wpsl-icon-reset").addClass("wpsl-in-progress"),ae&&ae.clearMarkers(),b(),y(),1==wpslSettings.autoLocate?f(t,oe,n,s):c(t,s)),e("#wpsl-stores").show(),e("#wpsl-direction-details").hide())})}function b(){"undefined"!=typeof re&&""!==re&&(re.setMap(null),re="")}function y(){var t,s,o,n,l,i,a,r,p=e("#wpsl-wrap").hasClass("wpsl-default-filters"),d=[wpslSettings.searchRadius+" "+wpslSettings.distanceUnit,wpslSettings.maxResults],c=["wpsl-radius","wpsl-results"];for(t=0,s=c.length;s>t;t++)e("#"+c[t]+" select").val(parseInt(d[t])),e("#"+c[t]+" li").removeClass(),"wpsl-radius"==c[t]?o=wpslSettings.searchRadius:"wpsl-results"==c[t]&&(o=wpslSettings.maxResults),e("#"+c[t]+" li").each(function(){e(this).text()===d[t]&&(e(this).addClass("wpsl-selected-dropdown"),e("#"+c[t]+" .wpsl-selected-item").html(d[t]).attr("data-value",o))});e("#wpsl-category").length&&(e("#wpsl-category select").val(0),e("#wpsl-category li").removeClass(),e("#wpsl-category li:first-child").addClass("wpsl-selected-dropdown"),n=e("#wpsl-category li:first-child").text(),e("#wpsl-category .wpsl-selected-item").html(n).attr("data-value",0)),e(".wpsl-custom-dropdown").length>0&&e(".wpsl-custom-dropdown").each(function(t){p?e(this).find("option").removeAttr("selected"):(l=e(this).siblings("div"),i=l.find("li:first-child"),a=i.text(),r=i.attr("data-value"),l.find("li").removeClass(),l.prev().html(a).attr("data-value",r))})}function L(t){var s,o,n,l,i;for(h(),i=t.parents("li").length>0?t.parents("li").data("store-id"):t.parents(".wpsl-info-window").data("store-id"),"undefined"!=typeof re&&""!==re&&(o=re.getPosition()),ge={centerLatlng:ee.getCenter(),zoomLevel:ee.getZoom()},s=0,l=ce.length;l>s;s++)0!=ce[s].storeId||"undefined"!=typeof o&&""!==o?ce[s].storeId==i&&(n=ce[s].getPosition()):o=ce[s].getPosition();o&&n?(e("#wpsl-direction-details ul").empty(),e(".wpsl-direction-before, .wpsl-direction-after").remove(),k(o,n)):alert(wpslLabels.generalError)}function C(e,t){var s,o,n;for(s=0,o=ce.length;o>s;s++)ce[s].storeId==e&&(n=ce[s],"start"==t?n.setAnimation(google.maps.Animation.BOUNCE):n.setAnimation(null))}function k(t,s){var o,n,l,i,a,r,p,d,c,w="",g={};d="km"==wpslSettings.distanceUnit?"METRIC":"IMPERIAL",g={origin:t,destination:s,travelMode:google.maps.DirectionsTravelMode.DRIVING,unitSystem:google.maps.UnitSystem[d]},se.route(g,function(t,s){if(s==google.maps.DirectionsStatus.OK){if(te.setMap(ee),te.setDirections(t),t.routes.length>0){for(a=t.routes[0],r=0;r<a.legs.length;r++)for(o=a.legs[r],p=0,n=o.steps.length;n>p;p++)l=o.steps[p],i=p+1,w=w+"<li><div class='wpsl-direction-index'>"+i+"</div><div class='wpsl-direction-txt'>"+l.instructions+"</div><div class='wpsl-direction-distance'>"+l.distance.text+"</div></li>";for(e("#wpsl-direction-details ul").append(w).before("<div class='wpsl-direction-before'><a class='wpsl-back' id='wpsl-direction-start' href='#'>"+wpslLabels.back+"</a><div><span class='wpsl-total-distance'>"+a.legs[0].distance.text+"</span> - <span class='wpsl-total-durations'>"+a.legs[0].duration.text+"</span></div></div>").after("<p class='wpsl-direction-after'>"+t.routes[0].copyrights+"</p>"),e("#wpsl-direction-details").show(),r=0,n=ce.length;n>r;r++)ce[r].setMap(null);ae&&ae.clearMarkers(),"undefined"!=typeof re&&""!==re&&re.setMap(null),e("#wpsl-stores").hide(),1==wpslSettings.templateId&&(c=e("#wpsl-gmap").offset(),e(window).scrollTop(c.top))}}else q(s)})}function I(t){var s,o={address:e("#wpsl-search-input").val()};"undefined"==typeof wpslSettings.geocodeComponents||e.isEmptyObject(wpslSettings.geocodeComponents)||(o.componentRestrictions=wpslSettings.geocodeComponents),X.geocode(o,function(e,o){o==google.maps.GeocoderStatus.OK?(s=e[0].geometry.location,x(s,t)):H(o)})}function x(e,t){var s=!1;B(e,0,"",!0,t),M(e,fe,s,t)}function N(t){var s;X.geocode({latLng:t},function(t,o){o==google.maps.GeocoderStatus.OK?(s=E(t),""!==s&&e("#wpsl-search-input").val(s)):H(o)})}function E(e){var t,s,o,n=e[0].address_components.length;for(o=0;n>o;o++)s=e[0].address_components[o].types,(/^postal_code$/.test(s)||/^postal_code_prefix,postal_code$/.test(s))&&(t=e[0].address_components[o].long_name);return t}function M(e,t,s,o){1==wpslSettings.directionRedirect?R(e,function(){P(e,t,s,o)}):P(e,t,s,o)}function R(e,t){X.geocode({latLng:e},function(e,s){s==google.maps.GeocoderStatus.OK?(pe=e[0].formatted_address,t()):H(s)})}function P(t,s,o,n){var l,i,a={},r="",p=!1,d=e("#wpsl-listing-template").html(),c=e("#wpsl-stores ul"),g=wpslSettings.url+"img/ajax-loader.gif";a=O(t,s,o),c.empty().append("<li class='wpsl-preloader'><img src='"+g+"'/>"+wpslLabels.preloader+"</li>"),e.get(wpslSettings.ajaxurl,a,function(s){e(".wpsl-preloader, .no-results").remove(),s.length>0?(e.each(s,function(e){_.extend(s[e],Ce),l=new google.maps.LatLng(s[e].lat,s[e].lng),B(l,s[e].id,s[e],p,n),r+=_.template(d)(s[e])}),e("#wpsl-result-list").off("click",".wpsl-directions"),c.empty(),c.append(r),e("#wpsl-result-list").on("click",".wpsl-directions",function(){return 1!=wpslSettings.directionRedirect?(L(e(this)),!1):void 0}),Z(),e("#wpsl-result-list p:empty").remove()):(B(t,0,"",!0,n),i=T(),c.html("<li class='no-results'>"+i+"</li>")),K(),1==wpslSettings.resetMap&&(e.isEmptyObject(ue)&&google.maps.event.addListenerOnce(ee,"tilesloaded",function(){ue={centerLatlng:ee.getCenter(),zoomLevel:ee.getZoom()},e("#wpsl-map-controls").addClass("wpsl-reset-exists"),e(".wpsl-icon-reset, #wpsl-reset-map").show()}),e(".wpsl-icon-reset").removeClass("wpsl-in-progress"))}),1!=wpslSettings.mouseFocus||w()||e("#wpsl-search-input").focus()}function O(t,s,o){var n,l,i,a,r="",p=e("#wpsl-wrap").hasClass("wpsl-mobile"),d=e("#wpsl-wrap").hasClass("wpsl-default-filters"),c={action:"store_search",lat:t.lat(),lng:t.lng()};return s?(c.max_results=wpslSettings.maxResults,c.radius=wpslSettings.searchRadius):(p||d?(n=parseInt(e("#wpsl-results .wpsl-dropdown").val()),l=parseInt(e("#wpsl-radius .wpsl-dropdown").val())):(n=parseInt(e("#wpsl-results .wpsl-selected-item").attr("data-value")),l=parseInt(e("#wpsl-radius .wpsl-selected-item").attr("data-value"))),isNaN(n)?c.max_results=wpslSettings.maxResults:c.max_results=n,isNaN(l)?c.radius=wpslSettings.searchRadius:c.radius=l,"undefined"!=typeof wpslSettings.categoryIds?c.filter=wpslSettings.categoryIds:e("#wpsl-category").length>0?(r=p||d?parseInt(e("#wpsl-category .wpsl-dropdown").val()):parseInt(e("#wpsl-category .wpsl-selected-item").attr("data-value")),isNaN(r)||0===r||(c.filter=r)):e("#wpsl-checkbox-filter").length>0&&e("#wpsl-checkbox-filter input:checked").length>0&&(c.filter=z()),e(".wpsl-custom-dropdown").length>0&&e(".wpsl-custom-dropdown").each(function(t){i="",a="",p||d?(i=e(this).attr("name"),a=e(this).val()):(i=e(this).attr("name"),a=e(this).next(".wpsl-selected-item").attr("data-value")),i&&a&&(c[i]=a)})),1==o&&("undefined"!=typeof oe?c.skip_cache=1:(c.autoload=1,"undefined"!=typeof wpslSettings.categoryIds&&(c.filter=wpslSettings.categoryIds))),c}function T(){var e;return e="undefined"!=typeof wpslSettings.noResults&&""!==wpslSettings.noResults?wpslSettings.noResults:wpslLabels.noResults}function z(){var t=e("#wpsl-checkbox-filter input:checked").map(function(){return e(this).val()});return t=t.get(),t=t.join(",")}function Z(){if(1==wpslSettings.markerClusters){var e=Number(wpslSettings.clusterZoom),t=Number(wpslSettings.clusterSize);isNaN(e)&&(e=""),isNaN(t)&&(t=""),ae=new MarkerClusterer(ee,ce,{gridSize:t,maxZoom:e})}}function B(e,t,s,o,n){var l,i,a,r=!0;0===t?(s={store:wpslLabels.startPoint},l=we.url+wpslSettings.startMarker):l=we.url+wpslSettings.storeMarker,i={url:l,scaledSize:new google.maps.Size(Number(we.scaledSize[0]),Number(we.scaledSize[1])),origin:new google.maps.Point(Number(we.origin[0]),Number(we.origin[1])),anchor:new google.maps.Point(Number(we.anchor[0]),Number(we.anchor[1]))},a=new google.maps.Marker({position:e,map:ee,optimized:!1,title:V(s.store),draggable:o,storeId:t,icon:i}),ce.push(a),google.maps.event.addListener(a,"click",function(o){return function(){0!=t?"undefined"!=typeof wpslSettings.markerStreetView&&1==wpslSettings.markerStreetView?G(e,function(){$(a,j(s),n,o)}):$(a,j(s),n,o):$(a,wpslLabels.startPoint,n,o),google.maps.event.clearListeners(n,"domready"),google.maps.event.addListener(n,"domready",function(){U(a,o),A()})}}(ee)),o&&google.maps.event.addListener(a,"dragend",function(e){F(r),ee.setCenter(e.latLng),N(e.latLng),M(e.latLng,fe,he=!1,n)})}function V(e){return e?e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(t)}):void 0}function $(e,t,s,o){de.length=0,s.setContent(t),s.open(o,e),de.push(s),"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle&&1==wpslSettings.markerClusters&&(le=e.storeId,s.setVisible(!0))}function U(t,s){e(".wpsl-info-actions a").on("click",function(o){var n=Number(wpslSettings.autoZoomLevel);if(o.stopImmediatePropagation(),e(this).hasClass("wpsl-directions")){if(1==wpslSettings.directionRedirect)return!0;L(e(this))}else e(this).hasClass("wpsl-streetview")?W(t,s):e(this).hasClass("wpsl-zoom-here")&&(s.setCenter(t.getPosition()),s.setZoom(n));return!1})}function A(){var t=ee.getZoom();t>=wpslSettings.autoZoomLevel?e(".wpsl-zoom-here").hide():e(".wpsl-zoom-here").show()}function W(t,s){var o=s.getStreetView();o.setPosition(t.getPosition()),o.setVisible(!0),e("#wpsl-map-controls").hide(),D(o,s)}function D(t,s){google.maps.event.addListener(t,"visible_changed",function(){if(!t.getVisible()){var o=s.getZoom();e("#wpsl-map-controls").show(),s.setZoom(o-1),s.setZoom(o)}})}function G(e,t){var s=new google.maps.StreetViewService;s.getPanoramaByLocation(e,50,function(e,s){me=s==google.maps.StreetViewStatus.OK?!0:!1,t()})}function j(t){var s,o;return o=e("#wpsl-base-gmap_0").length?e("#wpsl-cpt-info-window-template").html():e("#wpsl-info-window-template").html(),s=_.template(o)(t)}function K(){var e,t,s=Number(wpslSettings.autoZoomLevel),o=new google.maps.LatLngBounds;for(google.maps.event.addListenerOnce(ee,"bounds_changed",function(e){this.getZoom()>s&&this.setZoom(s)}),e=0,t=ce.length;t>e;e++)o.extend(ce[e].position);ee.fitBounds(o)}function F(e){var t,s;if(te.setMap(null),ce){for(s=0,t=ce.length;t>s;s++)e?1!=ce[s].draggable?ce[s].setMap(null):re=ce[s]:ce[s].setMap(null);ce.length=0}ae&&ae.clearMarkers()}function H(e){var t;switch(e){case"ZERO_RESULTS":t=wpslLabels.noResults;break;case"OVER_QUERY_LIMIT":t=wpslLabels.queryLimit;break;default:t=wpslLabels.generalError}alert(t)}function q(e){var t;switch(e){case"NOT_FOUND":case"ZERO_RESULTS":t=wpslLabels.noDirectionsFound;break;case"OVER_QUERY_LIMIT":t=wpslLabels.queryLimit;break;default:t=wpslLabels.generalError}alert(t)}function Q(){var t=Number(wpslSettings.maxDropdownHeight);e(".wpsl-dropdown").each(function(s){var o,n,l=e(this);l.$dropdownWrap=l.wrap("<div class='wpsl-dropdown'></div>").parent(),l.$selectedVal=l.val(),l.$dropdownElem=e("<div><ul/></div>").appendTo(l.$dropdownWrap),l.$dropdown=l.$dropdownElem.find("ul"),l.$options=l.$dropdownWrap.find("option"),l.hide().removeClass("wpsl-dropdown"),e.each(l.$options,function(){o=e(this).val()==l.$selectedVal?'class="wpsl-selected-dropdown"':"",l.$dropdown.append("<li data-value="+e(this).val()+" "+o+">"+e(this).text()+"</li>")}),l.$dropdownElem.before("<span data-value="+l.find(":selected").val()+" class='wpsl-selected-item'>"+l.find(":selected").text()+"</span>"),l.$dropdownItem=l.$dropdownElem.find("li"),l.$dropdownWrap.on("click",function(s){return e(this).hasClass("wpsl-active")?void e(this).removeClass("wpsl-active"):(Y(),e(this).toggleClass("wpsl-active"),n=0,e(this).hasClass("wpsl-active")?(l.$dropdownItem.each(function(t){n+=e(this).outerHeight()}),l.$dropdownElem.css("height",n+2+"px")):l.$dropdownElem.css("height",0),n>t&&(e(this).addClass("wpsl-scroll-required"),l.$dropdownElem.css("height",t+"px")),void s.stopPropagation())}),l.$dropdownItem.on("click",function(t){l.$dropdownWrap.find(e(".wpsl-selected-item")).html(e(this).text()).attr("data-value",e(this).attr("data-value")),l.$dropdownItem.removeClass("wpsl-selected-dropdown"),e(this).addClass("wpsl-selected-dropdown"),Y(),t.stopPropagation()})}),e(document).click(function(){Y()})}function Y(){e(".wpsl-dropdown").removeClass("wpsl-active"),e(".wpsl-dropdown div").css("height",0)}function J(){e(".wpsl-search").hasClass("wpsl-widget")&&(e("#wpsl-search-btn").trigger("click"),e(".wpsl-search").removeClass("wpsl-widget"))}var X,ee,te,se,oe,ne,le,ie,ae,re,pe,de=[],ce=[],we={},ge={},ue={},fe=!1,me=!1,he="undefined"!=typeof wpslSettings?wpslSettings.autoLoad:"";if(_.templateSettings={evaluate:/\<\%(.+?)\%\>/g,interpolate:/\<\%=(.+?)\%\>/g,escape:/\<\%-(.+?)\%\>/g},e(".wpsl-gmap-canvas").length&&(e("<img />").attr("src",wpslSettings.url+"img/ajax-loader.gif"),e(".wpsl-gmap-canvas").each(function(s){var o=e(this).attr("id");t(o,s)})),e("#wpsl-result-list").on("click",".wpsl-back",function(){var t,s;for(te.setMap(null),t=0,s=ce.length;s>t;t++)ce[t].setMap(ee);return"undefined"!=typeof re&&""!==re&&re.setMap(ee),ae&&Z(),ee.setCenter(ge.centerLatlng),ee.setZoom(ge.zoomLevel),e(".wpsl-direction-before, .wpsl-direction-after").remove(),e("#wpsl-stores").show(),e("#wpsl-direction-details").hide(),!1}),e("#wpsl-gmap").length&&("bounce"==wpslSettings.markerEffect?(e("#wpsl-stores").on("mouseenter","li",function(){C(e(this).data("store-id"),"start")}),e("#wpsl-stores").on("mouseleave","li",function(){C(e(this).data("store-id"),"stop")})):"info_window"==wpslSettings.markerEffect&&e("#wpsl-stores").on("mouseenter","li",function(){var t,s;for(t=0,s=ce.length;s>t;t++)ce[t].storeId==e(this).data("store-id")&&(google.maps.event.trigger(ce[t],"click"),ee.setCenter(ce[t].position))})),"undefined"!=typeof wpslSettings.infoWindowStyle&&"infobox"==wpslSettings.infoWindowStyle&&1==wpslSettings.markerClusters){var ve,Se,be,ye,Le;google.maps.event.addListener(ee,"zoom_changed",function(){google.maps.event.addListenerOnce(ee,"idle",function(){if("undefined"!=typeof ae&&(ve=ae.clusters_,ve.length))for(ye=0,Se=ve.length;Se>ye;ye++)for(Le=0,be=ve[ye].markers_.length;be>Le;Le++)if(ve[ye].markers_[Le].storeId==le){ie.getVisible()&&null===ve[ye].markers_[Le].map?ie.setVisible(!1):ie.getVisible()||null===ve[ye].markers_[Le].map||ie.setVisible(!0);break}})})}var Ce={formatPhoneNumber:function(e){return 1==wpslSettings.phoneUrl&&w()&&(e="<a href='tel:"+Ce.formatClickablePhoneNumber(e)+"'>"+e+"</a>"),e},formatClickablePhoneNumber:function(e){return-1!=e.indexOf("+")&&-1!=e.indexOf("(0)")&&(e=e.replace("(0)","")),e.replace(/(-| |\(|\)|\.|)/g,"")},createInfoWindowActions:function(t){var s,o="",n="";return e("#wpsl-gmap").length&&(me&&(o="<a class='wpsl-streetview' href='#'>"+wpslLabels.streetView+"</a>"),1==wpslSettings.markerZoomTo&&(n="<a class='wpsl-zoom-here' href='#'>"+wpslLabels.zoomHere+"</a>"),s="<div class='wpsl-info-actions'>"+Ce.createDirectionUrl(t)+o+n+"</div>"),s},createDirectionUrl:function(t){var s,o,n,l={};return 1==wpslSettings.directionRedirect?("undefined"==typeof pe&&(pe=""),l.target="target='_blank'","undefined"!=typeof t?l.src=e("[data-store-id="+t+"] .wpsl-directions").attr("href"):(n=this.zip?this.zip+", ":"",o=this.address+", "+this.city+", "+n+this.country,l.src="https://maps.google.com/maps?saddr="+Ce.rfc3986EncodeURIComponent(pe)+"&daddr="+Ce.rfc3986EncodeURIComponent(o))):l={src:"#",target:""},s="<a class='wpsl-directions' "+l.target+" href='"+l.src+"'>"+wpslLabels.directions+"</a>"},rfc3986EncodeURIComponent:function(e){return encodeURIComponent(e).replace(/[!'()*]/g,escape)}};if(e("#wpsl-stores").on("click",".wpsl-store-details",function(){var t,s,o=e(this).parents("li"),n=o.data("store-id");if("info window"==wpslSettings.moreInfoLocation)for(t=0,s=ce.length;s>t;t++)ce[t].storeId==n&&google.maps.event.trigger(ce[t],"click");else o.find(".wpsl-more-info-listings").is(":visible")?e(this).removeClass("wpsl-active-details"):e(this).addClass("wpsl-active-details"),o.siblings().find(".wpsl-store-details").removeClass("wpsl-active-details"),o.siblings().find(".wpsl-more-info-listings").hide(),o.find(".wpsl-more-info-listings").toggle();return"default"!=wpslSettings.templateId||"store listings"==wpslSettings.moreInfoLocation?!1:void 0}),e("a[href='#"+wpslSettings.mapTabAnchor+"']").length){var ke,Ie,xe=Number(wpslSettings.mapTabAnchorReturn)?!0:!1,_e=e("a[href='#"+wpslSettings.mapTabAnchor+"']");_e.on("click",function(){return setTimeout(function(){ke=ee.getZoom(),Ie=ee.getCenter(),google.maps.event.trigger(ee,"resize"),ee.setZoom(ke),ee.setCenter(Ie),K()},50),xe})}});
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === WP Store Locator ===
2
  Plugin URI: https://wpstorelocator.co
3
  Contributors: tijmensmit
4
  Donate link: https://www.paypal.me/tijmensmit
5
  Tags: google maps, store locator, business locations, geocoding, stores, geo, zipcode locator, dealer locater, geocode, gmaps, google map, google map plugin, location finder, map tools, shop locator, wp google map
6
  Requires at least: 3.7
7
- Tested up to: 4.4.1
8
- Stable tag: 2.2
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
@@ -121,6 +121,9 @@ If you find a plugin or theme that causes a conflict, please report it on the [s
121
 
122
  == Changelog ==
123
 
 
 
 
124
  = 2.2, March 20, 2016 =
125
  * New: The option to show the categories with checkboxes instead of a dropdown.
126
  * Note: If you're showing the categories with checkboxes, then you can change the amount of used columns by setting the "checkbox_columns" ( between 1 and 4 ) on the [wpsl] shortcode.
1
+ === WP Store Locator ===
2
  Plugin URI: https://wpstorelocator.co
3
  Contributors: tijmensmit
4
  Donate link: https://www.paypal.me/tijmensmit
5
  Tags: google maps, store locator, business locations, geocoding, stores, geo, zipcode locator, dealer locater, geocode, gmaps, google map, google map plugin, location finder, map tools, shop locator, wp google map
6
  Requires at least: 3.7
7
+ Tested up to: 4.5
8
+ Stable tag: 2.2.1
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
121
 
122
  == Changelog ==
123
 
124
+ = 2.2.1, March 24, 2016 =
125
+ * Fixed: A JS bug that sometimes resulted in duplicate results showing up in the search results.
126
+
127
  = 2.2, March 20, 2016 =
128
  * New: The option to show the categories with checkboxes instead of a dropdown.
129
  * Note: If you're showing the categories with checkboxes, then you can change the amount of used columns by setting the "checkbox_columns" ( between 1 and 4 ) on the [wpsl] shortcode.
wp-store-locator.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Store Locator
4
  Description: An easy to use location management system that enables users to search for nearby physical stores
5
  Author: Tijmen Smit
6
  Author URI: https://wpstorelocator.co/
7
- Version: 2.2
8
  Text Domain: wpsl
9
  Domain Path: /languages/
10
  License: GPL v3
@@ -58,7 +58,7 @@ if ( !class_exists( 'WP_Store_locator' ) ) {
58
  public function define_constants() {
59
 
60
  if ( !defined( 'WPSL_VERSION_NUM' ) )
61
- define( 'WPSL_VERSION_NUM', '2.2' );
62
 
63
  if ( !defined( 'WPSL_URL' ) )
64
  define( 'WPSL_URL', plugin_dir_url( __FILE__ ) );
4
  Description: An easy to use location management system that enables users to search for nearby physical stores
5
  Author: Tijmen Smit
6
  Author URI: https://wpstorelocator.co/
7
+ Version: 2.2.1
8
  Text Domain: wpsl
9
  Domain Path: /languages/
10
  License: GPL v3
58
  public function define_constants() {
59
 
60
  if ( !defined( 'WPSL_VERSION_NUM' ) )
61
+ define( 'WPSL_VERSION_NUM', '2.2.1' );
62
 
63
  if ( !defined( 'WPSL_URL' ) )
64
  define( 'WPSL_URL', plugin_dir_url( __FILE__ ) );