root / trunk / web / dojo / dojox / wire / ml / Transfer.js
History | View | Annotate | Download (3.54 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.ml.Transfer"]){ |
9 |
dojo._hasResource["dojox.wire.ml.Transfer"]=true; |
10 |
dojo.provide("dojox.wire.ml.Transfer");
|
11 |
dojo.provide("dojox.wire.ml.ChildWire");
|
12 |
dojo.provide("dojox.wire.ml.ColumnWire");
|
13 |
dojo.provide("dojox.wire.ml.NodeWire");
|
14 |
dojo.provide("dojox.wire.ml.SegmentWire");
|
15 |
dojo.require("dijit._Widget");
|
16 |
dojo.require("dijit._Container");
|
17 |
dojo.require("dojox.wire._base");
|
18 |
dojo.require("dojox.wire.ml.Action");
|
19 |
dojo.declare("dojox.wire.ml.Transfer",dojox.wire.ml.Action,{source:"",sourceStore:"",sourceAttribute:"",sourcePath:"",type:"",converter:"",delimiter:"",target:"",targetStore:"",targetAttribute:"",targetPath:"",_run:function(){ |
20 |
var _1=this._getWire("source"); |
21 |
var _2=this._getWire("target"); |
22 |
dojox.wire.transfer(_1,_2,arguments);
|
23 |
},_getWire:function(_3){ |
24 |
var _4=undefined; |
25 |
if(_3=="source"){ |
26 |
_4={object:this.source,dataStore:this.sourceStore,attribute:this.sourceAttribute,path:this.sourcePath,type:this.type,converter:this.converter}; |
27 |
}else{
|
28 |
_4={object:this.target,dataStore:this.targetStore,attribute:this.targetAttribute,path:this.targetPath}; |
29 |
} |
30 |
if(_4.object){
|
31 |
if(_4.object.length>=9&&_4.object.substring(0,9)=="arguments"){ |
32 |
_4.property=_4.object.substring(9);
|
33 |
_4.object=null;
|
34 |
}else{
|
35 |
var i=_4.object.indexOf("."); |
36 |
if(i<0){ |
37 |
_4.object=dojox.wire.ml._getValue(_4.object); |
38 |
}else{
|
39 |
_4.property=_4.object.substring(i+1);
|
40 |
_4.object=dojox.wire.ml._getValue(_4.object.substring(0,i));
|
41 |
} |
42 |
} |
43 |
} |
44 |
if(_4.dataStore){
|
45 |
_4.dataStore=dojox.wire.ml._getValue(_4.dataStore); |
46 |
} |
47 |
var _5=undefined; |
48 |
var _6=this.getChildren(); |
49 |
for(var i in _6){ |
50 |
var _7=_6[i];
|
51 |
if(_7 instanceof dojox.wire.ml.ChildWire&&_7.which==_3){ |
52 |
if(!_5){
|
53 |
_5={}; |
54 |
} |
55 |
_7._addWire(this,_5);
|
56 |
} |
57 |
} |
58 |
if(_5){
|
59 |
_5.object=dojox.wire.create(_4); |
60 |
_5.dataStore=_4.dataStore; |
61 |
_4=_5; |
62 |
} |
63 |
return _4;
|
64 |
}}); |
65 |
dojo.declare("dojox.wire.ml.ChildWire",dijit._Widget,{which:"source",object:"",property:"",type:"",converter:"",attribute:"",path:"",name:"",_addWire:function(_8,_9){ |
66 |
if(this.name){ |
67 |
if(!_9.children){
|
68 |
_9.children={}; |
69 |
} |
70 |
_9.children[this.name]=this._getWire(_8); |
71 |
}else{
|
72 |
if(!_9.children){
|
73 |
_9.children=[]; |
74 |
} |
75 |
_9.children.push(this._getWire(_8));
|
76 |
} |
77 |
},_getWire:function(_a){ |
78 |
return {object:(this.object?dojox.wire.ml._getValue(this.object):undefined),property:this.property,type:this.type,converter:this.converter,attribute:this.attribute,path:this.path}; |
79 |
}}); |
80 |
dojo.declare("dojox.wire.ml.ColumnWire",dojox.wire.ml.ChildWire,{column:"",_addWire:function(_b,_c){ |
81 |
if(this.column){ |
82 |
if(!_c.columns){
|
83 |
_c.columns={}; |
84 |
} |
85 |
_c.columns[this.column]=this._getWire(_b); |
86 |
}else{
|
87 |
if(!_c.columns){
|
88 |
_c.columns=[]; |
89 |
} |
90 |
_c.columns.push(this._getWire(_b));
|
91 |
} |
92 |
}}); |
93 |
dojo.declare("dojox.wire.ml.NodeWire",[dojox.wire.ml.ChildWire,dijit._Container],{titleProperty:"",titleAttribute:"",titlePath:"",_addWire:function(_d,_e){ |
94 |
if(!_e.nodes){
|
95 |
_e.nodes=[]; |
96 |
} |
97 |
_e.nodes.push(this._getWires(_d));
|
98 |
},_getWires:function(_f){ |
99 |
var _10={node:this._getWire(_f),title:{type:"string",property:this.titleProperty,attribute:this.titleAttribute,path:this.titlePath}}; |
100 |
var _11=[];
|
101 |
var _12=this.getChildren(); |
102 |
for(var i in _12){ |
103 |
var _13=_12[i];
|
104 |
if(_13 instanceof dojox.wire.ml.NodeWire){ |
105 |
_11.push(_13._getWires(_f)); |
106 |
} |
107 |
} |
108 |
if(_11.length>0){ |
109 |
_10.children=_11; |
110 |
} |
111 |
return _10;
|
112 |
}}); |
113 |
dojo.declare("dojox.wire.ml.SegmentWire",dojox.wire.ml.ChildWire,{_addWire:function(_14,_15){ |
114 |
if(!_15.segments){
|
115 |
_15.segments=[]; |
116 |
} |
117 |
_15.segments.push(this._getWire(_14));
|
118 |
if(_14.delimiter&&!_15.delimiter){
|
119 |
_15.delimiter=_14.delimiter; |
120 |
} |
121 |
}}); |
122 |
} |