Skip to content

Commit 1664b97

Browse files
committed
Fixed empty name search field value overriding filter results, Fixed groups of filters not applying together
1 parent b9e4b4a commit 1664b97

File tree

8 files changed

+43
-25
lines changed

8 files changed

+43
-25
lines changed

bower.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": "3.1.2",
3+
"version": "3.1.3",
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",

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v3.1.2 - 2021-03-27
1+
/*! jQuery Google Maps Store Locator - v3.1.3 - 2021-05-02
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2021 Bjorn Holine; Licensed MIT */
44

@@ -1010,19 +1010,27 @@
10101010
* @returns {boolean}
10111011
*/
10121012
filterData: function (data, filters) {
1013-
this.writeDebug('filterData',arguments);
1014-
var filterTest = false;
1013+
this.writeDebug('filterData', arguments);
1014+
var filterTest = true;
10151015

10161016
for (var k in filters) {
10171017
if (filters.hasOwnProperty(k)) {
1018+
var testResults = [];
10181019

1019-
// Exclusive filtering
1020-
if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
1021-
filterTest = this.filterMatching(filters[k], data[k], false );
1020+
for (var l = 0; l < filters[k].length; l++) {
1021+
1022+
// Exclusive filtering
1023+
if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
1024+
testResults[l] = this.filterMatching(filters[k], data[k], false);
1025+
}
1026+
// Inclusive filtering
1027+
else {
1028+
testResults[l] = this.filterMatching(filters[k], data[k]);
1029+
}
10221030
}
1023-
// Inclusive filtering
1024-
else {
1025-
filterTest = this.filterMatching(filters[k], data[k]);
1031+
1032+
if (testResults.indexOf(true) === -1) {
1033+
filterTest = false;
10261034
}
10271035
}
10281036
}
@@ -2812,7 +2820,7 @@
28122820

28132821
// Name search - using taxonomy filter to handle
28142822
if (_this.settings.nameSearch === true) {
2815-
if (typeof searchInput !== 'undefined') {
2823+
if (typeof searchInput !== 'undefined' && '' !== searchInput) {
28162824
filters[_this.settings.nameAttribute] = [searchInput];
28172825
}
28182826
}

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.

dist/categories-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ <h1 class="bh-sl-title">Using Chipotle as an Example</h1>
127127

128128
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
129129
<script src="assets/js/libs/handlebars.min.js"></script>
130-
<script src="https://maps.google.com/maps/api/js"></script>
130+
<script src="https://maps.google.com/maps/api/js?key=AIzaSyAdkGsZ0H4hJpSOLBbrELzmfQEHawLV5Q8"></script>
131131
<script src="assets/js/plugins/storeLocator/jquery.storelocator.js"></script>
132132
<script>
133133
$(function() {

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": "3.1.2",
3+
"version": "3.1.3",
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ filtering.
3737

3838
### Version 3.1.3
3939

40+
* Fixed empty name search field value overriding filter results.
41+
* Fixed groups of filters not applying together.
4042
* Fixed potential error from occurring if fullMapStartListLimit is set and the number of locations is less than the limit.
4143

4244
### Version 3.1.2

src/js/jquery.storelocator.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,19 +1006,27 @@
10061006
* @returns {boolean}
10071007
*/
10081008
filterData: function (data, filters) {
1009-
this.writeDebug('filterData',arguments);
1010-
var filterTest = false;
1009+
this.writeDebug('filterData', arguments);
1010+
var filterTest = true;
10111011

10121012
for (var k in filters) {
10131013
if (filters.hasOwnProperty(k)) {
1014+
var testResults = [];
10141015

1015-
// Exclusive filtering
1016-
if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
1017-
filterTest = this.filterMatching(filters[k], data[k], false );
1016+
for (var l = 0; l < filters[k].length; l++) {
1017+
1018+
// Exclusive filtering
1019+
if (this.settings.exclusiveFiltering === true || (this.settings.exclusiveTax !== null && Array.isArray(this.settings.exclusiveTax) && this.settings.exclusiveTax.indexOf(k) !== -1)) {
1020+
testResults[l] = this.filterMatching(filters[k], data[k], false);
1021+
}
1022+
// Inclusive filtering
1023+
else {
1024+
testResults[l] = this.filterMatching(filters[k], data[k]);
1025+
}
10181026
}
1019-
// Inclusive filtering
1020-
else {
1021-
filterTest = this.filterMatching(filters[k], data[k]);
1027+
1028+
if (testResults.indexOf(true) === -1) {
1029+
filterTest = false;
10221030
}
10231031
}
10241032
}
@@ -2808,7 +2816,7 @@
28082816

28092817
// Name search - using taxonomy filter to handle
28102818
if (_this.settings.nameSearch === true) {
2811-
if (typeof searchInput !== 'undefined') {
2819+
if (typeof searchInput !== 'undefined' && '' !== searchInput) {
28122820
filters[_this.settings.nameAttribute] = [searchInput];
28132821
}
28142822
}

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","dealer","location", "locations", "maps", "map", "stores", "find"],
6-
"version": "3.1.2",
6+
"version": "3.1.3",
77
"author": {
88
"name": "Bjorn Holine",
99
"url": "http://www.bjornblog.com/"

0 commit comments

Comments
 (0)