Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Go to most recent revision | 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.TreeControllerExtension");
13
dojo.provide("dojo.widget.TreeControllerExtension");
12
dojo.declare("dojo.widget.TreeControllerExtension", null, {saveExpandedIndices:function (node, field) {
14
dojo.declare("dojo.widget.TreeControllerExtension", null, {saveExpandedIndices:function (node, field) {
13
	var obj = {};
15
	var obj = {};
14
	for (var i = 0; i < node.children.length; i++) {
16
	for (var i = 0; i < node.children.length; i++) {
15
		if (node.children[i].isExpanded) {
17
		if (node.children[i].isExpanded) {
16
			var key = dojo.lang.isUndefined(field) ? i : node.children[i][field];
18
			var key = dojo.lang.isUndefined(field) ? i : node.children[i][field];
17
			obj[key] = this.saveExpandedIndices(node.children[i], field);
19
			obj[key] = this.saveExpandedIndices(node.children[i], field);
18
		}
20
		}
19
	}
21
	}
20
	return obj;
22
	return obj;
21
}, restoreExpandedIndices:function (node, savedIndices, field) {
23
}, restoreExpandedIndices:function (node, savedIndices, field) {
22
	var _this = this;
24
	var _this = this;
23
	var handler = function (node, savedIndices) {
25
	var handler = function (node, savedIndices) {
24
		this.node = node;
26
		this.node = node;
25
		this.savedIndices = savedIndices;
27
		this.savedIndices = savedIndices;
26
		this.process = function () {
28
		this.process = function () {
27
			_this.restoreExpandedIndices(this.node, this.savedIndices, field);
29
			_this.restoreExpandedIndices(this.node, this.savedIndices, field);
28
		};
30
		};
29
	};
31
	};
30
	for (var i = 0; i < node.children.length; i++) {
32
	for (var i = 0; i < node.children.length; i++) {
31
		var child = node.children[i];
33
		var child = node.children[i];
32
		var found = false;
34
		var found = false;
33
		var key = -1;
35
		var key = -1;
34
		if (dojo.lang.isUndefined(field) && savedIndices[i]) {
36
		if (dojo.lang.isUndefined(field) && savedIndices[i]) {
35
			found = true;
37
			found = true;
36
			key = i;
38
			key = i;
37
		}
39
		}
38
		if (field) {
40
		if (field) {
39
			for (var key in savedIndices) {
41
			for (var key in savedIndices) {
40
				if (key == child[field]) {
42
				if (key == child[field]) {
41
					found = true;
43
					found = true;
42
					break;
44
					break;
43
				}
45
				}
44
			}
46
			}
45
		}
47
		}
46
		if (found) {
48
		if (found) {
47
			var h = new handler(child, savedIndices[key]);
49
			var h = new handler(child, savedIndices[key]);
48
			_this.expand(child, false, h, h.process);
50
			_this.expand(child, false, h, h.process);
49
		} else {
51
		} else {
50
			if (child.isExpanded) {
52
			if (child.isExpanded) {
51
				dojo.lang.forEach(child.getDescendants(), function (elem) {
53
				dojo.lang.forEach(child.getDescendants(), function (elem) {
52
					_this.collapse(elem);
54
					_this.collapse(elem);
53
				});
55
				});
54
			}
56
			}
55
		}
57
		}
56
	}
58
	}
57
}});
59
}});
58
 
60