summaryrefslogtreecommitdiff
path: root/lib/dojo/data/util/simpleFetch.js
blob: b3cc365d167ff8a35f5f838b97efbd848f9ca963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
	Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


if(!dojo._hasResource["dojo.data.util.simpleFetch"]){
dojo._hasResource["dojo.data.util.simpleFetch"]=true;
dojo.provide("dojo.data.util.simpleFetch");
dojo.require("dojo.data.util.sorter");
dojo.data.util.simpleFetch.fetch=function(_1){
_1=_1||{};
if(!_1.store){
_1.store=this;
}
var _2=this;
var _3=function(_4,_5){
if(_5.onError){
var _6=_5.scope||dojo.global;
_5.onError.call(_6,_4,_5);
}
};
var _7=function(_8,_9){
var _a=_9.abort||null;
var _b=false;
var _c=_9.start?_9.start:0;
var _d=(_9.count&&(_9.count!==Infinity))?(_c+_9.count):_8.length;
_9.abort=function(){
_b=true;
if(_a){
_a.call(_9);
}
};
var _e=_9.scope||dojo.global;
if(!_9.store){
_9.store=_2;
}
if(_9.onBegin){
_9.onBegin.call(_e,_8.length,_9);
}
if(_9.sort){
_8.sort(dojo.data.util.sorter.createSortFunction(_9.sort,_2));
}
if(_9.onItem){
for(var i=_c;(i<_8.length)&&(i<_d);++i){
var _f=_8[i];
if(!_b){
_9.onItem.call(_e,_f,_9);
}
}
}
if(_9.onComplete&&!_b){
var _10=null;
if(!_9.onItem){
_10=_8.slice(_c,_d);
}
_9.onComplete.call(_e,_10,_9);
}
};
this._fetchItems(_1,_7,_3);
return _1;
};
}