From d6dc8acd04b055e1ea4017fbf98e071dec1c783e Mon Sep 17 00:00:00 2001 From: Mourner Date: Mon, 10 Jan 2011 13:06:22 +0200 Subject: [PATCH] move closePopupOnClick to Map --- src/layer/Popup.js | 8 +------- src/map/Map.Popup.js | 4 ++++ src/map/Map.js | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/layer/Popup.js b/src/layer/Popup.js index b2b03b81..079dd07b 100644 --- a/src/layer/Popup.js +++ b/src/layer/Popup.js @@ -3,8 +3,7 @@ L.Popup = L.Class.extend({ includes: L.Mixin.Events, options: { - maxWidth: 300, - closeOnClick: true + maxWidth: 300 }, initialize: function() { @@ -23,11 +22,6 @@ L.Popup = L.Class.extend({ map.on('viewreset', this._updatePosition, this); - if (this.options.closeOnClick) { - map.on('click', map.closePopup, map); - //TODO move closeOnClick to Map - } - this._container.style.visibility = 'hidden'; this._updateLayout(); this._updatePosition(); diff --git a/src/map/Map.Popup.js b/src/map/Map.Popup.js index 3dc5a81d..7efa9b41 100644 --- a/src/map/Map.Popup.js +++ b/src/map/Map.Popup.js @@ -3,6 +3,10 @@ L.Map.include({ openPopup: function(latlng, content, offset) { if (!this._popup) { this._popup = new L.Popup(); + + if (this.options.closePopupOnClick) { + this.on('click', this.closePopup, this); + } } else { this.removeLayer(this._popup); } diff --git a/src/map/Map.js b/src/map/Map.js index 81e0d8ad..00b8526d 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -23,7 +23,8 @@ L.Map = L.Class.extend({ doubleClickZoom: true, //misc - trackResize: true + trackResize: true, + closePopupOnClick: true },