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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user