Skip to content

Commit 35bcd22

Browse files
committed
Fixed pagination bubbling issue, Fixed pagination issues with autoGeocode and dragSearch combinations
1 parent e3861b1 commit 35bcd22

File tree

7 files changed

+60
-27
lines changed

7 files changed

+60
-27
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.5.1",
3+
"version": "2.5.2",
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: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.5.1 - 2016-03-12
1+
/*! jQuery Google Maps Store Locator - v2.5.2 - 2016-03-15
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2016 Bjorn Holine; Licensed MIT */
44

@@ -259,6 +259,9 @@
259259
}
260260
$(document).off('click', '.' + this.settings.locationList + ' li .loc-directions a');
261261
}
262+
if(this.settings.pagination === true) {
263+
$(document).off('click.'+pluginName, '.bh-sl-pagination li');
264+
}
262265
},
263266

264267
/**
@@ -497,7 +500,8 @@
497500
this.writeDebug('_start');
498501
var _this = this,
499502
doAutoGeo = this.settings.autoGeocode,
500-
latlng;
503+
latlng,
504+
originAddress;
501505

502506
// Full map blank start
503507
if (_this.settings.fullMapStartBlank !== false) {
@@ -531,7 +535,7 @@
531535
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
532536
r.geocode({'latLng': latlng}, function (data) {
533537
if (data !== null) {
534-
var originAddress = data.address;
538+
originAddress = addressInput = data.address;
535539
olat = mappingObj.lat = _this.settings.defaultLat;
536540
olng = mappingObj.lng = _this.settings.defaultLng;
537541
mappingObj.origin = originAddress;
@@ -1155,14 +1159,16 @@
11551159
*/
11561160
autoGeocodeQuery: function (position) {
11571161
this.writeDebug('autoGeocodeQuery',arguments);
1158-
var _this = this;
1159-
var mappingObj = {};
1162+
var _this = this,
1163+
originAddress;
1164+
1165+
11601166
// The address needs to be determined for the directions link
11611167
var r = new this.reverseGoogleGeocode(this);
11621168
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
11631169
r.geocode({'latLng': latlng}, function (data) {
11641170
if (data !== null) {
1165-
var originAddress = data.address;
1171+
originAddress = addressInput = data.address;
11661172
olat = mappingObj.lat = position.coords.latitude;
11671173
olng = mappingObj.lng = position.coords.longitude;
11681174
mappingObj.origin = originAddress;
@@ -1728,7 +1734,6 @@
17281734
newCenterCoords,
17291735
_this = this;
17301736

1731-
mappingObj = {};
17321737
olat = mappingObj.lat = newCenter.lat();
17331738
olng = mappingObj.lng = newCenter.lng();
17341739

@@ -1819,7 +1824,7 @@
18191824
this.writeDebug('processData',mappingObject);
18201825
var _this = this;
18211826
var i = 0;
1822-
var orig_lat, orig_lng, origin, name, maxDistance, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError;
1827+
var orig_lat, orig_lng, origin, name, maxDistance, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError, openMap;
18231828
if (!this.isEmptyObject(mappingObject)) {
18241829
orig_lat = mappingObject.lat;
18251830
orig_lng = mappingObject.lng;
@@ -1834,15 +1839,23 @@
18341839

18351840
// Save data and origin separately so we can potentially avoid multiple AJAX requests
18361841
originalData = dataRequest;
1837-
originalOrigin = origin;
1842+
if ( typeof origin !== 'undefined' ) {
1843+
originalOrigin = origin;
1844+
}
18381845

18391846
// Callback
18401847
if (_this.settings.callbackSuccess) {
18411848
_this.settings.callbackSuccess.call(this);
18421849
}
18431850

1851+
openMap = $mapDiv.hasClass('bh-sl-map-open');
1852+
18441853
// Set a variable for fullMapStart so we can detect the first run
1845-
if (_this.settings.fullMapStart === true && $mapDiv.hasClass('bh-sl-map-open') === false) {
1854+
if (
1855+
( _this.settings.fullMapStart === true && openMap === false ) ||
1856+
( _this.settings.autoGeocode === true && openMap === false ) ||
1857+
( _this.settings.defaultLoc === true && openMap === false )
1858+
) {
18461859
firstRun = true;
18471860
}
18481861
else {
@@ -2128,7 +2141,8 @@
21282141
}
21292142

21302143
// Handle pagination
2131-
$(document).on('click.'+pluginName, '.bh-sl-pagination li', function () {
2144+
$(document).on('click.'+pluginName, '.bh-sl-pagination li', function (e) {
2145+
e.preventDefault();
21322146
// Run paginationChange
21332147
_this.paginationChange($(this).attr('data-page'));
21342148
});

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

3636
## Changelog
3737

38+
### Version 2.5.2
39+
40+
* Fixed pagination bubbling issue.
41+
* Fixed pagination issues with autoGeocode and dragSearch combinations.
42+
3843
### Version 2.5.1
3944

4045
* Fixed issues with visibleMarkersList and location list background colors and selection.

src/js/jquery.storelocator.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@
256256
}
257257
$(document).off('click', '.' + this.settings.locationList + ' li .loc-directions a');
258258
}
259+
if(this.settings.pagination === true) {
260+
$(document).off('click.'+pluginName, '.bh-sl-pagination li');
261+
}
259262
},
260263

261264
/**
@@ -494,7 +497,8 @@
494497
this.writeDebug('_start');
495498
var _this = this,
496499
doAutoGeo = this.settings.autoGeocode,
497-
latlng;
500+
latlng,
501+
originAddress;
498502

499503
// Full map blank start
500504
if (_this.settings.fullMapStartBlank !== false) {
@@ -528,7 +532,7 @@
528532
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
529533
r.geocode({'latLng': latlng}, function (data) {
530534
if (data !== null) {
531-
var originAddress = data.address;
535+
originAddress = addressInput = data.address;
532536
olat = mappingObj.lat = _this.settings.defaultLat;
533537
olng = mappingObj.lng = _this.settings.defaultLng;
534538
mappingObj.origin = originAddress;
@@ -1152,14 +1156,16 @@
11521156
*/
11531157
autoGeocodeQuery: function (position) {
11541158
this.writeDebug('autoGeocodeQuery',arguments);
1155-
var _this = this;
1156-
var mappingObj = {};
1159+
var _this = this,
1160+
originAddress;
1161+
1162+
11571163
// The address needs to be determined for the directions link
11581164
var r = new this.reverseGoogleGeocode(this);
11591165
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
11601166
r.geocode({'latLng': latlng}, function (data) {
11611167
if (data !== null) {
1162-
var originAddress = data.address;
1168+
originAddress = addressInput = data.address;
11631169
olat = mappingObj.lat = position.coords.latitude;
11641170
olng = mappingObj.lng = position.coords.longitude;
11651171
mappingObj.origin = originAddress;
@@ -1725,7 +1731,6 @@
17251731
newCenterCoords,
17261732
_this = this;
17271733

1728-
mappingObj = {};
17291734
olat = mappingObj.lat = newCenter.lat();
17301735
olng = mappingObj.lng = newCenter.lng();
17311736

@@ -1816,7 +1821,7 @@
18161821
this.writeDebug('processData',mappingObject);
18171822
var _this = this;
18181823
var i = 0;
1819-
var orig_lat, orig_lng, origin, name, maxDistance, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError;
1824+
var orig_lat, orig_lng, origin, name, maxDistance, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError, openMap;
18201825
if (!this.isEmptyObject(mappingObject)) {
18211826
orig_lat = mappingObject.lat;
18221827
orig_lng = mappingObject.lng;
@@ -1831,15 +1836,23 @@
18311836

18321837
// Save data and origin separately so we can potentially avoid multiple AJAX requests
18331838
originalData = dataRequest;
1834-
originalOrigin = origin;
1839+
if ( typeof origin !== 'undefined' ) {
1840+
originalOrigin = origin;
1841+
}
18351842

18361843
// Callback
18371844
if (_this.settings.callbackSuccess) {
18381845
_this.settings.callbackSuccess.call(this);
18391846
}
18401847

1848+
openMap = $mapDiv.hasClass('bh-sl-map-open');
1849+
18411850
// Set a variable for fullMapStart so we can detect the first run
1842-
if (_this.settings.fullMapStart === true && $mapDiv.hasClass('bh-sl-map-open') === false) {
1851+
if (
1852+
( _this.settings.fullMapStart === true && openMap === false ) ||
1853+
( _this.settings.autoGeocode === true && openMap === false ) ||
1854+
( _this.settings.defaultLoc === true && openMap === false )
1855+
) {
18431856
firstRun = true;
18441857
}
18451858
else {
@@ -2125,7 +2138,8 @@
21252138
}
21262139

21272140
// Handle pagination
2128-
$(document).on('click.'+pluginName, '.bh-sl-pagination li', function () {
2141+
$(document).on('click.'+pluginName, '.bh-sl-pagination li', function (e) {
2142+
e.preventDefault();
21292143
// Run paginationChange
21302144
_this.paginationChange($(this).attr('data-page'));
21312145
});

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

0 commit comments

Comments
 (0)