ueditor.rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (302) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/javascripts/default.config.js +382 -0
  5. data/app/assets/javascripts/ueditor.js +2 -0
  6. data/lib/tasks/ueditor_on_rails_tasks.rake +4 -0
  7. data/lib/ueditor.rails.rb +17 -0
  8. data/lib/ueditor/engine.rb +23 -0
  9. data/lib/ueditor/helpers/form_builder.rb +11 -0
  10. data/lib/ueditor/helpers/form_helper.rb +13 -0
  11. data/lib/ueditor/helpers/js_helper.rb +13 -0
  12. data/lib/ueditor/helpers/view_helper.rb +13 -0
  13. data/lib/ueditor/hooks/simple_form.rb +16 -0
  14. data/lib/ueditor/version.rb +3 -0
  15. data/test/dummy/README.rdoc +28 -0
  16. data/test/dummy/Rakefile +6 -0
  17. data/test/dummy/app/assets/javascripts/application.js +14 -0
  18. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  19. data/test/dummy/app/controllers/application_controller.rb +5 -0
  20. data/test/dummy/app/controllers/dummy_controller.rb +18 -0
  21. data/test/dummy/app/helpers/application_helper.rb +2 -0
  22. data/test/dummy/app/models/dummy_model.rb +5 -0
  23. data/test/dummy/app/views/dummy/new.html.erb +22 -0
  24. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  25. data/test/dummy/bin/bundle +3 -0
  26. data/test/dummy/bin/rails +4 -0
  27. data/test/dummy/bin/rake +4 -0
  28. data/test/dummy/config.ru +4 -0
  29. data/test/dummy/config/application.rb +28 -0
  30. data/test/dummy/config/boot.rb +5 -0
  31. data/test/dummy/config/database.yml +25 -0
  32. data/test/dummy/config/environment.rb +5 -0
  33. data/test/dummy/config/environments/development.rb +34 -0
  34. data/test/dummy/config/environments/production.rb +80 -0
  35. data/test/dummy/config/environments/test.rb +39 -0
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/test/dummy/config/initializers/inflections.rb +16 -0
  40. data/test/dummy/config/initializers/mime_types.rb +4 -0
  41. data/test/dummy/config/initializers/session_store.rb +3 -0
  42. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  43. data/test/dummy/config/locales/en.yml +23 -0
  44. data/test/dummy/config/routes.rb +4 -0
  45. data/test/dummy/config/secrets.yml +22 -0
  46. data/test/dummy/log/development.log +51 -0
  47. data/test/dummy/public/404.html +67 -0
  48. data/test/dummy/public/422.html +67 -0
  49. data/test/dummy/public/500.html +66 -0
  50. data/test/dummy/public/favicon.ico +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/029530186b2a67ade6e57e578c85b454 +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/02b56f18dcd4ddec585a02528773c04b +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/07898ec696d976eeafb61ef6bb48e097 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/0ab8e71a1cbfab4ba97406936b8424d8 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/0d7c51218669ae27b1bb2d8ff9c9c1f9 +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/0f941886593d207e4ec1f3aba81f3189 +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/19694ecb6829b547affeb420f6c4f4ba +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/24fd9e383d10c56ae5bf72ce4e8d57d5 +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/2a3155304ce0d3a6b8245de3b211a442 +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/2ef8e8b9d212c49500f1cbb6ab432078 +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/2f6f08f80fb713b72a4c53eca782d352 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/46de6851f078c896ce0a451fe8e67691 +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/4d359ff4c9c3e425adcf7471f456dd80 +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/63be665b75f7410b31ece33884eb8eef +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/7bd63ec22736e590f74f2614ba885123 +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/8165d0bcd2b5c04b4a98f4f0cbabef64 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/8f07cc0565a08f28c45bc04f78ed9feb +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/9239aabeb118940064b039f4afb8f328 +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/92e3cf1ee6169034b72859923497867a +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/98ba4a17ce612c2782d52cb7f2a2beb9 +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/a38c0bac61b2d1e331de0057548aba0f +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/b0df046a48e07ba1cd75447c9732874b +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/b7d95afb3c2e49e813b301d797917b8c +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/bc3d8cda22ec9e1bf2cbe1f02cc13438 +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/bd22193b7c008abf93a7640553ee8b24 +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/c846ab366c3537979e0c1f64aa2c7e23 +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/ccf39b0f3aeafc89430db44186a59037 +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/ce2d1d6840444ec16109eb6d2cf8c224 +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/da3d050a8e457e6eb47cf56f3342fbd5 +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/db1e6b0095d2d333b72e73bdf3c40965 +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/e357c8a9ad97f42187ce017e3bf4a3ce +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/e37eb86c730315ed8a58688351abf8f9 +0 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  89. data/test/dummy/tmp/cache/assets/development/sprockets/fa046bb067616da9d14862739bf2c67c +0 -0
  90. data/test/test_helper.rb +15 -0
  91. data/test/ueditor_on_rails_test.rb +7 -0
  92. data/vendor/assets/javascripts/ueditor/dialogs/anchor/anchor.html +40 -0
  93. data/vendor/assets/javascripts/ueditor/dialogs/attachment/attachment.css +681 -0
  94. data/vendor/assets/javascripts/ueditor/dialogs/attachment/attachment.html +60 -0
  95. data/vendor/assets/javascripts/ueditor/dialogs/attachment/attachment.js +754 -0
  96. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
  97. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
  98. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
  99. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
  100. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_jpg.gif +0 -0
  101. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
  102. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
  103. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
  104. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
  105. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
  106. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
  107. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
  108. data/vendor/assets/javascripts/ueditor/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
  109. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/alignicon.gif +0 -0
  110. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/alignicon.png +0 -0
  111. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/bg.png +0 -0
  112. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/file-icons.gif +0 -0
  113. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/file-icons.png +0 -0
  114. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/icons.gif +0 -0
  115. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/icons.png +0 -0
  116. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/image.png +0 -0
  117. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/progress.png +0 -0
  118. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/success.gif +0 -0
  119. data/vendor/assets/javascripts/ueditor/dialogs/attachment/images/success.png +0 -0
  120. data/vendor/assets/javascripts/ueditor/dialogs/background/background.css +94 -0
  121. data/vendor/assets/javascripts/ueditor/dialogs/background/background.html +56 -0
  122. data/vendor/assets/javascripts/ueditor/dialogs/background/background.js +376 -0
  123. data/vendor/assets/javascripts/ueditor/dialogs/background/images/bg.png +0 -0
  124. data/vendor/assets/javascripts/ueditor/dialogs/background/images/success.png +0 -0
  125. data/vendor/assets/javascripts/ueditor/dialogs/charts/chart.config.js +65 -0
  126. data/vendor/assets/javascripts/ueditor/dialogs/charts/charts.css +165 -0
  127. data/vendor/assets/javascripts/ueditor/dialogs/charts/charts.html +89 -0
  128. data/vendor/assets/javascripts/ueditor/dialogs/charts/charts.js +519 -0
  129. data/vendor/assets/javascripts/ueditor/dialogs/charts/images/charts0.png +0 -0
  130. data/vendor/assets/javascripts/ueditor/dialogs/charts/images/charts1.png +0 -0
  131. data/vendor/assets/javascripts/ueditor/dialogs/charts/images/charts2.png +0 -0
  132. data/vendor/assets/javascripts/ueditor/dialogs/charts/images/charts3.png +0 -0
  133. data/vendor/assets/javascripts/ueditor/dialogs/charts/images/charts4.png +0 -0
  134. data/vendor/assets/javascripts/ueditor/dialogs/charts/images/charts5.png +0 -0
  135. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css +43 -0
  136. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html +54 -0
  137. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.js +186 -0
  138. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/0.gif +0 -0
  139. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/bface.gif +0 -0
  140. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/cface.gif +0 -0
  141. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/fface.gif +0 -0
  142. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
  143. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  144. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/tface.gif +0 -0
  145. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/wface.gif +0 -0
  146. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/yface.gif +0 -0
  147. data/vendor/assets/javascripts/ueditor/dialogs/gmap/gmap.html +89 -0
  148. data/vendor/assets/javascripts/ueditor/dialogs/help/help.css +7 -0
  149. data/vendor/assets/javascripts/ueditor/dialogs/help/help.html +82 -0
  150. data/vendor/assets/javascripts/ueditor/dialogs/help/help.js +56 -0
  151. data/vendor/assets/javascripts/ueditor/dialogs/image/image.css +894 -0
  152. data/vendor/assets/javascripts/ueditor/dialogs/image/image.html +120 -0
  153. data/vendor/assets/javascripts/ueditor/dialogs/image/image.js +1139 -0
  154. data/vendor/assets/javascripts/ueditor/dialogs/image/images/alignicon.jpg +0 -0
  155. data/vendor/assets/javascripts/ueditor/dialogs/image/images/bg.png +0 -0
  156. data/vendor/assets/javascripts/ueditor/dialogs/image/images/icons.gif +0 -0
  157. data/vendor/assets/javascripts/ueditor/dialogs/image/images/icons.png +0 -0
  158. data/vendor/assets/javascripts/ueditor/dialogs/image/images/image.png +0 -0
  159. data/vendor/assets/javascripts/ueditor/dialogs/image/images/progress.png +0 -0
  160. data/vendor/assets/javascripts/ueditor/dialogs/image/images/success.gif +0 -0
  161. data/vendor/assets/javascripts/ueditor/dialogs/image/images/success.png +0 -0
  162. data/vendor/assets/javascripts/ueditor/dialogs/insertframe/insertframe.html +98 -0
  163. data/vendor/assets/javascripts/ueditor/dialogs/internal.js +81 -0
  164. data/vendor/assets/javascripts/ueditor/dialogs/link/link.html +126 -0
  165. data/vendor/assets/javascripts/ueditor/dialogs/map/map.html +135 -0
  166. data/vendor/assets/javascripts/ueditor/dialogs/map/show.html +118 -0
  167. data/vendor/assets/javascripts/ueditor/dialogs/music/music.css +30 -0
  168. data/vendor/assets/javascripts/ueditor/dialogs/music/music.html +32 -0
  169. data/vendor/assets/javascripts/ueditor/dialogs/music/music.js +192 -0
  170. data/vendor/assets/javascripts/ueditor/dialogs/preview/preview.html +40 -0
  171. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/addimg.png +0 -0
  172. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/brush.png +0 -0
  173. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/delimg.png +0 -0
  174. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/delimgH.png +0 -0
  175. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/empty.png +0 -0
  176. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/emptyH.png +0 -0
  177. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/eraser.png +0 -0
  178. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/redo.png +0 -0
  179. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/redoH.png +0 -0
  180. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/scale.png +0 -0
  181. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/scaleH.png +0 -0
  182. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/size.png +0 -0
  183. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/undo.png +0 -0
  184. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/images/undoH.png +0 -0
  185. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/scrawl.css +72 -0
  186. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/scrawl.html +95 -0
  187. data/vendor/assets/javascripts/ueditor/dialogs/scrawl/scrawl.js +671 -0
  188. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.html +102 -0
  189. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.js +164 -0
  190. data/vendor/assets/javascripts/ueditor/dialogs/snapscreen/snapscreen.html +58 -0
  191. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.html +21 -0
  192. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.js +57 -0
  193. data/vendor/assets/javascripts/ueditor/dialogs/table/dragicon.png +0 -0
  194. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.css +84 -0
  195. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.html +64 -0
  196. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.js +237 -0
  197. data/vendor/assets/javascripts/ueditor/dialogs/table/edittd.html +61 -0
  198. data/vendor/assets/javascripts/ueditor/dialogs/table/edittip.html +33 -0
  199. data/vendor/assets/javascripts/ueditor/dialogs/template/config.js +42 -0
  200. data/vendor/assets/javascripts/ueditor/dialogs/template/images/bg.gif +0 -0
  201. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre0.png +0 -0
  202. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre1.png +0 -0
  203. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre2.png +0 -0
  204. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre3.png +0 -0
  205. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre4.png +0 -0
  206. data/vendor/assets/javascripts/ueditor/dialogs/template/template.css +18 -0
  207. data/vendor/assets/javascripts/ueditor/dialogs/template/template.html +26 -0
  208. data/vendor/assets/javascripts/ueditor/dialogs/template/template.js +53 -0
  209. data/vendor/assets/javascripts/ueditor/dialogs/video/images/bg.png +0 -0
  210. data/vendor/assets/javascripts/ueditor/dialogs/video/images/center_focus.jpg +0 -0
  211. data/vendor/assets/javascripts/ueditor/dialogs/video/images/file-icons.gif +0 -0
  212. data/vendor/assets/javascripts/ueditor/dialogs/video/images/file-icons.png +0 -0
  213. data/vendor/assets/javascripts/ueditor/dialogs/video/images/icons.gif +0 -0
  214. data/vendor/assets/javascripts/ueditor/dialogs/video/images/icons.png +0 -0
  215. data/vendor/assets/javascripts/ueditor/dialogs/video/images/image.png +0 -0
  216. data/vendor/assets/javascripts/ueditor/dialogs/video/images/left_focus.jpg +0 -0
  217. data/vendor/assets/javascripts/ueditor/dialogs/video/images/none_focus.jpg +0 -0
  218. data/vendor/assets/javascripts/ueditor/dialogs/video/images/progress.png +0 -0
  219. data/vendor/assets/javascripts/ueditor/dialogs/video/images/right_focus.jpg +0 -0
  220. data/vendor/assets/javascripts/ueditor/dialogs/video/images/success.gif +0 -0
  221. data/vendor/assets/javascripts/ueditor/dialogs/video/images/success.png +0 -0
  222. data/vendor/assets/javascripts/ueditor/dialogs/video/video.css +635 -0
  223. data/vendor/assets/javascripts/ueditor/dialogs/video/video.html +86 -0
  224. data/vendor/assets/javascripts/ueditor/dialogs/video/video.js +789 -0
  225. data/vendor/assets/javascripts/ueditor/dialogs/webapp/webapp.html +53 -0
  226. data/vendor/assets/javascripts/ueditor/dialogs/wordimage/fClipboard_ueditor.swf +0 -0
  227. data/vendor/assets/javascripts/ueditor/dialogs/wordimage/imageUploader.swf +0 -0
  228. data/vendor/assets/javascripts/ueditor/dialogs/wordimage/tangram.js +1495 -0
  229. data/vendor/assets/javascripts/ueditor/dialogs/wordimage/wordimage.html +111 -0
  230. data/vendor/assets/javascripts/ueditor/dialogs/wordimage/wordimage.js +157 -0
  231. data/vendor/assets/javascripts/ueditor/index.html +175 -0
  232. data/vendor/assets/javascripts/ueditor/lang/en/en.js +684 -0
  233. data/vendor/assets/javascripts/ueditor/lang/en/images/addimage.png +0 -0
  234. data/vendor/assets/javascripts/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
  235. data/vendor/assets/javascripts/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
  236. data/vendor/assets/javascripts/ueditor/lang/en/images/background.png +0 -0
  237. data/vendor/assets/javascripts/ueditor/lang/en/images/button.png +0 -0
  238. data/vendor/assets/javascripts/ueditor/lang/en/images/copy.png +0 -0
  239. data/vendor/assets/javascripts/ueditor/lang/en/images/deletedisable.png +0 -0
  240. data/vendor/assets/javascripts/ueditor/lang/en/images/deleteenable.png +0 -0
  241. data/vendor/assets/javascripts/ueditor/lang/en/images/listbackground.png +0 -0
  242. data/vendor/assets/javascripts/ueditor/lang/en/images/localimage.png +0 -0
  243. data/vendor/assets/javascripts/ueditor/lang/en/images/music.png +0 -0
  244. data/vendor/assets/javascripts/ueditor/lang/en/images/rotateleftdisable.png +0 -0
  245. data/vendor/assets/javascripts/ueditor/lang/en/images/rotateleftenable.png +0 -0
  246. data/vendor/assets/javascripts/ueditor/lang/en/images/rotaterightdisable.png +0 -0
  247. data/vendor/assets/javascripts/ueditor/lang/en/images/rotaterightenable.png +0 -0
  248. data/vendor/assets/javascripts/ueditor/lang/en/images/upload.png +0 -0
  249. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/copy.png +0 -0
  250. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/localimage.png +0 -0
  251. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/music.png +0 -0
  252. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/upload.png +0 -0
  253. data/vendor/assets/javascripts/ueditor/lang/zh-cn/zh-cn.js +669 -0
  254. data/vendor/assets/javascripts/ueditor/themes/default/css/ueditor.css +1903 -0
  255. data/vendor/assets/javascripts/ueditor/themes/default/css/ueditor.min.css +8 -0
  256. data/vendor/assets/javascripts/ueditor/themes/default/dialogbase.css +100 -0
  257. data/vendor/assets/javascripts/ueditor/themes/default/images/anchor.gif +0 -0
  258. data/vendor/assets/javascripts/ueditor/themes/default/images/arrow.png +0 -0
  259. data/vendor/assets/javascripts/ueditor/themes/default/images/arrow_down.png +0 -0
  260. data/vendor/assets/javascripts/ueditor/themes/default/images/arrow_up.png +0 -0
  261. data/vendor/assets/javascripts/ueditor/themes/default/images/button-bg.gif +0 -0
  262. data/vendor/assets/javascripts/ueditor/themes/default/images/cancelbutton.gif +0 -0
  263. data/vendor/assets/javascripts/ueditor/themes/default/images/charts.png +0 -0
  264. data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_h.gif +0 -0
  265. data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_h.png +0 -0
  266. data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_v.gif +0 -0
  267. data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_v.png +0 -0
  268. data/vendor/assets/javascripts/ueditor/themes/default/images/dialog-title-bg.png +0 -0
  269. data/vendor/assets/javascripts/ueditor/themes/default/images/filescan.png +0 -0
  270. data/vendor/assets/javascripts/ueditor/themes/default/images/highlighted.gif +0 -0
  271. data/vendor/assets/javascripts/ueditor/themes/default/images/icons-all.gif +0 -0
  272. data/vendor/assets/javascripts/ueditor/themes/default/images/icons.gif +0 -0
  273. data/vendor/assets/javascripts/ueditor/themes/default/images/icons.png +0 -0
  274. data/vendor/assets/javascripts/ueditor/themes/default/images/loaderror.png +0 -0
  275. data/vendor/assets/javascripts/ueditor/themes/default/images/loading.gif +0 -0
  276. data/vendor/assets/javascripts/ueditor/themes/default/images/lock.gif +0 -0
  277. data/vendor/assets/javascripts/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
  278. data/vendor/assets/javascripts/ueditor/themes/default/images/pagebreak.gif +0 -0
  279. data/vendor/assets/javascripts/ueditor/themes/default/images/scale.png +0 -0
  280. data/vendor/assets/javascripts/ueditor/themes/default/images/sortable.png +0 -0
  281. data/vendor/assets/javascripts/ueditor/themes/default/images/spacer.gif +0 -0
  282. data/vendor/assets/javascripts/ueditor/themes/default/images/sparator_v.png +0 -0
  283. data/vendor/assets/javascripts/ueditor/themes/default/images/table-cell-align.png +0 -0
  284. data/vendor/assets/javascripts/ueditor/themes/default/images/tangram-colorpicker.png +0 -0
  285. data/vendor/assets/javascripts/ueditor/themes/default/images/toolbar_bg.png +0 -0
  286. data/vendor/assets/javascripts/ueditor/themes/default/images/unhighlighted.gif +0 -0
  287. data/vendor/assets/javascripts/ueditor/themes/default/images/upload.png +0 -0
  288. data/vendor/assets/javascripts/ueditor/themes/default/images/videologo.gif +0 -0
  289. data/vendor/assets/javascripts/ueditor/themes/default/images/word.gif +0 -0
  290. data/vendor/assets/javascripts/ueditor/themes/default/images/wordpaste.png +0 -0
  291. data/vendor/assets/javascripts/ueditor/themes/iframe.css +1 -0
  292. data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.css +104 -0
  293. data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.js +3581 -0
  294. data/vendor/assets/javascripts/ueditor/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
  295. data/vendor/assets/javascripts/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js +9 -0
  296. data/vendor/assets/javascripts/ueditor/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
  297. data/vendor/assets/javascripts/ueditor/ueditor.all.js +29429 -0
  298. data/vendor/assets/javascripts/ueditor/ueditor.all.min.js +709 -0
  299. data/vendor/assets/javascripts/ueditor/ueditor.config.js +413 -0
  300. data/vendor/assets/javascripts/ueditor/ueditor.parse.js +1022 -0
  301. data/vendor/assets/javascripts/ueditor/ueditor.parse.min.js +28 -0
  302. metadata +464 -0
