OpenLayers OpenLayers

Changeset 7675

Show
Ignore:
Timestamp:
08/01/08 18:21:50 (4 months ago)
Author:
crschmidt
Message:

Patch from funky_c to move all alert()s in the library to a single
OpenLayers.Console.userError function. This allows for easy overriding of this
function for people who need to report errors at an application level (or
hiding these errors entirely), with the same default behavior as previous
releases. Patch from funky_c, r=me, (Closes #1651)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Ajax.js

    r7346 r7675  
    3939 */ 
    4040OpenLayers.nullHandler = function(request) { 
    41     alert(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); 
     41    OpenLayers.Console.userError(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); 
    4242}; 
    4343 
     
    5656 *     will be called with this set to caller and will receive the request 
    5757 *     object as an argument.  Note that if you do not specify an onComplete 
    58  *     function, <OpenLayers.nullHandler> will be called (which pops up an 
    59  *     alert dialog). 
     58 *     function, <OpenLayers.nullHandler> will be called (which pops up a  
     59 *     user friendly error message dialog). 
    6060 * onFailure - {Function} Optional callback for failure.  In the event of 
    6161 *     a failure, the callback will be called with this set to caller and will 
    6262 *     receive the request object as an argument.  Note that if you do not 
    6363 *     specify an onComplete function, <OpenLayers.nullHandler> will be called 
    64  *     (which pops up an alert dialog). 
     64 *     (which pops up a user friendly error message dialog). 
    6565 * 
    6666 * Returns: 
  • trunk/openlayers/lib/OpenLayers/Console.js

    r7627 r7675  
    8787     */ 
    8888    error: function() {}, 
     89     
     90    /** 
     91     * APIFunction: userError 
     92     * A single interface for showing error messages to the user. The default 
     93     * behavior is a Javascript alert, though this can be overridden by 
     94     * reassigning OpenLayers.Console.userError to a different function. 
     95     * 
     96     * Expects a single error message 
     97     *  
     98     * Parameters: 
     99     * object - {Object} 
     100     */ 
     101    userError: function(error) { 
     102        alert(error); 
     103    }, 
    89104 
    90105    /** 
  • trunk/openlayers/lib/OpenLayers/Control.js

    r6833 r7675  
    4444 * > 
    4545 * >     notice: function (bounds) { 
    46  * >         alert(bounds); 
     46 * >         OpenLayers.Console.userError(bounds); 
    4747 * >     } 
    4848 * > });  
  • trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js

    r7627 r7675  
    498498        if(this.map.getUnits() != 'degrees') { 
    499499            if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { 
    500                 alert(OpenLayers.i18n("sameProjection")); 
     500                OpenLayers.Console.userError(OpenLayers.i18n("sameProjection")); 
    501501            } 
    502502        } 
  • trunk/openlayers/lib/OpenLayers/Format.js

    r6313 r7675  
    6969     */ 
    7070    read: function(data) { 
    71         alert(OpenLayers.i18n("readNotImplemented")); 
     71        OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented")); 
    7272    }, 
    7373     
     
    8383     */ 
    8484    write: function(object) { 
    85         alert(OpenLayers.i18n("writeNotImplemented")); 
     85        OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented")); 
    8686    }, 
    8787 
  • trunk/openlayers/lib/OpenLayers/Format/WFS.js

    r6381 r7675  
    130130     */ 
    131131    update: function(feature) { 
    132         if (!feature.fid) { alert(OpenLayers.i18n("noFID")); } 
     132        if (!feature.fid) { OpenLayers.Console.userError(OpenLayers.i18n("noFID")); } 
    133133        var updateNode = this.createElementNS(this.wfsns, 'wfs:Update'); 
    134134        updateNode.setAttribute("typeName", this.layerName); 
     
    187187    remove: function(feature) { 
    188188        if (!feature.fid) {  
    189             alert(OpenLayers.i18n("noFID"));  
     189            OpenLayers.Console.userError(OpenLayers.i18n("noFID"));  
    190190            return false;  
    191191        } 
  • trunk/openlayers/lib/OpenLayers/Layer/GML.js

    r7339 r7675  
    163163     */ 
    164164    requestFailure: function(request) { 
    165         alert(OpenLayers.i18n("errorLoadingGML", {'url':this.url})); 
     165        OpenLayers.Console.userError(OpenLayers.i18n("errorLoadingGML", {'url':this.url})); 
    166166        this.events.triggerEvent("loadend"); 
    167167    }, 
  • trunk/openlayers/lib/OpenLayers/Layer/Vector.js

    r7652 r7675  
    110110    /** 
    111111     * APIProperty: reportError 
    112      * {Boolean} report error message via alert() when loading of renderers 
     112     * {Boolean} report friendly error message when loading of renderer 
    113113     * fails. 
    114114     */ 
     
    272272    displayError: function() { 
    273273        if (this.reportError) { 
    274             alert(OpenLayers.i18n("browserNotSupported",  
     274            OpenLayers.Console.userError(OpenLayers.i18n("browserNotSupported",  
    275275                                     {'renderers':this.renderers.join("\n")})); 
    276276        }     
  • trunk/openlayers/lib/OpenLayers/Layer/WFS.js

    r7417 r7675  
    512512     */ 
    513513    commitReport: function(string, response) { 
    514         alert(string); 
     514        OpenLayers.Console.userError(string); 
    515515    }, 
    516516 
  • trunk/openlayers/lib/OpenLayers/Util.js

    r7627 r7675  
    11421142    for(var key in urlObj1) { 
    11431143        if (options.test) { 
    1144             alert(key + "\n1:" + urlObj1[key] + "\n2:" + urlObj2[key]); 
     1144            OpenLayers.Console.userError(key + "\n1:" + urlObj1[key] + "\n2:" + urlObj2[key]); 
    11451145        } 
    11461146        var val1 = urlObj1[key];