Skip to content

Commit 5996dd6

Browse files
authored
Merge pull request bjorn2404#296 from bjorn2404/development
Development
2 parents 2b00f0f + 66d42fa commit 5996dd6

File tree

7 files changed

+88
-26
lines changed

7 files changed

+88
-26
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.12",
3+
"version": "3.1.13",
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: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v3.1.12 - 2023-06-19
1+
/*! jQuery Google Maps Store Locator - v3.1.13 - 2023-07-25
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2023 Bjorn Holine; Licensed MIT */
44

@@ -15,7 +15,7 @@
1515
// Variables used across multiple methods
1616
var $this, map, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalZoom, dataRequest, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService, prevSelectedMarkerBefore, prevSelectedMarkerAfter, firstRun, reload, nameAttrs, originalFilterVals;
1717
var featuredset = [], locationset = [], normalset = [], markers = [];
18-
var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {};
18+
var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {}, disabledFilterVals = {};
1919

2020
// Create the defaults once. DO NOT change these settings in this file - settings should be overridden in the plugin call
2121
var defaults = {
@@ -565,6 +565,7 @@
565565
// Track changes to the address search field.
566566
$('#' + this.settings.addressID).on('change.'+pluginName, function () {
567567
originalFilterVals = undefined;
568+
disabledFilterVals = {};
568569

569570
// Unset origin tracking if input field is removed.
570571
if (
@@ -2276,7 +2277,6 @@
22762277

22772278
if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
22782279
if ((olat) && (olng)) {
2279-
_this.settings.mapSettings.zoom = 0;
22802280
_this.processForm();
22812281
}
22822282
else {
@@ -2294,9 +2294,7 @@
22942294
if (_this.countFilters() === 0) {
22952295
_this.settings.mapSettings.zoom = originalZoom;
22962296
}
2297-
else {
2298-
_this.settings.mapSettings.zoom = 0;
2299-
}
2297+
23002298
_this.processForm();
23012299
}
23022300
else {
@@ -2322,7 +2320,6 @@
23222320
filters[filterKey] = [filterVal];
23232321
if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
23242322
if ((olat) && (olng)) {
2325-
_this.settings.mapSettings.zoom = 0;
23262323
_this.processForm();
23272324
}
23282325
else {
@@ -2876,13 +2873,19 @@
28762873
for (var i = 0; i < _this.settings.taxonomyFilters[key].length; i++) {
28772874
if (_this.settings.taxonomyFilters.hasOwnProperty(key)) {
28782875
$('#' + _this.settings.taxonomyFilters[key] + ' input, #' + _this.settings.taxonomyFilters[key] + ' option').each(function () {
2879-
if ($(this).val() !== '' && Array.from(new Set(availableValues[key].split(','))).indexOf($(this).val()) === -1) {
2876+
2877+
// Initial determination of values that should be disabled.
2878+
if ($(this).val() !== '' && ! Array.from(new Set(availableValues[key].split(','))).includes($(this).val())) {
2879+
if (! disabledFilterVals.hasOwnProperty(key)) {
2880+
disabledFilterVals[key] = [];
2881+
}
28802882

28812883
// Handle select options and radio button values when there is no address input.
28822884
if (
28832885
(typeof addressInput === 'undefined' || addressInput === '') &&
28842886
($(this).prop('tagName') === 'OPTION' || $(this).prop('type') === 'radio') &&
2885-
_this.hasSingleGroupFilterVal(filters, key)
2887+
_this.hasSingleGroupFilterVal(filters, key) &&
2888+
Array.from(new Set(originalFilterVals[key].split(','))).includes($(this).val())
28862889
) {
28872890
return;
28882891
}
@@ -2892,11 +2895,32 @@
28922895
(typeof addressInput !== 'undefined' || addressInput !== '') &&
28932896
($(this).prop('tagName') === 'OPTION' || $(this).prop('type') === 'radio') &&
28942897
_this.hasSingleGroupFilterVal(filters, key) &&
2895-
Array.from(new Set(originalFilterVals[key].split(','))).indexOf($(this).val()) !== -1
2898+
Array.from(new Set(originalFilterVals[key].split(','))).includes($(this).val()) &&
2899+
_this.countFilters() === 1
2900+
) {
2901+
return;
2902+
}
2903+
2904+
// Keep select options and radio button available values after one filter has been selected.
2905+
if (
2906+
($(this).prop('tagName') === 'OPTION' || $(this).prop('type') === 'radio') &&
2907+
_this.hasSingleGroupFilterVal(filters, key) &&
2908+
_this.countFilters() > 1 &&
2909+
Array.from(new Set(originalFilterVals[key].split(','))).includes($(this).val()) &&
2910+
! disabledFilterVals[key].includes($(this).val())
28962911
) {
28972912
return;
28982913
}
28992914

2915+
// Track disabled values.
2916+
if (
2917+
disabledFilterVals.hasOwnProperty(key) &&
2918+
Array.isArray(disabledFilterVals[key]) &&
2919+
! disabledFilterVals[key].includes($(this).val())
2920+
) {
2921+
disabledFilterVals[key].push($(this).val());
2922+
}
2923+
29002924
$(this).attr('disabled', true);
29012925
}
29022926
});
@@ -3177,7 +3201,11 @@
31773201
}
31783202

31793203
// Disable filter inputs if there are no locations with the values left.
3180-
if (firstRun !== true && this.settings.taxonomyFilters !== null && this.settings.exclusiveFiltering === false) {
3204+
if (
3205+
(firstRun !== true && _this.settings.exclusiveFiltering === false) ||
3206+
(_this.settings.fullMapStart === true && _this.settings.exclusiveFiltering === false) ||
3207+
(_this.settings.defaultLoc === true && _this.settings.exclusiveFiltering === false)
3208+
) {
31813209
_this.maybeDisableFilterOptions();
31823210
}
31833211

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.

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.12",
3+
"version": "3.1.13",
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ filtering.
3535

3636
## Changelog
3737

38+
### Version 3.1.13
39+
40+
* Fixed additional disable filtering functionality related to select options and radio buttons by globally tracking the disabled values.
41+
* Removed zoom reset to zero on taxonomy filtering to keep searched location in view.
42+
* Updated maybeDisableFilterOptions to run when full map start or default location settings are enabled.
43+
3844
### Version 3.1.12
3945

4046
* Added automatic reset functionality that fires when address input field value is removed (changed to blank).

src/js/jquery.storelocator.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Variables used across multiple methods
1212
var $this, map, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalZoom, dataRequest, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService, prevSelectedMarkerBefore, prevSelectedMarkerAfter, firstRun, reload, nameAttrs, originalFilterVals;
1313
var featuredset = [], locationset = [], normalset = [], markers = [];
14-
var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {};
14+
var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {}, disabledFilterVals = {};
1515

1616
// Create the defaults once. DO NOT change these settings in this file - settings should be overridden in the plugin call
1717
var defaults = {
@@ -561,6 +561,7 @@
561561
// Track changes to the address search field.
562562
$('#' + this.settings.addressID).on('change.'+pluginName, function () {
563563
originalFilterVals = undefined;
564+
disabledFilterVals = {};
564565

565566
// Unset origin tracking if input field is removed.
566567
if (
@@ -2272,7 +2273,6 @@
22722273

22732274
if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
22742275
if ((olat) && (olng)) {
2275-
_this.settings.mapSettings.zoom = 0;
22762276
_this.processForm();
22772277
}
22782278
else {
@@ -2290,9 +2290,7 @@
22902290
if (_this.countFilters() === 0) {
22912291
_this.settings.mapSettings.zoom = originalZoom;
22922292
}
2293-
else {
2294-
_this.settings.mapSettings.zoom = 0;
2295-
}
2293+
22962294
_this.processForm();
22972295
}
22982296
else {
@@ -2318,7 +2316,6 @@
23182316
filters[filterKey] = [filterVal];
23192317
if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
23202318
if ((olat) && (olng)) {
2321-
_this.settings.mapSettings.zoom = 0;
23222319
_this.processForm();
23232320
}
23242321
else {
@@ -2872,13 +2869,19 @@
28722869
for (var i = 0; i < _this.settings.taxonomyFilters[key].length; i++) {
28732870
if (_this.settings.taxonomyFilters.hasOwnProperty(key)) {
28742871
$('#' + _this.settings.taxonomyFilters[key] + ' input, #' + _this.settings.taxonomyFilters[key] + ' option').each(function () {
2875-
if ($(this).val() !== '' && Array.from(new Set(availableValues[key].split(','))).indexOf($(this).val()) === -1) {
2872+
2873+
// Initial determination of values that should be disabled.
2874+
if ($(this).val() !== '' && ! Array.from(new Set(availableValues[key].split(','))).includes($(this).val())) {
2875+
if (! disabledFilterVals.hasOwnProperty(key)) {
2876+
disabledFilterVals[key] = [];
2877+
}
28762878

28772879
// Handle select options and radio button values when there is no address input.
28782880
if (
28792881
(typeof addressInput === 'undefined' || addressInput === '') &&
28802882
($(this).prop('tagName') === 'OPTION' || $(this).prop('type') === 'radio') &&
2881-
_this.hasSingleGroupFilterVal(filters, key)
2883+
_this.hasSingleGroupFilterVal(filters, key) &&
2884+
Array.from(new Set(originalFilterVals[key].split(','))).includes($(this).val())
28822885
) {
28832886
return;
28842887
}
@@ -2888,11 +2891,32 @@
28882891
(typeof addressInput !== 'undefined' || addressInput !== '') &&
28892892
($(this).prop('tagName') === 'OPTION' || $(this).prop('type') === 'radio') &&
28902893
_this.hasSingleGroupFilterVal(filters, key) &&
2891-
Array.from(new Set(originalFilterVals[key].split(','))).indexOf($(this).val()) !== -1
2894+
Array.from(new Set(originalFilterVals[key].split(','))).includes($(this).val()) &&
2895+
_this.countFilters() === 1
2896+
) {
2897+
return;
2898+
}
2899+
2900+
// Keep select options and radio button available values after one filter has been selected.
2901+
if (
2902+
($(this).prop('tagName') === 'OPTION' || $(this).prop('type') === 'radio') &&
2903+
_this.hasSingleGroupFilterVal(filters, key) &&
2904+
_this.countFilters() > 1 &&
2905+
Array.from(new Set(originalFilterVals[key].split(','))).includes($(this).val()) &&
2906+
! disabledFilterVals[key].includes($(this).val())
28922907
) {
28932908
return;
28942909
}
28952910

2911+
// Track disabled values.
2912+
if (
2913+
disabledFilterVals.hasOwnProperty(key) &&
2914+
Array.isArray(disabledFilterVals[key]) &&
2915+
! disabledFilterVals[key].includes($(this).val())
2916+
) {
2917+
disabledFilterVals[key].push($(this).val());
2918+
}
2919+
28962920
$(this).attr('disabled', true);
28972921
}
28982922
});
@@ -3173,7 +3197,11 @@
31733197
}
31743198

31753199
// Disable filter inputs if there are no locations with the values left.
3176-
if (firstRun !== true && this.settings.taxonomyFilters !== null && this.settings.exclusiveFiltering === false) {
3200+
if (
3201+
(firstRun !== true && _this.settings.exclusiveFiltering === false) ||
3202+
(_this.settings.fullMapStart === true && _this.settings.exclusiveFiltering === false) ||
3203+
(_this.settings.defaultLoc === true && _this.settings.exclusiveFiltering === false)
3204+
) {
31773205
_this.maybeDisableFilterOptions();
31783206
}
31793207

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.12",
6+
"version": "3.1.13",
77
"author": {
88
"name": "Bjorn Holine",
99
"url": "https://www.bjornblog.com/"

0 commit comments

Comments
 (0)