From 1757d4082eb75c37914ad951c4d0caadd268f911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Junod?= Date: Fri, 19 Mar 2010 08:46:36 +0000 Subject: [PATCH] deactivate on clear. r=bartvde (closes #2471) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10114 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/NavigationHistory.js | 5 ++-- tests/Control/NavigationHistory.html | 27 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/NavigationHistory.js b/lib/OpenLayers/Control/NavigationHistory.js index a70df16747..a33c308183 100644 --- a/lib/OpenLayers/Control/NavigationHistory.js +++ b/lib/OpenLayers/Control/NavigationHistory.js @@ -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(); }, /** diff --git a/tests/Control/NavigationHistory.html b/tests/Control/NavigationHistory.html index b09ab4f43b..29ed3d1d62 100644 --- a/tests/Control/NavigationHistory.html +++ b/tests/Control/NavigationHistory.html @@ -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(); + } +