From 368ad02bdba40fbb1e1d58ff2c3a30d66296192e Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 16:11:43 -0700 Subject: [PATCH 01/14] Deprecated methods from Ajax.js. --- lib/OpenLayers/Request.js | 6 ++++ lib/{OpenLayers/Ajax.js => deprecated.js} | 37 ----------------------- 2 files changed, 6 insertions(+), 37 deletions(-) rename lib/{OpenLayers/Ajax.js => deprecated.js} (94%) diff --git a/lib/OpenLayers/Request.js b/lib/OpenLayers/Request.js index 3a5865bc0a..c1598143ad 100644 --- a/lib/OpenLayers/Request.js +++ b/lib/OpenLayers/Request.js @@ -7,6 +7,12 @@ * @requires OpenLayers/Events.js */ +/** + * TODO: deprecate me + * Use OpenLayers.Request.proxy instead. + */ +OpenLayers.ProxyHost = ""; + /** * Namespace: OpenLayers.Request * The OpenLayers.Request namespace contains convenience methods for working diff --git a/lib/OpenLayers/Ajax.js b/lib/deprecated.js similarity index 94% rename from lib/OpenLayers/Ajax.js rename to lib/deprecated.js index 92235025ae..af9792dcd5 100644 --- a/lib/OpenLayers/Ajax.js +++ b/lib/deprecated.js @@ -1,40 +1,3 @@ -/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for - * full list of contributors). Published under the Clear BSD license. - * See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. */ - -/** - * @requires OpenLayers/Request/XMLHttpRequest.js - * @requires OpenLayers/Console.js - * @requires OpenLayers/Lang.js - */ - -OpenLayers.ProxyHost = ""; -//OpenLayers.ProxyHost = "examples/proxy.cgi?url="; - -/** - * Ajax reader for OpenLayers - * - * @uri url to do remote XML http get - * @param {String} 'get' format params (x=y&a=b...) - * @who object to handle callbacks for this request - * @complete the function to be called on success - * @failure the function to be called on failure - * - * example usage from a caller: - * - * caps: function(request) { - * -blah- - * }, - * - * OpenLayers.loadURL(url,params,this,caps); - * - * Notice the above example does not provide an error handler; a default empty - * handler is provided which merely logs the error if a failure handler is not - * supplied - * - */ - /** * Function: OpenLayers.nullHandler From 95e7de2ab4774e682070a5e46c23a19c3933c732 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 16:17:52 -0700 Subject: [PATCH 02/14] Deprecated tests for Ajax.js. --- tests/{ => deprecated}/Ajax.html | 3 ++- tests/list-tests.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename tests/{ => deprecated}/Ajax.html (90%) diff --git a/tests/Ajax.html b/tests/deprecated/Ajax.html similarity index 90% rename from tests/Ajax.html rename to tests/deprecated/Ajax.html index 53142a2dcb..e73e80c625 100644 --- a/tests/Ajax.html +++ b/tests/deprecated/Ajax.html @@ -1,6 +1,7 @@ - + + + + + + + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 113e4feeb9..673a70a012 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -229,4 +229,5 @@
  • Kinetic.html
  • Util.html
  • deprecated/Ajax.html
  • +
  • deprecated/BaseTypes/Class.html
  • From 5db084afe89bc6d8bc122a3e7703b41907dcb814 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 16:37:01 -0700 Subject: [PATCH 04/14] Pull Ajax.js from the loader. --- lib/OpenLayers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 22fb1b8500..ea8db02c37 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -109,7 +109,6 @@ "OpenLayers/Kinetic.js", "Rico/Corner.js", "Rico/Color.js", - "OpenLayers/Ajax.js", "OpenLayers/Events.js", "OpenLayers/Request.js", "OpenLayers/Request/XMLHttpRequest.js", From dd5d7c9f077fe95a28c3205e58ae3c86e89cf063 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 16:37:31 -0700 Subject: [PATCH 05/14] Remove deprecated methods from Element.js. --- lib/OpenLayers/BaseTypes/Element.js | 75 ---------------------- lib/deprecated.js | 85 +++++++++++++++++++++++++ tests/BaseTypes/Element.html | 42 ------------ tests/deprecated/BaseTypes/Element.html | 56 ++++++++++++++++ tests/list-tests.html | 2 + 5 files changed, 143 insertions(+), 117 deletions(-) create mode 100644 tests/deprecated/BaseTypes/Element.html diff --git a/lib/OpenLayers/BaseTypes/Element.js b/lib/OpenLayers/BaseTypes/Element.js index 329a19bc87..55618a10fb 100644 --- a/lib/OpenLayers/BaseTypes/Element.js +++ b/lib/OpenLayers/BaseTypes/Element.js @@ -42,47 +42,6 @@ OpenLayers.Element = { } }, - - /** - * APIFunction: hide - * *Deprecated*. Hide element(s) passed in - * - * Parameters: - * element - {DOMElement} Actually user can pass any number of elements - */ - hide: function() { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", { - newMethod: "element.style.display = 'none';" - })); - - for (var i=0, len=arguments.length; i + + + + + + + +
    test
    + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index 673a70a012..323a5dc62d 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -230,4 +230,6 @@
  • Util.html
  • deprecated/Ajax.html
  • deprecated/BaseTypes/Class.html
  • +
  • deprecated/BaseTypes/Class.html
  • +
  • deprecated/BaseTypes/Element.html
  • From 20e19203d54306196c11357283d35ca121c479d8 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 16:48:58 -0700 Subject: [PATCH 06/14] Deprecated methods from BaseTypes.js. --- lib/OpenLayers/BaseTypes.js | 130 -------------------------- lib/deprecated.js | 181 +++++++++++++++++++++++++++++++++++- 2 files changed, 180 insertions(+), 131 deletions(-) diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index f1fdd2e630..88d645a4e9 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -198,75 +198,6 @@ OpenLayers.String = { }; -if (!String.prototype.startsWith) { - /** - * APIMethod: String.startsWith - * *Deprecated*. Whether or not a string starts with another string. - * - * Parameters: - * sStart - {String} The string we're testing for. - * - * Returns: - * {Boolean} Whether or not this string starts with the string passed in. - */ - String.prototype.startsWith = function(sStart) { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.String.startsWith'})); - return OpenLayers.String.startsWith(this, sStart); - }; -} - -if (!String.prototype.contains) { - /** - * APIMethod: String.contains - * *Deprecated*. Whether or not a string contains another string. - * - * Parameters: - * str - {String} The string that we're testing for. - * - * Returns: - * {Boolean} Whether or not this string contains with the string passed in. - */ - String.prototype.contains = function(str) { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.String.contains'})); - return OpenLayers.String.contains(this, str); - }; -} - -if (!String.prototype.trim) { - /** - * APIMethod: String.trim - * *Deprecated*. Removes leading and trailing whitespace characters from a string. - * - * Returns: - * {String} A trimmed version of the string - all leading and - * trailing spaces removed - */ - String.prototype.trim = function() { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.String.trim'})); - return OpenLayers.String.trim(this); - }; -} - -if (!String.prototype.camelize) { - /** - * APIMethod: String.camelize - * *Deprecated*. Camel-case a hyphenated string. - * Ex. "chicken-head" becomes "chickenHead", and - * "-chicken-head" becomes "ChickenHead". - * - * Returns: - * {String} The string, camelized - */ - String.prototype.camelize = function() { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.String.camelize'})); - return OpenLayers.String.camelize(this); - }; -} - /** * Namespace: OpenLayers.Number * Contains convenience functions for manipulating numbers. @@ -360,26 +291,6 @@ OpenLayers.Number = { } }; -if (!Number.prototype.limitSigDigs) { - /** - * APIMethod: Number.limitSigDigs - * *Deprecated*. Limit the number of significant digits on an integer. Does *not* - * work with floats! - * - * Parameters: - * sig - {Integer} - * - * Returns: - * {Integer} The number, rounded to the specified number of significant digits. - * If null, 0, or negative value passed in, returns 0 - */ - Number.prototype.limitSigDigs = function(sig) { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.Number.limitSigDigs'})); - return OpenLayers.Number.limitSigDigs(this, sig); - }; -} - /** * Namespace: OpenLayers.Function * Contains convenience functions for function manipulation. @@ -471,47 +382,6 @@ OpenLayers.Function = { }; -if (!Function.prototype.bind) { - /** - * APIMethod: Function.bind - * *Deprecated*. Bind a function to an object. - * Method to easily create closures with 'this' altered. - * - * Parameters: - * object - {Object} the this parameter - * - * Returns: - * {Function} A closure with 'this' altered to the first - * argument. - */ - Function.prototype.bind = function() { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.Function.bind'})); - // new function takes the same arguments with this function up front - Array.prototype.unshift.apply(arguments, [this]); - return OpenLayers.Function.bind.apply(null, arguments); - }; -} - -if (!Function.prototype.bindAsEventListener) { - /** - * APIMethod: Function.bindAsEventListener - * *Deprecated*. Bind a function to an object, and configure it to receive the - * event object as first parameter when called. - * - * Parameters: - * object - {Object} A reference to this. - * - * Returns: - * {Function} - */ - Function.prototype.bindAsEventListener = function(object) { - OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", - {'newMethod':'OpenLayers.Function.bindAsEventListener'})); - return OpenLayers.Function.bindAsEventListener(this, object); - }; -} - /** * Namespace: OpenLayers.Array * Contains convenience functions for array manipulation. diff --git a/lib/deprecated.js b/lib/deprecated.js index e88ab1a01b..06d9dde349 100644 --- a/lib/deprecated.js +++ b/lib/deprecated.js @@ -765,4 +765,183 @@ OpenLayers.Util.extend(OpenLayers.Element, { return {width: originalWidth, height: originalHeight}; } -}); \ No newline at end of file +}); + +if (!String.prototype.startsWith) { + /** + * APIMethod: String.startsWith + * *Deprecated*. Whether or not a string starts with another string. + * + * Parameters: + * sStart - {String} The string we're testing for. + * + * Returns: + * {Boolean} Whether or not this string starts with the string passed in. + */ + String.prototype.startsWith = function(sStart) { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.startsWith'})); + return OpenLayers.String.startsWith(this, sStart); + }; +} + +if (!String.prototype.contains) { + /** + * APIMethod: String.contains + * *Deprecated*. Whether or not a string contains another string. + * + * Parameters: + * str - {String} The string that we're testing for. + * + * Returns: + * {Boolean} Whether or not this string contains with the string passed in. + */ + String.prototype.contains = function(str) { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.contains'})); + return OpenLayers.String.contains(this, str); + }; +} + +if (!String.prototype.trim) { + /** + * APIMethod: String.trim + * *Deprecated*. Removes leading and trailing whitespace characters from a string. + * + * Returns: + * {String} A trimmed version of the string - all leading and + * trailing spaces removed + */ + String.prototype.trim = function() { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.trim'})); + return OpenLayers.String.trim(this); + }; +} + +if (!String.prototype.camelize) { + /** + * APIMethod: String.camelize + * *Deprecated*. Camel-case a hyphenated string. + * Ex. "chicken-head" becomes "chickenHead", and + * "-chicken-head" becomes "ChickenHead". + * + * Returns: + * {String} The string, camelized + */ + String.prototype.camelize = function() { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.camelize'})); + return OpenLayers.String.camelize(this); + }; +} + +if (!String.prototype.startsWith) { + /** + * APIMethod: String.startsWith + * *Deprecated*. Whether or not a string starts with another string. + * + * Parameters: + * sStart - {String} The string we're testing for. + * + * Returns: + * {Boolean} Whether or not this string starts with the string passed in. + */ + String.prototype.startsWith = function(sStart) { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.startsWith'})); + return OpenLayers.String.startsWith(this, sStart); + }; +} + +if (!String.prototype.contains) { + /** + * APIMethod: String.contains + * *Deprecated*. Whether or not a string contains another string. + * + * Parameters: + * str - {String} The string that we're testing for. + * + * Returns: + * {Boolean} Whether or not this string contains with the string passed in. + */ + String.prototype.contains = function(str) { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.contains'})); + return OpenLayers.String.contains(this, str); + }; +} + +if (!String.prototype.trim) { + /** + * APIMethod: String.trim + * *Deprecated*. Removes leading and trailing whitespace characters from a string. + * + * Returns: + * {String} A trimmed version of the string - all leading and + * trailing spaces removed + */ + String.prototype.trim = function() { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.trim'})); + return OpenLayers.String.trim(this); + }; +} + +if (!String.prototype.camelize) { + /** + * APIMethod: String.camelize + * *Deprecated*. Camel-case a hyphenated string. + * Ex. "chicken-head" becomes "chickenHead", and + * "-chicken-head" becomes "ChickenHead". + * + * Returns: + * {String} The string, camelized + */ + String.prototype.camelize = function() { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.String.camelize'})); + return OpenLayers.String.camelize(this); + }; +} + +if (!Function.prototype.bind) { + /** + * APIMethod: Function.bind + * *Deprecated*. Bind a function to an object. + * Method to easily create closures with 'this' altered. + * + * Parameters: + * object - {Object} the this parameter + * + * Returns: + * {Function} A closure with 'this' altered to the first + * argument. + */ + Function.prototype.bind = function() { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.Function.bind'})); + // new function takes the same arguments with this function up front + Array.prototype.unshift.apply(arguments, [this]); + return OpenLayers.Function.bind.apply(null, arguments); + }; +} + +if (!Function.prototype.bindAsEventListener) { + /** + * APIMethod: Function.bindAsEventListener + * *Deprecated*. Bind a function to an object, and configure it to receive the + * event object as first parameter when called. + * + * Parameters: + * object - {Object} A reference to this. + * + * Returns: + * {Function} + */ + Function.prototype.bindAsEventListener = function(object) { + OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", + {'newMethod':'OpenLayers.Function.bindAsEventListener'})); + return OpenLayers.Function.bindAsEventListener(this, object); + }; +} From f90d34fad9e0323f724ea42e86ab3fec1aaea790 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 17:10:31 -0700 Subject: [PATCH 07/14] Exclude deprecated methods from full build. --- build/full.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/build/full.cfg b/build/full.cfg index 5ed2b7b71c..91c817a89f 100644 --- a/build/full.cfg +++ b/build/full.cfg @@ -11,3 +11,4 @@ Firebug OpenLayers.js OpenLayers/Lang +deprecated.js From b7c826e796df27282ddb39a1ed4da0406f9f0b2c Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 8 Nov 2011 18:32:55 -0700 Subject: [PATCH 08/14] Remove MouseDefaults and MouseToolbar. --- examples/panel.html | 10 - examples/zoomify.html | 6 - lib/OpenLayers.js | 2 - lib/OpenLayers/Control.js | 1 - lib/OpenLayers/Control/MouseDefaults.js | 368 --------- lib/OpenLayers/Control/MouseToolbar.js | 406 ---------- lib/deprecated.js | 757 ++++++++++++++++++ .../Control/MouseToolbar.html | 3 +- tests/list-tests.html | 1 + 9 files changed, 760 insertions(+), 794 deletions(-) delete mode 100644 lib/OpenLayers/Control/MouseDefaults.js delete mode 100644 lib/OpenLayers/Control/MouseToolbar.js rename tests/{ => deprecated}/Control/MouseToolbar.html (96%) diff --git a/examples/panel.html b/examples/panel.html index 685bdacf37..be9785c192 100644 --- a/examples/panel.html +++ b/examples/panel.html @@ -16,14 +16,6 @@ background-color:white; } - .olControlPanel .olControlMouseDefaultsItemActive { - background-color: blue; - background-image: url("../theme/default/img/pan_on.png"); - } - .olControlPanel .olControlMouseDefaultsItemInactive { - background-color: orange; - background-image: url("../theme/default/img/pan_off.png"); - } .olControlPanel .olControlDrawFeatureItemActive { width: 22px; height: 22px; @@ -75,8 +67,6 @@ {title:"Zoom box: Selecting it you can zoom on an area by clicking and dragging."}); var panel = new OpenLayers.Control.Panel({defaultControl: zb}); panel.addControls([ - new OpenLayers.Control.MouseDefaults( - {title:'You can use the default mouse configuration'}), zb, new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path, {title:'Draw a feature'}), diff --git a/examples/zoomify.html b/examples/zoomify.html index 3bec55bb9f..6b610aad83 100644 --- a/examples/zoomify.html +++ b/examples/zoomify.html @@ -23,7 +23,6 @@ /* Map with raster coordinates (pixels) from Zoomify image */ var options = { - controls: [], maxExtent: new OpenLayers.Bounds(0, 0, zoomify_width, zoomify_height), maxResolution: Math.pow(2, zoomify.numberOfTiers-1 ), numZoomLevels: zoomify.numberOfTiers, @@ -33,11 +32,6 @@ map = new OpenLayers.Map("map", options); map.addLayer(zoomify); - map.addControl(new OpenLayers.Control.MousePosition()); - map.addControl(new OpenLayers.Control.PanZoomBar()); - map.addControl(new OpenLayers.Control.MouseDefaults()); - map.addControl(new OpenLayers.Control.KeyboardDefaults()); - map.setBaseLayer(zoomify); map.zoomToMaxExtent(); }; diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index ea8db02c37..e0c7ea19c1 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -185,7 +185,6 @@ "OpenLayers/Control/Navigation.js", "OpenLayers/Control/PinchZoom.js", "OpenLayers/Control/TouchNavigation.js", - "OpenLayers/Control/MouseDefaults.js", "OpenLayers/Control/MousePosition.js", "OpenLayers/Control/OverviewMap.js", "OpenLayers/Control/KeyboardDefaults.js", @@ -343,7 +342,6 @@ "OpenLayers/Format/OGCExceptionReport.js", "OpenLayers/Layer/WFS.js", "OpenLayers/Control/GetFeature.js", - "OpenLayers/Control/MouseToolbar.js", "OpenLayers/Control/NavToolbar.js", "OpenLayers/Control/PanPanel.js", "OpenLayers/Control/Pan.js", diff --git a/lib/OpenLayers/Control.js b/lib/OpenLayers/Control.js index 2b127b991d..0ca4627c29 100644 --- a/lib/OpenLayers/Control.js +++ b/lib/OpenLayers/Control.js @@ -22,7 +22,6 @@ * > var map = new OpenLayers.Map('map', { controls: [] }); * > * > map.addControl(new OpenLayers.Control.PanZoomBar()); - * > map.addControl(new OpenLayers.Control.MouseToolbar()); * > map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false})); * > map.addControl(new OpenLayers.Control.Permalink()); * > map.addControl(new OpenLayers.Control.Permalink('permalink')); diff --git a/lib/OpenLayers/Control/MouseDefaults.js b/lib/OpenLayers/Control/MouseDefaults.js deleted file mode 100644 index cc71164b4a..0000000000 --- a/lib/OpenLayers/Control/MouseDefaults.js +++ /dev/null @@ -1,368 +0,0 @@ -/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for - * full list of contributors). Published under the Clear BSD license. - * See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. */ - -/** - * @requires OpenLayers/Control.js - */ - -/** - * Class: OpenLayers.Control.MouseDefaults - * This class is DEPRECATED in 2.4 and will be removed by 3.0. - * If you need this functionality, use - * instead!!! - * - * This class is DEPRECATED in 2.4 and will be removed by 3.0. - * If you need this functionality, use Control.Navigation instead!!! - * - * Inherits from: - * - - */ -OpenLayers.Control.MouseDefaults = OpenLayers.Class(OpenLayers.Control, { - - /** WARNING WARNING WARNING!!! - This class is DEPRECATED in 2.4 and will be removed by 3.0. - If you need this functionality, use Control.Navigation instead!!! */ - - /** - * Property: performedDrag - * {Boolean} - */ - performedDrag: false, - - /** - * Property: wheelObserver - * {Function} - */ - wheelObserver: null, - - /** - * Constructor: OpenLayers.Control.MouseDefaults - */ - initialize: function() { - OpenLayers.Control.prototype.initialize.apply(this, arguments); - }, - - /** - * APIMethod: destroy - */ - destroy: function() { - - if (this.handler) { - this.handler.destroy(); - } - this.handler = null; - - this.map.events.un({ - "click": this.defaultClick, - "dblclick": this.defaultDblClick, - "mousedown": this.defaultMouseDown, - "mouseup": this.defaultMouseUp, - "mousemove": this.defaultMouseMove, - "mouseout": this.defaultMouseOut, - scope: this - }); - - //unregister mousewheel events specifically on the window and document - OpenLayers.Event.stopObserving(window, "DOMMouseScroll", - this.wheelObserver); - OpenLayers.Event.stopObserving(window, "mousewheel", - this.wheelObserver); - OpenLayers.Event.stopObserving(document, "mousewheel", - this.wheelObserver); - this.wheelObserver = null; - - OpenLayers.Control.prototype.destroy.apply(this, arguments); - }, - - /** - * Method: draw - */ - draw: function() { - this.map.events.on({ - "click": this.defaultClick, - "dblclick": this.defaultDblClick, - "mousedown": this.defaultMouseDown, - "mouseup": this.defaultMouseUp, - "mousemove": this.defaultMouseMove, - "mouseout": this.defaultMouseOut, - scope: this - }); - - this.registerWheelEvents(); - - }, - - /** - * Method: registerWheelEvents - */ - registerWheelEvents: function() { - - this.wheelObserver = OpenLayers.Function.bindAsEventListener( - this.onWheelEvent, this - ); - - //register mousewheel events specifically on the window and document - OpenLayers.Event.observe(window, "DOMMouseScroll", this.wheelObserver); - OpenLayers.Event.observe(window, "mousewheel", this.wheelObserver); - OpenLayers.Event.observe(document, "mousewheel", this.wheelObserver); - }, - - /** - * Method: defaultClick - * - * Parameters: - * evt - {Event} - * - * Returns: - * {Boolean} - */ - defaultClick: function (evt) { - if (!OpenLayers.Event.isLeftClick(evt)) { - return; - } - var notAfterDrag = !this.performedDrag; - this.performedDrag = false; - return notAfterDrag; - }, - - /** - * Method: defaultDblClick - * - * Parameters: - * evt - {Event} - */ - defaultDblClick: function (evt) { - var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); - this.map.setCenter(newCenter, this.map.zoom + 1); - OpenLayers.Event.stop(evt); - return false; - }, - - /** - * Method: defaultMouseDown - * - * Parameters: - * evt - {Event} - */ - defaultMouseDown: function (evt) { - if (!OpenLayers.Event.isLeftClick(evt)) { - return; - } - this.mouseDragStart = evt.xy.clone(); - this.performedDrag = false; - if (evt.shiftKey) { - this.map.div.style.cursor = "crosshair"; - this.zoomBox = OpenLayers.Util.createDiv('zoomBox', - this.mouseDragStart, - null, - null, - "absolute", - "2px solid red"); - this.zoomBox.style.backgroundColor = "white"; - this.zoomBox.style.filter = "alpha(opacity=50)"; // IE - this.zoomBox.style.opacity = "0.50"; - this.zoomBox.style.fontSize = "1px"; - this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; - this.map.eventsDiv.appendChild(this.zoomBox); - } - document.onselectstart = OpenLayers.Function.False; - OpenLayers.Event.stop(evt); - }, - - /** - * Method: defaultMouseMove - * - * Parameters: - * evt - {Event} - */ - defaultMouseMove: function (evt) { - // record the mouse position, used in onWheelEvent - this.mousePosition = evt.xy.clone(); - - if (this.mouseDragStart != null) { - if (this.zoomBox) { - var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); - var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); - this.zoomBox.style.width = Math.max(1, deltaX) + "px"; - this.zoomBox.style.height = Math.max(1, deltaY) + "px"; - if (evt.xy.x < this.mouseDragStart.x) { - this.zoomBox.style.left = evt.xy.x+"px"; - } - if (evt.xy.y < this.mouseDragStart.y) { - this.zoomBox.style.top = evt.xy.y+"px"; - } - } else { - var deltaX = this.mouseDragStart.x - evt.xy.x; - var deltaY = this.mouseDragStart.y - evt.xy.y; - var size = this.map.getSize(); - var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, - size.h / 2 + deltaY); - var newCenter = this.map.getLonLatFromViewPortPx( newXY ); - this.map.setCenter(newCenter, null, true); - this.mouseDragStart = evt.xy.clone(); - this.map.div.style.cursor = "move"; - } - this.performedDrag = true; - } - }, - - /** - * Method: defaultMouseUp - * - * Parameters: - * evt - {} - */ - defaultMouseUp: function (evt) { - if (!OpenLayers.Event.isLeftClick(evt)) { - return; - } - if (this.zoomBox) { - this.zoomBoxEnd(evt); - } else { - if (this.performedDrag) { - this.map.setCenter(this.map.center); - } - } - document.onselectstart=null; - this.mouseDragStart = null; - this.map.div.style.cursor = ""; - }, - - /** - * Method: defaultMouseOut - * - * Parameters: - * evt - {Event} - */ - defaultMouseOut: function (evt) { - if (this.mouseDragStart != null && - OpenLayers.Util.mouseLeft(evt, this.map.eventsDiv)) { - if (this.zoomBox) { - this.removeZoomBox(); - } - this.mouseDragStart = null; - } - }, - - - /** - * Method: defaultWheelUp - * User spun scroll wheel up - * - */ - defaultWheelUp: function(evt) { - if (this.map.getZoom() <= this.map.getNumZoomLevels()) { - this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), - this.map.getZoom() + 1); - } - }, - - /** - * Method: defaultWheelDown - * User spun scroll wheel down - */ - defaultWheelDown: function(evt) { - if (this.map.getZoom() > 0) { - this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), - this.map.getZoom() - 1); - } - }, - - /** - * Method: zoomBoxEnd - * Zoombox function. - */ - zoomBoxEnd: function(evt) { - if (this.mouseDragStart != null) { - if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || - Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { - var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); - var end = this.map.getLonLatFromViewPortPx( evt.xy ); - var top = Math.max(start.lat, end.lat); - var bottom = Math.min(start.lat, end.lat); - var left = Math.min(start.lon, end.lon); - var right = Math.max(start.lon, end.lon); - var bounds = new OpenLayers.Bounds(left, bottom, right, top); - this.map.zoomToExtent(bounds); - } else { - var end = this.map.getLonLatFromViewPortPx( evt.xy ); - this.map.setCenter(new OpenLayers.LonLat( - (end.lon), - (end.lat) - ), this.map.getZoom() + 1); - } - this.removeZoomBox(); - } - }, - - /** - * Method: removeZoomBox - * Remove the zoombox from the screen and nullify our reference to it. - */ - removeZoomBox: function() { - this.map.eventsDiv.removeChild(this.zoomBox); - this.zoomBox = null; - }, - - -/** - * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/ - */ - - - /** - * Method: onWheelEvent - * Catch the wheel event and handle it xbrowserly - * - * Parameters: - * e - {Event} - */ - onWheelEvent: function(e){ - - // first determine whether or not the wheeling was inside the map - var inMap = false; - var elem = OpenLayers.Event.element(e); - while(elem != null) { - if (this.map && elem == this.map.div) { - inMap = true; - break; - } - elem = elem.parentNode; - } - - if (inMap) { - - var delta = 0; - if (!e) { - e = window.event; - } - if (e.wheelDelta) { - delta = e.wheelDelta/120; - if (window.opera && window.opera.version() < 9.2) { - delta = -delta; - } - } else if (e.detail) { - delta = -e.detail / 3; - } - if (delta) { - // add the mouse position to the event because mozilla has a bug - // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179) - // getLonLatFromViewPortPx(e) returns wrong values - e.xy = this.mousePosition; - - if (delta < 0) { - this.defaultWheelDown(e); - } else { - this.defaultWheelUp(e); - } - } - - //only wheel the map, not the window - OpenLayers.Event.stop(e); - } - }, - - CLASS_NAME: "OpenLayers.Control.MouseDefaults" -}); diff --git a/lib/OpenLayers/Control/MouseToolbar.js b/lib/OpenLayers/Control/MouseToolbar.js deleted file mode 100644 index 9400c1791a..0000000000 --- a/lib/OpenLayers/Control/MouseToolbar.js +++ /dev/null @@ -1,406 +0,0 @@ -/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for - * full list of contributors). Published under the Clear BSD license. - * See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. */ - - -/** - * @requires OpenLayers/Control.js - * @requires OpenLayers/Control/MouseDefaults.js - */ - -/** - * Class: OpenLayers.Control.MouseToolbar - * This class is DEPRECATED in 2.4 and will be removed by 3.0. - * If you need this functionality, use - * instead!!! - */ -OpenLayers.Control.MouseToolbar = OpenLayers.Class( - OpenLayers.Control.MouseDefaults, { - - /** - * Property: mode - */ - mode: null, - /** - * Property: buttons - */ - buttons: null, - - /** - * APIProperty: direction - * {String} 'vertical' or 'horizontal' - */ - direction: "vertical", - - /** - * Property: buttonClicked - * {String} - */ - buttonClicked: null, - - /** - * Constructor: OpenLayers.Control.MouseToolbar - * - * Parameters: - * position - {} - * direction - {String} - */ - initialize: function(position, direction) { - OpenLayers.Control.prototype.initialize.apply(this, arguments); - this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X, - OpenLayers.Control.MouseToolbar.Y); - if (position) { - this.position = position; - } - if (direction) { - this.direction = direction; - } - this.measureDivs = []; - }, - - /** - * APIMethod: destroy - */ - destroy: function() { - for( var btnId in this.buttons) { - var btn = this.buttons[btnId]; - btn.map = null; - btn.events.destroy(); - } - OpenLayers.Control.MouseDefaults.prototype.destroy.apply(this, - arguments); - }, - - /** - * Method: draw - */ - draw: function() { - OpenLayers.Control.prototype.draw.apply(this, arguments); - OpenLayers.Control.MouseDefaults.prototype.draw.apply(this, arguments); - this.buttons = {}; - var sz = new OpenLayers.Size(28,28); - var centered = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,0); - this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area"); - centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); - this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan."); - centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); - this.switchModeTo("pan"); - - return this.div; - }, - - /** - * Method: _addButton - */ - _addButton:function(id, img, activeImg, xy, sz, title) { - var imgLocation = OpenLayers.Util.getImagesLocation() + img; - var activeImgLocation = OpenLayers.Util.getImagesLocation() + activeImg; - // var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz); - var btn = OpenLayers.Util.createAlphaImageDiv( - "OpenLayers_Control_MouseToolbar_" + id, - xy, sz, imgLocation, "absolute"); - - //we want to add the outer div - this.div.appendChild(btn); - btn.imgLocation = imgLocation; - btn.activeImgLocation = activeImgLocation; - - btn.events = new OpenLayers.Events(this, btn, null, true); - btn.events.on({ - "mousedown": this.buttonDown, - "mouseup": this.buttonUp, - "dblclick": OpenLayers.Event.stop, - scope: this - }); - btn.action = id; - btn.title = title; - btn.alt = title; - btn.map = this.map; - - //we want to remember/reference the outer div - this.buttons[id] = btn; - return btn; - }, - - /** - * Method: buttonDown - * - * Parameters: - * evt - {Event} - */ - buttonDown: function(evt) { - if (!OpenLayers.Event.isLeftClick(evt)) { - return; - } - this.buttonClicked = evt.element.action; - OpenLayers.Event.stop(evt); - }, - - /** - * Method: buttonUp - * - * Parameters: - * evt - {Event} - */ - buttonUp: function(evt) { - if (!OpenLayers.Event.isLeftClick(evt)) { - return; - } - if (this.buttonClicked != null) { - if (this.buttonClicked == evt.element.action) { - this.switchModeTo(evt.element.action); - } - OpenLayers.Event.stop(evt); - this.buttonClicked = null; - } - }, - - /** - * Method: defaultDblClick - * - * Parameters: - * evt - {Event} - */ - defaultDblClick: function (evt) { - this.switchModeTo("pan"); - this.performedDrag = false; - var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); - this.map.setCenter(newCenter, this.map.zoom + 1); - OpenLayers.Event.stop(evt); - return false; - }, - - /** - * Method: defaultMouseDown - * - * Parameters: - * evt - {Event} - */ - defaultMouseDown: function (evt) { - if (!OpenLayers.Event.isLeftClick(evt)) { - return; - } - this.mouseDragStart = evt.xy.clone(); - this.performedDrag = false; - this.startViaKeyboard = false; - if (evt.shiftKey && this.mode !="zoombox") { - this.switchModeTo("zoombox"); - this.startViaKeyboard = true; - } else if (evt.altKey && this.mode !="measure") { - this.switchModeTo("measure"); - } else if (!this.mode) { - this.switchModeTo("pan"); - } - - switch (this.mode) { - case "zoombox": - this.map.div.style.cursor = "crosshair"; - this.zoomBox = OpenLayers.Util.createDiv('zoomBox', - this.mouseDragStart, - null, - null, - "absolute", - "2px solid red"); - this.zoomBox.style.backgroundColor = "white"; - this.zoomBox.style.filter = "alpha(opacity=50)"; // IE - this.zoomBox.style.opacity = "0.50"; - this.zoomBox.style.fontSize = "1px"; - this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; - this.map.eventsDiv.appendChild(this.zoomBox); - this.performedDrag = true; - break; - case "measure": - var distance = ""; - if (this.measureStart) { - var measureEnd = this.map.getLonLatFromViewPortPx(this.mouseDragStart); - distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd); - distance = Math.round(distance * 100) / 100; - distance = distance + "km"; - this.measureStartBox = this.measureBox; - } - this.measureStart = this.map.getLonLatFromViewPortPx(this.mouseDragStart);; - this.measureBox = OpenLayers.Util.createDiv(null, - this.mouseDragStart.add( - -2-parseInt(this.map.layerContainerDiv.style.left), - -2-parseInt(this.map.layerContainerDiv.style.top)), - null, - null, - "absolute"); - this.measureBox.style.width="4px"; - this.measureBox.style.height="4px"; - this.measureBox.style.fontSize = "1px"; - this.measureBox.style.backgroundColor="red"; - this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; - this.map.layerContainerDiv.appendChild(this.measureBox); - if (distance) { - this.measureBoxDistance = OpenLayers.Util.createDiv(null, - this.mouseDragStart.add( - -2-parseInt(this.map.layerContainerDiv.style.left), - 2-parseInt(this.map.layerContainerDiv.style.top)), - null, - null, - "absolute"); - - this.measureBoxDistance.innerHTML = distance; - this.measureBoxDistance.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; - this.map.layerContainerDiv.appendChild(this.measureBoxDistance); - this.measureDivs.push(this.measureBoxDistance); - } - this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; - this.map.layerContainerDiv.appendChild(this.measureBox); - this.measureDivs.push(this.measureBox); - break; - default: - this.map.div.style.cursor = "move"; - break; - } - document.onselectstart = OpenLayers.Function.False; - OpenLayers.Event.stop(evt); - }, - - /** - * Method: switchModeTo - * - * Parameters: - * mode - {String} - */ - switchModeTo: function(mode) { - if (mode != this.mode) { - - - if (this.mode && this.buttons[this.mode]) { - OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); - } - if (this.mode == "measure" && mode != "measure") { - for(var i=0, len=this.measureDivs.length; i + * instead!!! + * + * This class is DEPRECATED in 2.4 and will be removed by 3.0. + * If you need this functionality, use Control.Navigation instead!!! + * + * Inherits from: + * - + */ +OpenLayers.Control.MouseDefaults = OpenLayers.Class(OpenLayers.Control, { + + /** WARNING WARNING WARNING!!! + This class is DEPRECATED in 2.4 and will be removed by 3.0. + If you need this functionality, use Control.Navigation instead!!! */ + + /** + * Property: performedDrag + * {Boolean} + */ + performedDrag: false, + + /** + * Property: wheelObserver + * {Function} + */ + wheelObserver: null, + + /** + * Constructor: OpenLayers.Control.MouseDefaults + */ + initialize: function() { + OpenLayers.Control.prototype.initialize.apply(this, arguments); + }, + + /** + * APIMethod: destroy + */ + destroy: function() { + + if (this.handler) { + this.handler.destroy(); + } + this.handler = null; + + this.map.events.un({ + "click": this.defaultClick, + "dblclick": this.defaultDblClick, + "mousedown": this.defaultMouseDown, + "mouseup": this.defaultMouseUp, + "mousemove": this.defaultMouseMove, + "mouseout": this.defaultMouseOut, + scope: this + }); + + //unregister mousewheel events specifically on the window and document + OpenLayers.Event.stopObserving(window, "DOMMouseScroll", + this.wheelObserver); + OpenLayers.Event.stopObserving(window, "mousewheel", + this.wheelObserver); + OpenLayers.Event.stopObserving(document, "mousewheel", + this.wheelObserver); + this.wheelObserver = null; + + OpenLayers.Control.prototype.destroy.apply(this, arguments); + }, + + /** + * Method: draw + */ + draw: function() { + this.map.events.on({ + "click": this.defaultClick, + "dblclick": this.defaultDblClick, + "mousedown": this.defaultMouseDown, + "mouseup": this.defaultMouseUp, + "mousemove": this.defaultMouseMove, + "mouseout": this.defaultMouseOut, + scope: this + }); + + this.registerWheelEvents(); + + }, + + /** + * Method: registerWheelEvents + */ + registerWheelEvents: function() { + + this.wheelObserver = OpenLayers.Function.bindAsEventListener( + this.onWheelEvent, this + ); + + //register mousewheel events specifically on the window and document + OpenLayers.Event.observe(window, "DOMMouseScroll", this.wheelObserver); + OpenLayers.Event.observe(window, "mousewheel", this.wheelObserver); + OpenLayers.Event.observe(document, "mousewheel", this.wheelObserver); + }, + + /** + * Method: defaultClick + * + * Parameters: + * evt - {Event} + * + * Returns: + * {Boolean} + */ + defaultClick: function (evt) { + if (!OpenLayers.Event.isLeftClick(evt)) { + return; + } + var notAfterDrag = !this.performedDrag; + this.performedDrag = false; + return notAfterDrag; + }, + + /** + * Method: defaultDblClick + * + * Parameters: + * evt - {Event} + */ + defaultDblClick: function (evt) { + var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); + this.map.setCenter(newCenter, this.map.zoom + 1); + OpenLayers.Event.stop(evt); + return false; + }, + + /** + * Method: defaultMouseDown + * + * Parameters: + * evt - {Event} + */ + defaultMouseDown: function (evt) { + if (!OpenLayers.Event.isLeftClick(evt)) { + return; + } + this.mouseDragStart = evt.xy.clone(); + this.performedDrag = false; + if (evt.shiftKey) { + this.map.div.style.cursor = "crosshair"; + this.zoomBox = OpenLayers.Util.createDiv('zoomBox', + this.mouseDragStart, + null, + null, + "absolute", + "2px solid red"); + this.zoomBox.style.backgroundColor = "white"; + this.zoomBox.style.filter = "alpha(opacity=50)"; // IE + this.zoomBox.style.opacity = "0.50"; + this.zoomBox.style.fontSize = "1px"; + this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; + this.map.eventsDiv.appendChild(this.zoomBox); + } + document.onselectstart = OpenLayers.Function.False; + OpenLayers.Event.stop(evt); + }, + + /** + * Method: defaultMouseMove + * + * Parameters: + * evt - {Event} + */ + defaultMouseMove: function (evt) { + // record the mouse position, used in onWheelEvent + this.mousePosition = evt.xy.clone(); + + if (this.mouseDragStart != null) { + if (this.zoomBox) { + var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); + var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); + this.zoomBox.style.width = Math.max(1, deltaX) + "px"; + this.zoomBox.style.height = Math.max(1, deltaY) + "px"; + if (evt.xy.x < this.mouseDragStart.x) { + this.zoomBox.style.left = evt.xy.x+"px"; + } + if (evt.xy.y < this.mouseDragStart.y) { + this.zoomBox.style.top = evt.xy.y+"px"; + } + } else { + var deltaX = this.mouseDragStart.x - evt.xy.x; + var deltaY = this.mouseDragStart.y - evt.xy.y; + var size = this.map.getSize(); + var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, + size.h / 2 + deltaY); + var newCenter = this.map.getLonLatFromViewPortPx( newXY ); + this.map.setCenter(newCenter, null, true); + this.mouseDragStart = evt.xy.clone(); + this.map.div.style.cursor = "move"; + } + this.performedDrag = true; + } + }, + + /** + * Method: defaultMouseUp + * + * Parameters: + * evt - {} + */ + defaultMouseUp: function (evt) { + if (!OpenLayers.Event.isLeftClick(evt)) { + return; + } + if (this.zoomBox) { + this.zoomBoxEnd(evt); + } else { + if (this.performedDrag) { + this.map.setCenter(this.map.center); + } + } + document.onselectstart=null; + this.mouseDragStart = null; + this.map.div.style.cursor = ""; + }, + + /** + * Method: defaultMouseOut + * + * Parameters: + * evt - {Event} + */ + defaultMouseOut: function (evt) { + if (this.mouseDragStart != null && + OpenLayers.Util.mouseLeft(evt, this.map.eventsDiv)) { + if (this.zoomBox) { + this.removeZoomBox(); + } + this.mouseDragStart = null; + } + }, + + + /** + * Method: defaultWheelUp + * User spun scroll wheel up + * + */ + defaultWheelUp: function(evt) { + if (this.map.getZoom() <= this.map.getNumZoomLevels()) { + this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), + this.map.getZoom() + 1); + } + }, + + /** + * Method: defaultWheelDown + * User spun scroll wheel down + */ + defaultWheelDown: function(evt) { + if (this.map.getZoom() > 0) { + this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), + this.map.getZoom() - 1); + } + }, + + /** + * Method: zoomBoxEnd + * Zoombox function. + */ + zoomBoxEnd: function(evt) { + if (this.mouseDragStart != null) { + if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || + Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { + var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); + var end = this.map.getLonLatFromViewPortPx( evt.xy ); + var top = Math.max(start.lat, end.lat); + var bottom = Math.min(start.lat, end.lat); + var left = Math.min(start.lon, end.lon); + var right = Math.max(start.lon, end.lon); + var bounds = new OpenLayers.Bounds(left, bottom, right, top); + this.map.zoomToExtent(bounds); + } else { + var end = this.map.getLonLatFromViewPortPx( evt.xy ); + this.map.setCenter(new OpenLayers.LonLat( + (end.lon), + (end.lat) + ), this.map.getZoom() + 1); + } + this.removeZoomBox(); + } + }, + + /** + * Method: removeZoomBox + * Remove the zoombox from the screen and nullify our reference to it. + */ + removeZoomBox: function() { + this.map.eventsDiv.removeChild(this.zoomBox); + this.zoomBox = null; + }, + + +/** + * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/ + */ + + + /** + * Method: onWheelEvent + * Catch the wheel event and handle it xbrowserly + * + * Parameters: + * e - {Event} + */ + onWheelEvent: function(e){ + + // first determine whether or not the wheeling was inside the map + var inMap = false; + var elem = OpenLayers.Event.element(e); + while(elem != null) { + if (this.map && elem == this.map.div) { + inMap = true; + break; + } + elem = elem.parentNode; + } + + if (inMap) { + + var delta = 0; + if (!e) { + e = window.event; + } + if (e.wheelDelta) { + delta = e.wheelDelta/120; + if (window.opera && window.opera.version() < 9.2) { + delta = -delta; + } + } else if (e.detail) { + delta = -e.detail / 3; + } + if (delta) { + // add the mouse position to the event because mozilla has a bug + // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179) + // getLonLatFromViewPortPx(e) returns wrong values + e.xy = this.mousePosition; + + if (delta < 0) { + this.defaultWheelDown(e); + } else { + this.defaultWheelUp(e); + } + } + + //only wheel the map, not the window + OpenLayers.Event.stop(e); + } + }, + + CLASS_NAME: "OpenLayers.Control.MouseDefaults" +}); + +/** + * Class: OpenLayers.Control.MouseToolbar + * This class is DEPRECATED in 2.4 and will be removed by 3.0. + * If you need this functionality, use + * instead!!! + */ +OpenLayers.Control.MouseToolbar = OpenLayers.Class( + OpenLayers.Control.MouseDefaults, { + + /** + * Property: mode + */ + mode: null, + /** + * Property: buttons + */ + buttons: null, + + /** + * APIProperty: direction + * {String} 'vertical' or 'horizontal' + */ + direction: "vertical", + + /** + * Property: buttonClicked + * {String} + */ + buttonClicked: null, + + /** + * Constructor: OpenLayers.Control.MouseToolbar + * + * Parameters: + * position - {} + * direction - {String} + */ + initialize: function(position, direction) { + OpenLayers.Control.prototype.initialize.apply(this, arguments); + this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X, + OpenLayers.Control.MouseToolbar.Y); + if (position) { + this.position = position; + } + if (direction) { + this.direction = direction; + } + this.measureDivs = []; + }, + + /** + * APIMethod: destroy + */ + destroy: function() { + for( var btnId in this.buttons) { + var btn = this.buttons[btnId]; + btn.map = null; + btn.events.destroy(); + } + OpenLayers.Control.MouseDefaults.prototype.destroy.apply(this, + arguments); + }, + + /** + * Method: draw + */ + draw: function() { + OpenLayers.Control.prototype.draw.apply(this, arguments); + OpenLayers.Control.MouseDefaults.prototype.draw.apply(this, arguments); + this.buttons = {}; + var sz = new OpenLayers.Size(28,28); + var centered = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,0); + this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area"); + centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); + this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan."); + centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); + this.switchModeTo("pan"); + + return this.div; + }, + + /** + * Method: _addButton + */ + _addButton:function(id, img, activeImg, xy, sz, title) { + var imgLocation = OpenLayers.Util.getImagesLocation() + img; + var activeImgLocation = OpenLayers.Util.getImagesLocation() + activeImg; + // var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz); + var btn = OpenLayers.Util.createAlphaImageDiv( + "OpenLayers_Control_MouseToolbar_" + id, + xy, sz, imgLocation, "absolute"); + + //we want to add the outer div + this.div.appendChild(btn); + btn.imgLocation = imgLocation; + btn.activeImgLocation = activeImgLocation; + + btn.events = new OpenLayers.Events(this, btn, null, true); + btn.events.on({ + "mousedown": this.buttonDown, + "mouseup": this.buttonUp, + "dblclick": OpenLayers.Event.stop, + scope: this + }); + btn.action = id; + btn.title = title; + btn.alt = title; + btn.map = this.map; + + //we want to remember/reference the outer div + this.buttons[id] = btn; + return btn; + }, + + /** + * Method: buttonDown + * + * Parameters: + * evt - {Event} + */ + buttonDown: function(evt) { + if (!OpenLayers.Event.isLeftClick(evt)) { + return; + } + this.buttonClicked = evt.element.action; + OpenLayers.Event.stop(evt); + }, + + /** + * Method: buttonUp + * + * Parameters: + * evt - {Event} + */ + buttonUp: function(evt) { + if (!OpenLayers.Event.isLeftClick(evt)) { + return; + } + if (this.buttonClicked != null) { + if (this.buttonClicked == evt.element.action) { + this.switchModeTo(evt.element.action); + } + OpenLayers.Event.stop(evt); + this.buttonClicked = null; + } + }, + + /** + * Method: defaultDblClick + * + * Parameters: + * evt - {Event} + */ + defaultDblClick: function (evt) { + this.switchModeTo("pan"); + this.performedDrag = false; + var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); + this.map.setCenter(newCenter, this.map.zoom + 1); + OpenLayers.Event.stop(evt); + return false; + }, + + /** + * Method: defaultMouseDown + * + * Parameters: + * evt - {Event} + */ + defaultMouseDown: function (evt) { + if (!OpenLayers.Event.isLeftClick(evt)) { + return; + } + this.mouseDragStart = evt.xy.clone(); + this.performedDrag = false; + this.startViaKeyboard = false; + if (evt.shiftKey && this.mode !="zoombox") { + this.switchModeTo("zoombox"); + this.startViaKeyboard = true; + } else if (evt.altKey && this.mode !="measure") { + this.switchModeTo("measure"); + } else if (!this.mode) { + this.switchModeTo("pan"); + } + + switch (this.mode) { + case "zoombox": + this.map.div.style.cursor = "crosshair"; + this.zoomBox = OpenLayers.Util.createDiv('zoomBox', + this.mouseDragStart, + null, + null, + "absolute", + "2px solid red"); + this.zoomBox.style.backgroundColor = "white"; + this.zoomBox.style.filter = "alpha(opacity=50)"; // IE + this.zoomBox.style.opacity = "0.50"; + this.zoomBox.style.fontSize = "1px"; + this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; + this.map.eventsDiv.appendChild(this.zoomBox); + this.performedDrag = true; + break; + case "measure": + var distance = ""; + if (this.measureStart) { + var measureEnd = this.map.getLonLatFromViewPortPx(this.mouseDragStart); + distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd); + distance = Math.round(distance * 100) / 100; + distance = distance + "km"; + this.measureStartBox = this.measureBox; + } + this.measureStart = this.map.getLonLatFromViewPortPx(this.mouseDragStart);; + this.measureBox = OpenLayers.Util.createDiv(null, + this.mouseDragStart.add( + -2-parseInt(this.map.layerContainerDiv.style.left), + -2-parseInt(this.map.layerContainerDiv.style.top)), + null, + null, + "absolute"); + this.measureBox.style.width="4px"; + this.measureBox.style.height="4px"; + this.measureBox.style.fontSize = "1px"; + this.measureBox.style.backgroundColor="red"; + this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; + this.map.layerContainerDiv.appendChild(this.measureBox); + if (distance) { + this.measureBoxDistance = OpenLayers.Util.createDiv(null, + this.mouseDragStart.add( + -2-parseInt(this.map.layerContainerDiv.style.left), + 2-parseInt(this.map.layerContainerDiv.style.top)), + null, + null, + "absolute"); + + this.measureBoxDistance.innerHTML = distance; + this.measureBoxDistance.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; + this.map.layerContainerDiv.appendChild(this.measureBoxDistance); + this.measureDivs.push(this.measureBoxDistance); + } + this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; + this.map.layerContainerDiv.appendChild(this.measureBox); + this.measureDivs.push(this.measureBox); + break; + default: + this.map.div.style.cursor = "move"; + break; + } + document.onselectstart = OpenLayers.Function.False; + OpenLayers.Event.stop(evt); + }, + + /** + * Method: switchModeTo + * + * Parameters: + * mode - {String} + */ + switchModeTo: function(mode) { + if (mode != this.mode) { + + + if (this.mode && this.buttons[this.mode]) { + OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); + } + if (this.mode == "measure" && mode != "measure") { + for(var i=0, len=this.measureDivs.length; i - + + + + diff --git a/tests/deprecated/Layer/MapServer/Untiled.html b/tests/deprecated/Layer/MapServer/Untiled.html new file mode 100644 index 0000000000..3ef70cc56f --- /dev/null +++ b/tests/deprecated/Layer/MapServer/Untiled.html @@ -0,0 +1,179 @@ + + + + + + + + +
    + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 8cb2edb0b5..8d11e15d93 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -230,5 +230,6 @@
  • deprecated/BaseTypes/Class.html
  • deprecated/BaseTypes/Element.html
  • deprecated/Control/MouseToolbar.html
  • +
  • deprecated/Layer/MapServer/Untiled.html
  • deprecated/Layer/WMS/Post.html
  • From 9f1869df2d8bc10ca445f8c2e3563212522e732a Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 9 Nov 2011 11:28:12 +0100 Subject: [PATCH 13/14] Don't use deprecated Element.hide and show methods internally. --- lib/OpenLayers/BaseTypes/Element.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Element.js b/lib/OpenLayers/BaseTypes/Element.js index 55618a10fb..bc1d84ed8a 100644 --- a/lib/OpenLayers/BaseTypes/Element.js +++ b/lib/OpenLayers/BaseTypes/Element.js @@ -36,9 +36,9 @@ OpenLayers.Element = { toggle: function() { for (var i=0, len=arguments.length; i Date: Wed, 9 Nov 2011 12:56:05 -0700 Subject: [PATCH 14/14] Add dependencies for deprecated.js. To use deprecated methods, include the "deprecated.js" script in your build profile. --- lib/deprecated.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/deprecated.js b/lib/deprecated.js index bc01105806..11a80ed00c 100644 --- a/lib/deprecated.js +++ b/lib/deprecated.js @@ -1,3 +1,13 @@ +/** + * @requires OpenLayers/BaseTypes/Class.js + * @requires OpenLayers/Util.js + * @requires OpenLayers/Control.js + * @requires OpenLayers/Format.js + * @requires OpenLayers/Request.js + * @requires OpenLayers/Layer/WMS.js + * @requires OpenLayers/Layer/MapServer.js + */ + /** * Namespace: OpenLayers.Class */