Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / wire / TreeAdapter.js @ 10

History | View | Annotate | Download (1.64 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.TreeAdapter"]){
9
dojo._hasResource["dojox.wire.TreeAdapter"]=true;
10
dojo.provide("dojox.wire.TreeAdapter");
11
dojo.require("dojox.wire.CompositeWire");
12
dojo.declare("dojox.wire.TreeAdapter",dojox.wire.CompositeWire,{_wireClass:"dojox.wire.TreeAdapter",constructor:function(_1){
13
this._initializeChildren(this.nodes);
14
},_getValue:function(_2){
15
if(!_2||!this.nodes){
16
return _2;
17
}
18
var _3=_2;
19
if(!dojo.isArray(_3)){
20
_3=[_3];
21
}
22
var _4=[];
23
for(var i in _3){
24
for(var i2 in this.nodes){
25
_4=_4.concat(this._getNodes(_3[i],this.nodes[i2]));
26
}
27
}
28
return _4;
29
},_setValue:function(_5,_6){
30
throw new Error("Unsupported API: "+this._wireClass+"._setValue");
31
},_initializeChildren:function(_7){
32
if(!_7){
33
return;
34
}
35
for(var i in _7){
36
var _8=_7[i];
37
if(_8.node){
38
_8.node.parent=this;
39
if(!dojox.wire.isWire(_8.node)){
40
_8.node=dojox.wire.create(_8.node);
41
}
42
}
43
if(_8.title){
44
_8.title.parent=this;
45
if(!dojox.wire.isWire(_8.title)){
46
_8.title=dojox.wire.create(_8.title);
47
}
48
}
49
if(_8.children){
50
this._initializeChildren(_8.children);
51
}
52
}
53
},_getNodes:function(_9,_a){
54
var _b=null;
55
if(_a.node){
56
_b=_a.node.getValue(_9);
57
if(!_b){
58
return [];
59
}
60
if(!dojo.isArray(_b)){
61
_b=[_b];
62
}
63
}else{
64
_b=[_9];
65
}
66
var _c=[];
67
for(var i in _b){
68
_9=_b[i];
69
var _d={};
70
if(_a.title){
71
_d.title=_a.title.getValue(_9);
72
}else{
73
_d.title=_9;
74
}
75
if(_a.children){
76
var _e=[];
77
for(var i2 in _a.children){
78
_e=_e.concat(this._getNodes(_9,_a.children[i2]));
79
}
80
if(_e.length>0){
81
_d.children=_e;
82
}
83
}
84
_c.push(_d);
85
}
86
return _c;
87
}});
88
}