OpenLayers OpenLayers

Ticket #1479: createBlocks.3.patch

File createBlocks.3.patch, 2.3 kB (added by crschmidt, 9 months ago)
  • tests/Popup/FramedCloud.html

    old new  
     1<html> 
     2<head> 
     3  <script src="../../lib/OpenLayers.js"></script> 
     4  <script type="text/javascript"> 
     5 
     6   function test_Popup_FramedCloud_setHTML(t) {  
     7        t.plan(1); 
     8        popup = new OpenLayers.Popup.FramedCloud(); 
     9        popup.setContentHTML("<p></p>"); 
     10        t.ok("setHTML on popup not yet added to map doesn't fail"); 
     11   } 
     12 
     13  </script> 
     14</head> 
     15<body> 
     16<div id="map" style="width:512px; height:256px"> </div> 
     17</body> 
     18</html> 
  • tests/list-tests.html

    old new  
    4040    <li>Popup.html</li> 
    4141    <li>Popup/Anchored.html</li> 
    4242    <li>Popup/AnchoredBubble.html</li> 
     43    <li>Popup/FramedCloud.html</li> 
    4344    <li>Feature.html</li> 
    4445    <li>Feature/Vector.html</li> 
    4546    <li>Style.html</li> 
  • lib/OpenLayers/Popup/Framed.js

    old new  
    248248     * Method: createBlocks 
    249249     */ 
    250250    createBlocks: function() { 
     251        if (!this.relativePosition) { 
     252            // this.relativePosition can't be set until we have a map 
     253            // set: if it's not set, we can't create blocks. (See #1479)  
     254            return false;  
     255        }     
     256         
    251257        this.blocks = []; 
    252258 
    253259        var position = this.positionBlocks[this.relativePosition]; 
     
    274280            block.div.appendChild(block.image); 
    275281            this.groupDiv.appendChild(block.div); 
    276282        } 
     283         
     284        return true; 
    277285    }, 
    278286 
    279287    /** 
     
    283291     *     the popup's blocks in their appropropriate places. 
    284292     */ 
    285293    updateBlocks: function() { 
    286  
    287294        if (!this.blocks) { 
    288             this.createBlocks(); 
     295            var cont = this.createBlocks(); 
     296            if (!cont) {  
     297                return false; 
     298            }      
    289299        } 
    290  
     300         
     301         
    291302        var position = this.positionBlocks[this.relativePosition]; 
    292303        for (var i = 0; i < position.blocks.length; i++) { 
    293304