Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.widget.TreeNodeV3");
13
dojo.provide("dojo.widget.TreeNodeV3");
12
dojo.require("dojo.html.*");
14
dojo.require("dojo.html.*");
13
dojo.require("dojo.event.*");
15
dojo.require("dojo.event.*");
14
dojo.require("dojo.io.*");
16
dojo.require("dojo.io.*");
15
dojo.require("dojo.widget.TreeWithNode");
17
dojo.require("dojo.widget.TreeWithNode");
16
dojo.widget.defineWidget("dojo.widget.TreeNodeV3", [dojo.widget.HtmlWidget, dojo.widget.TreeWithNode], function () {
18
dojo.widget.defineWidget("dojo.widget.TreeNodeV3", [dojo.widget.HtmlWidget, dojo.widget.TreeWithNode], function () {
17
	this.actionsDisabled = [];
19
	this.actionsDisabled = [];
18
	this.object = {};
20
	this.object = {};
19
}, {tryLazyInit:true, actions:{MOVE:"MOVE", DETACH:"DETACH", EDIT:"EDIT", ADDCHILD:"ADDCHILD", SELECT:"SELECT"}, labelClass:"", contentClass:"", expandNode:null, labelNode:null, nodeDocType:"", selected:false, getnodeDocType:function () {
21
}, {tryLazyInit:true, actions:{MOVE:"MOVE", DETACH:"DETACH", EDIT:"EDIT", ADDCHILD:"ADDCHILD", SELECT:"SELECT"}, labelClass:"", contentClass:"", expandNode:null, labelNode:null, nodeDocType:"", selected:false, getnodeDocType:function () {
20
	return this.nodeDocType;
22
	return this.nodeDocType;
21
}, cloneProperties:["actionsDisabled", "tryLazyInit", "nodeDocType", "objectId", "object", "title", "isFolder", "isExpanded", "state"], clone:function (deep) {
23
}, cloneProperties:["actionsDisabled", "tryLazyInit", "nodeDocType", "objectId", "object", "title", "isFolder", "isExpanded", "state"], clone:function (deep) {
22
	var ret = new this.constructor();
24
	var ret = new this.constructor();
23
	for (var i = 0; i < this.cloneProperties.length; i++) {
25
	for (var i = 0; i < this.cloneProperties.length; i++) {
24
		var prop = this.cloneProperties[i];
26
		var prop = this.cloneProperties[i];
25
		ret[prop] = dojo.lang.shallowCopy(this[prop], true);
27
		ret[prop] = dojo.lang.shallowCopy(this[prop], true);
26
	}
28
	}
27
	if (this.tree.unsetFolderOnEmpty && !deep && this.isFolder) {
29
	if (this.tree.unsetFolderOnEmpty && !deep && this.isFolder) {
28
		ret.isFolder = false;
30
		ret.isFolder = false;
29
	}
31
	}
30
	ret.toggleObj = this.toggleObj;
32
	ret.toggleObj = this.toggleObj;
31
	dojo.widget.manager.add(ret);
33
	dojo.widget.manager.add(ret);
32
	ret.tree = this.tree;
34
	ret.tree = this.tree;
33
	ret.buildRendering({}, {});
35
	ret.buildRendering({}, {});
34
	ret.initialize({}, {});
36
	ret.initialize({}, {});
35
	if (deep && this.children.length) {
37
	if (deep && this.children.length) {
36
		for (var i = 0; i < this.children.length; i++) {
38
		for (var i = 0; i < this.children.length; i++) {
37
			var child = this.children[i];
39
			var child = this.children[i];
38
			if (child.clone) {
40
			if (child.clone) {
39
				ret.children.push(child.clone(deep));
41
				ret.children.push(child.clone(deep));
40
			} else {
42
			} else {
41
				ret.children.push(dojo.lang.shallowCopy(child, deep));
43
				ret.children.push(dojo.lang.shallowCopy(child, deep));
42
			}
44
			}
43
		}
45
		}
44
		ret.setChildren();
46
		ret.setChildren();
45
	}
47
	}
46
	return ret;
48
	return ret;
47
}, markProcessing:function () {
49
}, markProcessing:function () {
48
	this.markProcessingSavedClass = dojo.html.getClass(this.expandNode);
50
	this.markProcessingSavedClass = dojo.html.getClass(this.expandNode);
49
	dojo.html.setClass(this.expandNode, this.tree.classPrefix + "ExpandLoading");
51
	dojo.html.setClass(this.expandNode, this.tree.classPrefix + "ExpandLoading");
50
}, unmarkProcessing:function () {
52
}, unmarkProcessing:function () {
51
	dojo.html.setClass(this.expandNode, this.markProcessingSavedClass);
53
	dojo.html.setClass(this.expandNode, this.markProcessingSavedClass);
52
}, buildRendering:function (args, fragment, parent) {
54
}, buildRendering:function (args, fragment, parent) {
53
	if (args.tree) {
55
	if (args.tree) {
54
		this.tree = dojo.lang.isString(args.tree) ? dojo.widget.manager.getWidgetById(args.tree) : args.tree;
56
		this.tree = dojo.lang.isString(args.tree) ? dojo.widget.manager.getWidgetById(args.tree) : args.tree;
55
	} else {
57
	} else {
56
		if (parent && parent.tree) {
58
		if (parent && parent.tree) {
57
			this.tree = parent.tree;
59
			this.tree = parent.tree;
58
		}
60
		}
59
	}
61
	}
60
	if (!this.tree) {
62
	if (!this.tree) {
61
		dojo.raise("Can't evaluate tree from arguments or parent");
63
		dojo.raise("Can't evaluate tree from arguments or parent");
62
	}
64
	}
63
	this.domNode = this.tree.nodeTemplate.cloneNode(true);
65
	this.domNode = this.tree.nodeTemplate.cloneNode(true);
64
	this.expandNode = this.domNode.firstChild;
66
	this.expandNode = this.domNode.firstChild;
65
	this.contentNode = this.domNode.childNodes[1];
67
	this.contentNode = this.domNode.childNodes[1];
66
	this.labelNode = this.contentNode.firstChild;
68
	this.labelNode = this.contentNode.firstChild;
67
	if (this.labelClass) {
69
	if (this.labelClass) {
68
		dojo.html.addClass(this.labelNode, this.labelClass);
70
		dojo.html.addClass(this.labelNode, this.labelClass);
69
	}
71
	}
70
	if (this.contentClass) {
72
	if (this.contentClass) {
71
		dojo.html.addClass(this.contentNode, this.contentClass);
73
		dojo.html.addClass(this.contentNode, this.contentClass);
72
	}
74
	}
73
	this.domNode.widgetId = this.widgetId;
75
	this.domNode.widgetId = this.widgetId;
74
	this.labelNode.innerHTML = this.title;
76
	this.labelNode.innerHTML = this.title;
75
}, isTreeNode:true, object:{}, title:"", isFolder:null, contentNode:null, expandClass:"", isExpanded:false, containerNode:null, getInfo:function () {
77
}, isTreeNode:true, object:{}, title:"", isFolder:null, contentNode:null, expandClass:"", isExpanded:false, containerNode:null, getInfo:function () {
76
	var info = {widgetId:this.widgetId, objectId:this.objectId, index:this.getParentIndex()};
78
	var info = {widgetId:this.widgetId, objectId:this.objectId, index:this.getParentIndex()};
77
	return info;
79
	return info;
78
}, setFolder:function () {
80
}, setFolder:function () {
79
	this.isFolder = true;
81
	this.isFolder = true;
80
	this.viewSetExpand();
82
	this.viewSetExpand();
81
	if (!this.containerNode) {
83
	if (!this.containerNode) {
82
		this.viewAddContainer();
84
		this.viewAddContainer();
83
	}
85
	}
84
	dojo.event.topic.publish(this.tree.eventNames.afterSetFolder, {source:this});
86
	dojo.event.topic.publish(this.tree.eventNames.afterSetFolder, {source:this});
85
}, initialize:function (args, frag, parent) {
87
}, initialize:function (args, frag, parent) {
86
	if (args.isFolder) {
88
	if (args.isFolder) {
87
		this.isFolder = true;
89
		this.isFolder = true;
88
	}
90
	}
89
	if (this.children.length || this.isFolder) {
91
	if (this.children.length || this.isFolder) {
90
		this.setFolder();
92
		this.setFolder();
91
	} else {
93
	} else {
92
		this.viewSetExpand();
94
		this.viewSetExpand();
93
	}
95
	}
94
	for (var i = 0; i < this.actionsDisabled.length; i++) {
96
	for (var i = 0; i < this.actionsDisabled.length; i++) {
95
		this.actionsDisabled[i] = this.actionsDisabled[i].toUpperCase();
97
		this.actionsDisabled[i] = this.actionsDisabled[i].toUpperCase();
96
	}
98
	}
97
	dojo.event.topic.publish(this.tree.eventNames.afterChangeTree, {oldTree:null, newTree:this.tree, node:this});
99
	dojo.event.topic.publish(this.tree.eventNames.afterChangeTree, {oldTree:null, newTree:this.tree, node:this});
98
}, unsetFolder:function () {
100
}, unsetFolder:function () {
99
	this.isFolder = false;
101
	this.isFolder = false;
100
	this.viewSetExpand();
102
	this.viewSetExpand();
101
	dojo.event.topic.publish(this.tree.eventNames.afterUnsetFolder, {source:this});
103
	dojo.event.topic.publish(this.tree.eventNames.afterUnsetFolder, {source:this});
102
}, insertNode:function (parent, index) {
104
}, insertNode:function (parent, index) {
103
	if (!index) {
105
	if (!index) {
104
		index = 0;
106
		index = 0;
105
	}
107
	}
106
	if (index == 0) {
108
	if (index == 0) {
107
		dojo.html.prependChild(this.domNode, parent.containerNode);
109
		dojo.html.prependChild(this.domNode, parent.containerNode);
108
	} else {
110
	} else {
109
		dojo.html.insertAfter(this.domNode, parent.children[index - 1].domNode);
111
		dojo.html.insertAfter(this.domNode, parent.children[index - 1].domNode);
110
	}
112
	}
111
}, updateTree:function (newTree) {
113
}, updateTree:function (newTree) {
112
	if (this.tree === newTree) {
114
	if (this.tree === newTree) {
113
		return;
115
		return;
114
	}
116
	}
115
	var oldTree = this.tree;
117
	var oldTree = this.tree;
116
	dojo.lang.forEach(this.getDescendants(), function (elem) {
118
	dojo.lang.forEach(this.getDescendants(), function (elem) {
117
		elem.tree = newTree;
119
		elem.tree = newTree;
118
	});
120
	});
119
	if (oldTree.classPrefix != newTree.classPrefix) {
121
	if (oldTree.classPrefix != newTree.classPrefix) {
120
		var stack = [this.domNode];
122
		var stack = [this.domNode];
121
		var elem;
123
		var elem;
122
		var reg = new RegExp("(^|\\s)" + oldTree.classPrefix, "g");
124
		var reg = new RegExp("(^|\\s)" + oldTree.classPrefix, "g");
123
		while (elem = stack.pop()) {
125
		while (elem = stack.pop()) {
124
			for (var i = 0; i < elem.childNodes.length; i++) {
126
			for (var i = 0; i < elem.childNodes.length; i++) {
125
				var childNode = elem.childNodes[i];
127
				var childNode = elem.childNodes[i];
126
				if (childNode.nodeDocType != 1) {
128
				if (childNode.nodeDocType != 1) {
127
					continue;
129
					continue;
128
				}
130
				}
129
				dojo.html.setClass(childNode, dojo.html.getClass(childNode).replace(reg, "$1" + newTree.classPrefix));
131
				dojo.html.setClass(childNode, dojo.html.getClass(childNode).replace(reg, "$1" + newTree.classPrefix));
130
				stack.push(childNode);
132
				stack.push(childNode);
131
			}
133
			}
132
		}
134
		}
133
	}
135
	}
134
	var message = {oldTree:oldTree, newTree:newTree, node:this};
136
	var message = {oldTree:oldTree, newTree:newTree, node:this};
135
	dojo.event.topic.publish(this.tree.eventNames.afterChangeTree, message);
137
	dojo.event.topic.publish(this.tree.eventNames.afterChangeTree, message);
136
	dojo.event.topic.publish(newTree.eventNames.afterChangeTree, message);
138
	dojo.event.topic.publish(newTree.eventNames.afterChangeTree, message);
137
}, addedTo:function (parent, index, dontPublishEvent) {
139
}, addedTo:function (parent, index, dontPublishEvent) {
138
	if (this.tree !== parent.tree) {
140
	if (this.tree !== parent.tree) {
139
		this.updateTree(parent.tree);
141
		this.updateTree(parent.tree);
140
	}
142
	}
141
	if (parent.isTreeNode) {
143
	if (parent.isTreeNode) {
142
		if (!parent.isFolder) {
144
		if (!parent.isFolder) {
143
			parent.setFolder();
145
			parent.setFolder();
144
			parent.state = parent.loadStates.LOADED;
146
			parent.state = parent.loadStates.LOADED;
145
		}
147
		}
146
	}
148
	}
147
	var siblingsCount = parent.children.length;
149
	var siblingsCount = parent.children.length;
148
	this.insertNode(parent, index);
150
	this.insertNode(parent, index);
149
	this.viewAddLayout();
151
	this.viewAddLayout();
150
	if (siblingsCount > 1) {
152
	if (siblingsCount > 1) {
151
		if (index == 0 && parent.children[1] instanceof dojo.widget.Widget) {
153
		if (index == 0 && parent.children[1] instanceof dojo.widget.Widget) {
152
			parent.children[1].viewUpdateLayout();
154
			parent.children[1].viewUpdateLayout();
153
		}
155
		}
154
		if (index == siblingsCount - 1 && parent.children[siblingsCount - 2] instanceof dojo.widget.Widget) {
156
		if (index == siblingsCount - 1 && parent.children[siblingsCount - 2] instanceof dojo.widget.Widget) {
155
			parent.children[siblingsCount - 2].viewUpdateLayout();
157
			parent.children[siblingsCount - 2].viewUpdateLayout();
156
		}
158
		}
157
	} else {
159
	} else {
158
		if (parent.isTreeNode) {
160
		if (parent.isTreeNode) {
159
			parent.viewSetHasChildren();
161
			parent.viewSetHasChildren();
160
		}
162
		}
161
	}
163
	}
162
	if (!dontPublishEvent) {
164
	if (!dontPublishEvent) {
163
		var message = {child:this, index:index, parent:parent};
165
		var message = {child:this, index:index, parent:parent};
164
		dojo.event.topic.publish(this.tree.eventNames.afterAddChild, message);
166
		dojo.event.topic.publish(this.tree.eventNames.afterAddChild, message);
165
	}
167
	}
166
}, createSimple:function (args, parent) {
168
}, createSimple:function (args, parent) {
167
	if (args.tree) {
169
	if (args.tree) {
168
		var tree = args.tree;
170
		var tree = args.tree;
169
	} else {
171
	} else {
170
		if (parent) {
172
		if (parent) {
171
			var tree = parent.tree;
173
			var tree = parent.tree;
172
		} else {
174
		} else {
173
			dojo.raise("createSimple: can't evaluate tree");
175
			dojo.raise("createSimple: can't evaluate tree");
174
		}
176
		}
175
	}
177
	}
176
	tree = dojo.widget.byId(tree);
178
	tree = dojo.widget.byId(tree);
177
	var treeNode = new tree.defaultChildWidget();
179
	var treeNode = new tree.defaultChildWidget();
178
	for (var x in args) {
180
	for (var x in args) {
179
		treeNode[x] = args[x];
181
		treeNode[x] = args[x];
180
	}
182
	}
181
	treeNode.toggleObj = dojo.lfx.toggle[treeNode.toggle.toLowerCase()] || dojo.lfx.toggle.plain;
183
	treeNode.toggleObj = dojo.lfx.toggle[treeNode.toggle.toLowerCase()] || dojo.lfx.toggle.plain;
182
	dojo.widget.manager.add(treeNode);
184
	dojo.widget.manager.add(treeNode);
183
	treeNode.buildRendering(args, {}, parent);
185
	treeNode.buildRendering(args, {}, parent);
184
	treeNode.initialize(args, {}, parent);
186
	treeNode.initialize(args, {}, parent);
185
	if (treeNode.parent) {
187
	if (treeNode.parent) {
186
		delete dojo.widget.manager.topWidgets[treeNode.widgetId];
188
		delete dojo.widget.manager.topWidgets[treeNode.widgetId];
187
	}
189
	}
188
	return treeNode;
190
	return treeNode;
189
}, viewUpdateLayout:function () {
191
}, viewUpdateLayout:function () {
190
	this.viewRemoveLayout();
192
	this.viewRemoveLayout();
191
	this.viewAddLayout();
193
	this.viewAddLayout();
192
}, viewAddContainer:function () {
194
}, viewAddContainer:function () {
193
	this.containerNode = this.tree.containerNodeTemplate.cloneNode(true);
195
	this.containerNode = this.tree.containerNodeTemplate.cloneNode(true);
194
	this.domNode.appendChild(this.containerNode);
196
	this.domNode.appendChild(this.containerNode);
195
}, viewAddLayout:function () {
197
}, viewAddLayout:function () {
196
	if (this.parent["isTree"]) {
198
	if (this.parent["isTree"]) {
197
		dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode) + " " + this.tree.classPrefix + "IsRoot");
199
		dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode) + " " + this.tree.classPrefix + "IsRoot");
198
	}
200
	}
199
	if (this.isLastChild()) {
201
	if (this.isLastChild()) {
200
		dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode) + " " + this.tree.classPrefix + "IsLast");
202
		dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode) + " " + this.tree.classPrefix + "IsLast");
