Skip to content

Commit 041ebfb

Browse files
committed
Fix name search filter value not clearing if form input is cleared
1 parent 3c54c2b commit 041ebfb

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

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

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

@@ -1725,6 +1725,7 @@
17251725
// Get the user input and use it
17261726
addressInput = $addressInput.val() || '';
17271727
searchInput = $searchInput.val() || '';
1728+
17281729
// Get the distance if set
17291730
if (this.settings.maxDistance === true) {
17301731
distance = $distanceInput.val() || '';
@@ -1772,6 +1773,10 @@
17721773
this._start();
17731774
}
17741775
else if (addressInput !== '') {
1776+
// Check for existing name search and remove if address input is blank.
1777+
if (searchInput === '' && filters.hasOwnProperty('name')) {
1778+
delete filters.name;
1779+
}
17751780

17761781
// Geocode the origin if needed
17771782
if (typeof originalOrigin !== 'undefined' && typeof olat !== 'undefined' && typeof olng !== 'undefined' && (addressInput === originalOrigin)) {
@@ -2895,9 +2900,9 @@
28952900
// Create array for featured locations
28962901
featuredset = $.grep(locationset, function (val) {
28972902

2898-
if (val.hasOwnProperty('featured')) {
2899-
return val.featured === 'true';
2900-
}
2903+
if (val.hasOwnProperty('featured')) {
2904+
return val.featured === 'true';
2905+
}
29012906
});
29022907

29032908
// Featured location restrictions.
@@ -2954,7 +2959,7 @@
29542959
storeNumToShow = _this.settings.locationsPerPage;
29552960
storeStart = page * _this.settings.locationsPerPage;
29562961

2957-
if( (storeStart + storeNumToShow) > locationset.length ) {
2962+
if ( (storeStart + storeNumToShow) > locationset.length ) {
29582963
storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length);
29592964
}
29602965

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.

src/js/jquery.storelocator.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@
17211721
// Get the user input and use it
17221722
addressInput = $addressInput.val() || '';
17231723
searchInput = $searchInput.val() || '';
1724+
17241725
// Get the distance if set
17251726
if (this.settings.maxDistance === true) {
17261727
distance = $distanceInput.val() || '';
@@ -1768,6 +1769,10 @@
17681769
this._start();
17691770
}
17701771
else if (addressInput !== '') {
1772+
// Check for existing name search and remove if address input is blank.
1773+
if (searchInput === '' && filters.hasOwnProperty('name')) {
1774+
delete filters.name;
1775+
}
17711776

17721777
// Geocode the origin if needed
17731778
if (typeof originalOrigin !== 'undefined' && typeof olat !== 'undefined' && typeof olng !== 'undefined' && (addressInput === originalOrigin)) {
@@ -2891,9 +2896,9 @@
28912896
// Create array for featured locations
28922897
featuredset = $.grep(locationset, function (val) {
28932898

2894-
if (val.hasOwnProperty('featured')) {
2895-
return val.featured === 'true';
2896-
}
2899+
if (val.hasOwnProperty('featured')) {
2900+
return val.featured === 'true';
2901+
}
28972902
});
28982903

28992904
// Featured location restrictions.
@@ -2950,7 +2955,7 @@
29502955
storeNumToShow = _this.settings.locationsPerPage;
29512956
storeStart = page * _this.settings.locationsPerPage;
29522957

2953-
if( (storeStart + storeNumToShow) > locationset.length ) {
2958+
if ( (storeStart + storeNumToShow) > locationset.length ) {
29542959
storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length);
29552960
}
29562961

0 commit comments

Comments
 (0)