OpenLayers OpenLayers

Ticket #1061: patch-close-popup-A1.diff

File patch-close-popup-A1.diff, 3.3 kB (added by elemoine, 1 year ago)
  • lib/OpenLayers/Popup/AnchoredBubble.js

    old new  
    3232     *     a 'size' (<OpenLayers.Size>) and 'offset' (<OpenLayers.Pixel>)  
    3333     *     (Note that this is generally an <OpenLayers.Icon>). 
    3434     * closeBox - {Boolean} 
     35     * closeBoxCallback - {Function} Function to be called on closeBox click. 
    3536     */ 
    36     initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) { 
     37    initialize:function(id, lonlat, size, contentHTML, anchor, closeBox, 
     38                        closeBoxCallback) { 
    3739        OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); 
    3840    }, 
    3941 
  • lib/OpenLayers/Popup/Anchored.js

    old new  
    3838    * anchor - {Object} Object which must expose a 'size' <OpenLayers.Size>  
    3939    *     and 'offset' <OpenLayers.Pixel> (generally an <OpenLayers.Icon>). 
    4040    * closeBox - {Boolean} 
     41    * closeBoxCallback - {Function} Function to be called on closeBox click. 
    4142    */ 
    42     initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) { 
    43         var newArguments = new Array(id, lonlat, size, contentHTML, closeBox); 
     43    initialize:function(id, lonlat, size, contentHTML, anchor, closeBox, 
     44                        closeBoxCallback) { 
     45        var newArguments = new Array(id, lonlat, size, contentHTML, closeBox, 
     46                                     closeBoxCallback); 
    4447        OpenLayers.Popup.prototype.initialize.apply(this, newArguments); 
    4548 
    4649        this.anchor = (anchor != null) ? anchor  
  • lib/OpenLayers/Popup.js

    old new  
    117117    * contentHTML - {String}          The HTML content to display inside the  
    118118    *                                 popup. 
    119119    * closeBox - {Boolean}            Whether to display a close box inside 
    120     *                                 the popup.  
     120    *                                 the popup. 
     121    * closeBoxCallback - {Function}   Function to be called on closeBox click. 
    121122    */ 
    122     initialize:function(id, lonlat, size, contentHTML, closeBox) { 
     123    initialize:function(id, lonlat, size, contentHTML, closeBox, closeBoxCallback) { 
    123124        if (id == null) { 
    124125            id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 
    125126        } 
     
    165166            closeImg.style.top = this.padding + "px"; 
    166167            this.groupDiv.appendChild(closeImg); 
    167168 
    168             var closePopup = function(e) { 
    169                 this.hide(); 
    170                 OpenLayers.Event.stop(e); 
     169            var callback = closeBoxCallback; 
     170            if (!callback) { 
     171                callback = function(e) { 
     172                    this.hide(); 
     173                    OpenLayers.Event.stop(e); 
     174                }; 
    171175            } 
    172176            OpenLayers.Event.observe(closeImg, "click",  
    173                     OpenLayers.Function.bindAsEventListener(closePopup, this)); 
     177                    OpenLayers.Function.bindAsEventListener(callback, this)); 
    174178 
    175179        } 
    176180