11<%@ page contentType =" text/html;charset=UTF-8" %>
22<%@ include file =" /WEB-INF/views/include/taglib.jsp" %>
3- <html >
3+ <!DOCTYPE html>
4+ <html style =" overflow-x :hidden ;overflow-y :auto ;" >
45<head >
56 <title >栏目列表</title >
6- <meta name = " decorator " content = " default " / >
7+ <%@ include file = " /WEB-INF/views/include/head.jsp " % >
78 <%@include file =" /WEB-INF/views/include/treeview.jsp" %>
89 <script type =" text/javascript" >
10+ var key, lastValue = " " , nodeList = [];
911 var tree, setting = {view: {selectedMulti: false },check: {enable: " ${ checked } " ,nocheckInherit: true },
10- data: {simpleData: {enable: true }},callback: {beforeClick : function (id , node ){
12+ data: {simpleData: {enable: true }},
13+ view: {
14+ fontCss : function (treeId , treeNode ) {
15+ return (!! treeNode .highlight ) ? {" font-weight" : " bold" } : {" font-weight" : " normal" };
16+ }
17+ },
18+ callback: {beforeClick : function (id , node ){
1119 if (" ${ checked } " == " true" ){
1220 tree .checkNode (node, ! node .checked , true , true );
1321 return false ;
1422 }
15- }, onDblClick : function (){
23+ },
24+ onDblClick : function (){
1625 top .$ .jBox .getBox ().find (" button[value='ok']" ).trigger (" click" );
1726 // alert($("input[type='text']", top.mainFrame.document).val());
1827 // $("input[type='text']", top.mainFrame.document).focus();
2130 $ .get (" ${ ctx } ${ url } ${ fn: indexOf(url,' ?' )== - 1 ? ' ?' : ' &' } &extId=${ extId } &module=${ module } &t=" + new Date ().getTime (), function (zNodes ){
2231 // 初始化树结构
2332 tree = $ .fn .zTree .init ($ (" #tree" ), setting, eval (" (" + zNodes+ " )" ));
33+
2434 // 默认展开一级节点
2535 var nodes = tree .getNodesByParam (" level" , 0 );
2636 for (var i= 0 ; i< nodes .length ; i++ ) {
3848 }
3949 }
4050 });
51+ key = $ (" #key" );
52+ key .bind (" focus" , focusKey).bind (" blur" , blurKey).bind (" change keydown cut input propertychange" , searchNode);
4153 });
54+ function focusKey (e ) {
55+ if (key .hasClass (" empty" )) {
56+ key .removeClass (" empty" );
57+ }
58+ }
59+ function blurKey (e ) {
60+ if (key .get (0 ).value === " " ) {
61+ key .addClass (" empty" );
62+ }
63+ searchNode (e);
64+ }
65+ function searchNode (e ) {
66+ // 取得输入的关键字的值
67+ var value = $ .trim (key .get (0 ).value );
68+
69+ // 按名字查询
70+ var keyType = " name" ;
71+ if (key .hasClass (" empty" )) {
72+ value = " " ;
73+ }
74+
75+ // 如果和上次一次,就退出不查了。
76+ if (lastValue === value) {
77+ return ;
78+ }
79+
80+ // 保存最后一次
81+ lastValue = value;
82+
83+ // 如果要查空字串,就退出不查了。
84+ if (value === " " ) {
85+ return ;
86+ }
87+ updateNodes (false );
88+ nodeList = tree .getNodesByParamFuzzy (keyType, value);
89+ updateNodes (true );
90+ }
91+ function updateNodes (highlight ) {
92+ for (var i= 0 , l= nodeList .length ; i< l; i++ ) {
93+ nodeList[i].highlight = highlight;
94+ tree .updateNode (nodeList[i]);
95+ tree .expandNode (nodeList[i].getParentNode (), true , false , false );
96+ }
97+ }
98+ function search () {
99+ $ (" #search" ).slideToggle (200 );
100+ $ (" #txt" ).toggle ();
101+ $ (" #key" ).focus ();
102+ }
42103 </script >
43104</head >
44105<body >
106+ <div style =" position :absolute ;right :8px ;top :5px ;cursor :pointer ;" onclick =" search();" >
107+ <i class =" icon-search" ></i ><label id =" txt" >搜索</label >
108+ </div >
109+ <div id =" search" class =" control-group hide" style =" padding :10px 0 0 15px ;" >
110+ <label for =" key" class =" control-label" style =" float :left ;padding :5px 5px 3px ;" >关键字:</label >
111+ <input type =" text" class =" empty" id =" key" name =" key" maxlength =" 50" style =" width :180px ;" >
112+ </div >
45113 <div id =" tree" class =" ztree" style =" padding :15px 20px ;" ></div >
46114</body >
0 commit comments