Skip to content

Commit 12565c8

Browse files
committed
Added order handling to tie into custom sorting
1 parent 9797249 commit 12565c8

File tree

11 files changed

+108
-10
lines changed

11 files changed

+108
-10
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": "3.0.0",
3+
"version": "3.0.1",
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",

callbacks/callback-order.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# callbackOrder
2+
3+
## Description
4+
5+
Fires when a new order option is selected.
6+
7+
## Parameters
8+
9+
| Name | Type | Description |
10+
|---|---|---|
11+
| sortObj | object | Sorting object properties: method, order, and prop. |

callbacks/callback-sorting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Fires when a new sorting method is selected.
88

99
| Name | Type | Description |
1010
|---|---|---|
11-
| sortObj | object | Sorting object properties: method, order, and prop. |
11+
| order | string | Order string value - asc or desc. |

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v3.0.0 - 2018-05-06
1+
/*! jQuery Google Maps Store Locator - v3.0.1 - 2018-09-06
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2018 Bjorn Holine; Licensed MIT */
44

@@ -90,6 +90,7 @@
9090
'maxDistanceID' : 'bh-sl-maxdistance',
9191
'modalContent' : 'bh-sl-modal-content',
9292
'modalWindow' : 'bh-sl-modal-window',
93+
'orderID' : 'bh-sl-order',
9394
'overlay' : 'bh-sl-overlay',
9495
'regionID' : 'bh-sl-region',
9596
'searchID' : 'bh-sl-search',
@@ -121,6 +122,7 @@
121122
'callbackNearestLoc' : null,
122123
'callbackNoResults' : null,
123124
'callbackNotify' : null,
125+
'callbackOrder' : null,
124126
'callbackPageChange' : null,
125127
'callbackRegion' : null,
126128
'callbackSorting' : null,
@@ -196,8 +198,9 @@
196198
this.taxonomyFiltering();
197199
}
198200

199-
// Do sorting if set.
201+
// Do sorting and ordering if set.
200202
this.sorting();
203+
this.order();
201204

202205
// Add modal window divs if set
203206
if (this.settings.modal === true) {
@@ -1872,6 +1875,40 @@
18721875
});
18731876
},
18741877

