From 637799f1f57ab48254a5b6eaa0f78896ae41c456 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 8 Oct 2013 17:24:49 -0700 Subject: [PATCH] Fix export location filter button Upstream pull request: https://github.com/kajic/leaflet-locationfilter/pull/14 --- app/assets/javascripts/index.js | 2 +- app/assets/javascripts/index/export.js | 8 ++++---- vendor/assets/leaflet/leaflet.locationfilter.js | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 77b247c10..e9e95abfe 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -292,7 +292,7 @@ $(document).ready(function () { }); $(document).on("click", "a", function(e) { - if (e.isPropagationStopped()) return; + if (e.isDefaultPrevented() || e.isPropagationStopped()) return; if (this.host === window.location.host && OSM.route(this.pathname + this.search + this.hash)) e.preventDefault(); }); diff --git a/app/assets/javascripts/index/export.js b/app/assets/javascripts/index/export.js index 51ad1e3e2..02dcdd440 100644 --- a/app/assets/javascripts/index/export.js +++ b/app/assets/javascripts/index/export.js @@ -22,12 +22,12 @@ OSM.Export = function(map) { validateControls(); } - function enableFilter() { - if (!locationFilter.getBounds().isValid()) { - locationFilter.setBounds(map.getBounds().pad(-0.2)); - } + function enableFilter(e) { + e.preventDefault(); $("#drag_box").hide(); + + locationFilter.setBounds(map.getBounds().pad(-0.2)); locationFilter.enable(); } diff --git a/vendor/assets/leaflet/leaflet.locationfilter.js b/vendor/assets/leaflet/leaflet.locationfilter.js index a17f1a5af..9a0af4db4 100644 --- a/vendor/assets/leaflet/leaflet.locationfilter.js +++ b/vendor/assets/leaflet/leaflet.locationfilter.js @@ -114,7 +114,6 @@ L.LocationFilter = L.Class.extend({ onAdd: function(map) { this._map = map; - this._layer = new L.LayerGroup(); if (this.options.enableButton || this.options.adjustButton) { this._initializeButtonContainer(); @@ -285,6 +284,8 @@ L.LocationFilter = L.Class.extend({ return; } + this._layer = new L.LayerGroup(); + // Calculate filter bounds this._calculateBounds(); -- 2.43.2