For controls with multiple handlers, we now tack them on to a handlers object. The base destroy takes care of the handlers. r=crschmidt,uz/2 (closes #1338)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6106 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-02-08 15:52:03 +00:00
parent 03a827de4d
commit 49e0bff93d
9 changed files with 132 additions and 147 deletions

View File

@@ -98,10 +98,10 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
mapOptions: null,
/**
* Property: dragHandler
* {<OpenLayers.Handler.Drag>} A handler for dragging the extent rectangle.
* Property: handlers
* {Object}
*/
dragHandler: null,
handlers: null,
/**
* Constructor: OpenLayers.Control.OverviewMap
@@ -114,6 +114,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
*/
initialize: function(options) {
this.layers = [];
this.handlers = {};
OpenLayers.Control.prototype.initialize.apply(this, [options]);
},
@@ -125,8 +126,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
if (!this.mapDiv) { // we've already been destroyed
return;
}
this.dragHandler.destroy();
this.clickHandler.destroy();
this.handlers.click.destroy();
this.mapDiv.removeChild(this.extentRectangle);
this.extentRectangle = null;
@@ -280,8 +280,8 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
* px - {<OpenLayers.Pixel>} The pixel location of the drag.
*/
rectDrag: function(px) {
var deltaX = this.dragHandler.last.x - px.x;
var deltaY = this.dragHandler.last.y - px.y;
var deltaX = this.handlers.drag.last.x - px.x;
var deltaY = this.handlers.drag.last.y - px.y;
if(deltaX != 0 || deltaY != 0) {
var rectTop = this.rectPxBounds.top;
var rectLeft = this.rectPxBounds.left;
@@ -456,11 +456,11 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
'border-bottom-width'));
this.hComp = (this.hComp) ? this.hComp : 2;
this.dragHandler = new OpenLayers.Handler.Drag(
this.handlers.drag = new OpenLayers.Handler.Drag(
this, {move: this.rectDrag, done: this.updateMapToRect},
{map: this.ovmap}
);
this.clickHandler = new OpenLayers.Handler.Click(
this.handlers.click = new OpenLayers.Handler.Click(
this, {
"click": this.mapDivClick
},{
@@ -470,18 +470,18 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
map: this.ovmap
}
);
this.clickHandler.activate();
this.handlers.click.activate();
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,
null, true);
this.rectEvents.register("mouseover", this, function(e) {
if(!this.dragHandler.active && !this.map.dragging) {
this.dragHandler.activate();
if(!this.handlers.drag.active && !this.map.dragging) {
this.handlers.drag.activate();
}
});
this.rectEvents.register("mouseout", this, function(e) {
if(!this.dragHandler.dragging) {
this.dragHandler.deactivate();
if(!this.handlers.drag.dragging) {
this.handlers.drag.deactivate();
}
});