@mnykj/alleditor-vue 0.0.0-stage → 1.3.2

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 (291) hide show
  1. package/README.md +51 -2
  2. package/nuxt.ts +67 -0
  3. package/package.json +62 -4
  4. package/scripts/sync-ueditor.mjs +28 -0
  5. package/src/AllEditor.vue +669 -0
  6. package/src/DualEditor.vue +7 -0
  7. package/src/UeHtmlEngine.vue +438 -0
  8. package/src/assets/iconfont/iconfont.css +27 -0
  9. package/src/assets/iconfont/iconfont.ttf +0 -0
  10. package/src/assets/iconfont/iconfont.woff +0 -0
  11. package/src/assets/iconfont/iconfont.woff2 +0 -0
  12. package/src/defaultToolbar.ts +115 -0
  13. package/src/importMenus.ts +158 -0
  14. package/src/index.ts +58 -0
  15. package/src/markdown.ts +46 -0
  16. package/src/stripJavascriptFromHtml.ts +28 -0
  17. package/src/ueToolbar.ts +257 -0
  18. package/src/ueditorBase.ts +2 -0
  19. package/src/ueditorPaths.ts +11 -0
  20. package/ueditor/dialogs/anchor/anchor.html +40 -0
  21. package/ueditor/dialogs/attachment/attachment.css +681 -0
  22. package/ueditor/dialogs/attachment/attachment.html +60 -0
  23. package/ueditor/dialogs/attachment/attachment.js +760 -0
  24. package/ueditor/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
  25. package/ueditor/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
  26. package/ueditor/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
  27. package/ueditor/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
  28. package/ueditor/dialogs/attachment/fileTypeImages/icon_jpg.gif +0 -0
  29. package/ueditor/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
  30. package/ueditor/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
  31. package/ueditor/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
  32. package/ueditor/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
  33. package/ueditor/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
  34. package/ueditor/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
  35. package/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
  36. package/ueditor/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
  37. package/ueditor/dialogs/attachment/images/alignicon.gif +0 -0
  38. package/ueditor/dialogs/attachment/images/alignicon.png +0 -0
  39. package/ueditor/dialogs/attachment/images/bg.png +0 -0
  40. package/ueditor/dialogs/attachment/images/file-icons.gif +0 -0
  41. package/ueditor/dialogs/attachment/images/file-icons.png +0 -0
  42. package/ueditor/dialogs/attachment/images/icons.gif +0 -0
  43. package/ueditor/dialogs/attachment/images/icons.png +0 -0
  44. package/ueditor/dialogs/attachment/images/image.png +0 -0
  45. package/ueditor/dialogs/attachment/images/progress.png +0 -0
  46. package/ueditor/dialogs/attachment/images/success.gif +0 -0
  47. package/ueditor/dialogs/attachment/images/success.png +0 -0
  48. package/ueditor/dialogs/background/background.css +94 -0
  49. package/ueditor/dialogs/background/background.html +56 -0
  50. package/ueditor/dialogs/background/background.js +376 -0
  51. package/ueditor/dialogs/background/images/bg.png +0 -0
  52. package/ueditor/dialogs/background/images/success.png +0 -0
  53. package/ueditor/dialogs/charts/chart.config.js +65 -0
  54. package/ueditor/dialogs/charts/charts.css +165 -0
  55. package/ueditor/dialogs/charts/charts.html +89 -0
  56. package/ueditor/dialogs/charts/charts.js +519 -0
  57. package/ueditor/dialogs/charts/images/charts0.png +0 -0
  58. package/ueditor/dialogs/charts/images/charts1.png +0 -0
  59. package/ueditor/dialogs/charts/images/charts2.png +0 -0
  60. package/ueditor/dialogs/charts/images/charts3.png +0 -0
  61. package/ueditor/dialogs/charts/images/charts4.png +0 -0
  62. package/ueditor/dialogs/charts/images/charts5.png +0 -0
  63. package/ueditor/dialogs/emotion/emotion.css +43 -0
  64. package/ueditor/dialogs/emotion/emotion.html +54 -0
  65. package/ueditor/dialogs/emotion/emotion.js +186 -0
  66. package/ueditor/dialogs/emotion/images/0.gif +0 -0
  67. package/ueditor/dialogs/emotion/images/bface.gif +0 -0
  68. package/ueditor/dialogs/emotion/images/cface.gif +0 -0
  69. package/ueditor/dialogs/emotion/images/fface.gif +0 -0
  70. package/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
  71. package/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  72. package/ueditor/dialogs/emotion/images/tface.gif +0 -0
  73. package/ueditor/dialogs/emotion/images/wface.gif +0 -0
  74. package/ueditor/dialogs/emotion/images/yface.gif +0 -0
  75. package/ueditor/dialogs/gmap/gmap.html +89 -0
  76. package/ueditor/dialogs/help/help.css +7 -0
  77. package/ueditor/dialogs/help/help.html +82 -0
  78. package/ueditor/dialogs/help/help.js +56 -0
  79. package/ueditor/dialogs/image/image.css +894 -0
  80. package/ueditor/dialogs/image/image.html +120 -0
  81. package/ueditor/dialogs/image/image.js +1123 -0
  82. package/ueditor/dialogs/image/images/alignicon.jpg +0 -0
  83. package/ueditor/dialogs/image/images/bg.png +0 -0
  84. package/ueditor/dialogs/image/images/icons.gif +0 -0
  85. package/ueditor/dialogs/image/images/icons.png +0 -0
  86. package/ueditor/dialogs/image/images/image.png +0 -0
  87. package/ueditor/dialogs/image/images/progress.png +0 -0
  88. package/ueditor/dialogs/image/images/success.gif +0 -0
  89. package/ueditor/dialogs/image/images/success.png +0 -0
  90. package/ueditor/dialogs/insertframe/insertframe.html +98 -0
  91. package/ueditor/dialogs/internal.js +81 -0
  92. package/ueditor/dialogs/link/link.html +132 -0
  93. package/ueditor/dialogs/map/map.html +135 -0
  94. package/ueditor/dialogs/map/show.html +118 -0
  95. package/ueditor/dialogs/music/music.css +30 -0
  96. package/ueditor/dialogs/music/music.html +32 -0
  97. package/ueditor/dialogs/music/music.js +192 -0
  98. package/ueditor/dialogs/preview/preview.html +40 -0
  99. package/ueditor/dialogs/scrawl/images/addimg.png +0 -0
  100. package/ueditor/dialogs/scrawl/images/brush.png +0 -0
  101. package/ueditor/dialogs/scrawl/images/delimg.png +0 -0
  102. package/ueditor/dialogs/scrawl/images/delimgH.png +0 -0
  103. package/ueditor/dialogs/scrawl/images/empty.png +0 -0
  104. package/ueditor/dialogs/scrawl/images/emptyH.png +0 -0
  105. package/ueditor/dialogs/scrawl/images/eraser.png +0 -0
  106. package/ueditor/dialogs/scrawl/images/redo.png +0 -0
  107. package/ueditor/dialogs/scrawl/images/redoH.png +0 -0
  108. package/ueditor/dialogs/scrawl/images/scale.png +0 -0
  109. package/ueditor/dialogs/scrawl/images/scaleH.png +0 -0
  110. package/ueditor/dialogs/scrawl/images/size.png +0 -0
  111. package/ueditor/dialogs/scrawl/images/undo.png +0 -0
  112. package/ueditor/dialogs/scrawl/images/undoH.png +0 -0
  113. package/ueditor/dialogs/scrawl/scrawl.css +72 -0
  114. package/ueditor/dialogs/scrawl/scrawl.html +95 -0
  115. package/ueditor/dialogs/scrawl/scrawl.js +670 -0
  116. package/ueditor/dialogs/searchreplace/searchreplace.html +102 -0
  117. package/ueditor/dialogs/searchreplace/searchreplace.js +170 -0
  118. package/ueditor/dialogs/snapscreen/snapscreen.html +58 -0
  119. package/ueditor/dialogs/spechars/spechars.html +21 -0
  120. package/ueditor/dialogs/spechars/spechars.js +57 -0
  121. package/ueditor/dialogs/table/dragicon.png +0 -0
  122. package/ueditor/dialogs/table/edittable.css +84 -0
  123. package/ueditor/dialogs/table/edittable.html +64 -0
  124. package/ueditor/dialogs/table/edittable.js +237 -0
  125. package/ueditor/dialogs/table/edittd.html +61 -0
  126. package/ueditor/dialogs/table/edittip.html +33 -0
  127. package/ueditor/dialogs/template/config.js +42 -0
  128. package/ueditor/dialogs/template/images/bg.gif +0 -0
  129. package/ueditor/dialogs/template/images/pre0.png +0 -0
  130. package/ueditor/dialogs/template/images/pre1.png +0 -0
  131. package/ueditor/dialogs/template/images/pre2.png +0 -0
  132. package/ueditor/dialogs/template/images/pre3.png +0 -0
  133. package/ueditor/dialogs/template/images/pre4.png +0 -0
  134. package/ueditor/dialogs/template/template.css +18 -0
  135. package/ueditor/dialogs/template/template.html +26 -0
  136. package/ueditor/dialogs/template/template.js +53 -0
  137. package/ueditor/dialogs/video/images/bg.png +0 -0
  138. package/ueditor/dialogs/video/images/center_focus.jpg +0 -0
  139. package/ueditor/dialogs/video/images/file-icons.gif +0 -0
  140. package/ueditor/dialogs/video/images/file-icons.png +0 -0
  141. package/ueditor/dialogs/video/images/icons.gif +0 -0
  142. package/ueditor/dialogs/video/images/icons.png +0 -0
  143. package/ueditor/dialogs/video/images/image.png +0 -0
  144. package/ueditor/dialogs/video/images/left_focus.jpg +0 -0
  145. package/ueditor/dialogs/video/images/none_focus.jpg +0 -0
  146. package/ueditor/dialogs/video/images/progress.png +0 -0
  147. package/ueditor/dialogs/video/images/right_focus.jpg +0 -0
  148. package/ueditor/dialogs/video/images/success.gif +0 -0
  149. package/ueditor/dialogs/video/images/success.png +0 -0
  150. package/ueditor/dialogs/video/video.css +635 -0
  151. package/ueditor/dialogs/video/video.html +86 -0
  152. package/ueditor/dialogs/video/video.js +791 -0
  153. package/ueditor/dialogs/webapp/webapp.html +53 -0
  154. package/ueditor/dialogs/wordimage/fClipboard_ueditor.swf +0 -0
  155. package/ueditor/dialogs/wordimage/imageUploader.swf +0 -0
  156. package/ueditor/dialogs/wordimage/tangram.js +1495 -0
  157. package/ueditor/dialogs/wordimage/wordimage.html +111 -0
  158. package/ueditor/dialogs/wordimage/wordimage.js +157 -0
  159. package/ueditor/lang/en/en.js +684 -0
  160. package/ueditor/lang/en/images/addimage.png +0 -0
  161. package/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
  162. package/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
  163. package/ueditor/lang/en/images/background.png +0 -0
  164. package/ueditor/lang/en/images/button.png +0 -0
  165. package/ueditor/lang/en/images/copy.png +0 -0
  166. package/ueditor/lang/en/images/deletedisable.png +0 -0
  167. package/ueditor/lang/en/images/deleteenable.png +0 -0
  168. package/ueditor/lang/en/images/listbackground.png +0 -0
  169. package/ueditor/lang/en/images/localimage.png +0 -0
  170. package/ueditor/lang/en/images/music.png +0 -0
  171. package/ueditor/lang/en/images/rotateleftdisable.png +0 -0
  172. package/ueditor/lang/en/images/rotateleftenable.png +0 -0
  173. package/ueditor/lang/en/images/rotaterightdisable.png +0 -0
  174. package/ueditor/lang/en/images/rotaterightenable.png +0 -0
  175. package/ueditor/lang/en/images/upload.png +0 -0
  176. package/ueditor/lang/zh-cn/images/copy.png +0 -0
  177. package/ueditor/lang/zh-cn/images/localimage.png +0 -0
  178. package/ueditor/lang/zh-cn/images/music.png +0 -0
  179. package/ueditor/lang/zh-cn/images/upload.png +0 -0
  180. package/ueditor/lang/zh-cn/zh-cn.js +669 -0
  181. package/ueditor/official-demo.html +175 -0
  182. package/ueditor/themes/default/css/ueditor.css +1906 -0
  183. package/ueditor/themes/default/css/ueditor.min.css +8 -0
  184. package/ueditor/themes/default/dialogbase.css +100 -0
  185. package/ueditor/themes/default/images/anchor.gif +0 -0
  186. package/ueditor/themes/default/images/arrow.png +0 -0
  187. package/ueditor/themes/default/images/arrow_down.png +0 -0
  188. package/ueditor/themes/default/images/arrow_up.png +0 -0
  189. package/ueditor/themes/default/images/button-bg.gif +0 -0
  190. package/ueditor/themes/default/images/cancelbutton.gif +0 -0
  191. package/ueditor/themes/default/images/charts.png +0 -0
  192. package/ueditor/themes/default/images/cursor_h.gif +0 -0
  193. package/ueditor/themes/default/images/cursor_h.png +0 -0
  194. package/ueditor/themes/default/images/cursor_v.gif +0 -0
  195. package/ueditor/themes/default/images/cursor_v.png +0 -0
  196. package/ueditor/themes/default/images/dialog-title-bg.png +0 -0
  197. package/ueditor/themes/default/images/filescan.png +0 -0
  198. package/ueditor/themes/default/images/highlighted.gif +0 -0
  199. package/ueditor/themes/default/images/icons-all.gif +0 -0
  200. package/ueditor/themes/default/images/icons.gif +0 -0
  201. package/ueditor/themes/default/images/icons.png +0 -0
  202. package/ueditor/themes/default/images/img-cracked.png +0 -0
  203. package/ueditor/themes/default/images/loaderror.png +0 -0
  204. package/ueditor/themes/default/images/loading.gif +0 -0
  205. package/ueditor/themes/default/images/lock.gif +0 -0
  206. package/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
  207. package/ueditor/themes/default/images/pagebreak.gif +0 -0
  208. package/ueditor/themes/default/images/scale.png +0 -0
  209. package/ueditor/themes/default/images/sortable.png +0 -0
  210. package/ueditor/themes/default/images/spacer.gif +0 -0
  211. package/ueditor/themes/default/images/sparator_v.png +0 -0
  212. package/ueditor/themes/default/images/table-cell-align.png +0 -0
  213. package/ueditor/themes/default/images/tangram-colorpicker.png +0 -0
  214. package/ueditor/themes/default/images/toolbar_bg.png +0 -0
  215. package/ueditor/themes/default/images/unhighlighted.gif +0 -0
  216. package/ueditor/themes/default/images/upload.png +0 -0
  217. package/ueditor/themes/default/images/videologo.gif +0 -0
  218. package/ueditor/themes/default/images/word.gif +0 -0
  219. package/ueditor/themes/default/images/wordpaste.png +0 -0
  220. package/ueditor/themes/iframe.css +1 -0
  221. package/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
  222. package/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
  223. package/ueditor/third-party/codemirror/codemirror.css +104 -0
  224. package/ueditor/third-party/codemirror/codemirror.js +3581 -0
  225. package/ueditor/third-party/highcharts/adapters/mootools-adapter.js +13 -0
  226. package/ueditor/third-party/highcharts/adapters/mootools-adapter.src.js +313 -0
  227. package/ueditor/third-party/highcharts/adapters/prototype-adapter.js +15 -0
  228. package/ueditor/third-party/highcharts/adapters/prototype-adapter.src.js +316 -0
  229. package/ueditor/third-party/highcharts/adapters/standalone-framework.js +17 -0
  230. package/ueditor/third-party/highcharts/adapters/standalone-framework.src.js +583 -0
  231. package/ueditor/third-party/highcharts/highcharts-more.js +50 -0
  232. package/ueditor/third-party/highcharts/highcharts-more.src.js +2430 -0
  233. package/ueditor/third-party/highcharts/highcharts.js +283 -0
  234. package/ueditor/third-party/highcharts/highcharts.src.js +16974 -0
  235. package/ueditor/third-party/highcharts/modules/annotations.js +7 -0
  236. package/ueditor/third-party/highcharts/modules/annotations.src.js +401 -0
  237. package/ueditor/third-party/highcharts/modules/canvas-tools.js +133 -0
  238. package/ueditor/third-party/highcharts/modules/canvas-tools.src.js +3113 -0
  239. package/ueditor/third-party/highcharts/modules/data.js +17 -0
  240. package/ueditor/third-party/highcharts/modules/data.src.js +582 -0
  241. package/ueditor/third-party/highcharts/modules/drilldown.js +11 -0
  242. package/ueditor/third-party/highcharts/modules/drilldown.src.js +447 -0
  243. package/ueditor/third-party/highcharts/modules/exporting.js +22 -0
  244. package/ueditor/third-party/highcharts/modules/exporting.src.js +709 -0
  245. package/ueditor/third-party/highcharts/modules/funnel.js +12 -0
  246. package/ueditor/third-party/highcharts/modules/funnel.src.js +289 -0
  247. package/ueditor/third-party/highcharts/modules/heatmap.js +1 -0
  248. package/ueditor/third-party/highcharts/modules/heatmap.src.js +53 -0
  249. package/ueditor/third-party/highcharts/modules/map.js +27 -0
  250. package/ueditor/third-party/highcharts/modules/map.src.js +1002 -0
  251. package/ueditor/third-party/highcharts/modules/no-data-to-display.js +12 -0
  252. package/ueditor/third-party/highcharts/modules/no-data-to-display.src.js +128 -0
  253. package/ueditor/third-party/highcharts/themes/dark-blue.js +254 -0
  254. package/ueditor/third-party/highcharts/themes/dark-green.js +255 -0
  255. package/ueditor/third-party/highcharts/themes/gray.js +257 -0
  256. package/ueditor/third-party/highcharts/themes/grid.js +103 -0
  257. package/ueditor/third-party/highcharts/themes/skies.js +89 -0
  258. package/ueditor/third-party/jquery-1.10.2.js +9789 -0
  259. package/ueditor/third-party/jquery-1.10.2.min.js +6 -0
  260. package/ueditor/third-party/jquery-1.10.2.min.map +1 -0
  261. package/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
  262. package/ueditor/third-party/video-js/font/vjs.eot +0 -0
  263. package/ueditor/third-party/video-js/font/vjs.svg +65 -0
  264. package/ueditor/third-party/video-js/font/vjs.ttf +0 -0
  265. package/ueditor/third-party/video-js/font/vjs.woff +0 -0
  266. package/ueditor/third-party/video-js/video-js.css +766 -0
  267. package/ueditor/third-party/video-js/video-js.min.css +5 -0
  268. package/ueditor/third-party/video-js/video-js.swf +0 -0
  269. package/ueditor/third-party/video-js/video.dev.js +7108 -0
  270. package/ueditor/third-party/video-js/video.js +129 -0
  271. package/ueditor/third-party/webuploader/Uploader.swf +0 -0
  272. package/ueditor/third-party/webuploader/webuploader.css +28 -0
  273. package/ueditor/third-party/webuploader/webuploader.custom.js +5670 -0
  274. package/ueditor/third-party/webuploader/webuploader.custom.min.js +2 -0
  275. package/ueditor/third-party/webuploader/webuploader.flashonly.js +4176 -0
  276. package/ueditor/third-party/webuploader/webuploader.flashonly.min.js +2 -0
  277. package/ueditor/third-party/webuploader/webuploader.html5only.js +5559 -0
  278. package/ueditor/third-party/webuploader/webuploader.html5only.min.js +2 -0
  279. package/ueditor/third-party/webuploader/webuploader.js +6733 -0
  280. package/ueditor/third-party/webuploader/webuploader.min.js +2 -0
  281. package/ueditor/third-party/webuploader/webuploader.withoutimage.js +4593 -0
  282. package/ueditor/third-party/webuploader/webuploader.withoutimage.min.js +2 -0
  283. package/ueditor/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
  284. package/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js +9 -0
  285. package/ueditor/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
  286. package/ueditor/ueditor.all.js +32931 -0
  287. package/ueditor/ueditor.all.min.js +17 -0
  288. package/ueditor/ueditor.config.js +507 -0
  289. package/ueditor/ueditor.parse.js +1230 -0
  290. package/ueditor/ueditor.parse.min.js +5 -0
  291. package/vite.ts +87 -0
