OpenLayers OpenLayers

root/trunk/openlayers/tests/Popup/Anchored.html

Revision 7886, 1.1 kB (checked in by euzuro, 4 months ago)

Bubble out the code that handles the re-sizing of the popup into an APIMethod: updateSize(). Other change is that now instead of using the 'contentHTML' string property to autosize, we will now use the actual contentDiv's 'innerHTML' property. This is possible because in the setContentHTML() function, we switch around the order and set the conentDiv.innerHTML *before* calling updateSize(). Seemingly minor, this change actually does wonders towards distancing us from the horrendous idea that the 'contentHTML' property was in the first place. Now, if users go in and fudge with the contentDiv DOMElement directly, they can still benefit from the auto-sizing. In fact, 'contentHTML' can be totally ignored altogether. joy. All tests pass, including an eyeballing of the acceptance test examples/popupMatrix.html in ff2 and ie7. Mil gracias to cr5 for the speedy review (Closes #1708)

  • Property svn:eol-style set to native
Line 
1 <html>
2 <head>
3   <script src="../../lib/OpenLayers.js"></script>
4   <script type="text/javascript">
5
6     var popup;
7
8     function test_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, null, "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>
Note: See TracBrowser for help on using the browser.