1878+
/**
1879+
* Set up front-end ordering functionality - this ties in to sorting and that has to be enabled for this to work.
1880+
*/
1881+
order: function() {
1882+
this.writeDebug('order',arguments);
1883+
var _this = this,
1884+
$mapDiv = $('#' + _this.settings.mapID),
1885+
$orderSelect = $('#' + _this.settings.orderID);
1886+
1887+
if ($orderSelect.length === 0) {
1888+
return;
1889+
}
1890+
1891+
$orderSelect.on('change.'+pluginName, function (e) {
1892+
e.stopPropagation();
1893+
1894+
// Reset pagination.
1895+
if (_this.settings.pagination === true) {
1896+
_this.paginationChange(0);
1897+
}
1898+
1899+
_this.settings.sortBy.order = $(this).val();
1900+
1901+
// Callback
1902+
if (_this.settings.callbackOrder) {
1903+
_this.settings.callbackOrder.call(this, _this.settings.order);
1904+
}
1905+
1906+
if ($mapDiv.hasClass('bh-sl-map-open')) {
1907+
_this.mapping(mappingObj);
1908+
}
1909+
});
1910+
},
1911+
18751912
/**
18761913
* Count the selected filters
18771914
*

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.

dist/sort-example.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ <h1 class="bh-sl-title">Using Chipotle as an Example</h1>
2828
<option data-method="numeric" value="address">Address</option>
2929
<option data-method="numeric" value="distance">Distance</option>
3030
</select>
31+
32+
<label for="bh-sl-order">Order:</label>
33+
<select id="bh-sl-order" name="bh-sl-order">
34+
<option value="asc">Ascending</option>
35+
<option value="desc">Descending</option>
36+
</select>
3137
</div>
3238

3339
<button id="bh-sl-submit" type="submit">Submit</button>

options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
| maxDistanceID | 'bh-sl-maxdistance' | ID of the select element for the maximum distance options. |
7474
| modalContent | 'bh-sl-modal-content' | Class of element container around the content of the modal window. |
7575
| modalWindow | 'bh-sl-modal-window' | Class of element of the actual modal window |
76+
| orderID | 'bh-sl-order' | ID of the select form field for custom sort order handling of location results. |
7677
| overlay | 'bh-sl-overlay' | Class of element that fills 100% of the window and fills with a transparent background image. |
7778
| regionID | 'bh-sl-region' | ID of the region select form field for country region biasing. |
7879
| searchID | 'bh-sl-search' | ID of the search input form field for location name searching. |
@@ -111,6 +112,7 @@
111112
| [callbackNearestLoc](callbacks/callback-nearestloc.md) | null | Nearest location callback |
112113
| [callbackNoResults](callbacks/callback-noresults.md) | null | No results callback |
113114
| [callbackNotify](callbacks/callback-notification.md) | null | Notification callback |
115+
| [callbackNotify](callbacks/callback-order.md) | null | Order callback |
114116
| [callbackPageChange](callbacks/callback-pagechange.md) | null | Page change callback |
115117
| [callbackRegion](callbacks/callback-region.md) | null | Region callback |
116118
| [callbackSorting](callbacks/callback-sorting.md) | null | Sorting callback |

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": "3.0.0",
3+
"version": "3.0.1",
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 3.0.1
39+
40+
* Added custom order handling to tie into previously added custom sorting. Set order to asc or desc.
41+
* Updated sort-example.html example with order select field.
42+
3843
### Version 3.0.0
3944

4045
Version 3 has a breaking change with the dataLocation and dataType settings switching the default from XML to JSON.

src/js/jquery.storelocator.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
'maxDistanceID' : 'bh-sl-maxdistance',
8787
'modalContent' : 'bh-sl-modal-content',
8888
'modalWindow' : 'bh-sl-modal-window',
89+
'orderID' : 'bh-sl-order',
8990
'overlay' : 'bh-sl-overlay',
9091
'regionID' : 'bh-sl-region',
9192
'searchID' : 'bh-sl-search',
@@ -117,6 +118,7 @@
117118
'callbackNearestLoc' : null,
118119
'callbackNoResults' : null,
119120
'callbackNotify' : null,
121+
'callbackOrder' : null,
120122
'callbackPageChange' : null,
121123
'callbackRegion' : null,
122124
'callbackSorting' : null,
@@ -192,8 +194,9 @@
192194
this.taxonomyFiltering();
193195
}
194196

195-
// Do sorting if set.
197+
// Do sorting and ordering if set.
196198
this.sorting();
199+
this.order();
197200

198201
// Add modal window divs if set
199202
if (this.settings.modal === true) {
@@ -1868,6 +1871,40 @@
18681871
});
18691872
},
18701873

1874+
/**
1875+
* Set up front-end ordering functionality - this ties in to sorting and that has to be enabled for this to work.
1876+
*/
1877+
order: function() {
1878+
this.writeDebug('order',arguments);
1879+
var _this = this,
1880+
$mapDiv = $('#' + _this.settings.mapID),
1881+
$orderSelect = $('#' + _this.settings.orderID);
1882+
1883+
if ($orderSelect.length === 0) {
1884+
return;
1885+
}
1886+
1887+
$orderSelect.on('change.'+pluginName, function (e) {
1888+
e.stopPropagation();
1889+
1890+
// Reset pagination.
1891+
if (_this.settings.pagination === true) {
1892+
_this.paginationChange(0);
1893+
}
1894+
1895+
_this.settings.sortBy.order = $(this).val();
1896+
1897+
// Callback
1898+
if (_this.settings.callbackOrder) {
1899+
_this.settings.callbackOrder.call(this, _this.settings.order);
1900+
}
1901+
1902+
if ($mapDiv.hasClass('bh-sl-map-open')) {
1903+
_this.mapping(mappingObj);
1904+
}
1905+
});
1906+
},
1907+
18711908
/**
18721909
* Count the selected filters
18731910
*

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","dealer","location", "locations", "maps", "map", "stores", "find"],
6-
"version": "3.0.0",
6+
"version": "3.0.1",
77
"author": {
88
"name": "Bjorn Holine",
99
"url": "http://www.bjornblog.com/"

0 commit comments

Comments
 (0)