aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dijit/tests/test_Tree.html
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dijit/tests/test_Tree.html
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dijit/tests/test_Tree.html')
-rw-r--r--includes/js/dijit/tests/test_Tree.html115
1 files changed, 115 insertions, 0 deletions
diff --git a/includes/js/dijit/tests/test_Tree.html b/includes/js/dijit/tests/test_Tree.html
new file mode 100644
index 0000000..fc88fc1
--- /dev/null
+++ b/includes/js/dijit/tests/test_Tree.html
@@ -0,0 +1,115 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <title>Dijit Tree Test</title>
+
+ <style type="text/css">
+ @import "../../dojo/resources/dojo.css";
+ @import "css/dijitTests.css";
+ </style>
+
+ <script type="text/javascript" src="../../dojo/dojo.js"
+ djConfig="parseOnLoad: true, isDebug: true"></script>
+ <script type="text/javascript" src="_testCommon.js"></script>
+
+ <script language="JavaScript" type="text/javascript">
+ dojo.require("dojo.data.ItemFileReadStore");
+ dojo.require("dijit.Tree");
+ dojo.require("dijit.ColorPalette");
+ dojo.require("dijit.Menu");
+ dojo.require("dojo.parser"); // scan page for widgets and instantiate them
+ </script>
+
+</head>
+<body>
+
+ <h1 class="testTitle">Dijit Tree Test</h1>
+
+ <div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore"
+ url="_data/countries.json"></div>
+ <div dojoType="dijit.tree.ForestStoreModel" jsId="continentModel"
+ store="continentStore" query="{type:'continent'}"
+ rootId="continentRoot" rootLabel="Continents" childrenAttrs="children"></div>
+
+ <h3>Tree with hardcoded root node (not corresponding to any item in the store)</h3>
+ <p>Clicking a folder node will open/close it (openOnclick==true), and clicking a leaf node will popup an alert.</p>
+ <div dojoType="dijit.Tree" id="mytree"
+ model="continentModel" openOnClick="true">
+ <script type="dojo/method" event="onClick" args="item">
+ alert("Execute of node " + continentStore.getLabel(item)
+ +", population=" + continentStore.getValue(item, "population"));
+ </script>
+ </div>
+
+ <button onclick="dijit.byId('mytree').destroyRecursive();">destroy</button>
+
+ <h2>A rootless tree (no "continents" node) with context menus, and custom icons</h2>
+
+ <ul dojoType="dijit.Menu" id="tree_menu" style="display: none;">
+ <li dojoType="dijit.MenuItem" onClick="alert('Hello world');">Enabled Item</li>
+ <li dojoType="dijit.MenuItem" disabled="true">Disabled Item</li>
+ <li dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut"
+ onClick="alert('not actually cutting anything, just a test!')">Cut</li>
+ <li dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy"
+ onClick="alert('not actually copying anything, just a test!')">Copy</li>
+ <li dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconPaste"
+ onClick="alert('not actually pasting anything, just a test!')">Paste</li>
+ <li dojoType="dijit.PopupMenuItem">
+ <span>Enabled Submenu</span>
+ <ul dojoType="dijit.Menu" id="submenu2">
+ <li dojoType="dijit.MenuItem" onClick="alert('Submenu 1!')">Submenu Item One</li>
+ <li dojoType="dijit.MenuItem" onClick="alert('Submenu 2!')">Submenu Item Two</li>
+ <li dojoType="dijit.PopupMenuItem">
+ <span>Deeper Submenu</span>
+ <ul dojoType="dijit.Menu" id="submenu4">
+ <li dojoType="dijit.MenuItem" onClick="alert('Sub-submenu 1!')">Sub-sub-menu Item One</li>
+ <li dojoType="dijit.MenuItem" onClick="alert('Sub-submenu 2!')">Sub-sub-menu Item Two</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li dojoType="dijit.PopupMenuItem" disabled="true">
+ <span>Disabled Submenu</span>
+ <ul dojoType="dijit.Menu" id="submenu3" style="display: none;">
+ <li dojoType="dijit.MenuItem" onClick="alert('Submenu 1!')">Submenu Item One</li>
+ <li dojoType="dijit.MenuItem" onClick="alert('Submenu 2!')">Submenu Item Two</li>
+ </ul>
+ </li>
+ </ul>
+
+ <div dojoType="dijit.Tree" id="tree2"
+ model="continentModel" showRoot="false" openOnClick="true">
+
+ <script type="dojo/connect">
+ var menu = dijit.byId("tree_menu");
+ // when we right-click anywhere on the tree, make sure we open the menu
+ menu.bindDomNode(this.domNode);
+
+ dojo.connect(menu, "_openMyself", this, function(e){
+ // get a hold of, and log out, the tree node that was the source of this open event
+ var tn = dijit.getEnclosingWidget(e.target);
+ console.debug(tn);
+
+ // now inspect the data store item that backs the tree node:
+ console.debug(tn.item);
+
+ // contrived condition: if this tree node doesn't have any children, disable all of the menu items
+ menu.getChildren().forEach(function(i){ i.setDisabled(!tn.item.children); });
+
+ // IMPLEMENT CUSTOM MENU BEHAVIOR HERE
+ });
+ </script>
+ <script type="dojo/method" event="getIconClass" args="item, opened">
+ return (item == this.model.root || continentStore.getValue(item, "type") == "continent") ?
+ (opened ? "customFolderOpenedIcon" : "customFolderClosedIcon") :
+ "noteIcon";
+ </script>
+ <script type="dojo/method" event="onClick" args="item">
+ alert("Execute of node " + this.model.getLabel(item)
+ +", population=" + continentStore.getValue(item, "population"));
+ </script>
+</div>
+
+</body>
+</html>