From 4af41b41f50e6af04f16b7aee6e51891ade2d421 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 20:04:49 +0200 Subject: [PATCH 1/8] Added tests for ZoomIn control. --- tests/Control/ZoomIn.html | 85 +++++++++++++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 2 files changed, 86 insertions(+) create mode 100644 tests/Control/ZoomIn.html diff --git a/tests/Control/ZoomIn.html b/tests/Control/ZoomIn.html new file mode 100644 index 0000000000..3e955426c4 --- /dev/null +++ b/tests/Control/ZoomIn.html @@ -0,0 +1,85 @@ + + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index dbf23429c4..eafd42abf0 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -49,6 +49,7 @@
  • Control/PanPanel.html
  • Control/SLDSelect.html
  • Control/Zoom.html
  • +
  • Control/ZoomIn.html
  • Control/ZoomOut.html
  • Control/ZoomToMaxExtent.html
  • Events.html
  • From 292da06150babdc1e9d6bb29b20d0b66edce8710 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 20:05:47 +0200 Subject: [PATCH 2/8] Changed ZoomIn control to inherit from OpenLayers.Control.Button. --- lib/OpenLayers/Control/ZoomIn.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Control/ZoomIn.js b/lib/OpenLayers/Control/ZoomIn.js index 776172d2d8..afab45004f 100644 --- a/lib/OpenLayers/Control/ZoomIn.js +++ b/lib/OpenLayers/Control/ZoomIn.js @@ -4,7 +4,7 @@ * full text of the license. */ /** - * @requires OpenLayers/Control.js + * @requires OpenLayers/Control/Button.js */ /** @@ -14,21 +14,15 @@ * Inherits from: * - */ -OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control, { +OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control.Button, { - /** - * Property: type - * {String} The type of -- When added to a - * , 'type' is used by the panel to determine how to - * handle our events. - */ - type: OpenLayers.Control.TYPE_BUTTON, - /** * Method: trigger */ trigger: function(){ - this.map.zoomIn(); + if (this.map) { + this.map.zoomIn(); + } }, CLASS_NAME: "OpenLayers.Control.ZoomIn" From d5bdadc18e06910bc592737bc155bda6772213fd Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 20:06:40 +0200 Subject: [PATCH 3/8] Removed erroneously commited alert-statements in tests. --- tests/Control/ZoomIn.html | 2 -- tests/Control/ZoomOut.html | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/Control/ZoomIn.html b/tests/Control/ZoomIn.html index 3e955426c4..b89165374b 100644 --- a/tests/Control/ZoomIn.html +++ b/tests/Control/ZoomIn.html @@ -41,8 +41,6 @@ function test_ZoomIn_trigger (t) { }), oldZoom; - alert(map.getZoom()); - oldZoom = map.getZoom(); // tests diff --git a/tests/Control/ZoomOut.html b/tests/Control/ZoomOut.html index 806f928730..38ef93de59 100644 --- a/tests/Control/ZoomOut.html +++ b/tests/Control/ZoomOut.html @@ -41,8 +41,6 @@ function test_ZoomOut_trigger (t) { }), oldZoom; - alert(map.getZoom()); - oldZoom = map.getZoom(); // tests From d08fb575b199f98259752b79dd9c80408f55623e Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 20:21:06 +0200 Subject: [PATCH 4/8] The changed controls should also check whether they have correctly inherited the property 'type' of the new parent class. --- tests/Control/ZoomIn.html | 18 ++++++++++++++++++ tests/Control/ZoomOut.html | 18 ++++++++++++++++++ tests/Control/ZoomToMaxExtent.html | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/tests/Control/ZoomIn.html b/tests/Control/ZoomIn.html index b89165374b..6279b1be59 100644 --- a/tests/Control/ZoomIn.html +++ b/tests/Control/ZoomIn.html @@ -25,6 +25,24 @@ function test_ZoomIn_constructor (t) { control.destroy(); } +function test_ZoomIn_type (t) { + t.plan( 1 ); + + // setup + var control = new OpenLayers.Control.ZoomIn(); + + // tests + // + t.eq( + control.type, + OpenLayers.Control.TYPE_BUTTON, + "ZoomIn control is of type OpenLayers.Control.TYPE_BUTTON" + ); + + // tear down + control.destroy(); +} + function test_ZoomIn_trigger (t) { t.plan( 2 ); diff --git a/tests/Control/ZoomOut.html b/tests/Control/ZoomOut.html index 38ef93de59..268e5c2f57 100644 --- a/tests/Control/ZoomOut.html +++ b/tests/Control/ZoomOut.html @@ -25,6 +25,24 @@ function test_ZoomOut_constructor (t) { control.destroy(); } +function test_ZoomOut_type (t) { + t.plan( 1 ); + + // setup + var control = new OpenLayers.Control.ZoomOut(); + + // tests + // + t.eq( + control.type, + OpenLayers.Control.TYPE_BUTTON, + "ZoomOut control is of type OpenLayers.Control.TYPE_BUTTON" + ); + + // tear down + control.destroy(); +} + function test_ZoomOut_trigger (t) { t.plan( 2 ); diff --git a/tests/Control/ZoomToMaxExtent.html b/tests/Control/ZoomToMaxExtent.html index d22c24717b..fb6d15e35b 100644 --- a/tests/Control/ZoomToMaxExtent.html +++ b/tests/Control/ZoomToMaxExtent.html @@ -25,6 +25,24 @@ function test_ZoomToMaxExtent_constructor (t) { control.destroy(); } +function test_ZoomToMaxExtent_type (t) { + t.plan( 1 ); + + // setup + var control = new OpenLayers.Control.ZoomToMaxExtent(); + + // tests + // + t.eq( + control.type, + OpenLayers.Control.TYPE_BUTTON, + "ZoomToMaxExtent control is of type 'OpenLayers.Control.TYPE_BUTTON'" + ); + + // tear down + control.destroy(); +} + function test_ZoomToMaxExtent_trigger (t) { t.plan( 2 ); From 53ed973eec575fe2fe8063d17e2855ef34793c83 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 21:24:54 +0200 Subject: [PATCH 5/8] Added tests for OpenLayers.Control.Pan. --- tests/Control/ZoomIn.html | 2 +- tests/list-tests.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Control/ZoomIn.html b/tests/Control/ZoomIn.html index 6279b1be59..844ded5bfc 100644 --- a/tests/Control/ZoomIn.html +++ b/tests/Control/ZoomIn.html @@ -14,7 +14,7 @@ function test_ZoomIn_constructor (t) { // t.ok( control instanceof OpenLayers.Control.ZoomIn, - "new OpenLayers.Control.ZoomOut returns object" + "new OpenLayers.Control.ZoomIn returns object" ); t.eq( control.displayClass, "olControlZoomIn", diff --git a/tests/list-tests.html b/tests/list-tests.html index eafd42abf0..c3deb1701a 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -46,6 +46,7 @@
  • Control/UTFGrid.html
  • Control/WMSGetFeatureInfo.html
  • Control/WMTSGetFeatureInfo.html
  • +
  • Control/Pan.html
  • Control/PanPanel.html
  • Control/SLDSelect.html
  • Control/Zoom.html
  • From 56d7cee8cfd6a13c55b94a217e7d6d38d5e68ab3 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 21:25:56 +0200 Subject: [PATCH 6/8] Protect the trigger action of pan control by checking whether we were added to a map prior to calling this.map.pan(). --- lib/OpenLayers/Control/Pan.js | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/OpenLayers/Control/Pan.js b/lib/OpenLayers/Control/Pan.js index 2850aa83bb..2c85caa10f 100644 --- a/lib/OpenLayers/Control/Pan.js +++ b/lib/OpenLayers/Control/Pan.js @@ -70,26 +70,27 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, { * Method: trigger */ trigger: function(){ + if (this.map) { + var getSlideFactor = OpenLayers.Function.bind(function (dim) { + return this.slideRatio ? + this.map.getSize()[dim] * this.slideRatio : + this.slideFactor; + }, this); - var getSlideFactor = OpenLayers.Function.bind(function (dim) { - return this.slideRatio ? - this.map.getSize()[dim] * this.slideRatio : - this.slideFactor; - }, this); - - switch (this.direction) { - case OpenLayers.Control.Pan.NORTH: - this.map.pan(0, -getSlideFactor("h")); - break; - case OpenLayers.Control.Pan.SOUTH: - this.map.pan(0, getSlideFactor("h")); - break; - case OpenLayers.Control.Pan.WEST: - this.map.pan(-getSlideFactor("w"), 0); - break; - case OpenLayers.Control.Pan.EAST: - this.map.pan(getSlideFactor("w"), 0); - break; + switch (this.direction) { + case OpenLayers.Control.Pan.NORTH: + this.map.pan(0, -getSlideFactor("h")); + break; + case OpenLayers.Control.Pan.SOUTH: + this.map.pan(0, getSlideFactor("h")); + break; + case OpenLayers.Control.Pan.WEST: + this.map.pan(-getSlideFactor("w"), 0); + break; + case OpenLayers.Control.Pan.EAST: + this.map.pan(getSlideFactor("w"), 0); + break; + } } }, From d86c1b6c9ce591dafeea8c09510e327f630a6e37 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 21:29:32 +0200 Subject: [PATCH 7/8] Changed Pan control to inherit from OpenLayers.Control.Button. --- lib/OpenLayers/Control/Pan.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers/Control/Pan.js b/lib/OpenLayers/Control/Pan.js index 2c85caa10f..4dfaefea79 100644 --- a/lib/OpenLayers/Control/Pan.js +++ b/lib/OpenLayers/Control/Pan.js @@ -4,7 +4,7 @@ * full text of the license. */ /** - * @requires OpenLayers/Control.js + * @requires OpenLayers/Control/Button.js */ /** @@ -15,7 +15,7 @@ * Inherits from: * - */ -OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, { +OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control.Button, { /** * APIProperty: slideFactor @@ -40,14 +40,6 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, { */ direction: null, - /** - * Property: type - * {String} The type of -- When added to a - * , 'type' is used by the panel to determine how to - * handle our events. - */ - type: OpenLayers.Control.TYPE_BUTTON, - /** * Constructor: OpenLayers.Control.Pan * Control which handles the panning (in any of the cardinal directions) From 4cd34bc851da54068d8ef1ee2b1f7080bbcf8110 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 21:31:12 +0200 Subject: [PATCH 8/8] Added tests for OpenLayers.Control.Pan. --- tests/Control/Pan.html | 201 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 tests/Control/Pan.html diff --git a/tests/Control/Pan.html b/tests/Control/Pan.html new file mode 100644 index 0000000000..0c9dfafa44 --- /dev/null +++ b/tests/Control/Pan.html @@ -0,0 +1,201 @@ + + + + + + + +
    + +