treeview-demo.min.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. $(function() {
  2. var e = [{
  3. text: "父节点 1",
  4. href: "#parent1",
  5. tags: ["4"],
  6. nodes: [{
  7. text: "子节点 1",
  8. href: "#child1",
  9. tags: ["2"],
  10. nodes: [{
  11. text: "孙子节点 1",
  12. href: "#grandchild1",
  13. tags: ["0"]
  14. },
  15. {
  16. text: "孙子节点 2",
  17. href: "#grandchild2",
  18. tags: ["0"]
  19. }]
  20. },
  21. {
  22. text: "子节点 2",
  23. href: "#child2",
  24. tags: ["0"]
  25. }]
  26. },
  27. {
  28. text: "父节点 2",
  29. href: "#parent2",
  30. tags: ["0"]
  31. },
  32. {
  33. text: "父节点 3",
  34. href: "#parent3",
  35. tags: ["0"]
  36. },
  37. {
  38. text: "父节点 4",
  39. href: "#parent4",
  40. tags: ["0"]
  41. },
  42. {
  43. text: "父节点 5",
  44. href: "#parent5",
  45. tags: ["0"]
  46. }],
  47. o = [{
  48. text: "父节点 1",
  49. tags: ["2"],
  50. nodes: [{
  51. text: "子节点 1",
  52. tags: ["3"],
  53. nodes: [{
  54. text: "孙子节点 1",
  55. tags: ["6"]
  56. },
  57. {
  58. text: "孙子节点 2",
  59. tags: ["3"]
  60. }]
  61. },
  62. {
  63. text: "子节点 2",
  64. tags: ["3"]
  65. }]
  66. },
  67. {
  68. text: "父节点 2",
  69. tags: ["7"]
  70. },
  71. {
  72. text: "父节点 3",
  73. icon: "glyphicon glyphicon-earphone",
  74. href: "#demo",
  75. tags: ["11"]
  76. },
  77. {
  78. text: "父节点 4",
  79. icon: "glyphicon glyphicon-cloud-download",
  80. href: "/demo.html",
  81. tags: ["19"],
  82. selected: !0
  83. },
  84. {
  85. text: "父节点 5",
  86. icon: "glyphicon glyphicon-certificate",
  87. color: "pink",
  88. backColor: "red",
  89. href: "http://www.tesco.com",
  90. tags: ["available", "0"]
  91. }],
  92. t = '[{"text": "父节点 1","nodes": [{"text": "子节点 1","nodes": [{"text": "孙子节点 1"},{"text": "孙子节点 2"}]},{"text": "子节点 2"}]},{"text": "父节点 2"},{"text": "父节点 3"},{"text": "父节点 4"},{"text": "父节点 5"}]';
  93. $("#treeview1").treeview({
  94. data: e
  95. }),
  96. $("#treeview2").treeview({
  97. levels: 1,
  98. data: e
  99. }),
  100. $("#treeview3").treeview({
  101. levels: 99,
  102. data: e
  103. }),
  104. $("#treeview4").treeview({
  105. color: "#428bca",
  106. data: e
  107. }),
  108. $("#treeview5").treeview({
  109. color: "#428bca",
  110. expandIcon: "glyphicon glyphicon-chevron-right",
  111. collapseIcon: "glyphicon glyphicon-chevron-down",
  112. nodeIcon: "glyphicon glyphicon-bookmark",
  113. data: e
  114. }),
  115. $("#treeview6").treeview({
  116. color: "#428bca",
  117. expandIcon: "glyphicon glyphicon-stop",
  118. collapseIcon: "glyphicon glyphicon-unchecked",
  119. nodeIcon: "glyphicon glyphicon-user",
  120. showTags: !0,
  121. data: e
  122. }),
  123. $("#treeview7").treeview({
  124. color: "#428bca",
  125. showBorder: !1,
  126. data: e
  127. }),
  128. $("#treeview8").treeview({
  129. expandIcon: "glyphicon glyphicon-stop",
  130. collapseIcon: "glyphicon glyphicon-unchecked",
  131. nodeIcon: "glyphicon glyphicon-user",
  132. color: "yellow",
  133. backColor: "purple",
  134. onhoverColor: "orange",
  135. borderColor: "red",
  136. showBorder: !1,
  137. showTags: !0,
  138. highlightSelected: !0,
  139. selectedColor: "yellow",
  140. selectedBackColor: "darkorange",
  141. data: e
  142. }),
  143. $("#treeview9").treeview({
  144. expandIcon: "glyphicon glyphicon-stop",
  145. collapseIcon: "glyphicon glyphicon-unchecked",
  146. nodeIcon: "glyphicon glyphicon-user",
  147. color: "yellow",
  148. backColor: "purple",
  149. onhoverColor: "orange",
  150. borderColor: "red",
  151. showBorder: !1,
  152. showTags: !0,
  153. highlightSelected: !0,
  154. selectedColor: "yellow",
  155. selectedBackColor: "darkorange",
  156. data: o
  157. }),
  158. $("#treeview10").treeview({
  159. color: "#428bca",
  160. enableLinks: !0,
  161. data: e
  162. }),
  163. $("#treeview11").treeview({
  164. color: "#428bca",
  165. data: e,
  166. onNodeSelected: function(e, o) {
  167. $("#event_output").prepend("<p>您单击了 " + o.text + "</p>")
  168. }
  169. }),
  170. $("#treeview12").treeview({
  171. data: t
  172. })
  173. });