OpenLayers OpenLayers

Changeset 487

Show
Ignore:
Timestamp:
05/31/06 21:15:23 (2 years ago)
Author:
euzuro
Message:

change Ajax.js's loadURL() function to take directly function references instead of strings to be dereferenced through a 'handlers' variable. Update code in Tile.WFS... only place it is used.

Files:

Legend:

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

    r324 r487  
    66* Ajax reader for OpenLayers 
    77* 
    8 * Pay close attention to how this works: 
    9 * 
    108*@uri url to do remote XML http get 
    119*@param 'get' format params (x=y&a=b...) 
    12 *@who object which is providing a specific callbacks for this request 
    13 *@complete  the name of the function which must be defined in the callers.handler[] array 
    14 *@failure  the name of the function which must be defined in the callers.handler[] array 
     10*@who object to handle callbacks for this request 
     11*@complete  the function to be called on success  
     12*@failure  the function to be called on failure 
    1513* 
    1614* example usage from a caller: 
    1715* 
    18 *   this.handlers["caps"] = function(request){..} 
    19 *   OpenLayers.loadURL(url,params,this,"caps"); 
     16*   caps: function(request) { 
     17*    -blah-   
     18*   }, 
     19
     20*   OpenLayers.loadURL(url,params,this,caps); 
    2021* 
    2122* Notice the above example does not provide an error handler; a default empty 
    22 * handler is provided which merely logs the error if a failure handler is not supplied 
     23* handler is provided which merely logs the error if a failure handler is not  
     24* supplied 
    2325* 
    2426*/ 
     
    5658//    ol.Log.debug("loadURL [" + uri + "]"); 
    5759 
    58     var successx; 
    59     var failurex; 
    60     var bind1 = null; 
    61     var bind2 = null; 
     60    var success = (onComplete) ? onComplete.bind(caller) 
     61                                : OpenLayers.nullHandler; 
    6262 
    63     if (onComplete) { 
    64         successx = caller.handlers[onComplete]; 
    65         bind1 = caller; 
    66     } else { 
    67         successx = OpenLayers.nullHandler; 
    68     } 
    69  
    70     if (onFailure) { 
    71         failurex = caller.handlers[onFailure]; 
    72         bind2=caller; 
    73     } else { 
    74         failurex = OpenLayers.nullHandler; 
    75     } 
     63    var failure = (onFailure) ? onFailure.bind(caller) 
     64                           : OpenLayers.nullHandler; 
    7665 
    7766    // from prototype.js 
     
    7968                     {   method: 'get',  
    8069                         parameters: params, 
    81                          onComplete: successx.bind(bind1),  
    82                          onFailure: failurex.bind(bind2) 
     70                         onComplete: success,  
     71                         onFailure: failure 
    8372                      } 
    8473                     ); 
  • trunk/openlayers/lib/OpenLayers/Tile/WFS.js

    r407 r487  
    2727         
    2828        this.features = new Array(); 
    29  
    30         this.handlers = new Array(); 
    31         this.handlers["requestSuccess"] = this.requestSuccess; 
    3229    }, 
    3330 
     
    3633    draw:function() { 
    3734        OpenLayers.Tile.prototype.draw.apply(this, arguments); 
    38         this.loadFeaturesForRegion("requestSuccess");         
     35        this.loadFeaturesForRegion(this.requestSuccess);         
    3936    }, 
    4037