noodall-ui 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (542) hide show
  1. data/.document +5 -0
  2. data/.gitignore +29 -0
  3. data/Gemfile +29 -0
  4. data/Gemfile.lock +205 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +17 -0
  7. data/Rakefile +17 -0
  8. data/app/controllers/noodall/admin/assets_controller.rb +241 -0
  9. data/app/controllers/noodall/admin/base_controller.rb +8 -0
  10. data/app/controllers/noodall/admin/components_controller.rb +22 -0
  11. data/app/controllers/noodall/admin/groups_controller.rb +11 -0
  12. data/app/controllers/noodall/admin/nodes_controller.rb +159 -0
  13. data/app/controllers/noodall/nodes_controller.rb +41 -0
  14. data/app/helpers/noodall/admin/assets_helper.rb +15 -0
  15. data/app/helpers/noodall/admin/base_helper.rb +14 -0
  16. data/app/helpers/noodall/admin/nodes_helper.rb +37 -0
  17. data/app/helpers/noodall/components_helper.rb +38 -0
  18. data/app/helpers/noodall/layout_helper.rb +25 -0
  19. data/app/helpers/noodall/nodes_helper.rb +72 -0
  20. data/app/models/asset.rb +103 -0
  21. data/app/views/layouts/noodall_admin.html.erb +66 -0
  22. data/app/views/noodall/admin/assets/_browser.html.erb +28 -0
  23. data/app/views/noodall/admin/assets/_form.html.erb +54 -0
  24. data/app/views/noodall/admin/assets/_menu.html.erb +8 -0
  25. data/app/views/noodall/admin/assets/_show.html.erb +48 -0
  26. data/app/views/noodall/admin/assets/_tags.html.erb +13 -0
  27. data/app/views/noodall/admin/assets/add.html.erb +10 -0
  28. data/app/views/noodall/admin/assets/form.html.erb +12 -0
  29. data/app/views/noodall/admin/assets/form.js.erb +2 -0
  30. data/app/views/noodall/admin/assets/index.html.erb +65 -0
  31. data/app/views/noodall/admin/assets/index.js.erb +1 -0
  32. data/app/views/noodall/admin/assets/show.html.erb +3 -0
  33. data/app/views/noodall/admin/assets/show.js.erb +1 -0
  34. data/app/views/noodall/admin/assets/tags.html.erb +3 -0
  35. data/app/views/noodall/admin/assets/tags.js.erb +1 -0
  36. data/app/views/noodall/admin/components/_component.erb +0 -0
  37. data/app/views/noodall/admin/nodes/_body.html.erb +5 -0
  38. data/app/views/noodall/admin/nodes/_branch.html.erb +10 -0
  39. data/app/views/noodall/admin/nodes/_home.html.erb +27 -0
  40. data/app/views/noodall/admin/nodes/_slot_form.html.erb +16 -0
  41. data/app/views/noodall/admin/nodes/change_template.html.erb +38 -0
  42. data/app/views/noodall/admin/nodes/index.html.erb +69 -0
  43. data/app/views/noodall/admin/nodes/new.html.erb +30 -0
  44. data/app/views/noodall/admin/nodes/show.html.erb +144 -0
  45. data/app/views/noodall/admin/nodes/tree.html.erb +3 -0
  46. data/app/views/noodall/admin/nodes/tree.js.erb +2 -0
  47. data/app/views/noodall/components/_component.erb +0 -0
  48. data/app/views/noodall/nodes/search.html.erb +14 -0
  49. data/app/views/noodall/nodes/sitemap.html.erb +3 -0
  50. data/app/views/noodall/nodes/sitemap.xml.rxml +22 -0
  51. data/config/application.rb +29 -0
  52. data/config/boot.rb +13 -0
  53. data/config/cucumber.yml +8 -0
  54. data/config/database.yml +14 -0
  55. data/config/environment.rb +5 -0
  56. data/config/environments/development.rb +30 -0
  57. data/config/environments/production.rb +50 -0
  58. data/config/environments/test.rb +35 -0
  59. data/config/locales/en.yml +5 -0
  60. data/config.ru +4 -0
  61. data/demo/controllers/application_controller.rb +22 -0
  62. data/demo/initializers/dragonfly.rb +1 -0
  63. data/demo/initializers/mongo_mapper.rb +13 -0
  64. data/demo/initializers/noodall.rb +2 -0
  65. data/demo/initializers/secret_token.rb +7 -0
  66. data/demo/initializers/session_store.rb +8 -0
  67. data/demo/models/gallery.rb +17 -0
  68. data/demo/models/page_a.rb +9 -0
  69. data/demo/models/page_b.rb +4 -0
  70. data/demo/models/page_c.rb +7 -0
  71. data/demo/models/promo.rb +22 -0
  72. data/demo/models/user.rb +12 -0
  73. data/demo/routes.rb +3 -0
  74. data/demo/seeds.rb +8 -0
  75. data/demo/views/admin/components/_gallery.html.erb +49 -0
  76. data/demo/views/admin/components/_promo.html.erb +34 -0
  77. data/demo/views/admin/nodes/_page_a.html.erb +47 -0
  78. data/demo/views/admin/nodes/_page_b.html.erb +35 -0
  79. data/demo/views/admin/nodes/_page_c.html.erb +35 -0
  80. data/demo/views/components/_gallery.html.erb +23 -0
  81. data/demo/views/components/_promo.html.erb +5 -0
  82. data/demo/views/layouts/application.html.erb +121 -0
  83. data/demo/views/nodes/page_a.html.erb +14 -0
  84. data/demo/views/nodes/page_b.html.erb +9 -0
  85. data/demo/views/nodes/page_c.html.erb +12 -0
  86. data/features/change_templates.feature +25 -0
  87. data/features/content_templates.feature +18 -0
  88. data/features/gallery_component.feature +22 -0
  89. data/features/manage_assets.feature +28 -0
  90. data/features/manage_content_tree.feature +42 -0
  91. data/features/preview.feature +8 -0
  92. data/features/promo_component.feature +18 -0
  93. data/features/publish_content.feature +28 -0
  94. data/features/search.feature +12 -0
  95. data/features/sitemap.feature +9 -0
  96. data/features/step_definitions/asset_steps.rb +66 -0
  97. data/features/step_definitions/cms_node_steps.rb +126 -0
  98. data/features/step_definitions/component_steps.rb +137 -0
  99. data/features/step_definitions/content_steps.rb +187 -0
  100. data/features/step_definitions/date_select_steps.rb +39 -0
  101. data/features/step_definitions/groups_access_steps.rb +92 -0
  102. data/features/step_definitions/node_steps.rb +25 -0
  103. data/features/step_definitions/preview_steps.rb +7 -0
  104. data/features/step_definitions/pubish_content_steps.rb +45 -0
  105. data/features/step_definitions/search_steps.rb +21 -0
  106. data/features/step_definitions/sign_in_steps.rb +3 -0
  107. data/features/step_definitions/web_steps.rb +219 -0
  108. data/features/support/env.rb +52 -0
  109. data/features/support/logo.png +0 -0
  110. data/features/support/paths.rb +56 -0
  111. data/generators/component/USAGE +8 -0
  112. data/generators/component/component_generator.rb +35 -0
  113. data/generators/component/lib/insert_commands.rb +61 -0
  114. data/generators/component/templates/admin_template.html.erb +50 -0
  115. data/generators/component/templates/factory.rb +5 -0
  116. data/generators/component/templates/model.rb +8 -0
  117. data/generators/component/templates/template.html.erb +41 -0
  118. data/generators/node/USAGE +8 -0
  119. data/generators/node/lib/insert_commands.rb +47 -0
  120. data/generators/node/node_generator.rb +35 -0
  121. data/generators/node/templates/admin_template.html.erb +49 -0
  122. data/generators/node/templates/factory.rb +5 -0
  123. data/generators/node/templates/model.rb +11 -0
  124. data/generators/node/templates/template.html.erb +41 -0
  125. data/generators/node_features/USAGE +8 -0
  126. data/generators/node_features/node_features_generator.rb +16 -0
  127. data/lib/generators/noodall/node/USAGE +8 -0
  128. data/lib/generators/noodall/node/node_generator.rb +21 -0
  129. data/lib/generators/noodall/node/templates/admin_template.html.erb +52 -0
  130. data/lib/generators/noodall/node/templates/factory.rb +8 -0
  131. data/lib/generators/noodall/node/templates/model.rb +13 -0
  132. data/lib/generators/noodall/node/templates/template.html.erb +12 -0
  133. data/lib/noodall/canable.rb +1 -0
  134. data/lib/noodall/dragonfly.rb +23 -0
  135. data/lib/noodall/engine.rb +13 -0
  136. data/lib/noodall/permalinks.rb +12 -0
  137. data/lib/noodall/routes.rb +45 -0
  138. data/lib/noodall/ui/version.rb +5 -0
  139. data/lib/noodall/ui.rb +17 -0
  140. data/lib/noodall/video_thumbnail_encoder.rb +31 -0
  141. data/lib/noodall-ui.rb +6 -0
  142. data/lib/tasks/cucumber.rake +53 -0
  143. data/log/.gitignore +0 -0
  144. data/noodall-ui.gemspec +28 -0
  145. data/public/favicon.ico +0 -0
  146. data/public/images/admin/add-small.png +0 -0
  147. data/public/images/admin/add.png +0 -0
  148. data/public/images/admin/add_file.gif +0 -0
  149. data/public/images/admin/advanced.gif +0 -0
  150. data/public/images/admin/back.png +0 -0
  151. data/public/images/admin/cancel-small.gif +0 -0
  152. data/public/images/admin/cancel.gif +0 -0
  153. data/public/images/admin/change-bg.gif +0 -0
  154. data/public/images/admin/change.gif +0 -0
  155. data/public/images/admin/check.png +0 -0
  156. data/public/images/admin/clear.gif +0 -0
  157. data/public/images/admin/close.png +0 -0
  158. data/public/images/admin/create.gif +0 -0
  159. data/public/images/admin/delete.gif +0 -0
  160. data/public/images/admin/delete.png +0 -0
  161. data/public/images/admin/doc-icon.png +0 -0
  162. data/public/images/admin/document.png +0 -0
  163. data/public/images/admin/down.png +0 -0
  164. data/public/images/admin/download.png +0 -0
  165. data/public/images/admin/draft.gif +0 -0
  166. data/public/images/admin/draft.png +0 -0
  167. data/public/images/admin/edit.gif +0 -0
  168. data/public/images/admin/edit.png +0 -0
  169. data/public/images/admin/image.png +0 -0
  170. data/public/images/admin/image_small.png +0 -0
  171. data/public/images/admin/info-white.png +0 -0
  172. data/public/images/admin/info.png +0 -0
  173. data/public/images/admin/media.gif +0 -0
  174. data/public/images/admin/nav-2.gif +0 -0
  175. data/public/images/admin/nav.gif +0 -0
  176. data/public/images/admin/next.png +0 -0
  177. data/public/images/admin/no-type-icon.png +0 -0
  178. data/public/images/admin/pagination.gif +0 -0
  179. data/public/images/admin/pdf-icon.png +0 -0
  180. data/public/images/admin/prev.png +0 -0
  181. data/public/images/admin/preview.gif +0 -0
  182. data/public/images/admin/publish.gif +0 -0
  183. data/public/images/admin/remove.gif +0 -0
  184. data/public/images/admin/reset.gif +0 -0
  185. data/public/images/admin/select_image.gif +0 -0
  186. data/public/images/admin/select_images.gif +0 -0
  187. data/public/images/admin/set.gif +0 -0
  188. data/public/images/admin/sort.png +0 -0
  189. data/public/images/admin/tag.png +0 -0
  190. data/public/images/admin/templates/article-page.gif +0 -0
  191. data/public/images/admin/templates/articles-list.gif +0 -0
  192. data/public/images/admin/templates/course-page.gif +0 -0
  193. data/public/images/admin/templates/event-page.gif +0 -0
  194. data/public/images/admin/templates/events-list.gif +0 -0
  195. data/public/images/admin/templates/home.gif +0 -0
  196. data/public/images/admin/templates/landing-page.gif +0 -0
  197. data/public/images/admin/templates/page-a.gif +0 -0
  198. data/public/images/admin/templates/page-b.gif +0 -0
  199. data/public/images/admin/templates/school-landing-page.gif +0 -0
  200. data/public/images/admin/templates/study-landing-page.gif +0 -0
  201. data/public/images/admin/top-level.png +0 -0
  202. data/public/images/admin/top-level_small.png +0 -0
  203. data/public/images/admin/txt-icon.png +0 -0
  204. data/public/images/admin/uncheck.png +0 -0
  205. data/public/images/admin/up.png +0 -0
  206. data/public/images/admin/update.gif +0 -0
  207. data/public/images/admin/upload.png +0 -0
  208. data/public/images/admin/video.png +0 -0
  209. data/public/images/admin/view.png +0 -0
  210. data/public/images/admin/xls-icon.png +0 -0
  211. data/public/images/fancybox/blank.gif +0 -0
  212. data/public/images/fancybox/fancy_close.png +0 -0
  213. data/public/images/fancybox/fancy_loading.png +0 -0
  214. data/public/images/fancybox/fancy_nav_left.png +0 -0
  215. data/public/images/fancybox/fancy_nav_right.png +0 -0
  216. data/public/images/fancybox/fancy_shadow_e.png +0 -0
  217. data/public/images/fancybox/fancy_shadow_n.png +0 -0
  218. data/public/images/fancybox/fancy_shadow_ne.png +0 -0
  219. data/public/images/fancybox/fancy_shadow_nw.png +0 -0
  220. data/public/images/fancybox/fancy_shadow_s.png +0 -0
  221. data/public/images/fancybox/fancy_shadow_se.png +0 -0
  222. data/public/images/fancybox/fancy_shadow_sw.png +0 -0
  223. data/public/images/fancybox/fancy_shadow_w.png +0 -0
  224. data/public/images/fancybox/fancy_title_left.png +0 -0
  225. data/public/images/fancybox/fancy_title_main.png +0 -0
  226. data/public/images/fancybox/fancy_title_over.png +0 -0
  227. data/public/images/fancybox/fancy_title_right.png +0 -0
  228. data/public/images/fancybox/fancybox-x.png +0 -0
  229. data/public/images/fancybox/fancybox-y.png +0 -0
  230. data/public/images/fancybox/fancybox.png +0 -0
  231. data/public/images/plupload/backgrounds.gif +0 -0
  232. data/public/images/plupload/buttons-disabled.png +0 -0
  233. data/public/images/plupload/buttons.png +0 -0
  234. data/public/images/plupload/delete.gif +0 -0
  235. data/public/images/plupload/done.gif +0 -0
  236. data/public/images/plupload/error.gif +0 -0
  237. data/public/images/plupload/throbber.gif +0 -0
  238. data/public/images/plupload/transp50.png +0 -0
  239. data/public/javascripts/admin/application.js +586 -0
  240. data/public/javascripts/admin/asset_edit.js +30 -0
  241. data/public/javascripts/admin/assets.js +98 -0
  242. data/public/javascripts/admin/gotham.font.js +20 -0
  243. data/public/javascripts/admin/jquery.jqtransform.js +366 -0
  244. data/public/javascripts/admin/nodes.js +30 -0
  245. data/public/javascripts/admin/tiny_mce_config.js +118 -0
  246. data/public/javascripts/ajaxify.js +20 -0
  247. data/public/javascripts/application.js +37 -0
  248. data/public/javascripts/carousel.lite.js +1 -0
  249. data/public/javascripts/cufon-yui.js +8 -0
  250. data/public/javascripts/fancybox.js +1078 -0
  251. data/public/javascripts/plupload/gears_init.js +86 -0
  252. data/public/javascripts/plupload/jquery.plupload.queue.min.js +1 -0
  253. data/public/javascripts/plupload/plupload.flash.swf +0 -0
  254. data/public/javascripts/plupload/plupload.full.min.js +1 -0
  255. data/public/javascripts/plupload/plupload.silverlight.xap +0 -0
  256. data/public/javascripts/rails.js +132 -0
  257. data/public/javascripts/tiny_mce/jquery.tinymce.js +1 -0
  258. data/public/javascripts/tiny_mce/langs/en.js +169 -0
  259. data/public/javascripts/tiny_mce/license.txt +504 -0
  260. data/public/javascripts/tiny_mce/plugins/advhr/css/advhr.css +5 -0
  261. data/public/javascripts/tiny_mce/plugins/advhr/editor_plugin.js +1 -0
  262. data/public/javascripts/tiny_mce/plugins/advhr/editor_plugin_src.js +57 -0
  263. data/public/javascripts/tiny_mce/plugins/advhr/js/rule.js +43 -0
  264. data/public/javascripts/tiny_mce/plugins/advhr/langs/en_dlg.js +5 -0
  265. data/public/javascripts/tiny_mce/plugins/advhr/rule.htm +57 -0
  266. data/public/javascripts/tiny_mce/plugins/advimage/css/advimage.css +13 -0
  267. data/public/javascripts/tiny_mce/plugins/advimage/editor_plugin.js +1 -0
  268. data/public/javascripts/tiny_mce/plugins/advimage/editor_plugin_src.js +50 -0
  269. data/public/javascripts/tiny_mce/plugins/advimage/image.htm +232 -0
  270. data/public/javascripts/tiny_mce/plugins/advimage/img/sample.gif +0 -0
  271. data/public/javascripts/tiny_mce/plugins/advimage/js/image.js +443 -0
  272. data/public/javascripts/tiny_mce/plugins/advimage/langs/en_dlg.js +43 -0
  273. data/public/javascripts/tiny_mce/plugins/advlink/css/advlink.css +8 -0
  274. data/public/javascripts/tiny_mce/plugins/advlink/editor_plugin.js +1 -0
  275. data/public/javascripts/tiny_mce/plugins/advlink/editor_plugin_src.js +61 -0
  276. data/public/javascripts/tiny_mce/plugins/advlink/js/advlink.js +528 -0
  277. data/public/javascripts/tiny_mce/plugins/advlink/langs/en_dlg.js +52 -0
  278. data/public/javascripts/tiny_mce/plugins/advlink/link.htm +333 -0
  279. data/public/javascripts/tiny_mce/plugins/advlist/editor_plugin.js +1 -0
  280. data/public/javascripts/tiny_mce/plugins/advlist/editor_plugin_src.js +154 -0
  281. data/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js +1 -0
  282. data/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js +117 -0
  283. data/public/javascripts/tiny_mce/plugins/autosave/editor_plugin.js +1 -0
  284. data/public/javascripts/tiny_mce/plugins/autosave/editor_plugin_src.js +422 -0
  285. data/public/javascripts/tiny_mce/plugins/autosave/langs/en.js +4 -0
  286. data/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin.js +1 -0
  287. data/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +120 -0
  288. data/public/javascripts/tiny_mce/plugins/contextmenu/editor_plugin.js +1 -0
  289. data/public/javascripts/tiny_mce/plugins/contextmenu/editor_plugin_src.js +127 -0
  290. data/public/javascripts/tiny_mce/plugins/directionality/editor_plugin.js +1 -0
  291. data/public/javascripts/tiny_mce/plugins/directionality/editor_plugin_src.js +82 -0
  292. data/public/javascripts/tiny_mce/plugins/emotions/editor_plugin.js +1 -0
  293. data/public/javascripts/tiny_mce/plugins/emotions/editor_plugin_src.js +43 -0
  294. data/public/javascripts/tiny_mce/plugins/emotions/emotions.htm +40 -0
  295. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-cool.gif +0 -0
  296. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-cry.gif +0 -0
  297. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-embarassed.gif +0 -0
  298. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-foot-in-mouth.gif +0 -0
  299. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-frown.gif +0 -0
  300. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-innocent.gif +0 -0
  301. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-kiss.gif +0 -0
  302. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-laughing.gif +0 -0
  303. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-money-mouth.gif +0 -0
  304. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-sealed.gif +0 -0
  305. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-smile.gif +0 -0
  306. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-surprised.gif +0 -0
  307. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-tongue-out.gif +0 -0
  308. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-undecided.gif +0 -0
  309. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-wink.gif +0 -0
  310. data/public/javascripts/tiny_mce/plugins/emotions/img/smiley-yell.gif +0 -0
  311. data/public/javascripts/tiny_mce/plugins/emotions/js/emotions.js +22 -0
  312. data/public/javascripts/tiny_mce/plugins/emotions/langs/en_dlg.js +20 -0
  313. data/public/javascripts/tiny_mce/plugins/example/dialog.htm +22 -0
  314. data/public/javascripts/tiny_mce/plugins/example/editor_plugin.js +1 -0
  315. data/public/javascripts/tiny_mce/plugins/example/editor_plugin_src.js +84 -0
  316. data/public/javascripts/tiny_mce/plugins/example/img/example.gif +0 -0
  317. data/public/javascripts/tiny_mce/plugins/example/js/dialog.js +19 -0
  318. data/public/javascripts/tiny_mce/plugins/example/langs/en.js +3 -0
  319. data/public/javascripts/tiny_mce/plugins/example/langs/en_dlg.js +3 -0
  320. data/public/javascripts/tiny_mce/plugins/fullpage/css/fullpage.css +182 -0
  321. data/public/javascripts/tiny_mce/plugins/fullpage/editor_plugin.js +1 -0
  322. data/public/javascripts/tiny_mce/plugins/fullpage/editor_plugin_src.js +149 -0
  323. data/public/javascripts/tiny_mce/plugins/fullpage/fullpage.htm +571 -0
  324. data/public/javascripts/tiny_mce/plugins/fullpage/js/fullpage.js +471 -0
  325. data/public/javascripts/tiny_mce/plugins/fullpage/langs/en_dlg.js +85 -0
  326. data/public/javascripts/tiny_mce/plugins/fullscreen/editor_plugin.js +1 -0
  327. data/public/javascripts/tiny_mce/plugins/fullscreen/editor_plugin_src.js +148 -0
  328. data/public/javascripts/tiny_mce/plugins/fullscreen/fullscreen.htm +109 -0
  329. data/public/javascripts/tiny_mce/plugins/iespell/editor_plugin.js +1 -0
  330. data/public/javascripts/tiny_mce/plugins/iespell/editor_plugin_src.js +54 -0
  331. data/public/javascripts/tiny_mce/plugins/inlinepopups/editor_plugin.js +1 -0
  332. data/public/javascripts/tiny_mce/plugins/inlinepopups/editor_plugin_src.js +635 -0
  333. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif +0 -0
  334. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif +0 -0
  335. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif +0 -0
  336. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif +0 -0
  337. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif +0 -0
  338. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif +0 -0
  339. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif +0 -0
  340. data/public/javascripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css +90 -0
  341. data/public/javascripts/tiny_mce/plugins/inlinepopups/template.htm +387 -0
  342. data/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin.js +1 -0
  343. data/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js +83 -0
  344. data/public/javascripts/tiny_mce/plugins/layer/editor_plugin.js +1 -0
  345. data/public/javascripts/tiny_mce/plugins/layer/editor_plugin_src.js +212 -0
  346. data/public/javascripts/tiny_mce/plugins/legacyoutput/editor_plugin.js +1 -0
  347. data/public/javascripts/tiny_mce/plugins/legacyoutput/editor_plugin_src.js +136 -0
  348. data/public/javascripts/tiny_mce/plugins/media/css/content.css +6 -0
  349. data/public/javascripts/tiny_mce/plugins/media/css/media.css +16 -0
  350. data/public/javascripts/tiny_mce/plugins/media/editor_plugin.js +1 -0
  351. data/public/javascripts/tiny_mce/plugins/media/editor_plugin_src.js +414 -0
  352. data/public/javascripts/tiny_mce/plugins/media/img/flash.gif +0 -0
  353. data/public/javascripts/tiny_mce/plugins/media/img/flv_player.swf +0 -0
  354. data/public/javascripts/tiny_mce/plugins/media/img/quicktime.gif +0 -0
  355. data/public/javascripts/tiny_mce/plugins/media/img/realmedia.gif +0 -0
  356. data/public/javascripts/tiny_mce/plugins/media/img/shockwave.gif +0 -0
  357. data/public/javascripts/tiny_mce/plugins/media/img/trans.gif +0 -0
  358. data/public/javascripts/tiny_mce/plugins/media/img/windowsmedia.gif +0 -0
  359. data/public/javascripts/tiny_mce/plugins/media/js/embed.js +73 -0
  360. data/public/javascripts/tiny_mce/plugins/media/js/media.js +630 -0
  361. data/public/javascripts/tiny_mce/plugins/media/langs/en_dlg.js +103 -0
  362. data/public/javascripts/tiny_mce/plugins/media/media.htm +817 -0
  363. data/public/javascripts/tiny_mce/plugins/nonbreaking/editor_plugin.js +1 -0
  364. data/public/javascripts/tiny_mce/plugins/nonbreaking/editor_plugin_src.js +53 -0
  365. data/public/javascripts/tiny_mce/plugins/noneditable/editor_plugin.js +1 -0
  366. data/public/javascripts/tiny_mce/plugins/noneditable/editor_plugin_src.js +90 -0
  367. data/public/javascripts/tiny_mce/plugins/pagebreak/css/content.css +1 -0
  368. data/public/javascripts/tiny_mce/plugins/pagebreak/editor_plugin.js +1 -0
  369. data/public/javascripts/tiny_mce/plugins/pagebreak/editor_plugin_src.js +77 -0
  370. data/public/javascripts/tiny_mce/plugins/pagebreak/img/pagebreak.gif +0 -0
  371. data/public/javascripts/tiny_mce/plugins/pagebreak/img/trans.gif +0 -0
  372. data/public/javascripts/tiny_mce/plugins/paste/editor_plugin.js +1 -0
  373. data/public/javascripts/tiny_mce/plugins/paste/editor_plugin_src.js +929 -0
  374. data/public/javascripts/tiny_mce/plugins/paste/js/pastetext.js +36 -0
  375. data/public/javascripts/tiny_mce/plugins/paste/js/pasteword.js +51 -0
  376. data/public/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js +5 -0
  377. data/public/javascripts/tiny_mce/plugins/paste/pastetext.htm +27 -0
  378. data/public/javascripts/tiny_mce/plugins/paste/pasteword.htm +21 -0
  379. data/public/javascripts/tiny_mce/plugins/preview/editor_plugin.js +1 -0
  380. data/public/javascripts/tiny_mce/plugins/preview/editor_plugin_src.js +53 -0
  381. data/public/javascripts/tiny_mce/plugins/preview/example.html +28 -0
  382. data/public/javascripts/tiny_mce/plugins/preview/jscripts/embed.js +73 -0
  383. data/public/javascripts/tiny_mce/plugins/preview/preview.html +17 -0
  384. data/public/javascripts/tiny_mce/plugins/print/editor_plugin.js +1 -0
  385. data/public/javascripts/tiny_mce/plugins/print/editor_plugin_src.js +34 -0
  386. data/public/javascripts/tiny_mce/plugins/save/editor_plugin.js +1 -0
  387. data/public/javascripts/tiny_mce/plugins/save/editor_plugin_src.js +101 -0
  388. data/public/javascripts/tiny_mce/plugins/searchreplace/css/searchreplace.css +6 -0
  389. data/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin.js +1 -0
  390. data/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js +57 -0
  391. data/public/javascripts/tiny_mce/plugins/searchreplace/js/searchreplace.js +130 -0
  392. data/public/javascripts/tiny_mce/plugins/searchreplace/langs/en_dlg.js +16 -0
  393. data/public/javascripts/tiny_mce/plugins/searchreplace/searchreplace.htm +99 -0
  394. data/public/javascripts/tiny_mce/plugins/spellchecker/css/content.css +1 -0
  395. data/public/javascripts/tiny_mce/plugins/spellchecker/editor_plugin.js +1 -0
  396. data/public/javascripts/tiny_mce/plugins/spellchecker/editor_plugin_src.js +341 -0
  397. data/public/javascripts/tiny_mce/plugins/spellchecker/img/wline.gif +0 -0
  398. data/public/javascripts/tiny_mce/plugins/style/css/props.css +13 -0
  399. data/public/javascripts/tiny_mce/plugins/style/editor_plugin.js +1 -0
  400. data/public/javascripts/tiny_mce/plugins/style/editor_plugin_src.js +55 -0
  401. data/public/javascripts/tiny_mce/plugins/style/js/props.js +641 -0
  402. data/public/javascripts/tiny_mce/plugins/style/langs/en_dlg.js +63 -0
  403. data/public/javascripts/tiny_mce/plugins/style/props.htm +726 -0
  404. data/public/javascripts/tiny_mce/plugins/tabfocus/editor_plugin.js +1 -0
  405. data/public/javascripts/tiny_mce/plugins/tabfocus/editor_plugin_src.js +112 -0
  406. data/public/javascripts/tiny_mce/plugins/table/cell.htm +178 -0
  407. data/public/javascripts/tiny_mce/plugins/table/css/cell.css +17 -0
  408. data/public/javascripts/tiny_mce/plugins/table/css/row.css +25 -0
  409. data/public/javascripts/tiny_mce/plugins/table/css/table.css +13 -0
  410. data/public/javascripts/tiny_mce/plugins/table/editor_plugin.js +1 -0
  411. data/public/javascripts/tiny_mce/plugins/table/editor_plugin_src.js +1118 -0
  412. data/public/javascripts/tiny_mce/plugins/table/js/cell.js +286 -0
  413. data/public/javascripts/tiny_mce/plugins/table/js/merge_cells.js +27 -0
  414. data/public/javascripts/tiny_mce/plugins/table/js/row.js +237 -0
  415. data/public/javascripts/tiny_mce/plugins/table/js/table.js +449 -0
  416. data/public/javascripts/tiny_mce/plugins/table/langs/en_dlg.js +74 -0
  417. data/public/javascripts/tiny_mce/plugins/table/merge_cells.htm +32 -0
  418. data/public/javascripts/tiny_mce/plugins/table/row.htm +155 -0
  419. data/public/javascripts/tiny_mce/plugins/table/table.htm +187 -0
  420. data/public/javascripts/tiny_mce/plugins/template/blank.htm +12 -0
  421. data/public/javascripts/tiny_mce/plugins/template/css/template.css +23 -0
  422. data/public/javascripts/tiny_mce/plugins/template/editor_plugin.js +1 -0
  423. data/public/javascripts/tiny_mce/plugins/template/editor_plugin_src.js +159 -0
  424. data/public/javascripts/tiny_mce/plugins/template/js/template.js +106 -0
  425. data/public/javascripts/tiny_mce/plugins/template/langs/en_dlg.js +15 -0
  426. data/public/javascripts/tiny_mce/plugins/template/template.htm +32 -0
  427. data/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin.js +1 -0
  428. data/public/javascripts/tiny_mce/plugins/visualchars/editor_plugin_src.js +76 -0
  429. data/public/javascripts/tiny_mce/plugins/wordcount/editor_plugin.js +1 -0
  430. data/public/javascripts/tiny_mce/plugins/wordcount/editor_plugin_src.js +98 -0
  431. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/abbr.htm +141 -0
  432. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/acronym.htm +141 -0
  433. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/attributes.htm +148 -0
  434. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/cite.htm +141 -0
  435. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/css/attributes.css +11 -0
  436. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/css/popup.css +9 -0
  437. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/del.htm +161 -0
  438. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/editor_plugin.js +1 -0
  439. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js +144 -0
  440. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/ins.htm +161 -0
  441. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/abbr.js +28 -0
  442. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/acronym.js +28 -0
  443. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/attributes.js +126 -0
  444. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/cite.js +28 -0
  445. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/del.js +63 -0
  446. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js +231 -0
  447. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/js/ins.js +62 -0
  448. data/public/javascripts/tiny_mce/plugins/xhtmlxtras/langs/en_dlg.js +32 -0
  449. data/public/javascripts/tiny_mce/themes/advanced/about.htm +54 -0
  450. data/public/javascripts/tiny_mce/themes/advanced/anchor.htm +26 -0
  451. data/public/javascripts/tiny_mce/themes/advanced/charmap.htm +53 -0
  452. data/public/javascripts/tiny_mce/themes/advanced/color_picker.htm +73 -0
  453. data/public/javascripts/tiny_mce/themes/advanced/editor_template.js +1 -0
  454. data/public/javascripts/tiny_mce/themes/advanced/editor_template_src.js +1167 -0
  455. data/public/javascripts/tiny_mce/themes/advanced/image.htm +80 -0
  456. data/public/javascripts/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
  457. data/public/javascripts/tiny_mce/themes/advanced/img/icons.gif +0 -0
  458. data/public/javascripts/tiny_mce/themes/advanced/js/about.js +72 -0
  459. data/public/javascripts/tiny_mce/themes/advanced/js/anchor.js +37 -0
  460. data/public/javascripts/tiny_mce/themes/advanced/js/charmap.js +335 -0
  461. data/public/javascripts/tiny_mce/themes/advanced/js/color_picker.js +253 -0
  462. data/public/javascripts/tiny_mce/themes/advanced/js/image.js +245 -0
  463. data/public/javascripts/tiny_mce/themes/advanced/js/link.js +156 -0
  464. data/public/javascripts/tiny_mce/themes/advanced/js/source_editor.js +62 -0
  465. data/public/javascripts/tiny_mce/themes/advanced/langs/en.js +62 -0
  466. data/public/javascripts/tiny_mce/themes/advanced/langs/en_dlg.js +51 -0
  467. data/public/javascripts/tiny_mce/themes/advanced/link.htm +58 -0
  468. data/public/javascripts/tiny_mce/themes/advanced/skins/default/content.css +35 -0
  469. data/public/javascripts/tiny_mce/themes/advanced/skins/default/dialog.css +117 -0
  470. data/public/javascripts/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
  471. data/public/javascripts/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
  472. data/public/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  473. data/public/javascripts/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  474. data/public/javascripts/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
  475. data/public/javascripts/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
  476. data/public/javascripts/tiny_mce/themes/advanced/skins/default/ui.css +213 -0
  477. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/content.css +35 -0
  478. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/dialog.css +116 -0
  479. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
  480. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
  481. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
  482. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui.css +215 -0
  483. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_black.css +8 -0
  484. data/public/javascripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css +5 -0
  485. data/public/javascripts/tiny_mce/themes/advanced/source_editor.htm +26 -0
  486. data/public/javascripts/tiny_mce/themes/simple/editor_template.js +1 -0
  487. data/public/javascripts/tiny_mce/themes/simple/editor_template_src.js +85 -0
  488. data/public/javascripts/tiny_mce/themes/simple/img/icons.gif +0 -0
  489. data/public/javascripts/tiny_mce/themes/simple/langs/en.js +11 -0
  490. data/public/javascripts/tiny_mce/themes/simple/skins/default/content.css +25 -0
  491. data/public/javascripts/tiny_mce/themes/simple/skins/default/ui.css +32 -0
  492. data/public/javascripts/tiny_mce/themes/simple/skins/o2k7/content.css +17 -0
  493. data/public/javascripts/tiny_mce/themes/simple/skins/o2k7/img/button_bg.png +0 -0
  494. data/public/javascripts/tiny_mce/themes/simple/skins/o2k7/ui.css +35 -0
  495. data/public/javascripts/tiny_mce/tiny_mce.js +1 -0
  496. data/public/javascripts/tiny_mce/tiny_mce_popup.js +5 -0
  497. data/public/javascripts/tiny_mce/tiny_mce_src.js +13134 -0
  498. data/public/javascripts/tiny_mce/utils/editable_selects.js +70 -0
  499. data/public/javascripts/tiny_mce/utils/form_utils.js +200 -0
  500. data/public/javascripts/tiny_mce/utils/mctabs.js +77 -0
  501. data/public/javascripts/tiny_mce/utils/validate.js +220 -0
  502. data/public/stylesheets/admin/fancybox.css +341 -0
  503. data/public/stylesheets/admin/forms.css +520 -0
  504. data/public/stylesheets/admin/handheld.css +6 -0
  505. data/public/stylesheets/admin/ie.css +118 -0
  506. data/public/stylesheets/admin/ie6.css +23 -0
  507. data/public/stylesheets/admin/ie8.css +16 -0
  508. data/public/stylesheets/admin/layout.css +723 -0
  509. data/public/stylesheets/admin/print.css +27 -0
  510. data/public/stylesheets/admin/reset.css +81 -0
  511. data/public/stylesheets/admin/skin.css +698 -0
  512. data/public/stylesheets/admin/tinymce.css +2 -0
  513. data/public/stylesheets/admin/typography.css +207 -0
  514. data/public/stylesheets/ellipsis.xml +15 -0
  515. data/public/stylesheets/fancybox.css +313 -0
  516. data/public/stylesheets/forms.css +7 -0
  517. data/public/stylesheets/ie.css +12 -0
  518. data/public/stylesheets/ie8.css +8 -0
  519. data/public/stylesheets/layout.css +31 -0
  520. data/public/stylesheets/plupload.queue.css +181 -0
  521. data/public/stylesheets/reset.css +84 -0
  522. data/public/stylesheets/sass/forms.scss +7 -0
  523. data/public/stylesheets/sass/ie.scss +12 -0
  524. data/public/stylesheets/sass/ie8.scss +8 -0
  525. data/public/stylesheets/sass/layout.scss +45 -0
  526. data/public/stylesheets/sass/skin.scss +35 -0
  527. data/public/stylesheets/sass/typography.scss +162 -0
  528. data/public/stylesheets/skin.css +22 -0
  529. data/public/stylesheets/typography.css +162 -0
  530. data/script/cucumber +10 -0
  531. data/script/rails +6 -0
  532. data/spec/factories/asset.rb +16 -0
  533. data/spec/factories/component.rb +9 -0
  534. data/spec/factories/node.rb +15 -0
  535. data/spec/factories/user.rb +5 -0
  536. data/spec/files/beef.png +0 -0
  537. data/spec/files/get_video.flv +0 -0
  538. data/spec/files/test.pdf +0 -0
  539. data/spec/noodall-ui_spec.rb +9 -0
  540. data/spec/spec_helper.rb +4 -0
  541. data/tmp/.gitignore +0 -0
  542. metadata +685 -0
