Made the Feature handler more robust to things that are related to changing layer order on the map, by registering an event handler that will bring the handler's layer back to the top of the layer stack in the DOM. Contains a manual test. r=elemoine (closes #1628)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7879 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-08-27 14:02:21 +00:00
parent 8e0876488b
commit 2a521ffcb2
5 changed files with 218 additions and 20 deletions
+5 -6
View File
@@ -30,7 +30,7 @@
}
function test_Handler_Feature_activate(t) {
t.plan(4);
t.plan(3);
var map = new OpenLayers.Map('map');
var control = new OpenLayers.Control();
map.addControl(control);
@@ -47,10 +47,8 @@
activated = handler.activate();
t.ok(activated,
"activate returns true if the handler was not already active");
t.eq(handler.layerIndex, zIndex,
"layerIndex property properly set");
t.eq(parseInt(layer.div.style.zIndex),
map.Z_INDEX_BASE['Popup'] - 1,
map.Z_INDEX_BASE['Feature'],
"layer z-index properly adjusted");
}
@@ -227,6 +225,8 @@
map.addControl(control);
var layer = new OpenLayers.Layer();
map.addLayer(layer);
var layerIndex = parseInt(layer.div.style.zIndex);
var handler = new OpenLayers.Handler.Feature(control, layer);
handler.active = false;
var deactivated = handler.deactivate();
@@ -234,13 +234,12 @@
"deactivate returns false if the handler was not already active");
handler.active = true;
handler.layerIndex = Math.floor(Math.random() * 10);
deactivated = handler.deactivate();
t.ok(deactivated,
"deactivate returns true if the handler was active already");
t.eq(parseInt(layer.div.style.zIndex),
handler.layerIndex,
layerIndex,
"deactivate sets the layer z-index back");
}