Debian Codegraph @

dijit/tests/tree/test_Custom_TreeNode.html

raw symbols SCIP
1 <!DOCTYPE HTML>
2 <html lang="en">
3 <head>
4 <title>Custom TreeNode Test</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
7 <script src="../boilerplate.js" type="text/javascript"></script>
8
9 <script type="text/javascript">
10 require([
11 "dojo/_base/declare", "dojo/data/ItemFileReadStore", "dojo/dom-construct",
12 "dijit/_WidgetBase", "dijit/Tree", "dijit/tree/ForestStoreModel",
13 "dojo/domReady!"
14 ], function(declare, ItemFileReadStore, domConstruct,
15 _WidgetBase, Tree, ForestStoreModel){
16
17 declare("SuperSmartLink", _WidgetBase, {
18 buildRendering: function(){
19 this.domNode = document.createElement("A");
20 this.domNode.href = "http://ibm.com";
21 this.inherited(arguments);
22 }
23 });
24
25 declare("SuperSmartTreeNode", Tree._TreeNode, {
26 postCreate: function(){
27 this.inherited(arguments);
28 this._smartLink = new SuperSmartLink();
29 this.contentNode.appendChild(this._smartLink.domNode);
30 // in real application this is done by template modification tree node class
31 domConstruct.place(this.labelNode, this._smartLink.domNode, "first");
32 }
33 });
34
35 declare("SuperSmartTree", Tree, {
36 focusNode: function(node){
37 this.inherited(arguments);
38 this.dndController.setSelection([node]);
39 },
40
41 _createTreeNode: function(args){
42 return new SuperSmartTreeNode(args);
43 }
44 });
45
46 var getChildren = function(depth, parent){
47 var classChildren = [];
48 for (var i = 0; i < 3; i++){
49 var child = {
50 id: parent+"_" + i,
51 name: parent+"_" + i
52 };
53 if (depth < 2 && i === 0){
54 child.children = getChildren(depth+1, child.id);
55 }
56 classChildren.push(child);
57 }
58 return classChildren;
59 };
60
61 var store = new ItemFileReadStore({
62 data: {
63 identifier: 'id',
64 label: 'name',
65 items: [
66 {id:"rrroot", name:"The Root", type:"", children: getChildren(0, "Child")}
67 ]
68 }
69 });
70
71 var model = new ForestStoreModel({
72 store: store,
73 query:{type:'*'},
74 childrenAttrs: ["children"]
75 });
76
77 tree = new SuperSmartTree({
78 "model": model,
79 showRoot: false,
80 persist: false
81
82 }).placeAt("AAA");
83
84 tree.startup();
85 });
86 </script>
87 </head>
88 <body class="claro" role="main">
89 <h1 class="title">Please expand Continent node</h1>
90 <div id="AAA" style="overflow: auto; height: 1000px">
91 </div>
92 Footer is here
93 </body>
94 </html>
95