Skip to content

Commit 7b40a55

Browse files
committed
Added query string parameter filter check so that results can be filtered with URL query strings
1 parent 87b50d0 commit 7b40a55

File tree

7 files changed

+50
-9
lines changed

7 files changed

+50
-9
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": "2.6.2",
3+
"version": "2.6.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: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.6.2 - 2016-08-26
1+
/*! jQuery Google Maps Store Locator - v2.6.3 - 2016-08-30
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2016 Bjorn Holine; Licensed MIT */
44

@@ -1640,7 +1640,6 @@
16401640

16411641
/**
16421642
* Check for existing filter selections
1643-
*
16441643
*/
16451644
checkFilters: function () {
16461645
this.writeDebug('checkFilters');
@@ -1658,6 +1657,24 @@
16581657
}
16591658
},
16601659

1660+
/**
1661+
* Check query string parameters for filter values.
1662+
*/
1663+
checkQueryStringFilters: function () {
1664+
this.writeDebug('checkQueryStringFilters',arguments);
1665+
// Loop through the filters.
1666+
for(var key in filters) {
1667+
if(filters.hasOwnProperty(key)) {
1668+
var filterVal = this.getQueryString(key);
1669+
1670+
// Only add the taxonomy id if it doesn't already exist
1671+
if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
1672+
filters[key] = [filterVal];
1673+
}
1674+
}
1675+
}
1676+
},
1677+
16611678
/**
16621679
* Get the filter key from the taxonomyFilter setting
16631680
*
@@ -1689,6 +1706,9 @@
16891706
filters[key] = [];
16901707
}
16911708
}
1709+
1710+
// Check query string for taxonomy parameter keys.
1711+
_this.checkQueryStringFilters();
16921712

16931713
// Handle filter updates
16941714
$('.' + this.settings.taxonomyFiltersContainer).on('change.'+pluginName, 'input, select', function (e) {

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

Lines changed: 3 additions & 3 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": "2.6.2",
3+
"version": "2.6.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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ filtering.
3838
### Version 2.6.3
3939

4040
* Added [InfoBubble](https://github.com/googlemaps/js-info-bubble) support and example file.
41+
* Added query string parameter filter check so that results can be filtered with URL query strings.
4142

4243
### Version 2.6.2
4344

src/js/jquery.storelocator.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,6 @@
16371637

16381638
/**
16391639
* Check for existing filter selections
1640-
*
16411640
*/
16421641
checkFilters: function () {
16431642
this.writeDebug('checkFilters');
@@ -1655,6 +1654,24 @@
16551654
}
16561655
},
16571656

1657+
/**
1658+
* Check query string parameters for filter values.
1659+
*/
1660+
checkQueryStringFilters: function () {
1661+
this.writeDebug('checkQueryStringFilters',arguments);
1662+
// Loop through the filters.
1663+
for(var key in filters) {
1664+
if(filters.hasOwnProperty(key)) {
1665+
var filterVal = this.getQueryString(key);
1666+
1667+
// Only add the taxonomy id if it doesn't already exist
1668+
if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
1669+
filters[key] = [filterVal];
1670+
}
1671+
}
1672+
}
1673+
},
1674+
16581675
/**
16591676
* Get the filter key from the taxonomyFilter setting
16601677
*
@@ -1686,6 +1703,9 @@
16861703
filters[key] = [];
16871704
}
16881705
}
1706+
1707+
// Check query string for taxonomy parameter keys.
1708+
_this.checkQueryStringFilters();
16891709

16901710
// Handle filter updates
16911711
$('.' + this.settings.taxonomyFiltersContainer).on('change.'+pluginName, 'input, select', function (e) {

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

0 commit comments

Comments
 (0)