bda10cb9756c0245888ba866e64f0e129b167c09.svn-base 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title></title>
  6. <!--框架必需start-->
  7. <script type="text/javascript" src="../../libs/js/jquery.js"></script>
  8. <script type="text/javascript" src="../../libs/js/language/cn.js"></script>
  9. <script type="text/javascript" src="../../libs/js/framework.js"></script>
  10. <link href="../../libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  11. <link rel="stylesheet" type="text/css" id="skin" prePath="../../"/>
  12. <link rel="stylesheet" type="text/css" id="customSkin"/>
  13. <!--框架必需end-->
  14. <!--树组件start -->
  15. <script type="text/javascript" src="../../libs/js/tree/ztree/ztree.js"></script>
  16. <link href="../../libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
  17. <!--树组件end -->
  18. <script>
  19. var curMenu = null, zTree_Menu = null;
  20. var setting = {
  21. view: {
  22. showLine: false,
  23. showIcon: false,
  24. selectedMulti: false,
  25. dblClickExpand: false,
  26. addDiyDom: addDiyDom
  27. },
  28. data: {
  29. simpleData: {
  30. enable: true
  31. }
  32. },
  33. callback: {
  34. beforeClick:beforeClick
  35. }
  36. };
  37. var zNodes =[
  38. { id:1, parentId:0, name:"特11(彩虹城小区-时代庄园北站)",info:[{key:"运营时间",value:"5:20-23:20",colspan:true},{key:"票价",value:"1元"},{key:"是否单一票制",value:"是"},{key:"公司",value:"客五"},{key:"是否无人售票",value:"是"},{key:"线路长度",value:"12.5公里"}]},
  39. { id:11, parentId:1, name:"1、彩虹城小区"},
  40. { id:12, parentId:1, name:"2、光彩路南口"},
  41. { id:13, parentId:1, name:"3、光彩路南口"},
  42. { id:14, parentId:1, name:"4、石榴园"},
  43. { id:15, parentId:1, name:"5、赵公口桥南"},
  44. { id:16, parentId:1, name:"6、彩虹城小区"},
  45. { id:17, parentId:1, name:"7、光彩路南口"},
  46. { id:18, parentId:1, name:"8、光彩路南口"},
  47. { id:19, parentId:1, name:"9、石榴园"},
  48. { id:110, parentId:1, name:"10、赵公口桥南"},
  49. { id:111, parentId:1, name:"11、彩虹城小区"},
  50. { id:112, parentId:1, name:"12、光彩路南口"},
  51. { id:113, parentId:1, name:"13、光彩路南口"},
  52. { id:114, parentId:1, name:"14、石榴园"},
  53. { id:115, parentId:1, name:"15、赵公口桥南"},
  54. { id:116, parentId:1, name:"16、彩虹城小区"},
  55. { id:117, parentId:1, name:"17、光彩路南口"},
  56. { id:118, parentId:1, name:"18、光彩路南口"},
  57. { id:119, parentId:1, name:"19、石榴园"},
  58. { id:120, parentId:1, name:"20、赵公口桥南"},
  59. { id:2, parentId:0, name:"特11(时代庄园北站-彩虹城小区)",info:[{key:"运营时间",value:"5:20-23:20",colspan:"true"},{key:"票价",value:"1元"},{key:"是否单一票制",value:"是"},{key:"公司",value:"客五"},{key:"是否无人售票",value:"是"},{key:"线路长度",value:"12.5公里"}]},
  60. { id:21, parentId:2, name:"1、彩虹城小区"},
  61. { id:22, parentId:2, name:"2、光彩路南口"},
  62. { id:23, parentId:2, name:"3、光彩路南口"},
  63. { id:24, parentId:2, name:"4、石榴园"},
  64. { id:25, parentId:2, name:"5、赵公口桥南"},
  65. { id:26, parentId:2, name:"6、彩虹城小区"},
  66. { id:27, parentId:2, name:"7、光彩路南口"},
  67. { id:28, parentId:2, name:"8、光彩路南口"},
  68. { id:29, parentId:2, name:"9、石榴园"},
  69. { id:210, parentId:2, name:"10、赵公口桥南"},
  70. { id:211, parentId:2, name:"11、彩虹城小区"},
  71. { id:212, parentId:2, name:"12、光彩路南口"},
  72. { id:213, parentId:2, name:"13、光彩路南口"},
  73. { id:214, parentId:2, name:"14、石榴园"},
  74. { id:215, parentId:2, name:"15、赵公口桥南"},
  75. { id:216, parentId:2, name:"16、彩虹城小区"},
  76. { id:217, parentId:2, name:"17、光彩路南口"},
  77. { id:218, parentId:2, name:"18、光彩路南口"},
  78. { id:219, parentId:2, name:"19、石榴园"},
  79. { id:220, parentId:2, name:"20、赵公口桥南"}
  80. ];
  81. function initComplete(){
  82. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  83. zTree_Menu = $.fn.zTree.getZTreeObj("treeDemo");
  84. }
  85. function beforeClick(treeId, treeNode) {
  86. //第一级点击项添加选中样式
  87. if (treeNode.level === 0) {
  88. //第一级移除选中样式
  89. $("#"+treeId).find("a").each(function(){
  90. if($(this).hasClass("cur")){
  91. $(this).removeClass("cur");
  92. $(this).next("div").hide();
  93. }
  94. })
  95. var a = $("#" + treeNode.tId + "_a");
  96. a.addClass("cur");
  97. a.next("div").show();
  98. //单击展开或收缩
  99. if(treeNode.open){
  100. zTree_Menu.expandNode(treeNode,false);
  101. var a = $("#" + treeNode.tId + "_a");
  102. a.removeClass("cur");
  103. a.next("div").hide();
  104. }
  105. else{
  106. zTree_Menu.expandAll(false);
  107. zTree_Menu.expandNode(treeNode);
  108. }
  109. }
  110. else{
  111. zTree_Menu.expandNode(treeNode);
  112. }
  113. }
  114. function addDiyDom(treeId, treeNode) {
  115. var aObj = $("#" + treeNode.tId + "_a");
  116. if ($("#infoBtn_"+treeNode.id).length>0) return;
  117. if(treeNode.isParent){
  118. var infoCon= $('<div class="ztree_custom_info"></div>');
  119. var ul=$('<ul></ul>');
  120. $.each(treeNode.info, function(idx, item){
  121. var li=$('<li></li>');
  122. li.text(item.key+":"+item.value);
  123. if(item.colspan){
  124. if(item.colspan=="true"||item.colspan==true){
  125. li.width(240);
  126. }
  127. }
  128. else{
  129. li.width(120);
  130. }
  131. ul.append(li);
  132. })
  133. ul.append('<div class="clear"></div>');
  134. infoCon.append(ul);
  135. aObj.after(infoCon);
  136. }
  137. };
  138. </script>
  139. <style>
  140. .ztree_custom{
  141. padding:0!important;
  142. }
  143. .ztree_custom li a.level0 {
  144. width:248px;
  145. height: 29px;
  146. background: white url(../../sample_html/tree/accTabNor.jpg) repeat-x center left;
  147. text-decoration:none;
  148. text-align:left;
  149. padding:0;
  150. margin:2px 0 5px 0;
  151. text-indent:10px;
  152. display:block;
  153. border-left:solid 1px #a3b0b9;
  154. border-right:solid 1px #a3b0b9;
  155. }
  156. .ztree_custom li a.level0 span{
  157. margin-left:4px!important;
  158. }
  159. .ztree_custom li a:hover.level0{
  160. text-decoration:none;
  161. }
  162. .ztree_custom li a.level0.cur {/*选中样式*/
  163. background-image: url("../../sample_html/tree/accTabCur.jpg")!important;
  164. color:white!important;
  165. background-color:white!important;
  166. }
  167. .ztree_custom li a.level0.cur span{
  168. color:white!important;
  169. }
  170. .ztree_custom li a.level0 span {
  171. display: block;
  172. color: #03509e;
  173. padding-top:3px;
  174. font-size:12px;
  175. word-spacing: 2px;
  176. }
  177. .ztree_custom li a.level0 span {
  178. float:left;
  179. margin:3px 0 0 15px;
  180. }
  181. .ztree_custom li span.switch.level0 {
  182. display:none;
  183. }
  184. .ztree_custom li ul{
  185. padding-left:0!important;
  186. }
  187. .ztree_custom_info{
  188. width:240px;
  189. white-space:normal;
  190. line-height:200%;
  191. border:solid 1px #799297;
  192. background-color:#f2f2f2;
  193. padding-left:5px!important;
  194. padding-right:5px!important;
  195. display:none;
  196. margin-bottom:5px!important;
  197. }
  198. .ztree_custom_info ul{
  199. margin:0!important;
  200. padding:0!important;
  201. }
  202. .ztree_custom_info ul li{
  203. margin:0!important;
  204. padding:0!important;
  205. height:30px;
  206. float:left;
  207. overflow:hidden;
  208. line-height:30px;
  209. }
  210. .ztree li a.curSelectedNode{
  211. border-top:none!important;
  212. border-bottom:none!important;
  213. border-left:solid 1px #3e7fb9!important;
  214. border-right:solid 1px #3e7fb9!important;
  215. }
  216. </style>
  217. </head>
  218. <body>
  219. <div class="box1" style="width: 600px;"><div class="box_topcenter"><div class="box_topleft"><div class="box_topright"></div></div></div><div class="box_middlecenter"><div class="box_middleleft"><div class="box_middleright"><div class="boxContent" style="overflow: visible;height:600px;">
  220. 使用树组件实现的公交线路查询效果。
  221. <br/>
  222. <div>
  223. <ul id="treeDemo" class="ztree ztree_custom"></ul>
  224. </div>
  225. <br/>
  226. </div></div></div></div><div class="box_bottomcenter"><div class="box_bottomleft"><div class="box_bottomright"></div></div></div></div>
  227. </body>
  228. </html>