Update MousePositoin control to support activate/deactivate. Patch by jorix,
tests pass, and controls.html example still works the same as before. (Closes #2520) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10669 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -68,6 +68,39 @@
|
||||
var val = control.formatOutput(lonlat);
|
||||
t.eq(val, 'prefix0.757separator0.374suffix', 'formatOutput correctly formats the mouse position output');
|
||||
}
|
||||
function test_deactivate(t) {
|
||||
t.plan(4);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer(null, {isBaseLayer: true});
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
// Auxiliary function
|
||||
function trigger(type, x, y) {
|
||||
map.events.triggerEvent(type, {
|
||||
xy: new OpenLayers.Pixel(x, y)
|
||||
})
|
||||
};
|
||||
|
||||
var control = new OpenLayers.Control.MousePosition();
|
||||
map.addControl(control);
|
||||
trigger("mousemove", 0, 0);
|
||||
|
||||
trigger("mousemove", 0, 1);
|
||||
t.ok(control.div.innerHTML != "",
|
||||
"Shows the position after add control (with autoActivate) and move");
|
||||
control.deactivate();
|
||||
t.ok(control.div.innerHTML == "",
|
||||
"Position is not displayed after deactivate and move");
|
||||
trigger("mousemove", 0, 2);
|
||||
t.ok(control.div.innerHTML == "",
|
||||
"Position is not displayed after move when deactivate");
|
||||
control.activate();
|
||||
trigger("mousemove", 0, 3);
|
||||
t.ok(control.div.innerHTML != "",
|
||||
"Shows the position after activate and move");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user