root / trunk / web / dojo / dojox / wire / _base.js @ 10
History | View | Annotate | Download (2.08 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, 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["dojox.wire._base"]){ |
9 |
dojo._hasResource["dojox.wire._base"]=true; |
10 |
dojo.provide("dojox.wire._base");
|
11 |
dojox.wire._defaultWireClass="dojox.wire.Wire";
|
12 |
dojox.wire._wireClasses={"attribute":"dojox.wire.DataWire","path":"dojox.wire.XmlWire","children":"dojox.wire.CompositeWire","columns":"dojox.wire.TableAdapter","nodes":"dojox.wire.TreeAdapter","segments":"dojox.wire.TextAdapter"}; |
13 |
dojox.wire.register=function(_1,_2){ |
14 |
if(!_1||!_2){
|
15 |
return;
|
16 |
} |
17 |
if(dojox.wire._wireClasses[_2]){
|
18 |
return;
|
19 |
} |
20 |
dojox.wire._wireClasses[_2]=_1; |
21 |
}; |
22 |
dojox.wire._getClass=function(_3){ |
23 |
dojo["require"](_3);
|
24 |
return dojo.getObject(_3);
|
25 |
}; |
26 |
dojox.wire.create=function(_4){ |
27 |
if(!_4){
|
28 |
_4={}; |
29 |
} |
30 |
var _5=_4.wireClass;
|
31 |
if(_5){
|
32 |
if(dojo.isString(_5)){
|
33 |
_5=dojox.wire._getClass(_5); |
34 |
} |
35 |
}else{
|
36 |
for(var _6 in _4){ |
37 |
if(!_4[_6]){
|
38 |
continue;
|
39 |
} |
40 |
_5=dojox.wire._wireClasses[_6]; |
41 |
if(_5){
|
42 |
if(dojo.isString(_5)){
|
43 |
_5=dojox.wire._getClass(_5); |
44 |
dojox.wire._wireClasses[_6]=_5; |
45 |
} |
46 |
break;
|
47 |
} |
48 |
} |
49 |
} |
50 |
if(!_5){
|
51 |
if(dojo.isString(dojox.wire._defaultWireClass)){
|
52 |
dojox.wire._defaultWireClass=dojox.wire._getClass(dojox.wire._defaultWireClass); |
53 |
} |
54 |
_5=dojox.wire._defaultWireClass; |
55 |
} |
56 |
return new _5(_4); |
57 |
}; |
58 |
dojox.wire.isWire=function(_7){ |
59 |
return (_7&&_7._wireClass);
|
60 |
}; |
61 |
dojox.wire.transfer=function(_8,_9,_a,_b){ |
62 |
if(!_8||!_9){
|
63 |
return;
|
64 |
} |
65 |
if(!dojox.wire.isWire(_8)){
|
66 |
_8=dojox.wire.create(_8); |
67 |
} |
68 |
if(!dojox.wire.isWire(_9)){
|
69 |
_9=dojox.wire.create(_9); |
70 |
} |
71 |
var _c=_8.getValue(_a);
|
72 |
_9.setValue(_c,(_b||_a)); |
73 |
}; |
74 |
dojox.wire.connect=function(_d,_e,_f){ |
75 |
if(!_d||!_e||!_f){
|
76 |
return;
|
77 |
} |
78 |
var _10={topic:_d.topic}; |
79 |
if(_d.topic){
|
80 |
_10.handle=dojo.subscribe(_d.topic,function(){
|
81 |
dojox.wire.transfer(_e,_f,arguments);
|
82 |
}); |
83 |
}else{
|
84 |
if(_d.event){
|
85 |
_10.handle=dojo.connect(_d.scope,_d.event,function(){
|
86 |
dojox.wire.transfer(_e,_f,arguments);
|
87 |
}); |
88 |
} |
89 |
} |
90 |
return _10;
|
91 |
}; |
92 |
dojox.wire.disconnect=function(_11){ |
93 |
if(!_11||!_11.handle){
|
94 |
return;
|
95 |
} |
96 |
if(_11.topic){
|
97 |
dojo.unsubscribe(_11.handle); |
98 |
}else{
|
99 |
dojo.disconnect(_11.handle); |
100 |
} |
101 |
}; |
102 |
} |