[OpenLayers-Commits] r4250 - in trunk/openlayers: lib/OpenLayers/Popup tests tests/Popup

commits at openlayers.org commits at openlayers.org
Wed Sep 12 16:14:14 EDT 2007


Author: crschmidt
Date: 2007-09-12 16:14:14 -0400 (Wed, 12 Sep 2007)
New Revision: 4250

Added:
   trunk/openlayers/tests/Popup/test_Anchored.html
Modified:
   trunk/openlayers/lib/OpenLayers/Popup/Anchored.js
   trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js
   trunk/openlayers/tests/list-tests.html
Log:
Patch from Erik/I to fix:
Popups don't move adequately after zooming with scroll wheel
(Closes #494)


Modified: trunk/openlayers/lib/OpenLayers/Popup/Anchored.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Popup/Anchored.js	2007-09-12 20:04:26 UTC (rev 4249)
+++ trunk/openlayers/lib/OpenLayers/Popup/Anchored.js	2007-09-12 20:14:14 UTC (rev 4250)
@@ -91,11 +91,15 @@
 
     /**
      * Method: moveTo
+     * Since the popup is moving to a new px, it might need also to be moved
+     *     relative to where the marker is.
      * 
      * Parameters:
      * px - {<OpenLayers.Pixel>}
      */
     moveTo: function(px) {
+        this.relativePosition = this.calculateRelativePosition(px);
+        
         var newPx = this.calculateNewPx(px);
         
         var newArguments = new Array(newPx);        

Modified: trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js	2007-09-12 20:04:26 UTC (rev 4249)
+++ trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js	2007-09-12 20:14:14 UTC (rev 4250)
@@ -52,9 +52,6 @@
 
         this.setContentHTML();
         
-        this.setRicoCorners(!this.rounded);
-        this.rounded = true;
-        
         //set the popup color and opacity           
         this.setBackgroundColor(); 
         this.setOpacity();
@@ -63,6 +60,20 @@
     },
 
     /**
+     * Method: moveTo
+     * The popup may have been moved to a new relative location, in which case
+     *     we will want to re-do the rico corners.
+     * 
+     * Parameters:
+     * px - {<OpenLayers.Pixel>}
+     */
+    moveTo: function(px) {
+        OpenLayers.Popup.Anchored.prototype.moveTo.apply(this, arguments);
+        this.setRicoCorners(!this.rounded);
+        this.rounded = true;
+    },
+
+    /**
      * APIMethod: setSize
      * 
      * Parameters:

Added: trunk/openlayers/tests/Popup/test_Anchored.html
===================================================================
--- trunk/openlayers/tests/Popup/test_Anchored.html	                        (rev 0)
+++ trunk/openlayers/tests/Popup/test_Anchored.html	2007-09-12 20:14:14 UTC (rev 4250)
@@ -0,0 +1,37 @@
+<html>
+<head>
+  <script src="../../lib/OpenLayers.js"></script>
+  <script type="text/javascript">
+
+    var popup;
+
+    function test_01_Popup_Anchored_default_constructor(t) {
+        t.plan( 4 );
+
+        popup = new OpenLayers.Popup.Anchored();
+
+        t.ok( popup instanceof OpenLayers.Popup.Anchored, "new OpenLayers.Popup.Anchored returns Popup.Anchored object" );
+        t.ok(popup.id.startsWith("OpenLayers.Popup.Anchored"), "valid default popupid");
+        var firstID = popup.id;
+        t.eq(popup.contentHTML, "", "good default popup.contentHTML");
+
+        
+        popup = new OpenLayers.Popup.Anchored();
+        var newID = popup.id;
+        t.ok(newID != firstID, "default id generator creating unique ids");
+    }
+    function test_Popup_Anchored_updateRelPos(t) { 
+        t.plan(1);
+        var popup = new OpenLayers.Popup.Anchored();
+        popup.calculateNewPx = function () {}
+        popup.calculateRelativePosition = function() {
+            t.ok(true, "update relative position is called on moveTo");
+        }
+        popup.moveTo(new OpenLayers.Pixel(0,0));
+   } 
+
+  </script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/openlayers/tests/list-tests.html
===================================================================
--- trunk/openlayers/tests/list-tests.html	2007-09-12 20:04:26 UTC (rev 4249)
+++ trunk/openlayers/tests/list-tests.html	2007-09-12 20:14:14 UTC (rev 4250)
@@ -31,6 +31,7 @@
     <li>test_Marker.html</li>
     <li>Marker/test_Box.html</li>
     <li>test_Popup.html</li>
+    <li>Popup/test_Anchored.html</li>
     <li>test_Feature.html</li>
     <li>Feature/test_Vector.html</li>
     <li>test_Events.html</li>



More information about the Commits mailing list