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.

110 lines
6.2 KiB

3 years ago
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  7. <script type="text/javascript" src="../internal.js"></script>
  8. <style type="text/css">
  9. .wrapper{width: 600px;padding: 10px;height: 352px;overflow: hidden;position: relative;border-bottom: 1px solid #d7d7d7}
  10. .localPath input{float: left;width: 350px;line-height: 20px;height: 20px;}
  11. #clipboard{float:left;width: 70px;height: 30px; }
  12. .description{ color: #0066cc; margin-top: 2px; width: 450px; height: 45px;float: left;line-height: 22px}
  13. #upload{width: 100px;height: 30px;float: right; margin:10px 2px 0 0;cursor: pointer;}
  14. #msg{ width: 140px; height: 30px; line-height:25px;float: left;color: red}
  15. </style>
  16. </head>
  17. <body>
  18. <div class="wrapper">
  19. <div class="localPath">
  20. <input id="localPath" type="text" readonly />
  21. <div id="clipboard"></div>
  22. <div id="msg"></div>
  23. </div>
  24. <div id="flashContainer"></div>
  25. <div>
  26. <div id="upload" style="display: none" ><img id="uploadBtn"></div>
  27. <div class="description">
  28. <span style="color: red"><var id="lang_resave"></var>: </span><var id="lang_step"></var>
  29. </div>
  30. </div>
  31. </div>
  32. <script type="text/javascript" src="tangram.js"></script>
  33. <script type="text/javascript" src="wordimage.js"></script>
  34. <script type="text/javascript">
  35. editor.setOpt({
  36. wordImageFieldName:"upfile",
  37. compressSide:0,
  38. maxImageSideLength:900
  39. });
  40. //全局变量
  41. var imageUrls = [], //用于保存从服务器返回的图片信息数组
  42. selectedImageCount = 0, //当前已选择的但未上传的图片数量
  43. optImageUrl = editor.getActionUrl(editor.getOpt('imageActionName')),
  44. optImageFieldName = editor.getOpt('imageFieldName'),
  45. optImageCompressBorder = editor.getOpt('imageCompressEnable') ? editor.getOpt('imageCompressBorder'):null,
  46. maxSize = editor.getOpt('imageMaxSize') / 1024 / 1024,
  47. extension = editor.getOpt('imageAllowFiles').join(';').replace(/\./g, '*.');
  48. /* 添加额外的GET参数 */
  49. var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
  50. urlWidthParams = optImageUrl + (optImageUrl.indexOf('?') == -1 ? '?':'&') + params;
  51. utils.domReady(function(){
  52. //创建Flash相关的参数集合
  53. var flashOptions = {
  54. container:"flashContainer", //flash容器id
  55. url:urlWidthParams, // 上传处理页面的url地址
  56. ext:editor.queryCommandValue('serverParam') || {}, //可向服务器提交的自定义参数列表
  57. fileType:'{"description":"'+lang.fileType+'", "extension":"' + extension + '"}', //上传文件格式限制
  58. flashUrl:'imageUploader.swf', //上传用的flash组件地址
  59. width:600, //flash的宽度
  60. height:272, //flash的高度
  61. gridWidth:120, // 每一个预览图片所占的宽度
  62. gridHeight:120, // 每一个预览图片所占的高度
  63. picWidth:100, // 单张预览图片的宽度
  64. picHeight:100, // 单张预览图片的高度
  65. uploadDataFieldName: optImageFieldName, // POST请求中图片数据的key
  66. picDescFieldName:'pictitle', // POST请求中图片描述的key
  67. maxSize: maxSize, // 文件的最大体积,单位M
  68. compressSize:1, // 上传前如果图片体积超过该值,会先压缩,单位M
  69. maxNum:32, // 单次最大可上传多少个文件
  70. compressSide: 0, //等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度
  71. compressLength: optImageCompressBorder //能接受的最大边长,超过该值Flash会自动等比压缩
  72. };
  73. //回调函数集合,支持传递函数名的字符串、函数句柄以及函数本身三种类型
  74. var callbacks={
  75. selectFileCallback: function(selectFiles){ // 选择文件的回调
  76. selectedImageCount += selectFiles.length;
  77. if(selectedImageCount) baidu.g("upload").style.display = "";
  78. dialog.buttons[0].setDisabled(true); //初始化时置灰确定按钮
  79. },
  80. deleteFileCallback: function(delFiles){ // 删除文件的回调
  81. selectedImageCount -= delFiles.length;
  82. if (!selectedImageCount) {
  83. baidu.g("upload").style.display = "none";
  84. dialog.buttons[0].setDisabled(false); //没有选择图片时重新点亮按钮
  85. }
  86. },
  87. uploadCompleteCallback: function(data){ // 单个文件上传完成的回调
  88. try{var info = eval("(" + data.info + ")");
  89. info && imageUrls.push(info);
  90. selectedImageCount--;
  91. }catch(e){}
  92. },
  93. uploadErrorCallback: function (data){ // 单个文件上传失败的回调,
  94. console && console.log(data);
  95. },
  96. allCompleteCallback: function(){ // 全部上传完成时的回调
  97. dialog.buttons[0].setDisabled(false); //上传完毕后点亮按钮
  98. }
  99. //exceedFileCallback: 'exceedFileCallback', // 文件超出限制的最大体积时的回调
  100. //startUploadCallback: startUploadCallback // 开始上传某个文件时的回调
  101. };
  102. wordImage.init(flashOptions,callbacks);
  103. });
  104. </script>
  105. </body>
  106. </html>