Skip to content

Commit 8132e0f

Browse files
committed
Added exclusiveFiltering and callbackFilters, fixed fullMapStart and inlineDirections combo bug, fixed olat/olng not being set in autoGeocodeQuery method
1 parent 7793c8a commit 8132e0f

File tree

8 files changed

+79
-22
lines changed

8 files changed

+79
-22
lines changed

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.0.5 - 2015-01-04
1+
/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-24
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2015 Bjorn Holine; Licensed MIT */
44

@@ -75,6 +75,7 @@
7575
'infowindowTemplateID' : null,
7676
'taxonomyFilters' : null,
7777
'taxonomyFiltersContainer' : 'bh-sl-filters-container',
78+
'exclusiveFiltering' : false,
7879
'querystringParams' : false,
7980
'callbackNotify' : null,
8081
'callbackBeforeSend' : null,
@@ -89,6 +90,7 @@
8990
'callbackNoResults' : null,
9091
'callbackListClick' : null,
9192
'callbackMarkerClick' : null,
93+
'callbackFilters' : null,
9294
// Language options
9395
'addressErrorAlert' : 'Unable to find address',
9496
'autoGeocodeErrorAlert' : 'Automatic location detection failed. Please fill in your address or zip code.',
@@ -626,8 +628,25 @@
626628

627629
for (var k in filters) {
628630
if (filters.hasOwnProperty(k)) {
629-
if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) {
630-
filterTest = false;
631+
632+
// Exclusive filtering
633+
if(this.settings.exclusiveFiltering === true) {
634+
var filterTests = filters[k];
635+
var exclusiveTest = [];
636+
637+
for(var l = 0; l < filterTests.length; l++) {
638+
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k]);
639+
}
640+
641+
if(exclusiveTest.indexOf(true) === -1) {
642+
filterTest = false;
643+
}
644+
}
645+
// Inclusive filtering
646+
else {
647+
if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) {
648+
filterTest = false;
649+
}
631650
}
632651
}
633652
}
@@ -951,8 +970,8 @@
951970
r.geocode({'latLng': latlng}, function (data) {
952971
if (data !== null) {
953972
var originAddress = data.address;
954-
mappingObj.lat = position.coords.latitude;
955-
mappingObj.lng = position.coords.longitude;
973+
olat = mappingObj.lat = position.coords.latitude;
974+
olng = mappingObj.lng = position.coords.longitude;
956975
mappingObj.origin = originAddress;
957976
_this.mapping(mappingObj);
958977
} else {
@@ -1762,7 +1781,7 @@
17621781
});
17631782

17641783
// Inline directions
1765-
if(_this.settings.inlineDirections === true){
1784+
if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') {
17661785
// Open directions
17671786
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) {
17681787
e.preventDefault();
@@ -1859,6 +1878,11 @@
18591878
if (_this.settings.modal === true && _this.settings.callbackModalReady) {
18601879
_this.settings.callbackModalReady.call(this);
18611880
}
1881+
1882+
// Filters callback
1883+
if (_this.settings.callbackFilters) {
1884+
_this.settings.callbackFilters.call(this, filters);
1885+
}
18621886

18631887
});
18641888
}

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.

license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 Bjorn Holine
1+
Copyright (c) 2015 Bjorn Holine
22

33
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:
44

