Skip to content

Commit

Permalink
Fixed error when filtering with query strings where filter values wit…
Browse files Browse the repository at this point in the history
…h spaces wouldn't work, updated processForm method so submitting the map removes focus from any of the form input/select fields instead of just the address input, updated filterData string replace methods to match string replace method in filters setup
  • Loading branch information
bjorn2404 committed Jun 12, 2017
1 parent 638abb2 commit 1201e16
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-storelocator-plugin",
"version": "2.7.3",
"version": "2.7.4",
"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.",
"repository": {
"type": "git",
Expand Down
17 changes: 8 additions & 9 deletions dist/assets/js/plugins/storeLocator/jquery.storelocator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jQuery Google Maps Store Locator - v2.7.3 - 2017-05-07
/*! jQuery Google Maps Store Locator - v2.7.4 - 2017-06-11
* http://www.bjornblog.com/web/jquery-store-locator-plugin
* Copyright (c) 2017 Bjorn Holine; Licensed MIT */

Expand Down Expand Up @@ -875,7 +875,7 @@

if(typeof data[k] !== 'undefined') {
for (var l = 0; l < filterTests.length; l++) {
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/[^\x00-\x7F]/g, ''));
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, ''));
}
}

Expand All @@ -885,7 +885,7 @@
}
// Inclusive filtering
else {
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/[^\x00-\x7F]/g, '')))) {
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, '')))) {
filterTest = false;
}
}
Expand Down Expand Up @@ -1522,8 +1522,8 @@
e.preventDefault();
}

// Blur the input field to hide mobile keyboards.
$addressInput.blur();
// Blur any form field to hide mobile keyboards.
$('.' + _this.settings.formContainer +' input, .' + _this.settings.formContainer + ' select').blur();

// Query string parameters
if(this.settings.querystringParams === true) {
Expand Down Expand Up @@ -1770,21 +1770,20 @@
if ( $taxGroupContainer.find('input[type="checkbox"]').length ) {

for ( var i = 0; i < value.length; i++ ) {
$taxGroupContainer.find('input:checkbox[value=' + value[i] + ']').prop('checked', true);
$taxGroupContainer.find('input:checkbox[value="' + value[i] + '"]').prop('checked', true);
}

}

// Handle select fields.
if ( $taxGroupContainer.find('select').length ) {
// Only expecting one value for select fields.
$taxGroupContainer.find('option[value=' + value[0] + ']').prop('selected', true);
$taxGroupContainer.find('option[value="' + value[0] + '"]').prop('selected', true);
}

// Handle radio buttons.
if ( $taxGroupContainer.find('input[type="radio"]').length ) {
// Only one value for radio button.
$taxGroupContainer.find('input:radio[value=' + value[0] + ']').prop('checked', true);
$taxGroupContainer.find('input:radio[value="' + value[0] + '"]').prop('checked', true);
}
},

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-storelocator-plugin",
"version": "2.7.3",
"version": "2.7.4",
"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.",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ filtering.

## Changelog

### Version 2.7.4

* Fixed error when filtering with query strings where filter values with spaces wouldn't work.
* Updated processForm method so submitting the map removes focus from any of the form input/select fields instead of just the address input.
* Updated filterData string replace methods to match string replace method in filters setup.

### Version 2.7.3

* Added ability to indicate multiple query string parameter values (for checkboxes) with a comma separated list value.
Expand Down
15 changes: 7 additions & 8 deletions src/js/jquery.storelocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@

if(typeof data[k] !== 'undefined') {
for (var l = 0; l < filterTests.length; l++) {
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/[^\x00-\x7F]/g, ''));
exclusiveTest[l] = new RegExp(filterTests[l], 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, ''));
}
}

Expand All @@ -882,7 +882,7 @@
}
// Inclusive filtering
else {
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/[^\x00-\x7F]/g, '')))) {
if (typeof data[k] === 'undefined' || !(new RegExp(filters[k].join(''), 'i').test(data[k].replace(/([^\x00-\x7F]|[.*+?^=!:${}()|\[\]\/\\])/g, '')))) {
filterTest = false;
}
}
Expand Down Expand Up @@ -1519,8 +1519,8 @@
e.preventDefault();
}

// Blur the input field to hide mobile keyboards.
$addressInput.blur();
// Blur any form field to hide mobile keyboards.
$('.' + _this.settings.formContainer +' input, .' + _this.settings.formContainer + ' select').blur();

// Query string parameters
if(this.settings.querystringParams === true) {
Expand Down Expand Up @@ -1767,21 +1767,20 @@
if ( $taxGroupContainer.find('input[type="checkbox"]').length ) {

for ( var i = 0; i < value.length; i++ ) {
$taxGroupContainer.find('input:checkbox[value=' + value[i] + ']').prop('checked', true);
$taxGroupContainer.find('input:checkbox[value="' + value[i] + '"]').prop('checked', true);
}

}

// Handle select fields.
if ( $taxGroupContainer.find('select').length ) {
// Only expecting one value for select fields.
$taxGroupContainer.find('option[value=' + value[0] + ']').prop('selected', true);
$taxGroupContainer.find('option[value="' + value[0] + '"]').prop('selected', true);
}

// Handle radio buttons.
if ( $taxGroupContainer.find('input[type="radio"]').length ) {
// Only one value for radio button.
$taxGroupContainer.find('input:radio[value=' + value[0] + ']').prop('checked', true);
$taxGroupContainer.find('input:radio[value="' + value[0] + '"]').prop('checked', true);
}
},

Expand Down
2 changes: 1 addition & 1 deletion storelocator.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "jQuery Google Maps Store Locator",
"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.",
"keywords": ["jquery","locator","store", "location", "locations", "maps", "map", "stores", "find"],
"version": "2.7.3",
"version": "2.7.4",
"author": {
"name": "Bjorn Holine",
"url": "http://www.bjornblog.com/"
Expand Down

0 comments on commit 1201e16

Please sign in to comment.