旭捷内部项目管理系统
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.

97 lines
2.6 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. var _4=$.data(_3,"filebox");
  14. var _5=_4.options;
  15. _5.fileboxId="filebox_file_id_"+(++_1);
  16. $(_3).addClass("filebox-f").textbox(_5);
  17. $(_3).textbox("textbox").attr("readonly","readonly");
  18. _4.filebox=$(_3).next().addClass("filebox");
  19. var _6=_7(_3);
  20. var _8=$(_3).filebox("button");
  21. if(_8.length){
  22. $("<label class=\"filebox-label\" for=\""+_5.fileboxId+"\"></label>").appendTo(_8);
  23. if(_8.linkbutton("options").disabled){
  24. _6.attr("disabled","disabled");
  25. }else{
  26. _6.removeAttr("disabled");
  27. }
  28. }
  29. };
  30. function _7(_9){
  31. var _a=$.data(_9,"filebox");
  32. var _b=_a.options;
  33. _a.filebox.find(".textbox-value").remove();
  34. _b.oldValue="";
  35. var _c=$("<input type=\"file\" class=\"textbox-value\">").appendTo(_a.filebox);
  36. _c.attr("id",_b.fileboxId).attr("name",$(_9).attr("textboxName")||"");
  37. _c.attr("accept",_b.accept);
  38. if(_b.multiple){
  39. _c.attr("multiple","multiple");
  40. }
  41. _c.change(function(){
  42. var _d=this.value;
  43. if(this.files){
  44. _d=$.map(this.files,function(_e){
  45. return _e.name;
  46. }).join(_b.separator);
  47. }
  48. $(_9).filebox("setText",_d);
  49. _b.onChange.call(_9,_d,_b.oldValue);
  50. _b.oldValue=_d;
  51. });
  52. return _c;
  53. };
  54. $.fn.filebox=function(_f,_10){
  55. if(typeof _f=="string"){
  56. var _11=$.fn.filebox.methods[_f];
  57. if(_11){
  58. return _11(this,_10);
  59. }else{
  60. return this.textbox(_f,_10);
  61. }
  62. }
  63. _f=_f||{};
  64. return this.each(function(){
  65. var _12=$.data(this,"filebox");
  66. if(_12){
  67. $.extend(_12.options,_f);
  68. }else{
  69. $.data(this,"filebox",{options:$.extend({},$.fn.filebox.defaults,$.fn.filebox.parseOptions(this),_f)});
  70. }
  71. _2(this);
  72. });
  73. };
  74. $.fn.filebox.methods={options:function(jq){
  75. var _13=jq.textbox("options");
  76. return $.extend($.data(jq[0],"filebox").options,{width:_13.width,value:_13.value,originalValue:_13.originalValue,disabled:_13.disabled,readonly:_13.readonly});
  77. },clear:function(jq){
  78. return jq.each(function(){
  79. $(this).textbox("clear");
  80. _7(this);
  81. });
  82. },reset:function(jq){
  83. return jq.each(function(){
  84. $(this).filebox("clear");
  85. });
  86. },setValue:function(jq){
  87. return jq;
  88. },setValues:function(jq){
  89. return jq;
  90. }};
  91. $.fn.filebox.parseOptions=function(_14){
  92. var t=$(_14);
  93. return $.extend({},$.fn.textbox.parseOptions(_14),$.parser.parseOptions(_14,["accept","separator"]),{multiple:(t.attr("multiple")?true:undefined)});
  94. };
  95. $.fn.filebox.defaults=$.extend({},$.fn.textbox.defaults,{buttonIcon:null,buttonText:"Choose File",buttonAlign:"right",inputEvents:{},accept:"",separator:",",multiple:false});
  96. })(jQuery);