Skip to content

Commit 61e15e4

Browse files
committed
Working through JSHint warnings, updated comments
1 parent 01c0712 commit 61e15e4

File tree

3 files changed

+121
-101
lines changed

3 files changed

+121
-101
lines changed

dist/js/jquery.storelocator.js

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-10-05
1+
/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-10-11
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2014 Bjorn Holine; Licensed MIT */
44

@@ -199,6 +199,7 @@
199199
destroy: function () {
200200
// Reset
201201
this.reset();
202+
var mapContainer = $('#' + this.settings.mapID);
202203

203204
// Remove marker event listeners
204205
if(markers.length) {
@@ -209,9 +210,8 @@
209210

210211
// Remove markup
211212
$('.' + this.settings.locationList + ' ul').empty();
212-
if($('#' + this.settings.mapID).hasClass('bh-sl-map-open')) {
213-
$('#' + this.settings.mapID).empty();
214-
$('#' + this.settings.mapID).removeClass('bh-sl-map-open');
213+
if(mapContainer.hasClass('bh-sl-map-open')) {
214+
mapContainer.empty().removeClass('bh-sl-map-open');
215215
}
216216

217217
// Remove modal markup
@@ -220,7 +220,7 @@
220220
}
221221

222222
// Remove map style from cotnainer
223-
$('#' + this.settings.mapID).attr('style', '');
223+
mapContainer.attr('style', '');
224224

225225
// Hide map container
226226
$this.hide();
@@ -356,9 +356,9 @@
356356
/**
357357
* AJAX data request
358358
*
359-
* @param lat (number)
360-
* @param lng (number)
361-
* @param address (string)
359+
* @param lat {number}
360+
* @param lng {number}
361+
* @param address {string}
362362
* @returns {*}
363363
*/
364364
getData: function (lat, lng, address) {
@@ -490,10 +490,10 @@
490490
// If show full map option is true
491491
if (this.settings.fullMapStart === true) {
492492
if(this.settings.querystringParams === true && this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID)) {
493-
this.processForm();
493+
this.processForm(null);
494494
}
495495
else {
496-
this.mapping();
496+
this.mapping(null);
497497
}
498498
}
499499

@@ -567,7 +567,7 @@
567567
/**
568568
* Checks to see if the object is empty. Using this instead of $.isEmptyObject for legacy browser support
569569
*
570-
* @param obj {object} the object to check
570+
* @param obj {Object} the object to check
571571
* @returns {boolean}
572572
*/
573573
isEmptyObject: function (obj) {
@@ -642,8 +642,10 @@
642642
var filterTest = true;
643643

644644
for (var k in filters) {
645-
if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) {
646-
filterTest = false;
645+
if (filters.hasOwnProperty(k)) {
646+
if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) {
647+
filterTest = false;
648+
}
647649
}
648650
}
649651

@@ -725,10 +727,10 @@
725727
/**
726728
* Marker image setup
727729
*
728-
* @param markerUrl (string) path to marker image
729-
* @param markerWidth (number} width of mearker
730-
* @param markerHeight (number) height of marker
731-
* @returns {object} Google Maps icon object
730+
* @param markerUrl {string} path to marker image
731+
* @param markerWidth {number} width of mearker
732+
* @param markerHeight {number} height of marker
733+
* @returns {Object} Google Maps icon object
732734
*/
733735
markerImage: function (markerUrl, markerWidth, markerHeight) {
734736
var markerImg;
@@ -754,11 +756,12 @@
754756
/**
755757
* Map marker setup
756758
*
757-
* @param point {object} LatLng of current location
758-
* @param name (string) location name
759-
* @param address (string) location address
760-
* @param letter (string) optional letter used for front-end identification and correlation between list and points
761-
* @param category (string) location category/categories
759+
* @param point {Object} LatLng of current location
760+
* @param name {string} location name
761+
* @param address {string} location address
762+
* @param letter {string} optional letter used for front-end identification and correlation between list and points
763+
* @param map {Object} the Google Map
764+
* @param category {string} location category/categories
762765
* @returns {google.maps.Marker}
763766
*/
764767
createMarker: function (point, name, address, letter, map, category) {
@@ -826,9 +829,9 @@
826829
/**
827830
* Define the location data for the templates
828831
*
829-
* @param currentMarker {object} Google Maps marker
830-
* @param storeStart (number) optional first location on the current page
831-
* @param page (number) optional current page
832+
* @param currentMarker {Object} Google Maps marker
833+
* @param storeStart {number} optional first location on the current page
834+
* @param page {number} optional current page
832835
* @returns {{location: *[]}}
833836
*/
834837
defineLocationData: function (currentMarker, storeStart, page) {
@@ -882,7 +885,7 @@
882885
/**
883886
* Set up the list templates
884887
*
885-
* @param marker {object} Google Maps marker
888+
* @param marker {Object} Google Maps marker
886889
* @param storeStart {number} optional first location on the current page
887890
* @param page {number} optional current page
888891
*/
@@ -895,7 +898,15 @@
895898
$('.' + this.settings.locationList + ' ul').append(listHtml);
896899
},
897900

898-
// Infowindows
901+
/**
902+
* Create the infowindow
903+
*
904+
* @param marker {Object} Google Maps marker object
905+
* @param location {string} indicates if the list or a map marker was clicked
906+
* @param infowindow Google Maps InfoWindow constructor
907+
* @param storeStart {number}
908+
* @param page {number}
909+
*/
899910
createInfowindow: function (marker, location, infowindow, storeStart, page) {
900911
var _this = this;
901912
// Define the location data
@@ -917,19 +928,22 @@
917928
// Focus on the list
918929
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
919930
var markerId = marker.get('id');
920-
$('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus');
931+
var selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
932+
selectedLocation.addClass('list-focus');
921933

922934
// Scroll list to selected marker
923-
var container = $('.' + _this.settings.locationList), scrollTo = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
924-
$('.' + _this.settings.locationList).animate({
925-
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
935+
var container = $('.' + _this.settings.locationList);
936+
container.animate({
937+
scrollTop: selectedLocation.offset().top - container.offset().top + container.scrollTop()
926938
});
927939
});
928940
}
929941
},
930942

931943
/**
932944
* HTML5 geocoding function for automatic location detection
945+
*
946+
* @param position
933947
*/
934948
autoGeocodeQuery: function (position) {
935949
var _this = this;
@@ -946,17 +960,16 @@
946960
_this.mapping(mappingObj);
947961
} else {
948962
// Unable to geocode
949-
alert(this.settings.addressErrorAlert);
963+
alert(_this.settings.addressErrorAlert);
950964
}
951965
});
952966
},
953967