@@ -0,0 +1,1118 @@
1
+ /**
2
+ * editor_plugin_src.js
3
+ *
4
+ * Copyright 2009, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://tinymce.moxiecode.com/license
8
+ * Contributing: http://tinymce.moxiecode.com/contributing
9
+ */
10
+
11
+ (function(tinymce) {
12
+ var each = tinymce.each;
13
+
14
+ /**
15
+ * Table Grid class.
16
+ */
17
+ function TableGrid(table, dom, selection) {
18
+ var grid, startPos, endPos, selectedCell;
19
+
20
+ buildGrid();
21
+ selectedCell = dom.getParent(selection.getStart(), 'th,td');
22
+ if (selectedCell) {
23
+ startPos = getPos(selectedCell);
24
+ endPos = findEndPos();
25
+ selectedCell = getCell(startPos.x, startPos.y);
26
+ }
27
+
28
+ function buildGrid() {
29
+ var startY = 0;
30
+
31
+ grid = [];
32
+
33
+ each(['thead', 'tbody', 'tfoot'], function(part) {
34
+ var rows = dom.select(part + ' tr', table);
35
+
36
+ each(rows, function(tr, y) {
37
+ y += startY;
38
+
39
+ each(dom.select('td,th', tr), function(td, x) {
40
+ var x2, y2, rowspan, colspan;
41
+
42
+ // Skip over existing cells produced by rowspan
43
+ if (grid[y]) {
44
+ while (grid[y][x])
45
+ x++;
46
+ }
47
+
48
+ // Get col/rowspan from cell
49
+ rowspan = getSpanVal(td, 'rowspan');
50
+ colspan = getSpanVal(td, 'colspan');
51
+
52
+ // Fill out rowspan/colspan right and down
53
+ for (y2 = y; y2 < y + rowspan; y2++) {
54
+ if (!grid[y2])
55
+ grid[y2] = [];
56
+
57
+ for (x2 = x; x2 < x + colspan; x2++) {
58
+ grid[y2][x2] = {
59
+ part : part,
60
+ real : y2 == y && x2 == x,
61
+ elm : td,
62
+ rowspan : rowspan,
63
+ colspan : colspan
64
+ };
65
+ }
66
+ }
67
+ });
68
+ });
69
+
70
+ startY += rows.length;
71
+ });
72
+ };
73
+
74
+ function getCell(x, y) {
75
+ var row;
76
+
77
+ row = grid[y];
78
+ if (row)
79
+ return row[x];
80
+ };
81
+
82
+ function getSpanVal(td, name) {
83
+ return parseInt(td.getAttribute(name) || 1);
84
+ };
85
+
86
+ function isCellSelected(cell) {
87
+ return dom.hasClass(cell.elm, 'mceSelected') || cell == selectedCell;
88
+ };
89
+
90
+ function getSelectedRows() {
91
+ var rows = [];
92
+
93
+ each(table.rows, function(row) {
94
+ each(row.cells, function(cell) {
95
+ if (dom.hasClass(cell, 'mceSelected') || cell == selectedCell.elm) {
96
+ rows.push(row);
97
+ return false;
98
+ }
99
+ });
100
+ });
101
+
102
+ return rows;
103
+ };
104
+
105
+ function deleteTable() {
106
+ var rng = dom.createRng();
107
+
108
+ rng.setStartAfter(table);
109
+ rng.setEndAfter(table);
110
+
111
+ selection.setRng(rng);
112
+
113
+ dom.remove(table);
114
+ };
115
+
116
+ function cloneCell(cell) {
117
+ var formatNode;
118
+
119
+ // Clone formats
120
+ tinymce.walk(cell, function(node) {
121
+ var curNode;
122
+
123
+ if (node.nodeType == 3) {
124
+ each(dom.getParents(node.parentNode, null, cell).reverse(), function(node) {
125
+ node = node.cloneNode(false);
126
+
127
+ if (!formatNode)
128
+ formatNode = curNode = node;
129
+ else if (curNode)
130
+ curNode.appendChild(node);
131
+
132
+ curNode = node;
133
+ });
134
+
135
+ // Add something to the inner node
136
+ if (curNode)
137
+ curNode.innerHTML = tinymce.isIE ? '&nbsp;' : '<br _mce_bogus="1" />';
138
+
139
+ return false;
140
+ }
141
+ }, 'childNodes');
142
+
143
+ cell = cell.cloneNode(false);
144
+ cell.rowSpan = cell.colSpan = 1;
145
+
146
+ if (formatNode) {
147
+ cell.appendChild(formatNode);
148
+ } else {
149
+ if (!tinymce.isIE)
150
+ cell.innerHTML = '<br _mce_bogus="1" />';
151
+ }
152
+
153
+ return cell;
154
+ };
155
+
156
+ function cleanup() {
157
+ var rng = dom.createRng();
158
+
159
+ // Empty rows
160
+ each(dom.select('tr', table), function(tr) {
161
+ if (tr.cells.length == 0)
162
+ dom.remove(tr);
163
+ });
164
+
165
+ // Empty table
166
+ if (dom.select('tr', table).length == 0) {
167
+ rng.setStartAfter(table);
168
+ rng.setEndAfter(table);
169
+ selection.setRng(rng);
170
+ dom.remove(table);
171
+ return;
172
+ }
173
+
174
+ // Empty header/body/footer
175
+ each(dom.select('thead,tbody,tfoot', table), function(part) {
176
+ if (part.rows.length == 0)
177
+ dom.remove(part);
178
+ });
179
+
180
+ // Restore selection to start position if it still exists
181
+ buildGrid();
182
+
183
+ // Restore the selection to the closest table position
184
+ row = grid[Math.min(grid.length - 1, startPos.y)];
185
+ if (row) {
186
+ selection.select(row[Math.min(row.length - 1, startPos.x)].elm, true);
187
+ selection.collapse(true);
188
+ }
189
+ };
190
+
191
+ function fillLeftDown(x, y, rows, cols) {
192
+ var tr, x2, r, c, cell;
193
+
194
+ tr = grid[y][x].elm.parentNode;
195
+ for (r = 1; r <= rows; r++) {
196
+ tr = dom.getNext(tr, 'tr');
197
+
198
+ if (tr) {
199
+ // Loop left to find real cell
200
+ for (x2 = x; x2 >= 0; x2--) {
201
+ cell = grid[y + r][x2].elm;
202
+
203
+ if (cell.parentNode == tr) {
204
+ // Append clones after
205
+ for (c = 1; c <= cols; c++)
206
+ dom.insertAfter(cloneCell(cell), cell);
207
+
208
+ break;
209
+ }
210
+ }
211
+
212
+ if (x2 == -1) {
213
+ // Insert nodes before first cell
214
+ for (c = 1; c <= cols; c++)
215
+ tr.insertBefore(cloneCell(tr.cells[0]), tr.cells[0]);
216
+ }
217
+ }
218
+ }
219
+ };
220
+
221
+ function split() {
222
+ each(grid, function(row, y) {
223
+ each(row, function(cell, x) {
224
+ var colSpan, rowSpan, newCell, i;
225
+
226
+ if (isCellSelected(cell)) {
227
+ cell = cell.elm;
228
+ colSpan = getSpanVal(cell, 'colspan');
229
+ rowSpan = getSpanVal(cell, 'rowspan');
230
+
231
+ if (colSpan > 1 || rowSpan > 1) {
232
+ cell.colSpan = cell.rowSpan = 1;
233
+
234
+ // Insert cells right
235
+ for (i = 0; i < colSpan - 1; i++)
236
+ dom.insertAfter(cloneCell(cell), cell);
237
+
238
+ fillLeftDown(x, y, rowSpan - 1, colSpan);
239
+ }
240
+ }
241
+ });
242
+ });
243
+ };
244
+
245
+ function merge(cell, cols, rows) {
246
+ var startX, startY, endX, endY, x, y, startCell, endCell, cell, children;
247
+
248
+ // Use specified cell and cols/rows
249
+ if (cell) {
250
+ pos = getPos(cell);
251
+ startX = pos.x;
252
+ startY = pos.y;
253
+ endX = startX + (cols - 1);
254
+ endY = startY + (rows - 1);
255
+ } else {
256
+ // Use selection
257
+ startX = startPos.x;
258
+ startY = startPos.y;
259
+ endX = endPos.x;
260
+ endY = endPos.y;
261
+ }
262
+
263
+ // Find start/end cells
264
+ startCell = getCell(startX, startY);
265
+ endCell = getCell(endX, endY);
266
+
267
+ // Check if the cells exists and if they are of the same part for example tbody = tbody
268
+ if (startCell && endCell && startCell.part == endCell.part) {
269
+ // Split and rebuild grid
270
+ split();
271
+ buildGrid();
272
+
273
+ // Set row/col span to start cell
274
+ startCell = getCell(startX, startY).elm;
275
+ startCell.colSpan = (endX - startX) + 1;
276
+ startCell.rowSpan = (endY - startY) + 1;
277
+
278
+ // Remove other cells and add it's contents to the start cell
279
+ for (y = startY; y <= endY; y++) {
280
+ for (x = startX; x <= endX; x++) {
281
+ cell = grid[y][x].elm;
282
+
283
+ if (cell != startCell) {
284
+ // Move children to startCell
285
+ children = tinymce.grep(cell.childNodes);
286
+ each(children, function(node, i) {
287
+ // Jump over last BR element
288
+ if (node.nodeName != 'BR' || i != children.length - 1)
289
+ startCell.appendChild(node);
290
+ });
291
+
292
+ // Remove cell
293
+ dom.remove(cell);
294
+ }
295
+ }
296
+ }
297
+
298
+ // Remove empty rows etc and restore caret location
299
+ cleanup();
300
+ }
301
+ };
302
+
303
+ function insertRow(before) {
304
+ var posY, cell, lastCell, x, rowElm, newRow, newCell, otherCell;
305
+
306
+ // Find first/last row
307
+ each(grid, function(row, y) {
308
+ each(row, function(cell, x) {
309
+ if (isCellSelected(cell)) {
310
+ cell = cell.elm;
311
+ rowElm = cell.parentNode;
312
+ newRow = rowElm.cloneNode(false);
313
+ posY = y;
314
+
315
+ if (before)
316
+ return false;
317
+ }
318
+ });
319
+
320
+ if (before)
321
+ return !posY;
322
+ });
323
+
324
+ for (x = 0; x < grid[0].length; x++) {
325
+ cell = grid[posY][x].elm;
326
+
327
+ if (cell != lastCell) {
328
+ if (!before) {
329
+ rowSpan = getSpanVal(cell, 'rowspan');
330
+ if (rowSpan > 1) {
331
+ cell.rowSpan = rowSpan + 1;
332
+ continue;
333
+ }
334
+ } else {
335
+ // Check if cell above can be expanded
336
+ if (posY > 0 && grid[posY - 1][x]) {
337
+ otherCell = grid[posY - 1][x].elm;
338
+ rowSpan = getSpanVal(otherCell, 'rowspan');
339
+ if (rowSpan > 1) {
340
+ otherCell.rowSpan = rowSpan + 1;
341
+ continue;
342
+ }
343
+ }
344
+ }
345
+
346
+ // Insert new cell into new row
347
+ newCell = cloneCell(cell)
348
+ newCell.colSpan = cell.colSpan;
349
+ newRow.appendChild(newCell);
350
+
351
+ lastCell = cell;
352
+ }
353
+ }
354
+
355
+ if (newRow.hasChildNodes()) {
356
+ if (!before)
357
+ dom.insertAfter(newRow, rowElm);
358
+ else
359
+ rowElm.parentNode.insertBefore(newRow, rowElm);
360
+ }
361
+ };
362
+
363
+ function insertCol(before) {
364
+ var posX, lastCell;
365
+
366
+ // Find first/last column
367
+ each(grid, function(row, y) {
368
+ each(row, function(cell, x) {
369
+ if (isCellSelected(cell)) {
370
+ posX = x;
371
+
372
+ if (before)
373
+ return false;
374
+ }
375
+ });
376
+
377
+ if (before)
378
+ return !posX;
379
+ });
380
+
381
+ each(grid, function(row, y) {
382
+ var cell = row[posX].elm, rowSpan, colSpan;
383
+
384
+ if (cell != lastCell) {
385
+ colSpan = getSpanVal(cell, 'colspan');
386
+ rowSpan = getSpanVal(cell, 'rowspan');
387
+
388
+ if (colSpan == 1) {
389
+ if (!before) {
390
+ dom.insertAfter(cloneCell(cell), cell);
391
+ fillLeftDown(posX, y, rowSpan - 1, colSpan);
392
+ } else {
393
+ cell.parentNode.insertBefore(cloneCell(cell), cell);
394
+ fillLeftDown(posX, y, rowSpan - 1, colSpan);
395
+ }
396
+ } else
397
+ cell.colSpan++;
398
+
399
+ lastCell = cell;
400
+ }
401
+ });
402
+ };
403
+
404
+ function deleteCols() {
405
+ var cols = [];
406
+
407
+ // Get selected column indexes
408
+ each(grid, function(row, y) {
409
+ each(row, function(cell, x) {
410
+ if (isCellSelected(cell) && tinymce.inArray(cols, x) === -1) {
411
+ each(grid, function(row) {
412
+ var cell = row[x].elm, colSpan;
413
+
414
+ colSpan = getSpanVal(cell, 'colspan');
415
+
416
+ if (colSpan > 1)
417
+ cell.colSpan = colSpan - 1;
418
+ else
419
+ dom.remove(cell);
420
+ });
421
+
422
+ cols.push(x);
423
+ }
424
+ });
425
+ });
426
+
427
+ cleanup();
428
+ };
429
+
430
+ function deleteRows() {
431
+ var rows;
432
+
433
+ function deleteRow(tr) {
434
+ var nextTr, pos, lastCell;
435
+
436
+ nextTr = dom.getNext(tr, 'tr');
437
+
438
+ // Move down row spanned cells
439
+ each(tr.cells, function(cell) {
440
+ var rowSpan = getSpanVal(cell, 'rowspan');
441
+
442
+ if (rowSpan > 1) {
443
+ cell.rowSpan = rowSpan - 1;
444
+ pos = getPos(cell);
445
+ fillLeftDown(pos.x, pos.y, 1, 1);
446
+ }
447
+ });
448
+
449
+ // Delete cells
450
+ pos = getPos(tr.cells[0]);
451
+ each(grid[pos.y], function(cell) {
452
+ var rowSpan;
453
+
454
+ cell = cell.elm;
455
+
456
+ if (cell != lastCell) {
457
+ rowSpan = getSpanVal(cell, 'rowspan');
458
+
459
+ if (rowSpan <= 1)
460
+ dom.remove(cell);
461
+ else
462
+ cell.rowSpan = rowSpan - 1;
463
+
464
+ lastCell = cell;
465
+ }
466
+ });
467
+ };
468
+
469
+ // Get selected rows and move selection out of scope
470
+ rows = getSelectedRows();
471
+
472
+ // Delete all selected rows
473
+ each(rows.reverse(), function(tr) {
474
+ deleteRow(tr);
475
+ });
476
+
477
+ cleanup();
478
+ };
479
+
480
+ function cutRows() {
481
+ var rows = getSelectedRows();
482
+
483
+ dom.remove(rows);
484
+ cleanup();
485
+
486
+ return rows;
487
+ };
488
+
489
+ function copyRows() {
490
+ var rows = getSelectedRows();
491
+
492
+ each(rows, function(row, i) {
493
+ rows[i] = row.cloneNode(true);
494
+ });
495
+
496
+ return rows;
497
+ };
498
+
499
+ function pasteRows(rows, before) {
500
+ var selectedRows = getSelectedRows(),
501
+ targetRow = selectedRows[before ? 0 : selectedRows.length - 1],
502
+ targetCellCount = targetRow.cells.length;
503
+
504
+ // Calc target cell count
505
+ each(grid, function(row) {
506
+ var match;
507
+
508
+ targetCellCount = 0;
509
+ each(row, function(cell, x) {
510
+ if (cell.real)
511
+ targetCellCount += cell.colspan;
512
+
513
+ if (cell.elm.parentNode == targetRow)
514
+ match = 1;
515
+ });
516
+
517
+ if (match)
518
+ return false;
519
+ });
520
+
521
+ if (!before)
522
+ rows.reverse();
523
+
524
+ each(rows, function(row) {
525
+ var cellCount = row.cells.length, cell;
526
+
527
+ // Remove col/rowspans
528
+ for (i = 0; i < cellCount; i++) {
529
+ cell = row.cells[i];
530
+ cell.colSpan = cell.rowSpan = 1;
531
+ }
532
+
533
+ // Needs more cells
534
+ for (i = cellCount; i < targetCellCount; i++)
535
+ row.appendChild(cloneCell(row.cells[cellCount - 1]));
536
+
537
+ // Needs less cells
538
+ for (i = targetCellCount; i < cellCount; i++)
539
+ dom.remove(row.cells[i]);
540
+
541
+ // Add before/after
542
+ if (before)
543
+ targetRow.parentNode.insertBefore(row, targetRow);
544
+ else
545
+ dom.insertAfter(row, targetRow);
546
+ });
547
+ };
548
+
549
+ function getPos(target) {
550
+ var pos;
551
+
552
+ each(grid, function(row, y) {
553
+ each(row, function(cell, x) {
554
+ if (cell.elm == target) {
555
+ pos = {x : x, y : y};
556
+ return false;
557
+ }
558
+ });
559
+
560
+ return !pos;
561
+ });
562
+
563
+ return pos;
564
+ };
565
+
566
+ function setStartCell(cell) {
567
+ startPos = getPos(cell);
568
+ };
569
+
570
+ function findEndPos() {
571
+ var pos, maxX, maxY;
572
+
573
+ maxX = maxY = 0;
574
+
575
+ each(grid, function(row, y) {
576
+ each(row, function(cell, x) {
577
+ var colSpan, rowSpan;
578
+
579
+ if (isCellSelected(cell)) {
580
+ cell = grid[y][x];
581
+
582
+ if (x > maxX)
583
+ maxX = x;
584
+
585
+ if (y > maxY)
586
+ maxY = y;
587
+
588
+ if (cell.real) {
589
+ colSpan = cell.colspan - 1;
590
+ rowSpan = cell.rowspan - 1;
591
+
592
+ if (colSpan) {
593
+ if (x + colSpan > maxX)
594
+ maxX = x + colSpan;
595
+ }
596
+
597
+ if (rowSpan) {
598
+ if (y + rowSpan > maxY)
599
+ maxY = y + rowSpan;
600
+ }
601
+ }
602
+ }
603
+ });
604
+ });
605
+
606
+ return {x : maxX, y : maxY};
607
+ };
608
+
609
+ function setEndCell(cell) {
610
+ var startX, startY, endX, endY, maxX, maxY, colSpan, rowSpan;
611
+
612
+ endPos = getPos(cell);
613
+
614
+ if (startPos && endPos) {
615
+ // Get start/end positions
616
+ startX = Math.min(startPos.x, endPos.x);
617
+ startY = Math.min(startPos.y, endPos.y);
618
+ endX = Math.max(startPos.x, endPos.x);
619
+ endY = Math.max(startPos.y, endPos.y);
620
+
621
+ // Expand end positon to include spans
622
+ maxX = endX;
623
+ maxY = endY;
624
+
625
+ // Expand startX
626
+ for (y = startY; y <= maxY; y++) {
627
+ cell = grid[y][startX];
628
+
629
+ if (!cell.real) {
630
+ if (startX - (cell.colspan - 1) < startX)
631
+ startX -= cell.colspan - 1;
632
+ }
633
+ }
634
+
635
+ // Expand startY
636
+ for (x = startX; x <= maxX; x++) {
637
+ cell = grid[startY][x];
638
+
639
+ if (!cell.real) {
640
+ if (startY - (cell.rowspan - 1) < startY)
641
+ startY -= cell.rowspan - 1;
642
+ }
643
+ }
644
+
645
+ // Find max X, Y
646
+ for (y = startY; y <= endY; y++) {
647
+ for (x = startX; x <= endX; x++) {
648
+ cell = grid[y][x];
649
+
650
+ if (cell.real) {
651
+ colSpan = cell.colspan - 1;
652
+ rowSpan = cell.rowspan - 1;
653
+
654
+ if (colSpan) {
655
+ if (x + colSpan > maxX)
656
+ maxX = x + colSpan;
657
+ }
658
+
659
+ if (rowSpan) {
660
+ if (y + rowSpan > maxY)
661
+ maxY = y + rowSpan;
662
+ }
663
+ }
664
+ }
665
+ }
666
+
667
+ // Remove current selection
668
+ dom.removeClass(dom.select('td.mceSelected,th.mceSelected'), 'mceSelected');
669
+
670
+ // Add new selection
671
+ for (y = startY; y <= maxY; y++) {
672
+ for (x = startX; x <= maxX; x++)
673
+ dom.addClass(grid[y][x].elm, 'mceSelected');
674
+ }
675
+ }
676
+ };
677
+
678
+ // Expose to public
679
+ tinymce.extend(this, {
680
+ deleteTable : deleteTable,
681
+ split : split,
682
+ merge : merge,
683
+ insertRow : insertRow,
684
+ insertCol : insertCol,
685
+ deleteCols : deleteCols,
686
+ deleteRows : deleteRows,
687
+ cutRows : cutRows,
688
+ copyRows : copyRows,
689
+ pasteRows : pasteRows,
690
+ getPos : getPos,
691
+ setStartCell : setStartCell,
692
+ setEndCell : setEndCell
693
+ });
694
+ };
695
+
696
+ tinymce.create('tinymce.plugins.TablePlugin', {
697
+ init : function(ed, url) {
698
+ var winMan, clipboardRows;
699
+
700
+ function createTableGrid(node) {
701
+ var selection = ed.selection, tblElm = ed.dom.getParent(node || selection.getNode(), 'table');
702
+
703
+ if (tblElm)
704
+ return new TableGrid(tblElm, ed.dom, selection);
705
+ };
706
+
707
+ function cleanup() {
708
+ // Restore selection possibilities
709
+ ed.getBody().style.webkitUserSelect = '';
710
+ ed.dom.removeClass(ed.dom.select('td.mceSelected,th.mceSelected'), 'mceSelected');
711
+ };
712
+
713
+ // Register buttons
714
+ each([
715
+ ['table', 'table.desc', 'mceInsertTable', true],
716
+ ['delete_table', 'table.del', 'mceTableDelete'],
717
+ ['delete_col', 'table.delete_col_desc', 'mceTableDeleteCol'],
718
+ ['delete_row', 'table.delete_row_desc', 'mceTableDeleteRow'],
719
+ ['col_after', 'table.col_after_desc', 'mceTableInsertColAfter'],
720
+ ['col_before', 'table.col_before_desc', 'mceTableInsertColBefore'],
721
+ ['row_after', 'table.row_after_desc', 'mceTableInsertRowAfter'],
722
+ ['row_before', 'table.row_before_desc', 'mceTableInsertRowBefore'],
723
+ ['row_props', 'table.row_desc', 'mceTableRowProps', true],
724
+ ['cell_props', 'table.cell_desc', 'mceTableCellProps', true],
725
+ ['split_cells', 'table.split_cells_desc', 'mceTableSplitCells', true],
726
+ ['merge_cells', 'table.merge_cells_desc', 'mceTableMergeCells', true]
727
+ ], function(c) {
728
+ ed.addButton(c[0], {title : c[1], cmd : c[2], ui : c[3]});
729
+ });
730
+
731
+ // Select whole table is a table border is clicked
732
+ if (!tinymce.isIE) {
733
+ ed.onClick.add(function(ed, e) {
734
+ e = e.target;
735
+
736
+ if (e.nodeName === 'TABLE')
737
+ ed.selection.select(e);
738
+ });
739
+ }
740
+
741
+ // Handle node change updates
742
+ ed.onNodeChange.add(function(ed, cm, n) {
743
+ var p;
744
+
745
+ n = ed.selection.getStart();
746
+ p = ed.dom.getParent(n, 'td,th,caption');
747
+ cm.setActive('table', n.nodeName === 'TABLE' || !!p);
748
+
749
+ // Disable table tools if we are in caption
750
+ if (p && p.nodeName === 'CAPTION')
751
+ p = 0;
752
+
753
+ cm.setDisabled('delete_table', !p);
754
+ cm.setDisabled('delete_col', !p);
755
+ cm.setDisabled('delete_table', !p);
756
+ cm.setDisabled('delete_row', !p);
757
+ cm.setDisabled('col_after', !p);
758
+ cm.setDisabled('col_before', !p);
759
+ cm.setDisabled('row_after', !p);
760
+ cm.setDisabled('row_before', !p);
761
+ cm.setDisabled('row_props', !p);
762
+ cm.setDisabled('cell_props', !p);
763
+ cm.setDisabled('split_cells', !p);
764
+ cm.setDisabled('merge_cells', !p);
765
+ });
766
+
767
+ ed.onInit.add(function(ed) {
768
+ var startTable, startCell, dom = ed.dom, tableGrid;
769
+
770
+ winMan = ed.windowManager;
771
+
772
+ // Add cell selection logic
773
+ ed.onMouseDown.add(function(ed, e) {
774
+ if (e.button != 2) {
775
+ cleanup();
776
+
777
+ startCell = dom.getParent(e.target, 'td,th');
778
+ startTable = dom.getParent(startCell, 'table');
779
+ }
780
+ });
781
+
782
+ dom.bind(ed.getDoc(), 'mouseover', function(e) {
783
+ var sel, table, target = e.target;
784
+
785
+ if (startCell && (tableGrid || target != startCell) && (target.nodeName == 'TD' || target.nodeName == 'TH')) {
786
+ table = dom.getParent(target, 'table');
787
+ if (table == startTable) {
788
+ if (!tableGrid) {
789
+ tableGrid = createTableGrid(table);
790
+ tableGrid.setStartCell(startCell);
791
+
792
+ ed.getBody().style.webkitUserSelect = 'none';
793
+ }
794
+
795
+ tableGrid.setEndCell(target);
796
+ }
797
+
798
+ // Remove current selection
799
+ sel = ed.selection.getSel();
800
+
801
+ if (sel.removeAllRanges)
802
+ sel.removeAllRanges();
803
+ else
804
+ sel.empty();
805
+
806
+ e.preventDefault();
807
+ }
808
+ });
809
+
810
+ ed.onMouseUp.add(function(ed, e) {
811
+ var rng, sel = ed.selection, selectedCells, nativeSel = sel.getSel(), walker, node, lastNode, endNode;
812
+
813
+ // Move selection to startCell
814
+ if (startCell) {
815
+ if (tableGrid)
816
+ ed.getBody().style.webkitUserSelect = '';
817
+
818
+ function setPoint(node, start) {
819
+ var walker = new tinymce.dom.TreeWalker(node, node);
820
+
821
+ do {
822
+ // Text node
823
+ if (node.nodeType == 3 && tinymce.trim(node.nodeValue).length != 0) {
824
+ if (start)
825
+ rng.setStart(node, 0);
826
+ else
827
+ rng.setEnd(node, node.nodeValue.length);
828
+
829
+ return;
830
+ }
831
+
832
+ // BR element
833
+ if (node.nodeName == 'BR') {
834
+ if (start)
835
+ rng.setStartBefore(node);
836
+ else
837
+ rng.setEndBefore(node);
838
+
839
+ return;
840
+ }
841
+ } while (node = (start ? walker.next() : walker.prev()));
842
+ };
843
+
844
+ // Try to expand text selection as much as we can only Gecko supports cell selection
845
+ selectedCells = dom.select('td.mceSelected,th.mceSelected');
846
+ if (selectedCells.length > 0) {
847
+ rng = dom.createRng();
848
+ node = selectedCells[0];
849
+ endNode = selectedCells[selectedCells.length - 1];
850
+
851
+ setPoint(node, 1);
852
+ walker = new tinymce.dom.TreeWalker(node, dom.getParent(selectedCells[0], 'table'));
853
+
854
+ do {
855
+ if (node.nodeName == 'TD' || node.nodeName == 'TH') {
856
+ if (!dom.hasClass(node, 'mceSelected'))
857
+ break;
858
+
859
+ lastNode = node;
860
+ }
861
+ } while (node = walker.next());
862
+
863
+ setPoint(lastNode);
864
+
865
+ sel.setRng(rng);
866
+ }
867
+
868
+ ed.nodeChanged();
869
+ startCell = tableGrid = startTable = null;
870
+ }
871
+ });
872
+
873
+ ed.onKeyUp.add(function(ed, e) {
874
+ cleanup();
875
+ });
876
+
877
+ // Add context menu
878
+ if (ed && ed.plugins.contextmenu) {
879
+ ed.plugins.contextmenu.onContextMenu.add(function(th, m, e) {
880
+ var sm, se = ed.selection, el = se.getNode() || ed.getBody();
881
+
882
+ if (ed.dom.getParent(e, 'td') || ed.dom.getParent(e, 'th')) {
883
+ m.removeAll();
884
+
885
+ if (el.nodeName == 'A' && !ed.dom.getAttrib(el, 'name')) {
886
+ m.add({title : 'advanced.link_desc', icon : 'link', cmd : ed.plugins.advlink ? 'mceAdvLink' : 'mceLink', ui : true});
887
+ m.add({title : 'advanced.unlink_desc', icon : 'unlink', cmd : 'UnLink'});
888
+ m.addSeparator();
889
+ }
890
+
891
+ if (el.nodeName == 'IMG' && el.className.indexOf('mceItem') == -1) {
892
+ m.add({title : 'advanced.image_desc', icon : 'image', cmd : ed.plugins.advimage ? 'mceAdvImage' : 'mceImage', ui : true});
893
+ m.addSeparator();
894
+ }
895
+
896
+ m.add({title : 'table.desc', icon : 'table', cmd : 'mceInsertTable', value : {action : 'insert'}});
897
+ m.add({title : 'table.props_desc', icon : 'table_props', cmd : 'mceInsertTable'});
898
+ m.add({title : 'table.del', icon : 'delete_table', cmd : 'mceTableDelete'});
899
+ m.addSeparator();
900
+
901
+ // Cell menu
902
+ sm = m.addMenu({title : 'table.cell'});
903
+ sm.add({title : 'table.cell_desc', icon : 'cell_props', cmd : 'mceTableCellProps'});
904
+ sm.add({title : 'table.split_cells_desc', icon : 'split_cells', cmd : 'mceTableSplitCells'});
905
+ sm.add({title : 'table.merge_cells_desc', icon : 'merge_cells', cmd : 'mceTableMergeCells'});
906
+
907
+ // Row menu
908
+ sm = m.addMenu({title : 'table.row'});
909
+ sm.add({title : 'table.row_desc', icon : 'row_props', cmd : 'mceTableRowProps'});
910
+ sm.add({title : 'table.row_before_desc', icon : 'row_before', cmd : 'mceTableInsertRowBefore'});
911
+ sm.add({title : 'table.row_after_desc', icon : 'row_after', cmd : 'mceTableInsertRowAfter'});
912
+ sm.add({title : 'table.delete_row_desc', icon : 'delete_row', cmd : 'mceTableDeleteRow'});
913
+ sm.addSeparator();
914
+ sm.add({title : 'table.cut_row_desc', icon : 'cut', cmd : 'mceTableCutRow'});
915
+ sm.add({title : 'table.copy_row_desc', icon : 'copy', cmd : 'mceTableCopyRow'});
916
+ sm.add({title : 'table.paste_row_before_desc', icon : 'paste', cmd : 'mceTablePasteRowBefore'}).setDisabled(!clipboardRows);
917
+ sm.add({title : 'table.paste_row_after_desc', icon : 'paste', cmd : 'mceTablePasteRowAfter'}).setDisabled(!clipboardRows);
918
+
919
+ // Column menu
920
+ sm = m.addMenu({title : 'table.col'});
921
+ sm.add({title : 'table.col_before_desc', icon : 'col_before', cmd : 'mceTableInsertColBefore'});
922
+ sm.add({title : 'table.col_after_desc', icon : 'col_after', cmd : 'mceTableInsertColAfter'});
923
+ sm.add({title : 'table.delete_col_desc', icon : 'delete_col', cmd : 'mceTableDeleteCol'});
924
+ } else
925
+ m.add({title : 'table.desc', icon : 'table', cmd : 'mceInsertTable'});
926
+ });
927
+ }
928
+
929
+ // Fixes an issue on Gecko where it's impossible to place the caret behind a table
930
+ // This fix will force a paragraph element after the table but only when the forced_root_block setting is enabled
931
+ if (!tinymce.isIE) {
932
+ function fixTableCaretPos() {
933
+ var last;
934
+
935
+ // Skip empty text nodes form the end
936
+ for (last = ed.getBody().lastChild; last && last.nodeType == 3 && !last.nodeValue.length; last = last.previousSibling) ;
937
+
938
+ if (last && last.nodeName == 'TABLE')
939
+ ed.dom.add(ed.getBody(), 'p', null, '<br mce_bogus="1" />');
940
+ };
941
+
942
+ // Fixes an bug where it's impossible to place the caret before a table in Gecko
943
+ // this fix solves it by detecting when the caret is at the beginning of such a table
944
+ // and then manually moves the caret infront of the table
945
+ if (tinymce.isGecko) {
946
+ ed.onKeyDown.add(function(ed, e) {
947
+ var rng, table, dom = ed.dom;
948
+
949
+ // On gecko it's not possible to place the caret before a table
950
+ if (e.keyCode == 37 || e.keyCode == 38) {
951
+ rng = ed.selection.getRng();
952
+ table = dom.getParent(rng.startContainer, 'table');
953
+
954
+ if (table && ed.getBody().firstChild == table) {
955
+ if (isAtStart(rng, table)) {
956
+ rng = dom.createRng();
957
+
958
+ rng.setStartBefore(table);
959
+ rng.setEndBefore(table);
960
+
961
+ ed.selection.setRng(rng);
962
+
963
+ e.preventDefault();
964
+ }
965
+ }
966
+ }
967
+ });
968
+ }
969
+
970
+ ed.onKeyUp.add(fixTableCaretPos);
971
+ ed.onSetContent.add(fixTableCaretPos);
972
+ ed.onVisualAid.add(fixTableCaretPos);
973
+
974
+ ed.onPreProcess.add(function(ed, o) {
975
+ var last = o.node.lastChild;
976
+
977
+ if (last && last.childNodes.length == 1 && last.firstChild.nodeName == 'BR')
978
+ ed.dom.remove(last);
979
+ });
980
+
981
+ fixTableCaretPos();
982
+ }
983
+ });
984
+
985
+ // Register action commands
986
+ each({
987
+ mceTableSplitCells : function(grid) {
988
+ grid.split();
989
+ },
990
+
991
+ mceTableMergeCells : function(grid) {
992
+ var rowSpan, colSpan, cell;
993
+
994
+ cell = ed.dom.getParent(ed.selection.getNode(), 'th,td');
995
+ if (cell) {
996
+ rowSpan = cell.rowSpan;
997
+ colSpan = cell.colSpan;
998
+ }
999
+
1000
+ if (!ed.dom.select('td.mceSelected,th.mceSelected').length) {
1001
+ winMan.open({
1002
+ url : url + '/merge_cells.htm',
1003
+ width : 240 + parseInt(ed.getLang('table.merge_cells_delta_width', 0)),
1004
+ height : 110 + parseInt(ed.getLang('table.merge_cells_delta_height', 0)),
1005
+ inline : 1
1006
+ }, {
1007
+ rows : rowSpan,
1008
+ cols : colSpan,
1009
+ onaction : function(data) {
1010
+ grid.merge(cell, data.cols, data.rows);
1011
+ },
1012
+ plugin_url : url
1013
+ });
1014
+ } else
1015
+ grid.merge();
1016
+ },
1017
+
1018
+ mceTableInsertRowBefore : function(grid) {
1019
+ grid.insertRow(true);
1020
+ },
1021
+
1022
+ mceTableInsertRowAfter : function(grid) {
1023
+ grid.insertRow();
1024
+ },
1025
+
1026
+ mceTableInsertColBefore : function(grid) {
1027
+ grid.insertCol(true);
1028
+ },
1029
+
1030
+ mceTableInsertColAfter : function(grid) {
1031
+ grid.insertCol();
1032
+ },
1033
+
1034
+ mceTableDeleteCol : function(grid) {
1035
+ grid.deleteCols();
1036
+ },
1037
+
1038
+ mceTableDeleteRow : function(grid) {
1039
+ grid.deleteRows();
1040
+ },
1041
+
1042
+ mceTableCutRow : function(grid) {
1043
+ clipboardRows = grid.cutRows();
1044
+ },
1045
+
1046
+ mceTableCopyRow : function(grid) {
1047
+ clipboardRows = grid.copyRows();
1048
+ },
1049
+
1050
+ mceTablePasteRowBefore : function(grid) {
1051
+ grid.pasteRows(clipboardRows, true);
1052
+ },
1053
+
1054
+ mceTablePasteRowAfter : function(grid) {
1055
+ grid.pasteRows(clipboardRows);
1056
+ },
1057
+
1058
+ mceTableDelete : function(grid) {
1059
+ grid.deleteTable();
1060
+ }
1061
+ }, function(func, name) {
1062
+ ed.addCommand(name, function() {
1063
+ var grid = createTableGrid();
1064
+
1065
+ if (grid) {
1066
+ func(grid);
1067
+ ed.execCommand('mceRepaint');
1068
+ cleanup();
1069
+ }
1070
+ });
1071
+ });
1072
+
1073
+ // Register dialog commands
1074
+ each({
1075
+ mceInsertTable : function(val) {
1076
+ winMan.open({
1077
+ url : url + '/table.htm',
1078
+ width : 400 + parseInt(ed.getLang('table.table_delta_width', 0)),
1079
+ height : 320 + parseInt(ed.getLang('table.table_delta_height', 0)),
1080
+ inline : 1
1081
+ }, {
1082
+ plugin_url : url,
1083
+ action : val ? val.action : 0
1084
+ });
1085
+ },
1086
+
1087
+ mceTableRowProps : function() {
1088
+ winMan.open({
1089
+ url : url + '/row.htm',
1090
+ width : 400 + parseInt(ed.getLang('table.rowprops_delta_width', 0)),
1091
+ height : 295 + parseInt(ed.getLang('table.rowprops_delta_height', 0)),
1092
+ inline : 1
1093
+ }, {
1094
+ plugin_url : url
1095
+ });
1096
+ },
1097
+
1098
+ mceTableCellProps : function() {
1099
+ winMan.open({
1100
+ url : url + '/cell.htm',
1101
+ width : 400 + parseInt(ed.getLang('table.cellprops_delta_width', 0)),
1102
+ height : 295 + parseInt(ed.getLang('table.cellprops_delta_height', 0)),
1103
+ inline : 1
1104
+ }, {
1105
+ plugin_url : url
1106
+ });
1107
+ }
1108
+ }, function(func, name) {
1109
+ ed.addCommand(name, function(ui, val) {
1110
+ func(val);
1111
+ });
1112
+ });
1113
+ }
1114
+ });
1115
+
1116
+ // Register plugin
1117
+ tinymce.PluginManager.add('table', tinymce.plugins.TablePlugin);
1118
+ })(tinymce);