From 84e5c47caa74cd9e0d304ded97d879b5e7c2e00a Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 13 Apr 2012 09:58:59 +0200 Subject: [PATCH 01/13] Add tests for the ZoomToMaxExtent control. --- tests/Control/ZoomToMaxExtent.html | 85 ++++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 2 files changed, 86 insertions(+) create mode 100644 tests/Control/ZoomToMaxExtent.html diff --git a/tests/Control/ZoomToMaxExtent.html b/tests/Control/ZoomToMaxExtent.html new file mode 100644 index 0000000000..d22c24717b --- /dev/null +++ b/tests/Control/ZoomToMaxExtent.html @@ -0,0 +1,85 @@ + + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index 283bc69eb8..2ac92fd933 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/ZoomToMaxExtent.html
  • Events.html
  • Events/buttonclick.html
  • Extras.html
  • From 029bdaccde18d06b0d3a3c43fe589b2d03aa5963 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 13 Apr 2012 09:59:44 +0200 Subject: [PATCH 02/13] The ZoomToMaxExtent control should extend the OpenLayers.Control.Button and not OpenLayers.Control. --- lib/OpenLayers/Control/ZoomToMaxExtent.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Control/ZoomToMaxExtent.js b/lib/OpenLayers/Control/ZoomToMaxExtent.js index b172c28dc7..b8ac7a9b70 100644 --- a/lib/OpenLayers/Control/ZoomToMaxExtent.js +++ b/lib/OpenLayers/Control/ZoomToMaxExtent.js @@ -4,7 +4,7 @@ * full text of the license. */ /** - * @requires OpenLayers/Control.js + * @requires OpenLayers/Control/Button.js */ /** @@ -16,19 +16,14 @@ * Inherits from: * - */ -OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class(OpenLayers.Control, { +OpenLayers.Control.ZoomToMaxExtent = 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 - * Do the zoom. + * + * Called whenever this control is being rendered inside of a panel and a + * click occurs on this controls element. Actually zooms to the maximum + * extent of this controls map. */ trigger: function() { if (this.map) { From c40bdc90e9346f7559124ddc29773025dc7a51e5 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 08:11:08 +0200 Subject: [PATCH 03/13] Added tests for ZoomOut control. --- tests/Control/ZoomOut.html | 85 ++++++++++++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 2 files changed, 86 insertions(+) create mode 100644 tests/Control/ZoomOut.html diff --git a/tests/Control/ZoomOut.html b/tests/Control/ZoomOut.html new file mode 100644 index 0000000000..806f928730 --- /dev/null +++ b/tests/Control/ZoomOut.html @@ -0,0 +1,85 @@ + + + + + + + +
    + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 2ac92fd933..dbf23429c4 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/ZoomOut.html
  • Control/ZoomToMaxExtent.html
  • Events.html
  • Events/buttonclick.html
  • From 3dfa3fd15779ecaef93ba217771f644099e1db26 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 08:11:48 +0200 Subject: [PATCH 04/13] Changed ZoomOut control to inherit from OpenLayers.Control.Button. --- lib/OpenLayers/Control/ZoomOut.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Control/ZoomOut.js b/lib/OpenLayers/Control/ZoomOut.js index 2a538af9a3..6d6d818e2b 100644 --- a/lib/OpenLayers/Control/ZoomOut.js +++ b/lib/OpenLayers/Control/ZoomOut.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.ZoomOut = OpenLayers.Class(OpenLayers.Control, { +OpenLayers.Control.ZoomOut = 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.zoomOut(); + if (this.map) { + this.map.zoomOut(); + } }, CLASS_NAME: "OpenLayers.Control.ZoomOut" From a5c5fd8d3ec2257a26e7e06e17a1a8ff69abf0dd Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 08:20:09 +0200 Subject: [PATCH 05/13] Added tests for the 'type' property which is now inherited from the parent class. --- tests/Control/ZoomOut.html | 19 +++++++++++++++++-- tests/Control/ZoomToMaxExtent.html | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/Control/ZoomOut.html b/tests/Control/ZoomOut.html index 806f928730..5345c55d13 100644 --- a/tests/Control/ZoomOut.html +++ b/tests/Control/ZoomOut.html @@ -25,6 +25,23 @@ function test_ZoomOut_constructor (t) { control.destroy(); } +function test_ZoomOut_type(t){ + t.plan( 1 ); + + // setup + var control = new OpenLayers.Control.ZoomOut(); + + // check that the type of the control equals OpenLayers.Control.TYPE_BUTTON + 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 ); @@ -41,8 +58,6 @@ function test_ZoomOut_trigger (t) { }), oldZoom; - alert(map.getZoom()); - oldZoom = map.getZoom(); // tests diff --git a/tests/Control/ZoomToMaxExtent.html b/tests/Control/ZoomToMaxExtent.html index d22c24717b..674b9842a5 100644 --- a/tests/Control/ZoomToMaxExtent.html +++ b/tests/Control/ZoomToMaxExtent.html @@ -25,6 +25,23 @@ function test_ZoomToMaxExtent_constructor (t) { control.destroy(); } +function test_ZoomOut_type(t){ + t.plan( 1 ); + + // setup + var control = new OpenLayers.Control.ZoomToMaxExtent(); + + // check that the type of the control equals OpenLayers.Control.TYPE_BUTTON + 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 4af41b41f50e6af04f16b7aee6e51891ade2d421 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 17 Apr 2012 20:04:49 +0200 Subject: [PATCH 06/13] 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 07/13] 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 08/13] 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 09/13] 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 10/13] 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 11/13] 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 12/13] 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 13/13] 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 @@ + + + + + + + +
    + +