Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn2404 committed Jan 5, 2015
2 parents 8eb120b + 7793c8a commit 01b91d2
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 22 deletions.
36 changes: 27 additions & 9 deletions dist/assets/js/plugins/storeLocator/jquery.storelocator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! jQuery Google Maps Store Locator - v2.0.4 - 2014-12-15
/*! jQuery Google Maps Store Locator - v2.0.5 - 2015-01-04
* http://www.bjornblog.com/web/jquery-store-locator-plugin
* Copyright (c) 2014 Bjorn Holine; Licensed MIT */
* Copyright (c) 2015 Bjorn Holine; Licensed MIT */

;(function ($, window, document, undefined) {
'use strict';
Expand Down Expand Up @@ -87,8 +87,9 @@
'callbackDirectionsRequest': null,
'callbackCloseDirections' : null,
'callbackNoResults' : null,
'callbackListClick' : null,
'callbackMarkerClick' : null,
// Language options
'geocodeErrorAlert' : 'Geocode was not successful for the following reason: ',
'addressErrorAlert' : 'Unable to find address',
'autoGeocodeErrorAlert' : 'Automatic location detection failed. Please fill in your address or zip code.',
'distanceErrorAlert' : 'Unfortunately, our closest location is more than ',
Expand Down Expand Up @@ -225,6 +226,9 @@
normalset = [];
markers = [];
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li');
if( $('.' + this.settings.locationList + ' .bh-sl-close-directions-container').length ) {
$('.bh-sl-close-directions-container').remove();
}
},

/**
Expand Down Expand Up @@ -483,8 +487,8 @@
result.longitude = results[0].geometry.location.lng();
callbackFunction(result);
} else {
_this.notify(_this.settings.geocodeErrorAlert + status);
callbackFunction(null);
throw new Error('Geocode was not successful for the following reason: ' + status);
}
});
};
Expand All @@ -505,8 +509,8 @@
callbackFunction(result);
}
} else {
_this.notify(_this.settings.geocodeErrorAlert + status);
callbackFunction(null);
throw new Error('Reverse geocode was not successful for the following reason: ' + status);
}
});
};
Expand Down Expand Up @@ -913,9 +917,15 @@
infowindow.setContent(formattedAddress);
infowindow.open(marker.get('map'), marker);
// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
var markerId = marker.get('id');
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');

// Marker click callback
if (_this.settings.callbackMarkerClick) {
_this.settings.callbackMarkerClick.call(this, marker, markerId, $selectedLocation);
}

$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$selectedLocation.addClass('list-focus');

// Scroll list to selected marker
Expand Down Expand Up @@ -1059,7 +1069,6 @@
}

// Remove the close icon, remove the directions, add the list back
$('.bh-sl-close-directions-container').remove();
$('.' + this.settings.locationList + ' .adp').remove();
$('.' + this.settings.locationList + ' ul').fadeIn();

Expand Down Expand Up @@ -1724,7 +1733,12 @@
}
else{
if(_this.settings.originMarkerImg !== null) {
originImg = this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height);
if(_this.settings.originMarkerDim === null) {
originImg = _this.markerImage(_this.settings.originMarkerImg);
}
else {
originImg = _this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height);
}
}
else {
originImg = {
Expand Down Expand Up @@ -1806,9 +1820,13 @@
// Handle clicks from the list
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () {
var markerId = $(this).data('markerid');

var selectedMarker = markers[markerId];

// List click callback
if (_this.settings.callbackListClick) {
_this.settings.callbackListClick.call(this, markerId, selectedMarker);
}

// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus');
Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion options.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
| callbackDirectionsRequest | null | Callback that fires upon a directions request when using the inline directions option. |
| callbackCloseDirections | null | Callback that fires when the directions panel closes. |
| callbackNoResults | null | Callback that fires when no results are found. |
| geocodeErrorAlert | 'Geocode was not successful for the following reason: ' | Language setting |
| callbackListClick | null | Callback that fires when a list element is clicked in the location list. |
| callbackMarkerClick | null | Callback that fires when a map marker is clicked. |
| addressErrorAlert | 'Unable to find address' | Language setting |
| autoGeocodeErrorAlert | 'Automatic location detection failed. Please fill in your address or zip code.' | Language setting |
| distanceErrorAlert | 'Unfortunately, our closest location is more than ' | Language setting |
Expand Down
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.0.4",
"version": "2.0.5",
"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
10 changes: 10 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ for even faster loading.

## Changelog

### Version 2.0.5

- Fixed typo with originMarker setup.
- Made the originMarkerDim setting optional when setting a custom origin marker image - defaults to 32px by 32px.
- Removed geocodeErrorAlert language option and switched error alerts to custom exceptions so users aren't shown
multiple alerts.
- Fixed bug with inline directions where close icon wasn't being removed on page reload.
- Added callbackListClick that fires when a list element is clicked.
- Added callbackMarkerClick that fires when a map marker is clicked.

### Version 2.0.4

* Fixed bug with maxDistance and pagination setting combination. The last page of of the pagination results was set to
Expand Down
32 changes: 25 additions & 7 deletions src/js/jquery.storelocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@
'callbackDirectionsRequest': null,
'callbackCloseDirections' : null,
'callbackNoResults' : null,
'callbackListClick' : null,
'callbackMarkerClick' : null,
// Language options
'geocodeErrorAlert' : 'Geocode was not successful for the following reason: ',
'addressErrorAlert' : 'Unable to find address',
'autoGeocodeErrorAlert' : 'Automatic location detection failed. Please fill in your address or zip code.',
'distanceErrorAlert' : 'Unfortunately, our closest location is more than ',
Expand Down Expand Up @@ -223,6 +224,9 @@
normalset = [];
markers = [];
$(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li');
if( $('.' + this.settings.locationList + ' .bh-sl-close-directions-container').length ) {
$('.bh-sl-close-directions-container').remove();
}
},

/**
Expand Down Expand Up @@ -481,8 +485,8 @@
result.longitude = results[0].geometry.location.lng();
callbackFunction(result);
} else {
_this.notify(_this.settings.geocodeErrorAlert + status);
callbackFunction(null);
throw new Error('Geocode was not successful for the following reason: ' + status);
}
});
};
Expand All @@ -503,8 +507,8 @@
callbackFunction(result);
}
} else {
_this.notify(_this.settings.geocodeErrorAlert + status);
callbackFunction(null);
throw new Error('Reverse geocode was not successful for the following reason: ' + status);
}
});
};
Expand Down Expand Up @@ -911,9 +915,15 @@
infowindow.setContent(formattedAddress);
infowindow.open(marker.get('map'), marker);
// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
var markerId = marker.get('id');
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');

// Marker click callback
if (_this.settings.callbackMarkerClick) {
_this.settings.callbackMarkerClick.call(this, marker, markerId, $selectedLocation);
}

$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$selectedLocation.addClass('list-focus');

// Scroll list to selected marker
Expand Down Expand Up @@ -1057,7 +1067,6 @@
}

// Remove the close icon, remove the directions, add the list back
$('.bh-sl-close-directions-container').remove();
$('.' + this.settings.locationList + ' .adp').remove();
$('.' + this.settings.locationList + ' ul').fadeIn();

Expand Down Expand Up @@ -1722,7 +1731,12 @@
}
else{
if(_this.settings.originMarkerImg !== null) {
originImg = this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height);
if(_this.settings.originMarkerDim === null) {
originImg = _this.markerImage(_this.settings.originMarkerImg);
}
else {
originImg = _this.markerImage(_this.settings.originMarkerImg, _this.settings.originMarkerDim.width, _this.settings.originMarkerDim.height);
}
}
else {
originImg = {
Expand Down Expand Up @@ -1804,9 +1818,13 @@
// Handle clicks from the list
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () {
var markerId = $(this).data('markerid');

var selectedMarker = markers[markerId];

// List click callback
if (_this.settings.callbackListClick) {
_this.settings.callbackListClick.call(this, markerId, selectedMarker);
}

// Focus on the list
$('.' + _this.settings.locationList + ' li').removeClass('list-focus');
$('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']').addClass('list-focus');
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.0.4",
"version": "2.0.5",
"author": {
"name": "Bjorn Holine",
"url": "http://www.bjornblog.com/"
Expand Down

0 comments on commit 01b91d2

Please sign in to comment.