examples.treeview.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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': './script/php/getTree.php?folder=' + 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. }).bind('loaded.jstree', function (e, data) {
  71. // invoked after jstree has loaded
  72. $('.jstree-anchor').each(function (index) {
  73. if ($(this).attr('href').includes(".dll") || $(this).attr('href').includes(".dyn")) {
  74. api = $(this).attr('href');
  75. }
  76. });
  77. if (api != null) {
  78. var fileNames = api.split("/");
  79. fileName = fileNames[fileNames.length - 1];
  80. $("#api").attr("href", api)
  81. $("#api").append(fileName);
  82. }
  83. });
  84. /*
  85. Ajax JSON
  86. */
  87. $('#treeAjaxJSON').jstree({
  88. 'core': {
  89. 'themes': {
  90. 'responsive': false
  91. },
  92. 'check_callback': true,
  93. 'data': {
  94. 'url': function (node) {
  95. return node.id === '#' ? 'assets/ajax/ajax-treeview-roots.json' : 'assets/ajax/ajax-treeview-children.json';
  96. },
  97. 'data': function (node) {
  98. return {
  99. 'id': node.id
  100. };
  101. }
  102. }
  103. },
  104. 'types': {
  105. 'default': {
  106. 'icon': 'fa fa-folder'
  107. },
  108. 'file': {
  109. 'icon': 'fa fa-file'
  110. }
  111. },
  112. 'plugins': ['types']
  113. });
  114. /*
  115. Drag & Drop
  116. */
  117. $('#treeDragDrop').jstree({
  118. 'core': {
  119. 'check_callback': true,
  120. 'themes': {
  121. 'responsive': false
  122. }
  123. },
  124. 'types': {
  125. 'default': {
  126. 'icon': 'fa fa-folder'
  127. },
  128. 'file': {
  129. 'icon': 'fa fa-file'
  130. }
  131. },
  132. 'plugins': ['types', 'dnd']
  133. });
  134. }).apply(this, [jQuery]);