63afff768216af6391804bef90d5833adc34f8fd.svn-base 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var pic = [];
  2. var upload = [];
  3. function loadUpload(i,e,key,upload,assets)
  4. {
  5. var value = e.attr('v');
  6. if(typeof(upload[value]) != "undefined")
  7. {
  8. return;
  9. }
  10. upload[value] = true;
  11. e.uploadify({
  12. 'formData' : {'key' : key},
  13. 'swf' : assets + 'uploadify.swf',
  14. 'buttonText' : '选择文件',
  15. 'uploader' : upload,
  16. 'cancelImg' : assets + 'upload/img/fyuploadify-cancel.png',
  17. 'onUploadSuccess':function(file,data,response)
  18. {
  19. //console.info(data);
  20. var data = eval('('+data+')');
  21. if(data.status)
  22. {
  23. var mul = e.attr('mul');
  24. if(mul == 'yes')
  25. {
  26. if(pic.length <= 0 && $("#" + value).val())
  27. {
  28. pic = $("#" + value).val().split(',');
  29. }
  30. var m = $('.' +value+'_mul');
  31. var i = m.find('img').eq(pic.length);
  32. if(i.length)
  33. {
  34. i.attr('src', data.url);
  35. }
  36. else
  37. {
  38. m.append('<a href="javascript:;" title="点此删除" onclick="picDel(\''+data.url+'\', $(this), \''+value+'\')"><img src="'+data.url+'" width="150" style="margin-left:5px;" alt="点此删除"/></a>');
  39. }
  40. pic.push(data.url);
  41. //console.info(pic);
  42. $("#" + value).val(pic.join(','));
  43. }
  44. else
  45. {
  46. $("#"+file.id).find('.data').html('上传完毕');
  47. $('#'+value).val(data.url);
  48. $('#show_'+value).attr('src',data.url).show();
  49. }
  50. }
  51. else
  52. {
  53. $("#"+file.id).find('.data').html("<font color='red'>"+data.message+"</font>");
  54. return false;
  55. }
  56. }
  57. });
  58. }
  59. if(jQuery.browser.msie){
  60. SWFUpload.prototype.getFlashHTML = function () {
  61. return ['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
  62. '<param name="wmode" value="', this.settings.button_window_mode , '" />',
  63. '<param name="movie" value="', this.settings.flash_url, '" />',
  64. '<param name="quality" value="high" />',
  65. '<param name="menu" value="false" />',
  66. '<param name="allowScriptAccess" value="always" />',
  67. '<param name="flashvars" value="' + this.getFlashVars() + '" />',
  68. '</object>'].join("");
  69. }
  70. }
  71. function picDel(p,e,v)
  72. {
  73. if(pic.length <= 0 && $("#" + v).val())
  74. {
  75. pic = $("#" + v).val().split(',');
  76. }
  77. e.remove();
  78. pic.remove(p);
  79. //console.info(pic);
  80. $("#" + v).val(pic.join(','));
  81. }