201
	}
203
	}
202
}, viewRemoveLayout:function () {
204
}, viewRemoveLayout:function () {
203
	dojo.html.removeClass(this.domNode, this.tree.classPrefix + "IsRoot");
205
	dojo.html.removeClass(this.domNode, this.tree.classPrefix + "IsRoot");
204
	dojo.html.removeClass(this.domNode, this.tree.classPrefix + "IsLast");
206
	dojo.html.removeClass(this.domNode, this.tree.classPrefix + "IsLast");
205
}, viewGetExpandClass:function () {
207
}, viewGetExpandClass:function () {
206
	if (this.isFolder) {
208
	if (this.isFolder) {
207
		return this.isExpanded ? "ExpandOpen" : "ExpandClosed";
209
		return this.isExpanded ? "ExpandOpen" : "ExpandClosed";
208
	} else {
210
	} else {
209
		return "ExpandLeaf";
211
		return "ExpandLeaf";
210
	}
212
	}
211
}, viewSetExpand:function () {
213
}, viewSetExpand:function () {
212
	var expand = this.tree.classPrefix + this.viewGetExpandClass();
214
	var expand = this.tree.classPrefix + this.viewGetExpandClass();
213
	var reg = new RegExp("(^|\\s)" + this.tree.classPrefix + "Expand\\w+", "g");
215
	var reg = new RegExp("(^|\\s)" + this.tree.classPrefix + "Expand\\w+", "g");
214
	dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode).replace(reg, "") + " " + expand);
