index.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Org Chart</title>
  5. <link rel="stylesheet" href="jquery.orgchart.css"/>
  6. <style>
  7. body {
  8. font-family : Ubuntu, SansSerif
  9. }
  10. h1 {
  11. padding-bottom : 10px;
  12. text-align : center;
  13. }
  14. h2 {
  15. margin-top : 0px;
  16. margin-bottom : 8px;
  17. }
  18. p {
  19. margin : 0px;
  20. padding : 0px;
  21. line-height : 1.5em;
  22. }
  23. div#text {
  24. padding : 10px;
  25. }
  26. </style>
  27. <script src="../jquery/jquery.min.js"></script>
  28. <script src="jquery.textchildren.js"></script>
  29. <script src="jquery.orgchart.js"></script>
  30. <script>
  31. $(function() {
  32. $("#showList").click(function() {
  33. $("#org").toggle();
  34. return false;
  35. });
  36. $("#org").orgChart({
  37. levels : -1,
  38. stack : false,
  39. nodeText : function($node) {return $node.textChildren();}},
  40. $("#main"));
  41. });
  42. </script>
  43. </head>
  44. <body>
  45. <h1>JQuery/CSS Organisation Chart</h1>
  46. <div id="main">
  47. </div>
  48. <div id="text">
  49. <h2>Description</h2>
  50. <p>
  51. Use JQuery to transform a hidden nested unordered list into an organisation chart. Click on the nodes to show/hide child nodes.
  52. </p>
  53. <p>
  54. <a id="showList" href="#">Show</a> the underlying unordered list.
  55. </p>
  56. </div>
  57. <ul id="org" style="display: none;">
  58. <li>
  59. Complex
  60. <ul>
  61. <li>One</li>
  62. <li>Two
  63. <ul>
  64. <li>Two - A</li>
  65. <li>Two - B</li>
  66. </ul>
  67. </li>
  68. <li>Three
  69. <ul>
  70. <li>Three - A
  71. <ul>
  72. <li>Three - A1</li>
  73. </ul>
  74. </li>
  75. <li>Three - B
  76. <ul>
  77. <li>Three - B1</li>
  78. <li>Three - B2</li>
  79. <li>Three - B3
  80. <ul>
  81. <li>ThreeB3A</li>
  82. </ul>
  83. </li>
  84. </ul>
  85. </li>
  86. <li>Three - C
  87. <ul>
  88. <li>Three - C1</li>
  89. <li>Three - C2</li>
  90. </ul>
  91. </li>
  92. <li>Three - D</li>
  93. </ul>
  94. </li>
  95. <li>Four</li>
  96. <li>Five
  97. <ul>
  98. <li>Five - A</li>
  99. <li>Five - B</li>
  100. </ul>
  101. </li>
  102. </ul>
  103. </li>
  104. </ul>
  105. </body>
  106. </html>