@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/es/LcdpUeditor.d.ts +74 -0
  2. package/es/LcdpUeditor.js +335 -0
  3. package/es/const.d.ts +12 -0
  4. package/es/const.js +19 -0
  5. package/es/defaultConfig.json +77 -0
  6. package/es/index.d.ts +4 -0
  7. package/es/index.js +3 -0
  8. package/es/tools/UeditorResourceLoader.d.ts +21 -0
  9. package/es/tools/UeditorResourceLoader.js +114 -0
  10. package/es/tools/loadScript.d.ts +5 -0
  11. package/es/tools/loadScript.js +54 -0
  12. package/es/type.d.ts +142 -0
  13. package/es/type.js +1 -0
  14. package/package.json +32 -0
  15. package/ueditor-resource/dialogs/anchor/anchor.html +62 -0
  16. package/ueditor-resource/dialogs/attachment/attachment.css +716 -0
  17. package/ueditor-resource/dialogs/attachment/attachment.html +61 -0
  18. package/ueditor-resource/dialogs/attachment/attachment.js +803 -0
  19. package/ueditor-resource/dialogs/attachment/images/alignicon.gif +0 -0
  20. package/ueditor-resource/dialogs/attachment/images/alignicon.png +0 -0
  21. package/ueditor-resource/dialogs/attachment/images/bg.png +0 -0
  22. package/ueditor-resource/dialogs/attachment/images/file-icons.gif +0 -0
  23. package/ueditor-resource/dialogs/attachment/images/file-icons.png +0 -0
  24. package/ueditor-resource/dialogs/attachment/images/icons.gif +0 -0
  25. package/ueditor-resource/dialogs/attachment/images/icons.png +0 -0
  26. package/ueditor-resource/dialogs/attachment/images/image.png +0 -0
  27. package/ueditor-resource/dialogs/attachment/images/progress.png +0 -0
  28. package/ueditor-resource/dialogs/attachment/images/success.gif +0 -0
  29. package/ueditor-resource/dialogs/attachment/images/success.png +0 -0
  30. package/ueditor-resource/dialogs/audio/audio.css +879 -0
  31. package/ueditor-resource/dialogs/audio/audio.html +94 -0
  32. package/ueditor-resource/dialogs/audio/audio.js +815 -0
  33. package/ueditor-resource/dialogs/audio/icon/center-active.png +0 -0
  34. package/ueditor-resource/dialogs/audio/icon/center.png +0 -0
  35. package/ueditor-resource/dialogs/audio/icon/img.png +0 -0
  36. package/ueditor-resource/dialogs/audio/icon/left-active.png +0 -0
  37. package/ueditor-resource/dialogs/audio/icon/left.png +0 -0
  38. package/ueditor-resource/dialogs/audio/icon/none-active.png +0 -0
  39. package/ueditor-resource/dialogs/audio/icon/none.png +0 -0
  40. package/ueditor-resource/dialogs/audio/icon/right-active.png +0 -0
  41. package/ueditor-resource/dialogs/audio/icon/right.png +0 -0
  42. package/ueditor-resource/dialogs/audio/images/bg.png +0 -0
  43. package/ueditor-resource/dialogs/audio/images/center_focus.jpg +0 -0
  44. package/ueditor-resource/dialogs/audio/images/file-icons.gif +0 -0
  45. package/ueditor-resource/dialogs/audio/images/file-icons.png +0 -0
  46. package/ueditor-resource/dialogs/audio/images/icons.gif +0 -0
  47. package/ueditor-resource/dialogs/audio/images/icons.png +0 -0
  48. package/ueditor-resource/dialogs/audio/images/image.png +0 -0
  49. package/ueditor-resource/dialogs/audio/images/left_focus.jpg +0 -0
  50. package/ueditor-resource/dialogs/audio/images/none_focus.jpg +0 -0
  51. package/ueditor-resource/dialogs/audio/images/progress.png +0 -0
  52. package/ueditor-resource/dialogs/audio/images/right_focus.jpg +0 -0
  53. package/ueditor-resource/dialogs/audio/images/success.gif +0 -0
  54. package/ueditor-resource/dialogs/audio/images/success.png +0 -0
  55. package/ueditor-resource/dialogs/background/background.css +193 -0
  56. package/ueditor-resource/dialogs/background/background.html +59 -0
  57. package/ueditor-resource/dialogs/background/background.js +370 -0
  58. package/ueditor-resource/dialogs/background/images/bg.png +0 -0
  59. package/ueditor-resource/dialogs/background/images/success.png +0 -0
  60. package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -0
  61. package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -0
  62. package/ueditor-resource/dialogs/emotion/emotion.css +129 -0
  63. package/ueditor-resource/dialogs/emotion/emotion.html +70 -0
  64. package/ueditor-resource/dialogs/emotion/emotion.js +186 -0
  65. package/ueditor-resource/dialogs/emotion/images/0.gif +0 -0
  66. package/ueditor-resource/dialogs/emotion/images/bface.gif +0 -0
  67. package/ueditor-resource/dialogs/emotion/images/cface.gif +0 -0
  68. package/ueditor-resource/dialogs/emotion/images/fface.gif +0 -0
  69. package/ueditor-resource/dialogs/emotion/images/jxface2.gif +0 -0
  70. package/ueditor-resource/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  71. package/ueditor-resource/dialogs/emotion/images/tface.gif +0 -0
  72. package/ueditor-resource/dialogs/emotion/images/wface.gif +0 -0
  73. package/ueditor-resource/dialogs/emotion/images/yface.gif +0 -0
  74. package/ueditor-resource/dialogs/formula/formula.html +98 -0
  75. package/ueditor-resource/dialogs/formula/formula.js +147 -0
  76. package/ueditor-resource/dialogs/help/help.css +37 -0
  77. package/ueditor-resource/dialogs/help/help.html +82 -0
  78. package/ueditor-resource/dialogs/help/help.js +57 -0
  79. package/ueditor-resource/dialogs/image/icon/center-active.png +0 -0
  80. package/ueditor-resource/dialogs/image/icon/center.png +0 -0
  81. package/ueditor-resource/dialogs/image/icon/img.png +0 -0
  82. package/ueditor-resource/dialogs/image/icon/left-active.png +0 -0
  83. package/ueditor-resource/dialogs/image/icon/left.png +0 -0
  84. package/ueditor-resource/dialogs/image/icon/none-active.png +0 -0
  85. package/ueditor-resource/dialogs/image/icon/none.png +0 -0
  86. package/ueditor-resource/dialogs/image/icon/right-active.png +0 -0
  87. package/ueditor-resource/dialogs/image/icon/right.png +0 -0
  88. package/ueditor-resource/dialogs/image/image.css +768 -0
  89. package/ueditor-resource/dialogs/image/image.html +145 -0
  90. package/ueditor-resource/dialogs/image/image.js +1060 -0
  91. package/ueditor-resource/dialogs/image/images/alignicon.jpg +0 -0
  92. package/ueditor-resource/dialogs/image/images/bg.png +0 -0
  93. package/ueditor-resource/dialogs/image/images/icons.gif +0 -0
  94. package/ueditor-resource/dialogs/image/images/icons.png +0 -0
  95. package/ueditor-resource/dialogs/image/images/image.png +0 -0
  96. package/ueditor-resource/dialogs/image/images/progress.png +0 -0
  97. package/ueditor-resource/dialogs/image/images/success.gif +0 -0
  98. package/ueditor-resource/dialogs/image/images/success.png +0 -0
  99. package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -0
  100. package/ueditor-resource/dialogs/internal.js +81 -0
  101. package/ueditor-resource/dialogs/link/link.html +148 -0
  102. package/ueditor-resource/dialogs/preview/preview.html +45 -0
  103. package/ueditor-resource/dialogs/scrawl/images/addimg.png +0 -0
  104. package/ueditor-resource/dialogs/scrawl/images/brush.png +0 -0
  105. package/ueditor-resource/dialogs/scrawl/images/delimg.png +0 -0
  106. package/ueditor-resource/dialogs/scrawl/images/delimgH.png +0 -0
  107. package/ueditor-resource/dialogs/scrawl/images/empty.png +0 -0
  108. package/ueditor-resource/dialogs/scrawl/images/emptyH.png +0 -0
  109. package/ueditor-resource/dialogs/scrawl/images/eraser.png +0 -0
  110. package/ueditor-resource/dialogs/scrawl/images/redo.png +0 -0
  111. package/ueditor-resource/dialogs/scrawl/images/redoH.png +0 -0
  112. package/ueditor-resource/dialogs/scrawl/images/scale.png +0 -0
  113. package/ueditor-resource/dialogs/scrawl/images/scaleH.png +0 -0
  114. package/ueditor-resource/dialogs/scrawl/images/size.png +0 -0
  115. package/ueditor-resource/dialogs/scrawl/images/undo.png +0 -0
  116. package/ueditor-resource/dialogs/scrawl/images/undoH.png +0 -0
  117. package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -0
  118. package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -0
  119. package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -0
  120. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -0
  121. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -0
  122. package/ueditor-resource/dialogs/spechars/spechars.html +42 -0
  123. package/ueditor-resource/dialogs/spechars/spechars.js +86 -0
  124. package/ueditor-resource/dialogs/table/dragicon.png +0 -0
  125. package/ueditor-resource/dialogs/table/edittable.css +85 -0
  126. package/ueditor-resource/dialogs/table/edittable.html +69 -0
  127. package/ueditor-resource/dialogs/table/edittable.js +241 -0
  128. package/ueditor-resource/dialogs/table/edittd.html +62 -0
  129. package/ueditor-resource/dialogs/table/edittip.html +33 -0
  130. package/ueditor-resource/dialogs/template/config.js +42 -0
  131. package/ueditor-resource/dialogs/template/images/bg.gif +0 -0
  132. package/ueditor-resource/dialogs/template/images/pre0.png +0 -0
  133. package/ueditor-resource/dialogs/template/images/pre1.png +0 -0
  134. package/ueditor-resource/dialogs/template/images/pre2.png +0 -0
  135. package/ueditor-resource/dialogs/template/images/pre3.png +0 -0
  136. package/ueditor-resource/dialogs/template/images/pre4.png +0 -0
  137. package/ueditor-resource/dialogs/template/template.css +99 -0
  138. package/ueditor-resource/dialogs/template/template.html +26 -0
  139. package/ueditor-resource/dialogs/template/template.js +53 -0
  140. package/ueditor-resource/dialogs/video/icon/center-active.png +0 -0
  141. package/ueditor-resource/dialogs/video/icon/center.png +0 -0
  142. package/ueditor-resource/dialogs/video/icon/img.png +0 -0
  143. package/ueditor-resource/dialogs/video/icon/left-active.png +0 -0
  144. package/ueditor-resource/dialogs/video/icon/left.png +0 -0
  145. package/ueditor-resource/dialogs/video/icon/none-active.png +0 -0
  146. package/ueditor-resource/dialogs/video/icon/none.png +0 -0
  147. package/ueditor-resource/dialogs/video/icon/right-active.png +0 -0
  148. package/ueditor-resource/dialogs/video/icon/right.png +0 -0
  149. package/ueditor-resource/dialogs/video/images/bg.png +0 -0
  150. package/ueditor-resource/dialogs/video/images/center_focus.jpg +0 -0
  151. package/ueditor-resource/dialogs/video/images/file-icons.gif +0 -0
  152. package/ueditor-resource/dialogs/video/images/file-icons.png +0 -0
  153. package/ueditor-resource/dialogs/video/images/icons.gif +0 -0
  154. package/ueditor-resource/dialogs/video/images/icons.png +0 -0
  155. package/ueditor-resource/dialogs/video/images/image.png +0 -0
  156. package/ueditor-resource/dialogs/video/images/left_focus.jpg +0 -0
  157. package/ueditor-resource/dialogs/video/images/none_focus.jpg +0 -0
  158. package/ueditor-resource/dialogs/video/images/progress.png +0 -0
  159. package/ueditor-resource/dialogs/video/images/right_focus.jpg +0 -0
  160. package/ueditor-resource/dialogs/video/images/success.gif +0 -0
  161. package/ueditor-resource/dialogs/video/images/success.png +0 -0
  162. package/ueditor-resource/dialogs/video/video.css +909 -0
  163. package/ueditor-resource/dialogs/video/video.html +115 -0
  164. package/ueditor-resource/dialogs/video/video.js +867 -0
  165. package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -0
  166. package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -0
  167. package/ueditor-resource/index.html +146 -0
  168. package/ueditor-resource/lang/en/en.js +686 -0
  169. package/ueditor-resource/lang/en/images/addimage.png +0 -0
  170. package/ueditor-resource/lang/en/images/alldeletebtnhoverskin.png +0 -0
  171. package/ueditor-resource/lang/en/images/alldeletebtnupskin.png +0 -0
  172. package/ueditor-resource/lang/en/images/background.png +0 -0
  173. package/ueditor-resource/lang/en/images/button.png +0 -0
  174. package/ueditor-resource/lang/en/images/copy.png +0 -0
  175. package/ueditor-resource/lang/en/images/deletedisable.png +0 -0
  176. package/ueditor-resource/lang/en/images/deleteenable.png +0 -0
  177. package/ueditor-resource/lang/en/images/listbackground.png +0 -0
  178. package/ueditor-resource/lang/en/images/localimage.png +0 -0
  179. package/ueditor-resource/lang/en/images/music.png +0 -0
  180. package/ueditor-resource/lang/en/images/rotateleftdisable.png +0 -0
  181. package/ueditor-resource/lang/en/images/rotateleftenable.png +0 -0
  182. package/ueditor-resource/lang/en/images/rotaterightdisable.png +0 -0
  183. package/ueditor-resource/lang/en/images/rotaterightenable.png +0 -0
  184. package/ueditor-resource/lang/en/images/upload.png +0 -0
  185. package/ueditor-resource/lang/zh-cn/images/copy.png +0 -0
  186. package/ueditor-resource/lang/zh-cn/images/localimage.png +0 -0
  187. package/ueditor-resource/lang/zh-cn/images/music.png +0 -0
  188. package/ueditor-resource/lang/zh-cn/images/upload.png +0 -0
  189. package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -0
  190. package/ueditor-resource/plugins/demo/demo.js +3 -0
  191. package/ueditor-resource/themes/default/css/ueditor.css +2148 -0
  192. package/ueditor-resource/themes/default/dialog.css +17 -0
  193. package/ueditor-resource/themes/default/dialogbase.css +132 -0
  194. package/ueditor-resource/themes/default/exts/ai.svg +12 -0
  195. package/ueditor-resource/themes/default/exts/apk.svg +12 -0
  196. package/ueditor-resource/themes/default/exts/chm.svg +12 -0
  197. package/ueditor-resource/themes/default/exts/css.svg +12 -0
  198. package/ueditor-resource/themes/default/exts/doc.svg +22 -0
  199. package/ueditor-resource/themes/default/exts/docx.svg +22 -0
  200. package/ueditor-resource/themes/default/exts/dwg.svg +16 -0
  201. package/ueditor-resource/themes/default/exts/folder.svg +3 -0
  202. package/ueditor-resource/themes/default/exts/gif.svg +14 -0
  203. package/ueditor-resource/themes/default/exts/html.svg +12 -0
  204. package/ueditor-resource/themes/default/exts/jpeg.svg +14 -0
  205. package/ueditor-resource/themes/default/exts/jpg.svg +14 -0
  206. package/ueditor-resource/themes/default/exts/log.svg +12 -0
  207. package/ueditor-resource/themes/default/exts/mp3.svg +14 -0
  208. package/ueditor-resource/themes/default/exts/mp4.svg +12 -0
  209. package/ueditor-resource/themes/default/exts/pdf.svg +14 -0
  210. package/ueditor-resource/themes/default/exts/png.svg +14 -0
  211. package/ueditor-resource/themes/default/exts/ppt.svg +24 -0
  212. package/ueditor-resource/themes/default/exts/pptx.svg +24 -0
  213. package/ueditor-resource/themes/default/exts/psd.svg +12 -0
  214. package/ueditor-resource/themes/default/exts/rar.svg +12 -0
  215. package/ueditor-resource/themes/default/exts/svg.svg +12 -0
  216. package/ueditor-resource/themes/default/exts/torrent.svg +14 -0
  217. package/ueditor-resource/themes/default/exts/txt.svg +14 -0
  218. package/ueditor-resource/themes/default/exts/unknown.svg +12 -0
  219. package/ueditor-resource/themes/default/exts/xls.svg +25 -0
  220. package/ueditor-resource/themes/default/exts/xlsx.svg +25 -0
  221. package/ueditor-resource/themes/default/exts/zip.svg +12 -0
  222. package/ueditor-resource/themes/default/images/anchor.gif +0 -0
  223. package/ueditor-resource/themes/default/images/arrow.png +0 -0
  224. package/ueditor-resource/themes/default/images/arrow_down.png +0 -0
  225. package/ueditor-resource/themes/default/images/arrow_up.png +0 -0
  226. package/ueditor-resource/themes/default/images/button-bg.gif +0 -0
  227. package/ueditor-resource/themes/default/images/cancelbutton.gif +0 -0
  228. package/ueditor-resource/themes/default/images/charts.png +0 -0
  229. package/ueditor-resource/themes/default/images/cursor_h.gif +0 -0
  230. package/ueditor-resource/themes/default/images/cursor_h.png +0 -0
  231. package/ueditor-resource/themes/default/images/cursor_v.gif +0 -0
  232. package/ueditor-resource/themes/default/images/cursor_v.png +0 -0
  233. package/ueditor-resource/themes/default/images/dialog-title-bg.png +0 -0
  234. package/ueditor-resource/themes/default/images/filescan.png +0 -0
  235. package/ueditor-resource/themes/default/images/highlighted.gif +0 -0
  236. package/ueditor-resource/themes/default/images/icons-all.gif +0 -0
  237. package/ueditor-resource/themes/default/images/icons.gif +0 -0
  238. package/ueditor-resource/themes/default/images/icons.png +0 -0
  239. package/ueditor-resource/themes/default/images/img-cracked.png +0 -0
  240. package/ueditor-resource/themes/default/images/loaderror.png +0 -0
  241. package/ueditor-resource/themes/default/images/loading.gif +0 -0
  242. package/ueditor-resource/themes/default/images/lock.gif +0 -0
  243. package/ueditor-resource/themes/default/images/neweditor-tab-bg.png +0 -0
  244. package/ueditor-resource/themes/default/images/pagebreak.gif +0 -0
  245. package/ueditor-resource/themes/default/images/scale.png +0 -0
  246. package/ueditor-resource/themes/default/images/sortable.png +0 -0
  247. package/ueditor-resource/themes/default/images/spacer.gif +0 -0
  248. package/ueditor-resource/themes/default/images/sparator_v.png +0 -0
  249. package/ueditor-resource/themes/default/images/table-cell-align.png +0 -0
  250. package/ueditor-resource/themes/default/images/tangram-colorpicker.png +0 -0
  251. package/ueditor-resource/themes/default/images/toolbar_bg.png +0 -0
  252. package/ueditor-resource/themes/default/images/unhighlighted.gif +0 -0
  253. package/ueditor-resource/themes/default/images/upload.png +0 -0
  254. package/ueditor-resource/themes/default/images/videologo.gif +0 -0
  255. package/ueditor-resource/themes/default/images/word.gif +0 -0
  256. package/ueditor-resource/themes/default/images/wordpaste.png +0 -0
  257. package/ueditor-resource/themes/iframe.css +63 -0
  258. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -0
  259. package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
  260. package/ueditor-resource/third-party/clipboard/clipboard.js +753 -0
  261. package/ueditor-resource/third-party/clipboard/clipboard.swf +0 -0
  262. package/ueditor-resource/third-party/codemirror/codemirror.css +106 -0
  263. package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -0
  264. package/ueditor-resource/third-party/jquery-3.5.1.js +2 -0
  265. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -0
  266. package/ueditor-resource/third-party/webuploader/webuploader.css +88 -0
  267. package/ueditor-resource/third-party/webuploader/webuploader.js +4 -0
  268. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
  269. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
  270. package/ueditor-resource/ueditor.all.js +32643 -0
  271. package/ueditor-resource/ueditor.config.js +656 -0
  272. package/ueditor-resource/ueditor.parse.js +639 -0
