Skip to content

Commit e784bce

Browse files
committed
Fixed JSHint formatting errors, documented new settings
1 parent 4956b51 commit e784bce

File tree

5 files changed

+69
-49
lines changed

5 files changed

+69
-49
lines changed

dist/assets/js/libs/handlebars.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assets/js/plugins/storeLocator/jquery.storelocator.js

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.0.9 - 2015-08-28
1+
/*! jQuery Google Maps Store Locator - v2.0.9 - 2015-09-19
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2015 Bjorn Holine; Licensed MIT */
44

@@ -34,7 +34,6 @@
3434
'catMarkers' : null,
3535
'lengthUnit' : 'm',
3636
'storeLimit' : 26,
37-
'debug' : false,
3837
'distanceAlert' : 60,
3938
'dataType' : 'xml',
4039
'dataLocation' : 'data/locations.xml',
@@ -68,7 +67,6 @@
6867
'inlineDirections' : false,
6968
'nameSearch' : false,
7069
'searchID' : 'bh-sl-search',
71-
'sessionStorage' : false,
7270
'nameAttribute' : 'name',
7371
'visibleMarkersList' : false,
7472
'infowindowTemplatePath' : 'assets/js/plugins/storeLocator/templates/infowindow-description.html',
@@ -81,6 +79,8 @@
8179
'taxonomyFiltersContainer' : 'bh-sl-filters-container',
8280
'exclusiveFiltering' : false,
8381
'querystringParams' : false,
82+
'debug' : true,
83+
'sessionStorage' : false,
8484
'callbackNotify' : null,
8585
'callbackBeforeSend' : null,
8686
'callbackSuccess' : null,
@@ -424,12 +424,16 @@
424424

