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:
@@ -37,7 +37,8 @@
|
|||||||
popup = new OpenLayers.Popup("chicken",
|
popup = new OpenLayers.Popup("chicken",
|
||||||
new OpenLayers.LonLat(5,40),
|
new OpenLayers.LonLat(5,40),
|
||||||
new OpenLayers.Size(200,200),
|
new OpenLayers.Size(200,200),
|
||||||
"example popup");
|
"example popup",
|
||||||
|
true);
|
||||||
|
|
||||||
map.addPopup(popup);
|
map.addPopup(popup);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
+19
-1
@@ -60,8 +60,9 @@ OpenLayers.Popup.prototype = {
|
|||||||
* @param {OpenLayers.LonLat} lonlat
|
* @param {OpenLayers.LonLat} lonlat
|
||||||
* @param {OpenLayers.Size} size
|
* @param {OpenLayers.Size} size
|
||||||
* @param {String} contentHTML
|
* @param {String} contentHTML
|
||||||
|
* @param {Boolean} closeBox
|
||||||
*/
|
*/
|
||||||
initialize:function(id, lonlat, size, contentHTML) {
|
initialize:function(id, lonlat, size, contentHTML, closeBox) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||||
}
|
}
|
||||||
@@ -90,6 +91,23 @@ OpenLayers.Popup.prototype = {
|
|||||||
this.contentDiv.className = 'olPopupContent';
|
this.contentDiv.className = 'olPopupContent';
|
||||||
this.div.appendChild(this.contentDiv);
|
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();
|
this.registerEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,10 @@ OpenLayers.Popup.Anchored.prototype =
|
|||||||
* - 'size' (OpenLayers.Size) and
|
* - 'size' (OpenLayers.Size) and
|
||||||
* - 'offset' (OpenLayers.Pixel)
|
* - 'offset' (OpenLayers.Pixel)
|
||||||
* (this is generally an OpenLayers.Icon)
|
* (this is generally an OpenLayers.Icon)
|
||||||
|
* @param {Boolean} closeBox
|
||||||
*/
|
*/
|
||||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) {
|
||||||
var newArguments = new Array(id, lonlat, size, contentHTML);
|
var newArguments = new Array(id, lonlat, size, contentHTML, closeBox);
|
||||||
OpenLayers.Popup.prototype.initialize.apply(this, newArguments);
|
OpenLayers.Popup.prototype.initialize.apply(this, newArguments);
|
||||||
|
|
||||||
this.anchor = (anchor != null) ? anchor
|
this.anchor = (anchor != null) ? anchor
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
|||||||
* - 'size' (OpenLayers.Size) and
|
* - 'size' (OpenLayers.Size) and
|
||||||
* - 'offset' (OpenLayers.Pixel)
|
* - 'offset' (OpenLayers.Pixel)
|
||||||
* (this is generally an OpenLayers.Icon)
|
* (this is generally an OpenLayers.Icon)
|
||||||
|
* @param {Boolean} closeBox
|
||||||
*/
|
*/
|
||||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) {
|
||||||
OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
|
OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user