Giving all controls an events instance. You can now listen for activate and deactivate on any control. Panel controls do this to know when they should redraw. Navigation history control demonstrates the effect of this change. r=elemoine (closes #1346)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6167 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-02-09 16:46:02 +00:00
parent 9bfd829512
commit bf224d699d
5 changed files with 61 additions and 40 deletions

View File

@@ -45,6 +45,11 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
destroy: function() {
OpenLayers.Control.prototype.destroy.apply(this, arguments);
for(var i = this.controls.length - 1 ; i >= 0; i--) {
this.controls[i].events.un({
"activate": this.redraw,
"deactivate": this.redraw,
scope: this
});
OpenLayers.Event.stopObservingElement(this.controls[i].panel_div);
this.controls[i].panel_div = null;
}
@@ -75,7 +80,6 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
for(var i = 0; i < this.controls.length; i++) {
this.controls[i].deactivate();
}
this.redraw();
return true;
} else {
return false;
@@ -93,6 +97,11 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
for (var i = 0; i < this.controls.length; i++) {
this.map.addControl(this.controls[i]);
this.controls[i].deactivate();
this.controls[i].events.on({
"activate": this.redraw,
"deactivate": this.redraw,
scope: this
});
}
this.activate();
return this.div;
@@ -145,7 +154,6 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
}
}
}
this.redraw();
},
/**
@@ -185,6 +193,11 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
for (var i = 0; i < controls.length; i++) {
this.map.addControl(controls[i]);
controls[i].deactivate();
controls[i].events.on({
"activate": this.redraw,
"deactivate": this.redraw,
scope: this
});
}
this.redraw();
}