-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSystem.Web.UI.TreeView.debug.js
More file actions
315 lines (303 loc) · 12.3 KB
/
System.Web.UI.TreeView.debug.js
File metadata and controls
315 lines (303 loc) · 12.3 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
//=============================================================================
// Jocys.com JavaScript.NET Classes (In C# Object Oriented Style)
// Created by Evaldas Jocys <evaldas@jocys.com>
//=============================================================================
/// <reference path="System.debug.js" />
//=============================================================================
// Namespaces
//-----------------------------------------------------------------------------
// <PropertyGroup>
// <RootNamespace>System.Web.UI</RootNamespace>
// <PropertyGroup>
//-----------------------------------------------------------------------------
System.Type.RegisterNamespace("System.Web.UI");
//=============================================================================
/***************************************************************
* (c) 2003-2004 Jean-Michel Garnier (garnierjm@yahoo.fr)
* (c) 2005-2006 Evaldas Jocys (evaldas@jocys.com)
* All rights reserved
*
* This script is part of the phpXplorer project. The phpXplorer project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt distributed with these scripts.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
// ---------------------------------------------------------------------------
// --- Name: Easy DHTML Treeview --
// --- Original idea by : D.D. de Kerf --
// --- Updated by Jean-Michel Garnier, garnierjm@yahoo.fr --
// --- Updated by Evaldas Jocys, evaldas@jocys.com --
// ---------------------------------------------------------------------------
//=============================================================================
// CLASS: System.Web.UI.TreeView
//-----------------------------------------------------------------------------
// XHTML = XML + (XSLT + CSS + JS)
System.Web.UI.TreeView = function (target, id, pathToScripts) {
//---------------------------------------------------------
// Public properties.
//---------------------------------------------------------
this.DataSource = "";
this.Node;
this.Processor;
this.Xsl = null;
this.Xml = null;
//---------------------------------------------------------
// Private properties.
//---------------------------------------------------------
var me = this;
//---------------------------------------------------------
// EVENTS: public
//---------------------------------------------------------
this.RiseEvent = function (e) { if (this[e.Name]) this[e.Name](this, e); };
//---------------------------------------------------------
this.OnInit;
this.OnDataBound;
//---------------------------------------------------------
// METHOD: DataBind
//---------------------------------------------------------
this.DataBind = function () {
this.Node = this.Processor.TransformToNode();
};
//---------------------------------------------------------
// METHOD: GetParam
//---------------------------------------------------------
this.GetParam = function (key) {
var path = "child::*//xsl:param[@name='" + key + "']/@select";
var s = this.Xsl.selectSingleNode(path);
return s.value;
};
//---------------------------------------------------------
// METHOD: SetParam
//---------------------------------------------------------
this.SetParam = function (key, value) {
var path = "child::*//xsl:param[@name='" + key + "']/@select";
var s = this.Xsl.selectSingleNode(path);
s.value = value;
};
//---------------------------------------------------------
// METHOD: InitializeInterface
//---------------------------------------------------------
this.InitializeInterface = function (sender, e) {
var path = pathToScripts ? pathToScripts : "../../Scripts/Classes/System.Web.UI.TreeView";
var pathToXsl = path + "/System.Web.UI.TreeView.xsl";
var pathToXml = path + "/System.Web.UI.TreeView.xml";
this.Xsl = new System.Xml.XslTemplate(pathToXsl);
this.Xml = new System.Xml.XmlDocument(pathToXml);
this.Processor = new System.Xml.XslProcessor(this.Xml, this.Xsl);
this.Node = this.Processor.TransformToNode();
};
//---------------------------------------------------------
// METHOD: InitializeEvents
//---------------------------------------------------------
this.InitializeEvents = function (sender, e) {
};
//---------------------------------------------------------
// INIT: Class
//---------------------------------------------------------
this.InitializeClass = function () {
// Set submited values or default values.
this.Target = target ? target : document;
this.id = id ? id : null;
// Initialize interface.
this.InitializeInterface(this, null);
// Initialize events.
this.InitializeEvents(this, null);
// Rise init event.
this.RiseEvent(new System.EventArgs("OnInit"));
};
this.InitializeClass();
};
System.Web.UI.TreeView.Toggle = function (node) {
// Get the next tag (read the HTML source)
var nextDIV = node.nextSibling;
// find the next DIV
while (nextDIV.nodeName !== "DIV") {
nextDIV = nextDIV.nextSibling;
}
// Unfold the branch if it isn't visible
if (nextDIV.style.display === 'none') {
// Change the image (if there is an image)
if (node.childNodes.length > 0) {
if (node.childNodes.item(0).nodeName === "IMG") {
node.childNodes.item(0).src = System.Web.UI.TreeView.getImagesDirectory(node.childNodes.item(0).src) + "minus.gif";
}
}
nextDIV.style.display = 'block';
}
// Collapse the branch if it IS visible
else {
// Change the image (if there is an image)
if (node.childNodes.length > 0) {
if (node.childNodes.item(0).nodeName === "IMG") {
node.childNodes.item(0).src = System.Web.UI.TreeView.getImagesDirectory(node.childNodes.item(0).src) + "plus.gif";
}
}
nextDIV.style.display = 'none';
}
};
System.Web.UI.TreeView.getImagesDirectory = function (source) {
return source.substring(0, source.lastIndexOf('/') + 1);
};
System.Web.UI.TreeView.Item = function (id, target, type, icon, name, value) {
//---------------------------------------------------------
// Public properties.
//---------------------------------------------------------
this.Node;
this.ContainerNode;
this.Item;
this.ItemType = ""; // "Folder" of "File"
//---------------------------------------------------------
// Private properties.
//---------------------------------------------------------
var me = this;
var pfx = "TW_";
//---------------------------------------------------------
// INIT: Interface
//---------------------------------------------------------
this.InitializeInterface = function (sender, e) {
this.Node = this.Target.createElement("div");
this.Node.className = pfx + this.ItemType;
this.Item = new System.Web.UI.TreeView.ItemTable(id, this.Target);
this.Item.SetName(name);
this.Item.SetValue(value);
this.Node.appendChild(this.Item.Node);
switch (this.ItemType) {
case "File":
this.Item.SetIcon("/Images/Icons/Favorites.16x16.png");
break;
case "Folder":
this.Item.SetIcon("/Scripts/Classes/System.Web.UI.TreeView/Images/Icons/Folder_false-16x16.png");
// Add children node;
this.ContainerNode = this.Target.createElement("div");
this.ContainerNode.className = pfx + "Container";
this.Node.appendChild(this.ContainerNode);
break;
default:
}
};
//---------------------------------------------------------
// INIT: Events
//---------------------------------------------------------
this.InitializeEvents = function (sender, e) {
};
//---------------------------------------------------------
// INIT: Class
//---------------------------------------------------------
this.InitializeClass = function () {
// Set submited values or default values.
this.id = id ? id : null;
this.Target = target ? target : document;
this.ItemType = type ? type : "file";
this.InitializeInterface(this, null);
//this.InitializeEvents(this,null);
};
this.InitializeClass();
};
System.Web.UI.TreeView.ItemTable = function (id, target, icon, name, value) {
//---------------------------------------------------------
// Public properties.
//---------------------------------------------------------
this.Node;
this.Table;
this.IdentCell;
this.IdentImage;
this.IconCell;
this.IconImage;
this.NameCell;
this.NameLabel;
this.ValueCell;
this.ValueLabel;
//---------------------------------------------------------
// Private properties.
//---------------------------------------------------------
var me = this;
var pfx = "TW_";
//---------------------------------------------------------
// METHOD: SetName
//---------------------------------------------------------
this.SetName = function (name) {
this.NameLabel.innerHTML = name;
};
//---------------------------------------------------------
// METHOD: SetIcon
//---------------------------------------------------------
this.SetIcon = function (path) {
this.IconImage.src = path;
};
//---------------------------------------------------------
// METHOD: SetValue
//---------------------------------------------------------
this.SetValue = function (value) {
var vs = new String(value.length);
if (vs.length > 0) {
this.ValueLabel.innerHTML = "[" + value + "]";
} else {
this.ValueLabel.innerHTML = "";
}
};
//---------------------------------------------------------
// INIT: Interface
//---------------------------------------------------------
this.InitializeInterface = function (sender, e) {
this.Table = this.Target.createElement("table");
this.Node = this.Table;
this.IdentCell = this.Target.createElement("td");
this.IdentImage = this.Target.createElement("img");
this.IconCell = this.Target.createElement("td");
this.IconImage = this.Target.createElement("img");
this.NameCell = this.Target.createElement("td");
this.NameLabel = this.Target.createElement("div");
this.ValueCell = this.Target.createElement("td");
this.ValueLabel = this.Target.createElement("div");
var tbody = this.Target.createElement("tbody");
var row = this.Target.createElement("tr");
// Append nodes.
this.Table.appendChild(tbody);
tbody.appendChild(row);
row.appendChild(this.IdentCell);
row.appendChild(this.IconCell);
row.appendChild(this.NameCell);
row.appendChild(this.ValueCell);
this.IdentCell.appendChild(this.IdentImage);
this.IconCell.appendChild(this.IconImage);
this.NameCell.appendChild(this.NameLabel);
this.ValueCell.appendChild(this.ValueLabel);
this.IdentImage.src = "http://css/WebResource.axd?d=wZvkaPHHbK_MFQNJMEK-ikdzGXF7hA8ZnzSegLIvkd01&t=632805362451875000";
// Set styles.
this.IdentCell.className = pfx + "Cell_Ident";
this.IconCell.className = pfx + "Cell_Icon";
this.NameCell.className = pfx + "Cell_Name";
this.ValueCell.className = pfx + "Cell_Value";
};
//---------------------------------------------------------
// INIT: Events
//---------------------------------------------------------
this.InitializeEvents = function (sender, e) {
};
//---------------------------------------------------------
// INIT: Class
//---------------------------------------------------------
this.InitializeClass = function () {
// Set submited values or default values.
this.id = id ? id : null;
this.Target = target ? target : document;
this.InitializeInterface(this, null);
this.InitializeEvents(this, null);
};
this.InitializeClass();
};
//==============================================================================
// END
//------------------------------------------------------------------------------