git-svn-id: http://svn.openlayers.org/trunk/openlayers@8420 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -139,6 +139,16 @@ OpenLayers.Protocol = OpenLayers.Class({
|
|||||||
*/
|
*/
|
||||||
commit: function() {
|
commit: function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: abort
|
||||||
|
* Abort an ongoing request.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* response - {<OpenLayers.Protocol.Response>}
|
||||||
|
*/
|
||||||
|
abort: function(response) {
|
||||||
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Protocol"
|
CLASS_NAME: "OpenLayers.Protocol"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -441,6 +441,21 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
|
|||||||
return resp;
|
return resp;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: abort
|
||||||
|
* Abort an ongoing request, the response object passed to
|
||||||
|
* this method must come from this HTTP protocol (as a result
|
||||||
|
* of a create, read, update, delete or commit operation).
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* response - {<OpenLayers.Protocol.Response>}
|
||||||
|
*/
|
||||||
|
abort: function(response) {
|
||||||
|
if (response) {
|
||||||
|
response.priv.abort();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: callUserCallback
|
* Method: callUserCallback
|
||||||
* This method is used from within the commit method each time an
|
* This method is used from within the commit method each time an
|
||||||
|
|||||||
@@ -157,13 +157,9 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {
|
|||||||
* returned by the layer protocol.
|
* returned by the layer protocol.
|
||||||
*/
|
*/
|
||||||
triggerRead: function() {
|
triggerRead: function() {
|
||||||
var filter = this.createFilter();
|
this.layer.protocol.abort(this.response);
|
||||||
if (this.response && this.response.priv &&
|
|
||||||
typeof this.response.priv.abort == "function") {
|
|
||||||
this.response.priv.abort();
|
|
||||||
}
|
|
||||||
this.response = this.layer.protocol.read({
|
this.response = this.layer.protocol.read({
|
||||||
filter: filter,
|
filter: this.createFilter(),
|
||||||
callback: this.merge,
|
callback: this.merge,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|||||||
+15
-21
@@ -76,7 +76,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_triggerRead(t) {
|
function test_triggerRead(t) {
|
||||||
t.plan(7);
|
t.plan(4);
|
||||||
|
|
||||||
var s = new OpenLayers.Strategy.BBOX();
|
var s = new OpenLayers.Strategy.BBOX();
|
||||||
|
|
||||||
@@ -85,32 +85,26 @@
|
|||||||
s.createFilter = function() {
|
s.createFilter = function() {
|
||||||
return filter;
|
return filter;
|
||||||
};
|
};
|
||||||
|
s.response = {"fake": "response"};
|
||||||
|
|
||||||
s.setLayer({
|
var protocol = new OpenLayers.Protocol({
|
||||||
protocol: {
|
read: function(options) {
|
||||||
read: function(options) {
|
t.ok(options.filter == filter,
|
||||||
t.ok(options.filter == filter,
|
"protocol read called with correct filter");
|
||||||
"protocol read called with correct filter");
|
t.ok(options.callback == s.merge,
|
||||||
t.ok(options.callback == s.merge,
|
"protocol read called with correct callback");
|
||||||
"protocol read called with correct callback");
|
t.ok(options.scope == s,
|
||||||
t.ok(options.scope == s,
|
"protocol read called with correct scope");
|
||||||
"protocol read called with correct scope");
|
},
|
||||||
}
|
abort: function(response) {
|
||||||
|
t.eq(response, s.response,
|
||||||
|
"protocol abort called with correct response");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3 tests
|
s.setLayer({protocol: protocol});
|
||||||
s.triggerRead();
|
|
||||||
|
|
||||||
// 4 tests
|
// 4 tests
|
||||||
s.response = {
|
|
||||||
priv: {
|
|
||||||
abort: function() {
|
|
||||||
t.ok(true,
|
|
||||||
"triggerRead aborts previous read request");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
s.triggerRead();
|
s.triggerRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user