fuelux.tree-sample-demo-data.js
7.29 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
var DataSourceTree = function(options) {
this._data = options.data;
this._delay = options.delay;
}
DataSourceTree.prototype.data = function(options, callback) {
var self = this;
var $data = null;
if(!("name" in options) && !("type" in options)){
$data = this._data;//the root tree
callback({ data: $data });
return;
}
else if("type" in options && options.type == "folder") {
if("additionalParameters" in options && "children" in options.additionalParameters)
$data = options.additionalParameters.children;
else $data = {}//no data
}
if($data != null)//this setTimeout is only for mimicking some random delay
setTimeout(function(){callback({ data: $data });} , parseInt(Math.random() * 500) + 200);
//we have used static data here
//but you can retrieve your data dynamically from a server using ajax call
//checkout examples/treeview.html and examples/treeview.js for more info
};
var tree_data = {
'for-sale' : {name: 'For Sale', type: 'folder'} ,
'vehicles' : {name: 'Vehicles', type: 'folder'} ,
'rentals' : {name: 'Rentals', type: 'folder'} ,
'real-estate' : {name: 'Real Estate', type: 'folder'} ,
'pets' : {name: 'Pets', type: 'folder'} ,
'tickets' : {name: 'Tickets', type: 'item'} ,
'services' : {name: 'Services', type: 'item'} ,
'personals' : {name: 'Personals', type: 'item'}
}
tree_data['for-sale']['additionalParameters'] = {
'children' : {
'appliances' : {name: 'Appliances', type: 'item'},
'arts-crafts' : {name: 'Arts & Crafts', type: 'item'},
'clothing' : {name: 'Clothing', type: 'item'},
'computers' : {name: 'Computers', type: 'item'},
'jewelry' : {name: 'Jewelry', type: 'item'},
'office-business' : {name: 'Office & Business', type: 'item'},
'sports-fitness' : {name: 'Sports & Fitness', type: 'item'}
}
}
tree_data['vehicles']['additionalParameters'] = {
'children' : {
'cars' : {name: 'Cars', type: 'folder'},
'motorcycles' : {name: 'Motorcycles', type: 'item'},
'boats' : {name: 'Boats', type: 'item'}
}
}
tree_data['vehicles']['additionalParameters']['children']['cars']['additionalParameters'] = {
'children' : {
'classics' : {name: 'Classics', type: 'item'},
'convertibles' : {name: 'Convertibles', type: 'item'},
'coupes' : {name: 'Coupes', type: 'item'},
'hatchbacks' : {name: 'Hatchbacks', type: 'item'},
'hybrids' : {name: 'Hybrids', type: 'item'},
'suvs' : {name: 'SUVs', type: 'item'},
'sedans' : {name: 'Sedans', type: 'item'},
'trucks' : {name: 'Trucks', type: 'item'}
}
}
tree_data['rentals']['additionalParameters'] = {
'children' : {
'apartments-rentals' : {name: 'Apartments', type: 'item'},
'office-space-rentals' : {name: 'Office Space', type: 'item'},
'vacation-rentals' : {name: 'Vacation Rentals', type: 'item'}
}
}
tree_data['real-estate']['additionalParameters'] = {
'children' : {
'apartments' : {name: 'Apartments', type: 'item'},
'villas' : {name: 'Villas', type: 'item'},
'plots' : {name: 'Plots', type: 'item'}
}
}
tree_data['pets']['additionalParameters'] = {
'children' : {
'cats' : {name: 'Cats', type: 'item'},
'dogs' : {name: 'Dogs', type: 'item'},
'horses' : {name: 'Horses', type: 'item'},
'reptiles' : {name: 'Reptiles', type: 'item'}
}
}
var treeDataSource = new DataSourceTree({data: tree_data});
var ace_icon = ace.vars['icon'];
//class="'+ace_icon+' fa fa-file-text grey"
//becomes
//class="ace-icon fa fa-file-text grey"
var tree_data_2 = {
'pictures' : {name: 'Pictures', type: 'folder', 'icon-class':'red'} ,
'music' : {name: 'Music', type: 'folder', 'icon-class':'orange'} ,
'video' : {name: 'Video', type: 'folder', 'icon-class':'blue'} ,
'documents' : {name: 'Documents', type: 'folder', 'icon-class':'green'} ,
'backup' : {name: 'Backup', type: 'folder'} ,
'readme' : {name: '<i class="'+ace_icon+' fa fa-file-text grey"></i> ReadMe.txt', type: 'item'},
'manual' : {name: '<i class="'+ace_icon+' fa fa-book blue"></i> Manual.html', type: 'item'}
}
tree_data_2['music']['additionalParameters'] = {
'children' : [
{name: '<i class="'+ace_icon+' fa fa-music blue"></i> song1.ogg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-music blue"></i> song2.ogg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-music blue"></i> song3.ogg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-music blue"></i> song4.ogg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-music blue"></i> song5.ogg', type: 'item'}
]
}
tree_data_2['video']['additionalParameters'] = {
'children' : [
{name: '<i class="'+ace_icon+' fa fa-film blue"></i> movie1.avi', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-film blue"></i> movie2.avi', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-film blue"></i> movie3.avi', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-film blue"></i> movie4.avi', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-film blue"></i> movie5.avi', type: 'item'}
]
}
tree_data_2['pictures']['additionalParameters'] = {
'children' : {
'wallpapers' : {name: 'Wallpapers', type: 'folder', 'icon-class':'pink'},
'camera' : {name: 'Camera', type: 'folder', 'icon-class':'pink'}
}
}
tree_data_2['pictures']['additionalParameters']['children']['wallpapers']['additionalParameters'] = {
'children' : [
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> wallpaper1.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> wallpaper2.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> wallpaper3.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> wallpaper4.jpg', type: 'item'}
]
}
tree_data_2['pictures']['additionalParameters']['children']['camera']['additionalParameters'] = {
'children' : [
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> photo1.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> photo2.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> photo3.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> photo4.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> photo5.jpg', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-picture-o green"></i> photo6.jpg', type: 'item'}
]
}
tree_data_2['documents']['additionalParameters'] = {
'children' : [
{name: '<i class="'+ace_icon+' fa fa-file-text red"></i> document1.pdf', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-file-text grey"></i> document2.doc', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-file-text grey"></i> document3.doc', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-file-text red"></i> document4.pdf', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-file-text grey"></i> document5.doc', type: 'item'}
]
}
tree_data_2['backup']['additionalParameters'] = {
'children' : [
{name: '<i class="'+ace_icon+' fa fa-archive brown"></i> backup1.zip', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-archive brown"></i> backup2.zip', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-archive brown"></i> backup3.zip', type: 'item'},
{name: '<i class="'+ace_icon+' fa fa-archive brown"></i> backup4.zip', type: 'item'}
]
}
var treeDataSource2 = new DataSourceTree({data: tree_data_2});