Fixing PanZoomBar and Panel issues after #164.

For PanZoomBar, this fixes the slider behavior. Now the buttonclick listener argument also includes a buttonXY property, and PanZoomPanel does not need an Events instance for the zoombarDiv any more.
For Panel, this fixes events for panels outside the map. Just setting the element on the Events instance was no longer enough after e70569b2bb. Events::attachToElement is now used, and it needed to be modified to also work if the Events instance had no element previously.
Finally, I renamed the button property of the buttonclick listener argument to buttonElement, to not confuse it with the browser event button property, and added some more tests and documentation.
This commit is contained in:
ahocevar
2012-01-21 19:11:08 +01:00
parent 469005dead
commit e7107b96cb
11 changed files with 87 additions and 79 deletions
+15
View File
@@ -322,6 +322,21 @@
map.destroy();
}
function test_buttonclick(t) {
t.plan(4);
var map = new OpenLayers.Map('map');
var panel1 = new OpenLayers.Control.Panel();
var div = document.createElement("div");
var panel2 = new OpenLayers.Control.Panel({div: div});
map.addControls([panel1, panel2]);
t.ok(map.events.listeners.buttonclick, "buttonclick event registered on map's Events instance for panel inside map");
t.ok(!panel1.events.element, "Panel inside map has no element on its Events instance");
t.ok(panel2.events.listeners.buttonclick, "buttonclick event registered on panel's Events instance if outside map")
t.ok(panel2.events.element === div, "Panel outside map has the panel's div as element on its Events instance");
}
</script>
</head>
<body>