From 8132e0fb9ecdef621aa80b4938ea05de13be5667 Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Tue, 24 Mar 2015 13:11:26 -0500 Subject: [PATCH 1/9] Added exclusiveFiltering and callbackFilters, fixed fullMapStart and inlineDirections combo bug, fixed olat/olng not being set in autoGeocodeQuery method --- .../storeLocator/jquery.storelocator.js | 36 +++++++++++++++---- .../storeLocator/jquery.storelocator.min.js | 4 +-- license.txt | 2 +- options.md | 2 ++ package.json | 2 +- readme.md | 19 ++++++---- src/js/jquery.storelocator.js | 34 +++++++++++++++--- storelocator.jquery.json | 2 +- 8 files changed, 79 insertions(+), 22 deletions(-) diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js index 1db4cc8..a1b69e3 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js @@ -1,4 +1,4 @@ -/*! jQuery Google Maps Store Locator - v2.0.5 - 2015-01-04 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-24 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ @@ -75,6 +75,7 @@ 'infowindowTemplateID' : null, 'taxonomyFilters' : null, 'taxonomyFiltersContainer' : 'bh-sl-filters-container', + 'exclusiveFiltering' : false, 'querystringParams' : false, 'callbackNotify' : null, 'callbackBeforeSend' : null, @@ -89,6 +90,7 @@ 'callbackNoResults' : null, 'callbackListClick' : null, 'callbackMarkerClick' : null, + 'callbackFilters' : null, // Language options 'addressErrorAlert' : 'Unable to find address', 'autoGeocodeErrorAlert' : 'Automatic location detection failed. Please fill in your address or zip code.', @@ -626,8 +628,25 @@ for (var k in filters) { if (filters.hasOwnProperty(k)) { - if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) { - filterTest = false; + + // Exclusive filtering + if(this.settings.exclusiveFiltering === true) { + var filterTests = filters[k]; + var exclusiveTest = []; + + for(var l = 0; l < filterTests.length; l++) { + exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k]); + } + + if(exclusiveTest.indexOf(true) === -1) { + filterTest = false; + } + } + // Inclusive filtering + else { + if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) { + filterTest = false; + } } } } @@ -951,8 +970,8 @@ r.geocode({'latLng': latlng}, function (data) { if (data !== null) { var originAddress = data.address; - mappingObj.lat = position.coords.latitude; - mappingObj.lng = position.coords.longitude; + olat = mappingObj.lat = position.coords.latitude; + olng = mappingObj.lng = position.coords.longitude; mappingObj.origin = originAddress; _this.mapping(mappingObj); } else { @@ -1762,7 +1781,7 @@ }); // Inline directions - if(_this.settings.inlineDirections === true){ + if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') { // Open directions $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { e.preventDefault(); @@ -1859,6 +1878,11 @@ if (_this.settings.modal === true && _this.settings.callbackModalReady) { _this.settings.callbackModalReady.call(this); } + + // Filters callback + if (_this.settings.callbackFilters) { + _this.settings.callbackFilters.call(this, filters); + } }); } diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js index 9498ce2..ea7afcb 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js @@ -1,5 +1,5 @@ -/*! jQuery Google Maps Store Locator - v2.0.5 - 2015-01-04 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-24 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ -!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
'),a("."+this.settings.modalWindow).prepend('
'),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this,f=a.Deferred();return this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),this.settings.loading===!0&&a("."+this.settings.formContainer).append('
'),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)b.hasOwnProperty(d)&&(new RegExp(b[d].join(""),"i").test(a[d])||(c=!1));return c?!0:void 0},_paginationOutput:function(a,b){a=parseFloat(a);var c="",d=a+1,e=a-1;a>0&&(c+='
  • '+this.settings.prevPage+"
  • ");for(var f=0;f'+g+"":'
  • '+g+"
  • "}return b>d&&(c+='
  • '+this.settings.nextPage+"
  • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;c.lat=a.coords.latitude,c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
    ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(d){var e,h,i,j,m,p,t,u,A,B,C,D,E,F=this,G=0;if(this.isEmptyObject(d)||(e=d.lat,h=d.lng,i=d.origin,j=d.name,m=d.distance,p=d.page),google.maps.visualRefresh=!0,"undefined"==typeof p&&(p=0),"undefined"==typeof i&&this.settings.nameSearch===!0)n=F._getData();else{var H=new google.maps.LatLng(e,h);"undefined"!=typeof k&&i===k&&"undefined"!=typeof l?(i=k,n=l):n=F._getData(q,r,i)}null!==F.settings.taxonomyFilters&&F.hasEmptyObjectVals(z)&&F.checkFilters(),n.done(function(d){var j=a("#"+F.settings.mapID),q="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=i,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&j.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),j.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var r=0;G0)for(var N=0;N
    '+F.settings.noResultsTitle+'

    '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof i&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&m){if("undefined"==typeof w[0]||w[0].distance>m)return void F.notify(F.settings.distanceErrorAlert+m+" "+q)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+q);if(F.settings.pagination===!0&&F.paginationSetup(p),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var O=new google.maps.LatLng(w[0].lat,w[0].lng);0===p?(F.settings.mapSettings.center=H,D=F.settings.mapSettings):(F.settings.mapSettings.center=O,D=F.settings.mapSettings)}else F.settings.mapSettings.center=H,D=F.settings.mapSettings;var P=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=P.getCenter();google.maps.event.trigger(P,"resize"),P.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),P);var Q=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var R="";if(F.settings.fullMapStart===!1&&t===!0)return;R=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:H,map:P,icon:R,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(i,c,P)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var S=0;C-1>=S;S++){var T="";T=String.fromCharCode(p>0?"A".charCodeAt(0)+(B+S):"A".charCodeAt(0)+S);var U=new google.maps.LatLng(w[S].lat,w[S].lng);u=F.createMarker(U,w[S].name,w[S].address,T,P,w[S].category),u.set("id",S),y[S]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&A.extend(U),F.createInfowindow(u,null,Q,B,p)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&P.fitBounds(A);var V=a("."+F.settings.locationList+" ul");V.empty(),0===w[0].lat&&0===w[0].lng?V.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),P.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,Q,B,p)},700)):F.createInfowindow(c,d,Q,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this)})}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
    ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
    '),a("."+this.settings.modalWindow).prepend('
    '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
    Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
    ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this,f=a.Deferred();return this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),this.settings.loading===!0&&a("."+this.settings.formContainer).append('
    '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
  • '+this.settings.prevPage+"
  • ");for(var f=0;f'+g+"":'
  • '+g+"
  • "}return b>d&&(c+='
  • '+this.settings.nextPage+"
  • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
    ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(d){var e,h,i,j,m,p,t,u,A,B,C,D,E,F=this,G=0;if(this.isEmptyObject(d)||(e=d.lat,h=d.lng,i=d.origin,j=d.name,m=d.distance,p=d.page),google.maps.visualRefresh=!0,"undefined"==typeof p&&(p=0),"undefined"==typeof i&&this.settings.nameSearch===!0)n=F._getData();else{var H=new google.maps.LatLng(e,h);"undefined"!=typeof k&&i===k&&"undefined"!=typeof l?(i=k,n=l):n=F._getData(q,r,i)}null!==F.settings.taxonomyFilters&&F.hasEmptyObjectVals(z)&&F.checkFilters(),n.done(function(d){var j=a("#"+F.settings.mapID),q="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=i,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&j.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),j.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var r=0;G0)for(var N=0;N
    '+F.settings.noResultsTitle+'

    '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof i&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&m){if("undefined"==typeof w[0]||w[0].distance>m)return void F.notify(F.settings.distanceErrorAlert+m+" "+q)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+q);if(F.settings.pagination===!0&&F.paginationSetup(p),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var O=new google.maps.LatLng(w[0].lat,w[0].lng);0===p?(F.settings.mapSettings.center=H,D=F.settings.mapSettings):(F.settings.mapSettings.center=O,D=F.settings.mapSettings)}else F.settings.mapSettings.center=H,D=F.settings.mapSettings;var P=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=P.getCenter();google.maps.event.trigger(P,"resize"),P.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),P);var Q=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var R="";if(F.settings.fullMapStart===!1&&t===!0)return;R=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:H,map:P,icon:R,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof i&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(i,c,P)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var S=0;C-1>=S;S++){var T="";T=String.fromCharCode(p>0?"A".charCodeAt(0)+(B+S):"A".charCodeAt(0)+S);var U=new google.maps.LatLng(w[S].lat,w[S].lng);u=F.createMarker(U,w[S].name,w[S].address,T,P,w[S].category),u.set("id",S),y[S]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&A.extend(U),F.createInfowindow(u,null,Q,B,p)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&P.fitBounds(A);var V=a("."+F.settings.locationList+" ul");V.empty(),0===w[0].lat&&0===w[0].lng?V.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),P.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,Q,B,p)},700)):F.createInfowindow(c,d,Q,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)})}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file diff --git a/license.txt b/license.txt index 31d5833..eab8450 100644 --- a/license.txt +++ b/license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2014 Bjorn Holine +Copyright (c) 2015 Bjorn Holine Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/options.md b/options.md index c675ddb..aaa4673 100644 --- a/options.md +++ b/options.md @@ -53,6 +53,7 @@ | infowindowTemplateID | null | ID of infowindow template if using inline Handlebar templates instead of separate files. | | taxonomyFilters | null | Filtering object that can be used to set up live filtering (see categories example). | | taxonomyFiltersContainer | 'bh-sl-filters-container' | Class of the container around the filters. | +| exclusiveFiltering | false | Set to true to enable exclusive taxonomy filtering rather than the default inclusive. | | querystringParams | false | Set to true to enable query string support for passing input variables from page to page. | | callbackNotify | null | Callback that can override the notify method. | | callbackBeforeSend | null | Callback that fires before the AJAX request. | @@ -67,6 +68,7 @@ | callbackNoResults | null | Callback that fires when no results are found. | | callbackListClick | null | Callback that fires when a list element is clicked in the location list. | | callbackMarkerClick | null | Callback that fires when a map marker is clicked. | +| callbackFilters | null | Callback that fires when a filter is changed. | | addressErrorAlert | 'Unable to find address' | Language setting | | autoGeocodeErrorAlert | 'Automatic location detection failed. Please fill in your address or zip code.' | Language setting | | distanceErrorAlert | 'Unfortunately, our closest location is more than ' | Language setting | diff --git a/package.json b/package.json index 748cbbf..3532843 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-storelocator-plugin", - "version": "2.0.5", + "version": "2.0.6", "description": "This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.", "repository": { "type": "git", diff --git a/readme.md b/readme.md index aeb269e..221fa9d 100644 --- a/readme.md +++ b/readme.md @@ -27,15 +27,22 @@ for even faster loading. ## Changelog +### Version 2.0.6 + +* Added the option to filter data exclusively rather than inclusively with the exclusiveFiltering setting. +* Added callbackFilters that fires when a filter is changed and can return the filter values. +* Fixed issue with fullMapStart and inlineDirections setting combination. +* Fixed issue with global olat and olng variables not being set with autoGeocode setting enabled. + ### Version 2.0.5 -- Fixed typo with originMarker setup. -- Made the originMarkerDim setting optional when setting a custom origin marker image - defaults to 32px by 32px. -- Removed geocodeErrorAlert language option and switched error alerts to custom exceptions so users aren't shown +* Fixed typo with originMarker setup. +* Made the originMarkerDim setting optional when setting a custom origin marker image - defaults to 32px by 32px. +* Removed geocodeErrorAlert language option and switched error alerts to custom exceptions so users aren't shown multiple alerts. -- Fixed bug with inline directions where close icon wasn't being removed on page reload. -- Added callbackListClick that fires when a list element is clicked. -- Added callbackMarkerClick that fires when a map marker is clicked. +* Fixed bug with inline directions where close icon wasn't being removed on page reload. +* Added callbackListClick that fires when a list element is clicked. +* Added callbackMarkerClick that fires when a map marker is clicked. ### Version 2.0.4 diff --git a/src/js/jquery.storelocator.js b/src/js/jquery.storelocator.js index 25ea096..12e08d6 100644 --- a/src/js/jquery.storelocator.js +++ b/src/js/jquery.storelocator.js @@ -73,6 +73,7 @@ 'infowindowTemplateID' : null, 'taxonomyFilters' : null, 'taxonomyFiltersContainer' : 'bh-sl-filters-container', + 'exclusiveFiltering' : false, 'querystringParams' : false, 'callbackNotify' : null, 'callbackBeforeSend' : null, @@ -87,6 +88,7 @@ 'callbackNoResults' : null, 'callbackListClick' : null, 'callbackMarkerClick' : null, + 'callbackFilters' : null, // Language options 'addressErrorAlert' : 'Unable to find address', 'autoGeocodeErrorAlert' : 'Automatic location detection failed. Please fill in your address or zip code.', @@ -624,8 +626,25 @@ for (var k in filters) { if (filters.hasOwnProperty(k)) { - if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) { - filterTest = false; + + // Exclusive filtering + if(this.settings.exclusiveFiltering === true) { + var filterTests = filters[k]; + var exclusiveTest = []; + + for(var l = 0; l < filterTests.length; l++) { + exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k]); + } + + if(exclusiveTest.indexOf(true) === -1) { + filterTest = false; + } + } + // Inclusive filtering + else { + if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) { + filterTest = false; + } } } } @@ -949,8 +968,8 @@ r.geocode({'latLng': latlng}, function (data) { if (data !== null) { var originAddress = data.address; - mappingObj.lat = position.coords.latitude; - mappingObj.lng = position.coords.longitude; + olat = mappingObj.lat = position.coords.latitude; + olng = mappingObj.lng = position.coords.longitude; mappingObj.origin = originAddress; _this.mapping(mappingObj); } else { @@ -1760,7 +1779,7 @@ }); // Inline directions - if(_this.settings.inlineDirections === true){ + if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') { // Open directions $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { e.preventDefault(); @@ -1857,6 +1876,11 @@ if (_this.settings.modal === true && _this.settings.callbackModalReady) { _this.settings.callbackModalReady.call(this); } + + // Filters callback + if (_this.settings.callbackFilters) { + _this.settings.callbackFilters.call(this, filters); + } }); } diff --git a/storelocator.jquery.json b/storelocator.jquery.json index 1d86b4c..5eb16fb 100644 --- a/storelocator.jquery.json +++ b/storelocator.jquery.json @@ -3,7 +3,7 @@ "title": "jQuery Google Maps Store Locator", "description": "This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.", "keywords": ["jquery","locator","store", "location", "locations", "maps", "map", "stores", "find"], - "version": "2.0.5", + "version": "2.0.6", "author": { "name": "Bjorn Holine", "url": "http://www.bjornblog.com/" From 3909be99b70726193c4d55242abe672adea610a3 Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Wed, 25 Mar 2015 22:41:21 -0500 Subject: [PATCH 2/9] Fixed issue with maxDistance and autoGeocode, fixed spelling error, removed the visualRefresh setting since it should no longer be needed --- .../js/plugins/storeLocator/jquery.storelocator.js | 9 +++------ .../js/plugins/storeLocator/jquery.storelocator.min.js | 4 ++-- readme.md | 1 + src/js/jquery.storelocator.js | 7 ++----- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js index a1b69e3..b743036 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js @@ -1,4 +1,4 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-24 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-25 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ @@ -1177,7 +1177,7 @@ }, /** - * Checks distance of each location and setups up the locationset array + * Checks distance of each location and sets up the locationset array * * @param data {Object} location data object * @param lat {number} origin latitude @@ -1194,7 +1194,7 @@ } // Create the array - if (this.settings.maxDistance === true && firstRun !== true && maxDistance !== null) { + if (this.settings.maxDistance === true && firstRun !== true && typeof maxDistance !== 'undefined' && maxDistance !== null) { if (data.distance < maxDistance) { locationset.push( data ); } @@ -1442,9 +1442,6 @@ maxDistance = mappingObject.distance; page = mappingObject.page; } - - // Enable the visual refresh https://developers.google.com/maps/documentation/javascript/basics#VisualRefresh - google.maps.visualRefresh = true; // Set the initial page to zero if not set if (typeof page === 'undefined') { diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js index ea7afcb..71b3174 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js @@ -1,5 +1,5 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-24 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-25 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ -!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
    ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
    '),a("."+this.settings.modalWindow).prepend('
    '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
    Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
    ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this,f=a.Deferred();return this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),this.settings.loading===!0&&a("."+this.settings.formContainer).append('
    '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
  • '+this.settings.prevPage+"
  • ");for(var f=0;f'+g+"":'
  • '+g+"
  • "}return b>d&&(c+='
  • '+this.settings.nextPage+"
  • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
    ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(d){var e,h,i,j,m,p,t,u,A,B,C,D,E,F=this,G=0;if(this.isEmptyObject(d)||(e=d.lat,h=d.lng,i=d.origin,j=d.name,m=d.distance,p=d.page),google.maps.visualRefresh=!0,"undefined"==typeof p&&(p=0),"undefined"==typeof i&&this.settings.nameSearch===!0)n=F._getData();else{var H=new google.maps.LatLng(e,h);"undefined"!=typeof k&&i===k&&"undefined"!=typeof l?(i=k,n=l):n=F._getData(q,r,i)}null!==F.settings.taxonomyFilters&&F.hasEmptyObjectVals(z)&&F.checkFilters(),n.done(function(d){var j=a("#"+F.settings.mapID),q="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=i,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&j.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),j.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var r=0;G0)for(var N=0;N
    '+F.settings.noResultsTitle+'

    '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof i&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&m){if("undefined"==typeof w[0]||w[0].distance>m)return void F.notify(F.settings.distanceErrorAlert+m+" "+q)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+q);if(F.settings.pagination===!0&&F.paginationSetup(p),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var O=new google.maps.LatLng(w[0].lat,w[0].lng);0===p?(F.settings.mapSettings.center=H,D=F.settings.mapSettings):(F.settings.mapSettings.center=O,D=F.settings.mapSettings)}else F.settings.mapSettings.center=H,D=F.settings.mapSettings;var P=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=P.getCenter();google.maps.event.trigger(P,"resize"),P.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),P);var Q=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var R="";if(F.settings.fullMapStart===!1&&t===!0)return;R=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:H,map:P,icon:R,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof i&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(i,c,P)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var S=0;C-1>=S;S++){var T="";T=String.fromCharCode(p>0?"A".charCodeAt(0)+(B+S):"A".charCodeAt(0)+S);var U=new google.maps.LatLng(w[S].lat,w[S].lng);u=F.createMarker(U,w[S].name,w[S].address,T,P,w[S].category),u.set("id",S),y[S]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&A.extend(U),F.createInfowindow(u,null,Q,B,p)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&P.fitBounds(A);var V=a("."+F.settings.locationList+" ul");V.empty(),0===w[0].lat&&0===w[0].lng?V.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),P.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,Q,B,p)},700)):F.createInfowindow(c,d,Q,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)})}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
    ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
    '),a("."+this.settings.modalWindow).prepend('
    '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
    Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
    ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this,f=a.Deferred();return this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),this.settings.loading===!0&&a("."+this.settings.formContainer).append('
    '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
  • '+this.settings.prevPage+"
  • ");for(var f=0;f'+g+"":'
  • '+g+"
  • "}return b>d&&(c+='
  • '+this.settings.nextPage+"
  • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
    ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(d){var e,h,i,j,m,p,t,u,A,B,C,D,E,F=this,G=0;if(this.isEmptyObject(d)||(e=d.lat,h=d.lng,i=d.origin,j=d.name,m=d.distance,p=d.page),"undefined"==typeof p&&(p=0),"undefined"==typeof i&&this.settings.nameSearch===!0)n=F._getData();else{var H=new google.maps.LatLng(e,h);"undefined"!=typeof k&&i===k&&"undefined"!=typeof l?(i=k,n=l):n=F._getData(q,r,i)}null!==F.settings.taxonomyFilters&&F.hasEmptyObjectVals(z)&&F.checkFilters(),n.done(function(d){var j=a("#"+F.settings.mapID),q="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=i,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&j.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),j.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var r=0;G0)for(var N=0;N
    '+F.settings.noResultsTitle+'

    '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof i&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&m){if("undefined"==typeof w[0]||w[0].distance>m)return void F.notify(F.settings.distanceErrorAlert+m+" "+q)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+q);if(F.settings.pagination===!0&&F.paginationSetup(p),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var O=new google.maps.LatLng(w[0].lat,w[0].lng);0===p?(F.settings.mapSettings.center=H,D=F.settings.mapSettings):(F.settings.mapSettings.center=O,D=F.settings.mapSettings)}else F.settings.mapSettings.center=H,D=F.settings.mapSettings;var P=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=P.getCenter();google.maps.event.trigger(P,"resize"),P.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),P);var Q=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var R="";if(F.settings.fullMapStart===!1&&t===!0)return;R=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:H,map:P,icon:R,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof i&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(i,c,P)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var S=0;C-1>=S;S++){var T="";T=String.fromCharCode(p>0?"A".charCodeAt(0)+(B+S):"A".charCodeAt(0)+S);var U=new google.maps.LatLng(w[S].lat,w[S].lng);u=F.createMarker(U,w[S].name,w[S].address,T,P,w[S].category),u.set("id",S),y[S]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&A.extend(U),F.createInfowindow(u,null,Q,B,p)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&P.fitBounds(A);var V=a("."+F.settings.locationList+" ul");V.empty(),0===w[0].lat&&0===w[0].lng?V.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),P.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,Q,B,p)},700)):F.createInfowindow(c,d,Q,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)})}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file diff --git a/readme.md b/readme.md index 221fa9d..2adc212 100644 --- a/readme.md +++ b/readme.md @@ -33,6 +33,7 @@ for even faster loading. * Added callbackFilters that fires when a filter is changed and can return the filter values. * Fixed issue with fullMapStart and inlineDirections setting combination. * Fixed issue with global olat and olng variables not being set with autoGeocode setting enabled. +* Fixed issue with maxDistance and autoGeocode setting combination. ### Version 2.0.5 diff --git a/src/js/jquery.storelocator.js b/src/js/jquery.storelocator.js index 12e08d6..e0cc340 100644 --- a/src/js/jquery.storelocator.js +++ b/src/js/jquery.storelocator.js @@ -1175,7 +1175,7 @@ }, /** - * Checks distance of each location and setups up the locationset array + * Checks distance of each location and sets up the locationset array * * @param data {Object} location data object * @param lat {number} origin latitude @@ -1192,7 +1192,7 @@ } // Create the array - if (this.settings.maxDistance === true && firstRun !== true && maxDistance !== null) { + if (this.settings.maxDistance === true && firstRun !== true && typeof maxDistance !== 'undefined' && maxDistance !== null) { if (data.distance < maxDistance) { locationset.push( data ); } @@ -1440,9 +1440,6 @@ maxDistance = mappingObject.distance; page = mappingObject.page; } - - // Enable the visual refresh https://developers.google.com/maps/documentation/javascript/basics#VisualRefresh - google.maps.visualRefresh = true; // Set the initial page to zero if not set if (typeof page === 'undefined') { From f961b13f48d186fe6ba6e30ae09b6a773320f23d Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Thu, 26 Mar 2015 16:25:34 -0500 Subject: [PATCH 3/9] Added raw data feature and example file --- .../storeLocator/jquery.storelocator.js | 784 +++++++++--------- .../storeLocator/jquery.storelocator.min.js | 4 +- dist/rawdata-example.php | 79 ++ options.md | 1 + src/js/jquery.storelocator.js | 782 ++++++++--------- 5 files changed, 909 insertions(+), 741 deletions(-) create mode 100644 dist/rawdata-example.php diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js index b743036..e19bdab 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js @@ -1,4 +1,4 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-25 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-26 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ @@ -37,6 +37,7 @@ 'distanceAlert' : 60, 'dataType' : 'xml', 'dataLocation' : 'data/locations.xml', + 'dataRaw' : null, 'xmlElement' : 'marker', 'listColor1' : '#ffffff', 'listColor2' : '#eeeeee', @@ -393,39 +394,55 @@ */ _getData: function (lat, lng, address) { var _this = this; - var d = $.Deferred(); // Before send callback if (this.settings.callbackBeforeSend) { this.settings.callbackBeforeSend.call(this, lat, lng, address); } - // Loading - if(this.settings.loading === true){ - $('.' + this.settings.formContainer).append('
    '); - } - - // AJAX request - $.ajax({ - type : 'GET', - url : this.settings.dataLocation + (this.settings.dataType === 'jsonp' ? (this.settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''), - // Passing the lat, lng, and address with the AJAX request so they can optionally be used by back-end languages - data: { - 'origLat' : lat, - 'origLng' : lng, - 'origAddress': address - }, - dataType : dataTypeRead, - jsonpCallback: (this.settings.dataType === 'jsonp' ? this.settings.callbackJsonp : null) - }).done(function (p) { - d.resolve(p); - - // Loading remove - if(_this.settings.loading === true){ - $('.' + _this.settings.formContainer + ' .' + _this.settings.loadingContainer).remove(); - } - }).fail(d.reject); - return d.promise(); + // Raw data + if( _this.settings.dataRaw !== null ) { + // XML + if( dataTypeRead === 'xml' ) { + return $.parseXML(_this.settings.dataRaw); + } + + // JSON + else if( dataTypeRead === 'json' ) { + return $.parseJSON(_this.settings.dataRaw); + } + } + // Remote data + else { + var d = $.Deferred(); + + // Loading + if(this.settings.loading === true){ + $('.' + this.settings.formContainer).append('
    '); + } + + // AJAX request + $.ajax({ + type : 'GET', + url : this.settings.dataLocation + (this.settings.dataType === 'jsonp' ? (this.settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''), + // Passing the lat, lng, and address with the AJAX request so they can optionally be used by back-end languages + data: { + 'origLat' : lat, + 'origLng' : lng, + 'origAddress': address + }, + dataType : dataTypeRead, + jsonpCallback: (this.settings.dataType === 'jsonp' ? this.settings.callbackJsonp : null) + }).done(function (p) { + d.resolve(p); + + // Loading remove + if(_this.settings.loading === true){ + $('.' + _this.settings.formContainer + ' .' + _this.settings.loadingContainer).remove(); + } + }).fail(d.reject); + return d.promise(); + } }, /** @@ -1432,14 +1449,11 @@ */ mapping: function (mappingObject) { var _this = this; - var orig_lat, orig_lng, origin, name, maxDistance, page, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults; - var i = 0; + var orig_lat, orig_lng, origin, originPoint, page; if (!this.isEmptyObject(mappingObject)) { orig_lat = mappingObject.lat; orig_lng = mappingObject.lng; origin = mappingObject.origin; - name = mappingObject.name; - maxDistance = mappingObject.distance; page = mappingObject.page; } @@ -1454,7 +1468,7 @@ } else { // Setup the origin point - var originPoint = new google.maps.LatLng(orig_lat, orig_lng); + originPoint = new google.maps.LatLng(orig_lat, orig_lng); // If the origin hasn't changed use the existing data so we aren't making unneeded AJAX requests if((typeof originalOrigin !== 'undefined') && (origin === originalOrigin) && (typeof originalData !== 'undefined')) { @@ -1475,413 +1489,443 @@ /** * Process the location data */ - dataRequest.done(function (data) { - var $mapDiv = $('#' + _this.settings.mapID); - // Get the length unit - var distUnit = (_this.settings.lengthUnit === 'km') ? _this.settings.kilometersLang : _this.settings.milesLang; - - // Save data and origin separately so we can potentially avoid multiple AJAX requests - originalData = dataRequest; - originalOrigin = origin; - - // Callback - if (_this.settings.callbackSuccess) { - _this.settings.callbackSuccess.call(this); - } - - // Set a variable for fullMapStart so we can detect the first run - if (_this.settings.fullMapStart === true && $mapDiv.hasClass('bh-sl-map-open') === false) { - firstRun = true; - } - else { - _this.reset(); - } + // Raw data + if( _this.settings.dataRaw !== null ) { + _this.processData(mappingObject, originPoint, dataRequest, page); + } + // Remote data + else { + dataRequest.done(function (data) { + _this.processData(mappingObject, originPoint, data, page); + }); + } + }, - $mapDiv.addClass('bh-sl-map-open'); + /** + * Processes the location data + * + * @param mappingObject {Object} all the potential mapping properties - latitude, longitude, origin, name, max distance, page + * @param originPoint {Object} LatLng of origin point + * @param data {Object} location data + * @param page {number} current page number + */ + processData: function (mappingObject, originPoint, data, page) { + var _this = this; + var i = 0; + var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults; + if (!this.isEmptyObject(mappingObject)) { + orig_lat = mappingObject.lat; + orig_lng = mappingObject.lng; + origin = mappingObject.origin; + name = mappingObject.name; + maxDistance = mappingObject.distance; + } - // Process the location data depending on the data format type - if (_this.settings.dataType === 'json' || _this.settings.dataType === 'jsonp') { - - // Process JSON - for(var x = 0; i < data.length; x++){ - var obj = data[x]; - var locationData = {}; - - // Parse each data variable - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - locationData[key] = obj[key]; - } - } + var $mapDiv = $('#' + _this.settings.mapID); + // Get the length unit + var distUnit = (_this.settings.lengthUnit === 'km') ? _this.settings.kilometersLang : _this.settings.milesLang; - _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + // Save data and origin separately so we can potentially avoid multiple AJAX requests + originalData = dataRequest; + originalOrigin = origin; - i++; - } - } - else if (_this.settings.dataType === 'kml') { - // Process KML - $(data).find('Placemark').each(function () { - var locationData = { - 'name' : $(this).find('name').text(), - 'lat' : $(this).find('coordinates').text().split(',')[1], - 'lng' : $(this).find('coordinates').text().split(',')[0], - 'description': $(this).find('description').text() - }; + // Callback + if (_this.settings.callbackSuccess) { + _this.settings.callbackSuccess.call(this); + } - _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + // Set a variable for fullMapStart so we can detect the first run + if (_this.settings.fullMapStart === true && $mapDiv.hasClass('bh-sl-map-open') === false) { + firstRun = true; + } + else { + _this.reset(); + } - i++; - }); - } - else { - // Process XML - $(data).find(_this.settings.xmlElement).each(function () { - var locationData = {}; + $mapDiv.addClass('bh-sl-map-open'); - for (var key in this.attributes) { - if (this.attributes.hasOwnProperty(key)) { - locationData[this.attributes[key].name] = this.attributes[key].value; - } + // Process the location data depending on the data format type + if (_this.settings.dataType === 'json' || _this.settings.dataType === 'jsonp') { + + // Process JSON + for(var x = 0; i < data.length; x++){ + var obj = data[x]; + var locationData = {}; + + // Parse each data variable + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + locationData[key] = obj[key]; } + } - _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); - i++; - }); + i++; } - - // Name search - using taxonomy filter to handle - if (_this.settings.nameSearch === true) { - if(typeof searchInput !== 'undefined') { - filters[_this.settings.nameAttribute] = [searchInput]; + } + else if (_this.settings.dataType === 'kml') { + // Process KML + $(data).find('Placemark').each(function () { + var locationData = { + 'name' : $(this).find('name').text(), + 'lat' : $(this).find('coordinates').text().split(',')[1], + 'lng' : $(this).find('coordinates').text().split(',')[0], + 'description': $(this).find('description').text() + }; + + _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + + i++; + }); + } + else { + // Process XML + $(data).find(_this.settings.xmlElement).each(function () { + var locationData = {}; + + for (var key in this.attributes) { + if (this.attributes.hasOwnProperty(key)) { + locationData[this.attributes[key].name] = this.attributes[key].value; + } } + + _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + + i++; + }); + } + + // Name search - using taxonomy filter to handle + if (_this.settings.nameSearch === true) { + if(typeof searchInput !== 'undefined') { + filters[_this.settings.nameAttribute] = [searchInput]; } + } - // Taxonomy filtering setup - if (_this.settings.taxonomyFilters !== null || _this.settings.nameSearch === true) { - var taxFilters = {}; - - for(var k in filters) { - if (filters.hasOwnProperty(k) && filters[k].length > 0) { - // Let's use regex - for (var z = 0; z < filters[k].length; z++) { - // Creating a new object so we don't mess up the original filters - if (!taxFilters[k]) { - taxFilters[k] = []; - } - taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") + '\\b)'; + // Taxonomy filtering setup + if (_this.settings.taxonomyFilters !== null || _this.settings.nameSearch === true) { + var taxFilters = {}; + + for(var k in filters) { + if (filters.hasOwnProperty(k) && filters[k].length > 0) { + // Let's use regex + for (var z = 0; z < filters[k].length; z++) { + // Creating a new object so we don't mess up the original filters + if (!taxFilters[k]) { + taxFilters[k] = []; } + taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") + '\\b)'; } } - // Filter the data - if (!_this.isEmptyObject(taxFilters)) { - locationset = $.grep(locationset, function (val) { - return _this.filterData(val, taxFilters); - }); - } } + // Filter the data + if (!_this.isEmptyObject(taxFilters)) { + locationset = $.grep(locationset, function (val) { + return _this.filterData(val, taxFilters); + }); + } + } - // Handle no results - if (_this.isEmptyObject(locationset)) { - // Callback - if (_this.settings.callbackNoResults) { - _this.settings.callbackNoResults.call(this); - } - - // Hide the map and locations if they're showing - if ($mapDiv.hasClass('bh-sl-map-open')) { - $this.hide(); - } - - // Append the no results message - noResults = $('
  • ' + _this.settings.noResultsTitle + '

    ' + _this.settings.noResultsDesc + '
  • ').hide().fadeIn(); - - // Setup a no results location - locationset[0] = { - 'distance': 0, - 'lat' : 0, - 'lng': 0 - }; + // Handle no results + if (_this.isEmptyObject(locationset)) { + // Callback + if (_this.settings.callbackNoResults) { + _this.settings.callbackNoResults.call(this); } - // Sort the multi-dimensional array by distance - if (typeof origin !== 'undefined') { - _this.sortNumerically(locationset); + // Hide the map and locations if they're showing + if ($mapDiv.hasClass('bh-sl-map-open')) { + $this.hide(); } - // Featured locations filtering - if (_this.settings.featuredLocations === true) { - // Create array for featured locations - featuredset = $.grep(locationset, function (val) { - return val.featured === 'true'; - }); + // Append the no results message + noResults = $('
  • ' + _this.settings.noResultsTitle + '

    ' + _this.settings.noResultsDesc + '
  • ').hide().fadeIn(); - // Create array for normal locations - normalset = $.grep(locationset, function (val) { - return val.featured !== 'true'; - }); + // Setup a no results location + locationset[0] = { + 'distance': 0, + 'lat' : 0, + 'lng': 0 + }; + } - // Combine the arrays - locationset = []; - locationset = featuredset.concat(normalset); - } + // Sort the multi-dimensional array by distance + if (typeof origin !== 'undefined') { + _this.sortNumerically(locationset); + } - // Check the closest marker - if (_this.settings.maxDistance === true && firstRun !== true && maxDistance) { - if (typeof locationset[0] === 'undefined' || locationset[0].distance > maxDistance) { - _this.notify(_this.settings.distanceErrorAlert + maxDistance + ' ' + distUnit); - return; - } + // Featured locations filtering + if (_this.settings.featuredLocations === true) { + // Create array for featured locations + featuredset = $.grep(locationset, function (val) { + return val.featured === 'true'; + }); + + // Create array for normal locations + normalset = $.grep(locationset, function (val) { + return val.featured !== 'true'; + }); + + // Combine the arrays + locationset = []; + locationset = featuredset.concat(normalset); + } + + // Check the closest marker + if (_this.settings.maxDistance === true && firstRun !== true && maxDistance) { + if (typeof locationset[0] === 'undefined' || locationset[0].distance > maxDistance) { + _this.notify(_this.settings.distanceErrorAlert + maxDistance + ' ' + distUnit); + return; } - else { - if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) { - _this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit); - } + } + else { + if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) { + _this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit); } + } - // Output page numbers if pagination setting is true - if (_this.settings.pagination === true) { - _this.paginationSetup(page); - } + // Output page numbers if pagination setting is true + if (_this.settings.pagination === true) { + _this.paginationSetup(page); + } - // Slide in the map container - if (_this.settings.slideMap === true) { - $this.slideDown(); + // Slide in the map container + if (_this.settings.slideMap === true) { + $this.slideDown(); + } + + // Set up the modal window + if (_this.settings.modal === true) { + // Callback + if (_this.settings.callbackModalOpen) { + _this.settings.callbackModalOpen.call(this); } - - // Set up the modal window - if (_this.settings.modal === true) { - // Callback - if (_this.settings.callbackModalOpen) { - _this.settings.callbackModalOpen.call(this); - } - // Pop up the modal window - $('.' + _this.settings.overlay).fadeIn(); - // Close modal when close icon is clicked and when background overlay is clicked - $(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () { + // Pop up the modal window + $('.' + _this.settings.overlay).fadeIn(); + // Close modal when close icon is clicked and when background overlay is clicked + $(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () { + _this.modalClose(); + }); + // Prevent clicks within the modal window from closing the entire thing + $(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) { + e.stopPropagation(); + }); + // Close modal when escape key is pressed + $(document).on('keyup.'+pluginName, function (e) { + if (e.keyCode === 27) { _this.modalClose(); - }); - // Prevent clicks within the modal window from closing the entire thing - $(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) { - e.stopPropagation(); - }); - // Close modal when escape key is pressed - $(document).on('keyup.'+pluginName, function (e) { - if (e.keyCode === 27) { - _this.modalClose(); - } - }); - } + } + }); + } - // Avoid error if number of locations is less than the default of 26 - if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit) { - storeNum = locationset.length; - } - else { - storeNum = _this.settings.storeLimit; - } + // Avoid error if number of locations is less than the default of 26 + if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit) { + storeNum = locationset.length; + } + else { + storeNum = _this.settings.storeLimit; + } - // If pagination is on, change the store limit to the setting and slice the locationset array - if (_this.settings.pagination === true) { - storeNumToShow = _this.settings.locationsPerPage; - storeStart = page * _this.settings.locationsPerPage; + // If pagination is on, change the store limit to the setting and slice the locationset array + if (_this.settings.pagination === true) { + storeNumToShow = _this.settings.locationsPerPage; + storeStart = page * _this.settings.locationsPerPage; - if( (storeStart + storeNumToShow) > locationset.length ) { - storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length); - } - - locationset = locationset.slice(storeStart, storeStart + storeNumToShow); - storeNum = locationset.length; - } - else { - storeNumToShow = storeNum; - storeStart = 0; + if( (storeStart + storeNumToShow) > locationset.length ) { + storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length); } - // Google maps settings - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { - myOptions = _this.settings.mapSettings; - bounds = new google.maps.LatLngBounds(); - } - else if (_this.settings.pagination === true) { - // Update the map to focus on the first point in the new set - var nextPoint = new google.maps.LatLng(locationset[0].lat, locationset[0].lng); + locationset = locationset.slice(storeStart, storeStart + storeNumToShow); + storeNum = locationset.length; + } + else { + storeNumToShow = storeNum; + storeStart = 0; + } - if (page === 0) { - _this.settings.mapSettings.center = originPoint; - myOptions = _this.settings.mapSettings; - } - else { - _this.settings.mapSettings.center = nextPoint; - myOptions = _this.settings.mapSettings; - } + // Google maps settings + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + myOptions = _this.settings.mapSettings; + bounds = new google.maps.LatLngBounds(); + } + else if (_this.settings.pagination === true) { + // Update the map to focus on the first point in the new set + var nextPoint = new google.maps.LatLng(locationset[0].lat, locationset[0].lng); + + if (page === 0) { + _this.settings.mapSettings.center = originPoint; + myOptions = _this.settings.mapSettings; } else { - _this.settings.mapSettings.center = originPoint; + _this.settings.mapSettings.center = nextPoint; myOptions = _this.settings.mapSettings; } + } + else { + _this.settings.mapSettings.center = originPoint; + myOptions = _this.settings.mapSettings; + } - // Create the map - var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); + // Create the map + var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); - // Re-center the map when the browser is resized - google.maps.event.addDomListener(window, 'resize', function() { - var center = map.getCenter(); - google.maps.event.trigger(map, 'resize'); - map.setCenter(center); - }); - - // Load the map - $this.data(_this.settings.mapID.replace('#', ''), map); + // Re-center the map when the browser is resized + google.maps.event.addDomListener(window, 'resize', function() { + var center = map.getCenter(); + google.maps.event.trigger(map, 'resize'); + map.setCenter(center); + }); - // Initialize the infowondow - var infowindow = new google.maps.InfoWindow(); + // Load the map + $this.data(_this.settings.mapID.replace('#', ''), map); - // Add origin marker if the setting is set - if (_this.settings.originMarker === true) { - var originImg = ''; - - // If fullMapStart is on and it's the first run there is no origin - if(_this.settings.fullMapStart === false && firstRun === true) { - return; - } - else{ - if(_this.settings.originMarkerImg !== null) { - if(_this.settings.originMarkerDim === null) { - originImg = _this.markerImage(_this.settings.originMarkerImg); - } - else { - originImg = _this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height); - } + // Initialize the infowondow + var infowindow = new google.maps.InfoWindow(); + + // Add origin marker if the setting is set + if (_this.settings.originMarker === true) { + var originImg = ''; + + // If fullMapStart is on and it's the first run there is no origin + if(_this.settings.fullMapStart === false && firstRun === true) { + return; + } + else{ + if(_this.settings.originMarkerImg !== null) { + if(_this.settings.originMarkerDim === null) { + originImg = _this.markerImage(_this.settings.originMarkerImg); } else { - originImg = { - url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png' - }; + originImg = _this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height); } - - marker = new google.maps.Marker({ - position : originPoint, - map : map, - icon : originImg, - draggable: false - }); } - } - - // Handle pagination - $(document).on('click.'+pluginName, '.bh-sl-pagination li', function () { - // Run paginationChange - _this.paginationChange($(this).attr('data-page')); - }); - - // Inline directions - if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') { - // Open directions - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { - e.preventDefault(); - var locID = $(this).closest('li').attr('data-markerid'); - _this.directionsRequest(origin, locID, map); - }); + else { + originImg = { + url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png' + }; + } - // Close directions - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () { - _this.closeDirections(); + marker = new google.maps.Marker({ + position : originPoint, + map : map, + icon : originImg, + draggable: false }); } + } - // Add markers and infowindows loop - for (var y = 0; y <= storeNumToShow - 1; y++) { - var letter = ''; + // Handle pagination + $(document).on('click.'+pluginName, '.bh-sl-pagination li', function () { + // Run paginationChange + _this.paginationChange($(this).attr('data-page')); + }); - if (page > 0) { - letter = String.fromCharCode('A'.charCodeAt(0) + (storeStart + y)); - } - else { - letter = String.fromCharCode('A'.charCodeAt(0) + y); - } - - var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng); - marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); - marker.set('id', y); - markers[y] = marker; - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { - bounds.extend(point); - } - // Pass variables to the pop-up infowindows - _this.createInfowindow(marker, null, infowindow, storeStart, page); - } + // Inline directions + if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') { + // Open directions + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { + e.preventDefault(); + var locID = $(this).closest('li').attr('data-markerid'); + _this.directionsRequest(origin, locID, map); + }); - // Center and zoom if no origin or zoom was provided - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { - map.fitBounds(bounds); - } + // Close directions + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () { + _this.closeDirections(); + }); + } + + // Add markers and infowindows loop + for (var y = 0; y <= storeNumToShow - 1; y++) { + var letter = ''; - // Create the links that focus on the related marker - var locList = $('.' + _this.settings.locationList + ' ul'); - locList.empty(); - // Check the locationset and continue with the list setup or show no results message - if(locationset[0].lat === 0 && locationset[0].lng === 0) { - locList.append(noResults); + if (page > 0) { + letter = String.fromCharCode('A'.charCodeAt(0) + (storeStart + y)); } else { - $(markers).each(function (x) { - var currentMarker = markers[x]; - _this.listSetup(currentMarker, storeStart, page); - }); + letter = String.fromCharCode('A'.charCodeAt(0) + y); } - // Handle clicks from the list - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () { - var markerId = $(this).data('markerid'); - var selectedMarker = markers[markerId]; + var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng); + marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); + marker.set('id', y); + markers[y] = marker; + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + bounds.extend(point); + } + // Pass variables to the pop-up infowindows + _this.createInfowindow(marker, null, infowindow, storeStart, page); + } - // List click callback - if (_this.settings.callbackListClick) { - _this.settings.callbackListClick.call(this, markerId, selectedMarker); - } + // Center and zoom if no origin or zoom was provided + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + map.fitBounds(bounds); + } - // Focus on the list - $('.' + _this.settings.locationList + ' li').removeClass('list-focus'); - $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus'); - - map.panTo(selectedMarker.getPosition()); - var listLoc = 'left'; - if (_this.settings.bounceMarker === true) { - selectedMarker.setAnimation(google.maps.Animation.BOUNCE); - setTimeout(function () { - selectedMarker.setAnimation(null); - _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); - }, 700 - ); - } - else { - _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); - } - }); - - // Prevent bubbling from list content links - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function (e) { - e.stopPropagation(); + // Create the links that focus on the related marker + var locList = $('.' + _this.settings.locationList + ' ul'); + locList.empty(); + // Check the locationset and continue with the list setup or show no results message + if(locationset[0].lat === 0 && locationset[0].lng === 0) { + locList.append(noResults); + } + else { + $(markers).each(function (x) { + var currentMarker = markers[x]; + _this.listSetup(currentMarker, storeStart, page); }); + } - // Add the list li background colors - this wil be dropped in a future version in favor of CSS - $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1); - $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2); - - // Modal ready callback - if (_this.settings.modal === true && _this.settings.callbackModalReady) { - _this.settings.callbackModalReady.call(this); + // Handle clicks from the list + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () { + var markerId = $(this).data('markerid'); + var selectedMarker = markers[markerId]; + + // List click callback + if (_this.settings.callbackListClick) { + _this.settings.callbackListClick.call(this, markerId, selectedMarker); } - // Filters callback - if (_this.settings.callbackFilters) { - _this.settings.callbackFilters.call(this, filters); + // Focus on the list + $('.' + _this.settings.locationList + ' li').removeClass('list-focus'); + $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus'); + + map.panTo(selectedMarker.getPosition()); + var listLoc = 'left'; + if (_this.settings.bounceMarker === true) { + selectedMarker.setAnimation(google.maps.Animation.BOUNCE); + setTimeout(function () { + selectedMarker.setAnimation(null); + _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); + }, 700 + ); } - + else { + _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); + } + }); + + // Prevent bubbling from list content links + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function (e) { + e.stopPropagation(); }); + + // Add the list li background colors - this wil be dropped in a future version in favor of CSS + $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1); + $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2); + + // Modal ready callback + if (_this.settings.modal === true && _this.settings.callbackModalReady) { + _this.settings.callbackModalReady.call(this); + } + + // Filters callback + if (_this.settings.callbackFilters) { + _this.settings.callbackFilters.call(this, filters); + } + } }); diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js index 71b3174..3116d22 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js @@ -1,5 +1,5 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-25 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-26 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ -!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
    ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
    '),a("."+this.settings.modalWindow).prepend('
    '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
    Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
    ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this,f=a.Deferred();return this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),this.settings.loading===!0&&a("."+this.settings.formContainer).append('
    '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
  • '+this.settings.prevPage+"
  • ");for(var f=0;f'+g+"":'
  • '+g+"
  • "}return b>d&&(c+='
  • '+this.settings.nextPage+"
  • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
    ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(d){var e,h,i,j,m,p,t,u,A,B,C,D,E,F=this,G=0;if(this.isEmptyObject(d)||(e=d.lat,h=d.lng,i=d.origin,j=d.name,m=d.distance,p=d.page),"undefined"==typeof p&&(p=0),"undefined"==typeof i&&this.settings.nameSearch===!0)n=F._getData();else{var H=new google.maps.LatLng(e,h);"undefined"!=typeof k&&i===k&&"undefined"!=typeof l?(i=k,n=l):n=F._getData(q,r,i)}null!==F.settings.taxonomyFilters&&F.hasEmptyObjectVals(z)&&F.checkFilters(),n.done(function(d){var j=a("#"+F.settings.mapID),q="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=i,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&j.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),j.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var r=0;G0)for(var N=0;N
    '+F.settings.noResultsTitle+'

    '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof i&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&m){if("undefined"==typeof w[0]||w[0].distance>m)return void F.notify(F.settings.distanceErrorAlert+m+" "+q)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+q);if(F.settings.pagination===!0&&F.paginationSetup(p),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var O=new google.maps.LatLng(w[0].lat,w[0].lng);0===p?(F.settings.mapSettings.center=H,D=F.settings.mapSettings):(F.settings.mapSettings.center=O,D=F.settings.mapSettings)}else F.settings.mapSettings.center=H,D=F.settings.mapSettings;var P=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=P.getCenter();google.maps.event.trigger(P,"resize"),P.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),P);var Q=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var R="";if(F.settings.fullMapStart===!1&&t===!0)return;R=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:H,map:P,icon:R,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof i&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(i,c,P)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var S=0;C-1>=S;S++){var T="";T=String.fromCharCode(p>0?"A".charCodeAt(0)+(B+S):"A".charCodeAt(0)+S);var U=new google.maps.LatLng(w[S].lat,w[S].lng);u=F.createMarker(U,w[S].name,w[S].address,T,P,w[S].category),u.set("id",S),y[S]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&A.extend(U),F.createInfowindow(u,null,Q,B,p)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof i)&&P.fitBounds(A);var V=a("."+F.settings.locationList+" ul");V.empty(),0===w[0].lat&&0===w[0].lng?V.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),P.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,Q,B,p)},700)):F.createInfowindow(c,d,Q,B,p)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)})}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",dataRaw:null,xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
    ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
    '),a("."+this.settings.modalWindow).prepend('
    '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
    Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
    ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this;if(this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),null===e.settings.dataRaw){var f=a.Deferred();return this.settings.loading===!0&&a("."+this.settings.formContainer).append('
    '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()}return"xml"===j?a.parseXML(e.settings.dataRaw):"json"===j?a.parseJSON(e.settings.dataRaw):void 0},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
  • '+this.settings.prevPage+"
  • ");for(var f=0;f'+g+"":'
  • '+g+"
  • "}return b>d&&(c+='
  • '+this.settings.nextPage+"
  • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
    ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(a){var b,c,d,e,f,g=this;this.isEmptyObject(a)||(b=a.lat,c=a.lng,d=a.origin,f=a.page),"undefined"==typeof f&&(f=0),"undefined"==typeof d&&this.settings.nameSearch===!0?n=g._getData():(e=new google.maps.LatLng(b,c),"undefined"!=typeof k&&d===k&&"undefined"!=typeof l?(d=k,n=l):n=g._getData(q,r,d)),null!==g.settings.taxonomyFilters&&g.hasEmptyObjectVals(z)&&g.checkFilters(),null!==g.settings.dataRaw?g.processData(a,e,n,f):n.done(function(b){g.processData(a,e,b,f)})},processData:function(d,e,h,i){var j,m,p,q,r,t,u,A,B,C,D,E,F=this,G=0;this.isEmptyObject(d)||(j=d.lat,m=d.lng,p=d.origin,q=d.name,r=d.distance);var H=a("#"+F.settings.mapID),I="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=p,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&H.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),H.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var J=0;G0)for(var P=0;P
    '+F.settings.noResultsTitle+'

    '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof p&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&r){if("undefined"==typeof w[0]||w[0].distance>r)return void F.notify(F.settings.distanceErrorAlert+r+" "+I)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+I);if(F.settings.pagination===!0&&F.paginationSetup(i),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var Q=new google.maps.LatLng(w[0].lat,w[0].lng);0===i?(F.settings.mapSettings.center=e,D=F.settings.mapSettings):(F.settings.mapSettings.center=Q,D=F.settings.mapSettings)}else F.settings.mapSettings.center=e,D=F.settings.mapSettings;var R=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=R.getCenter();google.maps.event.trigger(R,"resize"),R.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),R);var S=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var T="";if(F.settings.fullMapStart===!1&&t===!0)return;T=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:e,map:R,icon:T,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof p&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(p,c,R)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var U=0;C-1>=U;U++){var V="";V=String.fromCharCode(i>0?"A".charCodeAt(0)+(B+U):"A".charCodeAt(0)+U);var W=new google.maps.LatLng(w[U].lat,w[U].lng);u=F.createMarker(W,w[U].name,w[U].address,V,R,w[U].category),u.set("id",U),y[U]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&A.extend(W),F.createInfowindow(u,null,S,B,i)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&R.fitBounds(A);var X=a("."+F.settings.locationList+" ul");X.empty(),0===w[0].lat&&0===w[0].lng?X.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),R.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,S,B,i)},700)):F.createInfowindow(c,d,S,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/rawdata-example.php b/dist/rawdata-example.php new file mode 100644 index 0000000..e6f4e04 --- /dev/null +++ b/dist/rawdata-example.php @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + +'; + +?> + + + + + Map Example - Raw Data + + + + + + +
    + + +
    +
    +
    + + +
    + + +
    +
    + +
    +
    +
      +
      +
      +
      +
      + + + + + + + + + \ No newline at end of file diff --git a/options.md b/options.md index aaa4673..d700b47 100644 --- a/options.md +++ b/options.md @@ -15,6 +15,7 @@ | distanceAlert | 60 | Displays alert if there are no locations with 60 m/km of the user's location. Set to -1 to disable. | | dataType | 'xml' | The format of the data source. Accepted values include kml, xml, json, and jsonp. | | dataLocation | 'data/locations.xml' | The path to the location data. | +| dataRaw | null | Accepts raw KML, XML, or JSON instead of using a remote file. | | xmlElement | 'marker' | XML element used for locations (tag). | | listColor1 | '#ffffff' | Background color of the odd list elements. | | listColor2 | '#eeeeee' | Background color of the even list elements. | diff --git a/src/js/jquery.storelocator.js b/src/js/jquery.storelocator.js index e0cc340..9a85f5d 100644 --- a/src/js/jquery.storelocator.js +++ b/src/js/jquery.storelocator.js @@ -35,6 +35,7 @@ 'distanceAlert' : 60, 'dataType' : 'xml', 'dataLocation' : 'data/locations.xml', + 'dataRaw' : null, 'xmlElement' : 'marker', 'listColor1' : '#ffffff', 'listColor2' : '#eeeeee', @@ -391,39 +392,55 @@ */ _getData: function (lat, lng, address) { var _this = this; - var d = $.Deferred(); // Before send callback if (this.settings.callbackBeforeSend) { this.settings.callbackBeforeSend.call(this, lat, lng, address); } - // Loading - if(this.settings.loading === true){ - $('.' + this.settings.formContainer).append('
      '); - } - - // AJAX request - $.ajax({ - type : 'GET', - url : this.settings.dataLocation + (this.settings.dataType === 'jsonp' ? (this.settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''), - // Passing the lat, lng, and address with the AJAX request so they can optionally be used by back-end languages - data: { - 'origLat' : lat, - 'origLng' : lng, - 'origAddress': address - }, - dataType : dataTypeRead, - jsonpCallback: (this.settings.dataType === 'jsonp' ? this.settings.callbackJsonp : null) - }).done(function (p) { - d.resolve(p); - - // Loading remove - if(_this.settings.loading === true){ - $('.' + _this.settings.formContainer + ' .' + _this.settings.loadingContainer).remove(); - } - }).fail(d.reject); - return d.promise(); + // Raw data + if( _this.settings.dataRaw !== null ) { + // XML + if( dataTypeRead === 'xml' ) { + return $.parseXML(_this.settings.dataRaw); + } + + // JSON + else if( dataTypeRead === 'json' ) { + return $.parseJSON(_this.settings.dataRaw); + } + } + // Remote data + else { + var d = $.Deferred(); + + // Loading + if(this.settings.loading === true){ + $('.' + this.settings.formContainer).append('
      '); + } + + // AJAX request + $.ajax({ + type : 'GET', + url : this.settings.dataLocation + (this.settings.dataType === 'jsonp' ? (this.settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''), + // Passing the lat, lng, and address with the AJAX request so they can optionally be used by back-end languages + data: { + 'origLat' : lat, + 'origLng' : lng, + 'origAddress': address + }, + dataType : dataTypeRead, + jsonpCallback: (this.settings.dataType === 'jsonp' ? this.settings.callbackJsonp : null) + }).done(function (p) { + d.resolve(p); + + // Loading remove + if(_this.settings.loading === true){ + $('.' + _this.settings.formContainer + ' .' + _this.settings.loadingContainer).remove(); + } + }).fail(d.reject); + return d.promise(); + } }, /** @@ -1430,14 +1447,11 @@ */ mapping: function (mappingObject) { var _this = this; - var orig_lat, orig_lng, origin, name, maxDistance, page, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults; - var i = 0; + var orig_lat, orig_lng, origin, originPoint, page; if (!this.isEmptyObject(mappingObject)) { orig_lat = mappingObject.lat; orig_lng = mappingObject.lng; origin = mappingObject.origin; - name = mappingObject.name; - maxDistance = mappingObject.distance; page = mappingObject.page; } @@ -1452,7 +1466,7 @@ } else { // Setup the origin point - var originPoint = new google.maps.LatLng(orig_lat, orig_lng); + originPoint = new google.maps.LatLng(orig_lat, orig_lng); // If the origin hasn't changed use the existing data so we aren't making unneeded AJAX requests if((typeof originalOrigin !== 'undefined') && (origin === originalOrigin) && (typeof originalData !== 'undefined')) { @@ -1473,413 +1487,443 @@ /** * Process the location data */ - dataRequest.done(function (data) { - var $mapDiv = $('#' + _this.settings.mapID); - // Get the length unit - var distUnit = (_this.settings.lengthUnit === 'km') ? _this.settings.kilometersLang : _this.settings.milesLang; - - // Save data and origin separately so we can potentially avoid multiple AJAX requests - originalData = dataRequest; - originalOrigin = origin; - - // Callback - if (_this.settings.callbackSuccess) { - _this.settings.callbackSuccess.call(this); - } - - // Set a variable for fullMapStart so we can detect the first run - if (_this.settings.fullMapStart === true && $mapDiv.hasClass('bh-sl-map-open') === false) { - firstRun = true; - } - else { - _this.reset(); - } + // Raw data + if( _this.settings.dataRaw !== null ) { + _this.processData(mappingObject, originPoint, dataRequest, page); + } + // Remote data + else { + dataRequest.done(function (data) { + _this.processData(mappingObject, originPoint, data, page); + }); + } + }, - $mapDiv.addClass('bh-sl-map-open'); + /** + * Processes the location data + * + * @param mappingObject {Object} all the potential mapping properties - latitude, longitude, origin, name, max distance, page + * @param originPoint {Object} LatLng of origin point + * @param data {Object} location data + * @param page {number} current page number + */ + processData: function (mappingObject, originPoint, data, page) { + var _this = this; + var i = 0; + var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults; + if (!this.isEmptyObject(mappingObject)) { + orig_lat = mappingObject.lat; + orig_lng = mappingObject.lng; + origin = mappingObject.origin; + name = mappingObject.name; + maxDistance = mappingObject.distance; + } - // Process the location data depending on the data format type - if (_this.settings.dataType === 'json' || _this.settings.dataType === 'jsonp') { - - // Process JSON - for(var x = 0; i < data.length; x++){ - var obj = data[x]; - var locationData = {}; - - // Parse each data variable - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - locationData[key] = obj[key]; - } - } + var $mapDiv = $('#' + _this.settings.mapID); + // Get the length unit + var distUnit = (_this.settings.lengthUnit === 'km') ? _this.settings.kilometersLang : _this.settings.milesLang; - _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + // Save data and origin separately so we can potentially avoid multiple AJAX requests + originalData = dataRequest; + originalOrigin = origin; - i++; - } - } - else if (_this.settings.dataType === 'kml') { - // Process KML - $(data).find('Placemark').each(function () { - var locationData = { - 'name' : $(this).find('name').text(), - 'lat' : $(this).find('coordinates').text().split(',')[1], - 'lng' : $(this).find('coordinates').text().split(',')[0], - 'description': $(this).find('description').text() - }; + // Callback + if (_this.settings.callbackSuccess) { + _this.settings.callbackSuccess.call(this); + } - _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + // Set a variable for fullMapStart so we can detect the first run + if (_this.settings.fullMapStart === true && $mapDiv.hasClass('bh-sl-map-open') === false) { + firstRun = true; + } + else { + _this.reset(); + } - i++; - }); - } - else { - // Process XML - $(data).find(_this.settings.xmlElement).each(function () { - var locationData = {}; + $mapDiv.addClass('bh-sl-map-open'); - for (var key in this.attributes) { - if (this.attributes.hasOwnProperty(key)) { - locationData[this.attributes[key].name] = this.attributes[key].value; - } + // Process the location data depending on the data format type + if (_this.settings.dataType === 'json' || _this.settings.dataType === 'jsonp') { + + // Process JSON + for(var x = 0; i < data.length; x++){ + var obj = data[x]; + var locationData = {}; + + // Parse each data variable + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + locationData[key] = obj[key]; } + } - _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); - i++; - }); + i++; } - - // Name search - using taxonomy filter to handle - if (_this.settings.nameSearch === true) { - if(typeof searchInput !== 'undefined') { - filters[_this.settings.nameAttribute] = [searchInput]; + } + else if (_this.settings.dataType === 'kml') { + // Process KML + $(data).find('Placemark').each(function () { + var locationData = { + 'name' : $(this).find('name').text(), + 'lat' : $(this).find('coordinates').text().split(',')[1], + 'lng' : $(this).find('coordinates').text().split(',')[0], + 'description': $(this).find('description').text() + }; + + _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + + i++; + }); + } + else { + // Process XML + $(data).find(_this.settings.xmlElement).each(function () { + var locationData = {}; + + for (var key in this.attributes) { + if (this.attributes.hasOwnProperty(key)) { + locationData[this.attributes[key].name] = this.attributes[key].value; + } } + + _this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance); + + i++; + }); + } + + // Name search - using taxonomy filter to handle + if (_this.settings.nameSearch === true) { + if(typeof searchInput !== 'undefined') { + filters[_this.settings.nameAttribute] = [searchInput]; } + } - // Taxonomy filtering setup - if (_this.settings.taxonomyFilters !== null || _this.settings.nameSearch === true) { - var taxFilters = {}; - - for(var k in filters) { - if (filters.hasOwnProperty(k) && filters[k].length > 0) { - // Let's use regex - for (var z = 0; z < filters[k].length; z++) { - // Creating a new object so we don't mess up the original filters - if (!taxFilters[k]) { - taxFilters[k] = []; - } - taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") + '\\b)'; + // Taxonomy filtering setup + if (_this.settings.taxonomyFilters !== null || _this.settings.nameSearch === true) { + var taxFilters = {}; + + for(var k in filters) { + if (filters.hasOwnProperty(k) && filters[k].length > 0) { + // Let's use regex + for (var z = 0; z < filters[k].length; z++) { + // Creating a new object so we don't mess up the original filters + if (!taxFilters[k]) { + taxFilters[k] = []; } + taxFilters[k][z] = '(?=.*\\b' + filters[k][z].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") + '\\b)'; } } - // Filter the data - if (!_this.isEmptyObject(taxFilters)) { - locationset = $.grep(locationset, function (val) { - return _this.filterData(val, taxFilters); - }); - } } + // Filter the data + if (!_this.isEmptyObject(taxFilters)) { + locationset = $.grep(locationset, function (val) { + return _this.filterData(val, taxFilters); + }); + } + } - // Handle no results - if (_this.isEmptyObject(locationset)) { - // Callback - if (_this.settings.callbackNoResults) { - _this.settings.callbackNoResults.call(this); - } - - // Hide the map and locations if they're showing - if ($mapDiv.hasClass('bh-sl-map-open')) { - $this.hide(); - } - - // Append the no results message - noResults = $('
    • ' + _this.settings.noResultsTitle + '

      ' + _this.settings.noResultsDesc + '
    • ').hide().fadeIn(); - - // Setup a no results location - locationset[0] = { - 'distance': 0, - 'lat' : 0, - 'lng': 0 - }; + // Handle no results + if (_this.isEmptyObject(locationset)) { + // Callback + if (_this.settings.callbackNoResults) { + _this.settings.callbackNoResults.call(this); } - // Sort the multi-dimensional array by distance - if (typeof origin !== 'undefined') { - _this.sortNumerically(locationset); + // Hide the map and locations if they're showing + if ($mapDiv.hasClass('bh-sl-map-open')) { + $this.hide(); } - // Featured locations filtering - if (_this.settings.featuredLocations === true) { - // Create array for featured locations - featuredset = $.grep(locationset, function (val) { - return val.featured === 'true'; - }); + // Append the no results message + noResults = $('
    • ' + _this.settings.noResultsTitle + '

      ' + _this.settings.noResultsDesc + '
    • ').hide().fadeIn(); - // Create array for normal locations - normalset = $.grep(locationset, function (val) { - return val.featured !== 'true'; - }); + // Setup a no results location + locationset[0] = { + 'distance': 0, + 'lat' : 0, + 'lng': 0 + }; + } - // Combine the arrays - locationset = []; - locationset = featuredset.concat(normalset); - } + // Sort the multi-dimensional array by distance + if (typeof origin !== 'undefined') { + _this.sortNumerically(locationset); + } - // Check the closest marker - if (_this.settings.maxDistance === true && firstRun !== true && maxDistance) { - if (typeof locationset[0] === 'undefined' || locationset[0].distance > maxDistance) { - _this.notify(_this.settings.distanceErrorAlert + maxDistance + ' ' + distUnit); - return; - } + // Featured locations filtering + if (_this.settings.featuredLocations === true) { + // Create array for featured locations + featuredset = $.grep(locationset, function (val) { + return val.featured === 'true'; + }); + + // Create array for normal locations + normalset = $.grep(locationset, function (val) { + return val.featured !== 'true'; + }); + + // Combine the arrays + locationset = []; + locationset = featuredset.concat(normalset); + } + + // Check the closest marker + if (_this.settings.maxDistance === true && firstRun !== true && maxDistance) { + if (typeof locationset[0] === 'undefined' || locationset[0].distance > maxDistance) { + _this.notify(_this.settings.distanceErrorAlert + maxDistance + ' ' + distUnit); + return; } - else { - if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) { - _this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit); - } + } + else { + if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) { + _this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit); } + } - // Output page numbers if pagination setting is true - if (_this.settings.pagination === true) { - _this.paginationSetup(page); - } + // Output page numbers if pagination setting is true + if (_this.settings.pagination === true) { + _this.paginationSetup(page); + } - // Slide in the map container - if (_this.settings.slideMap === true) { - $this.slideDown(); + // Slide in the map container + if (_this.settings.slideMap === true) { + $this.slideDown(); + } + + // Set up the modal window + if (_this.settings.modal === true) { + // Callback + if (_this.settings.callbackModalOpen) { + _this.settings.callbackModalOpen.call(this); } - - // Set up the modal window - if (_this.settings.modal === true) { - // Callback - if (_this.settings.callbackModalOpen) { - _this.settings.callbackModalOpen.call(this); - } - // Pop up the modal window - $('.' + _this.settings.overlay).fadeIn(); - // Close modal when close icon is clicked and when background overlay is clicked - $(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () { + // Pop up the modal window + $('.' + _this.settings.overlay).fadeIn(); + // Close modal when close icon is clicked and when background overlay is clicked + $(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () { + _this.modalClose(); + }); + // Prevent clicks within the modal window from closing the entire thing + $(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) { + e.stopPropagation(); + }); + // Close modal when escape key is pressed + $(document).on('keyup.'+pluginName, function (e) { + if (e.keyCode === 27) { _this.modalClose(); - }); - // Prevent clicks within the modal window from closing the entire thing - $(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) { - e.stopPropagation(); - }); - // Close modal when escape key is pressed - $(document).on('keyup.'+pluginName, function (e) { - if (e.keyCode === 27) { - _this.modalClose(); - } - }); - } + } + }); + } - // Avoid error if number of locations is less than the default of 26 - if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit) { - storeNum = locationset.length; - } - else { - storeNum = _this.settings.storeLimit; - } + // Avoid error if number of locations is less than the default of 26 + if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit) { + storeNum = locationset.length; + } + else { + storeNum = _this.settings.storeLimit; + } - // If pagination is on, change the store limit to the setting and slice the locationset array - if (_this.settings.pagination === true) { - storeNumToShow = _this.settings.locationsPerPage; - storeStart = page * _this.settings.locationsPerPage; + // If pagination is on, change the store limit to the setting and slice the locationset array + if (_this.settings.pagination === true) { + storeNumToShow = _this.settings.locationsPerPage; + storeStart = page * _this.settings.locationsPerPage; - if( (storeStart + storeNumToShow) > locationset.length ) { - storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length); - } - - locationset = locationset.slice(storeStart, storeStart + storeNumToShow); - storeNum = locationset.length; - } - else { - storeNumToShow = storeNum; - storeStart = 0; + if( (storeStart + storeNumToShow) > locationset.length ) { + storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length); } - // Google maps settings - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { - myOptions = _this.settings.mapSettings; - bounds = new google.maps.LatLngBounds(); - } - else if (_this.settings.pagination === true) { - // Update the map to focus on the first point in the new set - var nextPoint = new google.maps.LatLng(locationset[0].lat, locationset[0].lng); + locationset = locationset.slice(storeStart, storeStart + storeNumToShow); + storeNum = locationset.length; + } + else { + storeNumToShow = storeNum; + storeStart = 0; + } - if (page === 0) { - _this.settings.mapSettings.center = originPoint; - myOptions = _this.settings.mapSettings; - } - else { - _this.settings.mapSettings.center = nextPoint; - myOptions = _this.settings.mapSettings; - } + // Google maps settings + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + myOptions = _this.settings.mapSettings; + bounds = new google.maps.LatLngBounds(); + } + else if (_this.settings.pagination === true) { + // Update the map to focus on the first point in the new set + var nextPoint = new google.maps.LatLng(locationset[0].lat, locationset[0].lng); + + if (page === 0) { + _this.settings.mapSettings.center = originPoint; + myOptions = _this.settings.mapSettings; } else { - _this.settings.mapSettings.center = originPoint; + _this.settings.mapSettings.center = nextPoint; myOptions = _this.settings.mapSettings; } + } + else { + _this.settings.mapSettings.center = originPoint; + myOptions = _this.settings.mapSettings; + } - // Create the map - var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); + // Create the map + var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); - // Re-center the map when the browser is resized - google.maps.event.addDomListener(window, 'resize', function() { - var center = map.getCenter(); - google.maps.event.trigger(map, 'resize'); - map.setCenter(center); - }); - - // Load the map - $this.data(_this.settings.mapID.replace('#', ''), map); + // Re-center the map when the browser is resized + google.maps.event.addDomListener(window, 'resize', function() { + var center = map.getCenter(); + google.maps.event.trigger(map, 'resize'); + map.setCenter(center); + }); - // Initialize the infowondow - var infowindow = new google.maps.InfoWindow(); + // Load the map + $this.data(_this.settings.mapID.replace('#', ''), map); - // Add origin marker if the setting is set - if (_this.settings.originMarker === true) { - var originImg = ''; - - // If fullMapStart is on and it's the first run there is no origin - if(_this.settings.fullMapStart === false && firstRun === true) { - return; - } - else{ - if(_this.settings.originMarkerImg !== null) { - if(_this.settings.originMarkerDim === null) { - originImg = _this.markerImage(_this.settings.originMarkerImg); - } - else { - originImg = _this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height); - } + // Initialize the infowondow + var infowindow = new google.maps.InfoWindow(); + + // Add origin marker if the setting is set + if (_this.settings.originMarker === true) { + var originImg = ''; + + // If fullMapStart is on and it's the first run there is no origin + if(_this.settings.fullMapStart === false && firstRun === true) { + return; + } + else{ + if(_this.settings.originMarkerImg !== null) { + if(_this.settings.originMarkerDim === null) { + originImg = _this.markerImage(_this.settings.originMarkerImg); } else { - originImg = { - url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png' - }; + originImg = _this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height); } - - marker = new google.maps.Marker({ - position : originPoint, - map : map, - icon : originImg, - draggable: false - }); } - } - - // Handle pagination - $(document).on('click.'+pluginName, '.bh-sl-pagination li', function () { - // Run paginationChange - _this.paginationChange($(this).attr('data-page')); - }); - - // Inline directions - if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') { - // Open directions - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { - e.preventDefault(); - var locID = $(this).closest('li').attr('data-markerid'); - _this.directionsRequest(origin, locID, map); - }); + else { + originImg = { + url: 'https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png' + }; + } - // Close directions - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () { - _this.closeDirections(); + marker = new google.maps.Marker({ + position : originPoint, + map : map, + icon : originImg, + draggable: false }); } + } - // Add markers and infowindows loop - for (var y = 0; y <= storeNumToShow - 1; y++) { - var letter = ''; + // Handle pagination + $(document).on('click.'+pluginName, '.bh-sl-pagination li', function () { + // Run paginationChange + _this.paginationChange($(this).attr('data-page')); + }); - if (page > 0) { - letter = String.fromCharCode('A'.charCodeAt(0) + (storeStart + y)); - } - else { - letter = String.fromCharCode('A'.charCodeAt(0) + y); - } - - var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng); - marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); - marker.set('id', y); - markers[y] = marker; - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { - bounds.extend(point); - } - // Pass variables to the pop-up infowindows - _this.createInfowindow(marker, null, infowindow, storeStart, page); - } + // Inline directions + if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') { + // Open directions + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { + e.preventDefault(); + var locID = $(this).closest('li').attr('data-markerid'); + _this.directionsRequest(origin, locID, map); + }); - // Center and zoom if no origin or zoom was provided - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { - map.fitBounds(bounds); - } + // Close directions + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () { + _this.closeDirections(); + }); + } + + // Add markers and infowindows loop + for (var y = 0; y <= storeNumToShow - 1; y++) { + var letter = ''; - // Create the links that focus on the related marker - var locList = $('.' + _this.settings.locationList + ' ul'); - locList.empty(); - // Check the locationset and continue with the list setup or show no results message - if(locationset[0].lat === 0 && locationset[0].lng === 0) { - locList.append(noResults); + if (page > 0) { + letter = String.fromCharCode('A'.charCodeAt(0) + (storeStart + y)); } else { - $(markers).each(function (x) { - var currentMarker = markers[x]; - _this.listSetup(currentMarker, storeStart, page); - }); + letter = String.fromCharCode('A'.charCodeAt(0) + y); } - // Handle clicks from the list - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () { - var markerId = $(this).data('markerid'); - var selectedMarker = markers[markerId]; + var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng); + marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); + marker.set('id', y); + markers[y] = marker; + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + bounds.extend(point); + } + // Pass variables to the pop-up infowindows + _this.createInfowindow(marker, null, infowindow, storeStart, page); + } - // List click callback - if (_this.settings.callbackListClick) { - _this.settings.callbackListClick.call(this, markerId, selectedMarker); - } + // Center and zoom if no origin or zoom was provided + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + map.fitBounds(bounds); + } - // Focus on the list - $('.' + _this.settings.locationList + ' li').removeClass('list-focus'); - $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus'); - - map.panTo(selectedMarker.getPosition()); - var listLoc = 'left'; - if (_this.settings.bounceMarker === true) { - selectedMarker.setAnimation(google.maps.Animation.BOUNCE); - setTimeout(function () { - selectedMarker.setAnimation(null); - _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); - }, 700 - ); - } - else { - _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); - } - }); - - // Prevent bubbling from list content links - $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function (e) { - e.stopPropagation(); + // Create the links that focus on the related marker + var locList = $('.' + _this.settings.locationList + ' ul'); + locList.empty(); + // Check the locationset and continue with the list setup or show no results message + if(locationset[0].lat === 0 && locationset[0].lng === 0) { + locList.append(noResults); + } + else { + $(markers).each(function (x) { + var currentMarker = markers[x]; + _this.listSetup(currentMarker, storeStart, page); }); + } - // Add the list li background colors - this wil be dropped in a future version in favor of CSS - $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1); - $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2); - - // Modal ready callback - if (_this.settings.modal === true && _this.settings.callbackModalReady) { - _this.settings.callbackModalReady.call(this); + // Handle clicks from the list + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () { + var markerId = $(this).data('markerid'); + var selectedMarker = markers[markerId]; + + // List click callback + if (_this.settings.callbackListClick) { + _this.settings.callbackListClick.call(this, markerId, selectedMarker); } - // Filters callback - if (_this.settings.callbackFilters) { - _this.settings.callbackFilters.call(this, filters); + // Focus on the list + $('.' + _this.settings.locationList + ' li').removeClass('list-focus'); + $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus'); + + map.panTo(selectedMarker.getPosition()); + var listLoc = 'left'; + if (_this.settings.bounceMarker === true) { + selectedMarker.setAnimation(google.maps.Animation.BOUNCE); + setTimeout(function () { + selectedMarker.setAnimation(null); + _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); + }, 700 + ); } - + else { + _this.createInfowindow(selectedMarker, listLoc, infowindow, storeStart, page); + } + }); + + // Prevent bubbling from list content links + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function (e) { + e.stopPropagation(); }); + + // Add the list li background colors - this wil be dropped in a future version in favor of CSS + $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1); + $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2); + + // Modal ready callback + if (_this.settings.modal === true && _this.settings.callbackModalReady) { + _this.settings.callbackModalReady.call(this); + } + + // Filters callback + if (_this.settings.callbackFilters) { + _this.settings.callbackFilters.call(this, filters); + } + } }); From caa044e0da611f2dbaee7913ca552bbe9398f005 Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Fri, 27 Mar 2015 11:13:45 -0500 Subject: [PATCH 4/9] Added visible markers option to only display the location information for the current markers on the map --- .../storeLocator/jquery.storelocator.js | 47 ++++++++++++++++++- .../storeLocator/jquery.storelocator.min.js | 4 +- dist/index.html | 4 +- src/js/jquery.storelocator.js | 45 ++++++++++++++++++ 4 files changed, 96 insertions(+), 4 deletions(-) diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js index e19bdab..9b7a4b5 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js @@ -1,4 +1,4 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-26 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-27 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ @@ -68,6 +68,7 @@ 'nameSearch' : false, 'searchID' : 'bh-sl-search', 'nameAttribute' : 'name', + 'visibleMarkersList' : false, 'infowindowTemplatePath' : 'assets/js/plugins/storeLocator/templates/infowindow-description.html', 'listTemplatePath' : 'assets/js/plugins/storeLocator/templates/location-list-description.html', 'KMLinfowindowTemplatePath': 'assets/js/plugins/storeLocator/templates/kml-infowindow-description.html', @@ -1442,6 +1443,32 @@ }); }, + /** + * Updates the location list to reflect the markers that are displayed on the map + * + * @param markers {Object} Map markers + * @param map {Object} Google map + */ + checkVisibleMarkers: function(markers, map) { + var _this = this; + var locations, listHtml; + + // Empty the location list + $('.' + this.settings.locationList + ' ul').empty(); + + // Set up the new list + $(markers).each(function(x, marker){ + if(map.getBounds().contains(marker.getPosition())) { + // Define the location data + _this.listSetup(marker, 0, 0); + + // Set up the list template with the location data + listHtml = listTemplate(locations); + $('.' + _this.settings.locationList + ' ul').append(listHtml); + } + }); + }, + /** * The primary mapping function that runs everything * @@ -1916,6 +1943,24 @@ $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1); $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2); + // Visible markers list + if(_this.settings.visibleMarkersList === true) { + // Add event listener to filter the list when the map is fully loaded + google.maps.event.addListenerOnce(map, 'idle', function(){ + _this.checkVisibleMarkers(markers, map); + }); + + // Add event listener for center change + google.maps.event.addListener(map, 'center_changed', function() { + _this.checkVisibleMarkers(markers, map); + }); + + // Add event listener for zoom change + google.maps.event.addListener(map, 'zoom_changed', function() { + _this.checkVisibleMarkers(markers, map); + }); + } + // Modal ready callback if (_this.settings.modal === true && _this.settings.callbackModalReady) { _this.settings.callbackModalReady.call(this); diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js index 3116d22..dae405b 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js @@ -1,5 +1,5 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-26 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-27 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ -!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",dataRaw:null,xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
      ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
      '),a("."+this.settings.modalWindow).prepend('
      '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
      Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
      ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this;if(this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),null===e.settings.dataRaw){var f=a.Deferred();return this.settings.loading===!0&&a("."+this.settings.formContainer).append('
      '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()}return"xml"===j?a.parseXML(e.settings.dataRaw):"json"===j?a.parseJSON(e.settings.dataRaw):void 0},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
    • '+this.settings.prevPage+"
    • ");for(var f=0;f'+g+"":'
    • '+g+"
    • "}return b>d&&(c+='
    • '+this.settings.nextPage+"
    • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
      ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},mapping:function(a){var b,c,d,e,f,g=this;this.isEmptyObject(a)||(b=a.lat,c=a.lng,d=a.origin,f=a.page),"undefined"==typeof f&&(f=0),"undefined"==typeof d&&this.settings.nameSearch===!0?n=g._getData():(e=new google.maps.LatLng(b,c),"undefined"!=typeof k&&d===k&&"undefined"!=typeof l?(d=k,n=l):n=g._getData(q,r,d)),null!==g.settings.taxonomyFilters&&g.hasEmptyObjectVals(z)&&g.checkFilters(),null!==g.settings.dataRaw?g.processData(a,e,n,f):n.done(function(b){g.processData(a,e,b,f)})},processData:function(d,e,h,i){var j,m,p,q,r,t,u,A,B,C,D,E,F=this,G=0;this.isEmptyObject(d)||(j=d.lat,m=d.lng,p=d.origin,q=d.name,r=d.distance);var H=a("#"+F.settings.mapID),I="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=p,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&H.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),H.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var J=0;G0)for(var P=0;P
      '+F.settings.noResultsTitle+'

      '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof p&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&r){if("undefined"==typeof w[0]||w[0].distance>r)return void F.notify(F.settings.distanceErrorAlert+r+" "+I)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+I);if(F.settings.pagination===!0&&F.paginationSetup(i),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var Q=new google.maps.LatLng(w[0].lat,w[0].lng);0===i?(F.settings.mapSettings.center=e,D=F.settings.mapSettings):(F.settings.mapSettings.center=Q,D=F.settings.mapSettings)}else F.settings.mapSettings.center=e,D=F.settings.mapSettings;var R=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=R.getCenter();google.maps.event.trigger(R,"resize"),R.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),R);var S=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var T="";if(F.settings.fullMapStart===!1&&t===!0)return;T=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:e,map:R,icon:T,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof p&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(p,c,R)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var U=0;C-1>=U;U++){var V="";V=String.fromCharCode(i>0?"A".charCodeAt(0)+(B+U):"A".charCodeAt(0)+U);var W=new google.maps.LatLng(w[U].lat,w[U].lng);u=F.createMarker(W,w[U].name,w[U].address,V,R,w[U].category),u.set("id",U),y[U]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&A.extend(W),F.createInfowindow(u,null,S,B,i)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&R.fitBounds(A);var X=a("."+F.settings.locationList+" ul");X.empty(),0===w[0].lat&&0===w[0].lng?X.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),R.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,S,B,i)},700)):F.createInfowindow(c,d,S,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",dataRaw:null,xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",visibleMarkersList:!1,infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
      ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
      '),a("."+this.settings.modalWindow).prepend('
      '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
      Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
      ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this;if(this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),null===e.settings.dataRaw){var f=a.Deferred();return this.settings.loading===!0&&a("."+this.settings.formContainer).append('
      '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()}return"xml"===j?a.parseXML(e.settings.dataRaw):"json"===j?a.parseJSON(e.settings.dataRaw):void 0},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
    • '+this.settings.prevPage+"
    • ");for(var f=0;f'+g+"":'
    • '+g+"
    • "}return b>d&&(c+='
    • '+this.settings.nextPage+"
    • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
      ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},checkVisibleMarkers:function(b,c){var d,e,f=this;a("."+this.settings.locationList+" ul").empty(),a(b).each(function(b,g){c.getBounds().contains(g.getPosition())&&(f.listSetup(g,0,0),e=h(d),a("."+f.settings.locationList+" ul").append(e))})},mapping:function(a){var b,c,d,e,f,g=this;this.isEmptyObject(a)||(b=a.lat,c=a.lng,d=a.origin,f=a.page),"undefined"==typeof f&&(f=0),"undefined"==typeof d&&this.settings.nameSearch===!0?n=g._getData():(e=new google.maps.LatLng(b,c),"undefined"!=typeof k&&d===k&&"undefined"!=typeof l?(d=k,n=l):n=g._getData(q,r,d)),null!==g.settings.taxonomyFilters&&g.hasEmptyObjectVals(z)&&g.checkFilters(),null!==g.settings.dataRaw?g.processData(a,e,n,f):n.done(function(b){g.processData(a,e,b,f)})},processData:function(d,e,h,i){var j,m,p,q,r,t,u,A,B,C,D,E,F=this,G=0;this.isEmptyObject(d)||(j=d.lat,m=d.lng,p=d.origin,q=d.name,r=d.distance);var H=a("#"+F.settings.mapID),I="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=p,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&H.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),H.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var J=0;G0)for(var P=0;P
      '+F.settings.noResultsTitle+'

      '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof p&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&r){if("undefined"==typeof w[0]||w[0].distance>r)return void F.notify(F.settings.distanceErrorAlert+r+" "+I)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+I);if(F.settings.pagination===!0&&F.paginationSetup(i),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var Q=new google.maps.LatLng(w[0].lat,w[0].lng);0===i?(F.settings.mapSettings.center=e,D=F.settings.mapSettings):(F.settings.mapSettings.center=Q,D=F.settings.mapSettings)}else F.settings.mapSettings.center=e,D=F.settings.mapSettings;var R=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=R.getCenter();google.maps.event.trigger(R,"resize"),R.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),R);var S=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var T="";if(F.settings.fullMapStart===!1&&t===!0)return;T=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:e,map:R,icon:T,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof p&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(p,c,R)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var U=0;C-1>=U;U++){var V="";V=String.fromCharCode(i>0?"A".charCodeAt(0)+(B+U):"A".charCodeAt(0)+U);var W=new google.maps.LatLng(w[U].lat,w[U].lng);u=F.createMarker(W,w[U].name,w[U].address,V,R,w[U].category),u.set("id",U),y[U]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&A.extend(W),F.createInfowindow(u,null,S,B,i)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&R.fitBounds(A);var X=a("."+F.settings.locationList+" ul");X.empty(),0===w[0].lat&&0===w[0].lng?X.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),R.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,S,B,i)},700)):F.createInfowindow(c,d,S,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.visibleMarkersList===!0&&(google.maps.event.addListenerOnce(R,"idle",function(){F.checkVisibleMarkers(y,R)}),google.maps.event.addListener(R,"center_changed",function(){F.checkVisibleMarkers(y,R)}),google.maps.event.addListener(R,"zoom_changed",function(){F.checkVisibleMarkers(y,R)})),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index e14129b..04ed072 100755 --- a/dist/index.html +++ b/dist/index.html @@ -40,7 +40,9 @@

      Using Chipotle as an Example

      diff --git a/src/js/jquery.storelocator.js b/src/js/jquery.storelocator.js index 9a85f5d..a5aebd6 100644 --- a/src/js/jquery.storelocator.js +++ b/src/js/jquery.storelocator.js @@ -66,6 +66,7 @@ 'nameSearch' : false, 'searchID' : 'bh-sl-search', 'nameAttribute' : 'name', + 'visibleMarkersList' : false, 'infowindowTemplatePath' : 'assets/js/plugins/storeLocator/templates/infowindow-description.html', 'listTemplatePath' : 'assets/js/plugins/storeLocator/templates/location-list-description.html', 'KMLinfowindowTemplatePath': 'assets/js/plugins/storeLocator/templates/kml-infowindow-description.html', @@ -1440,6 +1441,32 @@ }); }, + /** + * Updates the location list to reflect the markers that are displayed on the map + * + * @param markers {Object} Map markers + * @param map {Object} Google map + */ + checkVisibleMarkers: function(markers, map) { + var _this = this; + var locations, listHtml; + + // Empty the location list + $('.' + this.settings.locationList + ' ul').empty(); + + // Set up the new list + $(markers).each(function(x, marker){ + if(map.getBounds().contains(marker.getPosition())) { + // Define the location data + _this.listSetup(marker, 0, 0); + + // Set up the list template with the location data + listHtml = listTemplate(locations); + $('.' + _this.settings.locationList + ' ul').append(listHtml); + } + }); + }, + /** * The primary mapping function that runs everything * @@ -1914,6 +1941,24 @@ $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1); $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2); + // Visible markers list + if(_this.settings.visibleMarkersList === true) { + // Add event listener to filter the list when the map is fully loaded + google.maps.event.addListenerOnce(map, 'idle', function(){ + _this.checkVisibleMarkers(markers, map); + }); + + // Add event listener for center change + google.maps.event.addListener(map, 'center_changed', function() { + _this.checkVisibleMarkers(markers, map); + }); + + // Add event listener for zoom change + google.maps.event.addListener(map, 'zoom_changed', function() { + _this.checkVisibleMarkers(markers, map); + }); + } + // Modal ready callback if (_this.settings.modal === true && _this.settings.callbackModalReady) { _this.settings.callbackModalReady.call(this); From a279a05d6d9afb548ef13f4dd1fcbc46f177db2e Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Fri, 27 Mar 2015 13:19:14 -0500 Subject: [PATCH 5/9] Updated options.md with visibleMarkersList --- options.md | 1 + 1 file changed, 1 insertion(+) diff --git a/options.md b/options.md index d700b47..69d2e14 100644 --- a/options.md +++ b/options.md @@ -46,6 +46,7 @@ | nameSearch | false | Set to true to allow searching for locations by name using separate searchID field. | | searchID | 'bh-sl-search' | ID of the search input form field for location name searching. | | nameAttribute | 'name' | If using nameSearch, the data attribute used for the location name in the data file. | +| visibleMarkersList | false | Set to true to have the location list only show data from markers that are visible on the map. | | infowindowTemplatePath | 'templates/infowindow-description.html' | Path to the default infowindow template. | | listTemplatePath | 'templates/location-list-description.html' | Path to the default list template. | | KMLinfowindowTemplatePath | 'templates/kml-infowindow-description.html' | Path to the KML infowindow template – used if dataType is set to kml. | From 45e64a91057f4451c4453111753b8ebedff18741 Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Fri, 27 Mar 2015 17:56:09 -0500 Subject: [PATCH 6/9] Removed test call --- dist/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index 04ed072..e14129b 100755 --- a/dist/index.html +++ b/dist/index.html @@ -40,9 +40,7 @@

      Using Chipotle as an Example

      From effeddc9e1f046a77aff81ea03628712c4359a1c Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Fri, 27 Mar 2015 19:44:40 -0500 Subject: [PATCH 7/9] Changed distance error functionality so map centers and zooms automatically and displays all locations along after notification --- .../js/plugins/storeLocator/jquery.storelocator.js | 13 +++++++------ .../plugins/storeLocator/jquery.storelocator.min.js | 2 +- readme.md | 8 +++++++- src/js/jquery.storelocator.js | 13 +++++++------ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js index 9b7a4b5..fd60966 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js @@ -1539,7 +1539,7 @@ processData: function (mappingObject, originPoint, data, page) { var _this = this; var i = 0; - var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults; + var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError; if (!this.isEmptyObject(mappingObject)) { orig_lat = mappingObject.lat; orig_lng = mappingObject.lng; @@ -1709,6 +1709,7 @@ else { if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) { _this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit); + distError = true; } } @@ -1773,7 +1774,7 @@ } // Google maps settings - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) { myOptions = _this.settings.mapSettings; bounds = new google.maps.LatLngBounds(); } @@ -1798,7 +1799,7 @@ // Create the map var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); - // Re-center the map when the browser is resized + // Re-center the map when the browser is re-sized google.maps.event.addDomListener(window, 'resize', function() { var center = map.getCenter(); google.maps.event.trigger(map, 'resize'); @@ -1879,15 +1880,15 @@ marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); marker.set('id', y); markers[y] = marker; - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) { bounds.extend(point); } // Pass variables to the pop-up infowindows _this.createInfowindow(marker, null, infowindow, storeStart, page); } - // Center and zoom if no origin or zoom was provided - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + // Center and zoom if no origin or zoom was provided, or distance of first marker is greater than distanceAlert + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) { map.fitBounds(bounds); } diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js index dae405b..96bdf72 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js @@ -2,4 +2,4 @@ * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ -!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",dataRaw:null,xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",visibleMarkersList:!1,infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
      ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
      '),a("."+this.settings.modalWindow).prepend('
      '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
      Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
      ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this;if(this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),null===e.settings.dataRaw){var f=a.Deferred();return this.settings.loading===!0&&a("."+this.settings.formContainer).append('
      '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()}return"xml"===j?a.parseXML(e.settings.dataRaw):"json"===j?a.parseJSON(e.settings.dataRaw):void 0},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
    • '+this.settings.prevPage+"
    • ");for(var f=0;f'+g+"":'
    • '+g+"
    • "}return b>d&&(c+='
    • '+this.settings.nextPage+"
    • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
      ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},checkVisibleMarkers:function(b,c){var d,e,f=this;a("."+this.settings.locationList+" ul").empty(),a(b).each(function(b,g){c.getBounds().contains(g.getPosition())&&(f.listSetup(g,0,0),e=h(d),a("."+f.settings.locationList+" ul").append(e))})},mapping:function(a){var b,c,d,e,f,g=this;this.isEmptyObject(a)||(b=a.lat,c=a.lng,d=a.origin,f=a.page),"undefined"==typeof f&&(f=0),"undefined"==typeof d&&this.settings.nameSearch===!0?n=g._getData():(e=new google.maps.LatLng(b,c),"undefined"!=typeof k&&d===k&&"undefined"!=typeof l?(d=k,n=l):n=g._getData(q,r,d)),null!==g.settings.taxonomyFilters&&g.hasEmptyObjectVals(z)&&g.checkFilters(),null!==g.settings.dataRaw?g.processData(a,e,n,f):n.done(function(b){g.processData(a,e,b,f)})},processData:function(d,e,h,i){var j,m,p,q,r,t,u,A,B,C,D,E,F=this,G=0;this.isEmptyObject(d)||(j=d.lat,m=d.lng,p=d.origin,q=d.name,r=d.distance);var H=a("#"+F.settings.mapID),I="km"===F.settings.lengthUnit?F.settings.kilometersLang:F.settings.milesLang;if(l=n,k=p,F.settings.callbackSuccess&&F.settings.callbackSuccess.call(this),F.settings.fullMapStart===!0&&H.hasClass("bh-sl-map-open")===!1?t=!0:F.reset(),H.addClass("bh-sl-map-open"),"json"===F.settings.dataType||"jsonp"===F.settings.dataType)for(var J=0;G0)for(var P=0;P
      '+F.settings.noResultsTitle+'

      '+F.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof p&&F.sortNumerically(w),F.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),F.settings.maxDistance===!0&&t!==!0&&r){if("undefined"==typeof w[0]||w[0].distance>r)return void F.notify(F.settings.distanceErrorAlert+r+" "+I)}else-1!==F.settings.distanceAlert&&w[0].distance>F.settings.distanceAlert&&F.notify(F.settings.distanceErrorAlert+F.settings.distanceAlert+" "+I);if(F.settings.pagination===!0&&F.paginationSetup(i),F.settings.slideMap===!0&&g.slideDown(),F.settings.modal===!0&&(F.settings.callbackModalOpen&&F.settings.callbackModalOpen.call(this),a("."+F.settings.overlay).fadeIn(),a(c).on("click."+f,"."+F.settings.closeIcon+", ."+F.settings.overlay,function(){F.modalClose()}),a(c).on("click."+f,"."+F.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&F.modalClose()})),s=-1===F.settings.storeLimit||w.lengthw.length&&(C=F.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)D=F.settings.mapSettings,A=new google.maps.LatLngBounds;else if(F.settings.pagination===!0){var Q=new google.maps.LatLng(w[0].lat,w[0].lng);0===i?(F.settings.mapSettings.center=e,D=F.settings.mapSettings):(F.settings.mapSettings.center=Q,D=F.settings.mapSettings)}else F.settings.mapSettings.center=e,D=F.settings.mapSettings;var R=new google.maps.Map(c.getElementById(F.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=R.getCenter();google.maps.event.trigger(R,"resize"),R.setCenter(a)}),g.data(F.settings.mapID.replace("#",""),R);var S=new google.maps.InfoWindow;if(F.settings.originMarker===!0){var T="";if(F.settings.fullMapStart===!1&&t===!0)return;T=null!==F.settings.originMarkerImg?null===F.settings.originMarkerDim?F.markerImage(F.settings.originMarkerImg):F.markerImage(F.settings.originMarkerImg,F.settings.originMarkerDim.width,F.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:e,map:R,icon:T,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){F.paginationChange(a(this).attr("data-page"))}),F.settings.inlineDirections===!0&&"undefined"!=typeof p&&(a(c).on("click."+f,"."+F.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");F.directionsRequest(p,c,R)}),a(c).on("click."+f,"."+F.settings.locationList+" .bh-sl-close-icon",function(){F.closeDirections()}));for(var U=0;C-1>=U;U++){var V="";V=String.fromCharCode(i>0?"A".charCodeAt(0)+(B+U):"A".charCodeAt(0)+U);var W=new google.maps.LatLng(w[U].lat,w[U].lng);u=F.createMarker(W,w[U].name,w[U].address,V,R,w[U].category),u.set("id",U),y[U]=u,(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&A.extend(W),F.createInfowindow(u,null,S,B,i)}(F.settings.fullMapStart===!0&&t===!0||0===F.settings.mapSettings.zoom||"undefined"==typeof p)&&R.fitBounds(A);var X=a("."+F.settings.locationList+" ul");X.empty(),0===w[0].lat&&0===w[0].lng?X.append(E):a(y).each(function(a){var b=y[a];F.listSetup(b,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];F.settings.callbackListClick&&F.settings.callbackListClick.call(this,b,c),a("."+F.settings.locationList+" li").removeClass("list-focus"),a("."+F.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),R.panTo(c.getPosition());var d="left";F.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),F.createInfowindow(c,d,S,B,i)},700)):F.createInfowindow(c,d,S,B,i)}),a(c).on("click."+f,"."+F.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+F.settings.locationList+" ul li:even").css("background",F.settings.listColor1),a("."+F.settings.locationList+" ul li:odd").css("background",F.settings.listColor2),F.settings.visibleMarkersList===!0&&(google.maps.event.addListenerOnce(R,"idle",function(){F.checkVisibleMarkers(y,R)}),google.maps.event.addListener(R,"center_changed",function(){F.checkVisibleMarkers(y,R)}),google.maps.event.addListener(R,"zoom_changed",function(){F.checkVisibleMarkers(y,R)})),F.settings.modal===!0&&F.settings.callbackModalReady&&F.settings.callbackModalReady.call(this),F.settings.callbackFilters&&F.settings.callbackFilters.call(this,z)}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){"use strict";function e(b,c){g=a(b),this.element=b,this.settings=a.extend({},D,c),this._defaults=D,this._name=f,this.init()}var f="storeLocator";if("undefined"==typeof a.fn[f]){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[],w=[],x=[],y=[],z={},A={},B={},C={},D={mapID:"bh-sl-map",locationList:"bh-sl-loc-list",formContainer:"bh-sl-form-container",formID:"bh-sl-user-location",addressID:"bh-sl-address",regionID:"bh-sl-region",mapSettings:{zoom:12,mapTypeId:google.maps.MapTypeId.ROADMAP},markerImg:null,markerDim:null,catMarkers:null,lengthUnit:"m",storeLimit:26,distanceAlert:60,dataType:"xml",dataLocation:"data/locations.xml",dataRaw:null,xmlElement:"marker",listColor1:"#ffffff",listColor2:"#eeeeee",originMarker:!1,originMarkerImg:null,originMarkerDim:null,bounceMarker:!0,slideMap:!0,modal:!1,overlay:"bh-sl-overlay",modalWindow:"bh-sl-modal-window",modalContent:"bh-sl-modal-content",closeIcon:"bh-sl-close-icon",defaultLoc:!1,defaultLat:null,defaultLng:null,autoGeocode:!1,maxDistance:!1,maxDistanceID:"bh-sl-maxdistance",fullMapStart:!1,noForm:!1,loading:!1,loadingContainer:"bh-sl-loading",featuredLocations:!1,pagination:!1,locationsPerPage:10,inlineDirections:!1,nameSearch:!1,searchID:"bh-sl-search",nameAttribute:"name",visibleMarkersList:!1,infowindowTemplatePath:"assets/js/plugins/storeLocator/templates/infowindow-description.html",listTemplatePath:"assets/js/plugins/storeLocator/templates/location-list-description.html",KMLinfowindowTemplatePath:"assets/js/plugins/storeLocator/templates/kml-infowindow-description.html",KMLlistTemplatePath:"assets/js/plugins/storeLocator/templates/kml-location-list-description.html",listTemplateID:null,infowindowTemplateID:null,taxonomyFilters:null,taxonomyFiltersContainer:"bh-sl-filters-container",exclusiveFiltering:!1,querystringParams:!1,callbackNotify:null,callbackBeforeSend:null,callbackSuccess:null,callbackModalOpen:null,callbackModalReady:null,callbackModalClose:null,callbackJsonp:null,callbackPageChange:null,callbackDirectionsRequest:null,callbackCloseDirections:null,callbackNoResults:null,callbackListClick:null,callbackMarkerClick:null,callbackFilters:null,addressErrorAlert:"Unable to find address",autoGeocodeErrorAlert:"Automatic location detection failed. Please fill in your address or zip code.",distanceErrorAlert:"Unfortunately, our closest location is more than ",mileLang:"mile",milesLang:"miles",kilometerLang:"kilometer",kilometersLang:"kilometers",noResultsTitle:"No results",noResultsDesc:"No locations were found with the given criteria. Please modify your selections or input.",nextPage:"Next »",prevPage:"« Prev"};a.extend(e.prototype,{init:function(){B.EarthRadius="km"===this.settings.lengthUnit?6367:3956,j="kml"===this.settings.dataType?"xml":this.settings.dataType,this.settings.inlineDirections===!0&&(t=new google.maps.DirectionsRenderer,u=new google.maps.DirectionsService,a("."+this.settings.locationList).prepend('
      ')),m=this.settings.mapSettings.zoom,Handlebars.registerHelper("niceURL",function(a){return a?a.replace("https://","").replace("http://",""):void 0}),null!==this.settings.taxonomyFilters&&this.taxonomyFiltering(),this.settings.modal===!0&&(null!==this.settings.taxonomyFilters&&a("."+this.settings.taxonomyFiltersContainer).clone(!0,!0).prependTo(g),g.wrap('
      '),a("."+this.settings.modalWindow).prepend('
      '),a("."+this.settings.overlay).hide()),this._loadTemplates()},destroy:function(){this.reset();var b=a("#"+this.settings.mapID);if(y.length)for(var d=0;d<=y.length;d++)google.maps.event.removeListener(y[d]);a("."+this.settings.locationList+" ul").empty(),b.hasClass("bh-sl-map-open")&&b.empty().removeClass("bh-sl-map-open"),this.settings.modal===!0&&a(". "+this.settings.overlay).remove(),b.attr("style",""),g.hide(),a.removeData(g.get(0)),a(c).off(f),g.unbind()},reset:function(){w=[],v=[],x=[],y=[],a(c).off("click."+f,"."+this.settings.locationList+" li"),a("."+this.settings.locationList+" .bh-sl-close-directions-container").length&&a(".bh-sl-close-directions-container").remove()},notify:function(a){this.settings.callbackNotify?this.settings.callbackNotify.call(this,a):alert(a)},geoCodeCalcToRadian:function(a){return a*(Math.PI/180)},geoCodeCalcDiffRadian:function(a,b){return this.geoCodeCalcToRadian(b)-this.geoCodeCalcToRadian(a)},geoCodeCalcCalcDistance:function(a,b,c,d,e){return 2*e*Math.asin(Math.min(1,Math.sqrt(Math.pow(Math.sin(this.geoCodeCalcDiffRadian(a,c)/2),2)+Math.cos(this.geoCodeCalcToRadian(a))*Math.cos(this.geoCodeCalcToRadian(c))*Math.pow(Math.sin(this.geoCodeCalcDiffRadian(b,d)/2),2))))},getQueryString:function(a){if(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}},_loadTemplates:function(){var b,c=this,d='
      Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.
      ';"kml"===this.settings.dataType&&null===this.settings.listTemplateID&&null===this.settings.infowindowTemplateID?a.when(a.get(this.settings.KMLinfowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.KMLlistTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")}):null!==this.settings.listTemplateID&&null!==this.settings.infowindowTemplateID?(i=Handlebars.compile(a("#"+this.settings.infowindowTemplateID).html()),h=Handlebars.compile(a("#"+this.settings.listTemplateID).html()),c.locator()):a.when(a.get(this.settings.infowindowTemplatePath,function(a){b=a,i=Handlebars.compile(b)}),a.get(this.settings.listTemplatePath,function(a){b=a,h=Handlebars.compile(b)})).then(function(){c.locator()},function(){throw a("."+c.settings.formContainer).append(d),new Error("Could not load storeLocator plugin templates")})},locator:function(){this.settings.slideMap===!0&&g.hide(),this._start(),this._formEventHandler()},_formEventHandler:function(){var b=this;this.settings.noForm===!0?(a(c).on("click."+f,"."+this.settings.formContainer+" button",function(a){b.processForm(a)}),a(c).on("keyup."+f,function(c){13===c.keyCode&&a("#"+b.settings.addressID).is(":focus")&&b.processForm(c)})):a(c).on("submit."+f,"#"+this.settings.formID,function(a){b.processForm(a)})},_getData:function(b,c,d){var e=this;if(this.settings.callbackBeforeSend&&this.settings.callbackBeforeSend.call(this,b,c,d),null===e.settings.dataRaw){var f=a.Deferred();return this.settings.loading===!0&&a("."+this.settings.formContainer).append('
      '),a.ajax({type:"GET",url:this.settings.dataLocation+("jsonp"===this.settings.dataType?(this.settings.dataLocation.match(/\?/)?"&":"?")+"callback=?":""),data:{origLat:b,origLng:c,origAddress:d},dataType:j,jsonpCallback:"jsonp"===this.settings.dataType?this.settings.callbackJsonp:null}).done(function(b){f.resolve(b),e.settings.loading===!0&&a("."+e.settings.formContainer+" ."+e.settings.loadingContainer).remove()}).fail(f.reject),f.promise()}return"xml"===j?a.parseXML(e.settings.dataRaw):"json"===j?a.parseJSON(e.settings.dataRaw):void 0},_start:function(){var a=this;if(this.settings.defaultLoc===!0){var b=new this.reverseGoogleGeocode(this),c=new google.maps.LatLng(this.settings.defaultLat,this.settings.defaultLng);b.geocode({latLng:c},function(b){if(null!==b){var c=b.address;C.lat=a.settings.defaultLat,C.lng=a.settings.defaultLng,C.origin=c,a.mapping(C)}else a.notify(a.settings.addressErrorAlert)})}this.settings.fullMapStart===!0&&(this.settings.querystringParams===!0&&this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID)?this.processForm(null):this.mapping(null)),this.settings.autoGeocode===!0&&navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(b){a.autoGeocodeQuery(b)},function(b){a._autoGeocodeError(b)})},googleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Geocode was not successful for the following reason: "+b);var d={};d.latitude=a[0].geometry.location.lat(),d.longitude=a[0].geometry.location.lng(),c(d)})}},reverseGoogleGeocode:function(a){var b=new google.maps.Geocoder;this.geocode=function(a,c){b.geocode(a,function(a,b){if(b!==google.maps.GeocoderStatus.OK)throw c(null),new Error("Reverse geocode was not successful for the following reason: "+b);if(a[0]){var d={};d.address=a[0].formatted_address,c(d)}})}},roundNumber:function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},hasEmptyObjectVals:function(a){var b=!0;for(var c in a)a.hasOwnProperty(c)&&""!==a[c]&&0!==a[c].length&&(b=!1);return b},modalClose:function(){this.settings.callbackModalClose&&this.settings.callbackModalClose.call(this),z={},a("."+this.settings.overlay+" select").prop("selectedIndex",0),a("."+this.settings.overlay+" input").prop("checked",!1),a("."+this.settings.overlay).hide()},_createLocationVariables:function(a){var b;for(var c in w[a])w[a].hasOwnProperty(c)&&(b=w[a][c],"distance"===c&&(b=this.roundNumber(b,2)),A[c]=b)},sortNumerically:function(a){a.sort(function(a,b){return a.distanceb.distance?1:0})},filterData:function(a,b){var c=!0;for(var d in b)if(b.hasOwnProperty(d))if(this.settings.exclusiveFiltering===!0){for(var e=b[d],f=[],g=0;g0&&(c+='
    • '+this.settings.prevPage+"
    • ");for(var f=0;f'+g+"":'
    • '+g+"
    • "}return b>d&&(c+='
    • '+this.settings.nextPage+"
    • "),c},paginationSetup:function(b){var c="",d=w.length/this.settings.locationsPerPage,e=a(".bh-sl-pagination-container .bh-sl-pagination");"undefined"==typeof b&&(b=0),0===e.length?c=this._paginationOutput(b,d):(e.empty(),c=this._paginationOutput(b,d)),e.append(c)},markerImage:function(a,b,c){var d;return d="undefined"!=typeof b&&"undefined"!=typeof c?{url:a,size:new google.maps.Size(b,c),scaledSize:new google.maps.Size(b,c)}:{url:a,size:new google.maps.Size(32,32),scaledSize:new google.maps.Size(32,32)}},createMarker:function(a,b,c,d,e,f){var g,h,i,j=[];if("undefined"!=typeof f&&f.length&&(f=f.replace(/\s+/g,"")),null!==this.settings.catMarkers)if(-1!==f.indexOf(",")){j=f.split(",");for(var k=0;k26||null!==this.settings.catMarkers||null!==this.settings.markerImg?g=new google.maps.Marker({position:a,map:e,draggable:!1,icon:h}):(i={url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text="+d+"&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48"},g=new google.maps.Marker({position:a,map:e,icon:i,draggable:!1})),g},_defineLocationData:function(b,c,d){var e="";this._createLocationVariables(b.get("id"));var f;f=A.distance<=1?"km"===this.settings.lengthUnit?this.settings.kilometerLang:this.settings.mileLang:"km"===this.settings.lengthUnit?this.settings.kilometersLang:this.settings.milesLang;var g=b.get("id");return e=-1===this.settings.storeLimit||this.settings.storeLimit>26?g+1:String.fromCharCode(d>0?"A".charCodeAt(0)+(c+g):"A".charCodeAt(0)+g),{location:[a.extend(A,{markerid:g,marker:e,length:f,origin:p})]}},listSetup:function(b,c,d){var e=this._defineLocationData(b,c,d),f=h(e);a("."+this.settings.locationList+" ul").append(f)},createInfowindow:function(b,c,d,e,f){var g=this,h=this._defineLocationData(b,e,f),j=i(h);"left"===c?(d.setContent(j),d.open(b.get("map"),b)):google.maps.event.addListener(b,"click",function(){d.setContent(j),d.open(b.get("map"),b);var c=b.get("id"),e=a("."+g.settings.locationList+" li[data-markerid="+c+"]");g.settings.callbackMarkerClick&&g.settings.callbackMarkerClick.call(this,b,c,e),a("."+g.settings.locationList+" li").removeClass("list-focus"),e.addClass("list-focus");var f=a("."+g.settings.locationList);f.animate({scrollTop:e.offset().top-f.offset().top+f.scrollTop()})})},autoGeocodeQuery:function(a){var b=this,c={},d=new this.reverseGoogleGeocode(this),e=new google.maps.LatLng(a.coords.latitude,a.coords.longitude);d.geocode({latLng:e},function(d){if(null!==d){var e=d.address;q=c.lat=a.coords.latitude,r=c.lng=a.coords.longitude,c.origin=e,b.mapping(c)}else b.notify(b.settings.addressErrorAlert)})},_autoGeocodeError:function(){this.notify(this.settings.autoGeocodeErrorAlert)},paginationChange:function(a){this.settings.callbackPageChange&&this.settings.callbackPageChange.call(this,a),C.page=a,this.mapping(C)},getAddressByMarker:function(a){var b=null;return w[a].address&&(b+=w[a].address+" "),w[a].address2&&(b+=w[a].address2+" "),w[a].city&&(b+=w[a].city+", "),w[a].state&&(b+=w[a].state+" "),w[a].postal&&(b+=w[a].postal+" "),w[a].country&&(b+=w[a].country+" "),b},clearMarkers:function(){for(var a=0;a
      ')}a(c).off("click","."+this.settings.locationList+" li .loc-directions a")},closeDirections:function(){this.settings.callbackCloseDirections&&this.settings.callbackCloseDirections.call(this),a("."+this.settings.locationList+" .adp").remove(),a("."+this.settings.locationList+" ul").fadeIn(),this.reset(),q&&r&&(this.settings.mapSettings.zoom=0===this.countFilters()?m:0,this.processForm(null)),a(c).off("click."+f,"."+this.settings.locationList+" .bh-sl-close-icon")},processForm:function(b){var c=this,d=null;"undefined"!=typeof b&&null!==b&&b.preventDefault(),this.settings.maxDistance===!0&&(d=a("#"+this.settings.maxDistanceID).val()),this.settings.querystringParams===!0&&(this.getQueryString(this.settings.addressID)||this.getQueryString(this.settings.searchID))?(p=this.getQueryString(this.settings.addressID),o=this.getQueryString(this.settings.searchID)):(p=a("#"+this.settings.addressID).val(),o=a("#"+this.settings.searchID).val());var e=a("#"+this.settings.regionID).val();if(""===p&&""===o)this._start();else if(""!==p){var f=new this.googleGeocode(this);f.geocode({address:p,region:e},function(a){null!==a?(q=a.latitude,r=a.longitude,C.lat=q,C.lng=r,C.origin=p,C.name=o,C.distance=d,c.mapping(C)):c.notify(c.settings.addressErrorAlert)})}else""!==o&&(C.name=o,c.mapping(C))},locationsSetup:function(a,b,c,d,e,f){if("undefined"!=typeof e&&(a.distance||(a.distance=this.geoCodeCalcCalcDistance(b,c,a.lat,a.lng,B.EarthRadius))),this.settings.maxDistance===!0&&d!==!0&&"undefined"!=typeof f&&null!==f){if(!(a.distance-1&&(z[f].splice(g,1),a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0===b.countFilters()?m:0,b.processForm()):b.mapping(C)))}}else(a(this).is("select")||a(this).is('input[type="radio"]'))&&(b.checkFilters(),d=a(this).val(),e=a(this).closest(".bh-sl-filters").attr("id"),f=b.getFilterKey(e),d?f&&(z[f]=[d],a("#"+b.settings.mapID).hasClass("bh-sl-map-open")===!0&&(q&&r?(b.settings.mapSettings.zoom=0,b.processForm()):b.mapping(C))):(f&&(z[f]=[]),b.reset(),q&&r?(b.settings.mapSettings.zoom=m,b.processForm()):b.mapping(C)))})},checkVisibleMarkers:function(b,c){var d,e,f=this;a("."+this.settings.locationList+" ul").empty(),a(b).each(function(b,g){c.getBounds().contains(g.getPosition())&&(f.listSetup(g,0,0),e=h(d),a("."+f.settings.locationList+" ul").append(e))})},mapping:function(a){var b,c,d,e,f,g=this;this.isEmptyObject(a)||(b=a.lat,c=a.lng,d=a.origin,f=a.page),"undefined"==typeof f&&(f=0),"undefined"==typeof d&&this.settings.nameSearch===!0?n=g._getData():(e=new google.maps.LatLng(b,c),"undefined"!=typeof k&&d===k&&"undefined"!=typeof l?(d=k,n=l):n=g._getData(q,r,d)),null!==g.settings.taxonomyFilters&&g.hasEmptyObjectVals(z)&&g.checkFilters(),null!==g.settings.dataRaw?g.processData(a,e,n,f):n.done(function(b){g.processData(a,e,b,f)})},processData:function(d,e,h,i){var j,m,p,q,r,t,u,A,B,C,D,E,F,G=this,H=0;this.isEmptyObject(d)||(j=d.lat,m=d.lng,p=d.origin,q=d.name,r=d.distance);var I=a("#"+G.settings.mapID),J="km"===G.settings.lengthUnit?G.settings.kilometersLang:G.settings.milesLang;if(l=n,k=p,G.settings.callbackSuccess&&G.settings.callbackSuccess.call(this),G.settings.fullMapStart===!0&&I.hasClass("bh-sl-map-open")===!1?t=!0:G.reset(),I.addClass("bh-sl-map-open"),"json"===G.settings.dataType||"jsonp"===G.settings.dataType)for(var K=0;H0)for(var Q=0;Q
      '+G.settings.noResultsTitle+'

      '+G.settings.noResultsDesc+"").hide().fadeIn(),w[0]={distance:0,lat:0,lng:0}),"undefined"!=typeof p&&G.sortNumerically(w),G.settings.featuredLocations===!0&&(v=a.grep(w,function(a){return"true"===a.featured}),x=a.grep(w,function(a){return"true"!==a.featured}),w=[],w=v.concat(x)),G.settings.maxDistance===!0&&t!==!0&&r){if("undefined"==typeof w[0]||w[0].distance>r)return void G.notify(G.settings.distanceErrorAlert+r+" "+J)}else-1!==G.settings.distanceAlert&&w[0].distance>G.settings.distanceAlert&&(G.notify(G.settings.distanceErrorAlert+G.settings.distanceAlert+" "+J),F=!0);if(G.settings.pagination===!0&&G.paginationSetup(i),G.settings.slideMap===!0&&g.slideDown(),G.settings.modal===!0&&(G.settings.callbackModalOpen&&G.settings.callbackModalOpen.call(this),a("."+G.settings.overlay).fadeIn(),a(c).on("click."+f,"."+G.settings.closeIcon+", ."+G.settings.overlay,function(){G.modalClose()}),a(c).on("click."+f,"."+G.settings.modalWindow,function(a){a.stopPropagation()}),a(c).on("keyup."+f,function(a){27===a.keyCode&&G.modalClose()})),s=-1===G.settings.storeLimit||w.lengthw.length&&(C=G.settings.locationsPerPage-(B+C-w.length)),w=w.slice(B,B+C),s=w.length):(C=s,B=0),G.settings.fullMapStart===!0&&t===!0||0===G.settings.mapSettings.zoom||"undefined"==typeof p||F===!0)D=G.settings.mapSettings,A=new google.maps.LatLngBounds;else if(G.settings.pagination===!0){var R=new google.maps.LatLng(w[0].lat,w[0].lng);0===i?(G.settings.mapSettings.center=e,D=G.settings.mapSettings):(G.settings.mapSettings.center=R,D=G.settings.mapSettings)}else G.settings.mapSettings.center=e,D=G.settings.mapSettings;var S=new google.maps.Map(c.getElementById(G.settings.mapID),D);google.maps.event.addDomListener(b,"resize",function(){var a=S.getCenter();google.maps.event.trigger(S,"resize"),S.setCenter(a)}),g.data(G.settings.mapID.replace("#",""),S);var T=new google.maps.InfoWindow;if(G.settings.originMarker===!0){var U="";if(G.settings.fullMapStart===!1&&t===!0)return;U=null!==G.settings.originMarkerImg?null===G.settings.originMarkerDim?G.markerImage(G.settings.originMarkerImg):G.markerImage(G.settings.originMarkerImg,G.settings.originMarkerDim.width,G.settings.originMarkerDim.height):{url:"https://mt.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png"},u=new google.maps.Marker({position:e,map:S,icon:U,draggable:!1})}a(c).on("click."+f,".bh-sl-pagination li",function(){G.paginationChange(a(this).attr("data-page"))}),G.settings.inlineDirections===!0&&"undefined"!=typeof p&&(a(c).on("click."+f,"."+G.settings.locationList+" li .loc-directions a",function(b){b.preventDefault();var c=a(this).closest("li").attr("data-markerid");G.directionsRequest(p,c,S)}),a(c).on("click."+f,"."+G.settings.locationList+" .bh-sl-close-icon",function(){G.closeDirections()}));for(var V=0;C-1>=V;V++){var W="";W=String.fromCharCode(i>0?"A".charCodeAt(0)+(B+V):"A".charCodeAt(0)+V);var X=new google.maps.LatLng(w[V].lat,w[V].lng);u=G.createMarker(X,w[V].name,w[V].address,W,S,w[V].category),u.set("id",V),y[V]=u,(G.settings.fullMapStart===!0&&t===!0||0===G.settings.mapSettings.zoom||"undefined"==typeof p||F===!0)&&A.extend(X),G.createInfowindow(u,null,T,B,i)}(G.settings.fullMapStart===!0&&t===!0||0===G.settings.mapSettings.zoom||"undefined"==typeof p||F===!0)&&S.fitBounds(A);var Y=a("."+G.settings.locationList+" ul");Y.empty(),0===w[0].lat&&0===w[0].lng?Y.append(E):a(y).each(function(a){var b=y[a];G.listSetup(b,B,i)}),a(c).on("click."+f,"."+G.settings.locationList+" li",function(){var b=a(this).data("markerid"),c=y[b];G.settings.callbackListClick&&G.settings.callbackListClick.call(this,b,c),a("."+G.settings.locationList+" li").removeClass("list-focus"),a("."+G.settings.locationList+" li[data-markerid="+b+"]").addClass("list-focus"),S.panTo(c.getPosition());var d="left";G.settings.bounceMarker===!0?(c.setAnimation(google.maps.Animation.BOUNCE),setTimeout(function(){c.setAnimation(null),G.createInfowindow(c,d,T,B,i)},700)):G.createInfowindow(c,d,T,B,i)}),a(c).on("click."+f,"."+G.settings.locationList+" li a",function(a){a.stopPropagation()}),a("."+G.settings.locationList+" ul li:even").css("background",G.settings.listColor1),a("."+G.settings.locationList+" ul li:odd").css("background",G.settings.listColor2),G.settings.visibleMarkersList===!0&&(google.maps.event.addListenerOnce(S,"idle",function(){G.checkVisibleMarkers(y,S)}),google.maps.event.addListener(S,"center_changed",function(){G.checkVisibleMarkers(y,S)}),google.maps.event.addListener(S,"zoom_changed",function(){G.checkVisibleMarkers(y,S)})),G.settings.modal===!0&&G.settings.callbackModalReady&&G.settings.callbackModalReady.call(this),G.settings.callbackFilters&&G.settings.callbackFilters.call(this,z)}}),a.fn[f]=function(b){var c=arguments;if(b===d||"object"==typeof b)return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))});if("string"==typeof b&&"_"!==b[0]&&"init"!==b){var g;return this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&(g=d[b].apply(d,Array.prototype.slice.call(c,1))),"destroy"===b&&a.data(this,"plugin_"+f,null)}),g!==d?g:this}}}}(jQuery,window,document); \ No newline at end of file diff --git a/readme.md b/readme.md index 2adc212..4c9adaf 100644 --- a/readme.md +++ b/readme.md @@ -30,7 +30,13 @@ for even faster loading. ### Version 2.0.6 * Added the option to filter data exclusively rather than inclusively with the exclusiveFiltering setting. -* Added callbackFilters that fires when a filter is changed and can return the filter values. +* Added callbackFilters that fires when a filter is changed and returns the filter values if needed. +* Added dataRaw option to use raw KML, XML or JSON data instead of the AJAX call. +* Added basic raw data example rawdata-example.php file. +* Added visibleMarkersList option that updates the location list to only display data from the markers that are curently +displayed on the map. +* Changed the distance error functionality so that the map centers and zooms automatically and all locations are +displayed on the map. * Fixed issue with fullMapStart and inlineDirections setting combination. * Fixed issue with global olat and olng variables not being set with autoGeocode setting enabled. * Fixed issue with maxDistance and autoGeocode setting combination. diff --git a/src/js/jquery.storelocator.js b/src/js/jquery.storelocator.js index a5aebd6..9027944 100644 --- a/src/js/jquery.storelocator.js +++ b/src/js/jquery.storelocator.js @@ -1537,7 +1537,7 @@ processData: function (mappingObject, originPoint, data, page) { var _this = this; var i = 0; - var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults; + var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError; if (!this.isEmptyObject(mappingObject)) { orig_lat = mappingObject.lat; orig_lng = mappingObject.lng; @@ -1707,6 +1707,7 @@ else { if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) { _this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit); + distError = true; } } @@ -1771,7 +1772,7 @@ } // Google maps settings - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) { myOptions = _this.settings.mapSettings; bounds = new google.maps.LatLngBounds(); } @@ -1796,7 +1797,7 @@ // Create the map var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions); - // Re-center the map when the browser is resized + // Re-center the map when the browser is re-sized google.maps.event.addDomListener(window, 'resize', function() { var center = map.getCenter(); google.maps.event.trigger(map, 'resize'); @@ -1877,15 +1878,15 @@ marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category); marker.set('id', y); markers[y] = marker; - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) { bounds.extend(point); } // Pass variables to the pop-up infowindows _this.createInfowindow(marker, null, infowindow, storeStart, page); } - // Center and zoom if no origin or zoom was provided - if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) { + // Center and zoom if no origin or zoom was provided, or distance of first marker is greater than distanceAlert + if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) { map.fitBounds(bounds); } From 354572a6ae645bdf91e16d3b67c130f8c5f885cb Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Sat, 28 Mar 2015 23:39:34 -0500 Subject: [PATCH 8/9] Added additional tests --- .../storeLocator/jquery.storelocator.js | 2 +- .../storeLocator/jquery.storelocator.min.js | 2 +- test/storeLocator_test.js | 114 +++++++++++++++++- 3 files changed, 115 insertions(+), 3 deletions(-) diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js index fd60966..cc053f2 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.js @@ -1,4 +1,4 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-27 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-28 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ diff --git a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js index 96bdf72..72ad1c5 100644 --- a/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js +++ b/dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js @@ -1,4 +1,4 @@ -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-27 +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-28 * http://www.bjornblog.com/web/jquery-store-locator-plugin * Copyright (c) 2015 Bjorn Holine; Licensed MIT */ diff --git a/test/storeLocator_test.js b/test/storeLocator_test.js index 2622efd..d59a012 100644 --- a/test/storeLocator_test.js +++ b/test/storeLocator_test.js @@ -22,7 +22,7 @@ /** * This file contains very minimal testing. I may or may not do more extensive tests - - * more or lesss playing around with it for the frist time + * more or less playing around with it for the first time */ module('storeLocator', { @@ -105,6 +105,16 @@ }, 1000); }); + /** + * Round number + */ + test('roundNumber()', 2, function() { + var $this = $('#map-container').data('plugin_storeLocator'); + + deepEqual($this.roundNumber(2.345432, 0), 2, 'Round down test'); + deepEqual($this.roundNumber(2.694928, 0), 3, 'Round up test'); + }); + /** * Empty object test */ @@ -118,5 +128,107 @@ deepEqual($this.isEmptyObject(emptyObj), true, 'Empty object test'); deepEqual($this.isEmptyObject(nonEmptyObj), false, 'Empty object fail test'); }); + + /** + * Empty object values test + */ + test('hasEmptyObjectVals()', 3, function() { + var $this = $('#map-container').data('plugin_storeLocator'); + var emptyObj = {}; + var emptyObjVals = { + 'test1' : '', + 'test2' : '' + }; + var nonEmptyObj = { + 'test': 'testing' + }; + + deepEqual($this.hasEmptyObjectVals(emptyObj), true, 'Empty object test'); + deepEqual($this.hasEmptyObjectVals(emptyObjVals), true, 'Empty object vals test'); + deepEqual($this.hasEmptyObjectVals(nonEmptyObj), false, 'Empty object fail test'); + }); + + + /** + * Sort locations (array of objects) numerically by distance test + */ + test('sortNumerically()', 1, function() { + var $this = $('#map-container').data('plugin_storeLocator'); + var positiveTest = [ + { 'distance': 9 }, + { 'distance': 2 }, + { 'distance': 30 }, + { 'distance': 5 } + ]; + var positiveMatch = [ + { 'distance': 2 }, + { 'distance': 5 }, + { 'distance': 9 }, + { 'distance': 30 } + ]; + + $this.sortNumerically(positiveTest); + + deepEqual(positiveTest, positiveMatch, 'Positive test'); + }); + + /** + * Filter data test + */ + test('filterData()', 2, function() { + var filter, filters, locationset, locationMatch, locationsMatch, inclusiveTest, exclusiveTest; + var $this = $('#map-container').data('plugin_storeLocator'); + + // Single filter + filter = { + 'city': ['Minneapolis'] + }; + + // Multi-filter + filters = { + 'city': ['Minneapolis', 'St. Paul'] + }; + + locationset = [{ + 'city': 'St. Paul', + 'state': 'MN' + }, { + 'city': 'Des Moines', + 'state': 'IA' + }, { + 'city': 'Minneapolis', + 'state': 'MN' + }]; + + locationMatch = [{ + 'city': 'Minneapolis', + 'state': 'MN' + }]; + + locationsMatch = [{ + 'city': 'St. Paul', + 'state': 'MN' + }, { + 'city': 'Minneapolis', + 'state': 'MN' + }]; + + inclusiveTest = $.grep(locationset, function (val, i) { + return $this.filterData(val, filter); + }); + + // Inclusive test + deepEqual(inclusiveTest, locationMatch, 'Inclusive filtering test'); + + $this.settings.exclusiveFiltering = true; + + exclusiveTest = $.grep(locationset, function (val, i) { + return $this.filterData(val, filters); + }); + + // Exclusive test + deepEqual(exclusiveTest, locationsMatch, 'Exclusive filtering test'); + }); + }(jQuery)); From c10639e3abd8de80967c657a1498d24b48e3b31f Mon Sep 17 00:00:00 2001 From: Bjorn Holine Date: Sun, 29 Mar 2015 01:27:09 -0500 Subject: [PATCH 9/9] Updated jQuery version in demo files --- dist/autogeocode-example.html | 2 +- dist/bootstrap-example.html | 2 +- dist/categories-example.html | 2 +- dist/category-markers-example.html | 2 +- dist/default-location-example.html | 2 +- dist/geocode.html | 2 +- dist/index.html | 2 +- dist/inline-directions.html | 2 +- dist/json-example.html | 2 +- dist/kml-example.html | 2 +- dist/maxdistance-example.html | 2 +- dist/modal-example.html | 2 +- dist/namesearch-example.html | 2 +- dist/noform-example.html | 2 +- dist/pagination-example.html | 2 +- dist/rawdata-example.php | 2 +- test/storeLocator.html | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/dist/autogeocode-example.html b/dist/autogeocode-example.html index 853a15b..c5b315b 100755 --- a/dist/autogeocode-example.html +++ b/dist/autogeocode-example.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/bootstrap-example.html b/dist/bootstrap-example.html index 10caad3..be8827b 100644 --- a/dist/bootstrap-example.html +++ b/dist/bootstrap-example.html @@ -44,7 +44,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/categories-example.html b/dist/categories-example.html index c946b4a..1db40ea 100644 --- a/dist/categories-example.html +++ b/dist/categories-example.html @@ -120,7 +120,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/category-markers-example.html b/dist/category-markers-example.html index 6d4bd95..26d2fc6 100644 --- a/dist/category-markers-example.html +++ b/dist/category-markers-example.html @@ -35,7 +35,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/default-location-example.html b/dist/default-location-example.html index a06657d..8374186 100755 --- a/dist/default-location-example.html +++ b/dist/default-location-example.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/geocode.html b/dist/geocode.html index 2fc32bc..4400a06 100755 --- a/dist/geocode.html +++ b/dist/geocode.html @@ -36,7 +36,7 @@

      Simple geocoding form

      - + diff --git a/dist/index.html b/dist/index.html index e14129b..b6809d2 100755 --- a/dist/index.html +++ b/dist/index.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/inline-directions.html b/dist/inline-directions.html index f404885..3afde87 100644 --- a/dist/inline-directions.html +++ b/dist/inline-directions.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/json-example.html b/dist/json-example.html index 53a04a6..a54a0ae 100755 --- a/dist/json-example.html +++ b/dist/json-example.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/kml-example.html b/dist/kml-example.html index d3dc43f..62efabe 100755 --- a/dist/kml-example.html +++ b/dist/kml-example.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/maxdistance-example.html b/dist/maxdistance-example.html index c670fbb..cc82720 100755 --- a/dist/maxdistance-example.html +++ b/dist/maxdistance-example.html @@ -40,7 +40,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/modal-example.html b/dist/modal-example.html index 9cfd24e..74fb73f 100755 --- a/dist/modal-example.html +++ b/dist/modal-example.html @@ -34,7 +34,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/namesearch-example.html b/dist/namesearch-example.html index f67d063..55f7669 100644 --- a/dist/namesearch-example.html +++ b/dist/namesearch-example.html @@ -38,7 +38,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/noform-example.html b/dist/noform-example.html index b25c8ee..91301d2 100755 --- a/dist/noform-example.html +++ b/dist/noform-example.html @@ -31,7 +31,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/pagination-example.html b/dist/pagination-example.html index 0cd8d41..363ec94 100644 --- a/dist/pagination-example.html +++ b/dist/pagination-example.html @@ -38,7 +38,7 @@

      Using Chipotle as an Example

      - + diff --git a/dist/rawdata-example.php b/dist/rawdata-example.php index e6f4e04..e2d5bb8 100644 --- a/dist/rawdata-example.php +++ b/dist/rawdata-example.php @@ -63,7 +63,7 @@
      - + diff --git a/test/storeLocator.html b/test/storeLocator.html index 9a75634..cc8e4b6 100644 --- a/test/storeLocator.html +++ b/test/storeLocator.html @@ -4,7 +4,7 @@ jQuery Google Maps Store Locator Plugin Test Suite - +