216
	dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode).replace(reg, "") + " " + expand);
215
	this.viewSetHasChildrenAndExpand();
217
	this.viewSetHasChildrenAndExpand();
216
}, viewGetChildrenClass:function () {
218
}, viewGetChildrenClass:function () {
217
	return "Children" + (this.children.length ? "Yes" : "No");
219
	return "Children" + (this.children.length ? "Yes" : "No");
218
}, viewSetHasChildren:function () {
220
}, viewSetHasChildren:function () {
219
	var clazz = this.tree.classPrefix + this.viewGetChildrenClass();
221
	var clazz = this.tree.classPrefix + this.viewGetChildrenClass();
220
	var reg = new RegExp("(^|\\s)" + this.tree.classPrefix + "Children\\w+", "g");
222
	var reg = new RegExp("(^|\\s)" + this.tree.classPrefix + "Children\\w+", "g");
221
	dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode).replace(reg, "") + " " + clazz);
223
	dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode).replace(reg, "") + " " + clazz);
222
	this.viewSetHasChildrenAndExpand();
224
	this.viewSetHasChildrenAndExpand();
223
}, viewSetHasChildrenAndExpand:function () {
225
}, viewSetHasChildrenAndExpand:function () {
224
	var clazz = this.tree.classPrefix + "State" + this.viewGetChildrenClass() + "-" + this.viewGetExpandClass();
226
	var clazz = this.tree.classPrefix + "State" + this.viewGetChildrenClass() + "-" + this.viewGetExpandClass();
225
	var reg = new RegExp("(^|\\s)" + this.tree.classPrefix + "State[\\w-]+", "g");
227
	var reg = new RegExp("(^|\\s)" + this.tree.classPrefix + "State[\\w-]+", "g");
226
	dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode).replace(reg, "") + " " + clazz);
