Add the ability to add a close button to popups via a final param to the

constructor of a popup. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1704 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-10-18 16:50:07 +00:00
parent 27a8fee770
commit cb3af3eaba
5 changed files with 26 additions and 5 deletions

View File

@@ -60,8 +60,9 @@ OpenLayers.Popup.prototype = {
* @param {OpenLayers.LonLat} lonlat
* @param {OpenLayers.Size} size
* @param {String} contentHTML
* @param {Boolean} closeBox
*/
initialize:function(id, lonlat, size, contentHTML) {
initialize:function(id, lonlat, size, contentHTML, closeBox) {
if (id == null) {
id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
}
@@ -90,6 +91,23 @@ OpenLayers.Popup.prototype = {
this.contentDiv.className = 'olPopupContent';
this.div.appendChild(this.contentDiv);
if (closeBox == true) {
// 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.div.appendChild(closeImg);
var closeEvents = new OpenLayers.Events(this, closeImg);
closeEvents.register("mousedown", this, this.hide);
}
this.registerEvents();
},