468194425ee6792980735c1f97c62bf8d0b060e6.svn-base 7.5 KB

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