@@ -0,0 +1,86 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title></title>
6
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
7
+ <script type="text/javascript" src="../internal.js"></script>
8
+ <link rel="stylesheet" type="text/css" href="video.css" />
9
+ </head>
10
+ <body>
11
+ <div class="wrapper">
12
+ <div id="videoTab">
13
+ <div id="tabHeads" class="tabhead">
14
+ <span tabSrc="video" class="focus" data-content-id="video"><var id="lang_tab_insertV"></var></span>
15
+ <span tabSrc="upload" data-content-id="upload"><var id="lang_tab_uploadV"></var></span>
16
+ </div>
17
+ <div id="tabBodys" class="tabbody">
18
+ <div id="video" class="panel focus">
19
+ <table><tr><td><label for="videoUrl" class="url"><var id="lang_video_url"></var></label></td><td><input id="videoUrl" type="text"></td></tr></table>
20
+ <div id="preview"></div>
21
+ <div id="videoInfo">
22
+ <fieldset>
23
+ <legend><var id="lang_video_size"></var></legend>
24
+ <table>
25
+ <tr><td><label for="videoWidth"><var id="lang_videoW"></var></label></td><td><input class="txt" id="videoWidth" type="text"/></td></tr>
26
+ <tr><td><label for="videoHeight"><var id="lang_videoH"></var></label></td><td><input class="txt" id="videoHeight" type="text"/></td></tr>
27
+ </table>
28
+ </fieldset>
29
+ <fieldset>
30
+ <legend><var id="lang_alignment"></var></legend>
31
+ <div id="videoFloat"></div>
32
+ </fieldset>
33
+ </div>
34
+ </div>
35
+ <div id="upload" class="panel">
36
+ <div id="upload_left">
37
+ <div id="queueList" class="queueList">
38
+ <div class="statusBar element-invisible">
39
+ <div class="progress">
40
+ <span class="text">0%</span>
41
+ <span class="percentage"></span>
42
+ </div><div class="info"></div>
43
+ <div class="btns">
44
+ <div id="filePickerBtn"></div>
45
+ <div class="uploadBtn"><var id="lang_start_upload"></var></div>
46
+ </div>
47
+ </div>
48
+ <div id="dndArea" class="placeholder">
49
+ <div class="filePickerContainer">
50
+ <div id="filePickerReady"></div>
51
+ </div>
52
+ </div>
53
+ <ul class="filelist element-invisible">
54
+ <li id="filePickerBlock" class="filePickerBlock"></li>
55
+ </ul>
56
+ </div>
57
+ </div>
58
+ <div id="uploadVideoInfo">
59
+ <fieldset>
60
+ <legend><var id="lang_upload_size"></var></legend>
61
+ <table>
62
+ <tr><td><label><var id="lang_upload_width"></var></label></td><td><input class="txt" id="upload_width" type="text"/></td></tr>
63
+ <tr><td><label><var id="lang_upload_height"></var></label></td><td><input class="txt" id="upload_height" type="text"/></td></tr>
64
+ </table>
65
+ </fieldset>
66
+ <fieldset>
67
+ <legend><var id="lang_upload_alignment"></var></legend>
68
+ <div id="upload_alignment"></div>
69
+ </fieldset>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </div>
75
+
76
+ <!-- jquery -->
77
+ <script type="text/javascript" src="../../third-party/jquery-1.10.2.min.js"></script>
78
+
79
+ <!-- webuploader -->
80
+ <script type="text/javascript" src="../../third-party/webuploader/webuploader.min.js"></script>
81
+ <link rel="stylesheet" type="text/css" href="../../third-party/webuploader/webuploader.css">
82
+
83
+ <!-- video -->
84
+ <script type="text/javascript" src="video.js"></script>
85
+ </body>
86
+ </html>
@@ -0,0 +1,789 @@
1
+ /**
2
+ * Created by JetBrains PhpStorm.
3
+ * User: taoqili
4
+ * Date: 12-2-20
5
+ * Time: 上午11:19
6
+ * To change this template use File | Settings | File Templates.
7
+ */
8
+
9
+ (function(){
10
+
11
+ var video = {},
12
+ uploadVideoList = [],
13
+ isModifyUploadVideo = false,
14
+ uploadFile;
15
+
16
+ window.onload = function(){
17
+ $focus($G("videoUrl"));
18
+ initTabs();
19
+ initVideo();
20
+ initUpload();
21
+ };
22
+
23
+ /* 初始化tab标签 */
24
+ function initTabs(){
25
+ var tabs = $G('tabHeads').children;
26
+ for (var i = 0; i < tabs.length; i++) {
27
+ domUtils.on(tabs[i], "click", function (e) {
28
+ var j, bodyId, target = e.target || e.srcElement;
29
+ for (j = 0; j < tabs.length; j++) {
30
+ bodyId = tabs[j].getAttribute('data-content-id');
31
+ if(tabs[j] == target){
32
+ domUtils.addClass(tabs[j], 'focus');
33
+ domUtils.addClass($G(bodyId), 'focus');
34
+ }else {
35
+ domUtils.removeClasses(tabs[j], 'focus');
36
+ domUtils.removeClasses($G(bodyId), 'focus');
37
+ }
38
+ }
39
+ });
40
+ }
41
+ }
42
+
43
+ function initVideo(){
44
+ createAlignButton( ["videoFloat", "upload_alignment"] );
45
+ addUrlChangeListener($G("videoUrl"));
46
+ addOkListener();
47
+
48
+ //编辑视频时初始化相关信息
49
+ (function(){
50
+ var img = editor.selection.getRange().getClosedNode(),url;
51
+ if(img && img.className){
52
+ var hasFakedClass = (img.className == "edui-faked-video"),
53
+ hasUploadClass = img.className.indexOf("edui-upload-video")!=-1;
54
+ if(hasFakedClass || hasUploadClass) {
55
+ $G("videoUrl").value = url = img.getAttribute("_url");
56
+ $G("videoWidth").value = img.width;
57
+ $G("videoHeight").value = img.height;
58
+ var align = domUtils.getComputedStyle(img,"float"),
59
+ parentAlign = domUtils.getComputedStyle(img.parentNode,"text-align");
60
+ updateAlignButton(parentAlign==="center"?"center":align);
61
+ }
62
+ if(hasUploadClass) {
63
+ isModifyUploadVideo = true;
64
+ }
65
+ }
66
+ createPreviewVideo(url);
67
+ })();
68
+ }
69
+
70
+ /**
71
+ * 监听确认和取消两个按钮事件,用户执行插入或者清空正在播放的视频实例操作
72
+ */
73
+ function addOkListener(){
74
+ dialog.onok = function(){
75
+ $G("preview").innerHTML = "";
76
+ var currentTab = findFocus("tabHeads","tabSrc");
77
+ switch(currentTab){
78
+ case "video":
79
+ return insertSingle();
80
+ break;
81
+ case "videoSearch":
82
+ return insertSearch("searchList");
83
+ break;
84
+ case "upload":
85
+ return insertUpload();
86
+ break;
87
+ }
88
+ };
89
+ dialog.oncancel = function(){
90
+ $G("preview").innerHTML = "";
91
+ };
92
+ }
93
+
94
+ /**
95
+ * 依据传入的align值更新按钮信息
96
+ * @param align
97
+ */
98
+ function updateAlignButton( align ) {
99
+ var aligns = $G( "videoFloat" ).children;
100
+ for ( var i = 0, ci; ci = aligns[i++]; ) {
101
+ if ( ci.getAttribute( "name" ) == align ) {
102
+ if ( ci.className !="focus" ) {
103
+ ci.className = "focus";
104
+ }
105
+ } else {
106
+ if ( ci.className =="focus" ) {
107
+ ci.className = "";
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ /**
114
+ * 将单个视频信息插入编辑器中
115
+ */
116
+ function insertSingle(){
117
+ var width = $G("videoWidth"),
118
+ height = $G("videoHeight"),
119
+ url=$G('videoUrl').value,
120
+ align = findFocus("videoFloat","name");
121
+ if(!url) return false;
122
+ if ( !checkNum( [width, height] ) ) return false;
123
+ editor.execCommand('insertvideo', {
124
+ url: convert_url(url),
125
+ width: width.value,
126
+ height: height.value,
127
+ align: align
128
+ }, isModifyUploadVideo ? 'upload':null);
129
+ }
130
+
131
+ /**
132
+ * 将元素id下的所有代表视频的图片插入编辑器中
133
+ * @param id
134
+ */
135
+ function insertSearch(id){
136
+ var imgs = domUtils.getElementsByTagName($G(id),"img"),
137
+ videoObjs=[];
138
+ for(var i=0,img; img=imgs[i++];){
139
+ if(img.getAttribute("selected")){
140
+ videoObjs.push({
141
+ url:img.getAttribute("ue_video_url"),
142
+ width:420,
143
+ height:280,
144
+ align:"none"
145
+ });
146
+ }
147
+ }
148
+ editor.execCommand('insertvideo',videoObjs);
149
+ }
150
+
151
+ /**
152
+ * 找到id下具有focus类的节点并返回该节点下的某个属性
153
+ * @param id
154
+ * @param returnProperty
155
+ */
156
+ function findFocus( id, returnProperty ) {
157
+ var tabs = $G( id ).children,
158
+ property;
159
+ for ( var i = 0, ci; ci = tabs[i++]; ) {
160
+ if ( ci.className=="focus" ) {
161
+ property = ci.getAttribute( returnProperty );
162
+ break;
163
+ }
164
+ }
165
+ return property;
166
+ }
167
+ function convert_url(url){
168
+ if ( !url ) return '';
169
+ url = utils.trim(url)
170
+ .replace(/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i, 'player.youku.com/player.php/sid/$1/v.swf')
171
+ .replace(/(www\.)?youtube\.com\/watch\?v=([\w\-]+)/i, "www.youtube.com/v/$2")
172
+ .replace(/youtu.be\/(\w+)$/i, "www.youtube.com/v/$1")
173
+ .replace(/v\.ku6\.com\/.+\/([\w\.]+)\.html.*$/i, "player.ku6.com/refer/$1/v.swf")
174
+ .replace(/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i, "player.56.com/v_$1.swf")
175
+ .replace(/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i, "player.56.com/v_$1.swf")
176
+ .replace(/v\.pps\.tv\/play_([\w]+)\.html.*$/i, "player.pps.tv/player/sid/$1/v.swf")
177
+ .replace(/www\.letv\.com\/ptv\/vplay\/([\d]+)\.html.*$/i, "i7.imgs.letv.com/player/swfPlayer.swf?id=$1&autoplay=0")
178
+ .replace(/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i, "www.tudou.com/v/$1")
179
+ .replace(/v\.qq\.com\/cover\/[\w]+\/[\w]+\/([\w]+)\.html/i, "static.video.qq.com/TPout.swf?vid=$1")
180
+ .replace(/v\.qq\.com\/.+[\?\&]vid=([^&]+).*$/i, "static.video.qq.com/TPout.swf?vid=$1")
181
+ .replace(/my\.tv\.sohu\.com\/[\w]+\/[\d]+\/([\d]+)\.shtml.*$/i, "share.vrs.sohu.com/my/v.swf&id=$1");
182
+
183
+ return url;
184
+ }
185
+
186
+ /**
187
+ * 检测传入的所有input框中输入的长宽是否是正数
188
+ * @param nodes input框集合,
189
+ */
190
+ function checkNum( nodes ) {
191
+ for ( var i = 0, ci; ci = nodes[i++]; ) {
192
+ var value = ci.value;
193
+ if ( !isNumber( value ) && value) {
194
+ alert( lang.numError );
195
+ ci.value = "";
196
+ ci.focus();
197
+ return false;
198
+ }
199
+ }
200
+ return true;
201
+ }
202
+
203
+ /**
204
+ * 数字判断
205
+ * @param value
206
+ */
207
+ function isNumber( value ) {
208
+ return /(0|^[1-9]\d*$)/.test( value );
209
+ }
210
+
211
+ /**
212
+ * 创建图片浮动选择按钮
213
+ * @param ids
214
+ */
215
+ function createAlignButton( ids ) {
216
+ for ( var i = 0, ci; ci = ids[i++]; ) {
217
+ var floatContainer = $G( ci ),
218
+ nameMaps = {"none":lang['default'], "left":lang.floatLeft, "right":lang.floatRight, "center":lang.block};
219
+ for ( var j in nameMaps ) {
220
+ var div = document.createElement( "div" );
221
+ div.setAttribute( "name", j );
222
+ if ( j == "none" ) div.className="focus";
223
+ div.style.cssText = "background:url(images/" + j + "_focus.jpg);";
224
+ div.setAttribute( "title", nameMaps[j] );
225
+ floatContainer.appendChild( div );
226
+ }
227
+ switchSelect( ci );
228
+ }
229
+ }
230
+
231
+ /**
232
+ * 选择切换
233
+ * @param selectParentId
234
+ */
235
+ function switchSelect( selectParentId ) {
236
+ var selects = $G( selectParentId ).children;
237
+ for ( var i = 0, ci; ci = selects[i++]; ) {
238
+ domUtils.on( ci, "click", function () {
239
+ for ( var j = 0, cj; cj = selects[j++]; ) {
240
+ cj.className = "";
241
+ cj.removeAttribute && cj.removeAttribute( "class" );
242
+ }
243
+ this.className = "focus";
244
+ } )
245
+ }
246
+ }
247
+
248
+ /**
249
+ * 监听url改变事件
250
+ * @param url
251
+ */
252
+ function addUrlChangeListener(url){
253
+ if (browser.ie) {
254
+ url.onpropertychange = function () {
255
+ createPreviewVideo( this.value );
256
+ }
257
+ } else {
258
+ url.addEventListener( "input", function () {
259
+ createPreviewVideo( this.value );
260
+ }, false );
261
+ }
262
+ }
263
+
264
+ /**
265
+ * 根据url生成视频预览
266
+ * @param url
267
+ */
268
+ function createPreviewVideo(url){
269
+ if ( !url )return;
270
+
271
+ var conUrl = convert_url(url);
272
+
273
+ $G("preview").innerHTML = '<div class="previewMsg"><span>'+lang.urlError+'</span></div>'+
274
+ '<embed class="previewVideo" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
275
+ ' src="' + conUrl + '"' +
276
+ ' width="' + 420 + '"' +
277
+ ' height="' + 280 + '"' +
278
+ ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >' +
279
+ '</embed>';
280
+ }
281
+
282
+
283
+ /* 插入上传视频 */
284
+ function insertUpload(){
285
+ var videoObjs=[],
286
+ uploadDir = editor.getOpt('videoUrlPrefix'),
287
+ width = $G('upload_width').value || 420,
288
+ height = $G('upload_height').value || 280,
289
+ align = findFocus("upload_alignment","name") || 'none';
290
+ for(var key in uploadVideoList) {
291
+ var file = uploadVideoList[key];
292
+ videoObjs.push({
293
+ url: uploadDir + file.url,
294
+ width:width,
295
+ height:height,
296
+ align:align
297
+ });
298
+ }
299
+
300
+ var count = uploadFile.getQueueCount();
301
+ if (count) {
302
+ $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
303
+ return false;
304
+ } else {
305
+ editor.execCommand('insertvideo', videoObjs, 'upload');
306
+ }
307
+ }
308
+
309
+ /*初始化上传标签*/
310
+ function initUpload(){
311
+ uploadFile = new UploadFile('queueList');
312
+ }
313
+
314
+
315
+ /* 上传附件 */
316
+ function UploadFile(target) {
317
+ this.$wrap = target.constructor == String ? $('#' + target) : $(target);
318
+ this.init();
319
+ }
320
+ UploadFile.prototype = {
321
+ init: function () {
322
+ this.fileList = [];
323
+ this.initContainer();
324
+ this.initUploader();
325
+ },
326
+ initContainer: function () {
327
+ this.$queue = this.$wrap.find('.filelist');
328
+ },
329
+ /* 初始化容器 */
330
+ initUploader: function () {
331
+ var _this = this,
332
+ $ = jQuery, // just in case. Make sure it's not an other libaray.
333
+ $wrap = _this.$wrap,
334
+ // 图片容器
335
+ $queue = $wrap.find('.filelist'),
336
+ // 状态栏,包括进度和控制按钮
337
+ $statusBar = $wrap.find('.statusBar'),
338
+ // 文件总体选择信息。
339
+ $info = $statusBar.find('.info'),
340
+ // 上传按钮
341
+ $upload = $wrap.find('.uploadBtn'),
342
+ // 上传按钮
343
+ $filePickerBtn = $wrap.find('.filePickerBtn'),
344
+ // 上传按钮
345
+ $filePickerBlock = $wrap.find('.filePickerBlock'),
346
+ // 没选择文件之前的内容。
347
+ $placeHolder = $wrap.find('.placeholder'),
348
+ // 总体进度条
349
+ $progress = $statusBar.find('.progress').hide(),
350
+ // 添加的文件数量
351
+ fileCount = 0,
352
+ // 添加的文件总大小
353
+ fileSize = 0,
354
+ // 优化retina, 在retina下这个值是2
355
+ ratio = window.devicePixelRatio || 1,
356
+ // 缩略图大小
357
+ thumbnailWidth = 113 * ratio,
358
+ thumbnailHeight = 113 * ratio,
359
+ // 可能有pedding, ready, uploading, confirm, done.
360
+ state = '',
361
+ // 所有文件的进度信息,key为file id
362
+ percentages = {},
363
+ supportTransition = (function () {
364
+ var s = document.createElement('p').style,
365
+ r = 'transition' in s ||
366
+ 'WebkitTransition' in s ||
367
+ 'MozTransition' in s ||
368
+ 'msTransition' in s ||
369
+ 'OTransition' in s;
370
+ s = null;
371
+ return r;
372
+ })(),
373
+ // WebUploader实例
374
+ uploader,
375
+ actionUrl = editor.getActionUrl(editor.getOpt('videoActionName')),
376
+ fileMaxSize = editor.getOpt('videoMaxSize'),
377
+ acceptExtensions = (editor.getOpt('videoAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');;
378
+
379
+ if (!WebUploader.Uploader.support()) {
380
+ $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
381
+ return;
382
+ } else if (!editor.getOpt('videoActionName')) {
383
+ $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
384
+ return;
385
+ }
386
+
387
+ uploader = _this.uploader = WebUploader.create({
388
+ pick: {
389
+ id: '#filePickerReady',
390
+ label: lang.uploadSelectFile
391
+ },
392
+ swf: '../../third-party/webuploader/Uploader.swf',
393
+ server: actionUrl,
394
+ fileVal: editor.getOpt('videoFieldName'),
395
+ duplicate: true,
396
+ fileSingleSizeLimit: fileMaxSize,
397
+ compress: false
398
+ });
399
+ uploader.addButton({
400
+ id: '#filePickerBlock'
401
+ });
402
+ uploader.addButton({
403
+ id: '#filePickerBtn',
404
+ label: lang.uploadAddFile
405
+ });
406
+
407
+ setState('pedding');
408
+
409
+ // 当有文件添加进来时执行,负责view的创建
410
+ function addFile(file) {
411
+ var $li = $('<li id="' + file.id + '">' +
412
+ '<p class="title">' + file.name + '</p>' +
413
+ '<p class="imgWrap"></p>' +
414
+ '<p class="progress"><span></span></p>' +
415
+ '</li>'),
416
+
417
+ $btns = $('<div class="file-panel">' +
418
+ '<span class="cancel">' + lang.uploadDelete + '</span>' +
419
+ '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
420
+ '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
421
+ $prgress = $li.find('p.progress span'),
422
+ $wrap = $li.find('p.imgWrap'),
423
+ $info = $('<p class="error"></p>').hide().appendTo($li),
424
+
425
+ showError = function (code) {
426
+ switch (code) {
427
+ case 'exceed_size':
428
+ text = lang.errorExceedSize;
429
+ break;
430
+ case 'interrupt':
431
+ text = lang.errorInterrupt;
432
+ break;
433
+ case 'http':
434
+ text = lang.errorHttp;
435
+ break;
436
+ case 'not_allow_type':
437
+ text = lang.errorFileType;
438
+ break;
439
+ default:
440
+ text = lang.errorUploadRetry;
441
+ break;
442
+ }
443
+ $info.text(text).show();
444
+ };
445
+
446
+ if (file.getStatus() === 'invalid') {
447
+ showError(file.statusText);
448
+ } else {
449
+ $wrap.text(lang.uploadPreview);
450
+ if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|'+file.ext.toLowerCase()+'|') == -1) {
451
+ $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
452
+ '<span class="file-title">' + file.name + '</span>');
453
+ } else {
454
+ if (browser.ie && browser.version <= 7) {
455
+ $wrap.text(lang.uploadNoPreview);
456
+ } else {
457
+ uploader.makeThumb(file, function (error, src) {
458
+ if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
459
+ $wrap.text(lang.uploadNoPreview);
460
+ } else {
461
+ var $img = $('<img src="' + src + '">');
462
+ $wrap.empty().append($img);
463
+ $img.on('error', function () {
464
+ $wrap.text(lang.uploadNoPreview);
465
+ });
466
+ }
467
+ }, thumbnailWidth, thumbnailHeight);
468
+ }
469
+ }
470
+ percentages[ file.id ] = [ file.size, 0 ];
471
+ file.rotation = 0;
472
+
473
+ /* 检查文件格式 */
474
+ if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
475
+ showError('not_allow_type');
476
+ uploader.removeFile(file);
477
+ }
478
+ }
479
+
480
+ file.on('statuschange', function (cur, prev) {
481
+ if (prev === 'progress') {
482
+ $prgress.hide().width(0);
483
+ } else if (prev === 'queued') {
484
+ $li.off('mouseenter mouseleave');
485
+ $btns.remove();
486
+ }
487
+ // 成功
488
+ if (cur === 'error' || cur === 'invalid') {
489
+ showError(file.statusText);
490
+ percentages[ file.id ][ 1 ] = 1;
491
+ } else if (cur === 'interrupt') {
492
+ showError('interrupt');
493
+ } else if (cur === 'queued') {
494
+ percentages[ file.id ][ 1 ] = 0;
495
+ } else if (cur === 'progress') {
496
+ $info.hide();
497
+ $prgress.css('display', 'block');
498
+ } else if (cur === 'complete') {
499
+ }
500
+
501
+ $li.removeClass('state-' + prev).addClass('state-' + cur);
502
+ });
503
+
504
+ $li.on('mouseenter', function () {
505
+ $btns.stop().animate({height: 30});
506
+ });
507
+ $li.on('mouseleave', function () {
508
+ $btns.stop().animate({height: 0});
509
+ });
510
+
511
+ $btns.on('click', 'span', function () {
512
+ var index = $(this).index(),
513
+ deg;
514
+
515
+ switch (index) {
516
+ case 0:
517
+ uploader.removeFile(file);
518
+ return;
519
+ case 1:
520
+ file.rotation += 90;
521
+ break;
522
+ case 2:
523
+ file.rotation -= 90;
524
+ break;
525
+ }
526
+
527
+ if (supportTransition) {
528
+ deg = 'rotate(' + file.rotation + 'deg)';
529
+ $wrap.css({
530
+ '-webkit-transform': deg,
531
+ '-mos-transform': deg,
532
+ '-o-transform': deg,
533
+ 'transform': deg
534
+ });
535
+ } else {
536
+ $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
537
+ }
538
+
539
+ });
540
+
541
+ $li.insertBefore($filePickerBlock);
542
+ }
543
+
544
+ // 负责view的销毁
545
+ function removeFile(file) {
546
+ var $li = $('#' + file.id);
547
+ delete percentages[ file.id ];
548
+ updateTotalProgress();
549
+ $li.off().find('.file-panel').off().end().remove();
550
+ }
551
+
552
+ function updateTotalProgress() {
553
+ var loaded = 0,
554
+ total = 0,
555
+ spans = $progress.children(),
556
+ percent;
557
+
558
+ $.each(percentages, function (k, v) {
559
+ total += v[ 0 ];
560
+ loaded += v[ 0 ] * v[ 1 ];
561
+ });
562
+
563
+ percent = total ? loaded / total : 0;
564
+
565
+ spans.eq(0).text(Math.round(percent * 100) + '%');
566
+ spans.eq(1).css('width', Math.round(percent * 100) + '%');
567
+ updateStatus();
568
+ }
569
+
570
+ function setState(val, files) {
571
+
572
+ if (val != state) {
573
+
574
+ var stats = uploader.getStats();
575
+
576
+ $upload.removeClass('state-' + state);
577
+ $upload.addClass('state-' + val);
578
+
579
+ switch (val) {
580
+
581
+ /* 未选择文件 */
582
+ case 'pedding':
583
+ $queue.addClass('element-invisible');
584
+ $statusBar.addClass('element-invisible');
585
+ $placeHolder.removeClass('element-invisible');
586
+ $progress.hide(); $info.hide();
587
+ uploader.refresh();
588
+ break;
589
+
590
+ /* 可以开始上传 */
591
+ case 'ready':
592
+ $placeHolder.addClass('element-invisible');
593
+ $queue.removeClass('element-invisible');
594
+ $statusBar.removeClass('element-invisible');
595
+ $progress.hide(); $info.show();
596
+ $upload.text(lang.uploadStart);
597
+ uploader.refresh();
598
+ break;
599
+
600
+ /* 上传中 */
601
+ case 'uploading':
602
+ $progress.show(); $info.hide();
603
+ $upload.text(lang.uploadPause);
604
+ break;
605
+
606
+ /* 暂停上传 */
607
+ case 'paused':
608
+ $progress.show(); $info.hide();
609
+ $upload.text(lang.uploadContinue);
610
+ break;
611
+
612
+ case 'confirm':
613
+ $progress.show(); $info.hide();
614
+ $upload.text(lang.uploadStart);
615
+
616
+ stats = uploader.getStats();
617
+ if (stats.successNum && !stats.uploadFailNum) {
618
+ setState('finish');
619
+ return;
620
+ }
621
+ break;
622
+
623
+ case 'finish':
624
+ $progress.hide(); $info.show();
625
+ if (stats.uploadFailNum) {
626
+ $upload.text(lang.uploadRetry);
627
+ } else {
628
+ $upload.text(lang.uploadStart);
629
+ }
630
+ break;
631
+ }
632
+
633
+ state = val;
634
+ updateStatus();
635
+
636
+ }
637
+
638
+ if (!_this.getQueueCount()) {
639
+ $upload.addClass('disabled')
640
+ } else {
641
+ $upload.removeClass('disabled')
642
+ }
643
+
644
+ }
645
+
646
+ function updateStatus() {
647
+ var text = '', stats;
648
+
649
+ if (state === 'ready') {
650
+ text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
651
+ } else if (state === 'confirm') {
652
+ stats = uploader.getStats();
653
+ if (stats.uploadFailNum) {
654
+ text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
655
+ }
656
+ } else {
657
+ stats = uploader.getStats();
658
+ text = lang.updateStatusFinish.replace('_', fileCount).
659
+ replace('_KB', WebUploader.formatSize(fileSize)).
660
+ replace('_', stats.successNum);
661
+
662
+ if (stats.uploadFailNum) {
663
+ text += lang.updateStatusError.replace('_', stats.uploadFailNum);
664
+ }
665
+ }
666
+
667
+ $info.html(text);
668
+ }
669
+
670
+ uploader.on('fileQueued', function (file) {
671
+ fileCount++;
672
+ fileSize += file.size;
673
+
674
+ if (fileCount === 1) {
675
+ $placeHolder.addClass('element-invisible');
676
+ $statusBar.show();
677
+ }
678
+
679
+ addFile(file);
680
+ });
681
+
682
+ uploader.on('fileDequeued', function (file) {
683
+ fileCount--;
684
+ fileSize -= file.size;
685
+
686
+ removeFile(file);
687
+ updateTotalProgress();
688
+ });
689
+
690
+ uploader.on('filesQueued', function (file) {
691
+ if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
692
+ setState('ready');
693
+ }
694
+ updateTotalProgress();
695
+ });
696
+
697
+ uploader.on('all', function (type, files) {
698
+ switch (type) {
699
+ case 'uploadFinished':
700
+ setState('confirm', files);
701
+ break;
702
+ case 'startUpload':
703
+ /* 添加额外的GET参数 */
704
+ var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
705
+ url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?':'&') + 'encode=utf-8&' + params);
706
+ uploader.option('server', url);
707
+ setState('uploading', files);
708
+ break;
709
+ case 'stopUpload':
710
+ setState('paused', files);
711
+ break;
712
+ }
713
+ });
714
+
715
+ uploader.on('uploadBeforeSend', function (file, data, header) {
716
+ //这里可以通过data对象添加POST参数
717
+ header['X_Requested_With'] = 'XMLHttpRequest';
718
+ });
719
+
720
+ uploader.on('uploadProgress', function (file, percentage) {
721
+ var $li = $('#' + file.id),
722
+ $percent = $li.find('.progress span');
723
+
724
+ $percent.css('width', percentage * 100 + '%');
725
+ percentages[ file.id ][ 1 ] = percentage;
726
+ updateTotalProgress();
727
+ });
728
+
729
+ uploader.on('uploadSuccess', function (file, ret) {
730
+ var $file = $('#' + file.id);
731
+ try {
732
+ var responseText = (ret._raw || ret),
733
+ json = utils.str2json(responseText);
734
+ if (json.state == 'SUCCESS') {
735
+ uploadVideoList.push({
736
+ 'url': json.url,
737
+ 'type': json.type,
738
+ 'original':json.original
739
+ });
740
+ $file.append('<span class="success"></span>');
741
+ } else {
742
+ $file.find('.error').text(json.state).show();
743
+ }
744
+ } catch (e) {
745
+ $file.find('.error').text(lang.errorServerUpload).show();
746
+ }
747
+ });
748
+
749
+ uploader.on('uploadError', function (file, code) {
750
+ });
751
+ uploader.on('error', function (code, file) {
752
+ if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
753
+ addFile(file);
754
+ }
755
+ });
756
+ uploader.on('uploadComplete', function (file, ret) {
757
+ });
758
+
759
+ $upload.on('click', function () {
760
+ if ($(this).hasClass('disabled')) {
761
+ return false;
762
+ }
763
+
764
+ if (state === 'ready') {
765
+ uploader.upload();
766
+ } else if (state === 'paused') {
767
+ uploader.upload();
768
+ } else if (state === 'uploading') {
769
+ uploader.stop();
770
+ }
771
+ });
772
+
773
+ $upload.addClass('state-' + state);
774
+ updateTotalProgress();
775
+ },
776
+ getQueueCount: function () {
777
+ var file, i, status, readyFile = 0, files = this.uploader.getFiles();
778
+ for (i = 0; file = files[i++]; ) {
779
+ status = file.getStatus();
780
+ if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
781
+ }
782
+ return readyFile;
783
+ },
784
+ refresh: function(){
785
+ this.uploader.refresh();
786
+ }
787
+ };
788
+
789
+ })();