awesome.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4. <TITLE> ZTREE DEMO - awesome 风格</TITLE>
  5. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  6. <!-- Include font-awesome here, CDN is ok, or locally installed by bower to your project -->
  7. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  8. <link rel="stylesheet" href="../../../css/demo.css" type="text/css">
  9. <link rel="stylesheet" href="../../../css/awesomeStyle/awesome.css" type="text/css">
  10. <script type="text/javascript" src="../../../js/jquery.min.js"></script>
  11. <!-- <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>-->
  12. <script type="text/javascript" src="../../../js/jquery.ztree.core.js"></script>
  13. <script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
  14. <script type="text/javascript" src="../../../js/jquery.ztree.exedit.js"></script>
  15. <SCRIPT type="text/javascript">
  16. <!--
  17. var setting = {
  18. view: {
  19. addHoverDom: addHoverDom,
  20. removeHoverDom: removeHoverDom,
  21. selectedMulti: false
  22. },
  23. check: {
  24. enable: true
  25. ,chkStyle: 'radio'
  26. ,radioType: "level"
  27. },
  28. data: {
  29. simpleData: {
  30. enable: true
  31. }
  32. },
  33. edit: {
  34. enable: true
  35. }
  36. };
  37. var zNodes =[
  38. { id:1, pId:0, name:"pNode 1", open:true},
  39. { id:11, pId:1, name:"pNode 11"},
  40. { id:111, pId:11, name:" sNode 111"},
  41. { id:112, pId:11, name:"sNode 112"},
  42. { id:113, pId:11, name:"sNode 113"},
  43. { id:114, pId:11, name:"sNode 114"},
  44. { id:12, pId:1, name:"pNode 12"},
  45. { id:121, pId:12, name:"sNode 121"},
  46. { id:122, pId:12, name:"sNode 122"},
  47. { id:123, pId:12, name:"sNode 123"},
  48. { id:124, pId:12, name:"sNode 124"},
  49. { id:13, pId:1, name:"pNode 13", isParent:true},
  50. { id:2, pId:0, name:"pNode 2"},
  51. { id:21, pId:2, name:"pNode 21", open:true},
  52. { id:211, pId:21, name:"sNode 211"},
  53. { id:212, pId:21, name:"sNode 212"},
  54. { id:213, pId:21, name:"sNode 213"},
  55. { id:214, pId:21, name:"sNode 214"},
  56. { id:22, pId:2, name:"pNode 22"},
  57. { id:221, pId:22, name:"sNode 221"},
  58. { id:222, pId:22, name:"sNode 222"},
  59. { id:223, pId:22, name:"sNode 223"},
  60. { id:224, pId:22, name:"sNode 224"},
  61. { id:23, pId:2, name:"pNode 23"},
  62. { id:231, pId:23, name:"sNode 231"},
  63. { id:232, pId:23, name:"sNode 232"},
  64. { id:233, pId:23, name:"sNode 233"},
  65. { id:234, pId:23, name:"sNode 234"},
  66. { id:3, pId:0, name:"pNode 3", isParent:true}
  67. ];
  68. function setCheck() {
  69. setting.check.chkStyle = $("#r1").attr("checked")? "checkbox":"radio";
  70. setting.check.enable = (!$("#disablechk").attr("checked"));
  71. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  72. }
  73. $(document).ready(function(){
  74. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  75. setCheck();
  76. $("#r1").bind("change", setCheck);
  77. $("#r2").bind("change", setCheck);
  78. $("#disablechk").bind("change", setCheck);
  79. });
  80. var newCount = 1;
  81. function addHoverDom(treeId, treeNode) {
  82. var sObj = $("#" + treeNode.tId + "_span");
  83. if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
  84. var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
  85. + "' title='add node' onfocus='this.blur();'></span>";
  86. sObj.after(addStr);
  87. var btn = $("#addBtn_"+treeNode.tId);
  88. if (btn) btn.bind("click", function(){
  89. var zTree = $.fn.zTree.getZTreeObj("treeDemo");
  90. zTree.addNodes(treeNode, {id:(100 + newCount), pId:treeNode.id, name:"new node" + (newCount++)});
  91. return false;
  92. });
  93. };
  94. function removeHoverDom(treeId, treeNode) {
  95. $("#addBtn_"+treeNode.tId).unbind().remove();
  96. };
  97. //-->
  98. </SCRIPT>
  99. </HEAD>
  100. <BODY>
  101. <h1>Awesome 风格</h1>
  102. <h6>[ 文件路径: super/awesome.html ]</h6>
  103. <div class="content_wrap">
  104. <div class="bg left">
  105. <ul id="treeDemo" class="ztree"></ul>
  106. </div>
  107. <div class="right">
  108. <ul class="info">
  109. <li class="title"><h2>实现方法说明</h2>
  110. <ul class="list">
  111. <li>你需要在页面中引入 fontawesome 样式 (http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css)</li>
  112. <li> <i class="fa fa-car"></i> &lt;= 小汽车图标 (如果 fontawesome 样式被正常加载,你可以正常看到)</li>
  113. <li class="highlight_red">引入 适配 zTree 的 样式文件: 'css/awesomeStyle'</li>
  114. <li>感谢 mikkelking 提供这个 Demo. (仅供参考)</li>
  115. <li><p>Mode: <br/>
  116. <label ><input type="radio" id="r1" class="radio first" name="r" value="checkbox" checked />
  117. Checkbox</label>
  118. <label><input type="radio" id="r2" class="radio" name="r" value="radio" /> Radio</label>
  119. <label><input type="checkbox" id="disablechk" > Disable</label>
  120. <br/>
  121. </li>
  122. </ul>
  123. </ul>
  124. </li>
  125. </ul>
  126. </div>
  127. </div>
  128. </BODY>
  129. </HTML>