diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 82b715050b..734df9073a 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -90,6 +90,12 @@ OpenLayers.Popup = OpenLayers.Class({ */ groupDiv: null, + /** + * Property: closeDiv + * {DOMElement} the optional closer image + */ + closeDiv: null, + /** * Property: padding * {int} the internal padding of the content div. @@ -157,19 +163,18 @@ OpenLayers.Popup = OpenLayers.Class({ // close icon var closeSize = new OpenLayers.Size(17,17); var img = OpenLayers.Util.getImagesLocation() + "close.gif"; - var closeImg = OpenLayers.Util.createAlphaImageDiv(this.id + "_close", - null, - closeSize, - img); - closeImg.style.right = this.padding + "px"; - closeImg.style.top = this.padding + "px"; - this.groupDiv.appendChild(closeImg); + this.closeDiv = OpenLayers.Util.createAlphaImageDiv( + this.id + "_close", null, closeSize, img + ); + this.closeDiv.style.right = this.padding + "px"; + this.closeDiv.style.top = this.padding + "px"; + this.groupDiv.appendChild(this.closeDiv); var closePopup = closeBoxCallback || function(e) { this.hide(); OpenLayers.Event.stop(e); }; - OpenLayers.Event.observe(closeImg, "click", + OpenLayers.Event.observe(this.closeDiv, "click", OpenLayers.Function.bindAsEventListener(closePopup, this)); }