OpenLayers OpenLayers

Ticket #494: popup_calcRelPos.2.patch

File popup_calcRelPos.2.patch, 3.4 kB (added by euzuro, 1 year ago)

removing duplicated rounding code from anchored bubble's draw(), adding more ND comments

  • tests/Popup/test_Anchored.html

    old new  
     1<html> 
     2<head> 
     3  <script src="../../lib/OpenLayers.js"></script> 
     4  <script type="text/javascript"> 
     5 
     6    var popup; 
     7 
     8    function test_01_Popup_Anchored_default_constructor(t) { 
     9        t.plan( 4 ); 
     10 
     11        popup = new OpenLayers.Popup.Anchored(); 
     12 
     13        t.ok( popup instanceof OpenLayers.Popup.Anchored, "new OpenLayers.Popup.Anchored returns Popup.Anchored object" ); 
     14        t.ok(popup.id.startsWith("OpenLayers.Popup.Anchored"), "valid default popupid"); 
     15        var firstID = popup.id; 
     16        t.eq(popup.contentHTML, "", "good default popup.contentHTML"); 
     17 
     18         
     19        popup = new OpenLayers.Popup.Anchored(); 
     20        var newID = popup.id; 
     21        t.ok(newID != firstID, "default id generator creating unique ids"); 
     22    } 
     23    function test_Popup_Anchored_updateRelPos(t) {  
     24        t.plan(1); 
     25        var popup = new OpenLayers.Popup.Anchored(); 
     26        popup.calculateNewPx = function () {} 
     27        popup.calculateRelativePosition = function() { 
     28            t.ok(true, "update relative position is called on moveTo"); 
     29        } 
     30        popup.moveTo(new OpenLayers.Pixel(0,0)); 
     31   }  
     32 
     33  </script> 
     34</head> 
     35<body> 
     36</body> 
     37</html> 
  • tests/list-tests.html

    old new  
    3131    <li>test_Marker.html</li> 
    3232    <li>Marker/test_Box.html</li> 
    3333    <li>test_Popup.html</li> 
     34    <li>Popup/test_Anchored.html</li> 
    3435    <li>test_Feature.html</li> 
    3536    <li>Feature/test_Vector.html</li> 
    3637    <li>test_Events.html</li> 
  • lib/OpenLayers/Popup/AnchoredBubble.js

    old new  
    5252 
    5353        this.setContentHTML(); 
    5454         
    55         this.setRicoCorners(!this.rounded); 
    56         this.rounded = true; 
    57          
    5855        //set the popup color and opacity            
    5956        this.setBackgroundColor();  
    6057        this.setOpacity(); 
     
    6360    }, 
    6461 
    6562    /** 
     63     * Method: moveTo 
     64     * The popup may have been moved to a new relative location, in which case 
     65     *     we will want to re-do the rico corners. 
     66     *  
     67     * Parameters: 
     68     * px - {<OpenLayers.Pixel>} 
     69     */ 
     70    moveTo: function(px) { 
     71        OpenLayers.Popup.Anchored.prototype.moveTo.apply(this, arguments); 
     72        this.setRicoCorners(!this.rounded); 
     73        this.rounded = true; 
     74    }, 
     75 
     76    /** 
    6677     * APIMethod: setSize 
    6778     *  
    6879     * Parameters: 
  • lib/OpenLayers/Popup/Anchored.js

    old new  
    9191 
    9292    /** 
    9393     * Method: moveTo 
     94     * Since the popup is moving to a new px, it might need also to be moved 
     95     *     relative to where the marker is. 
    9496     *  
    9597     * Parameters: 
    9698     * px - {<OpenLayers.Pixel>} 
    9799     */ 
    98100    moveTo: function(px) { 
     101        this.relativePosition = this.calculateRelativePosition(px); 
    99102        var newPx = this.calculateNewPx(px); 
    100103         
    101104        var newArguments = new Array(newPx);