Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
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:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.widget.TreeDocIconExtension");
14
dojo.require("dojo.widget.HtmlWidget");
15
dojo.require("dojo.widget.TreeExtension");
16
dojo.widget.defineWidget("dojo.widget.TreeDocIconExtension", [dojo.widget.TreeExtension], {templateCssString:"\n/* CSS for TreeDocIconExtension */\n\n\n/* long vertical line under docIcon, connecting w/ children */\n.TreeStateChildrenYes-ExpandOpen .TreeIconContent {\n	background-image : url('../templates/images/TreeV3/i_long.gif');\n	background-repeat : no-repeat;\n	background-position: 18px 9px;\n}\n\n/* close has higher priority */\n.TreeStateChildrenYes-ExpandClosed .TreeIconContent {\n	background-image : url();\n}\n\n/* higher priotity: same length and appear after background-definition */\n.TreeStateChildrenNo-ExpandLeaf .TreeIconContent {\n	background-image : url();\n}\n\n.TreeStateChildrenNo-ExpandClosed .TreeIconContent {\n	background-image : url();\n}\n\n.TreeStateChildrenNo-ExpandOpen .TreeIconContent {\n	background-image : url();\n}\n\n\n/* highest priority */\n.TreeIconDocument {\n	background-image: url('../templates/images/TreeV3/document.gif');\n}\n\n.TreeExpandOpen .TreeIconFolder {\n	background-image: url('../templates/images/TreeV3/open.gif');\n}\n\n.TreeExpandClosed .TreeIconFolder {\n	background-image: url('../templates/images/TreeV3/closed.gif');\n}\n\n/* generic class for docIcon */\n.TreeIcon {\n	width: 18px;\n	height: 18px;\n	float: left;\n	display: inline;\n	background-repeat : no-repeat;\n}\n\ndiv.TreeContent {\n	margin-left: 36px;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/TreeDocIcon.css"), listenTreeEvents:["afterChangeTree", "afterSetFolder", "afterUnsetFolder"], listenNodeFilter:function (elem) {
17
	return elem instanceof dojo.widget.Widget;
18
}, getnodeDocType:function (node) {
19
	var nodeDocType = node.getnodeDocType();
20
	if (!nodeDocType) {
21
		nodeDocType = node.isFolder ? "Folder" : "Document";
22
	}
23
	return nodeDocType;
24
}, setnodeDocTypeClass:function (node) {
25
	var reg = new RegExp("(^|\\s)" + node.tree.classPrefix + "Icon\\w+", "g");
26
	var clazz = dojo.html.getClass(node.iconNode).replace(reg, "") + " " + node.tree.classPrefix + "Icon" + this.getnodeDocType(node);
27
	dojo.html.setClass(node.iconNode, clazz);
28
}, onAfterSetFolder:function (message) {
29
	if (message.source.iconNode) {
30
		this.setnodeDocTypeClass(message.source);
31
	}
32
}, onAfterUnsetFolder:function (message) {
33
	this.setnodeDocTypeClass(message.source);
34
}, listenNode:function (node) {
35
	node.contentIconNode = document.createElement("div");
36
	var clazz = node.tree.classPrefix + "IconContent";
37
	if (dojo.render.html.ie) {
38
		clazz = clazz + " " + node.tree.classPrefix + "IEIconContent";
39
	}
40
	dojo.html.setClass(node.contentIconNode, clazz);
41
	node.contentNode.parentNode.replaceChild(node.contentIconNode, node.expandNode);
42
	node.iconNode = document.createElement("div");
43
	dojo.html.setClass(node.iconNode, node.tree.classPrefix + "Icon" + " " + node.tree.classPrefix + "Icon" + this.getnodeDocType(node));
44
	node.contentIconNode.appendChild(node.expandNode);
45
	node.contentIconNode.appendChild(node.iconNode);
46
	dojo.dom.removeNode(node.contentNode);
47
	node.contentIconNode.appendChild(node.contentNode);
48
}, onAfterChangeTree:function (message) {
49
	var _this = this;
50
	if (!message.oldTree || !this.listenedTrees[message.oldTree.widgetId]) {
51
		this.processDescendants(message.node, this.listenNodeFilter, this.listenNode);
52
	}
53
}});
54