425425
// JSON
426426
else if( dataTypeRead === 'json' ) {
427-
if (Array.isArray && Array.isArray(_this.settings.dataRaw))
427+
if (Array.isArray && Array.isArray(_this.settings.dataRaw)) {
428428
return _this.settings.dataRaw;
429-
else if (typeof _this.settings.dataRaw === 'string')
429+
}
430+
else if (typeof _this.settings.dataRaw === 'string') {
430431
return $.parseJSON(_this.settings.dataRaw);
431-
else
432+
}
433+
else {
432434
return [];
435+
}
436+
433437
}
434438
}
435439
// Remote data
@@ -470,8 +474,8 @@
470474
*/
471475
_start: function () {
472476
this.writeDebug('_start');
473-
var _this = this,
474-
doAutoGeo = this.settings.autoGeocode;
477+
var _this = this,
478+
doAutoGeo = this.settings.autoGeocode;
475479
// If a default location is set
476480
if (this.settings.defaultLoc === true) {
477481
// The address needs to be determined for the directions link
@@ -496,14 +500,14 @@
496500
if ( $('#' + this.settings.addressID).val().trim() !== ''){
497501
_this.writeDebug('Using Address Field');
498502
_this.processForm(null);
499-
doAutoGeo = false; // no need for additional processing
503+
doAutoGeo = false; // No need for additional processing
500504
}
501505
// If show full map option is true
502506
else if (this.settings.fullMapStart === true) {
503507
if((this.settings.querystringParams === true && this.getQueryString(this.settings.addressID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.searchID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.maxDistanceID))) {
504508
_this.writeDebug('Using Query String');
505509
this.processForm(null);
506-
doAutoGeo = false; // no need for additional processing
510+
doAutoGeo = false; // No need for additional processing
507511
}
508512
else {
509513
this.mapping(null);
@@ -513,7 +517,7 @@
513517
// HTML5 geolocation API option
514518
if (this.settings.autoGeocode === true && doAutoGeo === true) {
515519
_this.writeDebug('Auto Geo');
516-
// saved geo location (saves around 3-5 seconds)
520+
// Saved geo location (saves around 3-5 seconds)
517521
if (_this.settings.sessionStorage === true && window.sessionStorage && window.sessionStorage.getItem('myGeo')){
518522
_this.writeDebug('Using Session Saved Values for GEO');
519523
_this.autoGeocodeQuery(JSON.parse(window.sessionStorage.getItem('myGeo')));
@@ -522,17 +526,18 @@
522526
else if (navigator.geolocation) {
523527
navigator.geolocation.getCurrentPosition(function(position){
524528
_this.writeDebug('Current Position Result');
525-
// to not break autoGeocodeQuery then we create the obj to match the geolocation format
529+
// To not break autoGeocodeQuery then we create the obj to match the geolocation format
526530
var pos = {
527-
coords : {
528-
latitude : position.coords.latitude,
529-
longitude : position.coords.longitude,
530-
accuracy : position.coords.accuracy
531+
coords: {
532+
latitude : position.coords.latitude,
533+
longitude: position.coords.longitude,
534+
accuracy : position.coords.accuracy
531535
}
532536
};
533537
// Have to do this to get around scope issues
534-
if (_this.settings.sessionStorage === true && window.sessionStorage)
538+
if (_this.settings.sessionStorage === true && window.sessionStorage) {
535539
window.sessionStorage.setItem('myGeo',JSON.stringify(pos));
540+
}
536541
_this.autoGeocodeQuery(pos);
537542
}, function(error){
538543
_this._autoGeocodeError(error);
@@ -1236,8 +1241,8 @@
12361241
}
12371242
else{
12381243
// Get the user input and use it
1239-
addressInput = $addressInput.val() || '';
1240-
searchInput = $searchInput.val() || '';
1244+
addressInput = $addressInput.val() || '';
1245+
searchInput = $searchInput.val() || '';
12411246
// Get the distance if set
12421247
if (this.settings.maxDistance === true) {
12431248
distance = $distanceInput.val() || '';
@@ -2097,21 +2102,25 @@
20972102
}
20982103
},
20992104

2100-
writeDebug : function (){
2101-
// http://www.briangrinstead.com/blog/console-log-helper-function
2105+
/**
2106+
* console.log helper function
2107+
*
2108+
* http://www.briangrinstead.com/blog/console-log-helper-function
2109+
*/
2110+
writeDebug: function () {
21022111
if (window.console && this.settings.debug) {
21032112
// Only run on the first time through - reset this function to the appropriate console.log helper
21042113
if (Function.prototype.bind) {
21052114
this.writeDebug = Function.prototype.bind.call(console.log, console, 'StoreLocator :');
21062115
} else {
2107-
this.writeDebug = function(){
2116+
this.writeDebug = function () {
21082117
arguments[0] = 'StoreLocator : ' + arguments[0];
21092118
Function.prototype.apply.call(console.log, console, arguments);
21102119
};
21112120
}
21122121
this.writeDebug.apply(this, arguments);
21132122
}
2114-
}
2123+
}
21152124

21162125
});
21172126

dist/assets/js/plugins/storeLocator/jquery.storelocator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
| taxonomyFiltersContainer | 'bh-sl-filters-container' | Class of the container around the filters. |
5858
| exclusiveFiltering | false | Set to true to enable exclusive taxonomy filtering rather than the default inclusive. |
5959
| querystringParams | false | Set to true to enable query string support for passing input variables from page to page. |
60+
| debug | false | Set to true to enable console.log helper function that can be used for debugging. |
61+
| sessionStorage | false | Set to true to enable Window.sessionStorage for user's location when autoGeocode is enabled. |
6062
| callbackNotify | null | Callback that can override the notify method. |
6163
| callbackBeforeSend | null | Callback that fires before the AJAX request. |
6264
| callbackSuccess | null | Callback that fires on successful AJAX request. |

src/js/jquery.storelocator.js

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
'catMarkers' : null,
3232
'lengthUnit' : 'm',
3333
'storeLimit' : 26,
34-
'debug' : false,
3534
'distanceAlert' : 60,
3635
'dataType' : 'xml',
3736
'dataLocation' : 'data/locations.xml',
@@ -65,7 +64,6 @@
6564
'inlineDirections' : false,
6665
'nameSearch' : false,
6766
'searchID' : 'bh-sl-search',
68-
'sessionStorage' : false,
6967
'nameAttribute' : 'name',
7068
'visibleMarkersList' : false,
7169
'infowindowTemplatePath' : 'assets/js/plugins/storeLocator/templates/infowindow-description.html',
@@ -78,6 +76,8 @@
7876
'taxonomyFiltersContainer' : 'bh-sl-filters-container',
7977
'exclusiveFiltering' : false,
8078
'querystringParams' : false,
79+
'debug' : true,
80+
'sessionStorage' : false,
8181
'callbackNotify' : null,
8282
'callbackBeforeSend' : null,
8383
'callbackSuccess' : null,
@@ -421,12 +421,16 @@
421421

422422
// JSON
423423
else if( dataTypeRead === 'json' ) {
424-
if (Array.isArray && Array.isArray(_this.settings.dataRaw))
424+
if (Array.isArray && Array.isArray(_this.settings.dataRaw)) {
425425
return _this.settings.dataRaw;
426-
else if (typeof _this.settings.dataRaw === 'string')
426+
}
427+
else if (typeof _this.settings.dataRaw === 'string') {
427428
return $.parseJSON(_this.settings.dataRaw);
428-
else
429+
}
430+
else {
429431
return [];
432+
}
433+
430434
}
431435
}
432436
// Remote data
@@ -467,8 +471,8 @@
467471
*/
468472
_start: function () {
469473
this.writeDebug('_start');
470-
var _this = this,
471-
doAutoGeo = this.settings.autoGeocode;
474+
var _this = this,
475+
doAutoGeo = this.settings.autoGeocode;
472476
// If a default location is set
473477
if (this.settings.defaultLoc === true) {
474478
// The address needs to be determined for the directions link
@@ -493,14 +497,14 @@
493497
if ( $('#' + this.settings.addressID).val().trim() !== ''){
494498
_this.writeDebug('Using Address Field');
495499
_this.processForm(null);
496-
doAutoGeo = false; // no need for additional processing
500+
doAutoGeo = false; // No need for additional processing
497501
}
498502
// If show full map option is true
499503
else if (this.settings.fullMapStart === true) {
500504
if((this.settings.querystringParams === true && this.getQueryString(this.settings.addressID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.searchID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.maxDistanceID))) {
501505
_this.writeDebug('Using Query String');
502506
this.processForm(null);
503-
doAutoGeo = false; // no need for additional processing
507+
doAutoGeo = false; // No need for additional processing
504508
}
505509
else {
506510
this.mapping(null);
@@ -510,7 +514,7 @@
510514
// HTML5 geolocation API option
511515
if (this.settings.autoGeocode === true && doAutoGeo === true) {
512516
_this.writeDebug('Auto Geo');
513-
// saved geo location (saves around 3-5 seconds)
517+
// Saved geo location (saves around 3-5 seconds)
514518
if (_this.settings.sessionStorage === true && window.sessionStorage && window.sessionStorage.getItem('myGeo')){
515519
_this.writeDebug('Using Session Saved Values for GEO');
516520
_this.autoGeocodeQuery(JSON.parse(window.sessionStorage.getItem('myGeo')));
@@ -519,17 +523,18 @@
519523
else if (navigator.geolocation) {
520524
navigator.geolocation.getCurrentPosition(function(position){
521525
_this.writeDebug('Current Position Result');
522-
// to not break autoGeocodeQuery then we create the obj to match the geolocation format
526+
// To not break autoGeocodeQuery then we create the obj to match the geolocation format
523527
var pos = {
524-
coords : {
525-
latitude : position.coords.latitude,
526-
longitude : position.coords.longitude,
527-
accuracy : position.coords.accuracy
528+
coords: {
529+
latitude : position.coords.latitude,
530+
longitude: position.coords.longitude,
531+
accuracy : position.coords.accuracy
528532
}
529533
};
530534
// Have to do this to get around scope issues
531-
if (_this.settings.sessionStorage === true && window.sessionStorage)
535+
if (_this.settings.sessionStorage === true && window.sessionStorage) {
532536
window.sessionStorage.setItem('myGeo',JSON.stringify(pos));
537+
}
533538
_this.autoGeocodeQuery(pos);
534539
}, function(error){
535540
_this._autoGeocodeError(error);
@@ -1233,8 +1238,8 @@
12331238
}
12341239
else{
12351240
// Get the user input and use it
1236-
addressInput = $addressInput.val() || '';
1237-
searchInput = $searchInput.val() || '';
1241+
addressInput = $addressInput.val() || '';
1242+
searchInput = $searchInput.val() || '';
12381243
// Get the distance if set
12391244
if (this.settings.maxDistance === true) {
12401245
distance = $distanceInput.val() || '';
@@ -2094,21 +2099,25 @@
20942099
}
20952100
},
20962101

2097-
writeDebug : function (){
2098-
// http://www.briangrinstead.com/blog/console-log-helper-function
2102+
/**
2103+
* console.log helper function
2104+
*
2105+
* http://www.briangrinstead.com/blog/console-log-helper-function
2106+
*/
2107+
writeDebug: function () {
20992108
if (window.console && this.settings.debug) {
21002109
// Only run on the first time through - reset this function to the appropriate console.log helper
21012110
if (Function.prototype.bind) {
21022111
this.writeDebug = Function.prototype.bind.call(console.log, console, 'StoreLocator :');
21032112
} else {
2104-
this.writeDebug = function(){
2113+
this.writeDebug = function () {
21052114
arguments[0] = 'StoreLocator : ' + arguments[0];
21062115
Function.prototype.apply.call(console.log, console, arguments);
21072116
};
21082117
}
21092118
this.writeDebug.apply(this, arguments);
21102119
}
2111-
}
2120+
}
21122121

21132122
});
21142123

0 commit comments

Comments
 (0)