@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,803 @@
1
+ /**
2
+ * User: Jinqn
3
+ * Date: 14-04-08
4
+ * Time: 下午16:34
5
+ * 上传图片对话框逻辑代码,包括tab: 远程图片/上传图片/在线图片/搜索图片
6
+ */
7
+
8
+ (function () {
9
+
10
+ var uploadFile,
11
+ onlineFile;
12
+
13
+ window.onload = function () {
14
+ initTabs();
15
+ initButtons();
16
+ };
17
+
18
+ /* 初始化tab标签 */
19
+ function initTabs() {
20
+ $G('tabhead').querySelector('[data-content-id="online"]').style.display = 'none';
21
+ var tabs = $G('tabhead').children;
22
+ for (var i = 0; i < tabs.length; i++) {
23
+ domUtils.on(tabs[i], "click", function (e) {
24
+ var target = e.target || e.srcElement;
25
+ setTabFocus(target.getAttribute('data-content-id'));
26
+ });
27
+ }
28
+
29
+ setTabFocus('upload');
30
+ }
31
+
32
+ /* 初始化tabbody */
33
+ function setTabFocus(id) {
34
+ if (!id) return;
35
+ var i, bodyId, tabs = $G('tabhead').children;
36
+ for (i = 0; i < tabs.length; i++) {
37
+ bodyId = tabs[i].getAttribute('data-content-id')
38
+ if (bodyId == id) {
39
+ domUtils.addClass(tabs[i], 'focus');
40
+ domUtils.addClass($G(bodyId), 'focus');
41
+ } else {
42
+ domUtils.removeClasses(tabs[i], 'focus');
43
+ domUtils.removeClasses($G(bodyId), 'focus');
44
+ }
45
+ }
46
+ switch (id) {
47
+ case 'upload':
48
+ uploadFile = uploadFile || new UploadFile('queueList');
49
+ break;
50
+ case 'online':
51
+ onlineFile = onlineFile || new OnlineFile('fileList');
52
+ break;
53
+ }
54
+ }
55
+
56
+ /* 初始化onok事件 */
57
+ function initButtons() {
58
+
59
+ dialog.onok = function () {
60
+ var list = [], id, tabs = $G('tabhead').children;
61
+ for (var i = 0; i < tabs.length; i++) {
62
+ if (domUtils.hasClass(tabs[i], 'focus')) {
63
+ id = tabs[i].getAttribute('data-content-id');
64
+ break;
65
+ }
66
+ }
67
+
68
+ switch (id) {
69
+ case 'upload':
70
+ list = uploadFile.getInsertList();
71
+ var count = uploadFile.getQueueCount();
72
+ if (count) {
73
+ $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
74
+ return false;
75
+ }
76
+ break;
77
+ case 'online':
78
+ list = onlineFile.getInsertList();
79
+ break;
80
+ }
81
+
82
+ editor.execCommand('insertfile', list);
83
+ };
84
+ }
85
+
86
+
87
+ /* 上传附件 */
88
+ function UploadFile(target) {
89
+ this.$wrap = target.constructor == String ? $('#' + target) : $(target);
90
+ this.init();
91
+ }
92
+
93
+ UploadFile.prototype = {
94
+ init: function () {
95
+ this.fileList = [];
96
+ this.initContainer();
97
+ this.initUploader();
98
+ },
99
+ initContainer: function () {
100
+ this.$queue = this.$wrap.find('.filelist');
101
+ },
102
+ /* 初始化容器 */
103
+ initUploader: function () {
104
+ var _this = this,
105
+ $ = jQuery, // just in case. Make sure it's not an other libaray.
106
+ $wrap = _this.$wrap,
107
+ // 图片容器
108
+ $queue = $wrap.find('.filelist'),
109
+ // 状态栏,包括进度和控制按钮
110
+ $statusBar = $wrap.find('.statusBar'),
111
+ // 文件总体选择信息。
112
+ $info = $statusBar.find('.info'),
113
+ // 上传按钮
114
+ $upload = $wrap.find('.uploadBtn'),
115
+ // 上传按钮
116
+ $filePickerBtn = $wrap.find('.filePickerBtn'),
117
+ // 上传按钮
118
+ $filePickerBlock = $wrap.find('.filePickerBlock'),
119
+ // 没选择文件之前的内容。
120
+ $placeHolder = $wrap.find('.placeholder'),
121
+ // 总体进度条
122
+ $progress = $statusBar.find('.progress').hide(),
123
+ // 添加的文件数量
124
+ fileCount = 0,
125
+ // 添加的文件总大小
126
+ fileSize = 0,
127
+ // 优化retina, 在retina下这个值是2
128
+ ratio = window.devicePixelRatio || 1,
129
+ // 缩略图大小
130
+ thumbnailWidth = 113 * ratio,
131
+ thumbnailHeight = 113 * ratio,
132
+ // 可能有pedding, ready, uploading, confirm, done.
133
+ state = '',
134
+ // 所有文件的进度信息,key为file id
135
+ percentages = {},
136
+ supportTransition = (function () {
137
+ var s = document.createElement('p').style,
138
+ r = 'transition' in s ||
139
+ 'WebkitTransition' in s ||
140
+ 'MozTransition' in s ||
141
+ 'msTransition' in s ||
142
+ 'OTransition' in s;
143
+ s = null;
144
+ return r;
145
+ })(),
146
+ // WebUploader实例
147
+ uploader,
148
+ actionUrl = editor.getActionUrl(editor.getOpt('fileActionName')),
149
+ fileMaxSize = editor.getOpt('fileMaxSize'),
150
+ acceptExtensions = (editor.getOpt('fileAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');
151
+ // 隐藏上传按钮
152
+ $upload.hide();
153
+
154
+ if (!WebUploader.Uploader.support()) {
155
+ $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
156
+ return;
157
+ } else if (!editor.getOpt('fileActionName')) {
158
+ // $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
159
+ // return;
160
+ }
161
+
162
+ uploader = _this.uploader = WebUploader.create({
163
+ pick: {
164
+ id: '#filePickerReady',
165
+ label: lang.uploadSelectFile
166
+ },
167
+ swf: '../../third-party/webuploader/Uploader.swf',
168
+ server: actionUrl,
169
+ fileVal: editor.getOpt('fileFieldName'),
170
+ duplicate: true,
171
+ fileSingleSizeLimit: fileMaxSize,
172
+ headers: editor.getOpt('serverHeaders') || {},
173
+ compress: false
174
+ });
175
+ uploader.addButton({
176
+ id: '#filePickerBlock'
177
+ });
178
+ uploader.addButton({
179
+ id: '#filePickerBtn',
180
+ label: lang.uploadAddFile
181
+ });
182
+
183
+ setState('pedding');
184
+
185
+ // 当有文件添加进来时执行,负责view的创建
186
+ function addFile(file) {
187
+ var $li = $('<li id="' + file.id + '">' +
188
+ '<p class="title">' + file.name + '</p>' +
189
+ '<p class="imgWrap"></p>' +
190
+ '<p class="progress"><span></span></p>' +
191
+ '</li>'),
192
+
193
+ $btns = $('<div class="file-panel">' +
194
+ '<span class="cancel">' + lang.uploadDelete + '</span>' +
195
+ '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
196
+ '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
197
+ $prgress = $li.find('p.progress span'),
198
+ $wrap = $li.find('p.imgWrap'),
199
+ $info = $('<p class="error"></p>').hide().appendTo($li),
200
+
201
+ showError = function (code) {
202
+ switch (code) {
203
+ case 'exceed_size':
204
+ text = lang.errorExceedSize;
205
+ break;
206
+ case 'interrupt':
207
+ text = lang.errorInterrupt;
208
+ break;
209
+ case 'http':
210
+ text = lang.errorHttp;
211
+ break;
212
+ case 'not_allow_type':
213
+ text = lang.errorFileType;
214
+ break;
215
+ default:
216
+ text = lang.errorUploadRetry;
217
+ break;
218
+ }
219
+ $info.text(text).show();
220
+ };
221
+
222
+ if (file.getStatus() === 'invalid') {
223
+ showError(file.statusText);
224
+ } else {
225
+ $wrap.text(lang.uploadPreview);
226
+ if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|' + file.ext.toLowerCase() + '|') == -1) {
227
+ $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
228
+ '<span class="file-title" title="' + file.name + '">' + file.name + '</span>');
229
+ } else {
230
+ if (browser.ie && browser.version <= 7) {
231
+ $wrap.text(lang.uploadNoPreview);
232
+ } else {
233
+ uploader.makeThumb(file, function (error, src) {
234
+ if (error || !src) {
235
+ $wrap.text(lang.uploadNoPreview);
236
+ } else {
237
+ var $img = $('<img src="' + src + '">');
238
+ $wrap.empty().append($img);
239
+ $img.on('error', function () {
240
+ $wrap.text(lang.uploadNoPreview);
241
+ });
242
+ }
243
+ }, thumbnailWidth, thumbnailHeight);
244
+ }
245
+ }
246
+ percentages[file.id] = [file.size, 0];
247
+ file.rotation = 0;
248
+
249
+ /* 检查文件格式 */
250
+ if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
251
+ showError('not_allow_type');
252
+ uploader.removeFile(file);
253
+ }
254
+ }
255
+
256
+ file.on('statuschange', function (cur, prev) {
257
+ if (prev === 'progress') {
258
+ $prgress.hide().width(0);
259
+ } else if (prev === 'queued') {
260
+ $li.off('mouseenter mouseleave');
261
+ $btns.remove();
262
+ }
263
+ // 成功
264
+ if (cur === 'error' || cur === 'invalid') {
265
+ showError(file.statusText);
266
+ percentages[file.id][1] = 1;
267
+ } else if (cur === 'interrupt') {
268
+ showError('interrupt');
269
+ } else if (cur === 'queued') {
270
+ percentages[file.id][1] = 0;
271
+ } else if (cur === 'progress') {
272
+ $info.hide();
273
+ $prgress.css('display', 'block');
274
+ } else if (cur === 'complete') {
275
+ }
276
+
277
+ $li.removeClass('state-' + prev).addClass('state-' + cur);
278
+ });
279
+
280
+ $li.on('mouseenter', function () {
281
+ $btns.stop().animate({ height: 30 });
282
+ });
283
+ $li.on('mouseleave', function () {
284
+ $btns.stop().animate({ height: 0 });
285
+ });
286
+
287
+ $btns.on('click', 'span', function () {
288
+ var index = $(this).index(),
289
+ deg;
290
+
291
+ switch (index) {
292
+ case 0:
293
+ uploader.removeFile(file);
294
+ return;
295
+ case 1:
296
+ file.rotation += 90;
297
+ break;
298
+ case 2:
299
+ file.rotation -= 90;
300
+ break;
301
+ }
302
+
303
+ if (supportTransition) {
304
+ deg = 'rotate(' + file.rotation + 'deg)';
305
+ $wrap.css({
306
+ '-webkit-transform': deg,
307
+ '-mos-transform': deg,
308
+ '-o-transform': deg,
309
+ 'transform': deg
310
+ });
311
+ } else {
312
+ $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
313
+ }
314
+
315
+ });
316
+
317
+ $li.insertBefore($filePickerBlock);
318
+ }
319
+
320
+ // 负责view的销毁
321
+ function removeFile(file) {
322
+ var $li = $('#' + file.id);
323
+ delete percentages[file.id];
324
+ updateTotalProgress();
325
+ $li.off().find('.file-panel').off().end().remove();
326
+ }
327
+
328
+ function updateTotalProgress() {
329
+ var loaded = 0,
330
+ total = 0,
331
+ spans = $progress.children(),
332
+ percent;
333
+
334
+ $.each(percentages, function (k, v) {
335
+ total += v[0];
336
+ loaded += v[0] * v[1];
337
+ });
338
+
339
+ percent = total ? loaded / total : 0;
340
+
341
+ spans.eq(0).text(Math.round(percent * 100) + '%');
342
+ spans.eq(1).css('width', Math.round(percent * 100) + '%');
343
+ updateStatus();
344
+ }
345
+
346
+ function setState(val, files) {
347
+
348
+ if (val != state) {
349
+
350
+ var stats = uploader.getStats();
351
+
352
+ $upload.removeClass('state-' + state);
353
+ $upload.addClass('state-' + val);
354
+
355
+ switch (val) {
356
+
357
+ /* 未选择文件 */
358
+ case 'pedding':
359
+ $queue.addClass('element-invisible');
360
+ $statusBar.addClass('element-invisible');
361
+ $placeHolder.removeClass('element-invisible');
362
+ $progress.hide();
363
+ $info.hide();
364
+ uploader.refresh();
365
+ break;
366
+
367
+ /* 可以开始上传 */
368
+ case 'ready':
369
+ $placeHolder.addClass('element-invisible');
370
+ $queue.removeClass('element-invisible');
371
+ $statusBar.removeClass('element-invisible');
372
+ $progress.hide();
373
+ $info.show();
374
+ $upload.text(lang.uploadStart);
375
+ uploader.refresh();
376
+ break;
377
+
378
+ /* 上传中 */
379
+ case 'uploading':
380
+ $progress.show();
381
+ $info.hide();
382
+ $upload.text(lang.uploadPause);
383
+ break;
384
+
385
+ /* 暂停上传 */
386
+ case 'paused':
387
+ $progress.show();
388
+ $info.hide();
389
+ $upload.text(lang.uploadContinue);
390
+ break;
391
+
392
+ case 'confirm':
393
+ $progress.show();
394
+ $info.hide();
395
+ $upload.text(lang.uploadStart);
396
+
397
+ stats = uploader.getStats();
398
+ if (stats.successNum && !stats.uploadFailNum) {
399
+ setState('finish');
400
+ return;
401
+ }
402
+ break;
403
+
404
+ case 'finish':
405
+ $progress.hide();
406
+ $info.show();
407
+ if (stats.uploadFailNum) {
408
+ $upload.text(lang.uploadRetry);
409
+ } else {
410
+ $upload.text(lang.uploadStart);
411
+ }
412
+ break;
413
+ }
414
+
415
+ state = val;
416
+ updateStatus();
417
+
418
+ }
419
+
420
+ if (!_this.getQueueCount()) {
421
+ $upload.addClass('disabled')
422
+ } else {
423
+ $upload.removeClass('disabled')
424
+ }
425
+
426
+ }
427
+
428
+ function updateStatus() {
429
+ var text = '', stats;
430
+
431
+ if (state === 'ready') {
432
+ text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
433
+ } else if (state === 'confirm') {
434
+ stats = uploader.getStats();
435
+ if (stats.uploadFailNum) {
436
+ text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
437
+ }
438
+ } else {
439
+ stats = uploader.getStats();
440
+ text = lang.updateStatusFinish.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)).replace('_', stats.successNum);
441
+
442
+ if (stats.uploadFailNum) {
443
+ text += lang.updateStatusError.replace('_', stats.uploadFailNum);
444
+ }
445
+ }
446
+
447
+ $info.html(text);
448
+ }
449
+
450
+ /**
451
+ * 前置校验
452
+ */
453
+ uploader.on('beforeFileQueued', function (file) {
454
+ if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) {
455
+ return true;
456
+ }
457
+ return false;
458
+ })
459
+
460
+ uploader.on('fileQueued', function (file) {
461
+ if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) {
462
+ fileCount++;
463
+ fileSize += file.size;
464
+ }
465
+
466
+ if (fileCount === 1) {
467
+ $placeHolder.addClass('element-invisible');
468
+ $statusBar.show();
469
+ }
470
+
471
+ addFile(file);
472
+ var uploadFunc = editor.getOpt('uploadFunction');
473
+ if (typeof uploadFunc === 'function') {
474
+ // 开始上传
475
+ if (state === 'ready') {
476
+ setState('uploading');
477
+ } else {
478
+ setState('ready');
479
+ setState('uploading');
480
+ };
481
+ file.setStatus('progress');
482
+ uploader.trigger('uploadProgress', file, 0);
483
+ uploadFunc(file.source.source).then(function (response) {
484
+ uploader.trigger('uploadProgress', file, 1);
485
+ file.setStatus('complete');
486
+ setState('finish');
487
+ uploader.trigger('uploadSuccess', file, response);
488
+ uploader.trigger('uploadComplete', file);
489
+ });
490
+ }
491
+ });
492
+
493
+ uploader.on('fileDequeued', function (file) {
494
+ if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) {
495
+ fileCount--;
496
+ fileSize -= file.size;
497
+ }
498
+
499
+ removeFile(file);
500
+ updateTotalProgress();
501
+ });
502
+
503
+ uploader.on('filesQueued', function (file) {
504
+ if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
505
+ setState('ready');
506
+ }
507
+ updateTotalProgress();
508
+ });
509
+
510
+ uploader.on('all', function (type, files) {
511
+ switch (type) {
512
+ case 'uploadFinished':
513
+ setState('confirm', files);
514
+ break;
515
+ case 'startUpload':
516
+ /* 添加额外的GET参数 */
517
+ var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
518
+ url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + 'encode=utf-8&' + params);
519
+ uploader.option('server', url);
520
+ setState('uploading', files);
521
+ break;
522
+ case 'stopUpload':
523
+ setState('paused', files);
524
+ break;
525
+ }
526
+ });
527
+
528
+ uploader.on('uploadBeforeSend', function (file, data, header) {
529
+ //这里可以通过data对象添加POST参数
530
+ if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
531
+ header['X_Requested_With'] = 'XMLHttpRequest';
532
+ }
533
+ });
534
+
535
+ uploader.on('uploadProgress', function (file, percentage) {
536
+ var $li = $('#' + file.id),
537
+ $percent = $li.find('.progress span');
538
+
539
+ $percent.css('width', percentage * 100 + '%');
540
+ percentages[file.id][1] = percentage;
541
+ updateTotalProgress();
542
+ });
543
+
544
+ uploader.on('uploadSuccess', function (file, json) {
545
+ var $file = $('#' + file.id);
546
+ try {
547
+ if (json.state == 'SUCCESS') {
548
+ _this.fileList.push(json);
549
+ $file.append('<span class="success"></span>');
550
+ // 触发上传附件事件
551
+ editor.fireEvent("uploadsuccess", {
552
+ res: json,
553
+ type: 'file'
554
+ });
555
+ } else {
556
+ $file.find('.error').text(json.state).show();
557
+ }
558
+ } catch (e) {
559
+ $file.find('.error').text(lang.errorServerUpload).show();
560
+ }
561
+ });
562
+
563
+ uploader.on('uploadError', function (file, code) {
564
+ });
565
+ uploader.on('error', function (code, file) {
566
+ if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
567
+ addFile(file);
568
+ }
569
+ });
570
+ uploader.on('uploadComplete', function (file, ret) {
571
+ });
572
+
573
+ $upload.on('click', function () {
574
+ if ($(this).hasClass('disabled')) {
575
+ return false;
576
+ }
577
+
578
+ if (state === 'ready') {
579
+ uploader.upload();
580
+ } else if (state === 'paused') {
581
+ uploader.upload();
582
+ } else if (state === 'uploading') {
583
+ uploader.stop();
584
+ }
585
+ });
586
+
587
+ $upload.addClass('state-' + state);
588
+ updateTotalProgress();
589
+ },
590
+ getQueueCount: function () {
591
+ var file, i, status, readyFile = 0, files = this.uploader.getFiles();
592
+ for (i = 0; file = files[i++];) {
593
+ status = file.getStatus();
594
+ if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
595
+ }
596
+ return readyFile;
597
+ },
598
+ getInsertList: function () {
599
+ var i, link, data, list = [],
600
+ prefix = editor.getOpt('fileUrlPrefix');
601
+ for (i = 0; i < this.fileList.length; i++) {
602
+ data = this.fileList[i];
603
+ link = data.url;
604
+ list.push({
605
+ title: data.original || link.substr(link.lastIndexOf('/') + 1),
606
+ url: prefix + link
607
+ });
608
+ }
609
+ return list;
610
+ }
611
+ };
612
+
613
+
614
+ /* 在线附件 */
615
+ function OnlineFile(target) {
616
+ this.container = utils.isString(target) ? document.getElementById(target) : target;
617
+ this.init();
618
+ }
619
+
620
+ OnlineFile.prototype = {
621
+ init: function () {
622
+ this.initContainer();
623
+ this.initEvents();
624
+ this.initData();
625
+ },
626
+ /* 初始化容器 */
627
+ initContainer: function () {
628
+ this.container.innerHTML = '';
629
+ this.list = document.createElement('ul');
630
+ this.clearFloat = document.createElement('li');
631
+
632
+ domUtils.addClass(this.list, 'list');
633
+ domUtils.addClass(this.clearFloat, 'clearFloat');
634
+
635
+ this.list.appendChild(this.clearFloat);
636
+ this.container.appendChild(this.list);
637
+ },
638
+ /* 初始化滚动事件,滚动到地步自动拉取数据 */
639
+ initEvents: function () {
640
+ var _this = this;
641
+
642
+ /* 滚动拉取图片 */
643
+ domUtils.on($G('fileList'), 'scroll', function (e) {
644
+ var panel = this;
645
+ if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) {
646
+ _this.getFileData();
647
+ }
648
+ });
649
+ /* 选中图片 */
650
+ domUtils.on(this.list, 'click', function (e) {
651
+ var target = e.target || e.srcElement,
652
+ li = target.parentNode;
653
+
654
+ if (li.tagName.toLowerCase() == 'li') {
655
+ if (domUtils.hasClass(li, 'selected')) {
656
+ domUtils.removeClasses(li, 'selected');
657
+ } else {
658
+ domUtils.addClass(li, 'selected');
659
+ }
660
+ }
661
+ });
662
+ },
663
+ /* 初始化第一次的数据 */
664
+ initData: function () {
665
+
666
+ /* 拉取数据需要使用的值 */
667
+ this.state = 0;
668
+ this.listSize = editor.getOpt('fileManagerListSize');
669
+ this.listIndex = 0;
670
+ this.listEnd = false;
671
+
672
+ /* 第一次拉取数据 */
673
+ this.getFileData();
674
+ },
675
+ /* 向后台拉取图片列表数据 */
676
+ getFileData: function () {
677
+ var _this = this;
678
+
679
+ if (!_this.listEnd && !this.isLoadingData) {
680
+ this.isLoadingData = true;
681
+ ajax.request(editor.getActionUrl(editor.getOpt('fileManagerActionName')), {
682
+ timeout: 100000,
683
+ data: utils.extend({
684
+ start: this.listIndex,
685
+ size: this.listSize
686
+ }, editor.queryCommandValue('serverparam')),
687
+ headers: editor.options.serverHeaders || {},
688
+ method: 'get',
689
+ onsuccess: function (r) {
690
+ try {
691
+ var json = eval('(' + r.responseText + ')');
692
+ if (json.state == 'SUCCESS') {
693
+ _this.pushData(json.list);
694
+ _this.listIndex = parseInt(json.start) + parseInt(json.list.length);
695
+ if (_this.listIndex >= json.total) {
696
+ _this.listEnd = true;
697
+ }
698
+ _this.isLoadingData = false;
699
+ }
700
+ } catch (e) {
701
+ if (r.responseText.indexOf('ue_separate_ue') != -1) {
702
+ var list = r.responseText.split(r.responseText);
703
+ _this.pushData(list);
704
+ _this.listIndex = parseInt(list.length);
705
+ _this.listEnd = true;
706
+ _this.isLoadingData = false;
707
+ }
708
+ }
709
+ },
710
+ onerror: function () {
711
+ _this.isLoadingData = false;
712
+ }
713
+ });
714
+ }
715
+ },
716
+ /* 添加图片到列表界面上 */
717
+ pushData: function (list) {
718
+ var i, item, img, filetype, preview, icon, _this = this,
719
+ urlPrefix = editor.getOpt('fileManagerUrlPrefix');
720
+ for (i = 0; i < list.length; i++) {
721
+ if (list[i] && list[i].url) {
722
+ item = document.createElement('li');
723
+ icon = document.createElement('span');
724
+ filetype = list[i].url.substr(list[i].url.lastIndexOf('.') + 1);
725
+
726
+ if ("png|jpg|jpeg|gif|bmp".indexOf(filetype) != -1) {
727
+ preview = document.createElement('img');
728
+ domUtils.on(preview, 'load', (function (image) {
729
+ return function () {
730
+ _this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight);
731
+ };
732
+ })(preview));
733
+ preview.width = 113;
734
+ preview.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=' : '&noCache=') + (+new Date()).toString(36));
735
+ } else {
736
+ var ic = document.createElement('i'),
737
+ textSpan = document.createElement('span');
738
+ textSpan.innerHTML = list[i].original || list[i].url.substr(list[i].url.lastIndexOf('/') + 1);
739
+ preview = document.createElement('div');
740
+ preview.appendChild(ic);
741
+ preview.appendChild(textSpan);
742
+ domUtils.addClass(preview, 'file-wrapper');
743
+ domUtils.addClass(textSpan, 'file-title');
744
+ domUtils.addClass(ic, 'file-type-' + filetype);
745
+ domUtils.addClass(ic, 'file-preview');
746
+ }
747
+ domUtils.addClass(icon, 'icon');
748
+ item.setAttribute('data-url', urlPrefix + list[i].url);
749
+ if (list[i].original) {
750
+ item.setAttribute('data-title', list[i].original);
751
+ }
752
+
753
+ item.appendChild(preview);
754
+ item.appendChild(icon);
755
+ this.list.insertBefore(item, this.clearFloat);
756
+ }
757
+ }
758
+ },
759
+ /* 改变图片大小 */
760
+ scale: function (img, w, h, type) {
761
+ var ow = img.width,
762
+ oh = img.height;
763
+
764
+ if (type == 'justify') {
765
+ if (ow >= oh) {
766
+ img.width = w;
767
+ img.height = h * oh / ow;
768
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
769
+ } else {
770
+ img.width = w * ow / oh;
771
+ img.height = h;
772
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
773
+ }
774
+ } else {
775
+ if (ow >= oh) {
776
+ img.width = w * ow / oh;
777
+ img.height = h;
778
+ img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
779
+ } else {
780
+ img.width = w;
781
+ img.height = h * oh / ow;
782
+ img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
783
+ }
784
+ }
785
+ },
786
+ getInsertList: function () {
787
+ var i, lis = this.list.children, list = [];
788
+ for (i = 0; i < lis.length; i++) {
789
+ if (domUtils.hasClass(lis[i], 'selected')) {
790
+ var url = lis[i].getAttribute('data-url');
791
+ var title = lis[i].getAttribute('data-title') || url.substr(url.lastIndexOf('/') + 1);
792
+ list.push({
793
+ title: title,
794
+ url: url
795
+ });
796
+ }
797
+ }
798
+ return list;
799
+ }
800
+ };
801
+
802
+
803
+ })();