|
1 |
| -/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-08-31 |
| 1 | +/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-09-01 |
2 | 2 | * http://www.bjornblog.com/web/jquery-store-locator-plugin
|
3 | 3 | * Copyright (c) 2014 Bjorn Holine; Licensed MIT */
|
4 | 4 |
|
|
17 | 17 | // Variables used across multiple functions
|
18 | 18 | var $this, listTemplate, infowindowTemplate, dataTypeRead, originalData, originalDataRequest, originalZoom, nameInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService;
|
19 | 19 | var featuredset = [], locationset = [], normalset = [], markers = [];
|
20 |
| - var filters = {}, locationData = {}, GeoCodeCalc = {}; |
| 20 | + var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {}; |
21 | 21 |
|
22 | 22 | // Create the defaults once. Do not change these settings in this file - settings should be overridden in the plugin call
|
23 | 23 | var defaults = {
|
|
281 | 281 | this.formEventHandler();
|
282 | 282 | },
|
283 | 283 |
|
284 |
| - /** |
285 |
| - * Handle form submission |
286 |
| - * |
287 |
| - * @param e {event} |
288 |
| - */ |
289 |
| - getFormValues: function (e) { |
290 |
| - // Stop the form submission |
291 |
| - e.preventDefault(); |
292 |
| - |
293 |
| - if (this.settings.maxDistance === true) { |
294 |
| - var maxDistance = $('#' + this.settings.maxDistanceID).val(); |
295 |
| - // Start the mapping |
296 |
| - this.processForm(maxDistance); |
297 |
| - } |
298 |
| - else { |
299 |
| - // Start the mapping |
300 |
| - this.processForm(); |
301 |
| - } |
302 |
| - }, |
303 |
| - |
304 | 284 | /**
|
305 | 285 | * Form event handler setup
|
306 | 286 | */
|
|
309 | 289 | // ASP.net or regular submission?
|
310 | 290 | if (this.settings.noForm === true) {
|
311 | 291 | $(document).on('click', '.' + this.settings.formContainerDiv + ' button', function (e) {
|
312 |
| - _this.getFormValues(e); |
| 292 | + _this.processForm(e); |
313 | 293 | });
|
314 | 294 | $(document).on('keyup', function (e) {
|
315 | 295 | if (e.keyCode === 13 && $('#' + _this.settings.inputID).is(':focus')) {
|
316 |
| - _this.getFormValues(e); |
| 296 | + _this.processForm(e); |
317 | 297 | }
|
318 | 298 | });
|
319 | 299 | }
|
320 | 300 | else {
|
321 | 301 | $(document).on('submit', '#' + this.settings.formID, function (e) {
|
322 |
| - _this.getFormValues(e); |
| 302 | + _this.processForm(e); |
323 | 303 | });
|
324 | 304 | }
|
325 | 305 | },
|
|
423 | 403 | */
|
424 | 404 | start: function () {
|
425 | 405 | var _this = this;
|
426 |
| - var mappingObj = {}; |
427 | 406 | // If a default location is set
|
428 | 407 | if (this.settings.defaultLoc === true) {
|
429 | 408 | // The address needs to be determined for the directions link
|
|
850 | 829 | * @param newPage
|
851 | 830 | */
|
852 | 831 | paginationChange: function (newPage) {
|
853 |
| - var maxDistance; |
854 |
| - var mappingObj = {}; |
855 |
| - |
856 |
| - if (this.settings.maxDistance === true) { |
857 |
| - maxDistance = $('#' + this.settings.maxDistanceID).val(); |
858 |
| - } |
859 | 832 |
|
860 |
| - this.reset(); |
861 |
| - mappingObj.lat = olat; |
862 |
| - mappingObj.lng = olng; |
863 |
| - mappingObj.origin = addressInput; |
864 |
| - mappingObj.name = nameInput; |
865 |
| - mappingObj.distance = maxDistance; |
866 | 833 | mappingObj.page = newPage;
|
867 | 834 | this.mapping(mappingObj);
|
868 | 835 | },
|
|
959 | 926 | /**
|
960 | 927 | * Process the form values and/or query string
|
961 | 928 | *
|
962 |
| - * @param distance {number} optional maximum distance |
| 929 | + * @param e {event} |
963 | 930 | */
|
964 |
| - processForm: function (distance) { |
| 931 | + processForm: function (e) { |
965 | 932 | var _this = this;
|
966 |
| - var mappingObj = {}; |
| 933 | + var distance = null; |
| 934 | + |
| 935 | + // Stop the form submission |
| 936 | + if(typeof e !== 'undefined') { |
| 937 | + e.preventDefault(); |
| 938 | + } |
| 939 | + |
| 940 | + // Get the distance if set |
| 941 | + if (this.settings.maxDistance === true) { |
| 942 | + distance = $('#' + this.settings.maxDistanceID).val(); |
| 943 | + } |
967 | 944 |
|
968 | 945 | if(this.settings.querystringParams === true) {
|
969 | 946 |
|
|
1025 | 1002 | * @param origin {string} origin address
|
1026 | 1003 | * @param maxDistance {number} optional maximum distance
|
1027 | 1004 | */
|
1028 |
| - mapping: function (mappingObj) { |
| 1005 | + mapping: function (mappingObject) { |
1029 | 1006 | var _this = this;
|
1030 | 1007 | var orig_lat, orig_lng, origin, name, maxDistance, page, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults;
|
1031 | 1008 | var i = 0;
|
1032 |
| - if (!this.isEmptyObject(mappingObj)) { |
1033 |
| - orig_lat = mappingObj.lat; |
1034 |
| - orig_lng = mappingObj.lng; |
1035 |
| - origin = mappingObj.origin; |
1036 |
| - name = mappingObj.name; |
1037 |
| - maxDistance = mappingObj.distance; |
1038 |
| - page = mappingObj.page; |
| 1009 | + if (!this.isEmptyObject(mappingObject)) { |
| 1010 | + orig_lat = mappingObject.lat; |
| 1011 | + orig_lng = mappingObject.lng; |
| 1012 | + origin = mappingObject.origin; |
| 1013 | + name = mappingObject.name; |
| 1014 | + maxDistance = mappingObject.distance; |
| 1015 | + page = mappingObject.page; |
1039 | 1016 | }
|
1040 | 1017 |
|
1041 | 1018 | // Enable the visual refresh https://developers.google.com/maps/documentation/javascript/basics#VisualRefresh
|
|
1514 | 1491 | _this.processForm();
|
1515 | 1492 | }
|
1516 | 1493 | else {
|
1517 |
| - _this.mapping(); |
| 1494 | + _this.mapping(mappingObj); |
1518 | 1495 | }
|
1519 | 1496 | }
|
1520 | 1497 | }
|
|
1535 | 1512 | _this.processForm();
|
1536 | 1513 | }
|
1537 | 1514 | else {
|
1538 |
| - _this.mapping(); |
| 1515 | + _this.mapping(mappingObj); |
1539 | 1516 | }
|
1540 | 1517 | }
|
1541 | 1518 | }
|
|
1562 | 1539 | _this.processForm();
|
1563 | 1540 | }
|
1564 | 1541 | else {
|
1565 |
| - _this.mapping(); |
| 1542 | + _this.mapping(mappingObj); |
1566 | 1543 | }
|
1567 | 1544 | }
|
1568 | 1545 | }
|
|
1578 | 1555 | _this.processForm();
|
1579 | 1556 | }
|
1580 | 1557 | else {
|
1581 |
| - _this.mapping(); |
| 1558 | + _this.mapping(mappingObj); |
1582 | 1559 | }
|
1583 | 1560 | }
|
1584 | 1561 | }
|
|
0 commit comments