ueditor_rails4 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.markdown +45 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/images/ueditor/themes/default/anchor.gif +0 -0
  6. data/app/assets/images/ueditor/themes/default/arrow.png +0 -0
  7. data/app/assets/images/ueditor/themes/default/button-bg.gif +0 -0
  8. data/app/assets/images/ueditor/themes/default/cancelbutton.gif +0 -0
  9. data/app/assets/images/ueditor/themes/default/cursor_h.gif +0 -0
  10. data/app/assets/images/ueditor/themes/default/cursor_h.png +0 -0
  11. data/app/assets/images/ueditor/themes/default/cursor_v.gif +0 -0
  12. data/app/assets/images/ueditor/themes/default/cursor_v.png +0 -0
  13. data/app/assets/images/ueditor/themes/default/dialog-title-bg.png +0 -0
  14. data/app/assets/images/ueditor/themes/default/filescan.png +0 -0
  15. data/app/assets/images/ueditor/themes/default/highlighted.gif +0 -0
  16. data/app/assets/images/ueditor/themes/default/icons-all.gif +0 -0
  17. data/app/assets/images/ueditor/themes/default/icons.gif +0 -0
  18. data/app/assets/images/ueditor/themes/default/icons.png +0 -0
  19. data/app/assets/images/ueditor/themes/default/lock.gif +0 -0
  20. data/app/assets/images/ueditor/themes/default/neweditor-tab-bg.png +0 -0
  21. data/app/assets/images/ueditor/themes/default/pagebreak.gif +0 -0
  22. data/app/assets/images/ueditor/themes/default/scale.png +0 -0
  23. data/app/assets/images/ueditor/themes/default/spacer.gif +0 -0
  24. data/app/assets/images/ueditor/themes/default/sparator_v.png +0 -0
  25. data/app/assets/images/ueditor/themes/default/toolbar_bg.png +0 -0
  26. data/app/assets/images/ueditor/themes/default/unhighlighted.gif +0 -0
  27. data/app/assets/images/ueditor/themes/default/upload.png +0 -0
  28. data/app/assets/images/ueditor/themes/default/videologo.gif +0 -0
  29. data/app/assets/images/ueditor/themes/default/word.gif +0 -0
  30. data/app/assets/images/ueditor/themes/default/wordpaste.png +0 -0
  31. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
  32. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
  33. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
  34. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
  35. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
  36. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
  37. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
  38. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
  39. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
  40. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
  41. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
  42. data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
  43. data/app/assets/images/ueditor_rails/dialogs/image/center_focus.jpg +0 -0
  44. data/app/assets/images/ueditor_rails/dialogs/image/left_focus.jpg +0 -0
  45. data/app/assets/images/ueditor_rails/dialogs/image/none_focus.jpg +0 -0
  46. data/app/assets/images/ueditor_rails/dialogs/image/right_focus.jpg +0 -0
  47. data/app/assets/images/ueditor_rails/dialogs/scrawl/addimg.png +0 -0
  48. data/app/assets/images/ueditor_rails/dialogs/scrawl/brush.png +0 -0
  49. data/app/assets/images/ueditor_rails/dialogs/scrawl/delimg.png +0 -0
  50. data/app/assets/images/ueditor_rails/dialogs/scrawl/delimgH.png +0 -0
  51. data/app/assets/images/ueditor_rails/dialogs/scrawl/empty.png +0 -0
  52. data/app/assets/images/ueditor_rails/dialogs/scrawl/emptyH.png +0 -0
  53. data/app/assets/images/ueditor_rails/dialogs/scrawl/eraser.png +0 -0
  54. data/app/assets/images/ueditor_rails/dialogs/scrawl/redo.png +0 -0
  55. data/app/assets/images/ueditor_rails/dialogs/scrawl/redoH.png +0 -0
  56. data/app/assets/images/ueditor_rails/dialogs/scrawl/scale.png +0 -0
  57. data/app/assets/images/ueditor_rails/dialogs/scrawl/scaleH.png +0 -0
  58. data/app/assets/images/ueditor_rails/dialogs/scrawl/size.png +0 -0
  59. data/app/assets/images/ueditor_rails/dialogs/scrawl/undo.png +0 -0
  60. data/app/assets/images/ueditor_rails/dialogs/scrawl/undoH.png +0 -0
  61. data/app/assets/javascripts/ueditor_rails/_config.js.erb +211 -0
  62. data/app/assets/javascripts/ueditor_rails/dialogs/attachment.js +5 -0
  63. data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_callbacks.js +166 -0
  64. data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_file_type_maps.js.erb +14 -0
  65. data/app/assets/javascripts/ueditor_rails/dialogs/image.js.erb +724 -0
  66. data/app/assets/javascripts/ueditor_rails/dialogs/scrawl.js +655 -0
  67. data/app/assets/javascripts/ueditor_rails/dialogs/wordimage.js +154 -0
  68. data/app/assets/javascripts/ueditor_rails/init.js +12 -0
  69. data/app/assets/stylesheets/ueditor/themes/default/dialogbase.css.erb +100 -0
  70. data/app/assets/stylesheets/ueditor/themes/default/ueditor.css +1582 -0
  71. data/app/assets/stylesheets/ueditor/themes/iframe.css +1 -0
  72. data/app/assets/stylesheets/ueditor_rails/dialogs/attachment.css.erb +161 -0
  73. data/app/assets/stylesheets/ueditor_rails/dialogs/image.css.erb +69 -0
  74. data/app/assets/stylesheets/ueditor_rails/dialogs/scrawl.css.erb +72 -0
  75. data/app/controllers/ueditor_rails/application_controller.rb +5 -0
  76. data/app/controllers/ueditor_rails/dialogs_controller.rb +21 -0
  77. data/app/controllers/ueditor_rails/libs_controller.rb +33 -0
  78. data/app/helpers/ueditor_rails/application_helper.rb +27 -0
  79. data/app/views/ueditor_rails/dialogs/attachment.html.erb +124 -0
  80. data/app/views/ueditor_rails/dialogs/image.html.erb +203 -0
  81. data/app/views/ueditor_rails/dialogs/scrawl.html.erb +96 -0
  82. data/app/views/ueditor_rails/dialogs/wordimage.html.erb +155 -0
  83. data/config/routes.rb +11 -0
  84. data/lib/generators/ueditor_rails/USAGE +8 -0
  85. data/lib/generators/ueditor_rails/install_generator.rb +15 -0
  86. data/lib/generators/ueditor_rails/templates/ueditor_config.js.erb +216 -0
  87. data/lib/tasks/ueditor_rails_tasks.rake +4 -0
  88. data/lib/ueditor_rails/engine.rb +17 -0
  89. data/lib/ueditor_rails/helpers/form_builder.rb +11 -0
  90. data/lib/ueditor_rails/helpers/form_helper.rb +37 -0
  91. data/lib/ueditor_rails/helpers/view_helper.rb +21 -0
  92. data/lib/ueditor_rails/util.rb +42 -0
  93. data/lib/ueditor_rails/version.rb +3 -0
  94. data/lib/ueditor_rails4.rb +32 -0
  95. data/test/dummy/README.rdoc +261 -0
  96. data/test/dummy/Rakefile +7 -0
  97. data/test/dummy/app/assets/javascripts/application.js +16 -0
  98. data/test/dummy/app/assets/javascripts/posts.js +2 -0
  99. data/test/dummy/app/assets/javascripts/ueditor_config.js.erb +208 -0
  100. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  101. data/test/dummy/app/assets/stylesheets/posts.css +4 -0
  102. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  103. data/test/dummy/app/controllers/application_controller.rb +3 -0
  104. data/test/dummy/app/controllers/posts_controller.rb +83 -0
  105. data/test/dummy/app/helpers/application_helper.rb +2 -0
  106. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  107. data/test/dummy/app/models/post.rb +3 -0
  108. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  109. data/test/dummy/app/views/posts/_form.html.erb +25 -0
  110. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  111. data/test/dummy/app/views/posts/index.html.erb +29 -0
  112. data/test/dummy/app/views/posts/new.html.erb +5 -0
  113. data/test/dummy/app/views/posts/show.html.erb +14 -0
  114. data/test/dummy/config.ru +4 -0
  115. data/test/dummy/config/application.rb +61 -0
  116. data/test/dummy/config/boot.rb +10 -0
  117. data/test/dummy/config/database.yml +25 -0
  118. data/test/dummy/config/environment.rb +5 -0
  119. data/test/dummy/config/environments/development.rb +37 -0
  120. data/test/dummy/config/environments/production.rb +67 -0
  121. data/test/dummy/config/environments/test.rb +37 -0
  122. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  123. data/test/dummy/config/initializers/inflections.rb +15 -0
  124. data/test/dummy/config/initializers/mime_types.rb +5 -0
  125. data/test/dummy/config/initializers/secret_token.rb +7 -0
  126. data/test/dummy/config/initializers/session_store.rb +8 -0
  127. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  128. data/test/dummy/config/locales/en.yml +5 -0
  129. data/test/dummy/config/routes.rb +8 -0
  130. data/test/dummy/db/migrate/20130327173045_create_posts.rb +10 -0
  131. data/test/dummy/db/schema.rb +23 -0
  132. data/test/dummy/public/404.html +26 -0
  133. data/test/dummy/public/422.html +26 -0
  134. data/test/dummy/public/500.html +25 -0
  135. data/test/dummy/public/favicon.ico +0 -0
  136. data/test/dummy/script/rails +6 -0
  137. data/test/dummy/test/fixtures/posts.yml +9 -0
  138. data/test/dummy/test/functional/posts_controller_test.rb +49 -0
  139. data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  140. data/test/dummy/test/unit/post_test.rb +7 -0
  141. data/test/functional/ueditor_rails/dialogs_controller_test.rb +16 -0
  142. data/test/functional/ueditor_rails/libs_controller_test.rb +21 -0
  143. data/test/integration/navigation_test.rb +10 -0
  144. data/test/test_helper.rb +15 -0
  145. data/test/ueditor_rails_test.rb +7 -0
  146. data/vendor/assets/javascripts/ueditor/dialogs/anchor/anchor.html.erb +57 -0
  147. data/vendor/assets/javascripts/ueditor/dialogs/background/background.css +24 -0
  148. data/vendor/assets/javascripts/ueditor/dialogs/background/background.html.erb +55 -0
  149. data/vendor/assets/javascripts/ueditor/dialogs/background/background.js +348 -0
  150. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css.erb +43 -0
  151. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html.erb +54 -0
  152. data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.js +186 -0
  153. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/0.gif +0 -0
  154. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/bface.gif +0 -0
  155. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/cface.gif +0 -0
  156. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/fface.gif +0 -0
  157. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
  158. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
  159. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/tface.gif +0 -0
  160. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/wface.gif +0 -0
  161. data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/yface.gif +0 -0
  162. data/vendor/assets/javascripts/ueditor/dialogs/gmap/gmap.html.erb +89 -0
  163. data/vendor/assets/javascripts/ueditor/dialogs/help/help.css +7 -0
  164. data/vendor/assets/javascripts/ueditor/dialogs/help/help.html.erb +84 -0
  165. data/vendor/assets/javascripts/ueditor/dialogs/help/help.js +54 -0
  166. data/vendor/assets/javascripts/ueditor/dialogs/highlightcode/highlightcode.html.erb +131 -0
  167. data/vendor/assets/javascripts/ueditor/dialogs/insertframe/insertframe.html.erb +98 -0
  168. data/vendor/assets/javascripts/ueditor/dialogs/internal.js +79 -0
  169. data/vendor/assets/javascripts/ueditor/dialogs/link/link.html.erb +141 -0
  170. data/vendor/assets/javascripts/ueditor/dialogs/map/map.html.erb +105 -0
  171. data/vendor/assets/javascripts/ueditor/dialogs/music/music.css +30 -0
  172. data/vendor/assets/javascripts/ueditor/dialogs/music/music.html.erb +32 -0
  173. data/vendor/assets/javascripts/ueditor/dialogs/music/music.js +192 -0
  174. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.html.erb +74 -0
  175. data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.js +160 -0
  176. data/vendor/assets/javascripts/ueditor/dialogs/snapscreen/snapscreen.html.erb +91 -0
  177. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.html.erb +21 -0
  178. data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.js +56 -0
  179. data/vendor/assets/javascripts/ueditor/dialogs/table/dragicon.png +0 -0
  180. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.css +75 -0
  181. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.html.erb +57 -0
  182. data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.js +182 -0
  183. data/vendor/assets/javascripts/ueditor/dialogs/table/edittd.html.erb +51 -0
  184. data/vendor/assets/javascripts/ueditor/dialogs/table/edittip.html.erb +33 -0
  185. data/vendor/assets/javascripts/ueditor/dialogs/tangram.js +1238 -0
  186. data/vendor/assets/javascripts/ueditor/dialogs/template/config.js +42 -0
  187. data/vendor/assets/javascripts/ueditor/dialogs/template/images/bg.gif +0 -0
  188. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre0.png +0 -0
  189. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre1.png +0 -0
  190. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre2.png +0 -0
  191. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre3.png +0 -0
  192. data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre4.png +0 -0
  193. data/vendor/assets/javascripts/ueditor/dialogs/template/template.css +18 -0
  194. data/vendor/assets/javascripts/ueditor/dialogs/template/template.html.erb +26 -0
  195. data/vendor/assets/javascripts/ueditor/dialogs/template/template.js +53 -0
  196. data/vendor/assets/javascripts/ueditor/dialogs/video/images/center_focus.jpg +0 -0
  197. data/vendor/assets/javascripts/ueditor/dialogs/video/images/left_focus.jpg +0 -0
  198. data/vendor/assets/javascripts/ueditor/dialogs/video/images/none_focus.jpg +0 -0
  199. data/vendor/assets/javascripts/ueditor/dialogs/video/images/right_focus.jpg +0 -0
  200. data/vendor/assets/javascripts/ueditor/dialogs/video/video.css +59 -0
  201. data/vendor/assets/javascripts/ueditor/dialogs/video/video.html.erb +78 -0
  202. data/vendor/assets/javascripts/ueditor/dialogs/video/video.js.erb +409 -0
  203. data/vendor/assets/javascripts/ueditor/dialogs/webapp/webapp.html.erb +64 -0
  204. data/vendor/assets/javascripts/ueditor/editor_all.js.erb +19133 -0
  205. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/copy.png +0 -0
  206. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/imglabel.png +0 -0
  207. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/localimage.png +0 -0
  208. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/music.png +0 -0
  209. data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/upload.png +0 -0
  210. data/vendor/assets/javascripts/ueditor/lang/zh-cn/zh-cn.js +492 -0
  211. data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
  212. data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +316 -0
  213. data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.css +104 -0
  214. data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.js +3581 -0
  215. data/vendor/assets/javascripts/ueditor/third-party/fClipboard_ueditor.swf +0 -0
  216. data/vendor/assets/javascripts/ueditor/third-party/imageUploader.swf +0 -0
  217. data/vendor/assets/javascripts/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
  218. data/vendor/assets/javascripts/ueditor/third-party/swfupload/fileprogress.js +215 -0
  219. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.cookies.js +53 -0
  220. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.js +1132 -0
  221. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.proxy.js +96 -0
  222. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.queue.js +98 -0
  223. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.speed.js +346 -0
  224. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.swf +0 -0
  225. data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload_fp9.swf +0 -0
  226. data/vendor/assets/javascripts/ueditor/uparse.js +348 -0
  227. metadata +363 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ name: MyString