options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
| infowindowTemplateID | null | ID of infowindow template if using inline Handlebar templates instead of separate files. |
5454
| taxonomyFilters | null | Filtering object that can be used to set up live filtering (see categories example). |
5555
| taxonomyFiltersContainer | 'bh-sl-filters-container' | Class of the container around the filters. |
56+
| exclusiveFiltering | false | Set to true to enable exclusive taxonomy filtering rather than the default inclusive. |
5657
| querystringParams | false | Set to true to enable query string support for passing input variables from page to page. |
5758
| callbackNotify | null | Callback that can override the notify method. |
5859
| callbackBeforeSend | null | Callback that fires before the AJAX request. |
@@ -67,6 +68,7 @@
6768
| callbackNoResults | null | Callback that fires when no results are found. |
6869
| callbackListClick | null | Callback that fires when a list element is clicked in the location list. |
6970
| callbackMarkerClick | null | Callback that fires when a map marker is clicked. |
71+
| callbackFilters | null | Callback that fires when a filter is changed. |
7072
| addressErrorAlert | 'Unable to find address' | Language setting |
7173
| autoGeocodeErrorAlert | 'Automatic location detection failed. Please fill in your address or zip code.' | Language setting |
7274
| distanceErrorAlert | 'Unfortunately, our closest location is more than ' | Language setting |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-storelocator-plugin",
3-
"version": "2.0.5",
3+
"version": "2.0.6",
44
"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.",
55
"repository": {
66
"type": "git",

readme.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,22 @@ for even faster loading.
2727

2828
## Changelog
2929

30+
### Version 2.0.6
31+
32+
* Added the option to filter data exclusively rather than inclusively with the exclusiveFiltering setting.
33+
* Added callbackFilters that fires when a filter is changed and can return the filter values.
34+
* Fixed issue with fullMapStart and inlineDirections setting combination.
35+
* Fixed issue with global olat and olng variables not being set with autoGeocode setting enabled.
36+
3037
### Version 2.0.5
3138

32-
- Fixed typo with originMarker setup.
33-
- Made the originMarkerDim setting optional when setting a custom origin marker image - defaults to 32px by 32px.
34-
- Removed geocodeErrorAlert language option and switched error alerts to custom exceptions so users aren't shown
39+
* Fixed typo with originMarker setup.
40+
* Made the originMarkerDim setting optional when setting a custom origin marker image - defaults to 32px by 32px.
41+
* Removed geocodeErrorAlert language option and switched error alerts to custom exceptions so users aren't shown
3542
multiple alerts.
36-
- Fixed bug with inline directions where close icon wasn't being removed on page reload.
37-
- Added callbackListClick that fires when a list element is clicked.
38-
- Added callbackMarkerClick that fires when a map marker is clicked.
43+
* Fixed bug with inline directions where close icon wasn't being removed on page reload.
44+
* Added callbackListClick that fires when a list element is clicked.
45+
* Added callbackMarkerClick that fires when a map marker is clicked.
3946

4047
### Version 2.0.4
4148

src/js/jquery.storelocator.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
'infowindowTemplateID' : null,
7474
'taxonomyFilters' : null,
7575
'taxonomyFiltersContainer' : 'bh-sl-filters-container',
76+
'exclusiveFiltering' : false,
7677
'querystringParams' : false,
7778
'callbackNotify' : null,
7879
'callbackBeforeSend' : null,
@@ -87,6 +88,7 @@
8788
'callbackNoResults' : null,
8889
'callbackListClick' : null,
8990
'callbackMarkerClick' : null,
91+
'callbackFilters' : null,
9092
// Language options
9193
'addressErrorAlert' : 'Unable to find address',
9294
'autoGeocodeErrorAlert' : 'Automatic location detection failed. Please fill in your address or zip code.',
@@ -624,8 +626,25 @@
624626

625627
for (var k in filters) {
626628
if (filters.hasOwnProperty(k)) {
627-
if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) {
628-
filterTest = false;
629+
630+
// Exclusive filtering
631+
if(this.settings.exclusiveFiltering === true) {
632+
var filterTests = filters[k];
633+
var exclusiveTest = [];
634+
635+
for(var l = 0; l < filterTests.length; l++) {
636+
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k]);
637+
}
638+
639+
if(exclusiveTest.indexOf(true) === -1) {
640+
filterTest = false;
641+
}
642+
}
643+
// Inclusive filtering
644+
else {
645+
if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) {
646+
filterTest = false;
647+
}
629648
}
630649
}
631650
}
@@ -949,8 +968,8 @@
949968
r.geocode({'latLng': latlng}, function (data) {
950969
if (data !== null) {
951970
var originAddress = data.address;
952-
mappingObj.lat = position.coords.latitude;
953-
mappingObj.lng = position.coords.longitude;
971+
olat = mappingObj.lat = position.coords.latitude;
972+
olng = mappingObj.lng = position.coords.longitude;
954973
mappingObj.origin = originAddress;
955974
_this.mapping(mappingObj);
956975
} else {
@@ -1760,7 +1779,7 @@
17601779
});
17611780

17621781
// Inline directions
1763-
if(_this.settings.inlineDirections === true){
1782+
if(_this.settings.inlineDirections === true && typeof origin !== 'undefined') {
17641783
// Open directions
17651784
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) {
17661785
e.preventDefault();
@@ -1857,6 +1876,11 @@
18571876
if (_this.settings.modal === true && _this.settings.callbackModalReady) {
18581877
_this.settings.callbackModalReady.call(this);
18591878
}
1879+
1880+
// Filters callback
1881+
if (_this.settings.callbackFilters) {
1882+
_this.settings.callbackFilters.call(this, filters);
1883+
}
18601884

18611885
});
18621886
}

storelocator.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"title": "jQuery Google Maps Store Locator",
44
"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.",
55
"keywords": ["jquery","locator","store", "location", "locations", "maps", "map", "stores", "find"],
6-
"version": "2.0.5",
6+
"version": "2.0.6",
77
"author": {
88
"name": "Bjorn Holine",
99
"url": "http://www.bjornblog.com/"

0 commit comments

Comments
 (0)