Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
		"http://www.w3.org/TR/html4/strict.dtd">
3
<html>
4
<head>
5
	<title>Dijit Tree Test</title>
6
 
7
	<style type="text/css">
8
		@import "../../dojo/resources/dojo.css";
9
		@import "css/dijitTests.css";
10
	</style>
11
 
12
 
13
	<script type="text/javascript" src="../../dojo/dojo.js"
14
		djConfig="parseOnLoad: true, isDebug: true"></script>
15
	<script type="text/javascript" src="_testCommon.js"></script>
16
 
17
	<script language="JavaScript" type="text/javascript">
18
		dojo.require("dojo.data.ItemFileReadStore");
19
		dojo.require("dijit.Tree");
20
		dojo.require("dijit.ColorPalette");
21
		dojo.require("dijit.Menu");
22
		dojo.require("dojo.parser");	// scan page for widgets and instantiate them
23
	</script>
24
 
25
</head>
26
<body>
27
 
28
	<h1 class="testTitle">Dijit Tree Test</h1>
29
 
30
	<div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore"
31
		url="../tests/_data/countries.json"></div>
32
 
33
	<h3>Tree with hardcoded root node (not corresponding to any item in the store)</h3>
34
	<div dojoType="dijit.Tree" id="mytree" store="continentStore" query="{type:'continent'}"
35
		labelAttr="name" label="Continents">
36
		<script type="dojo/method" event="onClick" args="item">
37
			if(item){
38
				alert("Execute of node " + continentStore.getLabel(item)
39
					+", population=" + continentStore.getValue(item, "population"));
40
			}else{
41
				alert("Execute on root node");
42
			}
43
		</script>
44
		<script type="dojo/method" event="getIconClass" args="item">
45
			return "noteIcon";
46
		</script>
47
	</div>
48
 
49
	<button onclick="dijit.byId('mytree').destroyRecursive();">destroy</button>
50
 
51
	<h2>A rootless tree (no "continents" node) with context menus</h2>
52
 
53
	<ul dojoType="dijit.Menu" id="tree_menu" style="display: none;">
54
		<li dojoType="dijit.MenuItem" onClick="alert('Hello world');">Enabled Item</li>
55
		<li dojoType="dijit.MenuItem" disabled="true">Disabled Item</li>
56
		<li dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut"
57
			onClick="alert('not actually cutting anything, just a test!')">Cut</li>
58
		<li dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
59
			onClick="alert('not actually copying anything, just a test!')">Copy</li>
60
		<li dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconPaste"
61
			onClick="alert('not actually pasting anything, just a test!')">Paste</li>
62
		<li dojoType="dijit.PopupMenuItem">
63
			<span>Enabled Submenu</span>
64
			<ul dojoType="dijit.Menu" id="submenu2">
65
				<li dojoType="dijit.MenuItem" onClick="alert('Submenu 1!')">Submenu Item One</li>
66
				<li dojoType="dijit.MenuItem" onClick="alert('Submenu 2!')">Submenu Item Two</li>
67
				<li dojoType="dijit.PopupMenuItem">
68
					<span>Deeper Submenu</span>
69
					<ul dojoType="dijit.Menu" id="submenu4">
70
						<li dojoType="dijit.MenuItem" onClick="alert('Sub-submenu 1!')">Sub-sub-menu Item One</li>
71
						<li dojoType="dijit.MenuItem" onClick="alert('Sub-submenu 2!')">Sub-sub-menu Item Two</li>
72
					</ul>
73
				</li>
74
			</ul>
75
		</li>
76
		<li dojoType="dijit.PopupMenuItem" disabled="true">
77
			<span>Disabled Submenu</span>
78
			<ul dojoType="dijit.Menu" id="submenu3" style="display: none;">
79
				<li dojoType="dijit.MenuItem" onClick="alert('Submenu 1!')">Submenu Item One</li>
80
				<li dojoType="dijit.MenuItem" onClick="alert('Submenu 2!')">Submenu Item Two</li>
81
			</ul>
82
		</li>
83
	</ul>
84
 
85
	<div dojoType="dijit.Tree" id="tree2" store="continentStore" query="{type:'continent'}">
86
		<script type="dojo/connect">
87
			var menu = dijit.byId("tree_menu");
88
			// when we right-click anywhere on the tree, make sure we open the menu
89
			menu.bindDomNode(this.domNode);
90
 
91
			dojo.connect(menu, "_openMyself", this, function(e){
92
				// get a hold of, and log out, the tree node that was the source of this open event
93
				var tn = this._domElement2TreeNode(e.target);
94
				console.debug(tn);
95
 
96
				// now inspect the data store item that backs the tree node:
97
				console.debug(tn.item);
98
 
99
				// contrived condition: if this tree node doesn't have any children, disable all of the menu items
100
				menu.getChildren().forEach(function(i){ i.setDisabled(!tn.item.children); });
101
 
102
				// IMPLEMENT CUSTOM MENU BEHAVIOR HERE
103
			});
104
		</script>
105
		<script type="dojo/method" event="getIconClass" args="item">
106
			return "noteIcon";
107
		</script>
108
	</div>
109
 
110
</body>
111
</html>