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.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@487 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+16
-27
@@ -5,21 +5,23 @@ OpenLayers.ProxyHost = "/viewer/Crossbrowser/blindproxy.py?url=";
|
|||||||
/**
|
/**
|
||||||
* Ajax reader for OpenLayers
|
* Ajax reader for OpenLayers
|
||||||
*
|
*
|
||||||
* Pay close attention to how this works:
|
|
||||||
*
|
|
||||||
*@uri url to do remote XML http get
|
*@uri url to do remote XML http get
|
||||||
*@param 'get' format params (x=y&a=b...)
|
*@param 'get' format params (x=y&a=b...)
|
||||||
*@who object which is providing a specific callbacks for this request
|
*@who object to handle callbacks for this request
|
||||||
*@complete the name of the function which must be defined in the callers.handler[] array
|
*@complete the function to be called on success
|
||||||
*@failure the name of the function which must be defined in the callers.handler[] array
|
*@failure the function to be called on failure
|
||||||
*
|
*
|
||||||
* example usage from a caller:
|
* example usage from a caller:
|
||||||
*
|
*
|
||||||
* this.handlers["caps"] = function(request){..}
|
* caps: function(request) {
|
||||||
* OpenLayers.loadURL(url,params,this,"caps");
|
* -blah-
|
||||||
|
* },
|
||||||
|
*
|
||||||
|
* OpenLayers.loadURL(url,params,this,caps);
|
||||||
*
|
*
|
||||||
* Notice the above example does not provide an error handler; a default empty
|
* 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
|
* handler is provided which merely logs the error if a failure handler is not
|
||||||
|
* supplied
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -55,31 +57,18 @@ OpenLayers.loadURL = function(uri, params, caller,
|
|||||||
|
|
||||||
// ol.Log.debug("loadURL [" + uri + "]");
|
// ol.Log.debug("loadURL [" + uri + "]");
|
||||||
|
|
||||||
var successx;
|
var success = (onComplete) ? onComplete.bind(caller)
|
||||||
var failurex;
|
: OpenLayers.nullHandler;
|
||||||
var bind1 = null;
|
|
||||||
var bind2 = null;
|
|
||||||
|
|
||||||
if (onComplete) {
|
var failure = (onFailure) ? onFailure.bind(caller)
|
||||||
successx = caller.handlers[onComplete];
|
: OpenLayers.nullHandler;
|
||||||
bind1 = caller;
|
|
||||||
} else {
|
|
||||||
successx = OpenLayers.nullHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onFailure) {
|
|
||||||
failurex = caller.handlers[onFailure];
|
|
||||||
bind2=caller;
|
|
||||||
} else {
|
|
||||||
failurex = OpenLayers.nullHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
// from prototype.js
|
// from prototype.js
|
||||||
new Ajax.Request(uri,
|
new Ajax.Request(uri,
|
||||||
{ method: 'get',
|
{ method: 'get',
|
||||||
parameters: params,
|
parameters: params,
|
||||||
onComplete: successx.bind(bind1),
|
onComplete: success,
|
||||||
onFailure: failurex.bind(bind2)
|
onFailure: failure
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,16 +26,13 @@ OpenLayers.Tile.WFS.prototype =
|
|||||||
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
this.features = new Array();
|
this.features = new Array();
|
||||||
|
|
||||||
this.handlers = new Array();
|
|
||||||
this.handlers["requestSuccess"] = this.requestSuccess;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
draw:function() {
|
draw:function() {
|
||||||
OpenLayers.Tile.prototype.draw.apply(this, arguments);
|
OpenLayers.Tile.prototype.draw.apply(this, arguments);
|
||||||
this.loadFeaturesForRegion("requestSuccess");
|
this.loadFeaturesForRegion(this.requestSuccess);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user