From ece872b81a177475642a04059a748397cbfe3757 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Mon, 5 Mar 2012 22:23:57 +0100 Subject: [PATCH 01/10] Remove our aliasing of OpenLayers.Util.getElement to window.$. --- lib/OpenLayers/Util.js | 7 ------- tests/Util.html | 5 ----- 2 files changed, 12 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 880e3435ab..9dff44d19f 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -74,13 +74,6 @@ OpenLayers.Util.isArray = function(a) { return (Object.prototype.toString.call(a) === '[object Array]'); }; -/** - * Maintain existing definition of $. - */ -if(typeof window.$ === "undefined") { - window.$ = OpenLayers.Util.getElement; -} - /** * Function: removeItem * Remove an object from an array. Iterates through the array diff --git a/tests/Util.html b/tests/Util.html index 2357b54e2c..73ea006625 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -77,11 +77,6 @@ t.eq(OpenLayers.Util.isArray(testArray), true, "isArray works"); } - function test_$(t) { - t.plan(1); - t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $."); - } - function test_Util_getImagesLocation (t) { t.plan( 1 ); t.ok( OpenLayers.Util.getImagesLocation(), "../img/", From de2eeaab0b39ef761ab5857b90b08dd7e4ce2531 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Mon, 5 Mar 2012 22:26:11 +0100 Subject: [PATCH 02/10] Fix up a test that used our $(). --- tests/Map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Map.html b/tests/Map.html index ee8b8e7fb2..1daa43a46e 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -748,7 +748,7 @@ function test_Map_double_addLayer(t) { t.plan(2); - map = new OpenLayers.Map($('map')); + map = new OpenLayers.Map('map'); layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'} From 5c2c39c9dd6c53f856d6453842da9fb2f70d62fd Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Mon, 5 Mar 2012 22:27:43 +0100 Subject: [PATCH 03/10] Fix the examples that used our '$' method. --- examples/editing-methods.js | 2 ++ examples/game-accel-ball.html | 1 + examples/geolocation.js | 2 +- examples/getfeatureinfo-control.html | 2 +- examples/select-feature.html | 3 +++ examples/snap-split.html | 2 ++ examples/snapping.html | 2 ++ examples/strategy-cluster-extended.js | 2 ++ examples/strategy-cluster-threshold.html | 1 + examples/strategy-cluster.html | 2 ++ examples/tilecache.html | 2 +- examples/using-proj4js.js | 2 ++ 12 files changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/editing-methods.js b/examples/editing-methods.js index 6c139a276d..9ed961eaf9 100644 --- a/examples/editing-methods.js +++ b/examples/editing-methods.js @@ -19,6 +19,8 @@ var draw = new OpenLayers.Control.DrawFeature( map.addControl(draw); draw.activate(); +$ = OpenLayers.Util.getElement; + // handle clicks on method links $("insertXY").onclick = function() { var values = parseInput( diff --git a/examples/game-accel-ball.html b/examples/game-accel-ball.html index 40bb02d791..a622768bd2 100644 --- a/examples/game-accel-ball.html +++ b/examples/game-accel-ball.html @@ -33,6 +33,7 @@ vlayer.drawFeature(feature); } function init() { + var $ = OpenLayers.Util.getElement; map = new OpenLayers.Map( 'map', { 'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight), diff --git a/examples/geolocation.js b/examples/geolocation.js index 1afc12d997..acde5faae5 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -92,7 +92,7 @@ geolocate.events.register("locationupdated",geolocate,function(e) { geolocate.events.register("locationfailed",this,function() { OpenLayers.Console.log('Location detection failed'); }); - +var $ = OpenLayers.Util.getElement; $('locate').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); diff --git a/examples/getfeatureinfo-control.html b/examples/getfeatureinfo-control.html index cb0bec10e4..2dcdf3c58d 100644 --- a/examples/getfeatureinfo-control.html +++ b/examples/getfeatureinfo-control.html @@ -48,7 +48,7 @@ + + + + + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index 283bc69eb8..14ccf78ed0 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -231,6 +231,7 @@
  • Kinetic.html
  • Util.html
  • deprecated/Ajax.html
  • +
  • deprecated/Util.html
  • deprecated/BaseTypes/Class.html
  • deprecated/BaseTypes/Element.html
  • deprecated/Control/MouseToolbar.html
  • From 9bbc1d43180d0cd94d1e2daeb8b386f7b3486b2e Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 25 Apr 2012 09:31:22 +0200 Subject: [PATCH 08/10] Update notes for 2.13 about deprecation of window.$ --- notes/2.13.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/notes/2.13.md b/notes/2.13.md index c8d0938d6c..e5a429912b 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -7,3 +7,21 @@ Previously, objects generated by the library were given id properties with value Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/416 + +# Behavior Changes from Past Releases + +## window.$ is no longer an alias for OpenLayers.Util.getElement + +We do no longer create a global variable '$' when such a symbol isn't already +defined. Previous versions of OpenLayers would define '$' to be an alias for +OpenLayers.Util.getElement. If you application requires window.$ to be defined +in such a way you can either + +* include deprecated.js in your custom build or as additional ressource in your + HTML-file +* or you do the aliasing in your application code yourself: + window.$ = OpenLayers.Util.getElement; + +Corresponding issue/pull requests: + +* https://github.com/openlayers/openlayers/pull/423 \ No newline at end of file From 042ad8d7115687cc286b90985f55785d39b0072b Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 25 Apr 2012 09:37:37 +0200 Subject: [PATCH 09/10] Minors in the notes file. --- notes/2.13.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notes/2.13.md b/notes/2.13.md index e5a429912b..12fabec635 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -14,12 +14,13 @@ Corresponding issues/pull requests: We do no longer create a global variable '$' when such a symbol isn't already defined. Previous versions of OpenLayers would define '$' to be an alias for -OpenLayers.Util.getElement. If you application requires window.$ to be defined +OpenLayers.Util.getElement. If your application requires window.$ to be defined in such a way you can either * include deprecated.js in your custom build or as additional ressource in your HTML-file * or you do the aliasing in your application code yourself: + window.$ = OpenLayers.Util.getElement; Corresponding issue/pull requests: From acb9f950df0b8bfa54552de7c46d8f3b887fff39 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 29 May 2012 21:47:22 +0200 Subject: [PATCH 10/10] Use document.getElementById in examples. Previously examples would either use the now deprecated `window.$` or the non-API-method `OpenLayers.Util.getElement`. This was well caught by @probins and @elemoine. --- examples/editing-methods.js | 14 ++++++-------- examples/game-accel-ball.html | 3 +-- examples/geolocation.js | 9 ++++----- examples/getfeatureinfo-control.html | 3 +-- examples/select-feature.html | 6 ++---- examples/snap-split.html | 23 ++++++++++------------- examples/snapping.html | 10 ++++------ examples/strategy-cluster-extended.js | 6 ++---- examples/strategy-cluster-threshold.html | 14 ++++++-------- examples/strategy-cluster.html | 17 ++++++++--------- examples/using-proj4js.js | 15 +++++++-------- 11 files changed, 51 insertions(+), 69 deletions(-) diff --git a/examples/editing-methods.js b/examples/editing-methods.js index 1c227c4b11..03d5e82311 100644 --- a/examples/editing-methods.js +++ b/examples/editing-methods.js @@ -19,10 +19,8 @@ var draw = new OpenLayers.Control.DrawFeature( map.addControl(draw); draw.activate(); -var $ = OpenLayers.Util.getElement; - // handle clicks on method links -$("insertXY").onclick = function() { +document.getElementById("insertXY").onclick = function() { var values = parseInput( window.prompt( "Enter map coordinates for new point (e.g. '-111, 46')", "x, y" @@ -32,7 +30,7 @@ $("insertXY").onclick = function() { draw.insertXY(values[0], values[1]); } }; -$("insertDeltaXY").onclick = function() { +document.getElementById("insertDeltaXY").onclick = function() { var values = parseInput( window.prompt( "Enter offset values for new point (e.g. '15, -10')", "dx, dy" @@ -42,7 +40,7 @@ $("insertDeltaXY").onclick = function() { draw.insertDeltaXY(values[0], values[1]); } }; -$("insertDirectionLength").onclick = function() { +document.getElementById("insertDirectionLength").onclick = function() { var values = parseInput( window.prompt( "Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length" @@ -52,7 +50,7 @@ $("insertDirectionLength").onclick = function() { draw.insertDirectionLength(values[0], values[1]); } }; -$("insertDeflectionLength").onclick = function() { +document.getElementById("insertDeflectionLength").onclick = function() { var values = parseInput( window.prompt( "Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length" @@ -62,10 +60,10 @@ $("insertDeflectionLength").onclick = function() { draw.insertDeflectionLength(values[0], values[1]); } }; -$("cancel").onclick = function() { +document.getElementById("cancel").onclick = function() { draw.cancel(); }; -$("finishSketch").onclick = function() { +document.getElementById("finishSketch").onclick = function() { draw.finishSketch(); }; diff --git a/examples/game-accel-ball.html b/examples/game-accel-ball.html index a622768bd2..c832e86721 100644 --- a/examples/game-accel-ball.html +++ b/examples/game-accel-ball.html @@ -33,10 +33,9 @@ vlayer.drawFeature(feature); } function init() { - var $ = OpenLayers.Util.getElement; map = new OpenLayers.Map( 'map', { - 'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight), + 'maxExtent': new OpenLayers.Bounds(0, 0, document.getElementById("map").clientWidth, document.getElementById("map").clientHeight), controls: [], maxResolution: 'auto'} ); diff --git a/examples/geolocation.js b/examples/geolocation.js index acde5faae5..3d8d6f4b55 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -92,16 +92,15 @@ geolocate.events.register("locationupdated",geolocate,function(e) { geolocate.events.register("locationfailed",this,function() { OpenLayers.Console.log('Location detection failed'); }); -var $ = OpenLayers.Util.getElement; -$('locate').onclick = function() { +document.getElementById('locate').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); - $('track').checked = false; + document.getElementById('track').checked = false; geolocate.watch = false; firstGeolocation = true; geolocate.activate(); }; -$('track').onclick = function() { +document.getElementById('track').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); if (this.checked) { @@ -110,4 +109,4 @@ $('track').onclick = function() { geolocate.activate(); } }; -$('track').checked = false; +document.getElementById('track').checked = false; diff --git a/examples/getfeatureinfo-control.html b/examples/getfeatureinfo-control.html index 2dcdf3c58d..baecd420fb 100644 --- a/examples/getfeatureinfo-control.html +++ b/examples/getfeatureinfo-control.html @@ -48,7 +48,6 @@