|
1 |
| -/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-08-07 |
| 1 | +/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-08-11 |
2 | 2 | * http://www.bjornblog.com/web/jquery-store-locator-plugin
|
3 | 3 | * Copyright (c) 2014 Bjorn Holine; Licensed MIT */
|
4 | 4 |
|
|
74 | 74 | 'listTemplateID' : null,
|
75 | 75 | 'infowindowTemplateID' : null,
|
76 | 76 | 'taxonomyFilters' : null,
|
| 77 | + 'querystringParams' : false, |
77 | 78 | 'callbackBeforeSend' : null,
|
78 | 79 | 'callbackSuccess' : null,
|
79 | 80 | 'callbackModalOpen' : null,
|
|
180 | 181 | this.loadTemplates();
|
181 | 182 | },
|
182 | 183 |
|
| 184 | + /** |
| 185 | + * Check for query string |
| 186 | + * |
| 187 | + * @param param {string} query string parameter to test |
| 188 | + * @returns {string} |
| 189 | + */ |
| 190 | + getQueryString: function(param) { |
| 191 | + param = param.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); |
| 192 | + var regex = new RegExp('[\\?&]' + param + '=([^&#]*)'), |
| 193 | + results = regex.exec(location.search); |
| 194 | + return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); |
| 195 | + }, |
| 196 | + |
183 | 197 | /**
|
184 | 198 | * Load templates
|
185 | 199 | */
|
|
258 | 272 | }
|
259 | 273 |
|
260 | 274 | this.start();
|
261 |
| - this.processFormInput(); |
| 275 | + this.formEventHandler(); |
262 | 276 | },
|
263 | 277 |
|
264 | 278 | /**
|
|
273 | 287 | if (this.settings.maxDistance === true) {
|
274 | 288 | var maxDistance = $('#' + this.settings.maxDistanceID).val();
|
275 | 289 | // Start the mapping
|
276 |
| - this.beginMapping(maxDistance); |
| 290 | + this.processForm(maxDistance); |
277 | 291 | }
|
278 | 292 | else {
|
279 | 293 | // Start the mapping
|
280 |
| - this.beginMapping(null); |
| 294 | + this.processForm(); |
281 | 295 | }
|
282 | 296 | },
|
283 | 297 |
|
284 | 298 | /**
|
285 |
| - * Process the form input |
| 299 | + * Form event handler setup |
286 | 300 | */
|
287 |
| - processFormInput: function () { |
| 301 | + formEventHandler: function () { |
288 | 302 | var _this = this;
|
289 | 303 | // ASP.net or regular submission?
|
290 | 304 | if (this.settings.noForm === true) {
|
|
425 | 439 |
|
426 | 440 | // If show full map option is true
|
427 | 441 | if (this.settings.fullMapStart === true) {
|
428 |
| - // Just do the mapping without an origin |
429 |
| - this.mapping(); |
| 442 | + if(this.settings.querystringParams === true && this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.nameID)) { |
| 443 | + this.processForm(); |
| 444 | + } |
| 445 | + else { |
| 446 | + this.mapping(); |
| 447 | + } |
430 | 448 | }
|
431 | 449 |
|
432 | 450 | // HTML5 geolocation API option
|
|
566 | 584 | var filterTest = true;
|
567 | 585 |
|
568 | 586 | for (var k in filters) {
|
569 |
| - if (!(new RegExp(filters[k].join("")).test(data[k]))) { |
| 587 | + if (!(new RegExp(filters[k].join(''), 'i').test(data[k]))) { |
570 | 588 | filterTest = false;
|
571 | 589 | }
|
572 | 590 | }
|
|
884 | 902 | else {
|
885 | 903 | this.settings.mapSettings.zoom = 0;
|
886 | 904 | }
|
887 |
| - this.beginMapping(null); |
| 905 | + this.processForm(null); |
888 | 906 | }
|
889 | 907 |
|
890 | 908 | $(document).off('click', '.' + this.settings.listDiv + ' .bh-sl-close-icon');
|
891 | 909 | },
|
892 | 910 |
|
893 | 911 | /**
|
894 |
| - * Set up the normal mapping TODO rename this function and processforminput |
| 912 | + * Process the form values and/or query string |
895 | 913 | *
|
896 | 914 | * @param distance {number} optional maximum distance
|
897 | 915 | */
|
898 |
| - beginMapping: function (distance) { |
| 916 | + processForm: function (distance) { |
899 | 917 | var _this = this;
|
900 | 918 | var mappingObj = {};
|
901 |
| - // Get the user input and use it |
902 |
| - addressInput = $('#' + this.settings.addressID).val(); |
903 |
| - nameInput = $('#' + this.settings.nameID).val(); |
| 919 | + |
| 920 | + if(this.settings.querystringParams === true) { |
| 921 | + |
| 922 | + // Check for query string parameters |
| 923 | + if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.nameID)){ |
| 924 | + addressInput = this.getQueryString(this.settings.addressID); |
| 925 | + nameInput = this.getQueryString(this.settings.nameID); |
| 926 | + } |
| 927 | + else{ |
| 928 | + // Get the user input and use it |
| 929 | + addressInput = $('#' + this.settings.addressID).val(); |
| 930 | + nameInput = $('#' + this.settings.nameID).val(); |
| 931 | + } |
| 932 | + } |
| 933 | + else { |
| 934 | + // Get the user input and use it |
| 935 | + addressInput = $('#' + this.settings.addressID).val(); |
| 936 | + nameInput = $('#' + this.settings.nameID).val(); |
| 937 | + } |
904 | 938 |
|
905 | 939 | // Get the region setting if set
|
906 | 940 | var region = $('#' + this.settings.regionID).val();
|
|
1113 | 1147 |
|
1114 | 1148 | // Name search - using taxonomy filter to handle
|
1115 | 1149 | if (_this.settings.nameSearch === true) {
|
1116 |
| - if (_this.settings.nameAttribute !== null) { |
1117 |
| - filters[_this.settings.nameAttribute] = nameInput; |
1118 |
| - } |
1119 |
| - else { |
1120 |
| - filters.name = [nameInput]; |
| 1150 | + if(typeof nameInput !== 'undefined') { |
| 1151 | + if (_this.settings.nameAttribute !== null) { |
| 1152 | + filters[_this.settings.nameAttribute] = nameInput; |
| 1153 | + } |
| 1154 | + else { |
| 1155 | + filters.name = [nameInput]; |
| 1156 | + } |
1121 | 1157 | }
|
1122 | 1158 | }
|
1123 | 1159 |
|
|
1429 | 1465 | _this.reset();
|
1430 | 1466 | if ((olat) && (olng)) {
|
1431 | 1467 | _this.settings.mapSettings.zoom = 0;
|
1432 |
| - _this.beginMapping(); |
| 1468 | + _this.processForm(); |
1433 | 1469 | }
|
1434 | 1470 | else {
|
1435 | 1471 | _this.mapping();
|
|
1450 | 1486 | else {
|
1451 | 1487 | _this.settings.mapSettings.zoom = 0;
|
1452 | 1488 | }
|
1453 |
| - _this.beginMapping(); |
| 1489 | + _this.processForm(); |
1454 | 1490 | }
|
1455 | 1491 | else {
|
1456 | 1492 | _this.mapping();
|
|
1477 | 1513 | _this.reset();
|
1478 | 1514 | if ((olat) && (olng)) {
|
1479 | 1515 | _this.settings.mapSettings.zoom = 0;
|
1480 |
| - _this.beginMapping(); |
| 1516 | + _this.processForm(); |
1481 | 1517 | }
|
1482 | 1518 | else {
|
1483 | 1519 | _this.mapping();
|
|
1493 | 1529 | _this.reset();
|
1494 | 1530 | if ((olat) && (olng)) {
|
1495 | 1531 | _this.settings.mapSettings.zoom = originalZoom;
|
1496 |
| - _this.beginMapping(); |
| 1532 | + _this.processForm(); |
1497 | 1533 | }
|
1498 | 1534 | else {
|
1499 | 1535 | _this.mapping();
|
|
0 commit comments