Debian Codegraph @

dijit/tests/tree/test_Tree.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>Dijit Tree Test</title>
6
7 <script type="text/javascript" src="../boilerplate.js"></script>
8
9 <script type="text/javascript">
10 require([
11 "dojo/parser",
12 "dojo/data/ItemFileWriteStore",
13 "dijit/Tree",
14 "dijit/tree/ForestStoreModel",
15 "dijit/ColorPalette",
16 "dijit/Menu",
17 "dijit/MenuItem",
18 "dijit/PopupMenuItem",
19 "dojo/domReady!"
20 ], function(parser){
21 parser.parse();
22 });
23
24 // Global variable used by mytree (and in turn referenced by Tree_mouse.html robot test)
25 mouseDowns = 0;
26 </script>
27
28 </head>
29 <body class="claro" role="main">
30
31 <script type="dojo/require">
32 registry: "dijit/registry"
33 </script>
34
35 <h1 class="testTitle">Dijit Tree Test</h1>
36
37 <div data-dojo-id="continentStore" data-dojo-type="dojo/data/ItemFileWriteStore" data-dojo-props='url:"../_data/countries.json"'></div>
38 <div data-dojo-id="continentModel" data-dojo-type="dijit/tree/ForestStoreModel" data-dojo-props='store:continentStore, query:{type:"continent"},
39 rootId:"continentRoot", rootLabel:"Continents", childrenAttrs:["children"]'></div>
40 <div data-dojo-id="wideModel" data-dojo-type="dijit/tree/ForestStoreModel" data-dojo-props='store:continentStore, query:{type:"continent"},
41 rootId:"continentRoot", rootLabel:"Long label that causes scrolling", childrenAttrs:["children"]'></div>
42
43 <h2 id="mytreeLabel">Tree with hardcoded root node (not corresponding to any item in the store)</h2>
44 <p>
45 Clicking a folder node will open/close it (openOnclick==true),
46 and clicking a leaf node will log a message to the console.
47 </p>
48 <label for="mytree_before">before:</label><input id="mytree_before"/>
49 <div id="mytree" data-dojo-type="dijit/Tree" aria-labelledby="mytreeLabel"
50 data-dojo-props='model:continentModel, openOnClick:true, onLoad:function(){ console.log("loaded mytree (first tree)"); }'>
51 <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="item">
52 console.log("Execute of node " + continentStore.getLabel(item)
53 +", population=" + continentStore.getValue(item, "population"));
54 </script>
55 <script type="dojo/method" data-dojo-event="onOpen" data-dojo-args="item">
56 console.log("Open of node " + (continentStore.getLabel(item) || "root"));
57 </script>
58 <script type="dojo/method" data-dojo-event="onClose" data-dojo-args="item">
59 console.log("Close of node " + (continentStore.getLabel(item) || "root"));
60 </script>
61 <script type="dojo/method" data-dojo-event="onMouseDown" data-dojo-args="evt">
62 mouseDowns++;
63 </script>
64 </div>
65
66 <button id="mytreeDestroyButton" onclick="dijit.byId('mytree').destroyRecursive();">destroy</button>
67
68 <h2 id="tree2Label">A rootless tree (no "continents" node) with context menus, and custom icons</h2>
69
70 <label for="tree2_before">before:</label><input id="tree2_before"/>
71 <div id="tree2" data-dojo-type="dijit/Tree" aria-labelledby="tree2Label" data-dojo-props='model:continentModel, showRoot:false, openOnClick:true,onLoad:function(){ console.log("loaded tree2 (second tree)"); }'>
72 <script type="dojo/method" data-dojo-event="getIconClass" data-dojo-args="item, opened">
73 return (item == this.model.root || continentStore.getValue(item, "type") == "continent") ?
74 (opened ? "customFolderOpenedIcon" : "customFolderClosedIcon") :
75 "noteIcon";
76 </script>
77 <script type="dojo/method" data-dojo-event="onClick" data-dojo-args="item">
78 console.log("Execute of node " + this.model.getLabel(item)
79 +", population=" + continentStore.getValue(item, "population"));
80 </script>
81 </div>
82
83 <ul id="tree_menu" data-dojo-type="dijit/Menu"
84 data-dojo-props='style:"display: none;", targetNodeIds: ["tree2"], selector: ".dijitTreeNode"'>
85 <li data-dojo-type="dijit/MenuItem">
86 <script type="dojo/on" data-dojo-event="click">
87 // get a hold of the dijit.TreeNode that was the source of this open event
88 var tn = registry.byNode(this.getParent().currentTarget);
89
90 // now print the data store item that backs the tree node
91 console.debug("menu click for item: ", tn.item.name);
92 </script>
93 Click Me
94 </li>
95 </ul>
96
97 <button id="tree2ExpandAll" onclick="dijit.byId('tree2').expandAll();">expand all</button>
98 <button onclick="dijit.byId('tree2').collapseAll();">collapse all</button>
99
100 <h2 id="mytree3Label">Double click, expand on load, direct style setting, tooltip test tree</h2>
101 <p>
102 Double-Clicking a folder node will open/close it (openOnDblClick==true),
103 and clicking or Double Clicking a leaf node will log a message to the console.
104 </p>
105 <label for="mytree3_before">before:</label> <input id="mytree3_before"/>
106 <div id="mytree3" aria-labelledby="mytree3Label" data-dojo-type="dijit/Tree"
107 data-dojo-props='store:continentStore, query:{type:"continent"},
108 label:"Continents", openOnClick:false, openOnDblClick:true,
109 autoExpand:true, onLoad:function(){ console.log("loaded mytree3 (third tree)"); }'>
110 <script type="dojo/method" data-dojo-event="getLabelStyle" data-dojo-args="item,opened">
111 if(item && continentStore.getValue(item,"type") == "continent"){
112 return {color: "red"};
113 }else{
114 return {color: "green"};
115 }
116 </script>
117 <script type="dojo/method" data-dojo-event="getIconStyle" data-dojo-args="item,opened">
118 if(item && continentStore.getValue(item,"type") == "continent"){
119 return {
120 backgroundImage: "url('../images/flatScreen.gif')",
121 height: "32px",
122 width: "32px"
123 };
124 }else{
125 return null;
126 }
127 </script>
128 <script type="dojo/method" data-dojo-event="getIconClass" data-dojo-args="item, opened">
129 if(!item || continentStore.getValue(item, "type") != "continent")
130 return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "dijitLeaf"
131 else
132 return "";
133 </script>
134 <script type="dojo/method" data-dojo-event="getTooltip" data-dojo-args="item,opened">
135 return item && ("Tooltip for " + this.model.getLabel(item));
136 </script>
137 <script type="dojo/method" data-dojo-event="onDblClick" data-dojo-args="item">
138 console.log("Execute of node " + this.model.getLabel(item)
139 +", population=" + continentStore.getValue(item, "population"));
140 </script>
141 </div>
142
143 <h2 id="thinTreeLabel">Tree w/horizontal scroll</h2>
144 <p>
145 For checking that selection and highlighting effect goes all the way to the right.
146 </p>
147 <p>
148 Expand North America and check highlighting for United States, plus shorter labels.
149 Then collapse North America and make sure horizontal scrollbar disappears.
150 </p>
151 <p>
152 Also check whether the Tree's initial display is correct.
153 Since the Tree persists, try refreshing the page when the tree is in an open state, and when it's in a closed
154 state.
155 </p>
156 <div id="thinTree" style="width: 170px; border: solid 1px #759dc0"
157 data-dojo-type="dijit/Tree" aria-labelledby="thinTreeLabel" data-dojo-props="model:wideModel">
158 <script type="dojo/aspect" data-dojo-advice="after" data-dojo-method="_adjustWidths">
159 console.log(this.id + ": adjusted widths of nodes");
160 </script>
161 </div>
162 <button onclick="dijit.byId('thinTree').expandAll();">expand all</button>
163 <button onclick="dijit.byId('thinTree').collapseAll();">collapse all</button>
164 <button onclick="dijit.byId('thinTree').set('paths', [['continentRoot','AF'],['continentRoot','NA','US']]);">
165 set paths to Africa, US
166 </button>
167 <button onclick="continentStore.fetchItemByIdentity({identity: 'US', onItem: function(item){ continentStore.setValue(item, 'name', 'A very very very long name for USA'); }});">
168 set long name for USA
169 </button>
170 <button onclick="continentStore.fetchItemByIdentity({identity: 'US', onItem: function(item){ continentStore.setValue(item, 'name', 'USA'); }});">
171 set short name for USA
172 </button>
173
174 </body>
175 </html>