Skip to content

Commit 00ddbed

Browse files
committed
Updated functionality reset disabled form filters when Reset button is clicked
1 parent aded2c5 commit 00ddbed

File tree

4 files changed

+44
-21
lines changed

4 files changed

+44
-21
lines changed

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

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

@@ -285,6 +285,7 @@
285285
featuredset = [];
286286
normalset = [];
287287
markers = [];
288+
originalFilterVals = [];
288289
firstRun = false;
289290
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li');
290291

@@ -345,8 +346,9 @@
345346
this.reset();
346347
reload = true;
347348

348-
if ( this.settings.taxonomyFilters !== null ) {
349+
if (this.settings.taxonomyFilters !== null) {
349350
this.formFiltersReset();
351+
this.resetDisabledFilterVals();
350352
this.taxonomyFiltersInit();
351353
}
352354

@@ -2769,14 +2771,11 @@
27692771
},
27702772

27712773
/**
2772-
* Disable input fields that aren't available within the current location set
2774+
* Reset disabled form fields
27732775
*/
2774-
maybeDisableFilterOptions: function() {
2775-
this.writeDebug('maybeDisableFilterOptions');
2776-
var availableValues = [];
2777-
var _this = this;
2776+
resetDisabledFilterVals: function() {
2777+
this.writeDebug('resetDisabledFilterVals');
27782778

2779-
// Initially reset any input/option fields that were previously disabled.
27802779
for (var taxKey in this.settings.taxonomyFilters) {
27812780
if (this.settings.taxonomyFilters.hasOwnProperty(taxKey)) {
27822781
for (var x = 0; x < this.settings.taxonomyFilters[taxKey].length; x++) {
@@ -2790,6 +2789,18 @@
27902789
}
27912790
}
27922791
}
2792+
},
2793+
2794+
/**
2795+
* Disable input fields that aren't available within the current location set
2796+
*/
2797+
maybeDisableFilterOptions: function() {
2798+
this.writeDebug('maybeDisableFilterOptions');
2799+
var availableValues = [];
2800+
var _this = this;
2801+
2802+
// Initially reset any input/option fields that were previously disabled.
2803+
this.resetDisabledFilterVals();
27932804

27942805
// Loop through current location set to determine what filter values are still available.
27952806
for (var location in locationset) {
@@ -3119,8 +3130,8 @@
31193130
locationset = featuredset.concat(normalset);
31203131
}
31213132

3122-
// Disable filter inputs of there are no locations with the values left.
3123-
if (firstRun !== true && _this.settings.exclusiveFiltering === false) {
3133+
// Disable filter inputs if there are no locations with the values left.
3134+
if (firstRun !== true && this.settings.taxonomyFilters !== null && this.settings.exclusiveFiltering === false) {
31243135
_this.maybeDisableFilterOptions();
31253136
}
31263137

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.

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ filtering.
3939

4040
* Fixed issue with new disable filtering functionality with radio buttons.
4141
* Fixed issue with reset button where all locations were duplicated - introduced in v3.0.1
42+
* Updated functionality reset disabled form filters when Reset button is clicked.
4243

4344
### Version 3.1.10
4445

src/js/jquery.storelocator.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
featuredset = [];
282282
normalset = [];
283283
markers = [];
284+
originalFilterVals = [];
284285
firstRun = false;
285286
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li');
286287

@@ -341,8 +342,9 @@
341342
this.reset();
342343
reload = true;
343344

344-
if ( this.settings.taxonomyFilters !== null ) {
345+
if (this.settings.taxonomyFilters !== null) {
345346
this.formFiltersReset();
347+
this.resetDisabledFilterVals();
346348
this.taxonomyFiltersInit();
347349
}
348350

@@ -2765,14 +2767,11 @@
27652767
},
27662768

27672769
/**
2768-
* Disable input fields that aren't available within the current location set
2770+
* Reset disabled form fields
27692771
*/
2770-
maybeDisableFilterOptions: function() {
2771-
this.writeDebug('maybeDisableFilterOptions');
2772-
var availableValues = [];
2773-
var _this = this;
2772+
resetDisabledFilterVals: function() {
2773+
this.writeDebug('resetDisabledFilterVals');
27742774

2775-
// Initially reset any input/option fields that were previously disabled.
27762775
for (var taxKey in this.settings.taxonomyFilters) {
27772776
if (this.settings.taxonomyFilters.hasOwnProperty(taxKey)) {
27782777
for (var x = 0; x < this.settings.taxonomyFilters[taxKey].length; x++) {
@@ -2786,6 +2785,18 @@
27862785
}
27872786
}
27882787
}
2788+
},
2789+
2790+
/**
2791+
* Disable input fields that aren't available within the current location set
2792+
*/
2793+
maybeDisableFilterOptions: function() {
2794+
this.writeDebug('maybeDisableFilterOptions');
2795+
var availableValues = [];
2796+
var _this = this;
2797+
2798+
// Initially reset any input/option fields that were previously disabled.
2799+
this.resetDisabledFilterVals();
27892800

27902801
// Loop through current location set to determine what filter values are still available.
27912802
for (var location in locationset) {
@@ -3115,8 +3126,8 @@
31153126
locationset = featuredset.concat(normalset);
31163127
}
31173128

3118-
// Disable filter inputs of there are no locations with the values left.
3119-
if (firstRun !== true && _this.settings.exclusiveFiltering === false) {
3129+
// Disable filter inputs if there are no locations with the values left.
3130+
if (firstRun !== true && this.settings.taxonomyFilters !== null && this.settings.exclusiveFiltering === false) {
31203131
_this.maybeDisableFilterOptions();
31213132
}
31223133

0 commit comments

Comments
 (0)