Skip to content

Commit fddd577

Browse files
committed
Updated the Handlebars.compile calls when using the inline template option, fixed incorrect callback call in the modalClose method, added callbackModalReady, fixed markerImg setting
1 parent 4b52056 commit fddd577

File tree

8 files changed

+112
-63
lines changed

8 files changed

+112
-63
lines changed

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.0.1 - 2014-11-08
1+
/*! jQuery Google Maps Store Locator - v2.0.2 - 2014-12-07
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2014 Bjorn Holine; Licensed MIT */
44

@@ -80,11 +80,13 @@
8080
'callbackBeforeSend' : null,
8181
'callbackSuccess' : null,
8282
'callbackModalOpen' : null,
83+
'callbackModalReady' : null,
8384
'callbackModalClose' : null,
8485
'callbackJsonp' : null,
8586
'callbackPageChange' : null,
8687
'callbackDirectionsRequest': null,
8788
'callbackCloseDirections' : null,
89+
'callbackNoResults' : null,
8890
// Language options
8991
'geocodeErrorAlert' : 'Geocode was not successful for the following reason: ',
9092
'addressErrorAlert' : 'Unable to find address',
@@ -304,10 +306,10 @@
304306
// Handle script tag template method
305307
else if (this.settings.listTemplateID !== null && this.settings.infowindowTemplateID !== null) {
306308
// Infowindows
307-
infowindowTemplate = Handlebars.compile($(this.settings.infowindowTemplateID).html());
309+
infowindowTemplate = Handlebars.compile($('#' + this.settings.infowindowTemplateID).html());
308310

309311
// Locations list
310-
listTemplate = Handlebars.compile($(this.settings.listTemplateID).html());
312+
listTemplate = Handlebars.compile($('#' + this.settings.listTemplateID).html());
311313

312314
// Continue to the main script
313315
_this.locator();
@@ -561,8 +563,8 @@
561563
*/
562564
modalClose: function () {
563565
// Callback
564-
if (this.settings.callbackModalOpen) {
565-
this.settings.callbackModalOpen.call(this);
566+
if (this.settings.callbackModalClose) {
567+
this.settings.callbackModalClose.call(this);
566568
}
567569

568570
// Reset the filters
@@ -775,11 +777,16 @@
775777

776778
// Custom single marker image override
777779
if(this.settings.markerImg !== null) {
778-
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
780+
if(this.settings.markerDim === null) {
781+
markerImg = this.markerImage(this.settings.markerImg);
782+
}
783+
else {
784+
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
785+
}
779786
}
780787

781788
// Create the default markers
782-
if (this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null) {
789+
if (this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null || this.settings.markerImg !== null) {
783790
marker = new google.maps.Marker({
784791
position : point,
785792
map : map,
@@ -1552,6 +1559,11 @@
15521559

15531560
// Handle no results
15541561
if (_this.isEmptyObject(locationset)) {
1562+
// Callback
1563+
if (_this.settings.callbackNoResults) {
1564+
_this.settings.callbackNoResults.call(this);
1565+
}
1566+
15551567
// Hide the map and locations if they're showing
15561568
if ($mapDiv.hasClass('bh-sl-map-open')) {
15571569
$this.hide();
@@ -1821,6 +1833,11 @@
18211833
$('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1);
18221834
$('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2);
18231835

1836+
// Modal ready callback
1837+
if (_this.settings.modal === true && _this.settings.callbackModalReady) {
1838+
_this.settings.callbackModalReady.call(this);
1839+
}
1840+
18241841
});
18251842
}
18261843

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.

dist/pagination-example.html

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title>Map Example - Pagination</title>
5-
<meta charset="UTF-8">
6-
<link rel="stylesheet" type="text/css" href="assets/css/storelocator.css" />
7-
</head>
3+
<head>
4+
<title>Map Example - Pagination</title>
5+
<meta charset="UTF-8">
6+
<link rel="stylesheet" type="text/css" href="assets/css/storelocator.css" />
7+
</head>
88

9-
<body>
9+
<body>
1010

11-
<div class="bh-sl-container">
12-
<div id="page-header">
13-
<h1>Using Chipotle as an Example</h1>
14-
<p>I used locations around Minneapolis and the southwest suburbs. So, for example, Edina, Plymouth, Eden Prarie, etc. would be good for testing the functionality.
15-
You can use just the city as the address - ex: Edina, MN.</p>
16-
</div>
17-
18-
<div class="bh-sl-form-container">
19-
<form id="bh-sl-user-location" method="post" action="#">
20-
<div class="form-input">
21-
<label for="bh-sl-address">Enter Address or Zip Code:</label>
22-
<input type="text" id="bh-sl-address" name="bh-sl-address" />
11+
<div class="bh-sl-container">
12+
<div id="page-header">
13+
<h1>Using Chipotle as an Example</h1>
14+
<p>I used locations around Minneapolis and the southwest suburbs. So, for example, Edina, Plymouth, Eden Prarie, etc. would be good for testing the functionality.
15+
You can use just the city as the address - ex: Edina, MN.</p>
16+
</div>
17+
18+
<div class="bh-sl-form-container">
19+
<form id="bh-sl-user-location" method="post" action="#">
20+
<div class="form-input">
21+
<label for="bh-sl-address">Enter Address or Zip Code:</label>
22+
<input type="text" id="bh-sl-address" name="bh-sl-address" />
23+
</div>
24+
25+
<button id="bh-sl-submit" type="submit">Submit</button>
26+
</form>
27+
</div>
28+
29+
<div id="map-container" class="bh-sl-map-container">
30+
<div class="bh-sl-loc-list">
31+
<ul class="list"></ul>
32+
</div>
33+
<div id="bh-sl-map" class="bh-sl-map"></div>
34+
</div>
35+
36+
<div class="bh-sl-pagination-container">
37+
<ol class="bh-sl-pagination"></ol>
2338
</div>
24-
25-
<button id="bh-sl-submit" type="submit">Submit</button>
26-
</form>
27-
</div>
28-
29-
<div id="map-container" class="bh-sl-map-container">
30-
<div class="bh-sl-loc-list">
31-
<ul class="list"></ul>
3239
</div>
33-
<div id="bh-sl-map" class="bh-sl-map"></div>
34-
</div>
3540

36-
<div class="bh-sl-pagination-container">
37-
<ol class="bh-sl-pagination"></ol>
38-
</div>
39-
</div>
40-
41-
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
42-
<script src="assets/js/libs/handlebars.min.js"></script>
43-
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
44-
<script src="assets/js/plugins/storeLocator/jquery.storelocator.js"></script>
45-
<script>
46-
$(function() {
47-
$('#map-container').storeLocator({
48-
'pagination': true
49-
});
50-
});
51-
</script>
52-
53-
</body>
41+
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
42+
<script src="assets/js/libs/handlebars.min.js"></script>
43+
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
44+
<script src="assets/js/plugins/storeLocator/jquery.storelocator.js"></script>
45+
<script>
46+
$(function() {
47+
$('#map-container').storeLocator({
48+
'pagination': true
49+
});
50+
});
51+
</script>
52+
53+
</body>
5454
</html>

options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@
5858
| callbackBeforeSend | null | Callback that fires before the AJAX request. |
5959
| callbackSuccess | null | Callback that fires on successful AJAX request. |
6060
| callbackModalOpen | null | Callback that fires when a modal opens. |
61+
| callbackModalReady | null | Callback that fires when the content of the modal is generated. |
6162
| callbackModalClose | null | Callback that fires when a modal closes. |
6263
| callbackJsonp | null | Callback that can specify the callback function name of a JSONP request. |
6364
| callbackPageChange | null | Callback that fires when the page changes if pagination is enabled. |
6465
| callbackDirectionsRequest | null | Callback that fires upon a directions request when using the inline directions option. |
6566
| callbackCloseDirections | null | Callback that fires when the directions panel closes. |
67+
| callbackNoResults | null | Callback that fires when no results are found. |
6668
| geocodeErrorAlert | 'Geocode was not successful for the following reason: ' | Language setting |
6769
| addressErrorAlert | 'Unable to find address' | Language setting |
6870
| autoGeocodeErrorAlert | 'Automatic location detection failed. Please fill in your address or zip code.' | Language setting |

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.0.1",
3+
"version": "2.0.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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ for even faster loading.
2727

2828
## Changelog
2929

30+
### Version 2.0.2
31+
32+
* Updated the Handlebars.compile calls when using the inline template options to include the ID hash so that it's
33+
consistent with the other ID settings.
34+
* Fixed incorrect callback call in the modalClose method - callbackModalOpen to callbackModalClose.
35+
* Added callbackModalReady that fires when the the content of the modal is generated.
36+
* Fixed markerImg setting - previously threw error if markerDim wasn't set.
37+
38+
### Version 2.0.1
39+
40+
* Quick fix to remove a dupicate copyright notice in dist/ file. Copyright was removed from src/jquery.storelocator.js
41+
file to prevent duplication with the Grunt Banner task.
42+
3043
### Version 2.0.0
3144

3245
Version 2 is a complete rewrite of the plugin based on the "basic" plugin pattern of the

src/js/jquery.storelocator.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@
7878
'callbackBeforeSend' : null,
7979
'callbackSuccess' : null,
8080
'callbackModalOpen' : null,
81+
'callbackModalReady' : null,
8182
'callbackModalClose' : null,
8283
'callbackJsonp' : null,
8384
'callbackPageChange' : null,
8485
'callbackDirectionsRequest': null,
8586
'callbackCloseDirections' : null,
87+
'callbackNoResults' : null,
8688
// Language options
8789
'geocodeErrorAlert' : 'Geocode was not successful for the following reason: ',
8890
'addressErrorAlert' : 'Unable to find address',
@@ -302,10 +304,10 @@
302304
// Handle script tag template method
303305
else if (this.settings.listTemplateID !== null && this.settings.infowindowTemplateID !== null) {
304306
// Infowindows
305-
infowindowTemplate = Handlebars.compile($(this.settings.infowindowTemplateID).html());
307+
infowindowTemplate = Handlebars.compile($('#' + this.settings.infowindowTemplateID).html());
306308

307309
// Locations list
308-
listTemplate = Handlebars.compile($(this.settings.listTemplateID).html());
310+
listTemplate = Handlebars.compile($('#' + this.settings.listTemplateID).html());
309311

310312
// Continue to the main script
311313
_this.locator();
@@ -559,8 +561,8 @@
559561
*/
560562
modalClose: function () {
561563
// Callback
562-
if (this.settings.callbackModalOpen) {
563-
this.settings.callbackModalOpen.call(this);
564+
if (this.settings.callbackModalClose) {
565+
this.settings.callbackModalClose.call(this);
564566
}
565567

566568
// Reset the filters
@@ -773,11 +775,16 @@
773775

774776
// Custom single marker image override
775777
if(this.settings.markerImg !== null) {
776-
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
778+
if(this.settings.markerDim === null) {
779+
markerImg = this.markerImage(this.settings.markerImg);
780+
}
781+
else {
782+
markerImg = this.markerImage(this.settings.markerImg, this.settings.markerDim.width, this.settings.markerDim.height);
783+
}
777784
}
778785

779786
// Create the default markers
780-
if (this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null) {
787+
if (this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null || this.settings.markerImg !== null) {
781788
marker = new google.maps.Marker({
782789
position : point,
783790
map : map,
@@ -1550,6 +1557,11 @@
15501557

15511558
// Handle no results
15521559
if (_this.isEmptyObject(locationset)) {
1560+
// Callback
1561+
if (_this.settings.callbackNoResults) {
1562+
_this.settings.callbackNoResults.call(this);
1563+
}
1564+
15531565
// Hide the map and locations if they're showing
15541566
if ($mapDiv.hasClass('bh-sl-map-open')) {
15551567
$this.hide();
@@ -1819,6 +1831,11 @@
18191831
$('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1);
18201832
$('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2);
18211833

1834+
// Modal ready callback
1835+
if (_this.settings.modal === true && _this.settings.callbackModalReady) {
1836+
_this.settings.callbackModalReady.call(this);
1837+
}
1838+
18221839
});
18231840
}
18241841

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

0 commit comments

Comments
 (0)