旭捷内部项目管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

556 lines
15 KiB

10 months ago
  1. /**
  2. * jQuery EasyUI 1.5.1
  3. *
  4. * Copyright (c) 2009-2016 www.jeasyui.com. All rights reserved.
  5. *
  6. * Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
  7. * To use it on other terms please contact us: info@jeasyui.com
  8. *
  9. */
  10. (function($){
  11. var _1=0;
  12. function _2(_3){
  13. $(_3).addClass("textbox-f").hide();
  14. var _4=$("<span class=\"textbox\">"+"<input class=\"textbox-text\" autocomplete=\"off\">"+"<input type=\"hidden\" class=\"textbox-value\">"+"</span>").insertAfter(_3);
  15. var _5=$(_3).attr("name");
  16. if(_5){
  17. _4.find("input.textbox-value").attr("name",_5);
  18. $(_3).removeAttr("name").attr("textboxName",_5);
  19. }
  20. return _4;
  21. };
  22. function _6(_7){
  23. var _8=$.data(_7,"textbox");
  24. var _9=_8.options;
  25. var tb=_8.textbox;
  26. var _a="_easyui_textbox_input"+(++_1);
  27. tb.addClass(_9.cls);
  28. tb.find(".textbox-text").remove();
  29. if(_9.multiline){
  30. $("<textarea id=\""+_a+"\" class=\"textbox-text\" autocomplete=\"off\"></textarea>").prependTo(tb);
  31. }else{
  32. $("<input id=\""+_a+"\" type=\""+_9.type+"\" class=\"textbox-text\" autocomplete=\"off\">").prependTo(tb);
  33. }
  34. $("#"+_a).attr("tabindex",$(_7).attr("tabindex")||"").css("text-align",_7.style.textAlign||"");
  35. tb.find(".textbox-addon").remove();
  36. var bb=_9.icons?$.extend(true,[],_9.icons):[];
  37. if(_9.iconCls){
  38. bb.push({iconCls:_9.iconCls,disabled:true});
  39. }
  40. if(bb.length){
  41. var bc=$("<span class=\"textbox-addon\"></span>").prependTo(tb);
  42. bc.addClass("textbox-addon-"+_9.iconAlign);
  43. for(var i=0;i<bb.length;i++){
  44. bc.append("<a href=\"javascript:;\" class=\"textbox-icon "+bb[i].iconCls+"\" icon-index=\""+i+"\" tabindex=\"-1\"></a>");
  45. }
  46. }
  47. tb.find(".textbox-button").remove();
  48. if(_9.buttonText||_9.buttonIcon){
  49. var _b=$("<a href=\"javascript:;\" class=\"textbox-button\"></a>").prependTo(tb);
  50. _b.addClass("textbox-button-"+_9.buttonAlign).linkbutton({text:_9.buttonText,iconCls:_9.buttonIcon,onClick:function(){
  51. var t=$(this).parent().prev();
  52. t.textbox("options").onClickButton.call(t[0]);
  53. }});
  54. }
  55. if(_9.label){
  56. if(typeof _9.label=="object"){
  57. _8.label=$(_9.label);
  58. _8.label.attr("for",_a);
  59. }else{
  60. $(_8.label).remove();
  61. _8.label=$("<label class=\"textbox-label\"></label>").html(_9.label);
  62. _8.label.css("textAlign",_9.labelAlign).attr("for",_a);
  63. if(_9.labelPosition=="after"){
  64. _8.label.insertAfter(tb);
  65. }else{
  66. _8.label.insertBefore(_7);
  67. }
  68. _8.label.removeClass("textbox-label-left textbox-label-right textbox-label-top");
  69. _8.label.addClass("textbox-label-"+_9.labelPosition);
  70. }
  71. }else{
  72. $(_8.label).remove();
  73. }
  74. _c(_7);
  75. _d(_7,_9.disabled);
  76. _e(_7,_9.readonly);
  77. };
  78. function _f(_10){
  79. var tb=$.data(_10,"textbox").textbox;
  80. tb.find(".textbox-text").validatebox("destroy");
  81. tb.remove();
  82. $(_10).remove();
  83. };
  84. function _11(_12,_13){
  85. var _14=$.data(_12,"textbox");
  86. var _15=_14.options;
  87. var tb=_14.textbox;
  88. var _16=tb.parent();
  89. if(_13){
  90. if(typeof _13=="object"){
  91. $.extend(_15,_13);
  92. }else{
  93. _15.width=_13;
  94. }
  95. }
  96. if(isNaN(parseInt(_15.width))){
  97. var c=$(_12).clone();
  98. c.css("visibility","hidden");
  99. c.insertAfter(_12);
  100. _15.width=c.outerWidth();
  101. c.remove();
  102. }
  103. var _17=tb.is(":visible");
  104. if(!_17){
  105. tb.appendTo("body");
  106. }
  107. var _18=tb.find(".textbox-text");
  108. var btn=tb.find(".textbox-button");
  109. var _19=tb.find(".textbox-addon");
  110. var _1a=_19.find(".textbox-icon");
  111. if(_15.height=="auto"){
  112. _18.css({margin:"",paddingTop:"",paddingBottom:"",height:"",lineHeight:""});
  113. }
  114. tb._size(_15,_16);
  115. if(_15.label&&_15.labelPosition){
  116. if(_15.labelPosition=="top"){
  117. _14.label._size({width:_15.labelWidth=="auto"?tb.outerWidth():_15.labelWidth},tb);
  118. if(_15.height!="auto"){
  119. tb._size("height",tb.outerHeight()-_14.label.outerHeight());
  120. }
  121. }else{
  122. _14.label._size({width:_15.labelWidth,height:tb.outerHeight()},tb);
  123. if(!_15.multiline){
  124. _14.label.css("lineHeight",_14.label.height()+"px");
  125. }
  126. tb._size("width",tb.outerWidth()-_14.label.outerWidth());
  127. }
  128. }
  129. if(_15.buttonAlign=="left"||_15.buttonAlign=="right"){
  130. btn.linkbutton("resize",{height:tb.height()});
  131. }else{
  132. btn.linkbutton("resize",{width:"100%"});
  133. }
  134. var _1b=tb.width()-_1a.length*_15.iconWidth-_1c("left")-_1c("right");
  135. var _1d=_15.height=="auto"?_18.outerHeight():(tb.height()-_1c("top")-_1c("bottom"));
  136. _19.css(_15.iconAlign,_1c(_15.iconAlign)+"px");
  137. _19.css("top",_1c("top")+"px");
  138. _1a.css({width:_15.iconWidth+"px",height:_1d+"px"});
  139. _18.css({paddingLeft:(_12.style.paddingLeft||""),paddingRight:(_12.style.paddingRight||""),marginLeft:_1e("left"),marginRight:_1e("right"),marginTop:_1c("top"),marginBottom:_1c("bottom")});
  140. if(_15.multiline){
  141. _18.css({paddingTop:(_12.style.paddingTop||""),paddingBottom:(_12.style.paddingBottom||"")});
  142. _18._outerHeight(_1d);
  143. }else{
  144. _18.css({paddingTop:0,paddingBottom:0,height:_1d+"px",lineHeight:_1d+"px"});
  145. }
  146. _18._outerWidth(_1b);
  147. _15.onResizing.call(_12,_15.width,_15.height);
  148. if(!_17){
  149. tb.insertAfter(_12);
  150. }
  151. _15.onResize.call(_12,_15.width,_15.height);
  152. function _1e(_1f){
  153. return (_15.iconAlign==_1f?_19._outerWidth():0)+_1c(_1f);
  154. };
  155. function _1c(_20){
  156. var w=0;
  157. btn.filter(".textbox-button-"+_20).each(function(){
  158. if(_20=="left"||_20=="right"){
  159. w+=$(this).outerWidth();
  160. }else{
  161. w+=$(this).outerHeight();
  162. }
  163. });
  164. return w;
  165. };
  166. };
  167. function _c(_21){
  168. var _22=$(_21).textbox("options");
  169. var _23=$(_21).textbox("textbox");
  170. _23.validatebox($.extend({},_22,{deltaX:function(_24){
  171. return $(_21).textbox("getTipX",_24);
  172. },deltaY:function(_25){
  173. return $(_21).textbox("getTipY",_25);
  174. },onBeforeValidate:function(){
  175. _22.onBeforeValidate.call(_21);
  176. var box=$(this);
  177. if(!box.is(":focus")){
  178. if(box.val()!==_22.value){
  179. _22.oldInputValue=box.val();
  180. box.val(_22.value);
  181. }
  182. }
  183. },onValidate:function(_26){
  184. var box=$(this);
  185. if(_22.oldInputValue!=undefined){
  186. box.val(_22.oldInputValue);
  187. _22.oldInputValue=undefined;
  188. }
  189. var tb=box.parent();
  190. if(_26){
  191. tb.removeClass("textbox-invalid");
  192. }else{
  193. tb.addClass("textbox-invalid");
  194. }
  195. _22.onValidate.call(_21,_26);
  196. }}));
  197. };
  198. function _27(_28){
  199. var _29=$.data(_28,"textbox");
  200. var _2a=_29.options;
  201. var tb=_29.textbox;
  202. var _2b=tb.find(".textbox-text");
  203. _2b.attr("placeholder",_2a.prompt);
  204. _2b.unbind(".textbox");
  205. $(_29.label).unbind(".textbox");
  206. if(!_2a.disabled&&!_2a.readonly){
  207. if(_29.label){
  208. $(_29.label).bind("click.textbox",function(e){
  209. if(!_2a.hasFocusMe){
  210. _2b.focus();
  211. $(_28).textbox("setSelectionRange",{start:0,end:_2b.val().length});
  212. }
  213. });
  214. }
  215. _2b.bind("blur.textbox",function(e){
  216. if(!tb.hasClass("textbox-focused")){
  217. return;
  218. }
  219. _2a.value=$(this).val();
  220. if(_2a.value==""){
  221. $(this).val(_2a.prompt).addClass("textbox-prompt");
  222. }else{
  223. $(this).removeClass("textbox-prompt");
  224. }
  225. tb.removeClass("textbox-focused");
  226. }).bind("focus.textbox",function(e){
  227. _2a.hasFocusMe=true;
  228. if(tb.hasClass("textbox-focused")){
  229. return;
  230. }
  231. if($(this).val()!=_2a.value){
  232. $(this).val(_2a.value);
  233. }
  234. $(this).removeClass("textbox-prompt");
  235. tb.addClass("textbox-focused");
  236. });
  237. for(var _2c in _2a.inputEvents){
  238. _2b.bind(_2c+".textbox",{target:_28},_2a.inputEvents[_2c]);
  239. }
  240. }
  241. var _2d=tb.find(".textbox-addon");
  242. _2d.unbind().bind("click",{target:_28},function(e){
  243. var _2e=$(e.target).closest("a.textbox-icon:not(.textbox-icon-disabled)");
  244. if(_2e.length){
  245. var _2f=parseInt(_2e.attr("icon-index"));
  246. var _30=_2a.icons[_2f];
  247. if(_30&&_30.handler){
  248. _30.handler.call(_2e[0],e);
  249. }
  250. _2a.onClickIcon.call(_28,_2f);
  251. }
  252. });
  253. _2d.find(".textbox-icon").each(function(_31){
  254. var _32=_2a.icons[_31];
  255. var _33=$(this);
  256. if(!_32||_32.disabled||_2a.disabled||_2a.readonly){
  257. _33.addClass("textbox-icon-disabled");
  258. }else{
  259. _33.removeClass("textbox-icon-disabled");
  260. }
  261. });
  262. var btn=tb.find(".textbox-button");
  263. btn.linkbutton((_2a.disabled||_2a.readonly)?"disable":"enable");
  264. tb.unbind(".textbox").bind("_resize.textbox",function(e,_34){
  265. if($(this).hasClass("easyui-fluid")||_34){
  266. _11(_28);
  267. }
  268. return false;
  269. });
  270. };
  271. function _d(_35,_36){
  272. var _37=$.data(_35,"textbox");
  273. var _38=_37.options;
  274. var tb=_37.textbox;
  275. var _39=tb.find(".textbox-text");
  276. var ss=$(_35).add(tb.find(".textbox-value"));
  277. _38.disabled=_36;
  278. if(_38.disabled){
  279. _39.blur();
  280. _39.validatebox("disable");
  281. tb.addClass("textbox-disabled");
  282. ss.attr("disabled","disabled");
  283. $(_37.label).addClass("textbox-label-disabled");
  284. }else{
  285. _39.validatebox("enable");
  286. tb.removeClass("textbox-disabled");
  287. ss.removeAttr("disabled");
  288. $(_37.label).removeClass("textbox-label-disabled");
  289. }
  290. };
  291. function _e(_3a,_3b){
  292. var _3c=$.data(_3a,"textbox");
  293. var _3d=_3c.options;
  294. var tb=_3c.textbox;
  295. var _3e=tb.find(".textbox-text");
  296. _3d.readonly=_3b==undefined?true:_3b;
  297. if(_3d.readonly){
  298. _3e.triggerHandler("blur.textbox");
  299. }
  300. _3e.validatebox("readonly",_3d.readonly);
  301. tb.removeClass("textbox-readonly").addClass(_3d.readonly?"textbox-readonly":"");
  302. };
  303. $.fn.textbox=function(_3f,_40){
  304. if(typeof _3f=="string"){
  305. var _41=$.fn.textbox.methods[_3f];
  306. if(_41){
  307. return _41(this,_40);
  308. }else{
  309. return this.each(function(){
  310. var _42=$(this).textbox("textbox");
  311. _42.validatebox(_3f,_40);
  312. });
  313. }
  314. }
  315. _3f=_3f||{};
  316. return this.each(function(){
  317. var _43=$.data(this,"textbox");
  318. if(_43){
  319. $.extend(_43.options,_3f);
  320. if(_3f.value!=undefined){
  321. _43.options.originalValue=_3f.value;
  322. }
  323. }else{
  324. _43=$.data(this,"textbox",{options:$.extend({},$.fn.textbox.defaults,$.fn.textbox.parseOptions(this),_3f),textbox:_2(this)});
  325. _43.options.originalValue=_43.options.value;
  326. }
  327. _6(this);
  328. _27(this);
  329. if(_43.options.doSize){
  330. _11(this);
  331. }
  332. var _44=_43.options.value;
  333. _43.options.value="";
  334. $(this).textbox("initValue",_44);
  335. });
  336. };
  337. $.fn.textbox.methods={options:function(jq){
  338. return $.data(jq[0],"textbox").options;
  339. },cloneFrom:function(jq,_45){
  340. return jq.each(function(){
  341. var t=$(this);
  342. if(t.data("textbox")){
  343. return;
  344. }
  345. if(!$(_45).data("textbox")){
  346. $(_45).textbox();
  347. }
  348. var _46=$.extend(true,{},$(_45).textbox("options"));
  349. var _47=t.attr("name")||"";
  350. t.addClass("textbox-f").hide();
  351. t.removeAttr("name").attr("textboxName",_47);
  352. var _48=$(_45).next().clone().insertAfter(t);
  353. var _49="_easyui_textbox_input"+(++_1);
  354. _48.find(".textbox-value").attr("name",_47);
  355. _48.find(".textbox-text").attr("id",_49);
  356. var _4a=$($(_45).textbox("label")).clone();
  357. if(_4a.length){
  358. _4a.attr("for",_49);
  359. if(_46.labelPosition=="after"){
  360. _4a.insertAfter(t.next());
  361. }else{
  362. _4a.insertBefore(t);
  363. }
  364. }
  365. $.data(this,"textbox",{options:_46,textbox:_48,label:(_4a.length?_4a:undefined)});
  366. var _4b=$(_45).textbox("button");
  367. if(_4b.length){
  368. t.textbox("button").linkbutton($.extend(true,{},_4b.linkbutton("options")));
  369. }
  370. _27(this);
  371. _c(this);
  372. });
  373. },textbox:function(jq){
  374. return $.data(jq[0],"textbox").textbox.find(".textbox-text");
  375. },button:function(jq){
  376. return $.data(jq[0],"textbox").textbox.find(".textbox-button");
  377. },label:function(jq){
  378. return $.data(jq[0],"textbox").label;
  379. },destroy:function(jq){
  380. return jq.each(function(){
  381. _f(this);
  382. });
  383. },resize:function(jq,_4c){
  384. return jq.each(function(){
  385. _11(this,_4c);
  386. });
  387. },disable:function(jq){
  388. return jq.each(function(){
  389. _d(this,true);
  390. _27(this);
  391. });
  392. },enable:function(jq){
  393. return jq.each(function(){
  394. _d(this,false);
  395. _27(this);
  396. });
  397. },readonly:function(jq,_4d){
  398. return jq.each(function(){
  399. _e(this,_4d);
  400. _27(this);
  401. });
  402. },isValid:function(jq){
  403. return jq.textbox("textbox").validatebox("isValid");
  404. },clear:function(jq){
  405. return jq.each(function(){
  406. $(this).textbox("setValue","");
  407. });
  408. },setText:function(jq,_4e){
  409. return jq.each(function(){
  410. var _4f=$(this).textbox("options");
  411. var _50=$(this).textbox("textbox");
  412. _4e=_4e==undefined?"":String(_4e);
  413. if($(this).textbox("getText")!=_4e){
  414. _50.val(_4e);
  415. }
  416. _4f.value=_4e;
  417. if(!_50.is(":focus")){
  418. if(_4e){
  419. _50.removeClass("textbox-prompt");
  420. }else{
  421. _50.val(_4f.prompt).addClass("textbox-prompt");
  422. }
  423. }
  424. $(this).textbox("validate");
  425. });
  426. },initValue:function(jq,_51){
  427. return jq.each(function(){
  428. var _52=$.data(this,"textbox");
  429. $(this).textbox("setText",_51);
  430. _52.textbox.find(".textbox-value").val(_51);
  431. $(this).val(_51);
  432. });
  433. },setValue:function(jq,_53){
  434. return jq.each(function(){
  435. var _54=$.data(this,"textbox").options;
  436. var _55=$(this).textbox("getValue");
  437. $(this).textbox("initValue",_53);
  438. if(_55!=_53){
  439. _54.onChange.call(this,_53,_55);
  440. $(this).closest("form").trigger("_change",[this]);
  441. }
  442. });
  443. },getText:function(jq){
  444. var _56=jq.textbox("textbox");
  445. if(_56.is(":focus")){
  446. return _56.val();
  447. }else{
  448. return jq.textbox("options").value;
  449. }
  450. },getValue:function(jq){
  451. return jq.data("textbox").textbox.find(".textbox-value").val();
  452. },reset:function(jq){
  453. return jq.each(function(){
  454. var _57=$(this).textbox("options");
  455. $(this).textbox("setValue",_57.originalValue);
  456. });
  457. },getIcon:function(jq,_58){
  458. return jq.data("textbox").textbox.find(".textbox-icon:eq("+_58+")");
  459. },getTipX:function(jq,_59){
  460. var _5a=jq.data("textbox");
  461. var _5b=_5a.options;
  462. var tb=_5a.textbox;
  463. var _5c=tb.find(".textbox-text");
  464. var _59=_59||_5b.tipPosition;
  465. var p1=tb.offset();
  466. var p2=_5c.offset();
  467. var w1=tb.outerWidth();
  468. var w2=_5c.outerWidth();
  469. if(_59=="right"){
  470. return w1-w2-p2.left+p1.left;
  471. }else{
  472. if(_59=="left"){
  473. return p1.left-p2.left;
  474. }else{
  475. return (w1-w2-p2.left+p1.left)/2-(p2.left-p1.left)/2;
  476. }
  477. }
  478. },getTipY:function(jq,_5d){
  479. var _5e=jq.data("textbox");
  480. var _5f=_5e.options;
  481. var tb=_5e.textbox;
  482. var _60=tb.find(".textbox-text");
  483. var _5d=_5d||_5f.tipPosition;
  484. var p1=tb.offset();
  485. var p2=_60.offset();
  486. var h1=tb.outerHeight();
  487. var h2=_60.outerHeight();
  488. if(_5d=="left"||_5d=="right"){
  489. return (h1-h2-p2.top+p1.top)/2-(p2.top-p1.top)/2;
  490. }else{
  491. if(_5d=="bottom"){
  492. return (h1-h2-p2.top+p1.top);
  493. }else{
  494. return (p1.top-p2.top);
  495. }
  496. }
  497. },getSelectionStart:function(jq){
  498. return jq.textbox("getSelectionRange").start;
  499. },getSelectionRange:function(jq){
  500. var _61=jq.textbox("textbox")[0];
  501. var _62=0;
  502. var end=0;
  503. if(typeof _61.selectionStart=="number"){
  504. _62=_61.selectionStart;
  505. end=_61.selectionEnd;
  506. }else{
  507. if(_61.createTextRange){
  508. var s=document.selection.createRange();
  509. var _63=_61.createTextRange();
  510. _63.setEndPoint("EndToStart",s);
  511. _62=_63.text.length;
  512. end=_62+s.text.length;
  513. }
  514. }
  515. return {start:_62,end:end};
  516. },setSelectionRange:function(jq,_64){
  517. return jq.each(function(){
  518. var _65=$(this).textbox("textbox")[0];
  519. var _66=_64.start;
  520. var end=_64.end;
  521. if(_65.setSelectionRange){
  522. _65.setSelectionRange(_66,end);
  523. }else{
  524. if(_65.createTextRange){
  525. var _67=_65.createTextRange();
  526. _67.collapse();
  527. _67.moveEnd("character",end);
  528. _67.moveStart("character",_66);
  529. _67.select();
  530. }
  531. }
  532. });
  533. }};
  534. $.fn.textbox.parseOptions=function(_68){
  535. var t=$(_68);
  536. return $.extend({},$.fn.validatebox.parseOptions(_68),$.parser.parseOptions(_68,["prompt","iconCls","iconAlign","buttonText","buttonIcon","buttonAlign","label","labelPosition","labelAlign",{multiline:"boolean",iconWidth:"number",labelWidth:"number"}]),{value:(t.val()||undefined),type:(t.attr("type")?t.attr("type"):undefined)});
  537. };
  538. $.fn.textbox.defaults=$.extend({},$.fn.validatebox.defaults,{doSize:true,width:"auto",height:"auto",cls:null,prompt:"",value:"",type:"text",multiline:false,icons:[],iconCls:null,iconAlign:"right",iconWidth:18,buttonText:"",buttonIcon:null,buttonAlign:"right",label:null,labelWidth:"auto",labelPosition:"before",labelAlign:"left",inputEvents:{blur:function(e){
  539. var t=$(e.data.target);
  540. var _69=t.textbox("options");
  541. if(t.textbox("getValue")!=_69.value){
  542. t.textbox("setValue",_69.value);
  543. }
  544. },keydown:function(e){
  545. if(e.keyCode==13){
  546. var t=$(e.data.target);
  547. t.textbox("setValue",t.textbox("getText"));
  548. }
  549. }},onChange:function(_6a,_6b){
  550. },onResizing:function(_6c,_6d){
  551. },onResize:function(_6e,_6f){
  552. },onClickButton:function(){
  553. },onClickIcon:function(_70){
  554. }});
  555. })(jQuery);