UU跑腿标准版

ligerBuild.source.js 136KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999
  1. /**
  2. * jQuery ligerUI 1.0.2
  3. * Author leoxie
  4. * 部分修改版
  5. * Author xiekai
  6. */
  7. //ligerAccordion.js
  8. if (typeof (LigerUIManagers) == "undefined") LigerUIManagers = {};
  9. (function($)
  10. {
  11. /// <param name="$" type="jQuery"></param>
  12. $.fn.ligerGetAccordionManager = function()
  13. {
  14. return LigerUIManagers[this[0].id + "_Accordion"];
  15. };
  16. $.fn.ligerRemoveAccordionManager = function()
  17. {
  18. return this.each(function()
  19. {
  20. LigerUIManagers[this.id + "_Accordion"] = null;
  21. });
  22. };
  23. $.fn.ligerAccordion = function(p)
  24. {
  25. this.each(function()
  26. {
  27. p = $.extend({
  28. height: null,
  29. speed : "normal",
  30. changeHeightOnResize: false,
  31. heightDiff: 0 // 高度补差
  32. }, p || {});
  33. if (this.usedAccordion) return;
  34. var g = {
  35. onResize: function()
  36. {
  37. if (!p.height || typeof (p.height) != 'string' || p.height.indexOf('%') == -1) return false;
  38. //set accordion height
  39. if (g.accordion.parent()[0].tagName.toLowerCase() == "body")
  40. {
  41. var windowHeight = $(window).height();
  42. windowHeight -= parseInt(g.layout.parent().css('paddingTop'));
  43. windowHeight -= parseInt(g.layout.parent().css('paddingBottom'));
  44. g.height = p.heightDiff + windowHeight * parseFloat(g.height) * 0.01;
  45. }
  46. else
  47. {
  48. g.height = p.heightDiff + (g.accordion.parent().height() * parseFloat(p.height) * 0.01);
  49. }
  50. g.accordion.height(g.height);
  51. g.setContentHeight(g.height - g.headerHoldHeight);
  52. },
  53. setHeight: function(height)
  54. {
  55. g.accordion.height(height);
  56. height -= g.headerHoldHeight;
  57. $("> .l-accordion-content", g.accordion).height(height);
  58. }
  59. };
  60. g.accordion = $(this);
  61. if (!g.accordion.hasClass("l-accordion-panel")) g.accordion.addClass("l-accordion-panel");
  62. var selectedIndex = 0;
  63. if ($("> div[lselected=true]", g.accordion).length > 0)
  64. selectedIndex = $("> div", g.accordion).index($("> div[lselected=true]", g.accordion));
  65. $("> div", g.accordion).each(function(i, box)
  66. {
  67. var header = $('<div class="l-accordion-header"><div class="l-accordion-toggle"></div><div class="l-accordion-header-inner"></div></div>');
  68. if (i == selectedIndex)
  69. $(".l-accordion-toggle", header).addClass("l-accordion-toggle-open");
  70. if ($(box).attr("title"))
  71. {
  72. var iconbox = "";
  73. if($(box).attr("iconcss"))
  74. {
  75. iconbox = '<span class="' + $(box).attr("iconcss") + '"></span>';
  76. }
  77. $(".l-accordion-header-inner", header).html(iconbox + $(box).attr("title"));
  78. $(box).attr("title","");
  79. }
  80. $(box).before(header);
  81. if (!$(box).hasClass("l-accordion-content")) $(box).addClass("l-accordion-content");
  82. });
  83. //add Even
  84. $(".l-accordion-toggle", g.accordion).each(function()
  85. {
  86. if (!$(this).hasClass("l-accordion-toggle-open") && !$(this).hasClass("l-accordion-toggle-close"))
  87. {
  88. $(this).addClass("l-accordion-toggle-close");
  89. }
  90. if ($(this).hasClass("l-accordion-toggle-close"))
  91. {
  92. $(this).parent().next(".l-accordion-content:visible").hide();
  93. }
  94. });
  95. $(".l-accordion-header", g.accordion).hover(function()
  96. {
  97. $(this).addClass("l-accordion-header-over");
  98. }, function()
  99. {
  100. $(this).removeClass("l-accordion-header-over");
  101. });
  102. $(".l-accordion-toggle", g.accordion).hover(function()
  103. {
  104. if ($(this).hasClass("l-accordion-toggle-open"))
  105. $(this).addClass("l-accordion-toggle-open-over");
  106. else if ($(this).hasClass("l-accordion-toggle-close"))
  107. $(this).addClass("l-accordion-toggle-close-over");
  108. }, function()
  109. {
  110. if ($(this).hasClass("l-accordion-toggle-open"))
  111. $(this).removeClass("l-accordion-toggle-open-over");
  112. else if ($(this).hasClass("l-accordion-toggle-close"))
  113. $(this).removeClass("l-accordion-toggle-close-over");
  114. });
  115. $(">.l-accordion-header", g.accordion).click(function()
  116. {
  117. var togglebtn = $(".l-accordion-toggle:first",this);
  118. if (togglebtn.hasClass("l-accordion-toggle-close"))
  119. {
  120. togglebtn.removeClass("l-accordion-toggle-close")
  121. .removeClass("l-accordion-toggle-close-over l-accordion-toggle-open-over")
  122. togglebtn.addClass("l-accordion-toggle-open");
  123. $(this).next(".l-accordion-content")
  124. .show(p.speed)
  125. .siblings(".l-accordion-content:visible").hide(p.speed);
  126. $(this).siblings(".l-accordion-header").find(".l-accordion-toggle").removeClass("l-accordion-toggle-open").addClass("l-accordion-toggle-close");
  127. }
  128. else
  129. {
  130. togglebtn.removeClass("l-accordion-toggle-open")
  131. .removeClass("l-accordion-toggle-close-over l-accordion-toggle-open-over")
  132. .addClass("l-accordion-toggle-close");
  133. $(this).next(".l-accordion-content").hide(p.speed);
  134. }
  135. });
  136. //init
  137. g.headerHoldHeight = 0;
  138. $("> .l-accordion-header", g.accordion).each(function()
  139. {
  140. g.headerHoldHeight += $(this).height();
  141. });
  142. if (p.height && typeof (p.height) == 'string' && p.height.indexOf('%') > 0)
  143. {
  144. g.onResize();
  145. if (p.changeHeightOnResize)
  146. {
  147. $(window).resize(function()
  148. {
  149. g.onResize();
  150. });
  151. }
  152. }
  153. else
  154. {
  155. if (p.height)
  156. {
  157. g.height = p.heightDiff + p.height;
  158. g.accordion.height(g.height);
  159. g.setHeight(p.height);
  160. }
  161. else
  162. {
  163. g.header = g.accordion.height();
  164. }
  165. }
  166. if (this.id == undefined) this.id = "LigerUI_" + new Date().getTime();
  167. LigerUIManagers[this.id + "_Accordion"] = g;
  168. this.usedAccordion = true;
  169. });
  170. if (this.length == 0) return null;
  171. if (this.length == 1) return LigerUIManagers[this[0].id + "_Accordion"];
  172. var managers = [];
  173. this.each(function() {
  174. managers.push(LigerUIManagers[this.id + "_Accordion"]);
  175. });
  176. return managers;
  177. };
  178. })(jQuery);
  179. //ligerDialog.js
  180. //dialog 图片文件夹的路径 针对于IE6设置
  181. var ligerDialogImagePath = "../../scripts/ui/skins/Aqua/images/dialog/";
  182. (function($) {
  183. $.ligerDefaults = $.ligerDefaults || {};
  184. $.ligerDefaults.Dialog = {
  185. cls:null, //给dialog附加css class
  186. id:null, //给dialog附加id
  187. buttons: null, //按钮集合
  188. isDrag: true, //是否拖动
  189. width: 280, //宽度
  190. height: null, //高度,默认自适应
  191. content: '', //内容
  192. target: null, //目标对象,指定它将以appendTo()的方式载入
  193. url: null, //目标页url,默认以iframe的方式载入
  194. load: false, //是否以load()的方式加载目标页的内容
  195. type: 'warn', //类型 warn、success、error、question
  196. left: null, //位置left
  197. top: null, //位置top
  198. modal: true, //是否模态对话框
  199. name: null, //创建iframe时 作为iframe的name和id
  200. isResize:false, // 是否调整大小
  201. allowClose:true, //允许关闭
  202. opener:null,
  203. timeParmName:null //是否给URL后面加上值为new Date().getTime()的参数,如果需要指定一个参数名即可
  204. };
  205. $.ligerDefaults.DialogString = {
  206. titleMessage: '提示', //提示文本标题
  207. waittingMessage:'正在等待中,请稍候...'
  208. };
  209. /// <param name="$" type="jQuery"></param>
  210. $.ligerDialog = {};
  211. $.ligerDialog.open = function(p) {
  212. p = $.extend({}, $.ligerDefaults.Dialog,$.ligerDefaults.DialogString, p || {});
  213. var g = {
  214. applyWindowMask: function() {
  215. $(".l-window-mask").remove();
  216. $("<div class='l-window-mask' style='display: block;'></div>").height($(window).height()+$(window).scrollTop()).appendTo('body');
  217. },
  218. removeWindowMask: function() {
  219. $(".l-window-mask").remove();
  220. },
  221. applyDrag: function() {
  222. if ($.fn.ligerDrag)
  223. g.dialog.ligerDrag({ handler: '.l-dialog-title' });
  224. },
  225. applyResize:function(){
  226. if($.fn.ligerResizable)
  227. {
  228. g.dialog.ligerResizable({
  229. onStopResize: function (current, e)
  230. {
  231. var top = 0;
  232. var left = 0;
  233. if (!isNaN(parseInt(g.dialog.css('top'))))
  234. top = parseInt(g.dialog.css('top'));
  235. if (!isNaN(parseInt(g.dialog.css('left'))))
  236. left = parseInt(g.dialog.css('left'));
  237. if (current.diffTop != undefined)
  238. {
  239. g.dialog.css({
  240. top: top + current.diffTop,
  241. left: left + current.diffLeft
  242. });
  243. g.dialog.body.css({
  244. width : current.newWidth - 26
  245. });
  246. $(".l-dialog-content",g.dialog.body).height(current.newHeight - 46 - $(".l-dialog-buttons", g.dialog).height());
  247. }
  248. return false;
  249. }
  250. });
  251. }
  252. },
  253. setImage: function() {
  254. if (p.type) {
  255. if (p.type == 'success' || p.type == 'donne' || p.type == 'ok') {
  256. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-donne").show();
  257. $(".l-dialog-content", g.dialog).css({ paddingLeft: 64, paddingBottom: 30 });
  258. }
  259. else if (p.type == 'error') {
  260. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-error").show();
  261. $(".l-dialog-content", g.dialog).css({ paddingLeft: 64, paddingBottom: 30 });
  262. }
  263. else if (p.type == 'warn') {
  264. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-warn").show();
  265. $(".l-dialog-content", g.dialog).css({ paddingLeft: 64, paddingBottom: 30 });
  266. }
  267. else if (p.type == 'question') {
  268. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-question").show();
  269. $(".l-dialog-content", g.dialog).css({ paddingLeft: 64, paddingBottom: 20 });
  270. }
  271. }
  272. }
  273. };
  274. g.dialog = $('<div class="l-dialog"><table class="l-dialog-table" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td class="l-dialog-tl"></td><td class="l-dialog-tc"><div class="l-dialog-tc-inner"><div class="l-dialog-icon"></div><div class="l-dialog-title"></div><div class="l-dialog-close"></div></div></td><td class="l-dialog-tr"></td></tr><tr><td class="l-dialog-cl"></td><td class="l-dialog-cc"><div class="l-dialog-body"><div class="l-dialog-image"></div> <div class="l-dialog-content"></div><div class="l-dialog-buttons"><div class="l-dialog-buttons-inner"></div></td><td class="l-dialog-cr"></td></tr><tr><td class="l-dialog-bl"></td><td class="l-dialog-bc"></td><td class="l-dialog-br"></td></tr></tbody></table></div>');
  275. $('body').append(g.dialog);
  276. g.dialog.body = $(".l-dialog-body:first", g.dialog);
  277. g.dialog.close = function() {
  278. if(g.dialog.frame)
  279. {
  280. $(g.dialog.frame.document).ready(function(){
  281. g.removeWindowMask();
  282. g.dialog.remove();
  283. });
  284. }
  285. else
  286. {
  287. g.removeWindowMask();
  288. g.dialog.remove();
  289. }
  290. };
  291. g.dialog.doShow = function() {
  292. g.dialog.show();
  293. };
  294. if(p.allowClose == false) $(".l-dialog-close", g.dialog).remove();
  295. if (p.target || p.url || p.type == "none") p.type = null;
  296. if(p.cls) g.dialog.addClass(p.cls);
  297. if(p.id) g.dialog.attr("id",p.id);
  298. //设置锁定屏幕、拖动支持 和设置图片
  299. if (p.modal)
  300. g.applyWindowMask();
  301. if (p.isDrag)
  302. g.applyDrag();
  303. if(p.isResize)
  304. g.applyResize();
  305. if (p.type)
  306. g.setImage();
  307. else {
  308. $(".l-dialog-image", g.dialog).remove();
  309. $(".l-dialog-content", g.dialog.body).addClass("l-dialog-content-noimage");
  310. }
  311. //设置主体内容
  312. if (p.target) {
  313. $(".l-dialog-content", g.dialog.body).prepend(p.target);
  314. }
  315. else if (p.url) {
  316. if(p.timeParmName)
  317. {
  318. p.url += p.url.indexOf('?')==-1 ? "?" : "&" ;
  319. p.url += p.timeParmName +"="+new Date().getTime();
  320. }
  321. var iframe = $("<iframe frameborder='0'></iframe>");
  322. var framename = p.name ? p.name : "ligerwindow" + new Date().getTime();
  323. iframe.attr("name", framename);
  324. $(".l-dialog-content", g.dialog.body).prepend(iframe);
  325. $(".l-dialog-content",g.dialog.body).addClass("l-dialog-content-nopadding");
  326. setTimeout(function(){
  327. iframe.attr("src",p.url);
  328. g.dialog.frame = window.frames[iframe.attr("name")];
  329. },0);
  330. }
  331. else if (p.content) {
  332. $(".l-dialog-content", g.dialog.body).html(p.content);
  333. }
  334. if(p.opener) g.dialog.opener = p.opener;
  335. //设置按钮
  336. if (p.buttons) {
  337. $(p.buttons).each(function(i,item){
  338. var btn = $('<div class="l-dialog-btn"><div class="l-dialog-btn-l"></div><div class="l-dialog-btn-r"></div><div class="l-dialog-btn-inner"></div></div>');
  339. $(".l-dialog-btn-inner", btn).html(item.text);
  340. $(".l-dialog-buttons-inner", g.dialog.body).prepend(btn);
  341. item.width && btn.width(item.width);
  342. item.onclick && btn.click(function() { item.onclick(item , g.dialog,i) });
  343. });
  344. }else{
  345. $(".l-dialog-buttons", g.dialog).remove();
  346. }
  347. $(".l-dialog-buttons-inner", g.dialog).append("<div class='l-clear'></div>");
  348. //设置参数属性
  349. p.width && g.dialog.body.width(p.width - 26);
  350. if(p.height)
  351. {
  352. $(".l-dialog-content",g.dialog.body).height(p.height - 46 - $(".l-dialog-buttons", g.dialog).height());
  353. }
  354. p.title = p.title || p.titleMessage;
  355. p.title && $(".l-dialog-title", g.dialog).html(p.title);
  356. $(".l-dialog-title", g.dialog).bind("selectstart", function() { return false; });
  357. //设置事件
  358. $(".l-dialog-btn", g.dialog.body).hover(function() {
  359. $(this).addClass("l-dialog-btn-over");
  360. }, function() {
  361. $(this).removeClass("l-dialog-btn-over");
  362. });
  363. $(".l-dialog-tc .l-dialog-close", g.dialog).hover(function() {
  364. $(this).addClass("l-dialog-close-over");
  365. }, function() {
  366. $(this).removeClass("l-dialog-close-over");
  367. }).click(function() {
  368. g.dialog.close();
  369. });
  370. //IE6 PNG Fix
  371. var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
  372. var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
  373. if ($.browser.msie && (ie55 || ie6)) {
  374. $(".l-dialog-tl:first", g.dialog).css({
  375. "background": "none",
  376. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "dialog-tl.png',sizingMethod='crop');"
  377. });
  378. $(".l-dialog-tc:first", g.dialog).css({
  379. "background": "none",
  380. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "ie6/dialog-tc.png',sizingMethod='crop');"
  381. });
  382. $(".l-dialog-tr:first", g.dialog).css({
  383. "background": "none",
  384. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "dialog-tr.png',sizingMethod='crop');"
  385. });
  386. $(".l-dialog-cl:first", g.dialog).css({
  387. "background": "none",
  388. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "ie6/dialog-cl.png',sizingMethod='crop');"
  389. });
  390. $(".l-dialog-cr:first", g.dialog).css({
  391. "background": "none",
  392. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "ie6/dialog-cr.png',sizingMethod='crop');"
  393. });
  394. $(".l-dialog-bl:first", g.dialog).css({
  395. "background": "none",
  396. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "dialog-bl.png',sizingMethod='crop');"
  397. });
  398. $(".l-dialog-bc:first", g.dialog).css({
  399. "background": "none",
  400. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "ie6/dialog-bc.png',sizingMethod='crop');"
  401. });
  402. $(".l-dialog-br:first", g.dialog).css({
  403. "background": "none",
  404. "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ligerDialogImagePath + "dialog-br.png',sizingMethod='crop');"
  405. });
  406. }
  407. //位置初始化
  408. var left = 0;
  409. var top = 0;
  410. var width = p.width || g.dialog.width();
  411. if (p.left != null) left = p.left;
  412. else left = 0.5 * ($(window).width() - width);
  413. if (p.top != null) top = p.top;
  414. else top = 0.5 * ($(window).height() - g.dialog.height()) + $(window).scrollTop() - 10;
  415. g.dialog.css({ left: left, top: top });
  416. g.dialog.doShow();
  417. return g.dialog;
  418. };
  419. $.ligerDialog.close = function()
  420. {
  421. $(".l-dialog,.l-window-mask").remove();
  422. };
  423. $.ligerDialog.alert = function(content, title, type, callback) {
  424. content = content || "";
  425. if (typeof (title) == "function") {
  426. callback = title;
  427. type = null;
  428. }
  429. else if (typeof (type) == "function") {
  430. callback = type;
  431. }
  432. var btnclick = function(item, Dialog,index) {
  433. Dialog.close();
  434. if (callback)
  435. callback(item, Dialog,index);
  436. };
  437. p = {
  438. content: content,
  439. buttons: [{ text: '确定', onclick: btnclick}]
  440. };
  441. if (typeof (title) == "string" && title != "") p.title = title;
  442. if (typeof (type) == "string" && type != "") p.type = type;
  443. $.ligerDialog.open(p);
  444. };
  445. $.ligerDialog.confirm = function(content,title, callback) {
  446. if (typeof (title) == "function") {
  447. callback = title;
  448. type = null;
  449. }
  450. var btnclick = function(item, Dialog) {
  451. Dialog.close();
  452. if (callback) {
  453. callback(item.type=='ok');
  454. }
  455. };
  456. p = {
  457. type: 'question',
  458. content: content,
  459. buttons: [{ text: '是', onclick: btnclick,type:'ok' }, { text: '否', onclick: btnclick,type:'no'}]
  460. };
  461. if (typeof (title) == "string" && title != "") p.title = title;
  462. $.ligerDialog.open(p);
  463. };
  464. $.ligerDialog.warning = function(content, title, callback) {
  465. if (typeof (title) == "function") {
  466. callback = title;
  467. type = null;
  468. }
  469. var btnclick= function(item, Dialog) {
  470. Dialog.close();
  471. if (callback) {
  472. callback(item.type);
  473. }
  474. };
  475. p = {
  476. type: 'question',
  477. content: content,
  478. buttons: [{ text: '是', onclick: btnclick, type: 'yes' }, { text: '否', onclick: btnclick, type: 'no' }, { text: '取消', onclick: btnclick, type: 'cancel'}]
  479. };
  480. if (typeof (title) == "string" && title != "") p.title = title;
  481. $.ligerDialog.open(p);
  482. };
  483. $.ligerDialog.waitting = function(title)
  484. {
  485. title = title || $.ligerDefaults.Dialog.waittingMessage;
  486. $.ligerDialog.open({cls:'l-dialog-waittingdialog',type:'none',content:'<div style="padding:4px">'+title+'</div>',allowClose:false});
  487. };
  488. $.ligerDialog.closeWaitting = function()
  489. {
  490. $(".l-dialog-waittingdialog,.l-window-mask").remove();
  491. };
  492. $.ligerDialog.success = function(content, title, onBtnClick) {
  493. $.ligerDialog.alert(content, title, 'success', onBtnClick);
  494. };
  495. $.ligerDialog.error = function(content, title, onBtnClick) {
  496. $.ligerDialog.alert(content, title, 'error', onBtnClick);
  497. };
  498. $.ligerDialog.warn = function(content, title, onBtnClick) {
  499. $.ligerDialog.alert(content, title, 'warn', onBtnClick);
  500. };
  501. $.ligerDialog.question = function(content, title) {
  502. $.ligerDialog.alert(content, title, 'question');
  503. };
  504. $.ligerDialog.prompt = function(title,value,multi, callback) {
  505. var target = $('<input type="text" class="l-dialog-inputtext"/>');
  506. if(typeof(multi) == "function"){
  507. callback = multi;
  508. }
  509. if (typeof (value) == "function") {
  510. callback = value;
  511. }
  512. else if (typeof (value) == "boolean") {
  513. multi = value;
  514. }
  515. if(typeof(multi) == "boolean" && multi)
  516. {
  517. target = $('<textarea class="l-dialog-textarea"></textarea>');
  518. }
  519. if(typeof (value) == "string" || typeof (value) == "int")
  520. {
  521. target.val(value);
  522. }
  523. var btnclick = function(item, Dialog , index) {
  524. Dialog.close();
  525. if (callback) {
  526. callback(item.type == 'yes', target.val());
  527. }
  528. }
  529. p = {
  530. title: title,
  531. target: target,
  532. width:320,
  533. buttons: [{ text: '确定', onclick: btnclick, type: 'yes' }, { text: '取消', onclick: btnclick, type: 'cancel'}]
  534. };
  535. $.ligerDialog.open(p);
  536. };
  537. })(jQuery);
  538. //ligerDrag.js
  539. (function($) {
  540. $.ligerDefaults = $.ligerDefaults || {};
  541. $.ligerDefaults.Drag = {
  542. onStartDrag: false,
  543. onDrag: false,
  544. onStopDrag: false
  545. };
  546. /// <param name="$" type="jQuery"></param>
  547. $.fn.ligerDrag = function(p) {
  548. p = $.extend({}, $.ligerDefaults.Drag, p || {});
  549. return this.each(function() {
  550. if (this.useDrag) return;
  551. var g = {
  552. start: function(e) {
  553. $('body').css('cursor', 'move');
  554. g.current = {
  555. target: g.target,
  556. left: g.target.offset().left,
  557. top: g.target.offset().top,
  558. startX: e.pageX || e.screenX,
  559. startY: e.pageY || e.clientY
  560. };
  561. $(document).bind('mouseup.drag', g.stop);
  562. $(document).bind('mousemove.drag', g.drag);
  563. if (p.onStartDrag) p.onStartDrag(g.current, e);
  564. },
  565. drag: function(e) {
  566. if (!g.current) return;
  567. var pageX = e.pageX || e.screenX;
  568. var pageY = e.pageY || e.screenY;
  569. g.current.diffX = pageX - g.current.startX;
  570. g.current.diffY = pageY - g.current.startY;
  571. if (p.onDrag) {
  572. if (p.onDrag(g.current, e) != false) {
  573. g.applyDrag();
  574. }
  575. }
  576. else {
  577. g.applyDrag();
  578. }
  579. // //每30毫秒触发一次
  580. // $(document).unbind('mousemove.drag');
  581. // setTimeout(function ()
  582. // {
  583. // $(document).bind('mousemove.drag', g.drag);
  584. // }, 30);
  585. },
  586. stop: function(e) {
  587. $(document).unbind('mousemove.drag');
  588. $(document).unbind('mouseup.drag');
  589. $("body").css("cursor", "");
  590. if (p.onStopDrag) p.onStopDrag(g.current, e);
  591. g.current = null;
  592. },
  593. //更新当前坐标
  594. applyDrag: function() {
  595. if (g.current.diffX) {
  596. g.target.css("left", (g.current.left + g.current.diffX));
  597. }
  598. if (g.current.diffY) {
  599. g.target.css("top", (g.current.top + g.current.diffY));
  600. }
  601. }
  602. };
  603. g.target = $(this);
  604. if (p.handler == undefined || p.handler == null)
  605. g.handler = $(this);
  606. else
  607. g.handler = (typeof p.handler == 'string' ? $(p.handler, this) : p.handle);
  608. g.handler.hover(function() {
  609. $('body').css('cursor', 'move');
  610. }, function() {
  611. $("body").css("cursor", "default");
  612. }).mousedown(function(e) {
  613. g.start(e);
  614. return false;
  615. });
  616. this.useDrag = true;
  617. });
  618. };
  619. })(jQuery);
  620. //ligerMenu.js
  621. if (typeof (LigerUIMenu) == "undefined") LigerUIMenu = {};
  622. (function ($)
  623. {
  624. $.ligerDefaults = $.ligerDefaults || {};
  625. $.ligerDefaults.Menu = {
  626. width: 120,
  627. top: 0,
  628. left: 0,
  629. items:null,
  630. shadow: true
  631. };
  632. /// <param name="$" type="jQuery"></param>
  633. $.ligerMenu = function (p)
  634. {
  635. p = $.extend({ }, $.ligerDefaults.Menu, p || {});
  636. var g = {
  637. show: function (options,menu)
  638. {
  639. if(menu==undefined) menu = g.menu;
  640. if (options && options.left != undefined)
  641. {
  642. menu.css({ left: options.left });
  643. }
  644. if (options && options.top != undefined)
  645. {
  646. menu.css({ top: options.top });
  647. }
  648. menu.show();
  649. g.updateShadow(menu);
  650. },
  651. updateShadow: function (menu)
  652. {
  653. if (!p.shadow) return;
  654. menu.shadow.css({
  655. left: menu.css('left'),
  656. top: menu.css('top'),
  657. width: menu.outerWidth(),
  658. height: menu.outerHeight()
  659. });
  660. if (menu.is(":visible"))
  661. menu.shadow.show();
  662. else
  663. menu.shadow.hide();
  664. },
  665. hide: function (menu)
  666. {
  667. if(menu==undefined) menu = g.menu;
  668. g.hideAllSubMenu(menu);
  669. menu.hide();
  670. g.updateShadow(menu);
  671. },
  672. toggle: function ()
  673. {
  674. g.menu.toggle();
  675. g.updateShadow(g.menu);
  676. },
  677. removeItem: function (itemid)
  678. {
  679. $("> .l-menu-item[menuitemid=" + itemid + "]", g.menu.items).remove();
  680. g.itemCount--;
  681. },
  682. setEnable: function (itemid)
  683. {
  684. $("> .l-menu-item[menuitemid=" + itemid + "]", g.menu.items).removeClass("l-menu-item-disable");
  685. },
  686. setDisable: function (itemid)
  687. {
  688. $("> .l-menu-item[menuitemid=" + itemid + "]", g.menu.items).addClass("l-menu-item-disable");
  689. },
  690. isEnable: function (itemid)
  691. {
  692. return !$("> .l-menu-item[menuitemid=" + itemid + "]", g.menu.items).hasClass("l-menu-item-disable");
  693. },
  694. getItemCount: function ()
  695. {
  696. return $("> .l-menu-item", g.menu.items).length;
  697. },
  698. addItem: function (item, menu)
  699. {
  700. if(!item) return ;
  701. if(menu== undefined) menu = g.menu;
  702. if (item.line)
  703. {
  704. menu.items.append('<div class="l-menu-item-line"></div>');
  705. return;
  706. }
  707. var ditem = $('<div class="l-menu-item"><div class="l-menu-item-text"></div> </div>');
  708. var itemcount = $("> .l-menu-item", menu.items).length;
  709. menu.items.append(ditem);
  710. item.id && ditem.attr("menuitemid", item.id);
  711. item.text && $(">.l-menu-item-text:first", ditem).html(item.text);
  712. item.icon && ditem.prepend('<div class="l-menu-item-icon l-icon-' + item.icon + '"></div>');
  713. item.disable && ditem.addClass("l-menu-item-disable");
  714. if (item.children)
  715. {
  716. if (ditem.attr("menuitemid") == undefined) ditem.attr("menuitemid", new Date().getTime());
  717. ditem.append('<div class="l-menu-item-arrow"></div>');
  718. var newmenu = g.createMenu(ditem.attr("menuitemid"));
  719. LigerUIMenu[ditem.attr("menuitemid")] = newmenu;
  720. newmenu.width(p.width);
  721. newmenu.hover(null,function(){
  722. if(!newmenu.showedSubMenu)
  723. g.hide(newmenu);
  724. });
  725. $(item.children).each(function ()
  726. {
  727. g.addItem(this, newmenu);
  728. });
  729. }
  730. item.click && ditem.click(function ()
  731. {
  732. if ($(this).hasClass("l-menu-item-disable")) return;
  733. item.click(item, itemcount);
  734. });
  735. item.dblclick && ditem.dblclick(function ()
  736. {
  737. if ($(this).hasClass("l-menu-item-disable")) return;
  738. item.dblclick(item, itemcount);
  739. });
  740. var menuover = $("> .l-menu-over:first", menu);
  741. ditem.hover(function ()
  742. {
  743. if ($(this).hasClass("l-menu-item-disable")) return;
  744. var itemtop = $(this).offset().top;
  745. var top = itemtop - menu.offset().top;
  746. menuover.css({ top: top });
  747. g.hideAllSubMenu(menu);
  748. if (item.children)
  749. {
  750. var meniitemid = $(this).attr("menuitemid");
  751. if (!meniitemid) return;
  752. if(LigerUIMenu[meniitemid])
  753. {
  754. g.show({top:itemtop,left:$(this).offset().left+$(this).width()-5},LigerUIMenu[meniitemid]);
  755. menu.showedSubMenu = true;
  756. }
  757. }
  758. }, function ()
  759. {
  760. if ($(this).hasClass("l-menu-item-disable")) return;
  761. var meniitemid = $(this).attr("menuitemid");
  762. if (item.children)
  763. {
  764. var meniitemid = $(this).attr("menuitemid");
  765. if (!meniitemid) return;
  766. };
  767. });
  768. },
  769. hideAllSubMenu:function(menu)
  770. {
  771. if(menu==undefined) menu = g.menu;
  772. $("> .l-menu-item",menu.items).each(function(){
  773. if($("> .l-menu-item-arrow",this).length>0)
  774. {
  775. var meniitemid = $(this).attr("menuitemid");
  776. if (!meniitemid) return;
  777. LigerUIMenu[meniitemid] && g.hide(LigerUIMenu[meniitemid]);
  778. }
  779. });
  780. menu.showedSubMenu = false;
  781. },
  782. createMenu: function (parentMenuItemID)
  783. {
  784. var menu = $('<div class="l-menu" style="display:none"><div class="l-menu-yline"></div><div class="l-menu-over"><div class="l-menu-over-l"></div> <div class="l-menu-over-r"></div></div><div class="l-menu-inner"></div></div>');
  785. parentMenuItemID && menu.attr("parentmenuitemid", parentMenuItemID);
  786. menu.items = $("> .l-menu-inner:first", menu);
  787. menu.appendTo('body');
  788. if (p.shadow)
  789. {
  790. menu.shadow = $('<div class="l-menu-shadow"></div>').insertAfter(menu);
  791. g.updateShadow(menu);
  792. }
  793. menu.hover(null,function(){
  794. if(!menu.showedSubMenu)
  795. $("> .l-menu-over:first", menu).css({ top: -24 });
  796. });
  797. return menu;
  798. }
  799. };
  800. g.menu = g.createMenu();
  801. g.menu.css({ top: p.top, left: p.left, width: p.width });
  802. p.items && $(p.items).each(function (i, item)
  803. {
  804. g.addItem(item);
  805. });
  806. return g;
  807. };
  808. $(document).click(function ()
  809. {
  810. $(".l-menu,.l-menu-shadow").hide();
  811. });
  812. })(jQuery);
  813. //ligerLayout.js
  814. (function ($) {
  815. /// <param name="$" type="jQuery"></param>
  816. $.fn.ligerGetLayoutManager = function () {
  817. return LigerUIManagers[this[0].id + "_Layout"];
  818. };
  819. $.fn.ligerRemoveLayoutManager = function () {
  820. return this.each(function () {
  821. LigerUIManagers[this.id + "_Layout"] = null;
  822. });
  823. };
  824. $.ligerDefaults = $.ligerDefaults || {};
  825. $.ligerDefaults.Layout = {
  826. topHeight: 65,
  827. bottomHeight: 65,
  828. leftWidth: 110,
  829. centerWidth: 300,
  830. rightWidth: 170,
  831. InWindow : true, //是否以窗口的高度为准 height设置为百分比时可用
  832. heightDiff : 0, //高度补差
  833. height:'100%', //高度
  834. onHeightChanged: null,
  835. isLeftCollapse: false, //初始化时 左边是否隐藏
  836. isRightCollapse: false, //初始化时 右边是否隐藏
  837. allowLeftCollapse: true, //是否允许 左边可以隐藏
  838. allowRightCollapse: true, //是否允许 右边可以隐藏
  839. allowLeftResize: true, //是否允许 左边可以调整大小
  840. allowRightResize: true, //是否允许 右边可以调整大小
  841. allowTopResize: true, //是否允许 头部可以调整大小
  842. allowBottomResize: true, //是否允许 底部可以调整大小
  843. space: 5 //间隔
  844. };
  845. $.fn.ligerLayout = function (p) {
  846. this.each(function () {
  847. p = $.extend({ }, $.ligerDefaults.Layout, p || {});
  848. if (this.usedLayout) return;
  849. var g = {
  850. init: function () {
  851. $("> .l-layout-left .l-layout-header,> .l-layout-right .l-layout-header", g.layout).hover(function () {
  852. $(this).addClass("l-layout-header-over");
  853. }, function () {
  854. $(this).removeClass("l-layout-header-over");
  855. });
  856. $(".l-layout-header-toggle", g.layout).hover(function () {
  857. $(this).addClass("l-layout-header-toggle-over");
  858. }, function () {
  859. $(this).removeClass("l-layout-header-toggle-over");
  860. });
  861. $(".l-layout-header-toggle", g.left).click(function () {
  862. g.setLeftCollapse(true);
  863. });
  864. $(".l-layout-header-toggle", g.right).click(function () {
  865. g.setRightCollapse(true);
  866. });
  867. //set top
  868. g.middleTop = 0;
  869. if (g.top) {
  870. g.middleTop += g.top.height();
  871. g.middleTop += parseInt(g.top.css('borderTopWidth'));
  872. g.middleTop += parseInt(g.top.css('borderBottomWidth'));
  873. //g.middleTop += p.space;
  874. }
  875. if (g.left) {
  876. g.left.css({ top: g.middleTop });
  877. g.leftCollapse.css({ top: g.middleTop });
  878. }
  879. if (g.center) {
  880. g.center.css({ top: g.middleTop });
  881. }
  882. if (g.right) {
  883. g.right.css({ top: g.middleTop });
  884. g.rightCollapse.css({ top: g.middleTop });
  885. }
  886. //set left
  887. if (g.left) g.left.css({ left: 0 }); //=====================================
  888. g.onResize();
  889. g.onResize();
  890. },
  891. setCollapse: function () {
  892. g.leftCollapse.hover(function () {
  893. $(this).addClass("l-layout-collapse-left-over");
  894. }, function () {
  895. $(this).removeClass("l-layout-collapse-left-over");
  896. });
  897. g.leftCollapse.toggle.hover(function () {
  898. $(this).addClass("l-layout-collapse-left-toggle-over");
  899. }, function () {
  900. $(this).removeClass("l-layout-collapse-left-toggle-over");
  901. });
  902. g.rightCollapse.hover(function () {
  903. $(this).addClass("l-layout-collapse-right-over");
  904. }, function () {
  905. $(this).removeClass("l-layout-collapse-right-over");
  906. });
  907. g.rightCollapse.toggle.hover(function () {
  908. $(this).addClass("l-layout-collapse-right-toggle-over");
  909. }, function () {
  910. $(this).removeClass("l-layout-collapse-right-toggle-over");
  911. });
  912. g.leftCollapse.toggle.click(function () {
  913. g.setLeftCollapse(false);
  914. });
  915. g.rightCollapse.toggle.click(function () {
  916. g.setRightCollapse(false);
  917. });
  918. if (g.left && g.isLeftCollapse) {
  919. g.leftCollapse.show();
  920. g.leftDropHandle && g.leftDropHandle.hide();
  921. g.left.hide();
  922. }
  923. if (g.right && g.isRightCollapse) {
  924. g.rightCollapse.show();
  925. g.rightDropHandle && g.rightDropHandle.hide();
  926. g.right.hide();
  927. }
  928. },
  929. setLeftCollapse: function (isCollapse) {
  930. if (!g.left) return false;
  931. g.isLeftCollapse = isCollapse;
  932. if (g.isLeftCollapse) {
  933. g.leftCollapse.show();
  934. g.leftDropHandle && g.leftDropHandle.hide();
  935. g.left.hide();
  936. }
  937. else {
  938. g.leftCollapse.hide();
  939. g.leftDropHandle && g.leftDropHandle.show();
  940. g.left.show();
  941. }
  942. g.onResize();
  943. },
  944. setRightCollapse: function (isCollapse) {
  945. if (!g.right) return false;
  946. g.isRightCollapse = isCollapse;
  947. g.onResize();
  948. if (g.isRightCollapse) {
  949. g.rightCollapse.show();
  950. g.rightDropHandle && g.rightDropHandle.hide();
  951. g.right.hide();
  952. }
  953. else {
  954. g.rightCollapse.hide();
  955. g.rightDropHandle && g.rightDropHandle.show();
  956. g.right.show();
  957. }
  958. g.onResize();
  959. },
  960. addDropHandle: function () {
  961. if (g.left && p.allowLeftResize) {
  962. g.leftDropHandle = $("<div class='l-layout-drophandle-left'></div>");
  963. g.layout.append(g.leftDropHandle);
  964. g.leftDropHandle && g.leftDropHandle.show();
  965. g.leftDropHandle.mousedown(function (e) {
  966. g.start('leftresize', e);
  967. });
  968. }
  969. if (g.right && p.allowRightResize) {
  970. g.rightDropHandle = $("<div class='l-layout-drophandle-right'></div>");
  971. g.layout.append(g.rightDropHandle);
  972. g.rightDropHandle && g.rightDropHandle.show();
  973. g.rightDropHandle.mousedown(function (e) {
  974. g.start('rightresize', e);
  975. });
  976. }
  977. if (g.top && p.allowTopResize) {
  978. g.topDropHandle = $("<div class='l-layout-drophandle-top'></div>");
  979. g.layout.append(g.topDropHandle);
  980. g.topDropHandle.show();
  981. g.topDropHandle.mousedown(function (e) {
  982. g.start('topresize', e);
  983. });
  984. }
  985. if (g.bottom && p.allowBottomResize) {
  986. g.bottomDropHandle = $("<div class='l-layout-drophandle-bottom'></div>");
  987. g.layout.append(g.bottomDropHandle);
  988. g.bottomDropHandle.show();
  989. g.bottomDropHandle.mousedown(function (e) {
  990. g.start('bottomresize', e);
  991. });
  992. }
  993. g.draggingxline = $("<div class='l-layout-dragging-xline'></div>");
  994. g.draggingyline = $("<div class='l-layout-dragging-yline'></div>");
  995. g.layout.append(g.draggingxline).append(g.draggingyline);
  996. },
  997. setDropHandlePosition: function () {
  998. if (g.leftDropHandle) {
  999. g.leftDropHandle.css({ left: g.left.width() + parseInt(g.left.css('left')), height: g.middleHeight, top: g.middleTop });
  1000. }
  1001. if (g.rightDropHandle) {
  1002. g.rightDropHandle.css({ left: parseInt(g.right.css('left')) - p.space, height: g.middleHeight, top: g.middleTop });
  1003. }
  1004. if (g.topDropHandle) {
  1005. g.topDropHandle.css({ top: g.top.height() + parseInt(g.top.css('top')), width: g.top.width() });
  1006. }
  1007. if (g.bottomDropHandle) {
  1008. g.bottomDropHandle.css({ top: parseInt(g.bottom.css('top')) - p.space, width: g.bottom.width() });
  1009. }
  1010. },
  1011. onResize: function () {
  1012. var oldheight = g.layout.height();
  1013. //set layout height
  1014. var h = 0;
  1015. var windowHeight = $(window).height();
  1016. var parentHeight = null;
  1017. if (typeof(p.height) == "string" && p.height.indexOf('%') > 0)
  1018. {
  1019. var layoutparent = g.layout.parent();
  1020. if (p.InWindow || layoutparent[0].tagName.toLowerCase() == "body") {
  1021. parentHeight = windowHeight;
  1022. parentHeight -= parseInt($('body').css('paddingTop'));
  1023. parentHeight -= parseInt($('body').css('paddingBottom'));
  1024. }
  1025. else{
  1026. parentHeight = layoutparent.height();
  1027. }
  1028. h = parentHeight * parseFloat(p.height) * 0.01;
  1029. if(p.InWindow || layoutparent[0].tagName.toLowerCase() == "body")
  1030. h -= (g.layout.offset().top - parseInt($('body').css('paddingTop')));
  1031. }
  1032. else
  1033. {
  1034. h = parseInt(p.height);
  1035. }
  1036. h += p.heightDiff;
  1037. g.layout.height(h);
  1038. g.layoutHeight = g.layout.height();
  1039. g.middleWidth = g.layout.width();
  1040. g.middleHeight = g.layout.height();
  1041. if (g.top) {
  1042. g.middleHeight -= g.top.height();
  1043. g.middleHeight -= parseInt(g.top.css('borderTopWidth'));
  1044. g.middleHeight -= parseInt(g.top.css('borderBottomWidth'));
  1045. g.middleHeight -= p.space;
  1046. }
  1047. if (g.bottom) {
  1048. g.middleHeight -= g.bottom.height();
  1049. g.middleHeight -= parseInt(g.bottom.css('borderTopWidth'));
  1050. g.middleHeight -= parseInt(g.bottom.css('borderBottomWidth'));
  1051. //g.middleHeight -= p.space;
  1052. }
  1053. //specific
  1054. g.middleHeight -= 2;
  1055. if (p.onHeightChanged && g.layoutHeight != oldheight) {
  1056. p.onHeightChanged({ layoutHeight: g.layoutHeight, diff: g.layoutHeight - oldheight, middleHeight: g.middleHeight });
  1057. }
  1058. if (g.center) {
  1059. g.centerWidth = g.middleWidth;
  1060. if (g.left) {
  1061. if (g.isLeftCollapse) {
  1062. g.centerWidth -= g.leftCollapse.width()+2; //================================
  1063. g.centerWidth -= parseInt(g.leftCollapse.css('borderLeftWidth'));
  1064. g.centerWidth -= parseInt(g.leftCollapse.css('borderRightWidth'));
  1065. g.centerWidth -= parseInt(g.leftCollapse.css('left'));
  1066. g.centerWidth -= p.space;
  1067. }
  1068. else {
  1069. g.centerWidth -= g.leftWidth+2; //=============================
  1070. g.centerWidth -= parseInt(g.left.css('borderLeftWidth'));
  1071. g.centerWidth -= parseInt(g.left.css('borderRightWidth'));
  1072. g.centerWidth -= parseInt(g.left.css('left'));
  1073. g.centerWidth -= p.space;
  1074. }
  1075. }
  1076. if (g.right) {
  1077. if (g.isRightCollapse) {
  1078. g.centerWidth -= g.rightCollapse.width();
  1079. g.centerWidth -= parseInt(g.rightCollapse.css('borderLeftWidth'));
  1080. g.centerWidth -= parseInt(g.rightCollapse.css('borderRightWidth'));
  1081. g.centerWidth -= parseInt(g.rightCollapse.css('right'));
  1082. g.centerWidth -= p.space;
  1083. }
  1084. else {
  1085. g.centerWidth -= g.rightWidth;
  1086. g.centerWidth -= parseInt(g.right.css('borderLeftWidth'));
  1087. g.centerWidth -= parseInt(g.right.css('borderRightWidth'));
  1088. g.centerWidth -= p.space;
  1089. }
  1090. }
  1091. g.centerLeft = 0;
  1092. if (g.left) {
  1093. if (g.isLeftCollapse) {
  1094. g.centerLeft += g.leftCollapse.width();
  1095. g.centerLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
  1096. g.centerLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
  1097. g.centerLeft += parseInt(g.leftCollapse.css('left'));
  1098. g.centerLeft += p.space;
  1099. }
  1100. else {
  1101. g.centerLeft += g.left.width();
  1102. g.centerLeft += parseInt(g.left.css('borderLeftWidth'));
  1103. g.centerLeft += parseInt(g.left.css('borderRightWidth'));
  1104. g.centerLeft += p.space;
  1105. }
  1106. }
  1107. g.center.css({ left: g.centerLeft });
  1108. g.center.width(g.centerWidth);
  1109. g.center.height(g.middleHeight);
  1110. var contentHeight = g.middleHeight;
  1111. if(g.center.header) contentHeight-= g.center.header.height();
  1112. g.center.content.height(contentHeight);
  1113. }
  1114. if (g.left) {
  1115. g.leftCollapse.height(g.middleHeight);
  1116. g.left.height(g.middleHeight);
  1117. }
  1118. if (g.right) {
  1119. g.rightCollapse.height(g.middleHeight);
  1120. g.right.height(g.middleHeight);
  1121. //set left
  1122. g.rightLeft = 0;
  1123. if (g.left) {
  1124. if (g.isLeftCollapse) {
  1125. g.rightLeft += g.leftCollapse.width();
  1126. g.rightLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
  1127. g.rightLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
  1128. g.rightLeft += p.space;
  1129. }
  1130. else {
  1131. g.rightLeft += g.left.width();
  1132. g.rightLeft += parseInt(g.left.css('borderLeftWidth'));
  1133. g.rightLeft += parseInt(g.left.css('borderRightWidth'));
  1134. g.rightLeft += parseInt(g.left.css('left'));
  1135. g.rightLeft += p.space;
  1136. }
  1137. }
  1138. if (g.center) {
  1139. g.rightLeft += g.center.width();
  1140. g.rightLeft += parseInt(g.center.css('borderLeftWidth'));
  1141. g.rightLeft += parseInt(g.center.css('borderRightWidth'));
  1142. g.rightLeft += p.space;
  1143. }
  1144. g.right.css({ left: g.rightLeft });
  1145. }
  1146. if (g.bottom) {
  1147. g.bottomTop = g.layoutHeight - g.bottom.height() - 2;
  1148. g.bottom.css({ top: g.bottomTop });
  1149. }
  1150. g.setDropHandlePosition();
  1151. },
  1152. start: function (dragtype, e) {
  1153. g.dragtype = dragtype;
  1154. if (dragtype == 'leftresize' || dragtype == 'rightresize') {
  1155. g.xresize = { startX: e.pageX };
  1156. g.draggingyline.css({ left: e.pageX - g.layout.offset().left, height: g.middleHeight, top: g.middleTop }).show();
  1157. $('body').css('cursor', 'col-resize');
  1158. }
  1159. else if (dragtype == 'topresize' || dragtype == 'bottomresize') {
  1160. g.yresize = { startY: e.pageY };
  1161. g.draggingxline.css({ top: e.pageY - g.layout.offset().top, width: g.layout.width() }).show();
  1162. $('body').css('cursor', 'row-resize');
  1163. }
  1164. else {
  1165. return;
  1166. }
  1167. g.layout.lock.width(g.layout.width());
  1168. g.layout.lock.height(g.layout.height());
  1169. g.layout.lock.show();
  1170. if ($.browser.msie || $.browser.safari) $('body').bind('selectstart', function () { return false; }); // 不能选择
  1171. $(document).bind('mouseup', g.stop);
  1172. $(document).bind('mousemove', g.drag);
  1173. },
  1174. drag: function (e) {
  1175. if (g.xresize) {
  1176. g.xresize.diff = e.pageX - g.xresize.startX;
  1177. g.draggingyline.css({ left: e.pageX - g.layout.offset().left });
  1178. $('body').css('cursor', 'col-resize');
  1179. }
  1180. else if (g.yresize) {
  1181. g.yresize.diff = e.pageY - g.yresize.startY;
  1182. g.draggingxline.css({ top: e.pageY - g.layout.offset().top });
  1183. $('body').css('cursor', 'row-resize');
  1184. }
  1185. },
  1186. stop: function (e) {
  1187. if (g.xresize && g.xresize.diff != undefined) {
  1188. if (g.dragtype == 'leftresize') {
  1189. g.leftWidth += g.xresize.diff;
  1190. g.left.width(g.leftWidth);
  1191. if (g.center)
  1192. g.center.width(g.center.width() - g.xresize.diff).css({ left: parseInt(g.center.css('left')) + g.xresize.diff });
  1193. else if (g.right)
  1194. g.right.width(g.left.width() - g.xresize.diff).css({ left: parseInt(g.right.css('left')) + g.xresize.diff });
  1195. }
  1196. else if (g.dragtype == 'rightresize') {
  1197. g.rightWidth -= g.xresize.diff;
  1198. g.right.width(g.rightWidth).css({ left: parseInt(g.right.css('left')) + g.xresize.diff });
  1199. if (g.center)
  1200. g.center.width(g.center.width() + g.xresize.diff);
  1201. else if (g.left)
  1202. g.left.width(g.left.width() + g.xresize.diff);
  1203. }
  1204. }
  1205. else if (g.yresize && g.yresize.diff != undefined) {
  1206. if (g.dragtype == 'topresize') {
  1207. g.top.height(g.top.height() + g.yresize.diff);
  1208. g.middleTop += g.yresize.diff;
  1209. g.middleHeight -= g.yresize.diff;
  1210. if (g.left) {
  1211. g.left.css({ top: g.middleTop }).height(g.middleHeight);
  1212. g.leftCollapse.css({ top: g.middleTop }).height(g.middleHeight);
  1213. }
  1214. if (g.center) g.center.css({ top: g.middleTop }).height(g.middleHeight);
  1215. if (g.right) {
  1216. g.right.css({ top: g.middleTop }).height(g.middleHeight);
  1217. g.rightCollapse.css({ top: g.middleTop }).height(g.middleHeight);
  1218. }
  1219. }
  1220. else if (g.dragtype == 'bottomresize') {
  1221. g.bottom.height(g.bottom.height() - g.yresize.diff);
  1222. g.middleHeight += g.yresize.diff;
  1223. g.bottomTop += g.yresize.diff;
  1224. g.bottom.css({ top: g.bottomTop });
  1225. if (g.left) {
  1226. g.left.height(g.middleHeight);
  1227. g.leftCollapse.height(g.middleHeight);
  1228. }
  1229. if (g.center) g.center.height(g.middleHeight);
  1230. if (g.right) {
  1231. g.right.height(g.middleHeight);
  1232. g.rightCollapse.height(g.middleHeight);
  1233. }
  1234. }
  1235. }
  1236. g.setDropHandlePosition();
  1237. g.draggingxline.hide();
  1238. g.draggingyline.hide();
  1239. g.xresize = g.yresize = g.dragtype = false;
  1240. g.layout.lock.hide();
  1241. if ($.browser.msie || $.browser.safari)
  1242. $('body').unbind('selectstart');
  1243. $(document).unbind('mousemove', g.drag);
  1244. $(document).unbind('mouseup', g.stop);
  1245. $('body').css('cursor', '');
  1246. }
  1247. };
  1248. g.layout = $(this);
  1249. if (!g.layout.hasClass("l-layout"))
  1250. g.layout.addClass("l-layout");
  1251. g.width = g.layout.width();
  1252. //top
  1253. if ($("> div[position=top]", g.layout).length > 0) {
  1254. g.top = $("> div[position=top]", g.layout).wrap('<div class="l-layout-top" style="top:0px;"></div>').parent();
  1255. g.top.content = $("> div[position=top]", g.top);
  1256. if (!g.top.content.hasClass("l-layout-content"))
  1257. g.top.content.addClass("l-layout-content");
  1258. g.topHeight = p.topHeight;
  1259. if (g.topHeight) {
  1260. g.top.height(g.topHeight);
  1261. }
  1262. }
  1263. //bottom
  1264. if ($("> div[position=bottom]", g.layout).length > 0) {
  1265. g.bottom = $("> div[position=bottom]", g.layout).wrap('<div class="l-layout-bottom"></div>').parent();
  1266. g.bottom.content = $("> div[position=bottom]", g.top);
  1267. if (!g.bottom.content.hasClass("l-layout-content"))
  1268. g.bottom.content.addClass("l-layout-content");
  1269. g.bottomHeight = p.bottomHeight;
  1270. if (g.bottomHeight) {
  1271. g.bottom.height(g.bottomHeight);
  1272. }
  1273. }
  1274. //left
  1275. if ($("> div[position=left]", g.layout).length > 0) {
  1276. g.left = $("> div[position=left]", g.layout).wrap('<div class="l-layout-left" style="left:0px;"></div>').parent();
  1277. g.left.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
  1278. g.left.prepend(g.left.header);
  1279. g.left.header.toggle = $(".l-layout-header-toggle", g.left.header);
  1280. g.left.content = $("> div[position=left]", g.left);
  1281. if (!g.left.content.hasClass("l-layout-content"))
  1282. g.left.content.addClass("l-layout-content");
  1283. if(!p.allowLeftCollapse) $(".l-layout-header-toggle", g.left.header).remove();
  1284. //set title
  1285. var lefttitle = g.left.content.attr("title");
  1286. if (lefttitle) {
  1287. g.left.content.attr("title", "");
  1288. $(".l-layout-header-inner", g.left.header).html(lefttitle);
  1289. }
  1290. //set width
  1291. g.leftWidth = p.leftWidth;
  1292. if (g.leftWidth)
  1293. g.left.width(g.leftWidth);
  1294. }
  1295. //center
  1296. if ($("> div[position=center]", g.layout).length > 0) {
  1297. g.center = $("> div[position=center]", g.layout).wrap('<div class="l-layout-center" ></div>').parent();
  1298. g.center.content = $("> div[position=center]", g.center);
  1299. g.center.content.addClass("l-layout-content");
  1300. //set title
  1301. var centertitle = g.center.content.attr("title");
  1302. if (centertitle) {
  1303. g.center.content.attr("title", "");
  1304. g.center.header = $('<div class="l-layout-header"></div>');
  1305. g.center.prepend(g.center.header);
  1306. g.center.header.html(centertitle);
  1307. }
  1308. //set width
  1309. g.centerWidth = p.centerWidth;
  1310. if (g.centerWidth)
  1311. g.center.width(g.centerWidth);
  1312. }
  1313. //right
  1314. if ($("> div[position=right]", g.layout).length > 0) {
  1315. g.right = $("> div[position=right]", g.layout).wrap('<div class="l-layout-right"></div>').parent();
  1316. g.right.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
  1317. g.right.prepend(g.right.header);
  1318. g.right.header.toggle = $(".l-layout-header-toggle", g.right.header);
  1319. if(!p.allowRightCollapse) $(".l-layout-header-toggle", g.right.header).remove();
  1320. g.right.content = $("> div[position=right]", g.right);
  1321. if (!g.right.content.hasClass("l-layout-content"))
  1322. g.right.content.addClass("l-layout-content");
  1323. //set title
  1324. var righttitle = g.right.content.attr("title");
  1325. if (righttitle) {
  1326. g.right.content.attr("title", "");
  1327. $(".l-layout-header-inner", g.right.header).html(righttitle);
  1328. }
  1329. //set width
  1330. g.rightWidth = p.rightWidth;
  1331. if (g.rightWidth)
  1332. g.right.width(g.rightWidth);
  1333. }
  1334. //lock
  1335. g.layout.lock = $("<div class='l-layout-lock'></div>");
  1336. g.layout.append(g.layout.lock);
  1337. //DropHandle
  1338. g.addDropHandle();
  1339. //Collapse
  1340. g.isLeftCollapse = p.isLeftCollapse;
  1341. g.isRightCollapse = p.isRightCollapse;
  1342. g.leftCollapse = $('<div class="l-layout-collapse-left" style="display: none; "><div class="l-layout-collapse-left-toggle"></div></div>');
  1343. g.rightCollapse = $('<div class="l-layout-collapse-right" style="display: none; "><div class="l-layout-collapse-right-toggle"></div></div>');
  1344. g.layout.append(g.leftCollapse).append(g.rightCollapse);
  1345. g.leftCollapse.toggle = $("> .l-layout-collapse-left-toggle", g.leftCollapse);
  1346. g.rightCollapse.toggle = $("> .l-layout-collapse-right-toggle", g.rightCollapse);
  1347. g.setCollapse();
  1348. //init
  1349. g.init();
  1350. $(window).resize(function () {
  1351. g.onResize();
  1352. });
  1353. if (this.id == undefined) this.id = "LigerUI_" + new Date().getTime();
  1354. LigerUIManagers[this.id + "_Layout"] = g;
  1355. this.usedLayout = true;
  1356. });
  1357. if (this.length == 0) return null;
  1358. if (this.length == 1) return LigerUIManagers[this[0].id + "_Layout"];
  1359. var managers = [];
  1360. this.each(function() {
  1361. managers.push(LigerUIManagers[this.id + "_Layout"]);
  1362. });
  1363. return managers;
  1364. };
  1365. })(jQuery);
  1366. //ligerResizable.js
  1367. (function ($)
  1368. {
  1369. $.ligerDefaults = $.ligerDefaults || {};
  1370. $.ligerDefaults.Resizable = {
  1371. handles: 'n, e, s, w, ne, se, sw, nw',
  1372. maxWidth: 2000,
  1373. maxHeight: 2000,
  1374. minWidth: 20,
  1375. minHeight: 20,
  1376. onStartResize: function (e) { },
  1377. onResize: function (e) { },
  1378. onStopResize: function (e) { },
  1379. onEndResize: null
  1380. };
  1381. $.fn.ligerResizable = function (p)
  1382. {
  1383. return this.each(function ()
  1384. {
  1385. p = $.extend({}, $.ligerDefaults.Resizable, p || {});
  1386. var g = {
  1387. init: function ()
  1388. {
  1389. g.target.append('<div class="l-resizable"></div>');
  1390. //add handler dom elements
  1391. var handles = p.handles.split(',');
  1392. for (var i = 0; i < handles.length; i++)
  1393. {
  1394. switch (handles[i].replace(/(^\s*)|(\s*$)/g, "")) //trim
  1395. {
  1396. case "nw":
  1397. g.target.append('<div class="l-resizable-h-l" direction="nw"></div>');
  1398. break;
  1399. case "ne":
  1400. g.target.append('<div class="l-resizable-h-r" direction="ne"></div>');
  1401. break;
  1402. case "n":
  1403. g.target.append('<div class="l-resizable-h-c" direction="n"></div>');
  1404. break;
  1405. case "w":
  1406. g.target.append('<div class="l-resizable-c-l" direction="w"></div>');
  1407. break;
  1408. case "e":
  1409. g.target.append('<div class="l-resizable-c-r" direction="e"></div>');
  1410. break;
  1411. case "sw":
  1412. g.target.append('<div class="l-resizable-f-l" direction="sw"></div>');
  1413. break;
  1414. case "se":
  1415. g.target.append('<div class="l-resizable-f-r" direction="se"></div>');
  1416. break;
  1417. case "s":
  1418. g.target.append('<div class="l-resizable-f-c" direction="s"></div>');
  1419. break;
  1420. }
  1421. }
  1422. $("> .l-resizable-h-c , > .l-resizable-f-c", g.target).width(g.target.width());
  1423. $("> .l-resizable-c-l , > .l-resizable-c-r", g.target).height(g.target.height());
  1424. g.target.resizable = $("> .l-resizable", g.target);
  1425. },
  1426. start: function (e, dir)
  1427. {
  1428. if ($.browser.msie || $.browser.safari)
  1429. $('body').bind('selectstart', function () { return false; }); // 不能选择
  1430. $(".l-window-mask-nobackground").remove();
  1431. $("<div class='l-window-mask-nobackground' style='display: block;'></div>").appendTo($("body"));
  1432. g.target.resizable.css({
  1433. width: g.target.width(),
  1434. height: g.target.height(),
  1435. left: 0,
  1436. top: 0
  1437. });
  1438. g.current = {
  1439. dir: dir,
  1440. left: g.target.offset().left,
  1441. top: g.target.offset().top,
  1442. width: g.target.width(),
  1443. height: g.target.height()
  1444. };
  1445. $(document).bind('mouseup', g.stop);
  1446. $(document).bind('mousemove', g.drag);
  1447. g.target.resizable.show();
  1448. if (p.onStartResize) p.onStartResize(g.current, e);
  1449. },
  1450. drag: function (e)
  1451. {
  1452. var dir = g.current.dir;
  1453. var resizableObj = g.target.resizable[0];
  1454. var width = g.current.width;
  1455. var height = g.current.height;
  1456. var moveWidth = (e.pageX || e.screenX) - g.current.left;
  1457. var moveHeight = (e.pageY || e.clientY) - g.current.top;
  1458. if (dir.indexOf("e") >= 0) moveWidth -= width;
  1459. if (dir.indexOf("s") >= 0) moveHeight -= height;
  1460. if (dir != "n" && dir != "s")
  1461. {
  1462. width += (dir.indexOf("w") >= 0) ? -moveWidth : moveWidth;
  1463. }
  1464. if (width >= p.minWidth)
  1465. {
  1466. if (dir.indexOf("w") >= 0)
  1467. {
  1468. resizableObj.style.left = moveWidth + 'px';
  1469. }
  1470. if (dir != "n" && dir != "s")
  1471. {
  1472. resizableObj.style.width = width + 'px';
  1473. }
  1474. }
  1475. if (dir != "w" && dir != "e")
  1476. {
  1477. height += (dir.indexOf("n") >= 0) ? -moveHeight : moveHeight;
  1478. }
  1479. if (height >= p.minHeight)
  1480. {
  1481. if (dir.indexOf("n") >= 0)
  1482. {
  1483. resizableObj.style.top = moveHeight + 'px';
  1484. }
  1485. if (dir != "w" && dir != "e")
  1486. {
  1487. resizableObj.style.height = height + 'px';
  1488. }
  1489. }
  1490. g.current.newWidth = width;
  1491. g.current.newHeight = height;
  1492. g.current.diffTop = parseInt(resizableObj.style.top);
  1493. if (isNaN(g.current.diffTop)) g.current.diffTop = 0;
  1494. g.current.diffLeft = parseInt(resizableObj.style.left);
  1495. if (isNaN(g.current.diffLeft)) g.current.diffLeft = 0;
  1496. $("body").css("cursor", dir + '-resize');
  1497. if (p.onResize) p.onResize(g.current, e);
  1498. },
  1499. stop: function (e)
  1500. {
  1501. if ($.browser.msie || $.browser.safari)
  1502. $('body').unbind('selectstart');
  1503. $(".l-window-mask-nobackground").remove();
  1504. if (!p.onStopResize) g.applyResize();
  1505. else if (p.onStopResize(g.current, e) != false) g.applyResize();
  1506. p.onEndResize && p.onEndResize(g.current, e);
  1507. $("body").css("cursor", "");
  1508. g.target.resizable.hide();
  1509. $(document).unbind('mousemove', g.drag);
  1510. $(document).unbind('mouseup', g.stop);
  1511. },
  1512. applyResize: function ()
  1513. {
  1514. var top = 0;
  1515. var left = 0;
  1516. if (!isNaN(parseInt(g.target.css('top'))))
  1517. top = parseInt(g.target.css('top'));
  1518. if (!isNaN(parseInt(g.target.css('left'))))
  1519. left = parseInt(g.target.css('left'));
  1520. if (g.current.diffTop != undefined)
  1521. {
  1522. if (g.current.diffTop != 0)
  1523. g.target.css({ top: top + g.current.diffTop });
  1524. if (g.current.diffLeft != 0)
  1525. g.target.css({ left: left + g.current.diffLeft });
  1526. g.target.css({
  1527. width: g.current.newWidth,
  1528. height: g.current.newHeight
  1529. });
  1530. }
  1531. }
  1532. };
  1533. g.target = $(this);
  1534. g.init();
  1535. $(">div", g.target).mousedown(function (e)
  1536. {
  1537. if (!$(this).attr("direction")) return;
  1538. g.start(e, $(this).attr("direction"));
  1539. return false;
  1540. });
  1541. });
  1542. };
  1543. })(jQuery);
  1544. //ligerTip.js
  1545. (function($) {
  1546. $.ligerDefaults = $.ligerDefaults || {};
  1547. $.ligerDefaults.Tip = {
  1548. content: null,
  1549. callback: null,
  1550. width: 150,
  1551. height: null,
  1552. distanceX: 7,
  1553. distanceY: 0,
  1554. appendIdTo: null //保存ID到那一个对象(jQuery)
  1555. };
  1556. /// <param name="$" type="jQuery"></param>
  1557. $.fn.ligerTip = function(p) {
  1558. p = $.extend({}, $.ligerDefaults.Tip, p || {});
  1559. this.each(function() {
  1560. var tip = null;
  1561. var tipid = $(this).attr("ligerTipId");
  1562. if (tipid) {
  1563. tip = $("#" + tipid);
  1564. if (p.content == "") tip.remove();
  1565. else $(".l-verify-tip-content", tip).html(p.content);
  1566. }
  1567. else if (p.content) {
  1568. tip = $('<div class="l-verify-tip"><div class="l-verify-tip-corner"></div><div class="l-verify-tip-content">' + p.content + '</div></div>');
  1569. tip.attr("id", "ligerUI" + new Date().getTime());
  1570. tip.fadeTo(0, 0.85); //对象的透明度
  1571. //tip.appendTo('body');
  1572. $(this).after(tip);
  1573. }
  1574. if (!tip) return;
  1575. //方法一:tip.css({ left: $(this).offset().left + $(this).width() + p.distanceX, top: $(this).offset().top + p.distanceY }).show();
  1576. tip.css({ left: $(this).position().left + $(this).width() + p.distanceX, top: $(this).position().top + p.distanceY }).show();
  1577. //方法三:$(this).parent().css('position','relative');
  1578. //方法三:tip.css({ left: $(this).outerWidth(true) + p.distanceX, top: p.distanceY }).show();
  1579. $(this).attr("ligerTipId", tip.attr("id"));
  1580. p.width && $("> .l-verify-tip-content", tip).width(p.width - 8);
  1581. p.height && $("> .l-verify-tip-content", tip).width(p.height);
  1582. p.appendIdTo && p.appendIdTo.attr("ligerTipId", tip.attr("id"));
  1583. p.callback && p.callback(tip);
  1584. });
  1585. if (this.length == 0) return null;
  1586. if (this.length == 1) return this[0].ligerTip;
  1587. var tips = [];
  1588. this.each(function() {
  1589. tips.push(this.ligerTip);
  1590. });
  1591. return tips;
  1592. };
  1593. $.fn.ligerHideTip = function(p) {
  1594. return this.each(function() {
  1595. var tipid = $(this).attr("ligerTipId");
  1596. if (tipid) {
  1597. $("#" + tipid).remove();
  1598. $("[ligerTipId=" + tipid + "]").removeAttr("ligerTipId");
  1599. }
  1600. });
  1601. };
  1602. })(jQuery);
  1603. //ligerTab.js
  1604. (function($)
  1605. {
  1606. /// <param name="$" type="jQuery"></param>
  1607. $.fn.ligerGetTabManager = function()
  1608. {
  1609. return LigerUIManagers[this[0].id + "_Tab"];
  1610. };
  1611. $.ligerDefaults = $.ligerDefaults || {};
  1612. $.ligerDefaults.Tab = {
  1613. height: null,
  1614. heightDiff: 0, // 高度补差
  1615. marginleft: 3,
  1616. changeHeightOnResize: false,
  1617. contextmenu : true,
  1618. closeMessage : "关闭当前页",
  1619. closeOtherMessage : "关闭其他",
  1620. closeAllMessage : "关闭所有",
  1621. reloadMessage : "刷新",
  1622. onBeforeOverrideTabItem:null,
  1623. onAfterOverrideTabItem:null,
  1624. onBeforeRemoveTabItem:null,
  1625. onAfterRemoveTabItem:null,
  1626. onBeforeAddTabItem :null,
  1627. onAfterAddTabItem:null,
  1628. onBeforeSelectTabItem :null,
  1629. onAfterSelectTabItem:null
  1630. };
  1631. $.fn.ligerTab = function(p)
  1632. {
  1633. p = $.extend({},$.ligerDefaults.Tab, p || {});
  1634. this.each(function()
  1635. {
  1636. if (this.usedTab) return;
  1637. if ($(this).hasClass('l-hidden')) { return; }
  1638. var g = {
  1639. //设置tab按钮(左和右),显示返回true,隐藏返回false
  1640. setTabButton: function()
  1641. {
  1642. var sumwidth = 0;
  1643. $("li", g.tab.links.ul).each(function()
  1644. {
  1645. sumwidth += ($(this).width() + p.marginleft);
  1646. });
  1647. var mainwidth = g.tab.width();
  1648. if (sumwidth > mainwidth)
  1649. {
  1650. $(".l-tab-links-left,.l-tab-links-right", g.tab.links).remove();
  1651. g.tab.links.append('<div class="l-tab-links-left"></div><div class="l-tab-links-right"></div>');
  1652. if($(g.tab).attr("toolsid"))
  1653. {
  1654. $(".l-tab-links-right", g.tab.links).css("right","17px");
  1655. }
  1656. g.setTabButtonEven();
  1657. return true;
  1658. } else
  1659. {
  1660. g.tab.links.ul.animate({ left: 0 });
  1661. $(".l-tab-links-left,.l-tab-links-right", g.tab.links).remove();
  1662. return false;
  1663. }
  1664. },
  1665. //设置左右按钮的事件 标签超出最大宽度时,可左右拖动
  1666. setTabButtonEven: function()
  1667. {
  1668. $(".l-tab-links-left", g.tab.links).hover(function()
  1669. {
  1670. $(this).addClass("l-tab-links-left-over");
  1671. }, function()
  1672. {
  1673. $(this).removeClass("l-tab-links-left-over");
  1674. }).click(function()
  1675. {
  1676. g.moveToPrevTabItem();
  1677. });
  1678. $(".l-tab-links-right", g.tab.links).hover(function()
  1679. {
  1680. $(this).addClass("l-tab-links-right-over");
  1681. }, function()
  1682. {
  1683. $(this).removeClass("l-tab-links-right-over");
  1684. }).click(function()
  1685. {
  1686. g.moveToNextTabItem();
  1687. });
  1688. },
  1689. //切换到上一个tab
  1690. moveToPrevTabItem: function()
  1691. {
  1692. var btnWitdth = $(".l-tab-links-left", g.tab.links).width();
  1693. var leftList = new Array(); //记录每个tab的left,由左到右
  1694. $("li", g.tab.links.ul).each(function(i, item)
  1695. {
  1696. var currentItemLeft = -1 * btnWitdth;
  1697. if (i > 0)
  1698. {
  1699. currentItemLeft = parseInt(leftList[i - 1]) + $(this).prev().width() + p.marginleft;
  1700. }
  1701. leftList.push(currentItemLeft);
  1702. });
  1703. var currentLeft = -1 * parseInt(g.tab.links.ul.css("left"));
  1704. for (var i = 0; i < leftList.length - 1; i++)
  1705. {
  1706. if (leftList[i] < currentLeft && leftList[i + 1] >= currentLeft)
  1707. {
  1708. g.tab.links.ul.animate({ left: -1 * parseInt(leftList[i]) });
  1709. return;
  1710. }
  1711. }
  1712. },
  1713. //切换到下一个tab
  1714. moveToNextTabItem: function()
  1715. {
  1716. var btnWitdth = $(".l-tab-links-right", g.tab).width() + $(".l-tab-links-tools", g.tab.links).width();
  1717. var sumwidth = 0;
  1718. var tabItems = $("li", g.tab.links.ul);
  1719. tabItems.each(function()
  1720. {
  1721. sumwidth += $(this).width() + p.marginleft;
  1722. });
  1723. var mainwidth = g.tab.width();
  1724. var leftList = new Array(); //记录每个tab的left,由右到左
  1725. for (var i = tabItems.length - 1; i >= 0; i--)
  1726. {
  1727. var currentItemLeft = sumwidth - mainwidth + btnWitdth + p.marginleft;
  1728. if (i != tabItems.length - 1)
  1729. {
  1730. currentItemLeft = parseInt(leftList[tabItems.length - 2 - i]) - ($(tabItems[i + 1]).width() + p.marginleft);
  1731. }
  1732. leftList.push(currentItemLeft);
  1733. }
  1734. var currentLeft = -1 * parseInt(g.tab.links.ul.css("left"));
  1735. for (var i = 1; i < leftList.length; i++)
  1736. {
  1737. if (leftList[i] <= currentLeft && leftList[i - 1] > currentLeft)
  1738. {
  1739. g.tab.links.ul.animate({ left: -1 * parseInt(leftList[i - 1]) });
  1740. return;
  1741. }
  1742. }
  1743. },
  1744. getTabItemCount : function()
  1745. {
  1746. return $("li", g.tab.links.ul).length;
  1747. },
  1748. getSelectedTabItemID:function()
  1749. {
  1750. return $("li.l-selected", g.tab.links.ul).attr("tabid");
  1751. },
  1752. removeSelectedTabItem:function()
  1753. {
  1754. g.removeTabItem(g.getSelectedTabItemID());
  1755. },
  1756. //覆盖选择的tabitem
  1757. overrideSelectedTabItem : function(options){
  1758. g.overrideTabItem(g.getSelectedTabItemID(),options);
  1759. },
  1760. //覆盖
  1761. overrideTabItem : function(targettabid,options){
  1762. if(p.onBeforeOverrideTabItem && p.onBeforeOverrideTabItem(targettabid)==false) return false;
  1763. var tabid = options.tabid;
  1764. if (tabid == undefined) tabid = g.getNewTabid();
  1765. var url = options.url;
  1766. var content = options.content;
  1767. var target = options.target;
  1768. var text = options.text;
  1769. var showClose = options.showClose;
  1770. var height = options.height;
  1771. //如果已经存在
  1772. if (g.isTabItemExist(tabid))
  1773. {
  1774. return;
  1775. }
  1776. var tabitem = $("li[tabid="+targettabid+"]", g.tab.links.ul);
  1777. var contentitem = $(".l-tab-content-item[tabid="+targettabid+"]",g.tab.content);
  1778. if(!tabitem || !contentitem) return ;
  1779. tabitem.attr("tabid", tabid);
  1780. contentitem.attr("tabid", tabid);
  1781. if($("iframe", contentitem).length==0 && url)
  1782. {
  1783. contentitem.html("<iframe frameborder='0'></iframe>");
  1784. }
  1785. else if(content)
  1786. {
  1787. contentitem.html(content);
  1788. }
  1789. $("iframe", contentitem).attr("name", tabid);
  1790. if (showClose == undefined) showClose = true;
  1791. if (showClose == false) $(".l-tab-links-item-close", tabitem).remove();
  1792. else{
  1793. if($(".l-tab-links-item-close", tabitem).length==0)
  1794. tabitem.append("<div class='l-tab-links-item-close'></div>");
  1795. }
  1796. if (text == undefined) text = tabid;
  1797. if (height) contentitem.height(height);
  1798. $("a", tabitem).text(text);
  1799. $("iframe", contentitem).attr("src", url);
  1800. p.onAfterOverrideTabItem && p.onAfterOverrideTabItem(targettabid);
  1801. },
  1802. //选中tab项
  1803. selectTabItem: function(tabid)
  1804. {
  1805. if(p.onBeforeSelectTabItem && p.onBeforeSelectTabItem(tabid)==false) return false;
  1806. g.selectedTabId = tabid;
  1807. $("> .l-tab-content-item[tabid=" + tabid + "]", g.tab.content).show().siblings().hide();
  1808. $("li[tabid=" + tabid + "]", g.tab.links.ul).addClass("l-selected").siblings().removeClass("l-selected");
  1809. p.onAfterSelectTabItem && p.onAfterSelectTabItem(tabid);
  1810. },
  1811. //移动tab到当前合适的位置
  1812. moveToCurrTabItem: function(tabid)
  1813. {
  1814. var btnWitdth = $(".l-tab-links-left", g.tab.links).width();
  1815. var mainwidth = g.tab.width();
  1816. var selecttableftwidth = 0;
  1817. var selecttabrightwidth = 0;
  1818. $("li", g.tab.links.ul).each(function()
  1819. {
  1820. selecttabrightwidth += $(this).width() + p.marginleft;
  1821. if($(this).attr("tabid") == tabid)
  1822. {
  1823. return false;
  1824. }
  1825. selecttableftwidth += $(this).width() + p.marginleft;
  1826. });
  1827. var tableftnum = parseInt($(g.tab.links.ul).css("left"));
  1828. if(selecttableftwidth < (0 - tableftnum))
  1829. {
  1830. g.tab.links.ul.animate({ left: -1 * (selecttableftwidth - btnWitdth) });
  1831. }
  1832. else if((selecttabrightwidth + tableftnum) > mainwidth)
  1833. {
  1834. btnWitdth += $(".l-tab-links-tools", g.tab.links).width();
  1835. g.tab.links.ul.animate({ left: (-1 * (selecttabrightwidth - mainwidth + btnWitdth + p.marginleft)) });
  1836. }
  1837. },
  1838. //移动到最后一个tab
  1839. moveToLastTabItem: function()
  1840. {
  1841. var sumwidth = 0;
  1842. $("li", g.tab.links.ul).each(function()
  1843. {
  1844. sumwidth += $(this).width() + p.marginleft;
  1845. });
  1846. var mainwidth = g.tab.width();
  1847. if (sumwidth > mainwidth)
  1848. {
  1849. var btnWitdth = $(".l-tab-links-right", g.tab.links).width() + $(".l-tab-links-tools", g.tab.links).width();
  1850. g.tab.links.ul.animate({ left: -1 * (sumwidth - mainwidth + btnWitdth + p.marginleft) });
  1851. }
  1852. },
  1853. //判断tab是否存在
  1854. isTabItemExist: function(tabid)
  1855. {
  1856. return $("li[tabid=" + tabid + "]", g.tab.links.ul).length > 0;
  1857. },
  1858. //增加一个tab
  1859. addTabItem: function(options)
  1860. {
  1861. if(p.onBeforeAddTabItem && p.onBeforeAddTabItem(tabid)==false) return false;
  1862. var tabid = options.tabid;
  1863. if (tabid == undefined) tabid = g.getNewTabid();
  1864. var url = options.url;
  1865. var iconcss = options.iconcss;
  1866. var content = options.content;
  1867. var text = options.text;
  1868. var showClose = options.showClose;
  1869. var height = options.height;
  1870. //如果已经存在
  1871. if (g.isTabItemExist(tabid))
  1872. {
  1873. g.selectTabItem(tabid);
  1874. g.moveToCurrTabItem(tabid);
  1875. g.reload(tabid); //刷新页面
  1876. return;
  1877. }
  1878. var tabitem = $("<li><a></a><div class='l-tab-links-item-left'></div><div class='l-tab-links-item-right'></div><div class='l-tab-links-item-close'></div></li>");
  1879. var contentitem = $("<div class='l-tab-content-item'><iframe frameborder='0'></iframe></div>");
  1880. if (g.makeFullHeight)
  1881. {
  1882. var newheight = g.tab.height() - g.tab.links.height();
  1883. contentitem.height(newheight);
  1884. }
  1885. tabitem.attr("tabid", tabid);
  1886. contentitem.attr("tabid", tabid);
  1887. $("iframe", contentitem).attr("name", tabid);
  1888. if (showClose == undefined) showClose = true;
  1889. if (showClose == false) $(".l-tab-links-item-close", tabitem).remove();
  1890. if (text == undefined) text = tabid;
  1891. if (height) contentitem.height(height);
  1892. $("a", tabitem).text(text);
  1893. if (iconcss) $("a", tabitem).addClass(iconcss);
  1894. $("iframe", contentitem).attr("src", url);
  1895. g.tab.links.ul.append(tabitem);
  1896. g.tab.content.append(contentitem);
  1897. g.selectTabItem(tabid);
  1898. if (g.setTabButton())
  1899. {
  1900. g.moveToLastTabItem();
  1901. }
  1902. //增加事件
  1903. g.addTabItemEvent(tabitem);
  1904. p.onAfterAddTabItem && p.onAfterAddTabItem(tabid);
  1905. },
  1906. addTabItemEvent: function(tabitem)
  1907. {
  1908. tabitem.click(function()
  1909. {
  1910. var tabid = $(this).attr("tabid");
  1911. g.selectTabItem(tabid);
  1912. });
  1913. //右键事件支持
  1914. g.tab.menu && po.addTabItemContextMenuEven(tabitem);
  1915. $(".l-tab-links-item-close", tabitem).hover(function()
  1916. {
  1917. $(this).addClass("l-tab-links-item-close-over");
  1918. }, function()
  1919. {
  1920. $(this).removeClass("l-tab-links-item-close-over");
  1921. }).click(function()
  1922. {
  1923. var tabid = $(this).parent().attr("tabid");
  1924. g.removeTabItem(tabid);
  1925. });
  1926. },
  1927. //移除tab项
  1928. removeTabItem: function(tabid)
  1929. {
  1930. if(p.onBeforeRemoveTabItem && p.onBeforeRemoveTabItem(tabid)==false) return false;
  1931. var currentIsSelected = $("li[tabid=" + tabid + "]", g.tab.links.ul).hasClass("l-selected");
  1932. if (currentIsSelected)
  1933. {
  1934. $(".l-tab-content-item[tabid=" + tabid + "]", g.tab.content).prev().show();
  1935. $("li[tabid=" + tabid + "]", g.tab.links.ul).prev().addClass("l-selected").siblings().removeClass("l-selected");
  1936. }
  1937. $(".l-tab-content-item[tabid=" + tabid + "]", g.tab.content).remove();
  1938. $("li[tabid=" + tabid + "]", g.tab.links.ul).remove();
  1939. g.setTabButton();
  1940. p.onAfterRemoveTabItem && p.onAfterRemoveTabItem(tabid);
  1941. },
  1942. addHeight: function(heightDiff)
  1943. {
  1944. var newHeight = g.tab.height() + heightDiff;
  1945. g.setHeight(newHeight);
  1946. },
  1947. setHeight: function(height)
  1948. {
  1949. g.tab.height(height);
  1950. g.setContentHeight();
  1951. },
  1952. setContentHeight: function()
  1953. {
  1954. var newheight = g.tab.height() - g.tab.links.height();
  1955. g.tab.content.height(newheight);
  1956. $("> .l-tab-content-item", g.tab.content).height(newheight);
  1957. },
  1958. getNewTabid: function()
  1959. {
  1960. var now = new Date();
  1961. return now.getTime();
  1962. },
  1963. //notabid 过滤掉tabid的
  1964. //noclose 过滤掉没有关闭按钮的
  1965. getTabidList : function(notabid,noclose)
  1966. {
  1967. var tabidlist = [];
  1968. $("> li", g.tab.links.ul).each(function(){
  1969. if($(this).attr("tabid")
  1970. && $(this).attr("tabid") != notabid
  1971. && (!noclose || $(".l-tab-links-item-close",this).length > 0))
  1972. {
  1973. tabidlist.push($(this).attr("tabid"));
  1974. }
  1975. });
  1976. return tabidlist;
  1977. },
  1978. removeOther :function(tabid,compel)
  1979. {
  1980. var tabidlist = g.getTabidList(tabid,true);
  1981. $(tabidlist).each(function(){
  1982. g.removeTabItem(this);
  1983. });
  1984. },
  1985. reload :function(tabid)
  1986. {
  1987. $(".l-tab-content-item[tabid=" + tabid + "] iframe", g.tab.content).each(function(i,iframe){
  1988. $(iframe).attr("src",$(iframe).attr("src"));
  1989. });
  1990. },
  1991. removeAll : function(compel)
  1992. {
  1993. var tabidlist = g.getTabidList(null,true);
  1994. $(tabidlist).each(function(){
  1995. g.removeTabItem(this);
  1996. });
  1997. },
  1998. onResize: function()
  1999. {
  2000. if (!p.height || typeof (p.height) != 'string' || p.height.indexOf('%') == -1) return false;
  2001. //set tab height
  2002. if (g.tab.parent()[0].tagName.toLowerCase() == "body")
  2003. {
  2004. var windowHeight = $(window).height();
  2005. windowHeight -= parseInt(g.tab.parent().css('paddingTop'));
  2006. windowHeight -= parseInt(g.tab.parent().css('paddingBottom'));
  2007. g.height = p.heightDiff + windowHeight * parseFloat(g.height) * 0.01;
  2008. }
  2009. else
  2010. {
  2011. g.height = p.heightDiff + (g.tab.parent().height() * parseFloat(p.height) * 0.01);
  2012. }
  2013. g.tab.height(g.height);
  2014. g.setContentHeight();
  2015. }
  2016. };
  2017. var po = {
  2018. menuItemClick:function(item)
  2019. {
  2020. if(!item.id || !g.actionTabid) return;
  2021. switch(item.id)
  2022. {
  2023. case "close":
  2024. g.removeTabItem(g.actionTabid);
  2025. g.actionTabid = null;
  2026. break;
  2027. case "closeother":
  2028. g.removeOther(g.actionTabid);
  2029. break;
  2030. case "closeall":
  2031. g.removeAll();
  2032. g.actionTabid = null;
  2033. break;
  2034. case "reload":
  2035. g.selectTabItem(g.actionTabid);
  2036. g.reload(g.actionTabid);
  2037. break;
  2038. }
  2039. },
  2040. addTabItemContextMenuEven:function(tabitem)
  2041. {
  2042. tabitem.bind("contextmenu",function(e){
  2043. if(!g.tab.menu) return;
  2044. g.actionTabid = tabitem.attr("tabid");
  2045. g.tab.menu.show({ top: e.pageY, left: e.pageX });
  2046. if($(".l-tab-links-item-close",this).length == 0)
  2047. {
  2048. g.tab.menu.setDisable('close');
  2049. }
  2050. else
  2051. {
  2052. g.tab.menu.setEnable('close');
  2053. }
  2054. return false;
  2055. });
  2056. }
  2057. };
  2058. if (p.height) g.makeFullHeight = true;
  2059. g.tab = $(this);
  2060. if (!g.tab.hasClass("l-tab")) g.tab.addClass("l-tab");
  2061. if(p.contextmenu && $.ligerMenu)
  2062. {
  2063. g.tab.menu = $.ligerMenu({width:100,items:[
  2064. {text:p.closeMessage,id:'close',click:po.menuItemClick},
  2065. {text:p.closeOtherMessage,id:'closeother',click:po.menuItemClick},
  2066. {text:p.closeAllMessage,id:'closeall',click:po.menuItemClick},
  2067. {text:p.reloadMessage,id:'reload',click:po.menuItemClick}
  2068. ]});
  2069. }
  2070. g.tab.content = $('<div class="l-tab-content"></div>');
  2071. $("> div", g.tab).appendTo(g.tab.content);
  2072. g.tab.content.appendTo(g.tab);
  2073. g.tab.links = $('<div class="l-tab-links"><ul style="left: 0px; "></ul></div>');
  2074. g.tab.links.prependTo(g.tab);
  2075. //添加工具栏
  2076. if($(g.tab).attr("toolsid"))
  2077. {
  2078. g.tab.links.append('<div id="' + $(g.tab).attr("toolsid") + '" class="l-tab-links-tools"></div>');
  2079. }
  2080. g.tab.links.ul = $("ul", g.tab.links);
  2081. var haslselected = $("> div[lselected=true]", g.tab.content).length > 0;
  2082. g.selectedTabId = $("> div[lselected=true]", g.tab.content).attr("tabid");
  2083. $("> div", g.tab.content).each(function(i, box)
  2084. {
  2085. var li = $('<li class=""><a></a><div class="l-tab-links-item-left"></div><div class="l-tab-links-item-right"></div></li>');
  2086. if ($(box).attr("title"))
  2087. {
  2088. $("> a", li).html($(box).attr("title"));
  2089. }
  2090. if ($(box).attr("iconcss"))
  2091. {
  2092. $("> a", li).addClass($(box).attr("iconcss"));
  2093. }
  2094. var tabid = $(box).attr("tabid");
  2095. if (tabid == undefined)
  2096. {
  2097. tabid = g.getNewTabid();
  2098. $(box).attr("tabid", tabid);
  2099. if ($(box).attr("lselected"))
  2100. {
  2101. g.selectedTabId = tabid;
  2102. }
  2103. }
  2104. li.attr("tabid", tabid);
  2105. if (!haslselected && i == 0) g.selectedTabId = tabid;
  2106. var showClose = $(box).attr("showClose");
  2107. if (showClose)
  2108. {
  2109. li.append("<div class='l-tab-links-item-close'></div>");
  2110. }
  2111. $("> ul", g.tab.links).append(li);
  2112. if (!$(box).hasClass("l-tab-content-item")) $(box).addClass("l-tab-content-item");
  2113. });
  2114. //init
  2115. g.selectTabItem(g.selectedTabId);
  2116. //set content height
  2117. if (p.height)
  2118. {
  2119. if (typeof (p.height) == 'string' && p.height.indexOf('%') > 0)
  2120. {
  2121. g.onResize();
  2122. if (p.changeHeightOnResize)
  2123. {
  2124. $(window).resize(function()
  2125. {
  2126. g.onResize();
  2127. });
  2128. }
  2129. } else
  2130. {
  2131. g.setHeight(p.height);
  2132. }
  2133. }
  2134. if (g.makeFullHeight)
  2135. g.setContentHeight();
  2136. //add even
  2137. $("li", g.tab.links).each(function()
  2138. {
  2139. g.addTabItemEvent($(this));
  2140. });
  2141. if (this.id == undefined) this.id = "LigerUI_" + new Date().getTime();
  2142. LigerUIManagers[this.id + "_Tab"] = g;
  2143. this.usedTab = true;
  2144. });
  2145. if (this.length == 0) return null;
  2146. if (this.length == 1) return LigerUIManagers[this[0].id + "_Tab"];
  2147. var managers = [];
  2148. this.each(function() {
  2149. managers.push(LigerUIManagers[this.id + "_Tab"]);
  2150. });
  2151. return managers;
  2152. };
  2153. })(jQuery);
  2154. //ligerTree.js
  2155. (function ($)
  2156. {
  2157. /// <param name="$" type="jQuery"></param>
  2158. $.fn.ligerGetTreeManager = function ()
  2159. {
  2160. return LigerUIManagers[this[0].id + "_Tree"];
  2161. };
  2162. $.ligerDefaults = $.ligerDefaults || {};
  2163. $.ligerDefaults.Tree = {
  2164. url: null,
  2165. data: null,
  2166. checkbox: true,
  2167. autoCheckboxEven : true,
  2168. parentIcon: 'folder',
  2169. childIcon: 'leaf',
  2170. textFieldName: 'text',
  2171. attribute : ['id','url'],
  2172. treeLine : true, //是否显示line
  2173. nodeWidth: 90,
  2174. statusName : '__status',
  2175. isLeaf : null, //是否子节点的判断函数
  2176. onBeforeExpand : null,
  2177. onContextmenu : null,
  2178. onExpand : null,
  2179. onBeforeCollapse: null,
  2180. onCollapse : null,
  2181. onBeforeSelect :null,
  2182. onSelect :null,
  2183. onBeforeCancelSelect :null,
  2184. onCancelselect :null,
  2185. onCheck :null,
  2186. onSuccess:null,
  2187. onError:null,
  2188. onClick:null,
  2189. idFieldName : null,
  2190. parentIDFieldName:null,
  2191. topParentIDValue : 0
  2192. };
  2193. $.fn.ligerTree = function (p)
  2194. {
  2195. this.each(function ()
  2196. {
  2197. p = $.extend({},$.ligerDefaults.Tree, p || {});
  2198. if (this.usedTree) return;
  2199. if ($(this).hasClass('l-hidden')) { return; }
  2200. //public Object
  2201. var g = {
  2202. getData :function()
  2203. {
  2204. return g.data;
  2205. },
  2206. //是否包含子节点
  2207. hasChildren: function (treenodedata)
  2208. {
  2209. if(p.isLeaf) return p.isLeaf(treenodedata);
  2210. return treenodedata.children ? true: false;
  2211. },
  2212. //获取父节点
  2213. getParentTreeItem: function (treenode, level)
  2214. {
  2215. var treeitem = $(treenode);
  2216. if (treeitem.parent().hasClass("l-tree"))
  2217. return null;
  2218. if (level == undefined)
  2219. {
  2220. if (treeitem.parent().parent("li").length == 0)
  2221. return null;
  2222. return treeitem.parent().parent("li")[0];
  2223. }
  2224. var currentLevel = parseInt(treeitem.attr("outlinelevel"));
  2225. var currenttreeitem = treeitem;
  2226. for (var i = currentLevel - 1; i >= level; i--)
  2227. {
  2228. currenttreeitem = currenttreeitem.parent().parent("li");
  2229. }
  2230. return currenttreeitem[0];
  2231. },
  2232. getChecked: function ()
  2233. {
  2234. if (!p.checkbox) return null;
  2235. var nodes = [];
  2236. $(".l-checkbox-checked", g.tree).parent().parent("li").each(function ()
  2237. {
  2238. var treedataindex = parseInt($(this).attr("treedataindex"));
  2239. nodes.push({ target: this,data:po.getDataNodeByTreeDataIndex(g.data,treedataindex) });
  2240. });
  2241. return nodes;
  2242. },
  2243. getSelected: function ()
  2244. {
  2245. var node = {};
  2246. node.target = $(".l-selected", g.tree).parent("li")[0];
  2247. if (node.target)
  2248. {
  2249. var treedataindex = parseInt($(node.target).attr("treedataindex"));
  2250. node.data = po.getDataNodeByTreeDataIndex(g.data,treedataindex);
  2251. return node;
  2252. }
  2253. return null;
  2254. },
  2255. //升级为父节点级别
  2256. upgrade: function (treeNode)
  2257. {
  2258. $(".l-note", treeNode).each(function ()
  2259. {
  2260. $(this).removeClass("l-note").addClass("l-expandable-open");
  2261. });
  2262. $(".l-note-last", treeNode).each(function ()
  2263. {
  2264. $(this).removeClass("l-note-last").addClass("l-expandable-open");
  2265. });
  2266. $("." + po.getChildNodeClassName(), treeNode).each(function ()
  2267. {
  2268. $(this)
  2269. .removeClass(po.getChildNodeClassName())
  2270. .addClass(po.getParentNodeClassName(true));
  2271. });
  2272. },
  2273. //降级为叶节点级别
  2274. demotion: function (treeNode)
  2275. {
  2276. if (!treeNode && treeNode[0].tagName.toLowerCase() != 'li') return;
  2277. var islast = $(treeNode).hasClass("l-last");
  2278. $(".l-expandable-open", treeNode).each(function ()
  2279. {
  2280. $(this).removeClass("l-expandable-open")
  2281. .addClass(islast ? "l-note-last" : "l-note");
  2282. });
  2283. $(".l-expandable-close", treeNode).each(function ()
  2284. {
  2285. $(this).removeClass("l-expandable-close")
  2286. .addClass(islast ? "l-note-last" : "l-note");
  2287. });
  2288. $("." + po.getParentNodeClassName(true), treeNode).each(function ()
  2289. {
  2290. $(this)
  2291. .removeClass(po.getParentNodeClassName(true))
  2292. .addClass(po.getChildNodeClassName());
  2293. });
  2294. },
  2295. collapseAll: function ()
  2296. {
  2297. $(".l-expandable-open", g.tree).click();
  2298. },
  2299. expandAll: function ()
  2300. {
  2301. $(".l-expandable-close", g.tree).click();
  2302. },
  2303. loadData: function (node, url,param)
  2304. {
  2305. g.loading.show();
  2306. param = param || {};
  2307. //请求服务器
  2308. $.ajax({
  2309. type: 'post',
  2310. url: url,
  2311. data: param,
  2312. dataType: 'json',
  2313. success: function (data)
  2314. {
  2315. g.loading.hide();
  2316. g.append(node, data);
  2317. if (p.onSuccess) p.onSuccess(data);
  2318. },
  2319. error: function (XMLHttpRequest, textStatus, errorThrown)
  2320. {
  2321. try
  2322. {
  2323. g.loading.hide();
  2324. if (p.onError)
  2325. p.onError(XMLHttpRequest, textStatus, errorThrown);
  2326. }
  2327. catch (e)
  2328. {
  2329. }
  2330. }
  2331. });
  2332. },
  2333. //清空
  2334. clear: function ()
  2335. {
  2336. //g.tree.html("");
  2337. $("> li",g.tree).each(function(){ g.remove(this);});
  2338. },
  2339. remove: function (treeNode)
  2340. {
  2341. var treedataindex = parseInt($(treeNode).attr("treedataindex"));
  2342. var treenodedata = po.getDataNodeByTreeDataIndex(g.data,treedataindex);
  2343. if(treenodedata) po.setTreeDataStatus([treenodedata],'delete');
  2344. var parentNode = g.getParentTreeItem(treeNode);
  2345. //复选框处理
  2346. if (p.checkbox)
  2347. {
  2348. $(".l-checkbox", treeNode).remove();
  2349. po.setParentCheckboxStatus($(treeNode));
  2350. }
  2351. $(treeNode).remove();
  2352. if (parentNode == null) //代表顶级节点
  2353. {
  2354. parentNode = g.tree.parent();
  2355. }
  2356. //set parent
  2357. var treeitemlength = $("> ul > li", parentNode).length;
  2358. if (treeitemlength > 0)
  2359. {
  2360. //遍历设置子节点
  2361. $("> ul > li", parentNode).each(function (i, item)
  2362. {
  2363. if (i == 0 && !$(this).hasClass("l-first"))
  2364. $(this).addClass("l-first");
  2365. if (i == treeitemlength - 1 && !$(this).hasClass("l-last"))
  2366. $(this).addClass("l-last");
  2367. if (i == 0 && i == treeitemlength - 1 && !$(this).hasClass("l-onlychild"))
  2368. $(this).addClass("l-onlychild");
  2369. $("> div .l-note,> div .l-note-last", this)
  2370. .removeClass("l-note l-note-last")
  2371. .addClass(i == treeitemlength - 1 ? "l-note-last" : "l-note");
  2372. po.setTreeItem(this, { isLast: i == treeitemlength - 1 });
  2373. });
  2374. }
  2375. },
  2376. //增加节点集合
  2377. append: function (parentNode, newdata)
  2378. {
  2379. if (!newdata || !newdata.length) return false;
  2380. if(p.idFieldName && p.parentIDFieldName)
  2381. newdata = po.convertData(newdata);
  2382. po.addTreeDataIndexToData(newdata);
  2383. po.setTreeDataStatus(newdata,'add');
  2384. po.appendData(parentNode,newdata);
  2385. if (!parentNode)//增加到根节点
  2386. {
  2387. //remove last node class
  2388. if ($("> li:last", g.tree).length > 0)
  2389. po.setTreeItem($("> li:last", g.tree)[0], { isLast: false });
  2390. var gridhtmlarr = po.getTreeHTMLByData(newdata,1,[],true);
  2391. gridhtmlarr[gridhtmlarr.length-1] = gridhtmlarr[0] = "";
  2392. g.tree.append(gridhtmlarr.join(''));
  2393. $(".l-body", g.tree).hover(function ()
  2394. {
  2395. $(this).addClass("l-over");
  2396. }, function ()
  2397. {
  2398. $(this).removeClass("l-over");
  2399. });
  2400. po.upadteTreeWidth();
  2401. return;
  2402. }
  2403. var treeitem = $(parentNode);
  2404. var outlineLevel = parseInt(treeitem.attr("outlinelevel"));
  2405. var hasChildren = $("> ul", treeitem).length > 0;
  2406. if (!hasChildren)
  2407. {
  2408. treeitem.append("<ul class='l-children'></ul>");
  2409. //设置为父节点
  2410. g.upgrade(parentNode);
  2411. }
  2412. //remove last node class
  2413. if ($("> .l-children > li:last", treeitem).length > 0)
  2414. po.setTreeItem($("> .l-children > li:last", treeitem)[0], { isLast: false });
  2415. var isLast = [];
  2416. for (var i = 1; i <= outlineLevel - 1; i++)
  2417. {
  2418. var currentParentTreeItem = $(g.getParentTreeItem(parentNode, i));
  2419. isLast.push(currentParentTreeItem.hasClass("l-last"));
  2420. }
  2421. isLast.push(treeitem.hasClass("l-last"));
  2422. var gridhtmlarr = po.getTreeHTMLByData(newdata,outlineLevel+1,isLast,true);
  2423. gridhtmlarr[gridhtmlarr.length-1] = gridhtmlarr[0] = "";
  2424. $(">.l-children",parentNode).append(gridhtmlarr.join(''));
  2425. po.upadteTreeWidth();
  2426. $(">.l-children .l-body", parentNode).hover(function ()
  2427. {
  2428. $(this).addClass("l-over");
  2429. }, function ()
  2430. {
  2431. $(this).removeClass("l-over");
  2432. });
  2433. }
  2434. };
  2435. //private Object
  2436. var po = {
  2437. //根据数据索引获取数据
  2438. getDataNodeByTreeDataIndex:function(data,treedataindex)
  2439. {
  2440. for(var i =0;i<data.length;i++)
  2441. {
  2442. if(data[i].treedataindex == treedataindex)
  2443. return data[i];
  2444. if(data[i].children)
  2445. {
  2446. var targetData= po.getDataNodeByTreeDataIndex(data[i].children,treedataindex);
  2447. if(targetData) return targetData;
  2448. }
  2449. }
  2450. return null;
  2451. },
  2452. //设置数据状态
  2453. setTreeDataStatus : function(data,status)
  2454. {
  2455. $(data).each(function ()
  2456. {
  2457. this[p.statusName] = status;
  2458. if(this.children)
  2459. {
  2460. po.setTreeDataStatus(this.children,status);
  2461. }
  2462. });
  2463. },
  2464. //设置data 索引
  2465. addTreeDataIndexToData : function(data)
  2466. {
  2467. $(data).each(function ()
  2468. {
  2469. if(this.treedataindex != undefined) return;
  2470. this.treedataindex = g.treedataindex++;
  2471. if(this.children)
  2472. {
  2473. po.addTreeDataIndexToData(this.children);
  2474. }
  2475. });
  2476. },
  2477. //添加项到g.data
  2478. appendData: function (treeNode,data)
  2479. {
  2480. var treedataindex = parseInt($(treeNode).attr("treedataindex"));
  2481. var treenodedata = po.getDataNodeByTreeDataIndex(g.data,treedataindex);
  2482. if(g.treedataindex == undefined) g.treedataindex = 0;
  2483. if(treenodedata && treenodedata.children == undefined) treenodedata.children =[];
  2484. $(data).each(function (i,item)
  2485. {
  2486. if(treenodedata)
  2487. treenodedata.children[treenodedata.children.length] = $.extend({},item);
  2488. else
  2489. g.data[g.data.length] = $.extend({},item);
  2490. });
  2491. },
  2492. setTreeItem: function (treeNode, options)
  2493. {
  2494. if (!options) return;
  2495. var treeItem = $(treeNode);
  2496. var outlineLevel = parseInt(treeItem.attr("outlinelevel"));
  2497. if (options.isLast != undefined)
  2498. {
  2499. if (options.isLast == true)
  2500. {
  2501. treeItem.removeClass("l-last").addClass("l-last");
  2502. $("> div .l-note", treeItem).removeClass("l-note").addClass("l-note-last");
  2503. $(".l-children li", treeItem)
  2504. .find(".l-box:eq(" + (outlineLevel - 1) + ")")
  2505. .removeClass("l-line");
  2506. }
  2507. else if (options.isLast == false)
  2508. {
  2509. treeItem.removeClass("l-last");
  2510. $("> div .l-note-last", treeItem).removeClass("l-note-last").addClass("l-note");
  2511. $(".l-children li", treeItem)
  2512. .find(".l-box:eq(" + (outlineLevel - 1) + ")")
  2513. .removeClass("l-line")
  2514. .addClass("l-line");
  2515. }
  2516. }
  2517. },
  2518. upadteTreeWidth: function ()
  2519. {
  2520. var treeWidth = g.maxOutlineLevel * 22;
  2521. if (p.checkbox) treeWidth += 22;
  2522. if (p.parentIcon || p.childIcon) treeWidth += 22;
  2523. treeWidth += p.nodeWidth;
  2524. g.tree.width(treeWidth);
  2525. },
  2526. getChildNodeClassName: function ()
  2527. {
  2528. return 'l-tree-icon-' + p.childIcon;
  2529. },
  2530. getParentNodeClassName: function (isOpen)
  2531. {
  2532. var nodeclassname = 'l-tree-icon-' + p.parentIcon;
  2533. if (isOpen) nodeclassname += '-open';
  2534. return nodeclassname;
  2535. },
  2536. //根据data生成最终完整的tree html
  2537. getTreeHTMLByData:function(data,outlineLevel ,isLast,isExpand)
  2538. {
  2539. if (g.maxOutlineLevel < outlineLevel)
  2540. g.maxOutlineLevel = outlineLevel;
  2541. isLast = isLast || [];
  2542. outlineLevel = outlineLevel || 1;
  2543. var treehtmlarr = [];
  2544. if(!isExpand) treehtmlarr.push('<ul class="l-children" style="display:none">');
  2545. else treehtmlarr.push("<ul class='l-children'>");
  2546. for (var i = 0; i < data.length; i++)
  2547. {
  2548. var isFirst = i==0;
  2549. var isLastCurrent = i==data.length-1;
  2550. var isExpandCurrent = true;
  2551. if(data[i].isexpand==false || data[i].isexpand == "false") isExpandCurrent = false;
  2552. treehtmlarr.push('<li ');
  2553. if(data[i].treedataindex!=undefined)
  2554. treehtmlarr.push('treedataindex="'+data[i].treedataindex+'" ');
  2555. if(isExpandCurrent)
  2556. treehtmlarr.push('isexpand='+data[i].isexpand +' ');
  2557. treehtmlarr.push('outlinelevel='+outlineLevel +' ');
  2558. //增加属性支持
  2559. for(var j=0;j<g.sysAttribute.length;j++)
  2560. {
  2561. if($(this).attr(g.sysAttribute[j]))
  2562. data[dataindex][g.sysAttribute[j]] = $(this).attr(g.sysAttribute[j]);
  2563. }
  2564. for(var j=0;j<p.attribute.length;j++)
  2565. {
  2566. if(data[i][p.attribute[j]])
  2567. treehtmlarr.push(p.attribute[j] + '="'+data[i][p.attribute[j]]+'" ');
  2568. }
  2569. //css class
  2570. treehtmlarr.push('class="');
  2571. isFirst && treehtmlarr.push('l-first ');
  2572. isLastCurrent && treehtmlarr.push('l-last ');
  2573. isFirst && isLastCurrent && treehtmlarr.push('l-onlychild ');
  2574. treehtmlarr.push('"');
  2575. treehtmlarr.push('>');
  2576. treehtmlarr.push('<div class="l-body">');
  2577. for (var k = 0; k <= outlineLevel - 2; k++)
  2578. {
  2579. if(isLast[k]) treehtmlarr.push('<div class="l-box"></div>');
  2580. else treehtmlarr.push('<div class="l-box l-line"></div>');
  2581. }
  2582. if (g.hasChildren(data[i]))
  2583. {
  2584. if(isExpandCurrent) treehtmlarr.push('<div class="l-box l-expandable-open"></div>');
  2585. else treehtmlarr.push('<div class="l-box l-expandable-close"></div>');
  2586. if(p.checkbox)
  2587. {
  2588. if(data[i].ischecked)
  2589. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-checked"></div>');
  2590. else
  2591. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-unchecked"></div>');
  2592. }
  2593. p.parentIcon && !isExpandCurrent && treehtmlarr.push('<div class="l-box ' + po.getParentNodeClassName() + '"></div>');
  2594. p.parentIcon && isExpandCurrent && treehtmlarr.push('<div class="l-box ' + po.getParentNodeClassName(true) + '"></div>');
  2595. }
  2596. else
  2597. {
  2598. if(isLastCurrent) treehtmlarr.push('<div class="l-box l-note-last"></div>');
  2599. else treehtmlarr.push('<div class="l-box l-note"></div>');
  2600. if(p.checkbox)
  2601. {
  2602. if(data[i].ischecked)
  2603. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-checked"></div>');
  2604. else
  2605. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-unchecked"></div>');
  2606. }
  2607. p.childIcon && treehtmlarr.push('<div class="l-box ' + po.getChildNodeClassName() + '"></div>');
  2608. }
  2609. treehtmlarr.push('<span>' + data[i][p.textFieldName] + '</span></div>');
  2610. if (g.hasChildren(data[i]))
  2611. {
  2612. var isLastNew = [];
  2613. for(var k=0;k<isLast.length;k++)
  2614. {
  2615. isLastNew.push(isLast[k]);
  2616. }
  2617. isLastNew.push(isLastCurrent);
  2618. treehtmlarr.push(po.getTreeHTMLByData(data[i].children,outlineLevel+1,isLastNew,isExpandCurrent).join(''));
  2619. }
  2620. treehtmlarr.push('</li>');
  2621. }
  2622. treehtmlarr.push("</ul>");
  2623. return treehtmlarr;
  2624. },
  2625. //根据简洁的html获取data
  2626. getDataByTreeHTML : function(treeDom)
  2627. {
  2628. var data = [];
  2629. $("> li", treeDom).each(function (i, item)
  2630. {
  2631. var dataindex = data.length;
  2632. data[dataindex] =
  2633. {
  2634. treedataindex:g.treedataindex++
  2635. };
  2636. data[dataindex][p.textFieldName] = $("> span,> a",this).html();
  2637. for(var j=0;j<g.sysAttribute.length;j++)
  2638. {
  2639. if($(this).attr(g.sysAttribute[j]))
  2640. data[dataindex][g.sysAttribute[j]] = $(this).attr(g.sysAttribute[j]);
  2641. }
  2642. for(var j=0;j<p.attribute.length;j++)
  2643. {
  2644. if($(this).attr(p.attribute[j]))
  2645. data[dataindex][p.attribute[j]] = $(this).attr(p.attribute[j]);
  2646. }
  2647. if($("> ul",this).length>0)
  2648. {
  2649. data[dataindex].children = po.getDataByTreeHTML($("> ul",this));
  2650. }
  2651. });
  2652. return data;
  2653. },
  2654. applyTree: function ()
  2655. {
  2656. g.data = po.getDataByTreeHTML(g.tree);
  2657. var gridhtmlarr = po.getTreeHTMLByData(g.data,1,[],true);
  2658. gridhtmlarr[gridhtmlarr.length-1] = gridhtmlarr[0] = "";
  2659. g.tree.html(gridhtmlarr.join(''));
  2660. po.upadteTreeWidth();
  2661. $(".l-body", g.tree).hover(function ()
  2662. {
  2663. $(this).addClass("l-over");
  2664. }, function ()
  2665. {
  2666. $(this).removeClass("l-over");
  2667. });
  2668. },
  2669. applyTreeEven: function (treeNode)
  2670. {
  2671. $("> .l-body", treeNode).hover(function ()
  2672. {
  2673. $(this).addClass("l-over");
  2674. }, function ()
  2675. {
  2676. $(this).removeClass("l-over");
  2677. });
  2678. },
  2679. setTreeEven : function()
  2680. {
  2681. p.onContextmenu && g.tree.bind("contextmenu",function(e){
  2682. var obj = (e.target || e.srcElement);
  2683. var treeitem = null;
  2684. if(obj.tagName.toLowerCase() == "a" || obj.tagName.toLowerCase()=="span" || $(obj).hasClass("l-box"))
  2685. treeitem = $(obj).parent().parent();
  2686. else if($(obj).hasClass("l-body"))
  2687. treeitem = $(obj).parent();
  2688. else if(obj.tagName.toLowerCase() == "li")
  2689. treeitem = $(obj);
  2690. if(!treeitem) return;
  2691. var treedataindex = parseInt(treeitem.attr("treedataindex"));
  2692. var treenodedata = po.getDataNodeByTreeDataIndex(g.data,treedataindex);
  2693. return p.onContextmenu({data:treenodedata,target:treeitem[0]},e);
  2694. });
  2695. g.tree.click(function (e)
  2696. {
  2697. var obj = (e.target || e.srcElement);
  2698. var treeitem = null;
  2699. if(obj.tagName.toLowerCase() == "a" || obj.tagName.toLowerCase()=="span" || $(obj).hasClass("l-box"))
  2700. treeitem = $(obj).parent().parent();
  2701. else if($(obj).hasClass("l-body"))
  2702. treeitem = $(obj).parent();
  2703. else
  2704. treeitem = $(obj);
  2705. if(!treeitem) return;
  2706. var treedataindex = parseInt(treeitem.attr("treedataindex"));
  2707. var treenodedata = po.getDataNodeByTreeDataIndex(g.data,treedataindex); var treeitembtn = $(".l-body:first .l-expandable-open:first,.l-body:first .l-expandable-close:first",treeitem);
  2708. if(!$(obj).hasClass("l-checkbox"))
  2709. {
  2710. if ($(">div:first",treeitem).hasClass("l-selected"))
  2711. {
  2712. if(p.onBeforeCancelSelect
  2713. && p.onBeforeCancelSelect({data:treenodedata,target:treeitem[0]}) == false)
  2714. return false;
  2715. $(">div:first",treeitem).removeClass("l-selected");
  2716. p.onCancelSelect && p.onCancelSelect({data:treenodedata,target:treeitem[0]});
  2717. }
  2718. else
  2719. {
  2720. if(p.onBeforeSelect
  2721. && p.onBeforeSelect({data:treenodedata,target:treeitem[0]}) == false)
  2722. return false;
  2723. $(".l-body", g.tree).removeClass("l-selected");
  2724. $(">div:first",treeitem).addClass("l-selected");
  2725. p.onSelect && p.onSelect({data:treenodedata,target:treeitem[0]});
  2726. }
  2727. }
  2728. //chekcbox even
  2729. if ($(obj).hasClass("l-checkbox"))
  2730. {
  2731. if(p.autoCheckboxEven)
  2732. {
  2733. //状态:未选中
  2734. if ($(obj).hasClass("l-checkbox-unchecked"))
  2735. {
  2736. $(obj).removeClass("l-checkbox-unchecked").addClass("l-checkbox-checked");
  2737. $(".l-children .l-checkbox", treeitem)
  2738. .removeClass("l-checkbox-incomplete l-checkbox-unchecked")
  2739. .addClass("l-checkbox-checked");
  2740. p.onCheck && p.onCheck({data:treenodedata,target:treeitem[0]},true);
  2741. }
  2742. //状态:选中
  2743. else if ($(obj).hasClass("l-checkbox-checked"))
  2744. {
  2745. $(obj).removeClass("l-checkbox-checked").addClass("l-checkbox-unchecked");
  2746. $(".l-children .l-checkbox", treeitem)
  2747. .removeClass("l-checkbox-incomplete l-checkbox-checked")
  2748. .addClass("l-checkbox-unchecked");
  2749. p.onCheck && p.onCheck({data:treenodedata,target:treeitem[0]},false);
  2750. }
  2751. //状态:未完全选中
  2752. else if ($(obj).hasClass("l-checkbox-incomplete"))
  2753. {
  2754. $(obj).removeClass("l-checkbox-incomplete").addClass("l-checkbox-checked");
  2755. $(".l-children .l-checkbox", treeitem)
  2756. .removeClass("l-checkbox-incomplete l-checkbox-unchecked")
  2757. .addClass("l-checkbox-checked");
  2758. p.onCheck && p.onCheck({data:treenodedata,target:treeitem[0]},true);
  2759. }
  2760. po.setParentCheckboxStatus(treeitem);
  2761. }
  2762. }
  2763. //状态:已经张开
  2764. else if (treeitembtn.hasClass("l-expandable-open"))
  2765. {
  2766. if(p.onBeforeCollapse
  2767. && p.onBeforeCollapse({data:treenodedata,target:treeitem[0]}) == false)
  2768. return false;
  2769. treeitembtn
  2770. .removeClass("l-expandable-open")
  2771. .addClass("l-expandable-close");
  2772. $("> .l-children", treeitem).slideToggle('fast');
  2773. $("> div ." + po.getParentNodeClassName(true), treeitem)
  2774. .removeClass(po.getParentNodeClassName(true))
  2775. .addClass(po.getParentNodeClassName());
  2776. p.onCollapse && p.onCollapse({data:treenodedata,target:treeitem[0]});
  2777. }
  2778. //状态:没有张开
  2779. else if (treeitembtn.hasClass("l-expandable-close"))
  2780. {
  2781. if(p.onBeforeExpand
  2782. && p.onBeforeExpand({data:treenodedata,target:treeitem[0]}) == false)
  2783. return false;
  2784. treeitembtn
  2785. .removeClass("l-expandable-close")
  2786. .addClass("l-expandable-open");
  2787. $("> .l-children", treeitem).slideToggle('fast',function(){
  2788. p.onExpand && p.onExpand({data:treenodedata,target:treeitem[0]});
  2789. });
  2790. $("> div ." + po.getParentNodeClassName(), treeitem)
  2791. .removeClass(po.getParentNodeClassName())
  2792. .addClass(po.getParentNodeClassName(true));
  2793. }
  2794. p.onClick && p.onClick({data:treenodedata,target:treeitem[0]});
  2795. });
  2796. },
  2797. //递归设置父节点的状态
  2798. setParentCheckboxStatus: function (treeitem)
  2799. {
  2800. //当前同级别或低级别的节点是否都选中了
  2801. var isCheckedComplete = $(".l-checkbox-unchecked", treeitem.parent()).length == 0;
  2802. //当前同级别或低级别的节点是否都没有选中
  2803. var isCheckedNull = $(".l-checkbox-checked", treeitem.parent()).length == 0;
  2804. if (isCheckedComplete)
  2805. {
  2806. treeitem.parent().prev().find(".l-checkbox")
  2807. .removeClass("l-checkbox-unchecked l-checkbox-incomplete")
  2808. .addClass("l-checkbox-checked");
  2809. }
  2810. else if (isCheckedNull)
  2811. {
  2812. treeitem.parent().prev().find("> .l-checkbox")
  2813. .removeClass("l-checkbox-checked l-checkbox-incomplete")
  2814. .addClass("l-checkbox-unchecked");
  2815. }
  2816. else
  2817. {
  2818. treeitem.parent().prev().find("> .l-checkbox")
  2819. .removeClass("l-checkbox-unchecked l-checkbox-checked")
  2820. .addClass("l-checkbox-incomplete");
  2821. }
  2822. if (treeitem.parent().parent("li").length > 0)
  2823. po.setParentCheckboxStatus(treeitem.parent().parent("li"));
  2824. },
  2825. convertData:function(data) //将ID、ParentID这种数据格式转换为树格式
  2826. {
  2827. if(!data || !data.length) return [];
  2828. var isolate = function(pid)//根据ParentID判断是否孤立
  2829. {
  2830. if(pid == p.topParentIDValue) return false;
  2831. for(var i=0;i<data.length;i++)
  2832. {
  2833. if(data[i][p.idFieldName] == pid) return false;
  2834. }
  2835. return true;
  2836. };
  2837. //计算孤立节点的个数
  2838. var isolateLength =0;
  2839. for(var i=0;i<data.length;i++)
  2840. {
  2841. if(isolate(data[i][p.parentIDFieldName])) isolateLength++;
  2842. }
  2843. var targetData = []; //存储数据的容器(返回)
  2844. var itemLength = data.length; //数据集合的个数
  2845. var insertedLength = 0; //已插入的数据个数
  2846. var currentIndex = 0; //当前数据索引
  2847. var getItem = function(container,id) //获取数据项(为空时表示没有插入)
  2848. {
  2849. if(!container.length) return null;
  2850. for(var i=0;i<container.length;i++)
  2851. {
  2852. if(container[i][p.idFieldName] == id) return container[i];
  2853. if(container[i].children)
  2854. {
  2855. var finditem = getItem(container[i].children,id);
  2856. if(finditem) return finditem;
  2857. }
  2858. }
  2859. return null;
  2860. };
  2861. var addItem = function(container,item) //插入数据项
  2862. {
  2863. container.push($.extend({},item));
  2864. insertedLength++;
  2865. };
  2866. //判断已经插入的节点和孤立节点 的个数总和是否已经满足条件
  2867. while(insertedLength + isolateLength <itemLength)
  2868. {
  2869. var item = data[currentIndex];
  2870. var id = item[p.idFieldName];
  2871. var pid = item[p.parentIDFieldName];
  2872. if(pid == p.topParentIDValue)//根节点
  2873. {
  2874. getItem(targetData,id) == null && addItem(targetData,item);
  2875. }
  2876. else
  2877. {
  2878. var pitem = getItem(targetData,pid);
  2879. if(pitem && getItem(targetData,id) == null)//找到父节点数据并且还没插入
  2880. {
  2881. pitem.children = pitem.children || [];
  2882. addItem(pitem.children,item);
  2883. }
  2884. }
  2885. currentIndex = (currentIndex+1)%itemLength;
  2886. }
  2887. return targetData;
  2888. }
  2889. };
  2890. if (!$(this).hasClass('l-tree')) $(this).addClass('l-tree');
  2891. g.tree = $(this);
  2892. if(!p.treeLine) g.tree.addClass("l-tree-noline");
  2893. g.sysAttribute = ['isexpand','ischecked','href','style'];
  2894. g.loading = $("<div class='l-tree-loading'></div>");
  2895. g.tree.after(g.loading);
  2896. g.data = [];
  2897. g.maxOutlineLevel = 1;
  2898. g.treedataindex = 0;
  2899. po.applyTree();
  2900. po.setTreeEven();
  2901. if (p.data)
  2902. {
  2903. g.append(null, p.data);
  2904. }
  2905. if (p.url)
  2906. {
  2907. g.loadData(null, p.url);
  2908. }
  2909. if (this.id == undefined || this.id == "") this.id = "LigerUI_" + new Date().getTime();
  2910. LigerUIManagers[this.id + "_Tree"] = g;
  2911. this.usedTree = true;
  2912. });
  2913. if (this.length == 0) return null;
  2914. if (this.length == 1) return LigerUIManagers[this[0].id + "_Tree"];
  2915. var managers = [];
  2916. this.each(function() {
  2917. managers.push(LigerUIManagers[this.id + "_Tree"]);
  2918. });
  2919. return managers;
  2920. };
  2921. })(jQuery);