examples.treeview.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. (function ($) {
  2. 'use strict';
  3. /*
  4. Basic
  5. */
  6. $('#treeBasic').jstree({
  7. 'core': {
  8. 'themes': {
  9. 'responsive': false
  10. }
  11. },
  12. 'types': {
  13. 'default': {
  14. 'icon': 'fa fa-folder'
  15. },
  16. 'file': {
  17. 'icon': 'fa fa-file'
  18. }
  19. },
  20. 'plugins': ['types']
  21. });
  22. /*
  23. Checkbox
  24. */
  25. $('#treeCheckbox').jstree({
  26. 'core': {
  27. 'themes': {
  28. 'responsive': false
  29. }
  30. },
  31. 'types': {
  32. 'default': {
  33. 'icon': 'fa fa-folder'
  34. },
  35. 'file': {
  36. 'icon': 'fa fa-file'
  37. }
  38. },
  39. 'plugins': ['types', 'checkbox']
  40. });
  41. /*
  42. Ajax HTML
  43. */
  44. $('#treeAjaxHTML').jstree({
  45. 'core': {
  46. 'themes': {
  47. 'responsive': false
  48. },
  49. 'check_callback': true,
  50. 'data': {
  51. 'url': 'testFile.php?folder=',
  52. }
  53. },
  54. 'types': {
  55. 'default': {
  56. 'icon': 'fa fa-folder'
  57. },
  58. 'file': {
  59. 'icon': 'fa fa-file'
  60. }
  61. },
  62. 'plugins': ['types']
  63. }).on(
  64. 'select_node.jstree',
  65. function (event, data) {
  66. if(data.node.text.includes(".")){
  67. window.location.href = data.node.a_attr.href;
  68. //console.log(data);
  69. }
  70. });
  71. /*
  72. Ajax JSON
  73. */
  74. $('#treeAjaxJSON').jstree({
  75. 'core': {
  76. 'themes': {
  77. 'responsive': false
  78. },
  79. 'check_callback': true,
  80. 'data': {
  81. 'url': function (node) {
  82. return node.id === '#' ? 'assets/ajax/ajax-treeview-roots.json' : 'assets/ajax/ajax-treeview-children.json';
  83. },
  84. 'data': function (node) {
  85. return {
  86. 'id': node.id
  87. };
  88. }
  89. }
  90. },
  91. 'types': {
  92. 'default': {
  93. 'icon': 'fa fa-folder'
  94. },
  95. 'file': {
  96. 'icon': 'fa fa-file'
  97. }
  98. },
  99. 'plugins': ['types']
  100. });
  101. /*
  102. Drag & Drop
  103. */
  104. $('#treeDragDrop').jstree({
  105. 'core': {
  106. 'check_callback': true,
  107. 'themes': {
  108. 'responsive': false
  109. }
  110. },
  111. 'types': {
  112. 'default': {
  113. 'icon': 'fa fa-folder'
  114. },
  115. 'file': {
  116. 'icon': 'fa fa-file'
  117. }
  118. },
  119. 'plugins': ['types', 'dnd']
  120. });
  121. }).apply(this, [jQuery]);