228
	dojo.html.setClass(this.domNode, dojo.html.getClass(this.domNode).replace(reg, "") + " " + clazz);
227
}, viewUnfocus:function () {
229
}, viewUnfocus:function () {
228
	dojo.html.removeClass(this.labelNode, this.tree.classPrefix + "LabelFocused");
230
	dojo.html.removeClass(this.labelNode, this.tree.classPrefix + "LabelFocused");
229
}, viewFocus:function () {
231
}, viewFocus:function () {
230
	dojo.html.addClass(this.labelNode, this.tree.classPrefix + "LabelFocused");
232
	dojo.html.addClass(this.labelNode, this.tree.classPrefix + "LabelFocused");
231
}, viewEmphasize:function () {
233
}, viewEmphasize:function () {
232
	dojo.html.clearSelection(this.labelNode);
234
	dojo.html.clearSelection(this.labelNode);
233
	dojo.html.addClass(this.labelNode, this.tree.classPrefix + "NodeEmphasized");
235
	dojo.html.addClass(this.labelNode, this.tree.classPrefix + "NodeEmphasized");
234
}, viewUnemphasize:function () {
236
}, viewUnemphasize:function () {
235
	dojo.html.removeClass(this.labelNode, this.tree.classPrefix + "NodeEmphasized");
237
	dojo.html.removeClass(this.labelNode, this.tree.classPrefix + "NodeEmphasized");
236
}, detach:function () {
238
}, detach:function () {
237
	if (!this.parent) {
239
	if (!this.parent) {
238
		return;
240
		return;
239
	}
241
	}
240
	var parent = this.parent;
242
	var parent = this.parent;
241
	var index = this.getParentIndex();
243
	var index = this.getParentIndex();
242
	this.doDetach.apply(this, arguments);
244
	this.doDetach.apply(this, arguments);
243
	dojo.event.topic.publish(this.tree.eventNames.afterDetach, {child:this, parent:parent, index:index});
245
	dojo.event.topic.publish(this.tree.eventNames.afterDetach, {child:this, parent:parent, index:index});
244
}, doDetach:function () {
246
}, doDetach:function () {
245
	var parent = this.parent;
247
	var parent = this.parent;
246
	if (!parent) {
248
	if (!parent) {
247
		return;
249
		return;
248
	}
250
	}
249
	var index = this.getParentIndex();
251
	var index = this.getParentIndex();
250
	this.viewRemoveLayout();
252
	this.viewRemoveLayout();
251
	dojo.widget.DomWidget.prototype.removeChild.call(parent, this);
253
	dojo.widget.DomWidget.prototype.removeChild.call(parent, this);
252
	var siblingsCount = parent.children.length;
254
	var siblingsCount = parent.children.length;
253
	if (siblingsCount > 0) {
255
	if (siblingsCount > 0) {
254
		if (index == 0) {
256
		if (index == 0) {
255
			parent.children[0].viewUpdateLayout();
257
			parent.children[0].viewUpdateLayout();
256
		}
258
		}
257
		if (index == siblingsCount) {
259
		if (index == siblingsCount) {
258
			parent.children[siblingsCount - 1].viewUpdateLayout();
260
			parent.children[siblingsCount - 1].viewUpdateLayout();
259
		}
261
		}
260
	} else {
262
	} else {
261
		if (parent.isTreeNode) {
263
		if (parent.isTreeNode) {
262
			parent.viewSetHasChildren();
264
			parent.viewSetHasChildren();
263
		}
265
		}
264
	}
266
	}
265
	if (this.tree.unsetFolderOnEmpty && !parent.children.length && parent.isTreeNode) {
267
	if (this.tree.unsetFolderOnEmpty && !parent.children.length && parent.isTreeNode) {
266
		parent.unsetFolder();
268
		parent.unsetFolder();
267
	}
269
	}
268
	this.parent = null;
270
	this.parent = null;
269
}, destroy:function () {
271
}, destroy:function () {
270
	dojo.event.topic.publish(this.tree.eventNames.beforeNodeDestroy, {source:this});
272
	dojo.event.topic.publish(this.tree.eventNames.beforeNodeDestroy, {source:this});
271
	this.detach();
273
	this.detach();
272
	return dojo.widget.HtmlWidget.prototype.destroy.apply(this, arguments);
274
	return dojo.widget.HtmlWidget.prototype.destroy.apply(this, arguments);
273
}, expand:function () {
275
}, expand:function () {
274
	if (this.isExpanded) {
276
	if (this.isExpanded) {
275
		return;
277
		return;
276
	}
278
	}
277
	if (this.tryLazyInit) {
279
	if (this.tryLazyInit) {
278
		this.setChildren();
280
		this.setChildren();
279
		this.tryLazyInit = false;
281
		this.tryLazyInit = false;
280
	}
282
	}
281
	this.isExpanded = true;
283
	this.isExpanded = true;
282
	this.viewSetExpand();
284
	this.viewSetExpand();
283
	this.showChildren();
285
	this.showChildren();
284
}, collapse:function () {
286
}, collapse:function () {
285
	if (!this.isExpanded) {
287
	if (!this.isExpanded) {
286
		return;
288
		return;
287
	}
289
	}
288
	this.isExpanded = false;
290
	this.isExpanded = false;
289
	this.hideChildren();
291
	this.hideChildren();
290
}, hideChildren:function () {
292
}, hideChildren:function () {
291
	this.tree.toggleObj.hide(this.containerNode, this.tree.toggleDuration, this.explodeSrc, dojo.lang.hitch(this, "onHideChildren"));
293
	this.tree.toggleObj.hide(this.containerNode, this.tree.toggleDuration, this.explodeSrc, dojo.lang.hitch(this, "onHideChildren"));
292
}, showChildren:function () {
294
}, showChildren:function () {
293
	this.tree.toggleObj.show(this.containerNode, this.tree.toggleDuration, this.explodeSrc, dojo.lang.hitch(this, "onShowChildren"));
295
	this.tree.toggleObj.show(this.containerNode, this.tree.toggleDuration, this.explodeSrc, dojo.lang.hitch(this, "onShowChildren"));
294
}, onShowChildren:function () {
296
}, onShowChildren:function () {
295
	this.onShow();
297
	this.onShow();
296
	dojo.event.topic.publish(this.tree.eventNames.afterExpand, {source:this});
298
	dojo.event.topic.publish(this.tree.eventNames.afterExpand, {source:this});
297
}, onHideChildren:function () {
299
}, onHideChildren:function () {
298
	this.viewSetExpand();
300
	this.viewSetExpand();
299
	this.onHide();
301
	this.onHide();
300
	dojo.event.topic.publish(this.tree.eventNames.afterCollapse, {source:this});
302
	dojo.event.topic.publish(this.tree.eventNames.afterCollapse, {source:this});
301
}, setTitle:function (title) {
303
}, setTitle:function (title) {
302
	var oldTitle = this.title;
304
	var oldTitle = this.title;
303
	this.labelNode.innerHTML = this.title = title;
305
	this.labelNode.innerHTML = this.title = title;
304
	dojo.event.topic.publish(this.tree.eventNames.afterSetTitle, {source:this, oldTitle:oldTitle});
306
	dojo.event.topic.publish(this.tree.eventNames.afterSetTitle, {source:this, oldTitle:oldTitle});
305
}, toString:function () {
307
}, toString:function () {
306
	return "[" + this.widgetType + ", " + this.title + "]";
308
	return "[" + this.widgetType + ", " + this.title + "]";
307
}});
309
}});
308
 
310