@@ -0,0 +1,867 @@
1
+ /**
2
+ * Created by JetBrains PhpStorm.
3
+ * User: taoqili
4
+ * Date: 12-2-20
5
+ * Time: 上午11:19
6
+ * To change this template use File | Settings | File Templates.
7
+ */
8
+
9
+ (function () {
10
+
11
+ var video = {},
12
+ uploadVideoList = [],
13
+ isModifyUploadVideo = false,
14
+ uploadFile;
15
+ var editorOpt = {};
16
+
17
+ window.onload = function () {
18
+ editorOpt = editor.getOpt('videoConfig');
19
+ $focus($G("videoUrl"));
20
+ initTabs();
21
+ initVideo();
22
+ initUpload();
23
+ };
24
+
25
+ /* 初始化tab标签 */
26
+ function initTabs() {
27
+ var tabs = $G('tabHeads').children;
28
+ for (var i = 0; i < tabs.length; i++) {
29
+ domUtils.on(tabs[i], "click", function (e) {
30
+ var j, bodyId, target = e.target || e.srcElement;
31
+ for (j = 0; j < tabs.length; j++) {
32
+ bodyId = tabs[j].getAttribute('data-content-id');
33
+ if (tabs[j] == target) {
34
+ domUtils.addClass(tabs[j], 'focus');
35
+ domUtils.addClass($G(bodyId), 'focus');
36
+ } else {
37
+ domUtils.removeClasses(tabs[j], 'focus');
38
+ domUtils.removeClasses($G(bodyId), 'focus');
39
+ }
40
+ }
41
+ });
42
+ }
43
+ if (!editorOpt.disableUpload) {
44
+ $G('tabHeads').querySelector('[data-content-id="upload"]').style.display = 'inline-block';
45
+ }
46
+ if (!!editorOpt.selectCallback) {
47
+ $G('videoSelect').style.display = 'inline-block';
48
+ domUtils.on($G('videoSelect'), "click", function (e) {
49
+ editorOpt.selectCallback(editor, function (info) {
50
+ if (info) {
51
+ $G('videoUrl').value = info.path;
52
+ createPreviewVideo(info.path);
53
+ }
54
+ });
55
+ });
56
+ }
57
+ }
58
+
59
+ function initVideo() {
60
+ createAlignButton(["videoFloat", "upload_alignment"]);
61
+ addUrlChangeListener($G("videoUrl"));
62
+ addOkListener();
63
+
64
+ //编辑视频时初始化相关信息
65
+ (function () {
66
+ var img = editor.selection.getRange().getClosedNode(), url;
67
+ if (img && img.className) {
68
+ var hasFakedClass = (img.className == "edui-faked-video"),
69
+ hasUploadClass = img.className.indexOf("edui-upload-video") != -1;
70
+ if (hasFakedClass || hasUploadClass) {
71
+ $G("videoUrl").value = url = img.getAttribute("_url");
72
+ $G("videoWidth").value = img.width;
73
+ $G("videoHeight").value = img.height;
74
+ var align = domUtils.getComputedStyle(img, "float"),
75
+ parentAlign = domUtils.getComputedStyle(img.parentNode, "text-align");
76
+ updateAlignButton(parentAlign === "center" ? "center" : align);
77
+ }
78
+ if (hasUploadClass) {
79
+ isModifyUploadVideo = true;
80
+ }
81
+ }
82
+ createPreviewVideo(url);
83
+ })();
84
+ }
85
+
86
+ /**
87
+ * 监听确认和取消两个按钮事件,用户执行插入或者清空正在播放的视频实例操作
88
+ */
89
+ function addOkListener() {
90
+ dialog.onok = function () {
91
+ $G("preview").innerHTML = "";
92
+ var currentTab = findFocus("tabHeads", "tabSrc");
93
+ switch (currentTab) {
94
+ case "video":
95
+ return insertSingle();
96
+ case "videoSearch":
97
+ return insertSearch("searchList");
98
+ case "upload":
99
+ return insertUpload();
100
+ }
101
+ };
102
+ dialog.oncancel = function () {
103
+ $G("preview").innerHTML = "";
104
+ };
105
+ }
106
+
107
+ /**
108
+ * 依据传入的align值更新按钮信息
109
+ * @param align
110
+ */
111
+ function updateAlignButton(align) {
112
+ var aligns = $G("videoFloat").children;
113
+ for (var i = 0, ci; ci = aligns[i++];) {
114
+ if (ci.getAttribute("name") == align) {
115
+ if (ci.className != "focus") {
116
+ ci.className = "focus";
117
+ }
118
+ } else {
119
+ if (ci.className == "focus") {
120
+ ci.className = "";
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * 将单个视频信息插入编辑器中
128
+ */
129
+ function insertSingle() {
130
+ var width = $G("videoWidth"),
131
+ height = $G("videoHeight"),
132
+ url = $G('videoUrl').value,
133
+ align = findFocus("videoFloat", "name");
134
+ if (!url) return false;
135
+ if (!checkNum([width, height])) return false;
136
+ editor.execCommand('insertvideo', {
137
+ url: convert_url(url),
138
+ width: width.value,
139
+ height: height.value,
140
+ align: align
141
+ }, isModifyUploadVideo ? 'upload' : null);
142
+ }
143
+
144
+ /**
145
+ * 将元素id下的所有代表视频的图片插入编辑器中
146
+ * @param id
147
+ */
148
+ function insertSearch(id) {
149
+ var imgs = domUtils.getElementsByTagName($G(id), "img"),
150
+ videoObjs = [];
151
+ for (var i = 0, img; img = imgs[i++];) {
152
+ if (img.getAttribute("selected")) {
153
+ videoObjs.push({
154
+ url: img.getAttribute("ue_video_url"),
155
+ width: 420,
156
+ height: 280,
157
+ align: "none"
158
+ });
159
+ }
160
+ }
161
+ editor.execCommand('insertvideo', videoObjs);
162
+ }
163
+
164
+ /**
165
+ * 找到id下具有focus类的节点并返回该节点下的某个属性
166
+ * @param id
167
+ * @param returnProperty
168
+ */
169
+ function findFocus(id, returnProperty) {
170
+ var tabs = $G(id).children,
171
+ property;
172
+ for (var i = 0, ci; ci = tabs[i++];) {
173
+ if (ci.className == "focus") {
174
+ property = ci.getAttribute(returnProperty);
175
+ break;
176
+ }
177
+ }
178
+ return property;
179
+ }
180
+
181
+ function convert_url(url) {
182
+ if (!url) return '';
183
+ url = utils.trim(url);
184
+ // .replace(/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i, 'player.youku.com/embed/$1')
185
+ // .replace(/(www\.)?youtube\.com\/watch\?v=([\w\-]+)/i, "www.youtube.com/v/$2")
186
+ // .replace(/youtu.be\/(\w+)$/i, "www.youtube.com/v/$1")
187
+ //.replace(/www\.iqiyi\.com\/v_(\w+)\.html/i, "www.youtube.com/v/$1")
188
+ // .replace(/v\.ku6\.com\/.+\/([\w\.]+)\.html.*$/i, "player.ku6.com/refer/$1/v.swf")
189
+ // .replace(/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i, "player.56.com/v_$1.swf")
190
+ // .replace(/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i, "player.56.com/v_$1.swf")
191
+ // .replace(/v\.pps\.tv\/play_([\w]+)\.html.*$/i, "player.pps.tv/player/sid/$1/v.swf")
192
+ // .replace(/www\.letv\.com\/ptv\/vplay\/([\d]+)\.html.*$/i, "i7.imgs.letv.com/player/swfPlayer.swf?id=$1&autoplay=0")
193
+ // .replace(/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i, "www.tudou.com/v/$1")
194
+ // https://v.qq.com/x/cover/wagzbx91asjomnu/w05337nxfof.html
195
+ // https://v.qq.com/iframe/player.html?vid=w05337nxfof&tiny=0&auto=0
196
+ // .replace(/v\.qq\.com\/x\/cover\/[\w]+\/([\w]+)\.html/i, "v.qq.com/iframe/player.html?vid=$1&tiny=0&auto=0")
197
+ // .replace(/v\.qq\.com\/x\/page\/([\w]+)\.html/i, "v.qq.com/iframe/player.html?vid=$1&tiny=0&auto=0")
198
+ // .replace(/www\.bilibili\.com\/video\/([a-zA-Z0-9]+)\/?.*$/i, "player.bilibili.com/player.html?bvid=$1")
199
+ // .replace(/v\.qq\.com\/cover\/[\w]+\/[\w]+\/([\w]+)\.html/i, "static.video.qq.com/TPout.swf?vid=$1")
200
+ // .replace(/v\.qq\.com\/.+[\?\&]vid=([^&]+).*$/i, "static.video.qq.com/TPout.swf?vid=$1")
201
+ // .replace(/my\.tv\.sohu\.com\/[\w]+\/[\d]+\/([\d]+)\.shtml.*$/i, "share.vrs.sohu.com/my/v.swf&id=$1")
202
+ ;
203
+ return url;
204
+ }
205
+
206
+ /**
207
+ * 检测传入的所有input框中输入的长宽是否是正数
208
+ * @param nodes input框集合,
209
+ */
210
+ function checkNum(nodes) {
211
+ for (var i = 0, ci; ci = nodes[i++];) {
212
+ var value = ci.value;
213
+ if (!isNumber(value) && value) {
214
+ alert(lang.numError);
215
+ ci.value = "";
216
+ ci.focus();
217
+ return false;
218
+ }
219
+ }
220
+ return true;
221
+ }
222
+
223
+ /**
224
+ * 数字判断
225
+ * @param value
226
+ */
227
+ function isNumber(value) {
228
+ return /(0|^[1-9]\d*$)/.test(value);
229
+ }
230
+
231
+ /**
232
+ * 创建图片浮动选择按钮
233
+ * @param ids
234
+ */
235
+ function createAlignButton(ids) {
236
+ for (var i = 0, ci; ci = ids[i++];) {
237
+ var floatContainer = $G(ci),
238
+ nameMaps = {
239
+ "none": lang['default'],
240
+ "left": lang.floatLeft,
241
+ "right": lang.floatRight,
242
+ "center": lang.block
243
+ };
244
+ for (var j in nameMaps) {
245
+ var div = document.createElement("div");
246
+ div.setAttribute("name", j);
247
+ if (j == "none") {
248
+ div.className = "focus"
249
+ div.style.cssText = "background-image:url(icon/" + j + "-active.png);";
250
+ } else {
251
+ div.style.cssText = "background-image:url(icon/" + j + ".png);";
252
+ }
253
+ div.setAttribute("title", nameMaps[j]);
254
+ floatContainer.appendChild(div);
255
+ }
256
+ switchSelect(ci);
257
+ }
258
+ }
259
+
260
+ /**
261
+ * 选择切换
262
+ * @param selectParentId
263
+ */
264
+ function switchSelect(selectParentId) {
265
+ var selects = $G(selectParentId).children;
266
+ for (var i = 0, ci; ci = selects[i++];) {
267
+ domUtils.on(ci, "click", function () {
268
+ for (var j = 0, cj; cj = selects[j++];) {
269
+ cj.className = "";
270
+ cj.style.cssText = "background-image:url(icon/" + cj.getAttribute('name') + ".png);";
271
+ cj.removeAttribute && cj.removeAttribute("class");
272
+ }
273
+ this.className = "focus";
274
+ this.style.cssText = "background-image:url(icon/" + this.getAttribute('name') + "-active.png);";
275
+ })
276
+ }
277
+ }
278
+
279
+ /**
280
+ * 监听url改变事件
281
+ * @param url
282
+ */
283
+ function addUrlChangeListener(url) {
284
+ if (browser.ie) {
285
+ url.onpropertychange = function () {
286
+ createPreviewVideo(this.value);
287
+ }
288
+ } else {
289
+ url.addEventListener("input", function () {
290
+ createPreviewVideo(this.value);
291
+ }, false);
292
+ }
293
+ }
294
+
295
+ /**
296
+ * 根据url生成视频预览
297
+ * @param url
298
+ */
299
+ function createPreviewVideo(url) {
300
+ const location = window.parent.location;
301
+ const host = location.protocol + '//' + location.host + location.pathname;
302
+ if (!url) return;
303
+
304
+ var conUrl = convert_url(url);
305
+
306
+ conUrl = utils.unhtml(conUrl);
307
+
308
+ $G("preview").innerHTML = '<div class="previewMsg"><span>' + lang.urlError + '</span></div>' +
309
+ '<iframe class="previewVideo" ' +
310
+ ' src="' + host + conUrl + '"' +
311
+ ' width="' + 420 + '"' +
312
+ ' height="' + 280 + '"' +
313
+ ' frameborder=0 allowfullscreen>' +
314
+ '</iframe>';
315
+ }
316
+
317
+
318
+ /* 插入上传视频 */
319
+ function insertUpload() {
320
+ var videoObjs = [],
321
+ uploadDir = editor.getOpt('videoUrlPrefix'),
322
+ width = $G('upload_width').value || 420,
323
+ height = $G('upload_height').value || 280,
324
+ align = findFocus("upload_alignment", "name") || 'none';
325
+ for (var key in uploadVideoList) {
326
+ var file = uploadVideoList[key];
327
+ videoObjs.push({
328
+ url: uploadDir + file.url,
329
+ width: width,
330
+ height: height,
331
+ align: align
332
+ });
333
+ }
334
+
335
+ var count = uploadFile.getQueueCount();
336
+ if (count) {
337
+ $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
338
+ return false;
339
+ } else {
340
+ editor.execCommand('insertvideo', videoObjs, 'upload');
341
+ }
342
+ }
343
+
344
+ /*初始化上传标签*/
345
+ function initUpload() {
346
+ uploadFile = new UploadFile('queueList');
347
+ }
348
+
349
+
350
+ /* 上传附件 */
351
+ function UploadFile(target) {
352
+ this.$wrap = target.constructor == String ? $('#' + target) : $(target);
353
+ this.init();
354
+ }
355
+
356
+ UploadFile.prototype = {
357
+ init: function () {
358
+ this.fileList = [];
359
+ this.initContainer();
360
+ this.initUploader();
361
+ },
362
+ initContainer: function () {
363
+ this.$queue = this.$wrap.find('.filelist');
364
+ },
365
+ /* 初始化容器 */
366
+ initUploader: function () {
367
+ var _this = this,
368
+ $ = jQuery, // just in case. Make sure it's not an other libaray.
369
+ $wrap = _this.$wrap,
370
+ // 图片容器
371
+ $queue = $wrap.find('.filelist'),
372
+ // 状态栏,包括进度和控制按钮
373
+ $statusBar = $wrap.find('.statusBar'),
374
+ // 文件总体选择信息。
375
+ $info = $statusBar.find('.info'),
376
+ // 上传按钮
377
+ $upload = $wrap.find('.uploadBtn'),
378
+ // 上传按钮
379
+ $filePickerBtn = $wrap.find('.filePickerBtn'),
380
+ // 上传按钮
381
+ $filePickerBlock = $wrap.find('.filePickerBlock'),
382
+ // 没选择文件之前的内容。
383
+ $placeHolder = $wrap.find('.placeholder'),
384
+ // 总体进度条
385
+ $progress = $statusBar.find('.progress').hide(),
386
+ // 添加的文件数量
387
+ fileCount = 0,
388
+ // 添加的文件总大小
389
+ fileSize = 0,
390
+ // 优化retina, 在retina下这个值是2
391
+ ratio = window.devicePixelRatio || 1,
392
+ // 缩略图大小
393
+ thumbnailWidth = 113 * ratio,
394
+ thumbnailHeight = 113 * ratio,
395
+ // 可能有pedding, ready, uploading, confirm, done.
396
+ state = '',
397
+ // 所有文件的进度信息,key为file id
398
+ percentages = {},
399
+ supportTransition = (function () {
400
+ var s = document.createElement('p').style,
401
+ r = 'transition' in s ||
402
+ 'WebkitTransition' in s ||
403
+ 'MozTransition' in s ||
404
+ 'msTransition' in s ||
405
+ 'OTransition' in s;
406
+ s = null;
407
+ return r;
408
+ })(),
409
+ // WebUploader实例
410
+ uploader,
411
+ actionUrl = editor.getActionUrl(editor.getOpt('videoActionName')),
412
+ fileMaxSize = editor.getOpt('videoMaxSize'),
413
+ acceptExtensions = (editor.getOpt('videoAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');
414
+ // 隐藏上传按钮
415
+ $upload.hide();
416
+
417
+ if (!WebUploader.Uploader.support()) {
418
+ $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
419
+ return;
420
+ } else if (!editor.getOpt('videoActionName')) {
421
+ $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
422
+ return;
423
+ }
424
+
425
+ uploader = _this.uploader = WebUploader.create({
426
+ pick: {
427
+ id: '#filePickerReady',
428
+ label: lang.uploadSelectFile
429
+ },
430
+ swf: '../../third-party/webuploader/Uploader.swf',
431
+ server: actionUrl,
432
+ fileVal: editor.getOpt('videoFieldName'),
433
+ duplicate: true,
434
+ fileSingleSizeLimit: fileMaxSize,
435
+ headers: editor.getOpt('serverHeaders') || {},
436
+ compress: false
437
+ });
438
+ uploader.addButton({
439
+ id: '#filePickerBlock'
440
+ });
441
+ uploader.addButton({
442
+ id: '#filePickerBtn',
443
+ label: lang.uploadAddFile
444
+ });
445
+
446
+ setState('pedding');
447
+
448
+ // 当有文件添加进来时执行,负责view的创建
449
+ function addFile(file) {
450
+ var $li = $('<li id="' + file.id + '">' +
451
+ '<p class="title">' + file.name + '</p>' +
452
+ '<p class="imgWrap"></p>' +
453
+ '<p class="progress"><span></span></p>' +
454
+ '</li>'),
455
+
456
+ $btns = $('<div class="file-panel">' +
457
+ '<span class="cancel">' + lang.uploadDelete + '</span>' +
458
+ '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
459
+ '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
460
+ $prgress = $li.find('p.progress span'),
461
+ $wrap = $li.find('p.imgWrap'),
462
+ $info = $('<p class="error"></p>').hide().appendTo($li),
463
+
464
+ showError = function (code) {
465
+ switch (code) {
466
+ case 'exceed_size':
467
+ text = lang.errorExceedSize;
468
+ break;
469
+ case 'interrupt':
470
+ text = lang.errorInterrupt;
471
+ break;
472
+ case 'http':
473
+ text = lang.errorHttp;
474
+ break;
475
+ case 'not_allow_type':
476
+ text = lang.errorFileType;
477
+ break;
478
+ default:
479
+ text = lang.errorUploadRetry;
480
+ break;
481
+ }
482
+ $info.text(text).show();
483
+ };
484
+
485
+ if (file.getStatus() === 'invalid') {
486
+ showError(file.statusText);
487
+ } else {
488
+ $wrap.text(lang.uploadPreview);
489
+ if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|' + file.ext.toLowerCase() + '|') == -1) {
490
+ $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
491
+ '<span class="file-title">' + file.name + '</span>');
492
+ } else {
493
+ if (browser.ie && browser.version <= 7) {
494
+ $wrap.text(lang.uploadNoPreview);
495
+ } else {
496
+ uploader.makeThumb(file, function (error, src) {
497
+ if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
498
+ $wrap.text(lang.uploadNoPreview);
499
+ } else {
500
+ var $img = $('<img src="' + src + '">');
501
+ $wrap.empty().append($img);
502
+ $img.on('error', function () {
503
+ $wrap.text(lang.uploadNoPreview);
504
+ });
505
+ }
506
+ }, thumbnailWidth, thumbnailHeight);
507
+ }
508
+ }
509
+ percentages[file.id] = [file.size, 0];
510
+ file.rotation = 0;
511
+
512
+ /* 检查文件格式 */
513
+ if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
514
+ showError('not_allow_type');
515
+ uploader.removeFile(file);
516
+ }
517
+ }
518
+
519
+ file.on('statuschange', function (cur, prev) {
520
+ if (prev === 'progress') {
521
+ $prgress.hide().width(0);
522
+ } else if (prev === 'queued') {
523
+ $li.off('mouseenter mouseleave');
524
+ $btns.remove();
525
+ }
526
+ // 成功
527
+ if (cur === 'error' || cur === 'invalid') {
528
+ showError(file.statusText);
529
+ percentages[file.id][1] = 1;
530
+ } else if (cur === 'interrupt') {
531
+ showError('interrupt');
532
+ } else if (cur === 'queued') {
533
+ percentages[file.id][1] = 0;
534
+ } else if (cur === 'progress') {
535
+ $info.hide();
536
+ $prgress.css('display', 'block');
537
+ } else if (cur === 'complete') {
538
+ }
539
+
540
+ $li.removeClass('state-' + prev).addClass('state-' + cur);
541
+ });
542
+
543
+ $li.on('mouseenter', function () {
544
+ $btns.stop().animate({ height: 30 });
545
+ });
546
+ $li.on('mouseleave', function () {
547
+ $btns.stop().animate({ height: 0 });
548
+ });
549
+
550
+ $btns.on('click', 'span', function () {
551
+ var index = $(this).index(),
552
+ deg;
553
+
554
+ switch (index) {
555
+ case 0:
556
+ uploader.removeFile(file);
557
+ return;
558
+ case 1:
559
+ file.rotation += 90;
560
+ break;
561
+ case 2:
562
+ file.rotation -= 90;
563
+ break;
564
+ }
565
+
566
+ if (supportTransition) {
567
+ deg = 'rotate(' + file.rotation + 'deg)';
568
+ $wrap.css({
569
+ '-webkit-transform': deg,
570
+ '-mos-transform': deg,
571
+ '-o-transform': deg,
572
+ 'transform': deg
573
+ });
574
+ } else {
575
+ $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
576
+ }
577
+
578
+ });
579
+
580
+ $li.insertBefore($filePickerBlock);
581
+ }
582
+
583
+ // 负责view的销毁
584
+ function removeFile(file) {
585
+ var $li = $('#' + file.id);
586
+ delete percentages[file.id];
587
+ updateTotalProgress();
588
+ $li.off().find('.file-panel').off().end().remove();
589
+ }
590
+
591
+ function updateTotalProgress() {
592
+ var loaded = 0,
593
+ total = 0,
594
+ spans = $progress.children(),
595
+ percent;
596
+
597
+ $.each(percentages, function (k, v) {
598
+ total += v[0];
599
+ loaded += v[0] * v[1];
600
+ });
601
+
602
+ percent = total ? loaded / total : 0;
603
+
604
+ spans.eq(0).text(Math.round(percent * 100) + '%');
605
+ spans.eq(1).css('width', Math.round(percent * 100) + '%');
606
+ updateStatus();
607
+ }
608
+
609
+ function setState(val, files) {
610
+
611
+ if (val != state) {
612
+
613
+ var stats = uploader.getStats();
614
+
615
+ $upload.removeClass('state-' + state);
616
+ $upload.addClass('state-' + val);
617
+
618
+ switch (val) {
619
+
620
+ /* 未选择文件 */
621
+ case 'pedding':
622
+ $queue.addClass('element-invisible');
623
+ $statusBar.addClass('element-invisible');
624
+ $placeHolder.removeClass('element-invisible');
625
+ $progress.hide();
626
+ $info.hide();
627
+ uploader.refresh();
628
+ break;
629
+
630
+ /* 可以开始上传 */
631
+ case 'ready':
632
+ $placeHolder.addClass('element-invisible');
633
+ $queue.removeClass('element-invisible');
634
+ $statusBar.removeClass('element-invisible');
635
+ $progress.hide();
636
+ $info.show();
637
+ $upload.text(lang.uploadStart);
638
+ uploader.refresh();
639
+ break;
640
+
641
+ /* 上传中 */
642
+ case 'uploading':
643
+ $progress.show();
644
+ $info.hide();
645
+ $upload.text(lang.uploadPause);
646
+ break;
647
+
648
+ /* 暂停上传 */
649
+ case 'paused':
650
+ $progress.show();
651
+ $info.hide();
652
+ $upload.text(lang.uploadContinue);
653
+ break;
654
+
655
+ case 'confirm':
656
+ $progress.show();
657
+ $info.hide();
658
+ $upload.text(lang.uploadStart);
659
+
660
+ stats = uploader.getStats();
661
+ if (stats.successNum && !stats.uploadFailNum) {
662
+ setState('finish');
663
+ return;
664
+ }
665
+ break;
666
+
667
+ case 'finish':
668
+ $progress.hide();
669
+ $info.show();
670
+ if (stats.uploadFailNum) {
671
+ $upload.text(lang.uploadRetry);
672
+ } else {
673
+ $upload.text(lang.uploadStart);
674
+ }
675
+ break;
676
+ }
677
+
678
+ state = val;
679
+ updateStatus();
680
+
681
+ }
682
+
683
+ if (!_this.getQueueCount()) {
684
+ $upload.addClass('disabled')
685
+ } else {
686
+ $upload.removeClass('disabled')
687
+ }
688
+
689
+ }
690
+
691
+ function updateStatus() {
692
+ var text = '', stats;
693
+
694
+ if (state === 'ready') {
695
+ text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
696
+ } else if (state === 'confirm') {
697
+ stats = uploader.getStats();
698
+ if (stats.uploadFailNum) {
699
+ text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
700
+ }
701
+ } else {
702
+ stats = uploader.getStats();
703
+ text = lang.updateStatusFinish.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)).replace('_', stats.successNum);
704
+
705
+ if (stats.uploadFailNum) {
706
+ text += lang.updateStatusError.replace('_', stats.uploadFailNum);
707
+ }
708
+ }
709
+
710
+ $info.html(text);
711
+ }
712
+
713
+ /**
714
+ * 前置校验
715
+ */
716
+ uploader.on('beforeFileQueued', function (file) {
717
+ if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1) {
718
+ return true;
719
+ }
720
+ return false;
721
+ })
722
+
723
+ uploader.on('fileQueued', function (file) {
724
+ fileCount++;
725
+ fileSize += file.size;
726
+
727
+ if (fileCount === 1) {
728
+ $placeHolder.addClass('element-invisible');
729
+ $statusBar.show();
730
+ }
731
+
732
+ addFile(file);
733
+
734
+ const uploadFunc = editor.getOpt('uploadFunction');
735
+ if (typeof uploadFunc === 'function') {
736
+ // 开始上传
737
+ if (state === 'ready') {
738
+ setState('uploading');
739
+ } else if (state === 'pedding') {
740
+ setState('ready');
741
+ setState('uploading');
742
+ }
743
+ file.setStatus('progress');
744
+ uploader.trigger('uploadProgress', file, 0);
745
+ uploadFunc(file.source.source).then(function (response) {
746
+ uploader.trigger('uploadProgress', file, 1);
747
+ file.setStatus('complete');
748
+ setState('finish');
749
+ uploader.trigger('uploadSuccess', file, response);
750
+ uploader.trigger('uploadComplete', file);
751
+ });
752
+ }
753
+ });
754
+
755
+ uploader.on('fileDequeued', function (file) {
756
+ fileCount--;
757
+ fileSize -= file.size;
758
+
759
+ removeFile(file);
760
+ updateTotalProgress();
761
+ });
762
+
763
+ uploader.on('filesQueued', function (file) {
764
+ if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
765
+ setState('ready');
766
+ }
767
+ updateTotalProgress();
768
+ });
769
+
770
+ uploader.on('all', function (type, files) {
771
+ switch (type) {
772
+ case 'uploadFinished':
773
+ setState('confirm', files);
774
+ break;
775
+ case 'startUpload':
776
+ /* 添加额外的GET参数 */
777
+ var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
778
+ url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + 'encode=utf-8&' + params);
779
+ uploader.option('server', url);
780
+ setState('uploading', files);
781
+ break;
782
+ case 'stopUpload':
783
+ setState('paused', files);
784
+ break;
785
+ }
786
+ });
787
+
788
+ uploader.on('uploadBeforeSend', function (file, data, header) {
789
+ //这里可以通过data对象添加POST参数
790
+ if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
791
+ header['X_Requested_With'] = 'XMLHttpRequest';
792
+ }
793
+ });
794
+
795
+ uploader.on('uploadProgress', function (file, percentage) {
796
+ var $li = $('#' + file.id),
797
+ $percent = $li.find('.progress span');
798
+
799
+ $percent.css('width', percentage * 100 + '%');
800
+ percentages[file.id][1] = percentage;
801
+ updateTotalProgress();
802
+ });
803
+
804
+ uploader.on('uploadSuccess', function (file, json) {
805
+ var $file = $('#' + file.id);
806
+ try {
807
+ if (json.state == 'SUCCESS') {
808
+ uploadVideoList.push({
809
+ 'url': json.url,
810
+ 'type': json.type,
811
+ 'original': json.original
812
+ });
813
+ $file.append('<span class="success"></span>');
814
+ // 触发上传视频事件
815
+ editor.fireEvent("uploadsuccess", {
816
+ res: json,
817
+ type: 'video'
818
+ });
819
+ } else {
820
+ $file.find('.error').text(json.state).show();
821
+ }
822
+ } catch (e) {
823
+ $file.find('.error').text(lang.errorServerUpload).show();
824
+ }
825
+ });
826
+
827
+ uploader.on('uploadError', function (file, code) {
828
+ });
829
+ uploader.on('error', function (code, file) {
830
+ if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
831
+ addFile(file);
832
+ }
833
+ });
834
+ uploader.on('uploadComplete', function (file, ret) {
835
+ });
836
+
837
+ $upload.on('click', function () {
838
+ if ($(this).hasClass('disabled')) {
839
+ return false;
840
+ }
841
+
842
+ if (state === 'ready') {
843
+ uploader.upload();
844
+ } else if (state === 'paused') {
845
+ uploader.upload();
846
+ } else if (state === 'uploading') {
847
+ uploader.stop();
848
+ }
849
+ });
850
+
851
+ $upload.addClass('state-' + state);
852
+ updateTotalProgress();
853
+ },
854
+ getQueueCount: function () {
855
+ var file, i, status, readyFile = 0, files = this.uploader.getFiles();
856
+ for (i = 0; file = files[i++];) {
857
+ status = file.getStatus();
858
+ if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
859
+ }
860
+ return readyFile;
861
+ },
862
+ refresh: function () {
863
+ this.uploader.refresh();
864
+ }
865
+ };
866
+
867
+ })();