jquery.tree.js 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  1. /**
  2. * jQuery EasyUI 1.4.1
  3. *
  4. * Copyright (c) 2009-2014 www.jeasyui.com. All rights reserved.
  5. *
  6. * Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
  7. * To use it on other terms please contact us at info@jeasyui.com
  8. *
  9. */
  10. (function($){
  11. function _1(_2){
  12. var _3=$(_2);
  13. _3.addClass("tree");
  14. return _3;
  15. };
  16. function _4(_5){
  17. var _6=$.data(_5,"tree").options;
  18. $(_5).unbind().bind("mouseover",function(e){
  19. var tt=$(e.target);
  20. var _7=tt.closest("div.tree-node");
  21. if(!_7.length){
  22. return;
  23. }
  24. _7.addClass("tree-node-hover");
  25. if(tt.hasClass("tree-hit")){
  26. if(tt.hasClass("tree-expanded")){
  27. tt.addClass("tree-expanded-hover");
  28. }else{
  29. tt.addClass("tree-collapsed-hover");
  30. }
  31. }
  32. e.stopPropagation();
  33. }).bind("mouseout",function(e){
  34. var tt=$(e.target);
  35. var _8=tt.closest("div.tree-node");
  36. if(!_8.length){
  37. return;
  38. }
  39. _8.removeClass("tree-node-hover");
  40. if(tt.hasClass("tree-hit")){
  41. if(tt.hasClass("tree-expanded")){
  42. tt.removeClass("tree-expanded-hover");
  43. }else{
  44. tt.removeClass("tree-collapsed-hover");
  45. }
  46. }
  47. e.stopPropagation();
  48. }).bind("click",function(e){
  49. var tt=$(e.target);
  50. var _9=tt.closest("div.tree-node");
  51. if(!_9.length){
  52. return;
  53. }
  54. if(tt.hasClass("tree-hit")){
  55. _81(_5,_9[0]);
  56. return false;
  57. }else{
  58. if(tt.hasClass("tree-checkbox")){
  59. _34(_5,_9[0],!tt.hasClass("tree-checkbox1"));
  60. return false;
  61. }else{
  62. _db(_5,_9[0]);
  63. _6.onClick.call(_5,_c(_5,_9[0]));
  64. }
  65. }
  66. e.stopPropagation();
  67. }).bind("dblclick",function(e){
  68. var _a=$(e.target).closest("div.tree-node");
  69. if(!_a.length){
  70. return;
  71. }
  72. _db(_5,_a[0]);
  73. _6.onDblClick.call(_5,_c(_5,_a[0]));
  74. e.stopPropagation();
  75. }).bind("contextmenu",function(e){
  76. var _b=$(e.target).closest("div.tree-node");
  77. if(!_b.length){
  78. return;
  79. }
  80. _6.onContextMenu.call(_5,e,_c(_5,_b[0]));
  81. e.stopPropagation();
  82. });
  83. };
  84. function _d(_e){
  85. var _f=$.data(_e,"tree").options;
  86. _f.dnd=false;
  87. var _10=$(_e).find("div.tree-node");
  88. _10.draggable("disable");
  89. _10.css("cursor","pointer");
  90. };
  91. function _11(_12){
  92. var _13=$.data(_12,"tree");
  93. var _14=_13.options;
  94. var _15=_13.tree;
  95. _13.disabledNodes=[];
  96. _14.dnd=true;
  97. _15.find("div.tree-node").draggable({disabled:false,revert:true,cursor:"pointer",proxy:function(_16){
  98. var p=$("<div class=\"tree-node-proxy\"></div>").appendTo("body");
  99. p.html("<span class=\"tree-dnd-icon tree-dnd-no\">&nbsp;</span>"+$(_16).find(".tree-title").html());
  100. p.hide();
  101. return p;
  102. },deltaX:15,deltaY:15,onBeforeDrag:function(e){
  103. if(_14.onBeforeDrag.call(_12,_c(_12,this))==false){
  104. return false;
  105. }
  106. if($(e.target).hasClass("tree-hit")||$(e.target).hasClass("tree-checkbox")){
  107. return false;
  108. }
  109. if(e.which!=1){
  110. return false;
  111. }
  112. $(this).next("ul").find("div.tree-node").droppable({accept:"no-accept"});
  113. var _17=$(this).find("span.tree-indent");
  114. if(_17.length){
  115. e.data.offsetWidth-=_17.length*_17.width();
  116. }
  117. },onStartDrag:function(){
  118. $(this).draggable("proxy").css({left:-10000,top:-10000});
  119. _14.onStartDrag.call(_12,_c(_12,this));
  120. var _18=_c(_12,this);
  121. if(_18.id==undefined){
  122. _18.id="easyui_tree_node_id_temp";
  123. _56(_12,_18);
  124. }
  125. _13.draggingNodeId=_18.id;
  126. },onDrag:function(e){
  127. var x1=e.pageX,y1=e.pageY,x2=e.data.startX,y2=e.data.startY;
  128. var d=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  129. if(d>3){
  130. $(this).draggable("proxy").show();
  131. }
  132. this.pageY=e.pageY;
  133. },onStopDrag:function(){
  134. $(this).next("ul").find("div.tree-node").droppable({accept:"div.tree-node"});
  135. for(var i=0;i<_13.disabledNodes.length;i++){
  136. $(_13.disabledNodes[i]).droppable("enable");
  137. }
  138. _13.disabledNodes=[];
  139. var _19=_ce(_12,_13.draggingNodeId);
  140. if(_19&&_19.id=="easyui_tree_node_id_temp"){
  141. _19.id="";
  142. _56(_12,_19);
  143. }
  144. _14.onStopDrag.call(_12,_19);
  145. }}).droppable({accept:"div.tree-node",onDragEnter:function(e,_1a){
  146. if(_14.onDragEnter.call(_12,this,_1b(_1a))==false){
  147. _1c(_1a,false);
  148. $(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
  149. $(this).droppable("disable");
  150. _13.disabledNodes.push(this);
  151. }
  152. },onDragOver:function(e,_1d){
  153. if($(this).droppable("options").disabled){
  154. return;
  155. }
  156. var _1e=_1d.pageY;
  157. var top=$(this).offset().top;
  158. var _1f=top+$(this).outerHeight();
  159. _1c(_1d,true);
  160. $(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
  161. if(_1e>top+(_1f-top)/2){
  162. if(_1f-_1e<5){
  163. $(this).addClass("tree-node-bottom");
  164. }else{
  165. $(this).addClass("tree-node-append");
  166. }
  167. }else{
  168. if(_1e-top<5){
  169. $(this).addClass("tree-node-top");
  170. }else{
  171. $(this).addClass("tree-node-append");
  172. }
  173. }
  174. if(_14.onDragOver.call(_12,this,_1b(_1d))==false){
  175. _1c(_1d,false);
  176. $(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
  177. $(this).droppable("disable");
  178. _13.disabledNodes.push(this);
  179. }
  180. },onDragLeave:function(e,_20){
  181. _1c(_20,false);
  182. $(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
  183. _14.onDragLeave.call(_12,this,_1b(_20));
  184. },onDrop:function(e,_21){
  185. var _22=this;
  186. var _23,_24;
  187. if($(this).hasClass("tree-node-append")){
  188. _23=_25;
  189. _24="append";
  190. }else{
  191. _23=_26;
  192. _24=$(this).hasClass("tree-node-top")?"top":"bottom";
  193. }
  194. if(_14.onBeforeDrop.call(_12,_22,_1b(_21),_24)==false){
  195. $(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
  196. return;
  197. }
  198. _23(_21,_22,_24);
  199. $(this).removeClass("tree-node-append tree-node-top tree-node-bottom");
  200. }});
  201. function _1b(_27,pop){
  202. return $(_27).closest("ul.tree").tree(pop?"pop":"getData",_27);
  203. };
  204. function _1c(_28,_29){
  205. var _2a=$(_28).draggable("proxy").find("span.tree-dnd-icon");
  206. _2a.removeClass("tree-dnd-yes tree-dnd-no").addClass(_29?"tree-dnd-yes":"tree-dnd-no");
  207. };
  208. function _25(_2b,_2c){
  209. if(_c(_12,_2c).state=="closed"){
  210. _75(_12,_2c,function(){
  211. _2d();
  212. });
  213. }else{
  214. _2d();
  215. }
  216. function _2d(){
  217. var _2e=_1b(_2b,true);
  218. $(_12).tree("append",{parent:_2c,data:[_2e]});
  219. _14.onDrop.call(_12,_2c,_2e,"append");
  220. };
  221. };
  222. function _26(_2f,_30,_31){
  223. var _32={};
  224. if(_31=="top"){
  225. _32.before=_30;
  226. }else{
  227. _32.after=_30;
  228. }
  229. var _33=_1b(_2f,true);
  230. _32.data=_33;
  231. $(_12).tree("insert",_32);
  232. _14.onDrop.call(_12,_30,_33,_31);
  233. };
  234. };
  235. function _34(_35,_36,_37){
  236. var _38=$.data(_35,"tree").options;
  237. if(!_38.checkbox){
  238. return;
  239. }
  240. var _39=_c(_35,_36);
  241. if(_38.onBeforeCheck.call(_35,_39,_37)==false){
  242. return;
  243. }
  244. var _3a=$(_36);
  245. var ck=_3a.find(".tree-checkbox");
  246. ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
  247. if(_37){
  248. ck.addClass("tree-checkbox1");
  249. }else{
  250. ck.addClass("tree-checkbox0");
  251. }
  252. if(_38.cascadeCheck){
  253. _3b(_3a);
  254. _3c(_3a);
  255. }
  256. _38.onCheck.call(_35,_39,_37);
  257. function _3c(_3d){
  258. var _3e=_3d.next().find(".tree-checkbox");
  259. _3e.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
  260. if(_3d.find(".tree-checkbox").hasClass("tree-checkbox1")){
  261. _3e.addClass("tree-checkbox1");
  262. }else{
  263. _3e.addClass("tree-checkbox0");
  264. }
  265. };
  266. function _3b(_3f){
  267. var _40=_8c(_35,_3f[0]);
  268. if(_40){
  269. var ck=$(_40.target).find(".tree-checkbox");
  270. ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2");
  271. if(_41(_3f)){
  272. ck.addClass("tree-checkbox1");
  273. }else{
  274. if(_42(_3f)){
  275. ck.addClass("tree-checkbox0");
  276. }else{
  277. ck.addClass("tree-checkbox2");
  278. }
  279. }
  280. _3b($(_40.target));
  281. }
  282. function _41(n){
  283. var ck=n.find(".tree-checkbox");
  284. if(ck.hasClass("tree-checkbox0")||ck.hasClass("tree-checkbox2")){
  285. return false;
  286. }
  287. var b=true;
  288. n.parent().siblings().each(function(){
  289. if(!$(this).children("div.tree-node").children(".tree-checkbox").hasClass("tree-checkbox1")){
  290. b=false;
  291. }
  292. });
  293. return b;
  294. };
  295. function _42(n){
  296. var ck=n.find(".tree-checkbox");
  297. if(ck.hasClass("tree-checkbox1")||ck.hasClass("tree-checkbox2")){
  298. return false;
  299. }
  300. var b=true;
  301. n.parent().siblings().each(function(){
  302. if(!$(this).children("div.tree-node").children(".tree-checkbox").hasClass("tree-checkbox0")){
  303. b=false;
  304. }
  305. });
  306. return b;
  307. };
  308. };
  309. };
  310. function _43(_44,_45){
  311. var _46=$.data(_44,"tree").options;
  312. if(!_46.checkbox){
  313. return;
  314. }
  315. var _47=$(_45);
  316. if(_48(_44,_45)){
  317. var ck=_47.find(".tree-checkbox");
  318. if(ck.length){
  319. if(ck.hasClass("tree-checkbox1")){
  320. _34(_44,_45,true);
  321. }else{
  322. _34(_44,_45,false);
  323. }
  324. }else{
  325. if(_46.onlyLeafCheck){
  326. $("<span class=\"tree-checkbox tree-checkbox0\"></span>").insertBefore(_47.find(".tree-title"));
  327. }
  328. }
  329. }else{
  330. var ck=_47.find(".tree-checkbox");
  331. if(_46.onlyLeafCheck){
  332. ck.remove();
  333. }else{
  334. if(ck.hasClass("tree-checkbox1")){
  335. _34(_44,_45,true);
  336. }else{
  337. if(ck.hasClass("tree-checkbox2")){
  338. var _49=true;
  339. var _4a=true;
  340. var _4b=_4c(_44,_45);
  341. for(var i=0;i<_4b.length;i++){
  342. if(_4b[i].checked){
  343. _4a=false;
  344. }else{
  345. _49=false;
  346. }
  347. }
  348. if(_49){
  349. _34(_44,_45,true);
  350. }
  351. if(_4a){
  352. _34(_44,_45,false);
  353. }
  354. }
  355. }
  356. }
  357. }
  358. };
  359. function _4d(_4e,ul,_4f,_50){
  360. var _51=$.data(_4e,"tree");
  361. var _52=_51.options;
  362. var _53=$(ul).prevAll("div.tree-node:first");
  363. _4f=_52.loadFilter.call(_4e,_4f,_53[0]);
  364. var _54=_55(_4e,"domId",_53.attr("id"));
  365. if(!_50){
  366. _54?_54.children=_4f:_51.data=_4f;
  367. $(ul).empty();
  368. }else{
  369. if(_54){
  370. _54.children?_54.children=_54.children.concat(_4f):_54.children=_4f;
  371. }else{
  372. _51.data=_51.data.concat(_4f);
  373. }
  374. }
  375. _52.view.render.call(_52.view,_4e,ul,_4f);
  376. if(_52.dnd){
  377. _11(_4e);
  378. }
  379. if(_54){
  380. _56(_4e,_54);
  381. }
  382. var _57=[];
  383. var _58=[];
  384. for(var i=0;i<_4f.length;i++){
  385. var _59=_4f[i];
  386. if(!_59.checked){
  387. _57.push(_59);
  388. }
  389. }
  390. _5a(_4f,function(_5b){
  391. if(_5b.checked){
  392. _58.push(_5b);
  393. }
  394. });
  395. var _5c=_52.onCheck;
  396. _52.onCheck=function(){
  397. };
  398. if(_57.length){
  399. _34(_4e,$("#"+_57[0].domId)[0],false);
  400. }
  401. for(var i=0;i<_58.length;i++){
  402. _34(_4e,$("#"+_58[i].domId)[0],true);
  403. }
  404. _52.onCheck=_5c;
  405. setTimeout(function(){
  406. _5d(_4e,_4e);
  407. },0);
  408. _52.onLoadSuccess.call(_4e,_54,_4f);
  409. };
  410. function _5d(_5e,ul,_5f){
  411. var _60=$.data(_5e,"tree").options;
  412. if(_60.lines){
  413. $(_5e).addClass("tree-lines");
  414. }else{
  415. $(_5e).removeClass("tree-lines");
  416. return;
  417. }
  418. if(!_5f){
  419. _5f=true;
  420. $(_5e).find("span.tree-indent").removeClass("tree-line tree-join tree-joinbottom");
  421. $(_5e).find("div.tree-node").removeClass("tree-node-last tree-root-first tree-root-one");
  422. var _61=$(_5e).tree("getRoots");
  423. if(_61.length>1){
  424. $(_61[0].target).addClass("tree-root-first");
  425. }else{
  426. if(_61.length==1){
  427. $(_61[0].target).addClass("tree-root-one");
  428. }
  429. }
  430. }
  431. $(ul).children("li").each(function(){
  432. var _62=$(this).children("div.tree-node");
  433. var ul=_62.next("ul");
  434. if(ul.length){
  435. if($(this).next().length){
  436. _63(_62);
  437. }
  438. _5d(_5e,ul,_5f);
  439. }else{
  440. _64(_62);
  441. }
  442. });
  443. var _65=$(ul).children("li:last").children("div.tree-node").addClass("tree-node-last");
  444. _65.children("span.tree-join").removeClass("tree-join").addClass("tree-joinbottom");
  445. function _64(_66,_67){
  446. var _68=_66.find("span.tree-icon");
  447. _68.prev("span.tree-indent").addClass("tree-join");
  448. };
  449. function _63(_69){
  450. var _6a=_69.find("span.tree-indent, span.tree-hit").length;
  451. _69.next().find("div.tree-node").each(function(){
  452. $(this).children("span:eq("+(_6a-1)+")").addClass("tree-line");
  453. });
  454. };
  455. };
  456. function _6b(_6c,ul,_6d,_6e){
  457. var _6f=$.data(_6c,"tree").options;
  458. _6d=$.extend({},_6f.queryParams,_6d||{});
  459. var _70=null;
  460. if(_6c!=ul){
  461. var _71=$(ul).prev();
  462. _70=_c(_6c,_71[0]);
  463. }
  464. if(_6f.onBeforeLoad.call(_6c,_70,_6d)==false){
  465. return;
  466. }
  467. var _72=$(ul).prev().children("span.tree-folder");
  468. _72.addClass("tree-loading");
  469. var _73=_6f.loader.call(_6c,_6d,function(_74){
  470. _72.removeClass("tree-loading");
  471. _4d(_6c,ul,_74);
  472. if(_6e){
  473. _6e();
  474. }
  475. },function(){
  476. _72.removeClass("tree-loading");
  477. _6f.onLoadError.apply(_6c,arguments);
  478. if(_6e){
  479. _6e();
  480. }
  481. });
  482. if(_73==false){
  483. _72.removeClass("tree-loading");
  484. }
  485. };
  486. function _75(_76,_77,_78){
  487. var _79=$.data(_76,"tree").options;
  488. var hit=$(_77).children("span.tree-hit");
  489. if(hit.length==0){
  490. return;
  491. }
  492. if(hit.hasClass("tree-expanded")){
  493. return;
  494. }
  495. var _7a=_c(_76,_77);
  496. if(_79.onBeforeExpand.call(_76,_7a)==false){
  497. return;
  498. }
  499. hit.removeClass("tree-collapsed tree-collapsed-hover").addClass("tree-expanded");
  500. hit.next().addClass("tree-folder-open");
  501. var ul=$(_77).next();
  502. if(ul.length){
  503. if(_79.animate){
  504. ul.slideDown("normal",function(){
  505. _7a.state="open";
  506. _79.onExpand.call(_76,_7a);
  507. if(_78){
  508. _78();
  509. }
  510. });
  511. }else{
  512. ul.css("display","block");
  513. _7a.state="open";
  514. _79.onExpand.call(_76,_7a);
  515. if(_78){
  516. _78();
  517. }
  518. }
  519. }else{
  520. var _7b=$("<ul style=\"display:none\"></ul>").insertAfter(_77);
  521. _6b(_76,_7b[0],{id:_7a.id},function(){
  522. if(_7b.is(":empty")){
  523. _7b.remove();
  524. }
  525. if(_79.animate){
  526. _7b.slideDown("normal",function(){
  527. _7a.state="open";
  528. _79.onExpand.call(_76,_7a);
  529. if(_78){
  530. _78();
  531. }
  532. });
  533. }else{
  534. _7b.css("display","block");
  535. _7a.state="open";
  536. _79.onExpand.call(_76,_7a);
  537. if(_78){
  538. _78();
  539. }
  540. }
  541. });
  542. }
  543. };
  544. function _7c(_7d,_7e){
  545. var _7f=$.data(_7d,"tree").options;
  546. var hit=$(_7e).children("span.tree-hit");
  547. if(hit.length==0){
  548. return;
  549. }
  550. if(hit.hasClass("tree-collapsed")){
  551. return;
  552. }
  553. var _80=_c(_7d,_7e);
  554. if(_7f.onBeforeCollapse.call(_7d,_80)==false){
  555. return;
  556. }
  557. hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed");
  558. hit.next().removeClass("tree-folder-open");
  559. var ul=$(_7e).next();
  560. if(_7f.animate){
  561. ul.slideUp("normal",function(){
  562. _80.state="closed";
  563. _7f.onCollapse.call(_7d,_80);
  564. });
  565. }else{
  566. ul.css("display","none");
  567. _80.state="closed";
  568. _7f.onCollapse.call(_7d,_80);
  569. }
  570. };
  571. function _81(_82,_83){
  572. var hit=$(_83).children("span.tree-hit");
  573. if(hit.length==0){
  574. return;
  575. }
  576. if(hit.hasClass("tree-expanded")){
  577. _7c(_82,_83);
  578. }else{
  579. _75(_82,_83);
  580. }
  581. };
  582. function _84(_85,_86){
  583. var _87=_4c(_85,_86);
  584. if(_86){
  585. _87.unshift(_c(_85,_86));
  586. }
  587. for(var i=0;i<_87.length;i++){
  588. _75(_85,_87[i].target);
  589. }
  590. };
  591. function _88(_89,_8a){
  592. var _8b=[];
  593. var p=_8c(_89,_8a);
  594. while(p){
  595. _8b.unshift(p);
  596. p=_8c(_89,p.target);
  597. }
  598. for(var i=0;i<_8b.length;i++){
  599. _75(_89,_8b[i].target);
  600. }
  601. };
  602. function _8d(_8e,_8f){
  603. var c=$(_8e).parent();
  604. while(c[0].tagName!="BODY"&&c.css("overflow-y")!="auto"){
  605. c=c.parent();
  606. }
  607. var n=$(_8f);
  608. var _90=n.offset().top;
  609. if(c[0].tagName!="BODY"){
  610. var _91=c.offset().top;
  611. if(_90<_91){
  612. c.scrollTop(c.scrollTop()+_90-_91);
  613. }else{
  614. if(_90+n.outerHeight()>_91+c.outerHeight()-18){
  615. c.scrollTop(c.scrollTop()+_90+n.outerHeight()-_91-c.outerHeight()+18);
  616. }
  617. }
  618. }else{
  619. c.scrollTop(_90);
  620. }
  621. };
  622. function _92(_93,_94){
  623. var _95=_4c(_93,_94);
  624. if(_94){
  625. _95.unshift(_c(_93,_94));
  626. }
  627. for(var i=0;i<_95.length;i++){
  628. _7c(_93,_95[i].target);
  629. }
  630. };
  631. function _96(_97,_98){
  632. var _99=$(_98.parent);
  633. var _9a=_98.data;
  634. if(!_9a){
  635. return;
  636. }
  637. _9a=$.isArray(_9a)?_9a:[_9a];
  638. if(!_9a.length){
  639. return;
  640. }
  641. var ul;
  642. if(_99.length==0){
  643. ul=$(_97);
  644. }else{
  645. if(_48(_97,_99[0])){
  646. var _9b=_99.find("span.tree-icon");
  647. _9b.removeClass("tree-file").addClass("tree-folder tree-folder-open");
  648. var hit=$("<span class=\"tree-hit tree-expanded\"></span>").insertBefore(_9b);
  649. if(hit.prev().length){
  650. hit.prev().remove();
  651. }
  652. }
  653. ul=_99.next();
  654. if(!ul.length){
  655. ul=$("<ul></ul>").insertAfter(_99);
  656. }
  657. }
  658. _4d(_97,ul[0],_9a,true);
  659. _43(_97,ul.prev());
  660. };
  661. function _9c(_9d,_9e){
  662. var ref=_9e.before||_9e.after;
  663. var _9f=_8c(_9d,ref);
  664. var _a0=_9e.data;
  665. if(!_a0){
  666. return;
  667. }
  668. _a0=$.isArray(_a0)?_a0:[_a0];
  669. if(!_a0.length){
  670. return;
  671. }
  672. _96(_9d,{parent:(_9f?_9f.target:null),data:_a0});
  673. var _a1=_9f?_9f.children:$(_9d).tree("getRoots");
  674. for(var i=0;i<_a1.length;i++){
  675. if(_a1[i].domId==$(ref).attr("id")){
  676. for(var j=_a0.length-1;j>=0;j--){
  677. _a1.splice((_9e.before?i:(i+1)),0,_a0[j]);
  678. }
  679. _a1.splice(_a1.length-_a0.length,_a0.length);
  680. break;
  681. }
  682. }
  683. var li=$();
  684. for(var i=0;i<_a0.length;i++){
  685. li=li.add($("#"+_a0[i].domId).parent());
  686. }
  687. if(_9e.before){
  688. li.insertBefore($(ref).parent());
  689. }else{
  690. li.insertAfter($(ref).parent());
  691. }
  692. };
  693. function _a2(_a3,_a4){
  694. var _a5=del(_a4);
  695. $(_a4).parent().remove();
  696. if(_a5){
  697. if(!_a5.children||!_a5.children.length){
  698. var _a6=$(_a5.target);
  699. _a6.find(".tree-icon").removeClass("tree-folder").addClass("tree-file");
  700. _a6.find(".tree-hit").remove();
  701. $("<span class=\"tree-indent\"></span>").prependTo(_a6);
  702. _a6.next().remove();
  703. }
  704. _56(_a3,_a5);
  705. _43(_a3,_a5.target);
  706. }
  707. _5d(_a3,_a3);
  708. function del(_a7){
  709. var id=$(_a7).attr("id");
  710. var _a8=_8c(_a3,_a7);
  711. var cc=_a8?_a8.children:$.data(_a3,"tree").data;
  712. for(var i=0;i<cc.length;i++){
  713. if(cc[i].domId==id){
  714. cc.splice(i,1);
  715. break;
  716. }
  717. }
  718. return _a8;
  719. };
  720. };
  721. function _56(_a9,_aa){
  722. var _ab=$.data(_a9,"tree").options;
  723. var _ac=$(_aa.target);
  724. var _ad=_c(_a9,_aa.target);
  725. var _ae=_ad.checked;
  726. if(_ad.iconCls){
  727. _ac.find(".tree-icon").removeClass(_ad.iconCls);
  728. }
  729. $.extend(_ad,_aa);
  730. _ac.find(".tree-title").html(_ab.formatter.call(_a9,_ad));
  731. if(_ad.iconCls){
  732. _ac.find(".tree-icon").addClass(_ad.iconCls);
  733. }
  734. if(_ae!=_ad.checked){
  735. _34(_a9,_aa.target,_ad.checked);
  736. }
  737. };
  738. function _af(_b0,_b1){
  739. if(_b1){
  740. var p=_8c(_b0,_b1);
  741. while(p){
  742. _b1=p.target;
  743. p=_8c(_b0,_b1);
  744. }
  745. return _c(_b0,_b1);
  746. }else{
  747. var _b2=_b3(_b0);
  748. return _b2.length?_b2[0]:null;
  749. }
  750. };
  751. function _b3(_b4){
  752. var _b5=$.data(_b4,"tree").data;
  753. for(var i=0;i<_b5.length;i++){
  754. _b6(_b5[i]);
  755. }
  756. return _b5;
  757. };
  758. function _4c(_b7,_b8){
  759. var _b9=[];
  760. var n=_c(_b7,_b8);
  761. var _ba=n?(n.children||[]):$.data(_b7,"tree").data;
  762. _5a(_ba,function(_bb){
  763. _b9.push(_b6(_bb));
  764. });
  765. return _b9;
  766. };
  767. function _8c(_bc,_bd){
  768. var p=$(_bd).closest("ul").prevAll("div.tree-node:first");
  769. return _c(_bc,p[0]);
  770. };
  771. function _be(_bf,_c0){
  772. _c0=_c0||"checked";
  773. if(!$.isArray(_c0)){
  774. _c0=[_c0];
  775. }
  776. var _c1=[];
  777. for(var i=0;i<_c0.length;i++){
  778. var s=_c0[i];
  779. if(s=="checked"){
  780. _c1.push("span.tree-checkbox1");
  781. }else{
  782. if(s=="unchecked"){
  783. _c1.push("span.tree-checkbox0");
  784. }else{
  785. if(s=="indeterminate"){
  786. _c1.push("span.tree-checkbox2");
  787. }
  788. }
  789. }
  790. }
  791. var _c2=[];
  792. $(_bf).find(_c1.join(",")).each(function(){
  793. var _c3=$(this).parent();
  794. _c2.push(_c(_bf,_c3[0]));
  795. });
  796. return _c2;
  797. };
  798. function _c4(_c5){
  799. var _c6=$(_c5).find("div.tree-node-selected");
  800. return _c6.length?_c(_c5,_c6[0]):null;
  801. };
  802. function _c7(_c8,_c9){
  803. var _ca=_c(_c8,_c9);
  804. if(_ca&&_ca.children){
  805. _5a(_ca.children,function(_cb){
  806. _b6(_cb);
  807. });
  808. }
  809. return _ca;
  810. };
  811. function _c(_cc,_cd){
  812. return _55(_cc,"domId",$(_cd).attr("id"));
  813. };
  814. function _ce(_cf,id){
  815. return _55(_cf,"id",id);
  816. };
  817. function _55(_d0,_d1,_d2){
  818. var _d3=$.data(_d0,"tree").data;
  819. var _d4=null;
  820. _5a(_d3,function(_d5){
  821. if(_d5[_d1]==_d2){
  822. _d4=_b6(_d5);
  823. return false;
  824. }
  825. });
  826. return _d4;
  827. };
  828. function _b6(_d6){
  829. var d=$("#"+_d6.domId);
  830. _d6.target=d[0];
  831. _d6.checked=d.find(".tree-checkbox").hasClass("tree-checkbox1");
  832. return _d6;
  833. };
  834. function _5a(_d7,_d8){
  835. var _d9=[];
  836. for(var i=0;i<_d7.length;i++){
  837. _d9.push(_d7[i]);
  838. }
  839. while(_d9.length){
  840. var _da=_d9.shift();
  841. if(_d8(_da)==false){
  842. return;
  843. }
  844. if(_da.children){
  845. for(var i=_da.children.length-1;i>=0;i--){
  846. _d9.unshift(_da.children[i]);
  847. }
  848. }
  849. }
  850. };
  851. function _db(_dc,_dd){
  852. var _de=$.data(_dc,"tree").options;
  853. var _df=_c(_dc,_dd);
  854. if(_de.onBeforeSelect.call(_dc,_df)==false){
  855. return;
  856. }
  857. $(_dc).find("div.tree-node-selected").removeClass("tree-node-selected");
  858. $(_dd).addClass("tree-node-selected");
  859. _de.onSelect.call(_dc,_df);
  860. };
  861. function _48(_e0,_e1){
  862. return $(_e1).children("span.tree-hit").length==0;
  863. };
  864. function _e2(_e3,_e4){
  865. var _e5=$.data(_e3,"tree").options;
  866. var _e6=_c(_e3,_e4);
  867. if(_e5.onBeforeEdit.call(_e3,_e6)==false){
  868. return;
  869. }
  870. $(_e4).css("position","relative");
  871. var nt=$(_e4).find(".tree-title");
  872. var _e7=nt.outerWidth();
  873. nt.empty();
  874. var _e8=$("<input class=\"tree-editor\">").appendTo(nt);
  875. _e8.val(_e6.text).focus();
  876. _e8.width(_e7+20);
  877. _e8.height(document.compatMode=="CSS1Compat"?(18-(_e8.outerHeight()-_e8.height())):18);
  878. _e8.bind("click",function(e){
  879. return false;
  880. }).bind("mousedown",function(e){
  881. e.stopPropagation();
  882. }).bind("mousemove",function(e){
  883. e.stopPropagation();
  884. }).bind("keydown",function(e){
  885. if(e.keyCode==13){
  886. _e9(_e3,_e4);
  887. return false;
  888. }else{
  889. if(e.keyCode==27){
  890. _ef(_e3,_e4);
  891. return false;
  892. }
  893. }
  894. }).bind("blur",function(e){
  895. e.stopPropagation();
  896. _e9(_e3,_e4);
  897. });
  898. };
  899. function _e9(_ea,_eb){
  900. var _ec=$.data(_ea,"tree").options;
  901. $(_eb).css("position","");
  902. var _ed=$(_eb).find("input.tree-editor");
  903. var val=_ed.val();
  904. _ed.remove();
  905. var _ee=_c(_ea,_eb);
  906. _ee.text=val;
  907. _56(_ea,_ee);
  908. _ec.onAfterEdit.call(_ea,_ee);
  909. };
  910. function _ef(_f0,_f1){
  911. var _f2=$.data(_f0,"tree").options;
  912. $(_f1).css("position","");
  913. $(_f1).find("input.tree-editor").remove();
  914. var _f3=_c(_f0,_f1);
  915. _56(_f0,_f3);
  916. _f2.onCancelEdit.call(_f0,_f3);
  917. };
  918. $.fn.tree=function(_f4,_f5){
  919. if(typeof _f4=="string"){
  920. return $.fn.tree.methods[_f4](this,_f5);
  921. }
  922. var _f4=_f4||{};
  923. return this.each(function(){
  924. var _f6=$.data(this,"tree");
  925. var _f7;
  926. if(_f6){
  927. _f7=$.extend(_f6.options,_f4);
  928. _f6.options=_f7;
  929. }else{
  930. _f7=$.extend({},$.fn.tree.defaults,$.fn.tree.parseOptions(this),_f4);
  931. $.data(this,"tree",{options:_f7,tree:_1(this),data:[]});
  932. var _f8=$.fn.tree.parseData(this);
  933. if(_f8.length){
  934. _4d(this,this,_f8);
  935. }
  936. }
  937. _4(this);
  938. if(_f7.data){
  939. _4d(this,this,$.extend(true,[],_f7.data));
  940. }
  941. _6b(this,this);
  942. });
  943. };
  944. $.fn.tree.methods={options:function(jq){
  945. return $.data(jq[0],"tree").options;
  946. },loadData:function(jq,_f9){
  947. return jq.each(function(){
  948. _4d(this,this,_f9);
  949. });
  950. },getNode:function(jq,_fa){
  951. return _c(jq[0],_fa);
  952. },getData:function(jq,_fb){
  953. return _c7(jq[0],_fb);
  954. },reload:function(jq,_fc){
  955. return jq.each(function(){
  956. if(_fc){
  957. var _fd=$(_fc);
  958. var hit=_fd.children("span.tree-hit");
  959. hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed");
  960. _fd.next().remove();
  961. _75(this,_fc);
  962. }else{
  963. $(this).empty();
  964. _6b(this,this);
  965. }
  966. });
  967. },getRoot:function(jq,_fe){
  968. return _af(jq[0],_fe);
  969. },getRoots:function(jq){
  970. return _b3(jq[0]);
  971. },getParent:function(jq,_ff){
  972. return _8c(jq[0],_ff);
  973. },getChildren:function(jq,_100){
  974. return _4c(jq[0],_100);
  975. },getChecked:function(jq,_101){
  976. return _be(jq[0],_101);
  977. },getSelected:function(jq){
  978. return _c4(jq[0]);
  979. },isLeaf:function(jq,_102){
  980. return _48(jq[0],_102);
  981. },find:function(jq,id){
  982. return _ce(jq[0],id);
  983. },select:function(jq,_103){
  984. return jq.each(function(){
  985. _db(this,_103);
  986. });
  987. },check:function(jq,_104){
  988. return jq.each(function(){
  989. _34(this,_104,true);
  990. });
  991. },uncheck:function(jq,_105){
  992. return jq.each(function(){
  993. _34(this,_105,false);
  994. });
  995. },collapse:function(jq,_106){
  996. return jq.each(function(){
  997. _7c(this,_106);
  998. });
  999. },expand:function(jq,_107){
  1000. return jq.each(function(){
  1001. _75(this,_107);
  1002. });
  1003. },collapseAll:function(jq,_108){
  1004. return jq.each(function(){
  1005. _92(this,_108);
  1006. });
  1007. },expandAll:function(jq,_109){
  1008. return jq.each(function(){
  1009. _84(this,_109);
  1010. });
  1011. },expandTo:function(jq,_10a){
  1012. return jq.each(function(){
  1013. _88(this,_10a);
  1014. });
  1015. },scrollTo:function(jq,_10b){
  1016. return jq.each(function(){
  1017. _8d(this,_10b);
  1018. });
  1019. },toggle:function(jq,_10c){
  1020. return jq.each(function(){
  1021. _81(this,_10c);
  1022. });
  1023. },append:function(jq,_10d){
  1024. return jq.each(function(){
  1025. _96(this,_10d);
  1026. });
  1027. },insert:function(jq,_10e){
  1028. return jq.each(function(){
  1029. _9c(this,_10e);
  1030. });
  1031. },remove:function(jq,_10f){
  1032. return jq.each(function(){
  1033. _a2(this,_10f);
  1034. });
  1035. },pop:function(jq,_110){
  1036. var node=jq.tree("getData",_110);
  1037. jq.tree("remove",_110);
  1038. return node;
  1039. },update:function(jq,_111){
  1040. return jq.each(function(){
  1041. _56(this,_111);
  1042. });
  1043. },enableDnd:function(jq){
  1044. return jq.each(function(){
  1045. _11(this);
  1046. });
  1047. },disableDnd:function(jq){
  1048. return jq.each(function(){
  1049. _d(this);
  1050. });
  1051. },beginEdit:function(jq,_112){
  1052. return jq.each(function(){
  1053. _e2(this,_112);
  1054. });
  1055. },endEdit:function(jq,_113){
  1056. return jq.each(function(){
  1057. _e9(this,_113);
  1058. });
  1059. },cancelEdit:function(jq,_114){
  1060. return jq.each(function(){
  1061. _ef(this,_114);
  1062. });
  1063. }};
  1064. $.fn.tree.parseOptions=function(_115){
  1065. var t=$(_115);
  1066. return $.extend({},$.parser.parseOptions(_115,["url","method",{checkbox:"boolean",cascadeCheck:"boolean",onlyLeafCheck:"boolean"},{animate:"boolean",lines:"boolean",dnd:"boolean"}]));
  1067. };
  1068. $.fn.tree.parseData=function(_116){
  1069. var data=[];
  1070. _117(data,$(_116));
  1071. return data;
  1072. function _117(aa,tree){
  1073. tree.children("li").each(function(){
  1074. var node=$(this);
  1075. var item=$.extend({},$.parser.parseOptions(this,["id","iconCls","state"]),{checked:(node.attr("checked")?true:undefined)});
  1076. item.text=node.children("span").html();
  1077. if(!item.text){
  1078. item.text=node.html();
  1079. }
  1080. var _118=node.children("ul");
  1081. if(_118.length){
  1082. item.children=[];
  1083. _117(item.children,_118);
  1084. }
  1085. aa.push(item);
  1086. });
  1087. };
  1088. };
  1089. var _119=1;
  1090. var _11a={render:function(_11b,ul,data){
  1091. var opts=$.data(_11b,"tree").options;
  1092. var _11c=$(ul).prev("div.tree-node").find("span.tree-indent, span.tree-hit").length;
  1093. var cc=_11d(_11c,data);
  1094. $(ul).append(cc.join(""));
  1095. function _11d(_11e,_11f){
  1096. var cc=[];
  1097. for(var i=0;i<_11f.length;i++){
  1098. var item=_11f[i];
  1099. if(item.state!="open"&&item.state!="closed"){
  1100. item.state="open";
  1101. }
  1102. item.domId="_easyui_tree_"+_119++;
  1103. cc.push("<li>");
  1104. cc.push("<div id=\""+item.domId+"\" class=\"tree-node\">");
  1105. for(var j=0;j<_11e;j++){
  1106. cc.push("<span class=\"tree-indent\"></span>");
  1107. }
  1108. var _120=false;
  1109. if(item.state=="closed"){
  1110. cc.push("<span class=\"tree-hit tree-collapsed\"></span>");
  1111. cc.push("<span class=\"tree-icon tree-folder "+(item.iconCls?item.iconCls:"")+"\"></span>");
  1112. }else{
  1113. if(item.children&&item.children.length){
  1114. cc.push("<span class=\"tree-hit tree-expanded\"></span>");
  1115. cc.push("<span class=\"tree-icon tree-folder tree-folder-open "+(item.iconCls?item.iconCls:"")+"\"></span>");
  1116. }else{
  1117. cc.push("<span class=\"tree-indent\"></span>");
  1118. cc.push("<span class=\"tree-icon tree-file "+(item.iconCls?item.iconCls:"")+"\"></span>");
  1119. _120=true;
  1120. }
  1121. }
  1122. if(opts.checkbox){
  1123. if((!opts.onlyLeafCheck)||_120){
  1124. cc.push("<span class=\"tree-checkbox tree-checkbox0\"></span>");
  1125. }
  1126. }
  1127. cc.push("<span class=\"tree-title\">"+opts.formatter.call(_11b,item)+"</span>");
  1128. cc.push("</div>");
  1129. if(item.children&&item.children.length){
  1130. var tmp=_11d(_11e+1,item.children);
  1131. cc.push("<ul style=\"display:"+(item.state=="closed"?"none":"block")+"\">");
  1132. cc=cc.concat(tmp);
  1133. cc.push("</ul>");
  1134. }
  1135. cc.push("</li>");
  1136. }
  1137. return cc;
  1138. };
  1139. }};
  1140. $.fn.tree.defaults={url:null,method:"post",animate:false,checkbox:false,cascadeCheck:true,onlyLeafCheck:false,lines:false,dnd:false,data:null,queryParams:{},formatter:function(node){
  1141. return node.text;
  1142. },loader:function(_121,_122,_123){
  1143. var opts=$(this).tree("options");
  1144. if(!opts.url){
  1145. return false;
  1146. }
  1147. $.ajax({type:opts.method,url:opts.url,data:_121,dataType:"json",success:function(data){
  1148. _122(data);
  1149. },error:function(){
  1150. _123.apply(this,arguments);
  1151. }});
  1152. },loadFilter:function(data,_124){
  1153. return data;
  1154. },view:_11a,onBeforeLoad:function(node,_125){
  1155. },onLoadSuccess:function(node,data){
  1156. },onLoadError:function(){
  1157. },onClick:function(node){
  1158. },onDblClick:function(node){
  1159. },onBeforeExpand:function(node){
  1160. },onExpand:function(node){
  1161. },onBeforeCollapse:function(node){
  1162. },onCollapse:function(node){
  1163. },onBeforeCheck:function(node,_126){
  1164. },onCheck:function(node,_127){
  1165. },onBeforeSelect:function(node){
  1166. },onSelect:function(node){
  1167. },onContextMenu:function(e,node){
  1168. },onBeforeDrag:function(node){
  1169. },onStartDrag:function(node){
  1170. },onStopDrag:function(node){
  1171. },onDragEnter:function(_128,_129){
  1172. },onDragOver:function(_12a,_12b){
  1173. },onDragLeave:function(_12c,_12d){
  1174. },onBeforeDrop:function(_12e,_12f,_130){
  1175. },onDrop:function(_131,_132,_133){
  1176. },onBeforeEdit:function(node){
  1177. },onAfterEdit:function(node){
  1178. },onCancelEdit:function(node){
  1179. }};
  1180. })(jQuery);