@@ -0,0 +1,1123 @@
1
+ /**
2
+ * User: Jinqn
3
+ * Date: 14-04-08
4
+ * Time: 下午16:34
5
+ * 上传图片对话框逻辑代码,包括tab: 远程图片/上传图片/在线图片/搜索图片
6
+ */
7
+
8
+ (function () {
9
+
10
+ var remoteImage,
11
+ uploadImage,
12
+ onlineImage,
13
+ searchImage;
14
+
15
+ window.onload = function () {
16
+ initTabs();
17
+ initAlign();
18
+ initButtons();
19
+ };
20
+
21
+ /* 初始化tab标签 */
22
+ function initTabs() {
23
+ var tabs = $G('tabhead').children;
24
+ for (var i = 0; i < tabs.length; i++) {
25
+ domUtils.on(tabs[i], "click", function (e) {
26
+ var target = e.target || e.srcElement;
27
+ setTabFocus(target.getAttribute('data-content-id'));
28
+ });
29
+ }
30
+
31
+ var img = editor.selection.getRange().getClosedNode();
32
+ if (img && img.tagName && img.tagName.toLowerCase() == 'img') {
33
+ setTabFocus('remote');
34
+ } else {
35
+ setTabFocus('upload');
36
+ }
37
+ }
38
+
39
+ /* 初始化tabbody */
40
+ function setTabFocus(id) {
41
+ if(!id) return;
42
+ var i, bodyId, tabs = $G('tabhead').children;
43
+ for (i = 0; i < tabs.length; i++) {
44
+ bodyId = tabs[i].getAttribute('data-content-id');
45
+ if (bodyId == id) {
46
+ domUtils.addClass(tabs[i], 'focus');
47
+ domUtils.addClass($G(bodyId), 'focus');
48
+ } else {
49
+ domUtils.removeClasses(tabs[i], 'focus');
50
+ domUtils.removeClasses($G(bodyId), 'focus');
51
+ }
52
+ }
53
+ switch (id) {
54
+ case 'remote':
55
+ remoteImage = remoteImage || new RemoteImage();
56
+ break;
57
+ case 'upload':
58
+ setAlign(editor.getOpt('imageInsertAlign'));
59
+ uploadImage = uploadImage || new UploadImage('queueList');
60
+ break;
61
+ case 'online':
62
+ setAlign(editor.getOpt('imageManagerInsertAlign'));
63
+ onlineImage = onlineImage || new OnlineImage('imageList');
64
+ onlineImage.reset();
65
+ break;
66
+ case 'search':
67
+ setAlign(editor.getOpt('imageManagerInsertAlign'));
68
+ searchImage = searchImage || new SearchImage();
69
+ break;
70
+ }
71
+ }
72
+
73
+ /* 初始化onok事件 */
74
+ function initButtons() {
75
+
76
+ dialog.onok = function () {
77
+ var remote = false, list = [], id, tabs = $G('tabhead').children;
78
+ for (var i = 0; i < tabs.length; i++) {
79
+ if (domUtils.hasClass(tabs[i], 'focus')) {
80
+ id = tabs[i].getAttribute('data-content-id');
81
+ break;
82
+ }
83
+ }
84
+
85
+ switch (id) {
86
+ case 'remote':
87
+ list = remoteImage.getInsertList();
88
+ break;
89
+ case 'upload':
90
+ list = uploadImage.getInsertList();
91
+ var count = uploadImage.getQueueCount();
92
+ if (count) {
93
+ $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
94
+ return false;
95
+ }
96
+ break;
97
+ case 'online':
98
+ list = onlineImage.getInsertList();
99
+ break;
100
+ case 'search':
101
+ list = searchImage.getInsertList();
102
+ remote = true;
103
+ break;
104
+ }
105
+
106
+ if(list) {
107
+ editor.execCommand('insertimage', list);
108
+ remote && editor.fireEvent("catchRemoteImage");
109
+ }
110
+ };
111
+ }
112
+
113
+
114
+ /* 初始化对其方式的点击事件 */
115
+ function initAlign(){
116
+ /* 点击align图标 */
117
+ domUtils.on($G("alignIcon"), 'click', function(e){
118
+ var target = e.target || e.srcElement;
119
+ if(target.className && target.className.indexOf('-align') != -1) {
120
+ setAlign(target.getAttribute('data-align'));
121
+ }
122
+ });
123
+ }
124
+
125
+ /* 设置对齐方式 */
126
+ function setAlign(align){
127
+ align = align || 'none';
128
+ var aligns = $G("alignIcon").children;
129
+ for(i = 0; i < aligns.length; i++){
130
+ if(aligns[i].getAttribute('data-align') == align) {
131
+ domUtils.addClass(aligns[i], 'focus');
132
+ $G("align").value = aligns[i].getAttribute('data-align');
133
+ } else {
134
+ domUtils.removeClasses(aligns[i], 'focus');
135
+ }
136
+ }
137
+ }
138
+ /* 获取对齐方式 */
139
+ function getAlign(){
140
+ var align = $G("align").value || 'none';
141
+ return align == 'none' ? '':align;
142
+ }
143
+
144
+
145
+ /* 在线图片 */
146
+ function RemoteImage(target) {
147
+ this.container = utils.isString(target) ? document.getElementById(target) : target;
148
+ this.init();
149
+ }
150
+ RemoteImage.prototype = {
151
+ init: function () {
152
+ this.initContainer();
153
+ this.initEvents();
154
+ },
155
+ initContainer: function () {
156
+ this.dom = {
157
+ 'url': $G('url'),
158
+ 'width': $G('width'),
159
+ 'height': $G('height'),
160
+ 'border': $G('border'),
161
+ 'vhSpace': $G('vhSpace'),
162
+ 'title': $G('title'),
163
+ 'align': $G('align')
164
+ };
165
+ var img = editor.selection.getRange().getClosedNode();
166
+ if (img) {
167
+ this.setImage(img);
168
+ }
169
+ },
170
+ initEvents: function () {
171
+ var _this = this,
172
+ locker = $G('lock');
173
+
174
+ /* 改变url */
175
+ domUtils.on($G("url"), 'keyup', updatePreview);
176
+ domUtils.on($G("border"), 'keyup', updatePreview);
177
+ domUtils.on($G("title"), 'keyup', updatePreview);
178
+
179
+ domUtils.on($G("width"), 'keyup', function(){
180
+ if(locker.checked) {
181
+ var proportion =locker.getAttribute('data-proportion');
182
+ $G('height').value = Math.round(this.value / proportion);
183
+ } else {
184
+ _this.updateLocker();
185
+ }
186
+ updatePreview();
187
+ });
188
+ domUtils.on($G("height"), 'keyup', function(){
189
+ if(locker.checked) {
190
+ var proportion =locker.getAttribute('data-proportion');
191
+ $G('width').value = Math.round(this.value * proportion);
192
+ } else {
193
+ _this.updateLocker();
194
+ }
195
+ updatePreview();
196
+ });
197
+ domUtils.on($G("lock"), 'change', function(){
198
+ var proportion = parseInt($G("width").value) /parseInt($G("height").value);
199
+ locker.setAttribute('data-proportion', proportion);
200
+ });
201
+
202
+ function updatePreview(){
203
+ _this.setPreview();
204
+ }
205
+ },
206
+ updateLocker: function(){
207
+ var width = $G('width').value,
208
+ height = $G('height').value,
209
+ locker = $G('lock');
210
+ if(width && height && width == parseInt(width) && height == parseInt(height)) {
211
+ locker.disabled = false;
212
+ locker.title = '';
213
+ } else {
214
+ locker.checked = false;
215
+ locker.disabled = 'disabled';
216
+ locker.title = lang.remoteLockError;
217
+ }
218
+ },
219
+ setImage: function(img){
220
+ /* 不是正常的图片 */
221
+ if (!img.tagName || img.tagName.toLowerCase() != 'img' && !img.getAttribute("src") || !img.src) return;
222
+
223
+ var wordImgFlag = img.getAttribute("word_img"),
224
+ src = wordImgFlag ? wordImgFlag.replace("&amp;", "&") : (img.getAttribute('_src') || img.getAttribute("src", 2).replace("&amp;", "&")),
225
+ align = editor.queryCommandValue("imageFloat");
226
+
227
+ /* 防止onchange事件循环调用 */
228
+ if (src !== $G("url").value) $G("url").value = src;
229
+ if(src) {
230
+ /* 设置表单内容 */
231
+ $G("width").value = img.width || '';
232
+ $G("height").value = img.height || '';
233
+ $G("border").value = img.getAttribute("border") || '0';
234
+ $G("vhSpace").value = img.getAttribute("vspace") || '0';
235
+ $G("title").value = img.title || img.alt || '';
236
+ setAlign(align);
237
+ this.setPreview();
238
+ this.updateLocker();
239
+ }
240
+ },
241
+ getData: function(){
242
+ var data = {};
243
+ for(var k in this.dom){
244
+ data[k] = this.dom[k].value;
245
+ }
246
+ return data;
247
+ },
248
+ setPreview: function(){
249
+ var url = $G('url').value,
250
+ ow = $G('width').value,
251
+ oh = $G('height').value,
252
+ border = $G('border').value,
253
+ title = $G('title').value,
254
+ preview = $G('preview'),
255
+ width,
256
+ height;
257
+
258
+ width = ((!ow || !oh) ? preview.offsetWidth:Math.min(ow, preview.offsetWidth));
259
+ width = width+(border*2) > preview.offsetWidth ? width:(preview.offsetWidth - (border*2));
260
+ height = (!ow || !oh) ? '':width*oh/ow;
261
+
262
+ if(url) {
263
+ preview.innerHTML = '<img src="' + url + '" width="' + width + '" height="' + height + '" border="' + border + 'px solid #000" title="' + title + '" />';
264
+ }
265
+ },
266
+ getInsertList: function () {
267
+ var data = this.getData();
268
+ if(data['url']) {
269
+ return [{
270
+ src: data['url'],
271
+ _src: data['url'],
272
+ width: data['width'] || '',
273
+ height: data['height'] || '',
274
+ border: data['border'] || '',
275
+ floatStyle: data['align'] || '',
276
+ vspace: data['vhSpace'] || '',
277
+ alt: data['title'] || '',
278
+ style: "width:" + data['width'] + "px;height:" + data['height'] + "px;"
279
+ }];
280
+ } else {
281
+ return [];
282
+ }
283
+ }
284
+ };
285
+
286
+
287
+
288
+ /* 上传图片 */
289
+ function UploadImage(target) {
290
+ this.$wrap = target.constructor == String ? $('#' + target) : $(target);
291
+ this.init();
292
+ }
293
+ UploadImage.prototype = {
294
+ init: function () {
295
+ this.imageList = [];
296
+ this.initContainer();
297
+ this.initUploader();
298
+ },
299
+ initContainer: function () {
300
+ this.$queue = this.$wrap.find('.filelist');
301
+ },
302
+ /* 初始化容器 */
303
+ initUploader: function () {
304
+ var _this = this,
305
+ $ = jQuery, // just in case. Make sure it's not an other libaray.
306
+ $wrap = _this.$wrap,
307
+ // 图片容器
308
+ $queue = $wrap.find('.filelist'),
309
+ // 状态栏,包括进度和控制按钮
310
+ $statusBar = $wrap.find('.statusBar'),
311
+ // 文件总体选择信息。
312
+ $info = $statusBar.find('.info'),
313
+ // 上传按钮
314
+ $upload = $wrap.find('.uploadBtn'),
315
+ // 上传按钮
316
+ $filePickerBtn = $wrap.find('.filePickerBtn'),
317
+ // 上传按钮
318
+ $filePickerBlock = $wrap.find('.filePickerBlock'),
319
+ // 没选择文件之前的内容。
320
+ $placeHolder = $wrap.find('.placeholder'),
321
+ // 总体进度条
322
+ $progress = $statusBar.find('.progress').hide(),
323
+ // 添加的文件数量
324
+ fileCount = 0,
325
+ // 添加的文件总大小
326
+ fileSize = 0,
327
+ // 优化retina, 在retina下这个值是2
328
+ ratio = window.devicePixelRatio || 1,
329
+ // 缩略图大小
330
+ thumbnailWidth = 113 * ratio,
331
+ thumbnailHeight = 113 * ratio,
332
+ // 可能有pedding, ready, uploading, confirm, done.
333
+ state = '',
334
+ // 所有文件的进度信息,key为file id
335
+ percentages = {},
336
+ supportTransition = (function () {
337
+ var s = document.createElement('p').style,
338
+ r = 'transition' in s ||
339
+ 'WebkitTransition' in s ||
340
+ 'MozTransition' in s ||
341
+ 'msTransition' in s ||
342
+ 'OTransition' in s;
343
+ s = null;
344
+ return r;
345
+ })(),
346
+ // WebUploader实例
347
+ uploader,
348
+ actionUrl = editor.getActionUrl(editor.getOpt('imageActionName')),
349
+ acceptExtensions = (editor.getOpt('imageAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, ''),
350
+ imageMaxSize = editor.getOpt('imageMaxSize'),
351
+ imageCompressBorder = editor.getOpt('imageCompressBorder');
352
+
353
+ if (!WebUploader.Uploader.support()) {
354
+ $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
355
+ return;
356
+ } else if (!editor.getOpt('imageActionName')) {
357
+ $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
358
+ return;
359
+ }
360
+
361
+ uploader = _this.uploader = WebUploader.create({
362
+ pick: {
363
+ id: '#filePickerReady',
364
+ label: lang.uploadSelectFile
365
+ },
366
+ accept: {
367
+ title: 'Images',
368
+ extensions: acceptExtensions,
369
+ mimeTypes: 'image/*'
370
+ },
371
+ swf: '../../third-party/webuploader/Uploader.swf',
372
+ server: actionUrl,
373
+ fileVal: editor.getOpt('imageFieldName'),
374
+ duplicate: true,
375
+ fileSingleSizeLimit: imageMaxSize, // 默认 2 M
376
+ compress: editor.getOpt('imageCompressEnable') ? {
377
+ width: imageCompressBorder,
378
+ height: imageCompressBorder,
379
+ // 图片质量,只有type为`image/jpeg`的时候才有效。
380
+ quality: 90,
381
+ // 是否允许放大,如果想要生成小图的时候不失真,此选项应该设置为false.
382
+ allowMagnify: false,
383
+ // 是否允许裁剪。
384
+ crop: false,
385
+ // 是否保留头部meta信息。
386
+ preserveHeaders: true
387
+ }:false
388
+ });
389
+ uploader.addButton({
390
+ id: '#filePickerBlock'
391
+ });
392
+ uploader.addButton({
393
+ id: '#filePickerBtn',
394
+ label: lang.uploadAddFile
395
+ });
396
+
397
+ setState('pedding');
398
+
399
+ // 当有文件添加进来时执行,负责view的创建
400
+ function addFile(file) {
401
+ var $li = $('<li id="' + file.id + '">' +
402
+ '<p class="title">' + file.name + '</p>' +
403
+ '<p class="imgWrap"></p>' +
404
+ '<p class="progress"><span></span></p>' +
405
+ '</li>'),
406
+
407
+ $btns = $('<div class="file-panel">' +
408
+ '<span class="cancel">' + lang.uploadDelete + '</span>' +
409
+ '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
410
+ '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
411
+ $prgress = $li.find('p.progress span'),
412
+ $wrap = $li.find('p.imgWrap'),
413
+ $info = $('<p class="error"></p>').hide().appendTo($li),
414
+
415
+ showError = function (code) {
416
+ switch (code) {
417
+ case 'exceed_size':
418
+ text = lang.errorExceedSize;
419
+ break;
420
+ case 'interrupt':
421
+ text = lang.errorInterrupt;
422
+ break;
423
+ case 'http':
424
+ text = lang.errorHttp;
425
+ break;
426
+ case 'not_allow_type':
427
+ text = lang.errorFileType;
428
+ break;
429
+ default:
430
+ text = lang.errorUploadRetry;
431
+ break;
432
+ }
433
+ $info.text(text).show();
434
+ };
435
+
436
+ if (file.getStatus() === 'invalid') {
437
+ showError(file.statusText);
438
+ } else {
439
+ $wrap.text(lang.uploadPreview);
440
+ if (browser.ie && browser.version <= 7) {
441
+ $wrap.text(lang.uploadNoPreview);
442
+ } else {
443
+ uploader.makeThumb(file, function (error, src) {
444
+ if (error || !src) {
445
+ $wrap.text(lang.uploadNoPreview);
446
+ } else {
447
+ var $img = $('<img src="' + src + '">');
448
+ $wrap.empty().append($img);
449
+ $img.on('error', function () {
450
+ $wrap.text(lang.uploadNoPreview);
451
+ });
452
+ }
453
+ }, thumbnailWidth, thumbnailHeight);
454
+ }
455
+ percentages[ file.id ] = [ file.size, 0 ];
456
+ file.rotation = 0;
457
+
458
+ /* 检查文件格式 */
459
+ if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
460
+ showError('not_allow_type');
461
+ uploader.removeFile(file);
462
+ }
463
+ }
464
+
465
+ file.on('statuschange', function (cur, prev) {
466
+ if (prev === 'progress') {
467
+ $prgress.hide().width(0);
468
+ } else if (prev === 'queued') {
469
+ $li.off('mouseenter mouseleave');
470
+ $btns.remove();
471
+ }
472
+ // 成功
473
+ if (cur === 'error' || cur === 'invalid') {
474
+ showError(file.statusText);
475
+ percentages[ file.id ][ 1 ] = 1;
476
+ } else if (cur === 'interrupt') {
477
+ showError('interrupt');
478
+ } else if (cur === 'queued') {
479
+ percentages[ file.id ][ 1 ] = 0;
480
+ } else if (cur === 'progress') {
481
+ $info.hide();
482
+ $prgress.css('display', 'block');
483
+ } else if (cur === 'complete') {
484
+ }
485
+
486
+ $li.removeClass('state-' + prev).addClass('state-' + cur);
487
+ });
488
+
489
+ $li.on('mouseenter', function () {
490
+ $btns.stop().animate({height: 30});
491
+ });
492
+ $li.on('mouseleave', function () {
493
+ $btns.stop().animate({height: 0});
494
+ });
495
+
496
+ $btns.on('click', 'span', function () {
497
+ var index = $(this).index(),
498
+ deg;
499
+
500
+ switch (index) {
501
+ case 0:
502
+ uploader.removeFile(file);
503
+ return;
504
+ case 1:
505
+ file.rotation += 90;
506
+ break;
507
+ case 2:
508
+ file.rotation -= 90;
509
+ break;
510
+ }
511
+
512
+ if (supportTransition) {
513
+ deg = 'rotate(' + file.rotation + 'deg)';
514
+ $wrap.css({
515
+ '-webkit-transform': deg,
516
+ '-mos-transform': deg,
517
+ '-o-transform': deg,
518
+ 'transform': deg
519
+ });
520
+ } else {
521
+ $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
522
+ }
523
+
524
+ });
525
+
526
+ $li.insertBefore($filePickerBlock);
527
+ }
528
+
529
+ // 负责view的销毁
530
+ function removeFile(file) {
531
+ var $li = $('#' + file.id);
532
+ delete percentages[ file.id ];
533
+ updateTotalProgress();
534
+ $li.off().find('.file-panel').off().end().remove();
535
+ }
536
+
537
+ function updateTotalProgress() {
538
+ var loaded = 0,
539
+ total = 0,
540
+ spans = $progress.children(),
541
+ percent;
542
+
543
+ $.each(percentages, function (k, v) {
544
+ total += v[ 0 ];
545
+ loaded += v[ 0 ] * v[ 1 ];
546
+ });
547
+
548
+ percent = total ? loaded / total : 0;
549
+
550
+ spans.eq(0).text(Math.round(percent * 100) + '%');
551
+ spans.eq(1).css('width', Math.round(percent * 100) + '%');
552
+ updateStatus();
553
+ }
554
+
555
+ function setState(val, files) {
556
+
557
+ if (val != state) {
558
+
559
+ var stats = uploader.getStats();
560
+
561
+ $upload.removeClass('state-' + state);
562
+ $upload.addClass('state-' + val);
563
+
564
+ switch (val) {
565
+
566
+ /* 未选择文件 */
567
+ case 'pedding':
568
+ $queue.addClass('element-invisible');
569
+ $statusBar.addClass('element-invisible');
570
+ $placeHolder.removeClass('element-invisible');
571
+ $progress.hide(); $info.hide();
572
+ uploader.refresh();
573
+ break;
574
+
575
+ /* 可以开始上传 */
576
+ case 'ready':
577
+ $placeHolder.addClass('element-invisible');
578
+ $queue.removeClass('element-invisible');
579
+ $statusBar.removeClass('element-invisible');
580
+ $progress.hide(); $info.show();
581
+ $upload.text(lang.uploadStart);
582
+ uploader.refresh();
583
+ break;
584
+
585
+ /* 上传中 */
586
+ case 'uploading':
587
+ $progress.show(); $info.hide();
588
+ $upload.text(lang.uploadPause);
589
+ break;
590
+
591
+ /* 暂停上传 */
592
+ case 'paused':
593
+ $progress.show(); $info.hide();
594
+ $upload.text(lang.uploadContinue);
595
+ break;
596
+
597
+ case 'confirm':
598
+ $progress.show(); $info.hide();
599
+ $upload.text(lang.uploadStart);
600
+
601
+ stats = uploader.getStats();
602
+ if (stats.successNum && !stats.uploadFailNum) {
603
+ setState('finish');
604
+ return;
605
+ }
606
+ break;
607
+
608
+ case 'finish':
609
+ $progress.hide(); $info.show();
610
+ if (stats.uploadFailNum) {
611
+ $upload.text(lang.uploadRetry);
612
+ } else {
613
+ $upload.text(lang.uploadStart);
614
+ }
615
+ break;
616
+ }
617
+
618
+ state = val;
619
+ updateStatus();
620
+
621
+ }
622
+
623
+ if (!_this.getQueueCount()) {
624
+ $upload.addClass('disabled')
625
+ } else {
626
+ $upload.removeClass('disabled')
627
+ }
628
+
629
+ }
630
+
631
+ function updateStatus() {
632
+ var text = '', stats;
633
+
634
+ if (state === 'ready') {
635
+ text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
636
+ } else if (state === 'confirm') {
637
+ stats = uploader.getStats();
638
+ if (stats.uploadFailNum) {
639
+ text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
640
+ }
641
+ } else {
642
+ stats = uploader.getStats();
643
+ text = lang.updateStatusFinish.replace('_', fileCount).
644
+ replace('_KB', WebUploader.formatSize(fileSize)).
645
+ replace('_', stats.successNum);
646
+
647
+ if (stats.uploadFailNum) {
648
+ text += lang.updateStatusError.replace('_', stats.uploadFailNum);
649
+ }
650
+ }
651
+
652
+ $info.html(text);
653
+ }
654
+
655
+ uploader.on('fileQueued', function (file) {
656
+ fileCount++;
657
+ fileSize += file.size;
658
+
659
+ if (fileCount === 1) {
660
+ $placeHolder.addClass('element-invisible');
661
+ $statusBar.show();
662
+ }
663
+
664
+ addFile(file);
665
+ });
666
+
667
+ uploader.on('fileDequeued', function (file) {
668
+ if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= imageMaxSize) {
669
+ fileCount--;
670
+ fileSize -= file.size;
671
+ }
672
+
673
+ removeFile(file);
674
+ updateTotalProgress();
675
+ });
676
+
677
+ uploader.on('filesQueued', function (file) {
678
+ if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
679
+ setState('ready');
680
+ }
681
+ updateTotalProgress();
682
+ });
683
+
684
+ uploader.on('all', function (type, files) {
685
+ switch (type) {
686
+ case 'uploadFinished':
687
+ setState('confirm', files);
688
+ break;
689
+ case 'startUpload':
690
+ /* 添加额外的GET参数 */
691
+ var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
692
+ url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?':'&') + 'encode=utf-8&' + params);
693
+ uploader.option('server', url);
694
+ setState('uploading', files);
695
+ break;
696
+ case 'stopUpload':
697
+ setState('paused', files);
698
+ break;
699
+ }
700
+ });
701
+
702
+ uploader.on('uploadBeforeSend', function (file, data, header) {
703
+ //这里可以通过data对象添加POST参数
704
+ if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
705
+ header['X-Requested-With'] = 'XMLHttpRequest';
706
+ }
707
+ });
708
+
709
+ uploader.on('uploadProgress', function (file, percentage) {
710
+ var $li = $('#' + file.id),
711
+ $percent = $li.find('.progress span');
712
+
713
+ $percent.css('width', percentage * 100 + '%');
714
+ percentages[ file.id ][ 1 ] = percentage;
715
+ updateTotalProgress();
716
+ });
717
+
718
+ uploader.on('uploadSuccess', function (file, ret) {
719
+ var $file = $('#' + file.id);
720
+ try {
721
+ var responseText = (ret._raw || ret),
722
+ json = utils.str2json(responseText);
723
+ if (json.state == 'SUCCESS') {
724
+ _this.imageList.push(json);
725
+ $file.append('<span class="success"></span>');
726
+ } else {
727
+ $file.find('.error').text(json.state).show();
728
+ }
729
+ } catch (e) {
730
+ $file.find('.error').text(lang.errorServerUpload).show();
731
+ }
732
+ });
733
+
734
+ uploader.on('uploadError', function (file, code) {
735
+ });
736
+ uploader.on('error', function (code, file) {
737
+ if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
738
+ addFile(file);
739
+ }
740
+ });
741
+ uploader.on('uploadComplete', function (file, ret) {
742
+ });
743
+
744
+ $upload.on('click', function () {
745
+ if ($(this).hasClass('disabled')) {
746
+ return false;
747
+ }
748
+
749
+ if (state === 'ready') {
750
+ uploader.upload();
751
+ } else if (state === 'paused') {
752
+ uploader.upload();
753
+ } else if (state === 'uploading') {
754
+ uploader.stop();
755
+ }
756
+ });
757
+
758
+ $upload.addClass('state-' + state);
759
+ updateTotalProgress();
760
+ },
761
+ getQueueCount: function () {
762
+ var file, i, status, readyFile = 0, files = this.uploader.getFiles();
763
+ for (i = 0; file = files[i++]; ) {
764
+ status = file.getStatus();
765
+ if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
766
+ }
767
+ return readyFile;
768
+ },
769
+ destroy: function () {
770
+ this.$wrap.remove();
771
+ },
772
+ getInsertList: function () {
773
+ var i, data, list = [],
774
+ align = getAlign(),
775
+ prefix = editor.getOpt('imageUrlPrefix');
776
+ for (i = 0; i < this.imageList.length; i++) {
777
+ data = this.imageList[i];
778
+ list.push({
779
+ src: prefix + data.url,
780
+ _src: prefix + data.url,
781
+ alt: data.original,
782
+ floatStyle: align
783
+ });
784
+ }
785
+ return list;
786
+ }
787
+ };
788
+
789
+
790
+ /* 在线图片 */
791
+ function OnlineImage(target) {
792
+ this.container = utils.isString(target) ? document.getElementById(target) : target;
793
+ this.init();
794
+ }
795
+ OnlineImage.prototype = {
796
+ init: function () {
797
+ this.reset();
798
+ this.initEvents();
799
+ },
800
+ /* 初始化容器 */
801
+ initContainer: function () {
802
+ this.container.innerHTML = '';
803
+ this.list = document.createElement('ul');
804
+ this.clearFloat = document.createElement('li');
805
+
806
+ domUtils.addClass(this.list, 'list');
807
+ domUtils.addClass(this.clearFloat, 'clearFloat');
808
+
809
+ this.list.appendChild(this.clearFloat);
810
+ this.container.appendChild(this.list);
811
+ },
812
+ /* 初始化滚动事件,滚动到地步自动拉取数据 */
813
+ initEvents: function () {
814
+ var _this = this;
815
+
816
+ /* 滚动拉取图片 */
817
+ domUtils.on($G('imageList'), 'scroll', function(e){
818
+ var panel = this;
819
+ if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
820
+ _this.getImageData();
821
+ }
822
+ });
823
+ /* 选中图片 */
824
+ domUtils.on(this.container, 'click', function (e) {
825
+ var target = e.target || e.srcElement,
826
+ li = target.parentNode;
827
+
828
+ if (li.tagName.toLowerCase() == 'li') {
829
+ if (domUtils.hasClass(li, 'selected')) {
830
+ domUtils.removeClasses(li, 'selected');
831
+ } else {
832
+ domUtils.addClass(li, 'selected');
833
+ }
834
+ }
835
+ });
836
+ },
837
+ /* 初始化第一次的数据 */
838
+ initData: function () {
839
+
840
+ /* 拉取数据需要使用的值 */
841
+ this.state = 0;
842
+ this.listSize = editor.getOpt('imageManagerListSize');
843
+ this.listIndex = 0;
844
+ this.listEnd = false;
845
+
846
+ /* 第一次拉取数据 */
847
+ this.getImageData();
848
+ },
849
+ /* 重置界面 */
850
+ reset: function() {
851
+ this.initContainer();
852
+ this.initData();
853
+ },
854
+ /* 向后台拉取图片列表数据 */
855
+ getImageData: function () {
856
+ var _this = this;
857
+
858
+ if(!_this.listEnd && !this.isLoadingData) {
859
+ this.isLoadingData = true;
860
+ var url = editor.getActionUrl(editor.getOpt('imageManagerActionName')),
861
+ isJsonp = utils.isCrossDomainUrl(url);
862
+ ajax.request(url, {
863
+ 'timeout': 100000,
864
+ 'dataType': isJsonp ? 'jsonp':'',
865
+ 'data': utils.extend({
866
+ start: this.listIndex,
867
+ size: this.listSize
868
+ }, editor.queryCommandValue('serverparam')),
869
+ 'method': 'get',
870
+ 'onsuccess': function (r) {
871
+ try {
872
+ var json = isJsonp ? r:eval('(' + r.responseText + ')');
873
+ if (json.state == 'SUCCESS') {
874
+ _this.pushData(json.list);
875
+ _this.listIndex = parseInt(json.start) + parseInt(json.list.length);
876
+ if(_this.listIndex >= json.total) {
877
+ _this.listEnd = true;
878
+ }
879
+ _this.isLoadingData = false;
880
+ }
881
+ } catch (e) {
882
+ if(r.responseText.indexOf('ue_separate_ue') != -1) {
883
+ var list = r.responseText.split(r.responseText);
884
+ _this.pushData(list);
885
+ _this.listIndex = parseInt(list.length);
886
+ _this.listEnd = true;
887
+ _this.isLoadingData = false;
888
+ }
889
+ }
890
+ },
891
+ 'onerror': function () {
892
+ _this.isLoadingData = false;
893
+ }
894
+ });
895
+ }
896
+ },
897
+ /* 添加图片到列表界面上 */
898
+ pushData: function (list) {
899
+ var i, item, img, icon, _this = this,
900
+ urlPrefix = editor.getOpt('imageManagerUrlPrefix');
901
+ for (i = 0; i < list.length; i++) {
902
+ if(list[i] && list[i].url) {
903
+ item = document.createElement('li');
904
+ img = document.createElement('img');
905
+ icon = document.createElement('span');
906
+
907
+ domUtils.on(img, 'load', (function(image){
908
+ return function(){
909
+ _this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight);
910
+ }
911
+ })(img));
912
+ img.width = 113;
913
+ img.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=':'&noCache=') + (+new Date()).toString(36) );
914
+ img.setAttribute('_src', urlPrefix + list[i].url);
915
+ domUtils.addClass(icon, 'icon');
916
+
917
+ item.appendChild(img);
918
+ item.appendChild(icon);
919
+ this.list.insertBefore(item, this.clearFloat);
920
+ }
921
+ }
922
+ },
923
+ /* 改变图片大小 */
924
+ scale: function (img, w, h, type) {
925
+ var ow = img.width,
926
+ oh = img.height;
927
+
928
+ if (type == 'justify') {
929
+ if (ow >= oh) {
930
+ img.width = w;
931
+ img.height = h * oh / ow;
932
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
933
+ } else {
934
+ img.width = w * ow / oh;
935
+ img.height = h;
936
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
937
+ }
938
+ } else {
939
+ if (ow >= oh) {
940
+ img.width = w * ow / oh;
941
+ img.height = h;
942
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
943
+ } else {
944
+ img.width = w;
945
+ img.height = h * oh / ow;
946
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
947
+ }
948
+ }
949
+ },
950
+ getInsertList: function () {
951
+ var i, lis = this.list.children, list = [], align = getAlign();
952
+ for (i = 0; i < lis.length; i++) {
953
+ if (domUtils.hasClass(lis[i], 'selected')) {
954
+ var img = lis[i].firstChild,
955
+ src = img.getAttribute('_src');
956
+ list.push({
957
+ src: src,
958
+ _src: src,
959
+ alt: src.substr(src.lastIndexOf('/') + 1),
960
+ floatStyle: align
961
+ });
962
+ }
963
+
964
+ }
965
+ return list;
966
+ }
967
+ };
968
+
969
+ /*搜索图片 */
970
+ function SearchImage() {
971
+ this.init();
972
+ }
973
+ SearchImage.prototype = {
974
+ init: function () {
975
+ this.initEvents();
976
+ },
977
+ initEvents: function(){
978
+ var _this = this;
979
+
980
+ /* 点击搜索按钮 */
981
+ domUtils.on($G('searchBtn'), 'click', function(){
982
+ var key = $G('searchTxt').value;
983
+ if(key && key != lang.searchRemind) {
984
+ _this.getImageData();
985
+ }
986
+ });
987
+ /* 点击清除妞 */
988
+ domUtils.on($G('searchReset'), 'click', function(){
989
+ $G('searchTxt').value = lang.searchRemind;
990
+ $G('searchListUl').innerHTML = '';
991
+ $G('searchType').selectedIndex = 0;
992
+ });
993
+ /* 搜索框聚焦 */
994
+ domUtils.on($G('searchTxt'), 'focus', function(){
995
+ var key = $G('searchTxt').value;
996
+ if(key && key == lang.searchRemind) {
997
+ $G('searchTxt').value = '';
998
+ }
999
+ });
1000
+ /* 搜索框回车键搜索 */
1001
+ domUtils.on($G('searchTxt'), 'keydown', function(e){
1002
+ var keyCode = e.keyCode || e.which;
1003
+ if (keyCode == 13) {
1004
+ $G('searchBtn').click();
1005
+ }
1006
+ });
1007
+
1008
+ /* 选中图片 */
1009
+ domUtils.on($G('searchList'), 'click', function(e){
1010
+ var target = e.target || e.srcElement,
1011
+ li = target.parentNode.parentNode;
1012
+
1013
+ if (li.tagName.toLowerCase() == 'li') {
1014
+ if (domUtils.hasClass(li, 'selected')) {
1015
+ domUtils.removeClasses(li, 'selected');
1016
+ } else {
1017
+ domUtils.addClass(li, 'selected');
1018
+ }
1019
+ }
1020
+ });
1021
+ },
1022
+ /* 改变图片大小 */
1023
+ scale: function (img, w, h) {
1024
+ var ow = img.width,
1025
+ oh = img.height;
1026
+
1027
+ if (ow >= oh) {
1028
+ img.width = w * ow / oh;
1029
+ img.height = h;
1030
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
1031
+ } else {
1032
+ img.width = w;
1033
+ img.height = h * oh / ow;
1034
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
1035
+ }
1036
+ },
1037
+ getImageData: function(){
1038
+ var _this = this,
1039
+ key = $G('searchTxt').value,
1040
+ type = $G('searchType').value,
1041
+ keepOriginName = editor.options.keepOriginName ? "1" : "0",
1042
+ url = "http://image.baidu.com/i?ct=201326592&cl=2&lm=-1&st=-1&tn=baiduimagejson&istype=2&rn=32&fm=index&pv=&word=" + key + type + "&ie=utf-8&oe=utf-8&keeporiginname=" + keepOriginName + "&" + +new Date;
1043
+
1044
+ $G('searchListUl').innerHTML = lang.searchLoading;
1045
+ ajax.request(url, {
1046
+ 'dataType': 'jsonp',
1047
+ 'charset': 'GB18030',
1048
+ 'onsuccess':function(json){
1049
+ var list = [];
1050
+ if(json && json.data) {
1051
+ for(var i = 0; i < json.data.length; i++) {
1052
+ if(json.data[i].objURL) {
1053
+ list.push({
1054
+ title: json.data[i].fromPageTitleEnc,
1055
+ src: json.data[i].objURL,
1056
+ url: json.data[i].fromURL
1057
+ });
1058
+ }
1059
+ }
1060
+ }
1061
+ _this.setList(list);
1062
+ },
1063
+ 'onerror':function(){
1064
+ $G('searchListUl').innerHTML = lang.searchRetry;
1065
+ }
1066
+ });
1067
+ },
1068
+ /* 添加图片到列表界面上 */
1069
+ setList: function (list) {
1070
+ var i, item, p, img, link, _this = this,
1071
+ listUl = $G('searchListUl');
1072
+
1073
+ listUl.innerHTML = '';
1074
+ if(list.length) {
1075
+ for (i = 0; i < list.length; i++) {
1076
+ item = document.createElement('li');
1077
+ p = document.createElement('p');
1078
+ img = document.createElement('img');
1079
+ link = document.createElement('a');
1080
+
1081
+ img.onload = function () {
1082
+ _this.scale(this, 113, 113);
1083
+ };
1084
+ img.width = 113;
1085
+ img.setAttribute('src', list[i].src);
1086
+
1087
+ link.href = list[i].url;
1088
+ link.target = '_blank';
1089
+ link.title = list[i].title;
1090
+ link.innerHTML = list[i].title;
1091
+
1092
+ p.appendChild(img);
1093
+ item.appendChild(p);
1094
+ item.appendChild(link);
1095
+ listUl.appendChild(item);
1096
+ }
1097
+ } else {
1098
+ listUl.innerHTML = lang.searchRetry;
1099
+ }
1100
+ },
1101
+ getInsertList: function () {
1102
+ var child,
1103
+ src,
1104
+ align = getAlign(),
1105
+ list = [],
1106
+ items = $G('searchListUl').children;
1107
+ for(var i = 0; i < items.length; i++) {
1108
+ child = items[i].firstChild && items[i].firstChild.firstChild;
1109
+ if(child.tagName && child.tagName.toLowerCase() == 'img' && domUtils.hasClass(items[i], 'selected')) {
1110
+ src = child.src;
1111
+ list.push({
1112
+ src: src,
1113
+ _src: src,
1114
+ alt: src.substr(src.lastIndexOf('/') + 1),
1115
+ floatStyle: align
1116
+ });
1117
+ }
1118
+ }
1119
+ return list;
1120
+ }
1121
+ };
1122
+
1123
+ })();