diff --git a/lib/OpenLayers/Ajax.js b/lib/OpenLayers/Ajax.js index c19a928bd6..693b1c1097 100644 --- a/lib/OpenLayers/Ajax.js +++ b/lib/OpenLayers/Ajax.js @@ -38,7 +38,7 @@ OpenLayers.ProxyHost = ""; * @param {} request */ OpenLayers.nullHandler = function(request) { - alert(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); + OpenLayers.Console.userError(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); }; /** @@ -55,13 +55,13 @@ OpenLayers.nullHandler = function(request) { * onComplete - {Function} Optional callback for success. The callback * will be called with this set to caller and will receive the request * object as an argument. Note that if you do not specify an onComplete - * function, will be called (which pops up an - * alert dialog). + * function, will be called (which pops up a + * user friendly error message dialog). * onFailure - {Function} Optional callback for failure. In the event of * a failure, the callback will be called with this set to caller and will * receive the request object as an argument. Note that if you do not * specify an onComplete function, will be called - * (which pops up an alert dialog). + * (which pops up a user friendly error message dialog). * * Returns: * {} The request object. To abort loading, diff --git a/lib/OpenLayers/Console.js b/lib/OpenLayers/Console.js index 8cb309556e..bfb40163ff 100644 --- a/lib/OpenLayers/Console.js +++ b/lib/OpenLayers/Console.js @@ -86,6 +86,21 @@ OpenLayers.Console = { * object - {Object} */ error: function() {}, + + /** + * APIFunction: userError + * A single interface for showing error messages to the user. The default + * behavior is a Javascript alert, though this can be overridden by + * reassigning OpenLayers.Console.userError to a different function. + * + * Expects a single error message + * + * Parameters: + * object - {Object} + */ + userError: function(error) { + alert(error); + }, /** * APIFunction: assert diff --git a/lib/OpenLayers/Control.js b/lib/OpenLayers/Control.js index d0d16a83aa..ce6ec13345 100644 --- a/lib/OpenLayers/Control.js +++ b/lib/OpenLayers/Control.js @@ -43,7 +43,7 @@ * > }, * > * > notice: function (bounds) { - * > alert(bounds); + * > OpenLayers.Console.userError(bounds); * > } * > }); * > map.addControl(control); diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 87c8aca53b..0da1f056c0 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -497,7 +497,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { // as the base layer for the main map. This should be made more robust. if(this.map.getUnits() != 'degrees') { if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { - alert(OpenLayers.i18n("sameProjection")); + OpenLayers.Console.userError(OpenLayers.i18n("sameProjection")); } } var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent()); diff --git a/lib/OpenLayers/Format.js b/lib/OpenLayers/Format.js index c6f02d1edd..c809c46f92 100644 --- a/lib/OpenLayers/Format.js +++ b/lib/OpenLayers/Format.js @@ -68,7 +68,7 @@ OpenLayers.Format = OpenLayers.Class({ * Depends on the subclass */ read: function(data) { - alert(OpenLayers.i18n("readNotImplemented")); + OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented")); }, /** @@ -82,7 +82,7 @@ OpenLayers.Format = OpenLayers.Class({ * {String} A string representation of the object. */ write: function(object) { - alert(OpenLayers.i18n("writeNotImplemented")); + OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented")); }, CLASS_NAME: "OpenLayers.Format" diff --git a/lib/OpenLayers/Format/WFS.js b/lib/OpenLayers/Format/WFS.js index 1af2cb13a4..9c942c5b86 100644 --- a/lib/OpenLayers/Format/WFS.js +++ b/lib/OpenLayers/Format/WFS.js @@ -129,7 +129,7 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, { * feature - {} */ update: function(feature) { - if (!feature.fid) { alert(OpenLayers.i18n("noFID")); } + if (!feature.fid) { OpenLayers.Console.userError(OpenLayers.i18n("noFID")); } var updateNode = this.createElementNS(this.wfsns, 'wfs:Update'); updateNode.setAttribute("typeName", this.layerName); @@ -186,7 +186,7 @@ OpenLayers.Format.WFS = OpenLayers.Class(OpenLayers.Format.GML, { */ remove: function(feature) { if (!feature.fid) { - alert(OpenLayers.i18n("noFID")); + OpenLayers.Console.userError(OpenLayers.i18n("noFID")); return false; } var deleteNode = this.createElementNS(this.wfsns, 'wfs:Delete'); diff --git a/lib/OpenLayers/Layer/GML.js b/lib/OpenLayers/Layer/GML.js index 142e878690..6f99a970a6 100644 --- a/lib/OpenLayers/Layer/GML.js +++ b/lib/OpenLayers/Layer/GML.js @@ -162,7 +162,7 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, { * request - {String} */ requestFailure: function(request) { - alert(OpenLayers.i18n("errorLoadingGML", {'url':this.url})); + OpenLayers.Console.userError(OpenLayers.i18n("errorLoadingGML", {'url':this.url})); this.events.triggerEvent("loadend"); }, diff --git a/lib/OpenLayers/Layer/Vector.js b/lib/OpenLayers/Layer/Vector.js index 4eb2a9ede7..421a7a7460 100644 --- a/lib/OpenLayers/Layer/Vector.js +++ b/lib/OpenLayers/Layer/Vector.js @@ -109,7 +109,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { /** * APIProperty: reportError - * {Boolean} report error message via alert() when loading of renderers + * {Boolean} report friendly error message when loading of renderer * fails. */ reportError: true, @@ -271,7 +271,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { */ displayError: function() { if (this.reportError) { - alert(OpenLayers.i18n("browserNotSupported", + OpenLayers.Console.userError(OpenLayers.i18n("browserNotSupported", {'renderers':this.renderers.join("\n")})); } }, diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index 4dfcddf0d7..f0ea8fedd3 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -511,7 +511,7 @@ OpenLayers.Layer.WFS = OpenLayers.Class( * response - {String} full XML response */ commitReport: function(string, response) { - alert(string); + OpenLayers.Console.userError(string); }, diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index a0f9775c00..3ae1169a58 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1141,7 +1141,7 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) { //compare all keys (host, port, etc) for(var key in urlObj1) { if (options.test) { - alert(key + "\n1:" + urlObj1[key] + "\n2:" + urlObj2[key]); + OpenLayers.Console.userError(key + "\n1:" + urlObj1[key] + "\n2:" + urlObj2[key]); } var val1 = urlObj1[key]; var val2 = urlObj2[key];