5
+ body: MyText
6
+
7
+ two:
8
+ name: MyString
9
+ body: MyText
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class PostsControllerTest < ActionController::TestCase
4
+ setup do
5
+ @post = posts(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:posts)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create post" do
20
+ assert_difference('Post.count') do
21
+ post :create, post: { body: @post.body, name: @post.name }
22
+ end
23
+
24
+ assert_redirected_to post_path(assigns(:post))
25
+ end
26
+
27
+ test "should show post" do
28
+ get :show, id: @post
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, id: @post
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update post" do
38
+ put :update, id: @post, post: { body: @post.body, name: @post.name }
39
+ assert_redirected_to post_path(assigns(:post))
40
+ end
41
+
42
+ test "should destroy post" do
43
+ assert_difference('Post.count', -1) do
44
+ delete :destroy, id: @post
45
+ end
46
+
47
+ assert_redirected_to posts_path
48
+ end
49
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class PostsHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ module UeditorRails
4
+ class DialogsControllerTest < ActionController::TestCase
5
+ test "should get attachment" do
6
+ get :attachment
7
+ assert_response :success
8
+ end
9
+
10
+ test "should get image" do
11
+ get :image
12
+ assert_response :success
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ module UeditorRails
4
+ class LibsControllerTest < ActionController::TestCase
5
+ test "should get swf_image_uploader" do
6
+ get :swf_image_uploader
7
+ assert_response :success
8
+ end
9
+
10
+ test "should get swf_upload" do
11
+ get :swf_upload
12
+ assert_response :success
13
+ end
14
+
15
+ test "should get swf_upload_fp9" do
16
+ get :swf_upload_fp9
17
+ assert_response :success
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class UeditorRailsTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, UeditorRails
6
+ end
7
+ end
@@ -0,0 +1,57 @@
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
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <title></title>
7
+ <style type="text/css">
8
+ * {
9
+ color: #838383;
10
+ margin: 0;
11
+ padding: 0
12
+ }
13
+
14
+ html, body {
15
+ font-size: 12px;
16
+ overflow: hidden;
17
+ }
18
+
19
+ .content {
20
+ padding: 5px 0 0 15px;
21
+ }
22
+
23
+ input {
24
+ width: 210px;
25
+ height: 21px;
26
+ line-height: 21px;
27
+ margin-left: 4px;
28
+ }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div class="content">
33
+ <span><var id="lang_input_anchorName"></var></span><input id="anchorName" value=""/>
34
+ </div>
35
+ <%= javascript_include_tag 'ueditor/dialogs/internal.js' %>
36
+ <script type="text/javascript">
37
+ var anchorInput = $G('anchorName'),
38
+ node = editor.selection.getRange().getClosedNode();
39
+ if (node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))) {
40
+ anchorInput.value = node;
41
+ }
42
+ anchorInput.onkeydown = function (evt) {
43
+ evt = evt || window.event;
44
+ if (evt.keyCode == 13) {
45
+ editor.execCommand('anchor', anchorInput.value);
46
+ dialog.close();
47
+ domUtils.preventDefault(evt)
48
+ }
49
+ };
50
+ dialog.onok = function () {
51
+ editor.execCommand('anchor', anchorInput.value);
52
+ dialog.close();
53
+ };
54
+ $focus(anchorInput);
55
+ </script>
56
+ </body>
57
+ </html>
@@ -0,0 +1,24 @@
1
+ .wrapper{ width: 424px;margin: 10px auto; zoom:1;position: relative}
2
+ .tabbody{height:225px;}
3
+ .panel { position: absolute;width:100%; height:100%;background: #fff;}
4
+
5
+ body{font-size: 12px;color: #888;overflow: hidden;}
6
+ input,label{vertical-align:middle}
7
+ .clear{clear: both;}
8
+ .pl{padding-left: 23px;padding-left: 28px\9;}
9
+
10
+ #imageList {width: 420px;height: 215px;margin-top: 10px;overflow: hidden;overflow-y: auto;}
11
+ #imageList div {float: left;width: 100px;height: 95px;margin: 5px 10px;}
12
+ #imageList img {cursor: pointer;border: 2px solid white;}
13
+
14
+ .bgarea{margin: 10px;padding: 5px;height: 84%;border: 1px solid #A8A297;}
15
+ .content div{margin: 10px 0 10px 5px;}
16
+ .content .iptradio{margin-right: 10px;}
17
+ .txt{width:280px;}
18
+
19
+ .wrapcolor{height: 19px;}
20
+ div.color{float: left;margin: 0;}
21
+ #colorPicker{width: 17px;height: 17px;border: 1px solid #CCC;display: inline-block;border-radius: 3px;box-shadow: 2px 2px 5px #D3D6DA;margin: 0;float: left;}
22
+ div.alignment,#custom{margin-left: 30px;margin-left: 35px\9;}
23
+ #custom input{height: 15px;min-height: 15px;width:20px;}
24
+ #repeatType{width:100px;}
@@ -0,0 +1,55 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
5
+ <%= stylesheet_link_tag 'ueditor/dialogs/background/background.css' %>
6
+ </head>
7
+ <body>
8
+ <div id="bg_container" class="wrapper">
9
+ <div id="tabHeads" class="tabhead">
10
+ <span class="focus" tabsrc="normal"><var id="lang_background_normal"></var></span>
11
+ <span class="" tabsrc="imgManager"><var id="lang_background_local"></var></span>
12
+ </div>
13
+ <div id="tabBodys" class="tabbody">
14
+ <div id="normal" class="panel">
15
+ <fieldset class="bgarea">
16
+ <legend><var id="lang_background_set"></var></legend>
17
+ <div class="content">
18
+ <div>
19
+ <input class="iptradio" type="radio" name="t" value="none" checked="checked" onclick="net(this)"><label><var id="lang_background_none"></var></label>
20
+ </div>
21
+ <div class="wrapcolor">
22
+ <div class="color">
23
+ <input class="iptradio" type="radio" name="t" value="color" onclick="net(this)"><label><var id="lang_background_color"></var>:</label>
24
+ </div>
25
+ <div id="colorPicker"></div>
26
+ <div class="clear"></div>
27
+ </div>
28
+ <div class="wrapcolor pl">
29
+ <label><var id="lang_background_netimg"></var>:</label><input class="txt" type="text" id="url">
30
+ </div>
31
+ <div id="alignment" class="alignment">
32
+ <var id="lang_background_align"></var>:<select id="repeatType" onchange="selectAlign(this)">
33
+ <option value="center"></option>
34
+ <option value="repeat-x"></option>
35
+ <option value="repeat-y"></option>
36
+ <option value="repeat"></option>
37
+ <option value="self"></option>
38
+ </select>
39
+ </div>
40
+ <div id="custom">
41
+ <var id="lang_background_position"></var>:x:<input type="text" size="1" id="x" maxlength="4" value="0">px&nbsp;&nbsp;y:<input type="text" size="1" id="y" maxlength="4" value="0">px
42
+ </div>
43
+ </div>
44
+ </fieldset>
45
+
46
+ </div>
47
+ <div id="imgManager" class="panel">
48
+ <div id="imageList" style=""></div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <%= javascript_include_tag 'ueditor/dialogs/internal.js' %>
53
+ <%= javascript_include_tag 'ueditor/dialogs/background/background.js' %>
54
+ </body>
55
+ </html>
@@ -0,0 +1,348 @@
1
+ var me = editor,
2
+ doc = me.document,
3
+ bodyStyle,
4
+ cp = $G("colorPicker"),
5
+ bkbodyStyle = "",
6
+ bkcolor = "";
7
+ var popup = new UE.ui.Popup({
8
+ content:new UE.ui.ColorPicker({
9
+ noColorText:me.getLang("clearColor"),
10
+ editor:me,
11
+ onpickcolor:function (t, color) {
12
+ domUtils.setStyle(cp, "background-color", color);
13
+ bkcolor = color;
14
+ UE.ui.Popup.postHide();
15
+ },
16
+ onpicknocolor:function (t, color) {
17
+ domUtils.setStyle(cp, "background-color", "transparent");
18
+ bkcolor = "";
19
+ UE.ui.Popup.postHide();
20
+ }
21
+ }),
22
+ editor:me,
23
+ onhide:function () {
24
+ setBody();
25
+ }
26
+ });
27
+ domUtils.on(cp, "click", function () {
28
+ popup.showAnchor(this);
29
+ });
30
+ domUtils.on(document, 'mousedown', function (evt) {
31
+ var el = evt.target || evt.srcElement;
32
+ UE.ui.Popup.postHide(el);
33
+ });
34
+ domUtils.on(window, 'scroll', function () {
35
+ UE.ui.Popup.postHide();
36
+ });
37
+ //获得head
38
+ var getHead = function () {
39
+ return domUtils.getElementsByTagName($G("tabHeads"), "span");
40
+ };
41
+ //给head绑定事件
42
+ var bindClick = function () {
43
+ var heads = getHead();
44
+ for (var i = 0, head; head = heads[i++];) {
45
+ head.onclick = function () {
46
+ var bodyid = this.getAttribute("tabsrc");
47
+ toggleHead(this);
48
+ toggleBody(bodyid);
49
+ if (bodyid == "imgManager") {
50
+ ajax.request(editor.options.imageManagerUrl, {
51
+ timeout:100000,
52
+ action:"get",
53
+ onsuccess:function (xhr) {
54
+ var tmp = utils.trim(xhr.responseText),
55
+ imageUrls = !tmp ? [] : tmp.split("ue_separate_ue"),
56
+ length = imageUrls.length,
57
+ imgList = $G("imageList");
58
+ imgList.innerHTML = !length ? "&nbsp;&nbsp;" + lang.noUploadImage : "";
59
+ for (var k = 0, ci; ci = imageUrls[k++];) {
60
+ var img = document.createElement("img");
61
+ var div = document.createElement("div");
62
+ div.appendChild(img);
63
+ div.style.display = "none";
64
+ imgList.appendChild(div);
65
+ img.onclick = function () {
66
+ var nodes = imgList.childNodes;
67
+ for (var i = 0, node; node = nodes[i++];) {
68
+ node.firstChild.removeAttribute("selected");
69
+ node.firstChild.style.cssText = "filter:alpha(Opacity=100);-moz-opacity:1;opacity: 1;border: 2px solid #fff";
70
+ }
71
+ changeSelected(this);
72
+ };
73
+ img.onload = function () {
74
+ this.parentNode.style.display = "";
75
+ var w = this.width, h = this.height;
76
+ scale(this, 95, 120, 80);
77
+ this.title = lang.toggleSelect + w + "X" + h;
78
+ };
79
+ img.setAttribute(k < 35 ? "src" : "lazy_src", editor.options.imageManagerPath + ci.replace(/\s+|\s+/ig, ""));
80
+ img.setAttribute("data_ue_src", editor.options.imageManagerPath + ci.replace(/\s+|\s+/ig, ""));
81
+
82
+ }
83
+ },
84
+ onerror:function () {
85
+ $G("imageList").innerHTML = lang.imageLoadError;
86
+ }
87
+ });
88
+ } else {
89
+ var radios = document.getElementsByName("t");
90
+ for (var i = 0, r; r = radios[i++];) {
91
+ if (r.checked && r.value != "none") {
92
+ $G("repeatType").style.display = "";
93
+ net(r);
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ };
100
+ /**
101
+ * 改变o的选中状态
102
+ * @param o
103
+ */
104
+ function changeSelected(o) {
105
+ if (o.getAttribute("selected")) {
106
+ o.removeAttribute("selected");
107
+ o.style.cssText = "filter:alpha(Opacity=100);-moz-opacity:1;opacity: 1;border: 2px solid #fff";
108
+ } else {
109
+ o.setAttribute("selected", "true");
110
+ o.style.cssText = "filter:alpha(Opacity=50);-moz-opacity:0.5;opacity: 0.5;border:2px solid blue;";
111
+ }
112
+ $G("url").value = o.getAttribute("src")
113
+ }
114
+ /**
115
+ * 图片缩放
116
+ * @param img
117
+ * @param max
118
+ */
119
+ function scale(img, max, oWidth, oHeight) {
120
+ var width = 0, height = 0, percent, ow = img.width || oWidth, oh = img.height || oHeight;
121
+ if (ow > max || oh > max) {
122
+ if (ow >= oh) {
123
+ if (width = ow - max) {
124
+ percent = (width / ow).toFixed(2);
125
+ img.height = oh - oh * percent;
126
+ img.width = max;
127
+ }
128
+ } else {
129
+ if (height = oh - max) {
130
+ percent = (height / oh).toFixed(2);
131
+ img.width = ow - ow * percent;
132
+ img.height = max;
133
+ }
134
+ }
135
+ }
136
+ }
137
+ //切换body
138
+ var toggleBody = function (id) {
139
+ var bodys = ["normal", "imgManager"];
140
+ for (var i = 0, body; body = bodys[i++];) {
141
+ $G(body).style.zIndex = body == id ? 200 : 1;
142
+ }
143
+ };
144
+ //切换head
145
+ var toggleHead = function (obj) {
146
+ var heads = getHead();
147
+ for (var i = 0, head; head = heads[i++];) {
148
+ domUtils.removeClasses(head, ["focus"]);
149
+ $G("repeatType").style.display = "none";
150
+ }
151
+ domUtils.addClass(obj, "focus");
152
+ };
153
+ //获得当前选中的tab
154
+ var getCheckedTab = function () {
155
+ var heads = getHead();
156
+ for (var i = 0, head; head = heads[i++];) {
157
+ if (domUtils.hasClass(head, "focus")) {
158
+ return head;
159
+ }
160
+ }
161
+ };
162
+
163
+
164
+ var init = function () {
165
+ bindClick();
166
+ var el = getHead()[0],
167
+ bodyid = el.getAttribute("tabsrc");
168
+ toggleHead(el);
169
+ toggleBody(bodyid);
170
+ $G("alignment").style.display = "none";
171
+ $G("custom").style.display = "none";
172
+ //初始化颜色
173
+ domUtils.setStyle(cp, "background-color", domUtils.getComputedStyle(doc.body, "background-color"));
174
+ var color = domUtils.getComputedStyle(doc.body, "background-color");
175
+ if ((color && color != "#ffffff" && color != "transparent") || domUtils.getComputedStyle(doc.body, "background-image") != "none") {
176
+ setTimeout(function () {
177
+ document.getElementsByName("t")[1].click();
178
+ }, 200);
179
+ }
180
+ initImgUrl();
181
+ initSelfPos();
182
+ initAlign();
183
+ };
184
+ //初始化自定义位置
185
+ function initSelfPos() {
186
+ var x, y;
187
+ if (browser.ie) {
188
+ x = domUtils.getComputedStyle(doc.body, "background-position-x").replace(/50%|%|px|center/ig, "");
189
+ y = domUtils.getComputedStyle(doc.body, "background-position-y").replace(/50%|%|px|center/ig, "");
190
+ } else {
191
+ var arr = domUtils.getComputedStyle(doc.body, "background-position").match(/\s?(\d*)px/ig);
192
+ if (arr && arr.length) {
193
+ x = arr[0].replace("px", "");
194
+ y = arr[1].replace("px", "");
195
+ }
196
+ }
197
+ $G("x").value = x || 0;
198
+ $G("y").value = y || 0;
199
+ }
200
+ //初始化图片地址
201
+ function initImgUrl() {
202
+ var su = domUtils.getComputedStyle(doc.body, "background-image"),
203
+ url = "";
204
+ if (su.indexOf(me.options.imagePath) > 0) {
205
+ url = su.match(/url\("?(.*[^\)"])"?/i);
206
+ if (url && url.length) {
207
+ url = url[1].substring(url[1].indexOf(me.options.imagePath), url[1].length);
208
+ }
209
+ } else {
210
+ url = su != "none" ? su.replace(/url\("?|"?\)/ig, "") : "";
211
+ }
212
+ $G("url").value = url;
213
+ }
214
+ //初始化定位
215
+ function initAlign() {
216
+ var align = domUtils.getComputedStyle(doc.body, "background-repeat"),
217
+ alignType = $G("repeatType");
218
+ if (align == "no-repeat") {
219
+ var pos = domUtils.getComputedStyle(doc.body, browser.ie ? "background-position-x" : "background-position");
220
+ alignType.value = pos && pos.match(/\s?(\d*)px/ig) ? "self" : "center";
221
+ if (pos == "center") {
222
+ alignType.value = "center";
223
+ }
224
+ $G("custom").style.display = alignType.value == "self" ? "" : "none";
225
+ } else {
226
+ alignType.value = align;
227
+ }
228
+ }
229
+ init();
230
+
231
+
232
+
233
+ //获得选中的类型
234
+ function getCheckIpt() {
235
+ var ipts = document.getElementsByName("t");
236
+ for (var i = 0, ipt; ipt = ipts[i++];) {
237
+ if (ipt.checked) {
238
+ return ipt.value;
239
+ }
240
+ }
241
+ }
242
+ var net = function (obj) {
243
+ var align = $G("alignment"),
244
+ url = $G("url"),
245
+ custom = $G("custom");
246
+ if (obj.value == "none") {
247
+ align.style.display = "none";
248
+ custom.style.display = "none";
249
+ if (browser.ie) {
250
+ url.onpropertychange = null;
251
+ } else {
252
+ url.removeEventListener("input", setBody);
253
+ }
254
+ } else {
255
+ bindSelfPos();
256
+ $G("repeatType").style.display = "";
257
+ align.style.display = "";
258
+ if (browser.ie) {
259
+ url.onpropertychange = setBody;
260
+ } else {
261
+ url.addEventListener("input", setBody, false);
262
+ }
263
+ }
264
+ setBody();
265
+ };
266
+ //给自定义位置绑定事件
267
+ var bindSelfPos = function () {
268
+ var x = $G("x"),
269
+ y = $G("y");
270
+ domUtils.on(x, ["propertychange", "input", "keydown"], function (evt) {
271
+ bindkeydown(evt, this);
272
+ });
273
+ domUtils.on(y, ["propertychange", "input", "keydown"], function (evt) {
274
+ bindkeydown(evt, this);
275
+ });
276
+ function bindkeydown(evt, obj) {
277
+ evt = evt || event;
278
+ if (evt.keyCode == 38 || evt.keyCode == 40) {
279
+ obj.value = evt.keyCode == 38 ? parseInt(obj.value) + 1 : parseInt(obj.value) - 1;
280
+ if (obj.value < 0) {
281
+ obj.value = 0;
282
+ }
283
+ } else {
284
+ if (evt.keyCode < 48 && evt.keyCode > 57) {
285
+ domUtils.preventDefault(evt);
286
+ }
287
+ }
288
+ setBody();
289
+ }
290
+ };
291
+ var showAlign = function () {
292
+ $G("alignment").style.display = "";
293
+ };
294
+ var selectAlign = function (obj) {
295
+ $G("custom").style.display = obj.value == "self" ? "" : "none";
296
+ setBody();
297
+ };
298
+ //给body增加样式和背景图片
299
+ var setBody = function () {
300
+ var color = domUtils.getStyle(cp, "background-color"),
301
+ bgimg = $G("url").value,
302
+ align = $G("repeatType").value,
303
+ alignObj = {
304
+ "background-repeat":"no-repeat",
305
+ "background-position":"center center"
306
+ },
307
+ outstr = [];
308
+ if (color)
309
+ alignObj["background-color"] = color;
310
+ if (bgimg)
311
+ alignObj["background-image"] = 'url("' + bgimg + '")';
312
+ switch (align) {
313
+ case "repeat-x":
314
+ alignObj["background-repeat"] = "repeat-x;";
315
+ break;
316
+ case "repeat-y":
317
+ alignObj["background-repeat"] = "repeat-y;";
318
+ break;
319
+ case "repeat":
320
+ alignObj["background-repeat"] = "repeat;";
321
+ break;
322
+ case "self":
323
+ alignObj["background-position"] = $G("x").value + "px " + $G("y").value + "px";
324
+ break;
325
+ }
326
+ for (var name in alignObj) {
327
+ if (alignObj.hasOwnProperty(name)) {
328
+ outstr.push(name + ":" + alignObj[name]);
329
+ }
330
+ }
331
+ if (getCheckIpt() != "none") {
332
+ utils.cssRule('body','body{' + outstr.join(";") + '}',doc);
333
+
334
+ } else {
335
+
336
+ utils.cssRule('body','',doc)
337
+ }
338
+ };
339
+
340
+
341
+
342
+ dialog.onok = function () {
343
+ setBody();
344
+ };
345
+ dialog.oncancel = function () {
346
+ utils.cssRule('body',bkbodyStyle,doc)
347
+ };
348
+ bkbodyStyle = utils.cssRule('body',undefined,doc);