3_callbacks.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>jsTree &raquo; Examples </title>
  8. <link rel="stylesheet" type="text/css" href="../media/style.css" />
  9. <link rel="shortcut icon" href="../media/favicon.ico" />
  10. <link rel="stylesheet" type="text/css" href="../media/prettify.css" />
  11. <script type="text/javascript" src="../media/prettify.js"></script>
  12. <script type="text/javascript" src="../media/iepngfix_tilebg.js"></script>
  13. <script type="text/javascript">window.onload = function() { prettyPrint(); }</script>
  14. <link rel="stylesheet" type="text/css" href="../../source/tree_component.css" />
  15. <script type="text/javascript" src="../../source/_lib.js"></script>
  16. <script type="text/javascript" src="../../source/tree_component.js"></script>
  17. </head>
  18. <body>
  19. <div id="container">
  20. <div id="head">
  21. <h1>jsTree</h1>
  22. <h2>javascript tree component</h2>
  23. <h3>Examples</h3>
  24. </div>
  25. <div id="sidebar">
  26. <h3 style="margin-top:0;">Documentation</h3>
  27. <ul>
  28. <li class="page_item"><a href="../_documentation/1_files.html" title="Required &amp; optional files">Required &#038; optional files</a></li>
  29. <li class="page_item"><a href="../_documentation/2_creation.html" title="Instance creation">Instance creation</a></li>
  30. <li class="page_item"><a href="../_documentation/3_configuration.html" title="Configuration">Configuration</a></li>
  31. <li class="page_item"><a href="../_documentation/4_data.html" title="Data sources">Data sources</a></li>
  32. <li class="page_item"><a href="../_documentation/5_customize.html" title="Customization">Customization</a></li>
  33. <li class="page_item"><a href="../_documentation/6_output.html" title="Output">Output</a></li>
  34. <li class="page_item"><a href="../_documentation/7_api.html" title="API">API&nbsp;</a></li>
  35. </ul>
  36. <h3>Examples</h3>
  37. <ul>
  38. <li class="page_item"><a href="1_datasources.html" title="Data sources">Data sources</a></li>
  39. <li class="page_item"><a href="2_operations.html" title="Operations">Operations</a></li>
  40. <li class="page_item current_page_item"><a href="3_callbacks.html" title="Callbacks">Callbacks</a></li>
  41. <li class="page_item"><a href="4_themes.html" title="Themes">Themes</a></li>
  42. <li class="page_item"><a href="5_others.html" title="Others">Other examples</a></li>
  43. <li class="page_item important"><a href="7_full.html" title="Full example">Full PHP &amp; mySQL example&nbsp;</a></li>
  44. </ul>
  45. </div>
  46. <div id="data" style="margin-top:-45px;">
  47. <div id="content">
  48. <ul class='nav'>
  49. <li><a href="2_operations.html" title="Operations">&laquo;&nbsp;Operations</a></li>
  50. <li><a href="../index.html">Up to Reference</a></li>
  51. <li><a href="4_themes.html" title="Themes">Themes&nbsp;&raquo;</a></li>
  52. </ul>
  53. <h2 style="margin-top:25px;">Callbacks</h2>
  54. <div class="entry"><div id="documentation">
  55. <p>You can view how callbacks are called here.</p>
  56. <div class="tree-drop" rel="tree-drop" style="line-height:16px; background:silver; color:gray; border:3px solid gray; width:200px; text-align:center; margin:10px 0; cursor:move;">You can drop me on the tree</div>
  57. <input type="button" value="refresh" onclick="$.tree_reference('demo').refresh();" style="margin-right:20px;"/>
  58. <input type="button" value="create" onclick="$.tree_reference('demo').create();" />
  59. <input type="button" value="rename" onclick="$.tree_reference('demo').rename();" />
  60. <input type="button" value="remove" onclick="$.tree_reference('demo').remove();" />
  61. <input type="button" value="copy" onclick="$.tree_reference('demo').copy();" />
  62. <input type="button" value="cut" onclick="$.tree_reference('demo').cut();" />
  63. <input type="button" value="paste" onclick="$.tree_reference('demo').paste();" />
  64. <div id="demo" class="demo" style="height:200px;"></div>
  65. <div id="sources" class="sources" style="200px;">
  66. <pre style="height:200px;">
  67. $(function () {
  68. $("#demo").tree({
  69. // Rest omitted
  70. rules : {
  71. droppable : [ "tree-drop" ],
  72. multiple : true,
  73. deletable : "all",
  74. draggable : "all"
  75. },
  76. callback : {
  77. beforechange: function() { log("About to change"); return true },
  78. beforeopen : function() { log("About to open"); return true },
  79. beforeclose : function() { log("About to close"); return true },
  80. beforemove : function() { log("About to move"); return true },
  81. beforecreate: function() { log("About to create"); return true },
  82. beforerename: function() { log("About to rename"); return true },
  83. beforedelete: function() { log("About to delete"); return true },
  84. onselect : function() { log("Select"); },
  85. ondeselect : function() { log("Deselect"); },
  86. onchange : function() { log("Focus changed"); },
  87. onrename : function() { log("Rename"); },
  88. onmove : function() { log("Move"); },
  89. oncopy : function() { log("Copy"); },
  90. oncreate : function() { log("Create"); },
  91. ondelete : function() { log("Delete"); },
  92. onopen : function() { log("Open"); },
  93. onopen_all : function() { log("Open ALL"); },
  94. onclose : function() { log("Close"); },
  95. error : function() { },
  96. ondblclk : function() { log("Doubleclick"); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
  97. onrgtclk : function() { log("Rightclick"); },
  98. onload : function() { log("Tree loaded"); },
  99. onfocus : function() { log("Tree got focus"); },
  100. ondrop : function() { log("Foreign node dropped"); }
  101. }
  102. });
  103. });
  104. </pre>
  105. </div>
  106. <script type="text/javascript">
  107. function log(str) {
  108. $("#log").prepend(str + "<br />");
  109. }
  110. $(function () {
  111. $("#demo").tree({
  112. data : {
  113. type : "json",
  114. json : [
  115. { attributes: { id : "pjson4_1" }, data: "Root node 1", children : [
  116. { attributes: { id : "pjson4_2" }, data: { title : "Custom icon", icon : "../media/images/ok.png" } },
  117. { attributes: { id : "pjson4_3" }, data: "Child node 2" },
  118. { attributes: { id : "pjson4_4" }, data: "Some other child node" }
  119. ]},
  120. { attributes: { id : "pjson4_5" }, data: "Root node 2" }
  121. ]
  122. },
  123. rules : {
  124. droppable : [ "tree-drop" ],
  125. multiple : true,
  126. deletable : "all",
  127. draggable : "all"
  128. },
  129. callback : {
  130. beforechange: function() { log("About to change"); return true },
  131. beforeopen : function() { log("About to open"); return true },
  132. beforeclose : function() { log("About to close"); return true },
  133. beforemove : function() { log("About to move"); return true },
  134. beforecreate: function() { log("About to create"); return true },
  135. beforerename: function() { log("About to rename"); return true },
  136. beforedelete: function() { log("About to delete"); return true },
  137. onselect : function() { log("Select"); },
  138. ondeselect : function() { log("Deselect"); },
  139. onchange : function() { log("Focus changed"); },
  140. onrename : function() { log("Rename"); },
  141. onmove : function() { log("Move"); },
  142. oncopy : function() { log("Copy"); },
  143. oncreate : function() { log("Create"); },
  144. ondelete : function() { log("Delete"); },
  145. onopen : function() { log("Open"); },
  146. onopen_all : function() { log("Open ALL"); },
  147. onclose : function() { log("Close"); },
  148. error : function() { },
  149. ondblclk : function() { log("Doubleclick"); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
  150. onrgtclk : function() { log("Rightclick"); },
  151. onload : function() { log("Tree loaded"); },
  152. onfocus : function() { log("Tree got focus"); },
  153. ondrop : function() { log("Foreign node dropped"); }
  154. }
  155. });
  156. });
  157. </script>
  158. <div id="log" style="border:3px solid gray; margin:5px 15px 5px 0; overflow:auto; padding:5px; background:white; height:100px;">
  159. </div>
  160. </div></div>
  161. </div>
  162. </div>
  163. </div>
  164. </body>
  165. </html>