3_configuration.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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; Documentation </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. </head>
  15. <body>
  16. <div id="container">
  17. <div id="head">
  18. <h1>jsTree</h1>
  19. <h2>javascript tree component</h2>
  20. <h3>Documentation</h3>
  21. </div>
  22. <div id="sidebar">
  23. <h3 style="margin-top:0;">Documentation</h3>
  24. <ul>
  25. <li class="page_item"><a href="1_files.html" title="Required &amp; optional files">Required &#038; optional files</a></li>
  26. <li class="page_item"><a href="2_creation.html" title="Instance creation">Instance creation</a></li>
  27. <li class="page_item current_page_item"><a href="3_configuration.html" title="Configuration">Configuration</a></li>
  28. <li class="page_item"><a href="4_data.html" title="Data sources">Data sources</a></li>
  29. <li class="page_item"><a href="5_customize.html" title="Customization">Customization</a></li>
  30. <li class="page_item"><a href="6_output.html" title="Output">Output</a></li>
  31. <li class="page_item"><a href="7_api.html" title="API">API&nbsp;</a></li>
  32. </ul>
  33. <h3>Examples</h3>
  34. <ul>
  35. <li class="page_item"><a href="../_examples/1_datasources.html" title="Data sources">Data sources</a></li>
  36. <li class="page_item"><a href="../_examples/2_operations.html" title="Operations">Operations</a></li>
  37. <li class="page_item"><a href="../_examples/3_callbacks.html" title="Callbacks">Callbacks</a></li>
  38. <li class="page_item"><a href="../_examples/4_themes.html" title="Themes">Themes</a></li>
  39. <li class="page_item"><a href="../_examples/5_others.html" title="Others">Other examples</a></li>
  40. <li class="page_item important"><a href="../_examples/7_full.html" title="Full example">Full PHP &amp; mySQL example&nbsp;</a></li>
  41. </ul>
  42. </div>
  43. <div id="data" style="margin-top:-45px;">
  44. <div id="content">
  45. <ul class='nav'>
  46. <li><a href="2_creation.html" title="Instance creation">&laquo;&nbsp;Instance creation</a></li>
  47. <li><a href="../index.html">Up to Reference</a></li>
  48. <li><a href="4_data.html" title="Data sources">Data sources&nbsp;&raquo;</a></li>
  49. </ul>
  50. <h2 style="margin-top:25px;">Configuration</h2>
  51. <div class="entry"><div id="documentation">
  52. <p>The <span class="var">options</span> object you pass at <a href="/documentation/create">initialization</a> contains all of the configuration options for the tree.</p>
  53. <p>You could save some time and pass only the properties that are different from the defaults:</p>
  54. <div class="source" id="defaults">Configuration defaults</div>
  55. <pre style="height:400px;">{
  56. data : {
  57. type : "predefined", // ENUM [json, xml_flat, xml_nested, predefined]
  58. method : "GET", // HOW TO REQUEST FILES
  59. async : false, // BOOL - async loading onopen
  60. async_data : function (NODE) { return { id : $(NODE).attr("id") || 0 } }, // PARAMETERS PASSED TO SERVER
  61. url : false, // FALSE or STRING - url to document to be used (async or not)
  62. json : false, // FALSE or OBJECT if type is JSON and async is false - the tree dump as json
  63. xml : false // FALSE or STRING
  64. },
  65. selected : false, // FALSE or STRING or ARRAY
  66. opened : [], // ARRAY OF INITIALLY OPENED NODES
  67. languages : [], // ARRAY of string values (which will be used as CSS classes - so they must be valid)
  68. path : false, // FALSE or STRING (if false - will be autodetected)
  69. cookies : false, // FALSE or OBJECT (prefix, open, selected, opts - from jqCookie - expires, path, domain, secure)
  70. ui : {
  71. dots : true, // BOOL - dots or no dots
  72. rtl : false, // BOOL - is the tree right-to-left
  73. animation : 0, // INT - duration of open/close animations in miliseconds
  74. hover_mode : true, // SHOULD get_* functions chage focus or change hovered item
  75. scroll_spd : 4,
  76. theme_path : false, // Path to themes
  77. theme_name : "default",// Name of theme
  78. context : [
  79. {
  80. id : "create",
  81. label : "Create",
  82. icon : "create.png",
  83. visible : function (NODE, TREE_OBJ) { if(NODE.length != 1) return false; return TREE_OBJ.check("creatable", NODE); },
  84. action : function (NODE, TREE_OBJ) { TREE_OBJ.create(false, TREE_OBJ.get_node(NODE)); }
  85. },
  86. "separator",
  87. {
  88. id : "rename",
  89. label : "Rename",
  90. icon : "rename.png",
  91. visible : function (NODE, TREE_OBJ) { if(NODE.length != 1) return false; return TREE_OBJ.check("renameable", NODE); },
  92. action : function (NODE, TREE_OBJ) { TREE_OBJ.rename(); }
  93. },
  94. {
  95. id : "delete",
  96. label : "Delete",
  97. icon : "remove.png",
  98. visible : function (NODE, TREE_OBJ) { var ok = true; $.each(NODE, function () { if(TREE_OBJ.check("deletable", this) == false) ok = false; return false; }); return ok; },
  99. action : function (NODE, TREE_OBJ) { $.each(NODE, function () { TREE_OBJ.remove(this); }); }
  100. }
  101. ]
  102. },
  103. rules : {
  104. multiple : false, // FALSE | CTRL | ON - multiple selection off/ with or without holding Ctrl
  105. metadata : false, // FALSE or STRING - attribute name (use metadata plugin)
  106. type_attr : "rel", // STRING attribute name (where is the type stored if no metadata)
  107. multitree : false, // BOOL - is drag n drop between trees allowed
  108. createat : "bottom", // STRING (top or bottom) new nodes get inserted at top or bottom
  109. use_inline : false, // CHECK FOR INLINE RULES - REQUIRES METADATA
  110. clickable : "all", // which node types can the user select | default - all
  111. renameable : "all", // which node types can the user select | default - all
  112. deletable : "all", // which node types can the user delete | default - all
  113. creatable : "all", // which node types can the user create in | default - all
  114. draggable : "none", // which node types can the user move | default - none | "all"
  115. dragrules : "all", // what move operations between nodes are allowed | default - none | "all"
  116. drag_copy : false, // FALSE | CTRL | ON - drag to copy off/ with or without holding Ctrl
  117. droppable : [],
  118. drag_button : "left"
  119. },
  120. lang : {
  121. new_node : "New folder",
  122. loading : "Loading ..."
  123. },
  124. callback : { // various callbacks to attach custom logic to
  125. // before focus - should return true | false
  126. beforechange: function(NODE,TREE_OBJ) { return true },
  127. beforeopen : function(NODE,TREE_OBJ) { return true },
  128. beforeclose : function(NODE,TREE_OBJ) { return true },
  129. // before move - should return true | false
  130. beforemove : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true },
  131. // before create - should return true | false
  132. beforecreate: function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true },
  133. // before rename - should return true | false
  134. beforerename: function(NODE,LANG,TREE_OBJ) { return true },
  135. // before delete - should return true | false
  136. beforedelete: function(NODE,TREE_OBJ) { return true },
  137. onJSONdata : function(DATA,TREE_OBJ) { return DATA; },
  138. onselect : function(NODE,TREE_OBJ) { }, // node selected
  139. ondeselect : function(NODE,TREE_OBJ) { }, // node deselected
  140. onchange : function(NODE,TREE_OBJ) { }, // focus changed
  141. onrename : function(NODE,LANG,TREE_OBJ,RB) { }, // node renamed ISNEW - TRUE|FALSE, current language
  142. onmove : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // move completed (TYPE is BELOW|ABOVE|INSIDE)
  143. oncopy : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // copy completed (TYPE is BELOW|ABOVE|INSIDE)
  144. oncreate : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // node created, parent node (TYPE is createat)
  145. ondelete : function(NODE, TREE_OBJ,RB) { }, // node deleted
  146. onopen : function(NODE, TREE_OBJ) { }, // node opened
  147. onopen_all : function(TREE_OBJ) { }, // all nodes opened
  148. onclose : function(NODE, TREE_OBJ) { }, // node closed
  149. error : function(TEXT, TREE_OBJ) { }, // error occured
  150. // double click on node - defaults to open/close & select
  151. ondblclk : function(NODE, TREE_OBJ) { TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
  152. // right click - to prevent use: EV.preventDefault(); EV.stopPropagation(); return false
  153. onrgtclk : function(NODE, TREE_OBJ, EV) { },
  154. onload : function(TREE_OBJ) { },
  155. onfocus : function(TREE_OBJ) { },
  156. ondrop : function(NODE,REF_NODE,TYPE,TREE_OBJ) {}
  157. }
  158. }</pre>
  159. </div></div>
  160. </div>
  161. </div>
  162. </div>
  163. </body>
  164. </html>