Avoid panel being displayed after deactivate. p=jorix, r=me (closes #2835)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10732 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -95,6 +95,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
* APIMethod: destroy
|
* APIMethod: destroy
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
this.deactivate();
|
||||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||||
for(var i = this.controls.length - 1 ; i >= 0; i--) {
|
for(var i = this.controls.length - 1 ; i >= 0; i--) {
|
||||||
if(this.controls[i].events) {
|
if(this.controls[i].events) {
|
||||||
@@ -143,6 +144,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
control = this.controls[i];
|
control = this.controls[i];
|
||||||
this.activeState[control.id] = control.deactivate();
|
this.activeState[control.id] = control.deactivate();
|
||||||
}
|
}
|
||||||
|
this.redraw();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -227,7 +227,26 @@
|
|||||||
t.ok(!controlNoDeactive.active, "Tool control autoActivate:true is not active");
|
t.ok(!controlNoDeactive.active, "Tool control autoActivate:true is not active");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function test_Control_Panel_dectivate (t) {
|
||||||
|
t.plan(3);
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var control = new OpenLayers.Control();
|
||||||
|
var panel = new OpenLayers.Control.Panel();
|
||||||
|
map.addControl(panel);
|
||||||
|
panel.addControls([control]);
|
||||||
|
t.ok(panel.div.innerHTML != "", "Panel displayed after activate");
|
||||||
|
|
||||||
|
panel.deactivate();
|
||||||
|
t.ok(panel.div.innerHTML == "",
|
||||||
|
"Panel is not displayed after deactivate without any active control");
|
||||||
|
|
||||||
|
panel.activate();
|
||||||
|
var div = panel.div;
|
||||||
|
panel.destroy();
|
||||||
|
t.ok(panel.div.innerHTML == "",
|
||||||
|
"Panel is not displayed after destroy without any active control");
|
||||||
|
map.destroy();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user