|
1 | | -/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-09-07 |
| 1 | +/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-09-13 |
2 | 2 | * http://www.bjornblog.com/web/jquery-store-locator-plugin |
3 | 3 | * Copyright (c) 2014 Bjorn Holine; Licensed MIT */ |
4 | 4 |
|
|
113 | 113 | featuredset = []; |
114 | 114 | normalset = []; |
115 | 115 | markers = []; |
116 | | - $(document).off('click', '.' + this.settings.locationList + ' li'); |
| 116 | + $(document).off('click.'+pluginName, '.' + this.settings.locationList + ' li'); |
117 | 117 | }, |
118 | 118 |
|
119 | 119 | /** |
|
190 | 190 | this.loadTemplates(); |
191 | 191 | }, |
192 | 192 |
|
| 193 | + /** |
| 194 | + * Destroy |
| 195 | + */ |
| 196 | + destroy: function () { |
| 197 | + // Reset |
| 198 | + this.reset(); |
| 199 | + |
| 200 | + // Remove marker event listeners |
| 201 | + if(markers.length) { |
| 202 | + for(var i = 0; i <= markers.length; i++) { |
| 203 | + google.maps.event.removeListener(markers[i]); |
| 204 | + } |
| 205 | + } |
| 206 | + |
| 207 | + // Remove markup |
| 208 | + $('.' + this.settings.locationList + ' ul').empty(); |
| 209 | + if($('#' + this.settings.mapID).hasClass('bh-sl-map-open')) { |
| 210 | + $('#' + this.settings.mapID).empty(); |
| 211 | + $('#' + this.settings.mapID).removeClass('bh-sl-map-open'); |
| 212 | + } |
| 213 | + |
| 214 | + // Remove modal markup |
| 215 | + if (this.settings.modal === true) { |
| 216 | + $('. ' + this.settings.overlay).remove(); |
| 217 | + } |
| 218 | + |
| 219 | + // Remove map style from cotnainer |
| 220 | + $('#' + this.settings.mapID).attr('style', ''); |
| 221 | + |
| 222 | + // Hide map container |
| 223 | + $this.hide(); |
| 224 | + // Remove data |
| 225 | + $.removeData($this.get(0)); |
| 226 | + // Remove namespached events |
| 227 | + $(document).off(pluginName); |
| 228 | + // Unbind plugin |
| 229 | + $this.unbind(); |
| 230 | + }, |
| 231 | + |
193 | 232 | /** |
194 | 233 | * Check for query string |
195 | 234 | * |
|
291 | 330 | var _this = this; |
292 | 331 | // ASP.net or regular submission? |
293 | 332 | if (this.settings.noForm === true) { |
294 | | - $(document).on('click', '.' + this.settings.formContainer + ' button', function (e) { |
| 333 | + $(document).on('click.'+pluginName, '.' + this.settings.formContainer + ' button', function (e) { |
295 | 334 | _this.processForm(e); |
296 | 335 | }); |
297 | | - $(document).on('keyup', function (e) { |
| 336 | + $(document).on('keyup.'+pluginName, function (e) { |
298 | 337 | if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) { |
299 | 338 | _this.processForm(e); |
300 | 339 | } |
301 | 340 | }); |
302 | 341 | } |
303 | 342 | else { |
304 | | - $(document).on('submit', '#' + this.settings.formID, function (e) { |
| 343 | + $(document).on('submit.'+pluginName, '#' + this.settings.formID, function (e) { |
305 | 344 | _this.processForm(e); |
306 | 345 | }); |
307 | 346 | } |
|
941 | 980 | this.processForm(null); |
942 | 981 | } |
943 | 982 |
|
944 | | - $(document).off('click', '.' + this.settings.locationList + ' .bh-sl-close-icon'); |
| 983 | + $(document).off('click.'+pluginName, '.' + this.settings.locationList + ' .bh-sl-close-icon'); |
945 | 984 | }, |
946 | 985 |
|
947 | 986 | /** |
|
1294 | 1333 | // Pop up the modal window |
1295 | 1334 | $('.' + _this.settings.overlay).fadeIn(); |
1296 | 1335 | // Close modal when close icon is clicked and when background overlay is clicked |
1297 | | - $(document).on('click', '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () { |
| 1336 | + $(document).on('click.'+pluginName, '.' + _this.settings.closeIcon + ', .' + _this.settings.overlay, function () { |
1298 | 1337 | _this.modalClose(); |
1299 | 1338 | }); |
1300 | 1339 | // Prevent clicks within the modal window from closing the entire thing |
1301 | | - $(document).on('click', '.' + _this.settings.modalWindow, function (e) { |
| 1340 | + $(document).on('click.'+pluginName, '.' + _this.settings.modalWindow, function (e) { |
1302 | 1341 | e.stopPropagation(); |
1303 | 1342 | }); |
1304 | 1343 | // Close modal when escape key is pressed |
1305 | | - $(document).on('keyup', function (e) { |
| 1344 | + $(document).on('keyup.'+pluginName, function (e) { |
1306 | 1345 | if (e.keyCode === 27) { |
1307 | 1346 | _this.modalClose(); |
1308 | 1347 | } |
|
1391 | 1430 | } |
1392 | 1431 |
|
1393 | 1432 | // Handle pagination |
1394 | | - $(document).on('click', '.bh-sl-pagination li', function () { |
| 1433 | + $(document).on('click.'+pluginName, '.bh-sl-pagination li', function () { |
1395 | 1434 | // Run paginationChange |
1396 | 1435 | _this.paginationChange($(this).attr('data-page')); |
1397 | 1436 | }); |
1398 | 1437 |
|
1399 | 1438 | // Inline directions |
1400 | 1439 | if(_this.settings.inlineDirections === true){ |
1401 | 1440 | // Open directions |
1402 | | - $(document).on('click', '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { |
| 1441 | + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li .loc-directions a', function (e) { |
1403 | 1442 | e.preventDefault(); |
1404 | 1443 | var locID = $(this).closest('li').attr('data-markerid'); |
1405 | 1444 | _this.directionsRequest(origin, locID, map); |
1406 | 1445 | }); |
1407 | 1446 |
|
1408 | 1447 | // Close directions |
1409 | | - $(document).on('click', '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () { |
| 1448 | + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () { |
1410 | 1449 | _this.closeDirections(); |
1411 | 1450 | }); |
1412 | 1451 | } |
|
1453 | 1492 | } |
1454 | 1493 |
|
1455 | 1494 | // Handle clicks from the list |
1456 | | - $(document).on('click', '.' + _this.settings.locationList + ' li', function () { |
| 1495 | + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li', function () { |
1457 | 1496 | var markerId = $(this).data('markerid'); |
1458 | 1497 |
|
1459 | 1498 | var selectedMarker = markers[markerId]; |
|
1478 | 1517 | }); |
1479 | 1518 |
|
1480 | 1519 | // Prevent bubbling from list content links |
1481 | | - $(document).on('click', '.' + _this.settings.locationList + ' li a', function (e) { |
| 1520 | + $(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' li a', function (e) { |
1482 | 1521 | e.stopPropagation(); |
1483 | 1522 | }); |
1484 | 1523 |
|
|
1501 | 1540 | }); |
1502 | 1541 |
|
1503 | 1542 | // Handle filter updates |
1504 | | - $('.bh-sl-filters-container').on('change', 'input, select', function (e) { |
| 1543 | + $('.bh-sl-filters-container').on('change.'+pluginName, 'input, select', function (e) { |
1505 | 1544 | e.stopPropagation(); |
1506 | 1545 |
|
1507 | 1546 | var filterId, filterContainer, filterKey; |
|
0 commit comments