PageRenderTime 27ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/webroot/resources/ui/js/jsTree.v.1.0rc2/_demo/index.html

https://github.com/iconifyit/SkyBlue-CMS
HTML | 262 lines | 249 code | 11 blank | 2 comment | 0 complexity | e7c70d4c7a88496f1eb3aad1683e4b13 MD5 | raw file
  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 v.1.0 - full featured demo</title>
  8. <script type="text/javascript" src="../_lib/jquery.js"></script>
  9. <script type="text/javascript" src="../_lib/jquery.cookie.js"></script>
  10. <script type="text/javascript" src="../_lib/jquery.hotkeys.js"></script>
  11. <script type="text/javascript" src="../jquery.jstree.js"></script>
  12. <style type="text/css">
  13. html, body { margin:0; padding:0; }
  14. body, td, th, pre, code, select, option, input, textarea { font-family:verdana,arial,sans-serif; font-size:10px; }
  15. .demo, .demo input, .jstree-dnd-helper, #vakata-contextmenu { font-size:10px; font-family:Verdana; }
  16. #container { width:780px; margin:10px auto; overflow:hidden; position:relative; }
  17. #demo { width:auto; height:400px; overflow:auto; border:1px solid gray; }
  18. #text { margin-top:1px; }
  19. #alog { font-size:9px !important; margin:5px; border:1px solid silver; }
  20. </style>
  21. </head>
  22. <body>
  23. <div id="container">
  24. <div id="mmenu" style="height:30px; overflow:auto;">
  25. <input type="button" id="add_folder" value="add folder" style="display:block; float:left;"/>
  26. <input type="button" id="add_default" value="add file" style="display:block; float:left;"/>
  27. <input type="button" id="rename" value="rename" style="display:block; float:left;"/>
  28. <input type="button" id="remove" value="remove" style="display:block; float:left;"/>
  29. <input type="button" id="cut" value="cut" style="display:block; float:left;"/>
  30. <input type="button" id="copy" value="copy" style="display:block; float:left;"/>
  31. <input type="button" id="paste" value="paste" style="display:block; float:left;"/>
  32. <input type="button" id="clear_search" value="clear" style="display:block; float:right;"/>
  33. <input type="button" id="search" value="search" style="display:block; float:right;"/>
  34. <input type="text" id="text" value="" style="display:block; float:right;" />
  35. </div>
  36. <!-- the tree container (notice NOT an UL node) -->
  37. <div id="demo" class="demo"></div>
  38. <!-- JavaScript neccessary for the tree -->
  39. <script type="text/javascript">
  40. $(function () {
  41. // Settings up the tree - using $(selector).jstree(options);
  42. // All those configuration options are documented in the _docs folder
  43. $("#demo")
  44. .jstree({
  45. // the list of plugins to include
  46. "plugins" : [ "themes", "json_data", "ui", "crrm", "cookies", "dnd", "search", "types", "hotkeys", "contextmenu" ],
  47. // Plugin configuration
  48. // I usually configure the plugin that handles the data first - in this case JSON as it is most common
  49. "json_data" : {
  50. // I chose an ajax enabled tree - again - as this is most common, and maybe a bit more complex
  51. // All the options are the same as jQuery's except for `data` which CAN (not should) be a function
  52. "ajax" : {
  53. // the URL to fetch the data
  54. "url" : "./server.php",
  55. // this function is executed in the instance's scope (this refers to the tree instance)
  56. // the parameter is the node being loaded (may be -1, 0, or undefined when loading the root nodes)
  57. "data" : function (n) {
  58. // the result is fed to the AJAX request `data` option
  59. return {
  60. "operation" : "get_children",
  61. "id" : n.attr ? n.attr("id").replace("node_","") : 1
  62. };
  63. }
  64. }
  65. },
  66. // Configuring the search plugin
  67. "search" : {
  68. // As this has been a common question - async search
  69. // Same as above - the `ajax` config option is actually jQuery's object (only `data` can be a function)
  70. "ajax" : {
  71. "url" : "./server.php",
  72. // You get the search string as a parameter
  73. "data" : function (str) {
  74. return {
  75. "operation" : "search",
  76. "search_str" : str
  77. };
  78. }
  79. }
  80. },
  81. // Using types - most of the time this is an overkill
  82. // Still meny people use them - here is how
  83. "types" : {
  84. // I set both options to -2, as I do not need depth and children count checking
  85. // Those two checks may slow jstree a lot, so use only when needed
  86. "max_depth" : -2,
  87. "max_children" : -2,
  88. // I want only `drive` nodes to be root nodes
  89. // This will prevent moving or creating any other type as a root node
  90. "valid_children" : [ "drive" ],
  91. "types" : {
  92. // The default type
  93. "default" : {
  94. // I want this type to have no children (so only leaf nodes)
  95. // In my case - those are files
  96. "valid_children" : "none",
  97. // If we specify an icon for the default type it WILL OVERRIDE the theme icons
  98. "icon" : {
  99. "image" : "./file.png"
  100. }
  101. },
  102. // The `folder` type
  103. "folder" : {
  104. // can have files and other folders inside of it, but NOT `drive` nodes
  105. "valid_children" : [ "default", "folder" ],
  106. "icon" : {
  107. "image" : "./folder.png"
  108. }
  109. },
  110. // The `drive` nodes
  111. "drive" : {
  112. // can have files and folders inside, but NOT other `drive` nodes
  113. "valid_children" : [ "default", "folder" ],
  114. "icon" : {
  115. "image" : "./root.png"
  116. },
  117. // those options prevent the functions with the same name to be used on the `drive` type nodes
  118. // internally the `before` event is used
  119. "start_drag" : false,
  120. "move_node" : false,
  121. "delete_node" : false,
  122. "remove" : false
  123. }
  124. }
  125. },
  126. // For UI & core - the nodes to initially select and open will be overwritten by the cookie plugin
  127. // the UI plugin - it handles selecting/deselecting/hovering nodes
  128. "ui" : {
  129. // this makes the node with ID node_4 selected onload
  130. "initially_select" : [ "node_4" ]
  131. },
  132. // the core plugin - not many options here
  133. "core" : {
  134. // just open those two nodes up
  135. // as this is an AJAX enabled tree, both will be downloaded from the server
  136. "initially_open" : [ "node_2" , "node_3" ]
  137. }
  138. })
  139. .bind("create.jstree", function (e, data) {
  140. $.post(
  141. "./server.php",
  142. {
  143. "operation" : "create_node",
  144. "id" : data.rslt.parent.attr("id").replace("node_",""),
  145. "position" : data.rslt.position,
  146. "title" : data.rslt.name,
  147. "type" : data.rslt.obj.attr("rel")
  148. },
  149. function (r) {
  150. if(r.status) {
  151. $(data.rslt.obj).attr("id", "node_" + r.id);
  152. }
  153. else {
  154. $.jstree.rollback(data.rlbk);
  155. }
  156. }
  157. );
  158. })
  159. .bind("remove.jstree", function (e, data) {
  160. data.rslt.obj.each(function () {
  161. $.ajax({
  162. async : false,
  163. type: 'POST',
  164. url: "./server.php",
  165. data : {
  166. "operation" : "remove_node",
  167. "id" : this.id.replace("node_","")
  168. },
  169. success : function (r) {
  170. if(!r.status) {
  171. data.inst.refresh();
  172. }
  173. }
  174. });
  175. });
  176. })
  177. .bind("rename.jstree", function (e, data) {
  178. $.post(
  179. "./server.php",
  180. {
  181. "operation" : "rename_node",
  182. "id" : data.rslt.obj.attr("id").replace("node_",""),
  183. "title" : data.rslt.new_name
  184. },
  185. function (r) {
  186. if(!r.status) {
  187. $.jstree.rollback(data.rlbk);
  188. }
  189. }
  190. );
  191. })
  192. .bind("move_node.jstree", function (e, data) {
  193. data.rslt.o.each(function (i) {
  194. $.ajax({
  195. async : false,
  196. type: 'POST',
  197. url: "./server.php",
  198. data : {
  199. "operation" : "move_node",
  200. "id" : $(this).attr("id").replace("node_",""),
  201. "ref" : data.rslt.np.attr("id").replace("node_",""),
  202. "position" : data.rslt.cp + i,
  203. "title" : data.rslt.name,
  204. "copy" : data.rslt.cy ? 1 : 0
  205. },
  206. success : function (r) {
  207. if(!r.status) {
  208. $.jstree.rollback(data.rlbk);
  209. }
  210. else {
  211. $(data.rslt.oc).attr("id", "node_" + r.id);
  212. if(data.rslt.cy && $(data.rslt.oc).children("UL").length) {
  213. data.inst.refresh(data.inst._get_parent(data.rslt.oc));
  214. }
  215. }
  216. $("#analyze").click();
  217. }
  218. });
  219. });
  220. });
  221. });
  222. </script>
  223. <script type="text/javascript">
  224. $(function () {
  225. $("#mmenu input").click(function () {
  226. switch(this.id) {
  227. case "add_default":
  228. case "add_folder":
  229. $("#demo").jstree("create", null, "last", { "attr" : { "rel" : this.id.toString().replace("add_", "") } });
  230. break;
  231. case "search":
  232. $("#demo").jstree("search", document.getElementById("text").value);
  233. break;
  234. case "text": break;
  235. default:
  236. $("#demo").jstree(this.id);
  237. break;
  238. }
  239. });
  240. });
  241. </script>
  242. <div style="position:absolute; right:30px; top:120px; width:220px; border:1px solid silver; min-height:160px;">
  243. <input type="button" style='display:block; width:170px; height:24px; margin:5px auto;' value="reconstruct" onclick="$.get('./server.php?reconstruct', function () { $('#demo').jstree('refresh',-1); });" />
  244. <input type="button" style='display:block; width:170px; height:24px; margin:5px auto;' id="analyze" value="analyze" onclick="$('#alog').load('./server.php?analyze');" />
  245. <input type="button" style='display:block; width:170px; height:24px; margin:5px auto;' value="refresh" onclick="$('#demo').jstree('refresh',-1);" />
  246. <div id='alog'></div>
  247. </div>
  248. <p style="margin:1em 2em 3em 2em; text-align:center; ">If you like the project - consider <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@vakata.com&currency_code=USD&amount=&return=http://jstree.com/donation&item_name=Buy+me+a+coffee+for+jsTree">supporting jstree</a>.</p>
  249. </div>
  250. </body>
  251. </html>