deactivate on clear. r=bartvde (closes #2471)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10114 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2010-03-19 08:46:36 +00:00
parent fc4e05dd83
commit 1757d4082e
2 changed files with 30 additions and 2 deletions

View File

@@ -129,8 +129,6 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
"moveend": this.getState
}, this.registry);
this.clear();
var previousOptions = {
trigger: OpenLayers.Function.bind(this.previousTrigger, this),
displayClass: this.displayClass + " " + this.displayClass + "Previous"
@@ -145,6 +143,7 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Util.extend(nextOptions, this.nextOptions);
this.next = new OpenLayers.Control.Button(nextOptions);
this.clear();
},
/**
@@ -280,7 +279,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
*/
clear: function() {
this.previousStack = [];
this.previous.deactivate();
this.nextStack = [];
this.next.deactivate();
},
/**

View File

@@ -168,6 +168,33 @@
}
function test_clear(t) {
t.plan(7);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer(
"test", {isBaseLayer: true}
);
map.addLayer(layer);
map.zoomToMaxExtent();
var control = new OpenLayers.Control.NavigationHistory();
map.addControl(control);
t.ok(!control.previous.active, "previous control not active");
t.ok(!control.next.active, "next control not active");
map.zoomTo(4);
t.ok(control.previous.active, "previous control is active after a move");
t.ok(!control.next.active, "next control is not active after a move");
control.clear();
t.eq(control.previousStack.length + control.nextStack.length, 0, "stacks are empty after a clear");
t.ok(!control.previous.active, "previous control not active after a clear");
t.ok(!control.next.active, "next control not active after a clear");
control.destroy();
}
</script>
</head>
<body>