PageSourceSearch

https://www.fmgbrakes.com/wp-content/plugins/wordpress-store-locat…/js/wordpress-store-locator-public.js

js fmgbrakes.com collected 2026-10-06 08:53:19 UTC 54,071 bytes, 1,538 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4	// Create the defaults once
5	var pluginName = "storeLocator",
6		defaults = {
7			store_locator: '#store_locator',
8			store_modal: "#store_modal",
9			store_modal_button: "#store_modal_button",
10			store_modal_close: "#store_modal_close",
11			map_container: "#store_locator_map",
12			map_min_height: 300,
13			store_locator_sidebar: '#store_locator_sidebar',
14			result_list: "#store_locator_result_list",
15			store_locator_address_field: '#store_locator_address_field',
16			store_locator_find_stores_button: '#store_locator_find_stores_button',
17			store_locator_loading: '#store_locator_loading',
18			store_locator_filter_radius: '#store_locator_filter_radius',
19			store_locator_filter_categories: '#store_locator_filter_categories',
20			store_locator_filter: '#store_locator_filter',
21			store_locator_filter_active_filter: '#store_locator_filter_active_filter',
22			store_locator_filter_open_close: '#store_locator_filter_open_close',
23			store_locator_filter_content: '#store_locator_filter_content',
24			store_locator_filter_checkbox: '.store_locator_filter_checkbox',
25
26			store_locator_form_customer_address: 'input[name="store_locator_form_customer_address"]',
27			store_locator_form_store_select: 'select[name="store_locator_form_store_select"]',
28
29			store_locator_embedded_search: '#store_locator_embedded_search',
30
31			store_locator_get_my_position: '#store_locator_get_my_position',
32			store_locator_get_all_stores: '#store_locator_get_all_stores',
33			store_locator_dragged_button: '#store_locator_dragged_button',
34			store_locator_category_icon: '',
35			earthRadi: {
36				mi: 3963.1676,
37				km: 6378.1,
38				ft: 20925524.9,
39				mt: 6378100,
40				"in": 251106299,
41				yd: 6975174.98,
42				fa: 3487587.49,
43				na: 3443.89849,
44				ch: 317053.408,
45				rd: 1268213.63,
46				fr: 31705.3408
47			},
48		};
49
50	// The actual plugin constructor
51	function Plugin ( element, options ) {
52		this.element = element;
53		this.settings = $.extend( {}, defaults, options );
54		this._defaults = defaults;
55
56		this._name = pluginName;
57		this.init();
58	}
59
60	// Avoid Plugin.prototype conflicts
61	$.extend( Plugin.prototype, {
62		init: function() {
63			var that = this;
64			this.window = $(window);
65			this.currentURL = window.location.href.split('?')[0];
66			this.documentHeight = $( document ).height();
67			this.windowHeight = this.window.height();
68			this.settings.mapDefaultZoom = parseInt(that.settings.mapDefaultZoom);
69			this.templateCache = {};
70			this.markers = [];
71			this.ownMarker = {};
72			this.radiusCircle = {};
73			this.categories = {};
74			this.filter = {};
75			this.address = "";
76
77			this.geocoder = new google.maps.Geocoder();
78
79			if(!this.isEmpty($(this.settings.store_locator))){
80				this.setResultListMaxHeight();
81
82				// Check if we have a Modal Button (Product Page)
83				if(!this.isEmpty($(this.settings.store_modal_button))){
84					this.initModal(function(){
85						that.initStoreLocator();
86						that.setResultListMaxHeight();
87					});
88				} else {
89					$(this.settings.store_modal_close).hide();
90					that.initStoreLocator();
91				}
92			}
93			if(!this.isEmpty($(this.settings.store_locator_form_store_select))){
94				that.initForm();
95			}
96			if(!this.isEmpty($(this.settings.store_locator_embedded_search))){
97				that.initEmbeddedSearch();
98			}
99
100		},
101		setResultListMaxHeight: function() {
102			var resultList = $(this.settings.result_list);
103			var store_locator_sidebar = $(this.settings.store_locator_sidebar);
104			var height = store_locator_sidebar.height() + 100;
105
106			resultList.css('max-height', height);
107		},
108		initModal: function(callback) {
109			var store_modal = $(this.settings.store_modal);
110			var store_modal_button = $(this.settings.store_modal_button);
111			var store_modal_close = $(this.settings.store_modal_close);
112			var that = this;
113
114		    store_modal_button.on('click', function()
115		    {
116		    	store_modal.show();
117			    store_modal.modal('show');
118			    callback();
119		    });
120
121		    store_modal_close.on('click', function()
122		    {
123		    	store_modal.hide();
124		    	$('.modal-backdrop').remove();
125			    store_modal.modal('hide');
126		    });
127		},
128		initStoreLocator: function() {
129			var that = this;
130
131			// Do not load Map again when Modal gets reopened
132			if(that.isEmpty(that.map)){
133				that.initMap(function(){
134					if(that.settings.searchBoxAutocomplete === "1") {
135						that.initAutocomplete();
136					}
137				    that.initStoreLocatorButton();
138				    that.initGetCurrentPositionLink();
139				    that.initGetAllStoresLink();
140				    that.autoHeightMap();
141				    that.watchMapDragged();
142				    that.watchAddressFieldEmpty();
143				    that.watchDraggedButton();
144
145				    that.initFilter();
146					if(that.settings.searchBoxAutolocate === "1") {
147						if(that.settings.searchBoxSaveAutolocate === "1") {
148							that.getCurrentPosition();
149						} else {
150							that.getCurrentPosition(false);
151						}					 
152					} else {
153						var currentPosition = new google.maps.LatLng(Number(that.settings.mapDefaultLat), Number(that.settings.mapDefaultLng)); 
154						that.setCurrentPosition(currentPosition);
155					}		    
156				});
157			}
158		},
159		initMap: function(callback) {
160			var mapContainer = $(this.settings.map_container);
161		    var mapDefaultZoom = this.settings.mapDefaultZoom;
162		    var mapDefaultType = this.settings.mapDefaultType;
163		    var mapDefaultLat = Number(this.settings.mapDefaultLat);
164		    var mapDefaultLng = Number(this.settings.mapDefaultLng);
165
166		    var mapStyling = this.settings.mapStyling;
167		    if( !this.isEmpty(mapStyling) ) {
168		    	mapStyling = JSON.parse(mapStyling);
169		    } else {
170		    	mapStyling = "";
171		    }
172
173		    // Construct Map
174		   	this.map = new google.maps.Map(mapContainer[0], {
175				zoom: mapDefaultZoom,
176				center: new google.maps.LatLng(mapDefaultLat, mapDefaultLng),
177				mapTypeId: google.maps.MapTypeId[mapDefaultType],
178				scrollwheel: false,
179				styles: mapStyling
180		    });
181
182		    callback();
183		},
184		getCurrentPosition: function(useCookie) {
185			var that = this;
186
187			var ip_geoservice = "https://geoip.nekudo.com/api/";
188
189			var cookieLat = that.getCookie('store_locator_lat');
190			var cookieLng = that.getCookie('store_locator_lng');
191			var currentPosition;
192			if (typeof(useCookie)==='undefined') useCookie = true;
193
194			if(cookieLat !== "" && cookieLng !== "" && useCookie === true){
195				currentPosition = new google.maps.LatLng(cookieLat, cookieLng);
196			}
197
198			if(typeof(currentPosition) == "undefined") {
199				if (navigator.geolocation) {
200
201					var options = {
202					  enableHighAccuracy: true,
203					  timeout: 5000,
204					  maximumAge: 0
205					};
206
207					navigator.geolocation.getCurrentPosition(function(position) {
208					
209						var currentPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 
210						document.cookie="store_locator_lat="+position.coords.latitude;
211						document.cookie="store_locator_lng="+position.coords.longitude;
212						that.setCurrentPosition(currentPosition);
213					}, function(error) {
214						console.log(error);
215						console.log('Getting position via IP!');
216						$.getJSON(ip_geoservice)
217							.done(function( location ) {
218								var ipLat = location.location.latitude;
219								var ipLng = location.location.longitude;
220								if(ipLat == "" || ipLng == "") {
221									alert('Could not find your position. Please enter it manually.');
222									return;
223								}
224								var currentPosition = new google.maps.LatLng(ipLat, ipLng); 
225								document.cookie="store_locator_lat="+ipLat;
226								document.cookie="store_locator_lng="+ipLng;
227								that.setCurrentPosition(currentPosition);
228						});	
229					}, options);
230
231				} else {
232					console.log('Browser Geolocation not supported! Getting position via IP');
233
234					$.getJSON(ip_geoservice)
235						.done(function( location ) {
236							var currentPosition = new google.maps.LatLng(location.latitude, location.longitude); 
237							document.cookie="store_locator_lat="+location.latitude;
238							document.cookie="store_locator_lng="+location.longitude;
239							that.setCurrentPosition(currentPosition);
240					});				
241				}
242
243			} else {
244				that.setCurrentPosition(currentPosition);
245			}
246		},
247		setCurrentPosition: function(latlng) {
248			var that = this;
249			var store_locator_address_field = $(this.settings.store_locator_address_field);
250
251			this.currentPosition = latlng;
252			this.lat = latlng.lat();
253			this.lng = latlng.lng();
254
255			if(store_locator_address_field.val() === "") {
256
257				this.geocodeLatLng(function(address){
258					store_locator_address_field.val(address);
259				});
260			}
261
262			// Delete old marker
263			if(!this.isEmpty(this.ownMarker)) {
264				this.ownMarker.setMap(null);
265			}
266			
267			this.ownMarker = new google.maps.Marker({
268				position: latlng,
269				map: this.map,
270				title: 'Your Position!',
271				icon: this.settings.mapDefaultUserIcon
272			});
273
274			this.drawRadiusCircle(true);
275			this.getStores();
276
277		},
278		drawRadiusCircle: function(inital) {
279			var that = this;
280			var mapRadius;
281			var distanceUnit = this.settings.mapDistanceUnit;
282			var earthRadius = this.settings.earthRadi[distanceUnit];
283			var selectedRadius = $(this.settings.store_locator_filter_radius).find(":selected").val();
284
285			if(!this.isEmpty(selectedRadius)){
286				this.radius = parseFloat(selectedRadius);
287			} else {
288				this.radius = parseFloat(this.settings.mapRadius);
289			}
290
291			if(!this.isEmpty(this.radiusCircle) && typeof(this.radiusCircle.setMap) !== "undefined") {
292				this.radiusCircle.setMap(null);
293			}
294
295			if(this.settings.mapDrawRadiusCircle === "0"){
296				if(this.settings.mapRadiusToZoom === "1") {
297					this.map.setZoom(this.radiusToZoom(this.radius));
298				}
299				return false;
300			}
301
302			mapRadius = (this.radius / earthRadius) * this.settings.earthRadi.mt;
303			this.radiusCircle = new google.maps.Circle({
304				center: this.currentPosition,
305				clickable: true,
306				draggable: false,
307				editable: false,
308				fillColor: '#004de8',
309				fillOpacity: 0.27,
310				map: this.map,
311				radius: mapRadius,
312				strokeColor: '#004de8',
313				strokeOpacity: 0.62,
314				strokeWeight: 1
315			});
316
317			if(inital !== true) {
318				this.map.fitBounds(this.radiusCircle.getBounds());
319			}
320		},
321		initAutocomplete: function() {
322			var that = this;
323			var addressField = $(this.settings.store_locator_address_field);
324			var countryRestrict = this.settings.autocompleteCountryRestrict;
325			var type = this.settings.autocompleteType;
326			var map = this.map;
327			
328			if ( !addressField) { return; }
329
330			var autocompleteOptions = {};
331			if(!that.isEmpty(countryRestrict)) {
332				autocompleteOptions.componentRestrictions = {'country' : countryRestrict };
333			}
334
335			if(!that.isEmpty(type)) {
336				autocompleteOptions.types = [type];
337			} else {
338				autocompleteOptions.types = ['geocode'];
339			}
340
341			var autocomplete = new google.maps.places.Autocomplete(addressField[0], autocompleteOptions);
342			autocomplete.bindTo('bounds', map);
343
344			autocomplete.addListener('place_changed', function(e){
345				var place = autocomplete.getPlace();
346				if(!that.isEmpty(place.formatted_address)) {
347					that.geocodeAddress(place.formatted_address);
348				} else {
349					that.geocodeAddress(place.name);
350				}
351			});
352
353			var predefinedAddress = that.getParameterByName('location');
354			if(!that.isEmpty(predefinedAddress)) {
355				addressField.val(predefinedAddress);
356				that.geocodeAddress(predefinedAddress);
357			}
358		},
359		initStoreLocatorButton: function() {
360			var that = this;
361			var button = $(this.settings.store_locator_find_stores_button);
362			var addressField = $(this.settings.store_locator_address_field);
363			var currentAddress;
364
365			button.on('click', function(e) {
366				e.preventDefault();
367				currentAddress = addressField.val();
368				that.geocodeAddress(currentAddress);
369			});
370		},
371		watchAddressFieldEmpty : function() {
372			var that = this;
373			var address_field = $(that.settings.store_locator_address_field);
374
375			address_field.on('keyup', function(e) {
376				var $this = $(this);
377				var val = $this.val()
378				if(val == "") {
379					$this.css('border', '2px solid red');
380				} else {
381					$this.css('border', 'none');
382				}
383			});
384		},
385		initGetCurrentPositionLink: function() {
386			var that = this;
387			var store_locator_get_my_position = $(this.settings.store_locator_get_my_position);
388			
389			store_locator_get_my_position.on('click', function(e){
390				e.preventDefault();
391				that.getCurrentPosition(false);
392			});
393		},
394		initGetAllStoresLink: function() {
395			var that = this;
396			var store_locator_get_all_stores = $(this.settings.store_locator_get_all_stores);
397			
398			store_locator_get_all_stores.on('click', function(e){
399				e.preventDefault();
400				that.maybeShowLoading();
401				that.getAllStores('', '', function(response) {
402
403					if(!that.isEmpty(that.radiusCircle) && typeof(that.radiusCircle.setMap) !== "undefined") {
404						that.radiusCircle.setMap(null);
405					}
406					that.map.setZoom(parseInt(that.settings.searchBoxShowShowAllStoresZoom));
407					var allStoresPosition = new google.maps.LatLng(Number(that.settings.searchBoxShowShowAllStoresLat), Number(that.settings.searchBoxShowShowAllStoresLng)); 
408					that.map.setCenter(allStoresPosition);
409
410					that.createMarker(response);
411					that.createResultList(response);
412					that.maybeShowLoading();
413				});
414			});
415		},
416		maybeShowLoading: function() {
417			var store_locator_loading = $(this.settings.store_locator_loading);
418
419			if(store_locator_loading.hasClass('store-locator-hidden'))
420			{
421				store_locator_loading.removeClass('store-locator-hidden');
422			} else {
423				store_locator_loading.addClass('store-locator-hidden');
424			}
425		},
426		geocodeAddress: function (address) {
427			var that = this;
428
429			if ( address ) {
430				this.geocoder.geocode( { 'address': address }, function ( results, status ) {
431					if ( status === google.maps.GeocoderStatus.OK ) {
432						that.setCurrentPosition(results[0].geometry.location);
433					}
434				} );
435			} else {
436				$(that.settings.store_locator_address_field).css('border', '2px solid red');
437			}
438		},
439		geocodeLatLng: function (callback) {
440			var that = this;
441			var latlng = {lat: this.lat, lng: this.lng};
442
443			this.geocoder.geocode({'location': latlng}, function(results, status) {
444				if (status === google.maps.GeocoderStatus.OK) {
445					if (results[1]) {
446						callback(results[1].formatted_address);
447					} else {
448						window.alert('No results found');
449					}
450				} else {
451					window.alert('Geocoder failed due to: ' + status);
452				}
453			});
454		},
455		autoHeightMap: function() {
456
457			var mapContainer = $(this.settings.map_container);
458			var store_locator_sidebar = $(this.settings.store_locator_sidebar);
459		    var mapHeight = $(store_locator_sidebar).height();
460
461		    if(mapHeight < this.settings.map_min_height) {
462		    	mapHeight = this.settings.map_min_height;
463		    }
464
465		    mapContainer.css('height', mapHeight);
466		    google.maps.event.trigger(this.map, "resize");
467
468		},
469		getStores: function() {
470			var that = this;
471			that.maybeShowLoading();
472
473			jQuery.ajax({
474				url: that.settings.ajax_url,
475				type: 'post',
476				dataType: 'JSON',
477				data: {
478					action: 'get_stores',
479					lat: that.lat,
480					lng: that.lng,
481					radius: that.radius,
482					categories: that.categories,
483					filter: that.filter,
484				},
485				success : function( response ) {
486					that.createMarker(response);
487					that.createResultList(response);
488					that.maybeShowLoading();
489					if (window.history.replaceState) {
490						that.buildReplaceState();
491					}
492				},
493				error: function(jqXHR, textStatus, errorThrown) {
494				    that.maybeShowLoading();
495				    alert('An Error Occured: ' + jqXHR.status + ' ' + errorThrown + '! Please contact System Administrator!');
496				}
497			});
498		},
499		createMarker: function(stores) {
500			var that = this;
501		   	var storesLength = Object.keys(stores).length;
502		   	var store;
503		   	var i = 0;
504		   	var marker;
505		   	var map = this.map;
506		    var infowindow =  new google.maps.InfoWindow({
507		        content: ""
508		    });
509
510		    // Clean markers
511			while(this.markers.length){
512			    this.markers.pop().setMap(null);
513			}
514			// Create Markers
515			if(storesLength > 0) {
516				for (i; i < storesLength; i++) {  
517
518					store = stores[i];
519					store.map = this.map;
520					this.store = store;
521					store.position = new google.maps.LatLng(store.lat, store.lng);
522
523					if(!that.isEmpty(store.ic)) {
524						store.icon = store.ic;
525					} else if(!that.isEmpty(that.settings.store_locator_category_icon)) {
526						store.icon = that.settings.store_locator_category_icon;
527					} else {
528						store.icon = that.settings.mapDefaultIcon;
529					}
530
531					// Label?
532					// store.label = i.toString();
533				    marker = new google.maps.Marker(store);
534				    this.markers.push(marker);
535				    if(this.settings.infowindowEnabled === "1") {
536				    	this.createInfowindow(marker, map, infowindow, store);
537				    }
538				}
539			}
540		},
541		createInfowindow: function(marker, map, infowindow, store) {
542			var that = this;
543
544			var infowindowLinkAction = this.settings.infowindowLinkAction;
545			store.infowindowAction = store.gu;
546			if(infowindowLinkAction == "web") {
547				store.infowindowAction = store.we;
548			}
549			if(infowindowLinkAction == "tel") {
550				store.infowindowAction = 'tel:' + store.te;
551			}
552			if(infowindowLinkAction == "email") {
553				store.infowindowAction = 'mailto:' + store.em;
554			}
555
556			var content = '<div id="store_locator_infowindow_' + store.ID + '" class="store_locator_infowindow">' +
557								'<div class="store-locator-col-sm-' + that.settings.infowindowDetailsColumns + ' store_locator_details">';
558								if(this.settings.infowindowLinkAction !== "none") {
559									content += '<a href="' + store.infowindowAction + '">' +
560													'<h3 class="store_locator_name">' + store.na + ' <i class="fa fa-chevron-right"></i></h3>' +
561												'</a>';
562									
563								} else {
564									content += '<h3 class="store_locator_name">' + store.na + '</h3>';
565								}
566								content += !that.isEmpty(store.dc) ? '<span class="store_locator_distance">' + that.settings.showDistanceText + ': ' + store.dc + '<br/></span>' : '';
567								content += '<p class="store_locator_address">';
568
569					if(that.settings.showAddressStyle == "american") {
570						content += !that.isEmpty(store.st) ? '<span class="store_locator_street">' + store.st + '<br/></span>' : '';
571						content += !that.isEmpty(store.ct) ? '<span class="store_locator_city">' + store.ct + ', </span>' : '';
572						content += !that.isEmpty(store.rg) ? '<span class="store_locator_region">' + store.rg + ' </span>' : '';
573						content += !that.isEmpty(store.zp) ? '<span class="store_locator_zip">' + store.zp + '<br/></span>' : '';						
574						content += !that.isEmpty(store.co) ? '<span class="store_locator_country">' + store.co + '</span>' : '';
575					} else {
576						content += !that.isEmpty(store.st) ? '<span class="store_locator_street">' + store.st + '<br/></span>' : '';
577						content += !that.isEmpty(store.zp) ? '<span class="store_locator_zip">' + store.zp + '</span>' : '';
578						content += !that.isEmpty(store.ct) ? '<span class="store_locator_city">' + store.ct + '<br/></span>' : '';
579						content += !that.isEmpty(store.rg) ? '<span class="store_locator_region">' + store.rg + '</span>' : '';
580						content += !that.isEmpty(store.co) ? '<span class="store_locator_country">' + store.co + '</span>' : '';
581					}
582
583			content +=				'</p>' +
584									'<p class="store_locator_contact">';
585			content += !that.isEmpty(store.te) ? '<span class="store_locator_tel">' + that.settings.showTelephoneText + ': <a href="tel:' + store.te + '">' + store.te + '</a><br/></span>' : '';
586			content += !that.isEmpty(store.em) ? '<span class="store_locator_email">' + that.settings.showEmailText + ': <a href="mailto:' + store.em + '">' + store.em + '</a><br/></span>' : '';
587			content += !that.isEmpty(store.mo) ? '<span class="store_locator_mobile">' + that.settings.showMobileText + ': <a href="tel:' + store.mo + '">' + store.mo + '</a><br/></span>' : '';
588			content += !that.isEmpty(store.fa) ? '<span class="store_locator_fax">' + that.settings.showFaxText + ': ' + store.fa + '<br/></span>' : '';
589			content += !that.isEmpty(store.we) ? '<span class="store_locator_website">' + that.settings.showWebsiteText + ': <a href="' + store.we + '" target="_blank">' + store.we + '</a><br/></span>' : '';
590			content +=				'</p>' +
591									'<p class="store_locator_actions">';
592
593			content += !that.isEmpty(store.lat) ? '<a href="http://maps.google.com/maps?saddr=' + this.lat + ',' + this.lng + '&daddr=' + store.lat + ',' + store.lng + '" class="btn button btn-primary btn-lg store_locator_get_direction" target="_blank"><i class="fa fa-compass"></i> '+that.settings.showGetDirectionText+'</a>' : '';
594
595			content += !that.isEmpty(that.settings.showContactStorePage) ? '<a href="' + that.settings.showContactStorePage + '?store_id=' + store.ID + '&address=' + encodeURIComponent($(that.settings.store_locator_address_field).val()) + '&lat=' + that.lat + '&lng=' + that.lng + '" class="btn button btn-primary btn-lg store_locator_contact_store"><i class="fa fa-mail-forward"></i> '+that.settings.showContactStoreText+'</a>' : '';
596
597			content += !that.isEmpty(store.te) ? '<a href="tel:' + store.te + '" class="btn button btn-primary btn-lg store_locator_call_now"><i class="fa fa-phone"></i> '+that.settings.showCallNowText+'</a>' : '';
598
599			content += !that.isEmpty(store.we) ? '<a href="' + store.we + '" class="btn button btn-primary btn-lg store_locator_visit_website" target="_blank"><i class="fa fa-globe"></i> '+that.settings.showVisitWebsiteText+'</a>' : '';
600
601			content += !that.isEmpty(store.em) ? '<a href="mailto:' + store.em + '" class="btn button btn-primary btn-lg store_locator_write_email"><i class="fa fa-envelope-o"></i> '+that.settings.showWriteEmailText+'</a>' : '';
602
603			content +=				'</p>' +
604								'</div>';
605								
606			content += !that.isEmpty(store.im) ? '<div class="store-locator-col-sm-' + that.settings.infowindowImageColumns + ' store_locator_image"> <img src="' + store.im + '" class="img-responsive" width="'+that.settings.imageDimensions.width+'" height="'+that.settings.imageDimensions.height+'" /></div>' : '';
607
608			if(!that.isEmpty(store.op)) {
609				content += 		'<div class="store-locator-col-sm-' + that.settings.infowindowOpeningHoursColumns + ' store_locator_opening_hours">' + 
610									that.createOpeningHoursTable(store.op)+
611								'</div>';
612			}
613			content += !that.isEmpty(store.de) ? '<div class="store-locator-col-sm-12 store_locator_description">' +
614									'' + store.de + '' +
615								'</div>' : '';
616			content +=		'</div>';
617
618		    marker.addListener('click', function() {
619
620				if(!that.isEmpty(store.ic)) {
621					this.setIcon(store.ic);
622				} else if(!that.isEmpty(that.settings.store_locator_category_icon)) {
623					this.setIcon(that.settings.store_locator_category_icon);
624				} else {
625					this.setIcon(that.settings.mapDefaultIconHover);
626				}
627
628				infowindow.setContent(content);
629		        infowindow.open(map, this);
630
631		        if(that.settings.mapPanToOnHover == "1") {
632		        	that.map.panTo(this.getPosition());
633	        	}
634
635		     	google.maps.event.addListener(map, 'click', function() {
636					infowindow.close();
637			    });
638		     	google.maps.event.addListener(that.radiusCircle, 'click', function() {
639					infowindow.close();
640			    });
641		    });
642		    
643		    marker.addListener('mouseover', function() {
644		    	if(that.settings.infowindowCheckClosed == "1") {
645		    		if(!that.isInfoWindowOpen(infowindow)) {
646		        		google.maps.event.trigger(this, 'click');
647	        		}
648        		} else {
649        			google.maps.event.trigger(this, 'click');
650        		}
651		    });
652		    marker.addListener('mouseout', function() {
653				if(!that.isEmpty(store.ic)) {
654					this.setIcon(store.ic);
655				} else if(!that.isEmpty(that.settings.store_locator_category_icon)) {
656					this.setIcon(that.settings.store_locator_category_icon);
657				} else {
658					this.setIcon(that.settings.mapDefaultIcon);
659				}
660		    });
661		},
662		createResultList: function(stores)
663		{
664			var that = this;
665		   	var storesLength = Object.keys(stores).length;
666		   	var resultList = $(this.settings.result_list);
667		   	var resultListIconEnabled = this.settings.resultListIconEnabled;
668		   	var resultListIcon = this.settings.resultListIcon;
669		   	var resultListIconSize = this.settings.resultListIconSize;
670		   	var resultListIconColor = this.settings.resultListIconColor;
671
672		   	var resultListPremiumIconEnabled = this.settings.resultListPremiumIconEnabled;
673		   	var resultListPremiumIcon = this.settings.resultListPremiumIcon;
674		   	var resultListPremiumIconSize = this.settings.resultListPremiumIconSize;
675		   	var resultListPremiumIconColor = this.settings.resultListPremiumIconColor;
676
677		   	var resultListLinkAction = this.settings.resultListLinkAction;
678		   	
679		   	var store;
680		   	var i = 0;
681		   	var content;
682		   	var filterBadges;
683
684		   	resultList.html('');
685		   	if(storesLength > 0) {
686				for (i; i < storesLength; i++) {
687					store = stores[i];
688
689					content = '';
690		   	
691					if(resultListIconEnabled === "1") {
692						content	+=	'<div class="store-locator-col-sm-2 store_locator_icon store-locator-hidden-sm store-locator-hidden-xs">' +
693											'<i style="color: '+ resultListIconColor +';" class="fa '+ resultListIcon +' ' + resultListIconSize +'"></i>' +
694										'</div>' +
695										'<div class="store-locator-col-sm-10 store_locator_details">';
696					} else if(that.settings.showImage == "1" && store.im) {
697						
698						content	+=	'<div class="store-locator-col-sm-4 store_locator_image_container ' + that.settings.imagePosition + '">';
699							content	+=	!that.isEmpty(store.im) ? '<img src="' + store.im + '" class="store-locator-img-responsive" width="'+that.settings.imageDimensions.width+'" height="'+that.settings.imageDimensions.height+'" />' : '';
700						content += '</div>';
701						content	+=	'<div class="store-locator-col-sm-8 store_locator_details">';
702					} else {
703						content	+=	'<div class="store-locator-col-sm-12 store_locator_details">';
704					}
705
706					var resultListLinkAction = this.settings.resultListLinkAction;
707
708					store.resultListLinkAction = store.gu;
709					if(resultListLinkAction == "web") {
710						store.resultListLinkAction = store.we;
711					}
712					if(resultListLinkAction == "tel") {
713						store.resultListLinkAction = 'tel:' + store.te;
714					}
715					if(resultListLinkAction == "email") {
716						store.resultListLinkAction = 'mailto:' + store.em;
717					}
718
719					if(this.settings.resultListLinkAction !== "none") {
720						content += '<a href="' + store.resultListLinkAction + '">' +
721										'<h3 class="store_locator_name">' + store.na + ' <i class="fa fa-chevron-right"></i></h3>' +
722									'</a>';
723						
724					} else {
725						content += '<h3 class="store_locator_name">' + store.na + '</h3>';
726					}
727
728					content += !that.isEmpty(store.dc) ? '<span class="store_locator_distance">
728' + that.settings.showDistanceText + ': ' + store.dc + '<br/></span>' : '';
729
730					filterBadges = "";
731					if(!that.isEmpty(store.fi)) {
732						$.each(store.fi, function(i, item){
733							filterBadges += that.createBadge(item);
734						});
735					}
736
737					if(!that.isEmpty(store.ca)) {
738						$.each(store.ca, function(i, item){
739							filterBadges += that.createBadge(item);
740						});
741					}
742
743					content += !that.isEmpty(filterBadges) ? '<span className="store_locator_badges">' +
744										filterBadges +
745									'<br/></span>' : '';
746
747									'<p class="store_locator_address">';
748
749					if(that.settings.showAddressStyle == "american") {
750						content += !that.isEmpty(store.st) ? '<span class="store_locator_street">' + store.st + '<br/></span>' : '';
751						content += !that.isEmpty(store.ct) ? '<span class="store_locator_city">' + store.ct + ', </span>' : '';
752						content += !that.isEmpty(store.rg) ? '<span class="store_locator_region">' + store.rg + ' </span>' : '';
753						content += !that.isEmpty(store.zp) ? '<span class="store_locator_zip">' + store.zp + '<br/></span>' : '';						
754						content += !that.isEmpty(store.co) ? '<span class="store_locator_country">' + store.co + '</span>' : '';
755					} else {
756						content += !that.isEmpty(store.st) ? '<span class="store_locator_street">' + store.st + '<br/></span>' : '';
757						content += !that.isEmpty(store.zp) ? '<span class="store_locator_zip">' + store.zp + '</span>' : '';
758						content += !that.isEmpty(store.ct) ? '<span class="store_locator_city">' + store.ct + '<br/></span>' : '';
759						content += !that.isEmpty(store.rg) ? '<span class="store_locator_region">' + store.rg + '</span>' : '';
760						content += !that.isEmpty(store.co) ? '<span class="store_locator_country">' + store.co + '</span>' : '';
761					}
762
763					content +=				'</p>' +
764											'<p class="store_locator_contact">';
765					content += !that.isEmpty(store.te) ? '<span class="store_locator_tel">' + that.settings.showTelephoneText + ': <a href="tel:' + store.te + '">' + store.te + '</a><br/></span>' : '';
766					content += !that.isEmpty(store.em) ? '<span class="store_locator_email">' + that.settings.showEmailText + ': <a href="mailto:' + store.em + '">' + store.em + '</a><br/></span>' : '';
767					content += !that.isEmpty(store.mo) ? '<span class="store_locator_mobile">' + that.settings.showMobileText + ': <a href="tel:' + store.mo + '">' + store.mo + '</a><br/></span>' : '';
768					content += !that.isEmpty(store.fa) ? '<span class="store_locator_fax">' + that.settings.showFaxText + ': ' + store.fa + '</span>' : '';
769					content += !that.isEmpty(store.dc) ? '<span class="store_locator_distance">' + that.settings.showDistanceText + ': ' + store.dc + '<br/></span>' : '';
770					content += !that.isEmpty(store.we) ? '<span class="store_locator_website">' + that.settings.showWebsiteText + ': <a href="' + store.we + '" target="_blank">' + store.we + '</a><br/></span>' : '';
771					content +=				'</p>';
772					content += !that.isEmpty(store.de) ? '<div class="store-locator-col-sm-12 store_locator_result_list_description">' +
773															'<p>' + store.de + '</p>' +
774														'</div>' : '';
775					content += 				'<p class="store_locator_actions">';
776
777					content += !that.isEmpty(store.lat) ? '<a href="http://maps.google.com/maps?saddr=' + this.lat + ',' + this.lng + '&daddr=' + store.lat + ',' + store.lng + '" class="btn button btn-primary btn-lg store_locator_get_direction" target="_blank"><i class="fa fa-compass"></i> '+that.settings.showGetDirectionText+'</a>' : '';
778
779					content += !that.isEmpty(that.settings.showContactStorePage) ? '<a href="' + that.settings.showContactStorePage + '?store_id=' + store.ID + '&address=' + encodeURIComponent($(that.settings.store_locator_address_field).val()) + '&lat=' + that.lat + '&lng=' + that.lng + '" class="btn button btn-primary btn-lg store_locator_contact_store"><i class="fa fa-mail-forward"></i> '+that.settings.showContactStoreText+'</a>' : '';
780
781					content += !that.isEmpty(store.te) ? '<a href="tel:' + store.te + '" class="btn button btn-primary btn-lg store_locator_call_now"><i class="fa fa-phone"></i> '+that.settings.showCallNowText+'</a>' : '';
782
783					content += !that.isEmpty(store.we) ? '<a href="' + store.we + '" class="btn button btn-primary btn-lg store_locator_visit_website" target="_blank"><i class="fa fa-globe"></i> '+that.settings.showVisitWebsiteText+'</a>' : '';
784
785					content += !that.isEmpty(store.em) ? '<a href="mailto:' + store.em + '" class="btn button btn-primary btn-lg store_locator_write_email"><i class="fa fa-envelope-o"></i> '+that.settings.showWriteEmailText+'</a>' : '';
786					
787					content += '<a class="btn button btn-primary btn-lg store_locator_show_on_map"><i class="fa fa-map-marker"></i> '+ that.settings.showShowOnMapText + '</a>';
788
789					content += '</div>';
790
791					var render = '';
792					render = '<div id="store_locator_result_list_item_' + store.ID + '" class="store_locator_result_list_item">' +
793								'<div class="store-locator-row">';
794					render += content;
795					
796					if(resultListPremiumIconEnabled === "1" && store.pr === "1") {
797						render	+=	'<i style="color: '+ resultListPremiumIconColor +'; position: absolute; top: 5px; z-index: 999999; right: 10px;" class="fa '+ resultListPremiumIcon +' ' + resultListPremiumIconSize +'"></i>';
798					}				
799
800					render +=	'</div>' +
801							'</div>';
802
803					resultList.append(render);
804				}
805			} else {
806				if(this.settings.mapExtendRadius === "1") {
807					if(!$(this.settings.store_locator_filter_radius + " option:last").is(":selected")) {
808						$(this.settings.store_locator_filter_radius + ' option:selected').prop('selected', false).next().prop('selected', 'selected').trigger('change');
809					} else {
810						this.noResults();
811					}
812				} else {
813					this.noResults();
814				}
815			}
816			this.autoHeightMap();
817			this.map.setCenter(this.currentPosition);
818			this.window.trigger('resize');
819
820			if(this.settings.resultListHover == "1") {
821				this.resultItemHover();
822			}
823
824			if(this.settings.showShowOnMap == "1") {
825				this.showOnMap();
826			}
827		},
828		createOpeningHoursTable: function(openingHours) {
829			var that = this;
830
831			var table = '';
832			$.each(openingHours, function(i, item) {
833				if(that.isEmpty(item)) {
834					return true;
835				}
836
837				if(i % 2 === 0) {
838					table += '<div class="store-locator-row">';
839					table += '<div class="store-locator-col-sm-12">';
840				}
841				
842				if(i % 2 === 0) {
843					if(i === "0") { table += that.settings.showOpeningHoursMonday; }
844					if(i === "2") { table += that.settings.showOpeningHoursTuesday; }
845					if(i === "4") { table += that.settings.showOpeningHoursWednesday; }
846					if(i === "6") { table += that.settings.showOpeningHoursThursday; }
847					if(i === "8") { table += that.settings.showOpeningHoursFriday; }
848					if(i === "10") { table += that.settings.showOpeningHoursSaturday; }
849					if(i === "12") { table += that.settings.showOpeningHoursSunday; }
850
851					table += ': ' + item;
852				} else {
853					table += " - " + item + ' ' + that.settings.showOpeningHoursClock;
854				}
855
856				if(i % 2 !== 0) {
857					table += '</div>';
858					table += '</div>';
859				}
860				
861			});
862			if(!that.isEmpty(table)) {
863				var title = '<h3 class="store_locator_opening_hours_title">' + that.settings.showOpeningHoursText + '</h3>';
864				table = '<div class="store-locator-opening-hours" id="store-locator-opening-hours">' + table + '</div>';
865				table = title + table;
866			}
867
868			return table;
869		},
870		createBadge: function(value) {
871			var that = this;
872
873			var badgeCSS = that.slugify(value);
874			var template = '<span class="store-locator-label store-locator-label-success ' + badgeCSS + '">%s</span> ';
875
876			return that.sprintf(template, value);
877		},
878		noResults: function() {
879		   	var resultList = $(this.settings.result_list);
880
881		   	resultList.html('');
882		   	resultList.append('<h4 class="store_locator_no_stores">' + this.settings.resultListNoResultsText + '</h4>');
883			this.autoHeightMap();
884		},
885		resultItemHover: function() {
886			var that = this;
887			var resultList = $(this.settings.result_list);
888
889			$('.store_locator_result_list_item').each(function(i, item){
890				$(item).on('mouseenter', function(){
891					google.maps.event.trigger(that.markers[i], 'click');
892				});
893			});
894		},
895		showOnMap: function() {
896			var that = this;
897			var resultList = $(this.settings.result_list);
898
899			$('.store_locator_show_on_map').each(function(i, item){
900				$(item).on('click', function(){
901					google.maps.event.trigger(that.markers[i], 'click');
902				});
903			});
904		},
905		initFilter: function() {
906			var that = this;
907			var store_locator_filter_open_close = $(this.settings.store_locator_filter_open_close);
908			var store_locator_filter_icon = store_locator_filter_open_close.find('i');
909
910			store_locator_filter_open_close.on('click', function(){
911				that.maybeShowFilter();
912			});
913			
914		    that.watchRadiusSelection();
915		    that.watchCategoriesSelection();
916		    that.watchCheckboxFilter();
917		    that.updateActiveFilter();
918		},
919		maybeShowFilter: function() {
920			var store_locator_filter_content = $(this.settings.store_locator_filter_content);
921			var store_locator_filter_open_close = $(this.settings.store_locator_filter_open_close);
922			var store_locator_filter_icon = store_locator_filter_open_close.find('i');
923
924			if(store_locator_filter_content.is(":hidden"))
925			{
926				store_locator_filter_icon.removeClass('fa-chevron-down');
927				store_locator_filter_icon.addClass('fa-chevron-up');
928				store_locator_filter_content.fadeIn();
929			} else {
930				store_locator_filter_icon.addClass('fa-chevron-down');
931				store_locator_filter_icon.removeClass('fa-chevron-up');
932				store_locator_filter_content.fadeOut();
933			}
934		},
935		watchRadiusSelection: function() {
936			var that = this;
937			var selectedRadius = $(this.settings.store_locator_filter_radius);
938
939			selectedRadius.on('change', function(){
940				that.drawRadiusCircle();
941
942				that.updateActiveFilter();
943				that.getStores();
944			});
945
946			var predefinedRadius = that.getParameterByName('radius');
947			if(!that.isEmpty(predefinedRadius)) {
948				var options = selectedRadius.find('option');
949				$.each(options, function(i, index) {
950					var option = $(this);
951					option.prop('selected', false);
952					if(option.val() == predefinedRadius) {
953						option.prop('selected', true);
954					}
955				});
956			}
957		},
958		watchCategoriesSelection: function() {
959			var that = this;
960			var selectedCategories = $(this.settings.store_locator_filter_categories);
961
962			if(selectedCategories.length == 0) {
963				var selectedCategories = $('.store_locator_category_filter_image');
964				var selectedCategoryID = $('.store_locator_category_filter_image[data-selected="selected"]').data('category');
965
966				if(selectedCategoryID > 0) {
967					that.categories = {0: selectedCategoryID };
968				}
969
970				selectedCategories.on('click', function(){
971					var selected = $(this);
972					selectedCategoryID = selected.data('category');
973
974					var categoryIcon = $(selected).data('icon');
975					if(!that.isEmpty(categoryIcon)) {
976						that.settings.store_locator_category_icon = categoryIcon;
977					} else {
978						that.settings.store_locator_category_icon = '';
979					}
980					that.categories = {0: selectedCategoryID };
981					that.updateActiveFilter();
982					that.getStores();
983				});
984			} else {
985
986				var selectedCategoryID = selectedCategories.find(':selected').val();
987
988				var predefinedCategory = that.getParameterByName('category');
989				if(!that.isEmpty(predefinedCategory) && that.isEmpty(selectedCategoryID)) {
990					var tst = selectedCategories.val(predefinedCategory);
991					selectedCategoryID = predefinedCategory;
992				}
993
994				that.categories = {0: selectedCategoryID };
995				selectedCategories.on('change', function(){
996					var selected = selectedCategories.find(':selected');
997					selectedCategoryID = selected.val();
998
999					var categoryIcon = $(selected).data('icon');
1000					if(!that.isEmpty(categoryIcon)) {
1001						that.settings.store_locator_category_icon = categoryIcon;
1002					} else {
1003						that.settings.store_locator_category_icon = '';
1004					}
1005					that.categories = {0: selectedCategoryID };
1006					that.updateActiveFilter();
1007					that.getStores();
1008				});
1009			}
1010		},
1011		watchCheckboxFilter: function() {
1012			var that = this;
1013			var filterCheckboxes = $(this.settings.store_locator_filter_checkbox);
1014
1015			var predefinedFilter = that.getQuerystringData('filter[]');
1016
1017			if(typeof predefinedFilter == 'string' ) {
1018				predefinedFilter = {0 : predefinedFilter};
1019			}
1020
1021			if(typeof predefinedFilter == 'undefined' ) {
1022				predefinedFilter = {};
1023			}
1024
1025		    filterCheckboxes.each(function(i, item) {
1026		    	var checkbox = $(item);
1027
1028				if(!that.isEmpty(predefinedFilter)) {
1029					$.each(predefinedFilter, function(i, index) {
1030						if(checkbox.prop('name') == index) {
1031							checkbox.prop('checked', 'checked');
1032						}
1033					});
1034				}
1035
1036			    var isChecked = checkbox.is(":checked");
1037
1038			    if(isChecked) {
1039			    	var filter = checkbox.prop("name");
1040			    	that.filter[filter] = filter;
1041			    }
1042		    });
1043
1044			$(filterCheckboxes).on('change', function () {
1045				that.filter = {};
1046			    filterCheckboxes.each(function(i, item) {
1047			    	var checkbox = $(item);
1048				    var isChecked = checkbox.is(":checked");
1049
1050				    if(isChecked) {
1051				    	var filter = checkbox.prop("name");
1052				    	that.filter[filter] = filter;
1053				    }
1054			    });
1055				that.updateActiveFilter();
1056				that.getStores();
1057			});
1058		},
1059		updateActiveFilter: function()
1060		{
1061			var that = this;
1062			var store_locator_filter = $(this.settings.store_locator_filter);
1063			var store_locator_filter_active_filter = $(this.settings.store_locator_filter_active_filter);
1064			var selectedCategories = store_locator_filter.find('select');
1065			var selectedFilters = store_locator_filter.find('input:checked');
1066			var template = '<span class="store_locator_filter_active store-locator-label store-locator-label-success %s">%s</span> ';
1067			var append = "";
1068
1069			store_locator_filter_active_filter.html('');
1070			selectedCategories.each(function(i, item){
1071				var val = $(item).find(':selected').val();
1072				if(val !== "") {
1073					var text = $(item).find(':selected').text();
1074					var slug = that.slugify(text);
1075					append = append + that.sprintf(template, slug, text);
1076				}				
1077			});
1078
1079			selectedFilters.each(function(i, item) {
1080				var text = $(item).val();
1081				var slug = that.slugify(text);
1082				append = append + that.sprintf(template, slug, text);
1083			});
1084
1085
1086			store_locator_filter_active_filter.html(append);
1087
1088		},
1089		watchResize: function() {
1090			var store_locator_sidebar = $(this.settings.store_locator_sidebar);
1091			var store_modal_close = $(this.settings.store_modal_close);
1092			var windowWidth = this.window.width();
1093
1094			var top;
1095			// if(windowWidth < 769) {
1096			// 	top = store_locator_sidebar.height() * -1;
1097			// 	store_modal_close.css('top', top);
1098			// } else {
1099			// 	top = 20;
1100			// 	store_modal_close.css('top', top);
1101			// }
1102		},
1103		watchMapDragged : function() {
1104
1105			var that = this;
1106			var map = that.map;
1107			
1108			var store_locator_dragged_button = $(that.settings.store_locator_dragged_button);
1109			store_locator_dragged_button.fadeOut();
1110			
1111			google.maps.event.addListener(map, 'dragend', function(e) {
1112				store_locator_dragged_button.fadeIn();
1113			} );
1114
1115		},
1116		watchDraggedButton : function () {
1117
1118			var that = this;
1119			var store_locator_dragged_button = $(that.settings.store_locator_dragged_button);
1120
1121			store_locator_dragged_button.on('click', function(e) {
1122				store_locator_dragged_button.fadeOut();
1123
1124				var coords = that.map.getCenter();
1125
1126				var currentPosition = new google.maps.LatLng(coords.lat(), coords.lng()); 
1127				that.setCurrentPosition(currentPosition);
1128			});
1129		},
1130		radiusToZoom: function(radius){
1131		    return Math.round(14-Math.log(radius)/Math.LN2);
1132		},
1133		initForm : function() {
1134			var that = this;
1135
1136			var predefinedAddress = that.getParameterByName('address');
1137			var predefinedLat = that.getParameterByName('lat');
1138			var predefinedLng = that.getParameterByName('lng');
1139			var addressField = $(this.settings.store_locator_form_customer_address);
1140			var address = addressField.val();
1141			var lat, lng;
1142
1143			if(!that.isEmpty(predefinedAddress) && that.isEmpty(address)) {
1144				addressField.val(predefinedAddress);
1145			}
1146
1147			if(!that.isEmpty(predefinedLat) && !that.isEmpty(predefinedLng)) {
1148				lat = predefinedLat;
1149				lng = predefinedLng;
1150			}
1151
1152			that.watchFormSelectField();
1153			that.watchFormAddressField();
1154			that.initFormAutocomplete();
1155			that.loadFormStores(lat, lng);
1156
1157		},
1158		loadFormStores : function(lat, lng) {
1159			var that = this;
1160
1161			var storeSelectField = $(this.settings.store_locator_form_store_select);
1162			var addressField = $(this.settings.store_locator_form_customer_address);
1163			var address = addressField.val();
1164			var predefinedStoreId = that.getParameterByName('store_id');
1165
1166			if( (that.isEmpty(lat) || that.isEmpty(lng)) && !that.isEmpty(address)) {
1167				that.geocoder.geocode( { 'address': address }, function ( results, status ) {
1168					if ( status === google.maps.GeocoderStatus.OK ) {
1169						var location = results[0].geometry.location;
1170						lat = location.lat();
1171						lng = location.lng();			
1172						that.getAllStores(lat, lng, that.storesToSelectField, { store_id : predefinedStoreId, that: that});
1173					} else {
1174						that.getAllStores(lat, lng, that.storesToSelectField, { store_id : predefinedStoreId, that: that});
1175					}
1176				} );
1177			} else {
1178				that.getAllStores(lat, lng, that.storesToSelectField, { store_id : predefinedStoreId, that: that});
1179			}
1180
1181		},
1182		watchFormAddressField : function() {
1183			var that = this;
1184			var addressField = $(this.settings.store_locator_form_customer_address);
1185
1186			addressField.on('focusout', function(e) {
1187				var $this = $(this);
1188				var val = $this.val()
1189				
1190				that.loadFormStores();
1191			});
1192		},
1193		watchFormSelectField : function () {
1194			var that = this;
1195			var storeSelectField = $(this.settings.store_locator_form_store_select);
1196			var dataName, dataValue;
1197			storeSelectField.on('change', function(e) {
1198				var $this = $(this);
1199				var selected = storeSelectField.find(':selected');
1200				var val = $this.val()
1201
1202				var possibleData = [
1203					'name',
1204					'address',
1205					'zip',
1206					'city',
1207					'country',
1208					'region',
1209					'telephone',
1210					'mobile',
1211					'fax',
1212					'email',
1213					'website',
1214				]
1215				
1216				$(possibleData).each(function(i, index) {
1217					var dataName = index;
1218					var dataValue = selected.data(dataName);
1219
1220					if(typeof dataValue !== 'undefined') {
1221						dataValue = dataValue.toString();
1222					}
1223
1224					if(that.isEmpty(dataValue)) {
1225						dataValue = "";
1226					}
1227					var inputField = $('input[name="store_locator_form_store_' + dataName + '"]');
1228					if(inputField.length > 0) {
1229						inputField.val(dataValue);
1230					}
1231					
1232					var infoField = $('.store_locator_store_info_' + dataName);
1233					if(infoField.length > 0) {
1234						infoField.html(dataValue);
1235					}
1236				});
1237			});
1238		},
1239		getAllStores: function(lat, lng, callback, options) {
1240			var that = this;
1241
1242			jQuery.ajax({
1243				url: that.settings.ajax_url,
1244				type: 'post',
1245				dataType: 'JSON',
1246				data: {
1247					action: 'get_all_stores',
1248					lat: lat,
1249					lng: lng,
1250				},
1251				success : function( response ) {
1252					callback(response, options);
1253				},
1254				error: function(jqXHR, textStatus, errorThrown) {
1255				    alert('An Error Occured: ' + jqXHR.status + ' ' + errorThrown + '! Please contact System Administrator!');
1256				}
1257			});
1258		},
1259		// Form 
1260		initFormAutocomplete: function() {
1261			var that = this;
1262			var addressField = $(this.settings.store_locator_form_customer_address);
1263			var countryRestrict = this.settings.autocompleteCountryRestrict;
1264			var type = this.settings.autocompleteType;
1265			var map = this.map;
1266			
1267			if ( !addressField) { return; }
1268
1269			var autocompleteOptions = {};
1270			if(!that.isEmpty(countryRestrict)) {
1271				autocompleteOptions.componentRestrictions = {'country' : countryRestrict };
1272			}
1273
1274			if(!that.isEmpty(type)) {
1275				autocompleteOptions.types = [type];
1276			} else {
1277				autocompleteOptions.types = ['geocode'];
1278			}
1279
1280			var autocomplete = new google.maps.places.Autocomplete(addressField[0], autocompleteOptions);
1281
1282			autocomplete.addListener('place_changed', function(e){
1283				var place = autocomplete.getPlace();
1284				if(!that.isEmpty(place.formatted_address)) {
1285					addressField.val(place.formatted_address).trigger('focusout');
1286				} else {
1287					addressField.val(place.name).trigger('focusout');
1288				}
1289			});
1290		},
1291		storesToSelectField: function(stores, options) {
1292
1293			var that = options.that;
1294			var store_id = options.store_id
1295			var storeSelectField = $(that.settings.store_locator_form_store_select);
1296			
1297			var html = '<option value="">Select Store</option>';
1298
1299			var storesLength = Object.keys(stores).length;
1300			var i = 0;
1301			var store;
1302
1303			var selected;
1304			var data;
1305			var disabled;
1306			if(storesLength > 0) {
1307				for (i; i < storesLength; i++) { 
1308					
1309					store = stores[i];
1310
1311					selected = "";
1312					if(store.ID == store_id) {
1313						selected = 'selected="selected"';
1314					}
1315
1316					data = "";
1317					if(!that.isEmpty(store.na)) {
1318						data += ' data-name="' + store.na + '"';
1319						if(!that.isEmpty(store.distance)) {
1320							store.distance = parseFloat(store.distance).toFixed(2); 
1321							store.na = store.na + ' (' + store.distance + ' ' + that.settings.mapDistanceUnit + ')';
1322						}
1323					}
1324					if(!that.isEmpty(store.st)) {
1325						data += ' data-address="' + store.st + '"';
1326					}
1327					if(!that.isEmpty(store.zp)) {
1328						data += ' data-zip="' + store.zp + '"';
1329					}
1330					if(!that.isEmpty(store.ct)) {
1331						data += ' data-city="' + store.ct + '"';
1332					}
1333					if(!that.isEmpty(store.co)) {
1334						data += ' data-country="' + store.co + '"';
1335					}
1336					if(!that.isEmpty(store.rg)) {
1337						data += ' data-region="' + store.rg + '"';
1338					}
1339					if(!that.isEmpty(store.te)) {
1340						data += ' data-telephone="' + store.te + '"';
1341					}
1342					if(!that.isEmpty(store.mo)) {
1343						data += ' data-mobile="' + store.mo + '"';
1344					}
1345					if(!that.isEmpty(store.fa)) {
1346						data += ' data-fax="' + store.fa + '"';
1347					}
1348					if(!that.isEmpty(store.em)) {
1349						data += ' data-email="' + store.em + '"';
1350					}
1351					if(!that.isEmpty(store.we)) {
1352						data += ' data-website="' + store.we + '"';
1353					}
1354
1355
1356					html += '<option value="' + store.ID + '" ' + selected + ' ' +  data + '>
1356' + store.na + '</option>';
1357				}
1358			}
1359
1360			storeSelectField.html(html).trigger('change');
1361		},
1362		initEmbeddedSearch : function() {
1363			var that = this;
1364			var addressField = $(this.settings.store_locator_address_field);
1365			var countryRestrict = this.settings.autocompleteCountryRestrict;
1366			var type = this.settings.autocompleteType;
1367			var map = this.map;
1368			
1369			if ( !addressField) { return; }
1370
1371			var autocompleteOptions = {};
1372			if(!that.isEmpty(countryRestrict)) {
1373				autocompleteOptions.componentRestrictions = {'country' : countryRestrict };
1374			}
1375
1376			if(!that.isEmpty(type)) {
1377				autocompleteOptions.types = [type];
1378			} else {
1379				autocompleteOptions.types = ['geocode'];
1380			}
1381
1382			var autocomplete = new google.maps.places.Autocomplete(addressField[0], autocompleteOptions);
1383
1384			autocomplete.addListener('place_changed', function(e){
1385				var place = autocomplete.getPlace();
1386				if(!that.isEmpty(place.formatted_address)) {
1387					addressField.val(place.formatted_address).trigger('focusout');
1388				} else {
1389					addressField.val(place.name).trigger('focusout');
1390				}
1391			});
1392		},
1393		isInfoWindowOpen : function(infoWindow){
1394		    var map = infoWindow.getMap();
1395		    return (map !== null && typeof map !== "undefined");
1396		},
1397		buildReplaceState : function() {
1398			var that = this;
1399			var address = $(that.settings.store_locator_address_field).val();
1400			var categories = that.categories;
1401			var filter = that.filter;
1402			var radius = that.radius;
1403
1404			var url = "";
1405			if(!that.isEmpty(address)) {
1406				url += '?location=' + address;
1407			}
1408
1409			if(categories[0]) {
1410				if(url == "") {
1411					url += '?category=' + categories[0];
1412				} else {
1413					url += '&category=' + categories[0];
1414				}
1415			}
1416			
1417			if(radius) {
1418				if(url == "") {
1419					url += '?radius=' + radius;
1420				} else {
1421					url += '&radius=' + radius;
1422				}
1423			}
1424
1425			if(filter) {
1426				var filterLoop = 0;
1427				$.each(filter, function(i, index) {
1428					if(filterLoop == 0 && url == "") {
1429						url += '?filter[]=' + index;
1430					} else {
1431						url += '&filter[]=' + index;
1432					}
1433					filterLoop++;
1434				});
1435			}
1436			
1437
1438			window.history.replaceState('test', 'Store Locator', that.currentURL + url);
1439		},
1440		//////////////////////
1441		///Helper Functions///
1442		//////////////////////
1443		isEmpty: function(obj) {
1444
1445		    if (obj == null)		return true;
1446		    if (obj.length > 0)		return false;
1447		    if (obj.length === 0)	return true;
1448
1449		    for (var key in obj) {
1450		        if (hasOwnProperty.call(obj, key)) return false;
1451		    }
1452
1453		    return true;
1454		},
1455		sprintf: function parse(str) {
1456		    var args = [].slice.call(arguments, 1),
1457		        i = 0;
1458
1459		    return str.replace(/%s/g, function() {
1460		        return args[i++];
1461		    });
1462		},
1463		getCookie: function(cname) {
1464		    var name = cname + "=";
1465		    var ca = document.cookie.split(';');
1466		    for(var i=0; i<ca.length; i++) {
1467		        var c = ca[i];
1468		        while (c.charAt(0)==' ') c = c.substring(1);
1469		        if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
1470		    }
1471		    return "";
1472		},
1473		slugify : function (text) {
1474		  return text.toString().toLowerCase()
1475		    .replace(/\s+/g, '-')           // Replace spaces with -
1476		    .replace(/[^\w\-]+/g, '')       // Remove all non-word chars
1477		    .replace(/\-\-+/g, '-')         // Replace multiple - with single -
1478		    .replace(/^-+/, '')             // Trim - from start of text
1479		    .replace(/-+$/, '');            // Trim - from end of text
1480		},
1481		getParameterByName : function (name, url) {
1482		    if (!url) url = window.location.href;
1483		    name = name.replace(/[\[\]]/g, "\\$&");
1484		    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
1485		        results = regex.exec(url);
1486		    if (!results) return null;
1487		    if (!results[2]) return '';
1488		    return decodeURIComponent(results[2].replace(/\+/g, " "));
1489		},
1490		getQuerystringData : function (name) {
1491		    var data = { };
1492		    var parameters = window.location.search.substring(1).split("&");
1493		    for (var i = 0, j = parameters.length; i < j; i++) {
1494		        var parameter = parameters[i].split("=");
1495		        var parameterName = decodeURIComponent(parameter[0]);
1496		        var parameterValue = typeof parameter[1] === "undefined" ? parameter[1] : decodeURIComponent(parameter[1]);
1497		        var dataType = typeof data[parameterName];
1498		        if (dataType === "undefined") {
1499		            data[parameterName] = parameterValue;
1500		        } else if (dataType === "array") {
1501		            data[parameterName].push(parameterValue);
1502		        } else {
1503		            data[parameterName] = [data[parameterName]];
1504		            data[parameterName].push(parameterValue);
1505		        }
1506		    }
1507		    return typeof name === "string" ? data[name] : data;
1508		}
1509	} );
1510
1511	// Constructor wrapper
1512	$.fn[ pluginName ] = function( options ) {
1513		return this.each( function() {
1514			if ( !$.data( this, "plugin_" + pluginName ) ) {
1515				$.data( this, "plugin_" +
1516					pluginName, new Plugin( this, options ) );
1517			}
1518		} );
1519	};
1520
1521	$.fn.emulateTransitionEnd = function (duration) {
1522		var called = false
1523		var $el = this
1524		$(this).one('bsTransitionEnd', function () { called = true })
1525		var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
1526		setTimeout(callback, duration)
1527		return this
1528	}
1529
1530	$(document).ready(function() {
1531
1532		$( "body" ).storeLocator( 
1533			store_locator_options
1534		);
1535
1536	} );
1537
1538})( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.