954968
/**
955969
* Handle autoGeocode failure
956970
*
957-
* @param error
958971
*/
959-
autoGeocodeError: function (error) {
972+
autoGeocodeError: function () {
960973
// If automatic detection doesn't work show an error
961974
alert(this.settings.autoGeocodeErrorAlert);
962975
},
@@ -1121,7 +1134,7 @@
11211134
_this.mapping(mappingObj);
11221135
} else {
11231136
// Unable to geocode
1124-
alert(this.settings.addressErrorAlert);
1137+
alert(_this.settings.addressErrorAlert);
11251138
}
11261139
});
11271140
}
@@ -1133,12 +1146,8 @@
11331146

11341147
/**
11351148
* The primary mapping function that runs everything
1136-
*
1137-
* @param data {kml,xml,or json} all location data
1138-
* @param orig_lat {number} origin latitude
1139-
* @param orig_lng {number} origin longitude
1140-
* @param origin {string} origin address
1141-
* @param maxDistance {number} optional maximum distance
1149+
*
1150+
* @param mappingObject {Object} all the mapping properties - latitude, longitude, origin, name, max distance, page
11421151
*/
11431152
mapping: function (mappingObject) {
11441153
var _this = this;
@@ -1187,20 +1196,22 @@
11871196
* Process the location data
11881197
*/
11891198
originalDataRequest.then(function (data) {
1199+
var mapContainer = $('#' + _this.settings.mapID);
1200+
11901201
// Callback
11911202
if (_this.settings.callbackSuccess) {
11921203
_this.settings.callbackSuccess.call(this);
11931204
}
11941205

11951206
// Set a variable for fullMapStart so we can detect the first run
1196-
if (_this.settings.fullMapStart === true && $('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === false) {
1207+
if (_this.settings.fullMapStart === true && mapContainer.hasClass('bh-sl-map-open') === false) {
11971208
firstRun = true;
11981209
}
11991210
else {
12001211
_this.reset();
12011212
}
12021213

1203-
$('#' + _this.settings.mapID).addClass('bh-sl-map-open');
1214+
mapContainer.addClass('bh-sl-map-open');
12041215

12051216
// Process the location data depending on the data format type
12061217
if (_this.settings.dataType === 'json' || _this.settings.dataType === 'jsonp') {
@@ -1329,17 +1340,15 @@
13291340

13301341
// Filter the data
13311342
if (!_this.isEmptyObject(taxFilters)) {
1332-
var filteredset = $.grep(locationset, function (val, i) {
1343+
locationset = $.grep(locationset, function (val) {
13331344
return _this.filterData(val, taxFilters);
13341345
});
1335-
1336-
locationset = filteredset;
13371346
}
13381347
}
13391348

13401349
if (_this.isEmptyObject(locationset)) {
13411350
// Hide the map and locations if they're showing
1342-
if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open')) {
1351+
if (mapContainer.hasClass('bh-sl-map-open')) {
13431352
$this.hide();
13441353
}
13451354

@@ -1367,7 +1376,7 @@
13671376
});
13681377

13691378
// Create array for normal locations
1370-
normalset = $.grep(locationset, function (val, i) {
1379+
normalset = $.grep(locationset, function (val) {
13711380
return val.featured !== 'true';
13721381
});
13731382

@@ -1562,10 +1571,11 @@
15621571
}
15631572

15641573
// Create the links that focus on the related marker
1565-
$('.' + _this.settings.locationList + ' ul').empty();
1574+
var locList = $('.' + _this.settings.locationList + ' ul');
1575+
locList.empty();
15661576
// Check the locationset and continue with the list setup or show no results message
15671577
if(locationset[0].lat === 0 && locationset[0].lng === 0) {
1568-
$('.' + _this.settings.locationList + ' ul').append(noResults);
1578+
locList.append(noResults);
15691579
}
15701580
else {
15711581
$(markers).each(function (x) {

0 commit comments

Comments
 (0)