From 153a03a3e54b77bfe01b762031b73ca5e2807981 Mon Sep 17 00:00:00 2001 From: Egon Steiner Date: Fri, 24 Jul 2015 13:01:57 +0200 Subject: [PATCH] fix closebutton position when rrose is displayed south --- leaflet.rrose.css | 4 ++++ rrose-src.js | 26 +++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/leaflet.rrose.css b/leaflet.rrose.css index 0b178d2..39abda1 100644 --- a/leaflet.rrose.css +++ b/leaflet.rrose.css @@ -80,6 +80,10 @@ a.leaflet-rrose-close-button { font-weight: bold; } +a.leaflet-rrose-close-button-s { + top: 20px; +} + a.leaflet-rrose-close-button:hover { color: #999; } diff --git a/rrose-src.js b/rrose-src.js index b3ffccf..e485fb2 100644 --- a/rrose-src.js +++ b/rrose-src.js @@ -22,14 +22,6 @@ L.Rrose = L.Popup.extend({ container = this._container = L.DomUtil.create('div', prefix + ' ' + this.options.className + ' leaflet-zoom-animated'), closeButton, wrapper; - if (this.options.closeButton) { - closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container); - closeButton.href = '#close'; - closeButton.innerHTML = '×'; - - L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); - } - // Set the pixel distances from the map edges at which popups are too close and need to be re-oriented. var x_bound = 80, y_bound = 80; // Determine the alternate direction to pop up; north mimics Leaflet's default behavior, so we initialize to that. @@ -65,7 +57,15 @@ L.Rrose = L.Popup.extend({ L.DomEvent.disableClickPropagation(wrapper); this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation); - } + + if (this.options.closeButton) { + closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button' + ' ' + prefix + '-close-button-s', container); + closeButton.href = '#close'; + closeButton.innerHTML = '×'; + + L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); + } + } else { if (this.options.position === 'n') { wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container); @@ -79,6 +79,14 @@ L.Rrose = L.Popup.extend({ this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation); this._tip = L.DomUtil.create('div', prefix + '-tip' + ' ' + prefix + '-tip-' + this.options.position, this._tipContainer); + + if (this.options.closeButton) { + closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container); + closeButton.href = '#close'; + closeButton.innerHTML = '×'; + + L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); + } } },