OpenLayers OpenLayers

Changeset 1704

Show
Ignore:
Timestamp:
10/18/06 12:50:07 (2 years ago)
Author:
crschmidt
Message:

Add the ability to add a close button to popups via a final param to the
constructor of a popup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/popups.html

    r1592 r1704  
    3838                                         new OpenLayers.LonLat(5,40), 
    3939                                         new OpenLayers.Size(200,200), 
    40                                          "example popup"); 
     40                                         "example popup", 
     41                                         true); 
    4142         
    4243            map.addPopup(popup); 
  • trunk/openlayers/lib/OpenLayers/Popup.js

    r1695 r1704  
    6161    * @param {OpenLayers.Size} size 
    6262    * @param {String} contentHTML 
    63     */ 
    64     initialize:function(id, lonlat, size, contentHTML) { 
     63    * @param {Boolean} closeBox 
     64    */ 
     65    initialize:function(id, lonlat, size, contentHTML, closeBox) { 
    6566        if (id == null) { 
    6667            id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 
     
    9091        this.contentDiv.className = 'olPopupContent';                                             
    9192        this.div.appendChild(this.contentDiv); 
     93 
     94        if (closeBox == true) { 
     95           // close icon 
     96            var closeSize = new OpenLayers.Size(17,17); 
     97            var img = OpenLayers.Util.getImagesLocation() + "close.gif"; 
     98            var closeImg = OpenLayers.Util.createAlphaImageDiv(this.id + "_close",  
     99                                                                null,  
     100                                                                closeSize,  
     101                                                                img); 
     102            closeImg.style.right = this.padding + "px"; 
     103            closeImg.style.top = this.padding + "px"; 
     104            this.div.appendChild(closeImg); 
     105 
     106            var closeEvents = new OpenLayers.Events(this, closeImg); 
     107            closeEvents.register("mousedown", this, this.hide); 
     108 
     109        } 
    92110 
    93111        this.registerEvents(); 
  • trunk/openlayers/lib/OpenLayers/Popup/Anchored.js

    r1651 r1704  
    3232    *                         - 'offset' (OpenLayers.Pixel)  
    3333    *                         (this is generally an OpenLayers.Icon) 
     34    * @param {Boolean} closeBox 
    3435    */ 
    35     initialize:function(id, lonlat, size, contentHTML, anchor) { 
    36         var newArguments = new Array(id, lonlat, size, contentHTML); 
     36    initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) { 
     37        var newArguments = new Array(id, lonlat, size, contentHTML, closeBox); 
    3738        OpenLayers.Popup.prototype.initialize.apply(this, newArguments); 
    3839 
  • trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js

    r1695 r1704  
    2929    *                         - 'offset' (OpenLayers.Pixel)  
    3030    *                         (this is generally an OpenLayers.Icon) 
     31    * @param {Boolean} closeBox 
    3132    */ 
    32     initialize:function(id, lonlat, size, contentHTML, anchor) { 
     33    initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) { 
    3334        OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); 
    3435    },