1
|
/*
|
2
|
Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
|
3
|
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4
|
see: http://dojotoolkit.org/license for details
|
5
|
*/
|
6
|
|
7
|
|
8
|
if(!dojo._hasResource["dojo.behavior"]){
|
9
|
dojo._hasResource["dojo.behavior"]=true;
|
10
|
dojo.provide("dojo.behavior");
|
11
|
dojo.behavior=new function(){
|
12
|
function arrIn(_1,_2){
|
13
|
if(!_1[_2]){
|
14
|
_1[_2]=[];
|
15
|
}
|
16
|
return _1[_2];
|
17
|
};
|
18
|
var _3=0;
|
19
|
function forIn(_4,_5,_6){
|
20
|
var _7={};
|
21
|
for(var x in _4){
|
22
|
if(typeof _7[x]=="undefined"){
|
23
|
if(!_6){
|
24
|
_5(_4[x],x);
|
25
|
}else{
|
26
|
_6.call(_5,_4[x],x);
|
27
|
}
|
28
|
}
|
29
|
}
|
30
|
};
|
31
|
this._behaviors={};
|
32
|
this.add=function(_9){
|
33
|
var _a={};
|
34
|
forIn(_9,this,function(_b,_c){
|
35
|
var _d=arrIn(this._behaviors,_c);
|
36
|
if(typeof _d["id"]!="number"){
|
37
|
_d.id=_3++;
|
38
|
}
|
39
|
var _e=[];
|
40
|
_d.push(_e);
|
41
|
if((dojo.isString(_b))||(dojo.isFunction(_b))){
|
42
|
_b={found:_b};
|
43
|
}
|
44
|
forIn(_b,function(_f,_10){
|
45
|
arrIn(_e,_10).push(_f);
|
46
|
});
|
47
|
});
|
48
|
};
|
49
|
var _11=function(_12,_13,_14){
|
50
|
if(dojo.isString(_13)){
|
51
|
if(_14=="found"){
|
52
|
dojo.publish(_13,[_12]);
|
53
|
}else{
|
54
|
dojo.connect(_12,_14,function(){
|
55
|
dojo.publish(_13,arguments);
|
56
|
});
|
57
|
}
|
58
|
}else{
|
59
|
if(dojo.isFunction(_13)){
|
60
|
if(_14=="found"){
|
61
|
_13(_12);
|
62
|
}else{
|
63
|
dojo.connect(_12,_14,_13);
|
64
|
}
|
65
|
}
|
66
|
}
|
67
|
};
|
68
|
this.apply=function(){
|
69
|
forIn(this._behaviors,function(_15,id){
|
70
|
dojo.query(id).forEach(function(_17){
|
71
|
var _18=0;
|
72
|
var bid="_dj_behavior_"+_15.id;
|
73
|
if(typeof _17[bid]=="number"){
|
74
|
_18=_17[bid];
|
75
|
if(_18==(_15.length)){
|
76
|
return;
|
77
|
}
|
78
|
}
|
79
|
for(var x=_18,_1b;_1b=_15[x];x++){
|
80
|
forIn(_1b,function(_1c,_1d){
|
81
|
if(dojo.isArray(_1c)){
|
82
|
dojo.forEach(_1c,function(_1e){
|
83
|
_11(_17,_1e,_1d);
|
84
|
});
|
85
|
}
|
86
|
});
|
87
|
}
|
88
|
_17[bid]=_15.length;
|
89
|
});
|
90
|
});
|
91
|
};
|
92
|
};
|
93
|
dojo.addOnLoad(dojo.behavior,"apply");
|
94
|
}
|