rails_kindeditor_video 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/Gemfile +6 -0
  4. data/README.md +473 -0
  5. data/Rakefile +2 -0
  6. data/app/assets/javascripts/kindeditor.js +1 -0
  7. data/app/controllers/kindeditor/assets_controller.rb +127 -0
  8. data/app/uploaders/kindeditor/asset_uploader.rb +89 -0
  9. data/app/uploaders/kindeditor/file_uploader.rb +10 -0
  10. data/app/uploaders/kindeditor/flash_uploader.rb +10 -0
  11. data/app/uploaders/kindeditor/image_uploader.rb +10 -0
  12. data/app/uploaders/kindeditor/media_uploader.rb +10 -0
  13. data/config/routes.rb +6 -0
  14. data/lib/generators/rails_kindeditor/install/USAGE +10 -0
  15. data/lib/generators/rails_kindeditor/install/install_generator.rb +23 -0
  16. data/lib/generators/rails_kindeditor/install/templates/application.js +17 -0
  17. data/lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb +29 -0
  18. data/lib/generators/rails_kindeditor/migration/USAGE +14 -0
  19. data/lib/generators/rails_kindeditor/migration/migration_generator.rb +36 -0
  20. data/lib/generators/rails_kindeditor/migration/templates/migration/migration.rb +18 -0
  21. data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/asset.rb +14 -0
  22. data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/file.rb +3 -0
  23. data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/flash.rb +3 -0
  24. data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/image.rb +3 -0
  25. data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/media.rb +3 -0
  26. data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb +27 -0
  27. data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/file.rb +3 -0
  28. data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/flash.rb +3 -0
  29. data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/image.rb +3 -0
  30. data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/media.rb +3 -0
  31. data/lib/rails_kindeditor/active_record.rb +14 -0
  32. data/lib/rails_kindeditor/engine.rb +34 -0
  33. data/lib/rails_kindeditor/formtastic.rb +12 -0
  34. data/lib/rails_kindeditor/helper.rb +117 -0
  35. data/lib/rails_kindeditor/simple_form.rb +11 -0
  36. data/lib/rails_kindeditor/version.rb +4 -0
  37. data/lib/rails_kindeditor.rb +61 -0
  38. data/lib/rails_kindeditor_video.rb +1 -0
  39. data/lib/tasks/assets.rake +9 -0
  40. data/rails_kindeditor_video.gemspec +24 -0
  41. data/screenshots/rails_kindeditor.png +0 -0
  42. data/screenshots/simple_mode.png +0 -0
  43. data/vendor/assets/javascripts/kindeditor/kindeditor.js +9909 -0
  44. data/vendor/assets/javascripts/kindeditor/lang/ar.js +242 -0
  45. data/vendor/assets/javascripts/kindeditor/lang/en.js +241 -0
  46. data/vendor/assets/javascripts/kindeditor/lang/ko.js +246 -0
  47. data/vendor/assets/javascripts/kindeditor/lang/ru.js +242 -0
  48. data/vendor/assets/javascripts/kindeditor/lang/zh-CN.js +238 -0
  49. data/vendor/assets/javascripts/kindeditor/lang/zh-TW.js +243 -0
  50. data/vendor/assets/javascripts/kindeditor/plugins/anchor/anchor.js +46 -0
  51. data/vendor/assets/javascripts/kindeditor/plugins/autoheight/autoheight.js +54 -0
  52. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/baidumap.js +93 -0
  53. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/index.html +83 -0
  54. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/map.html +43 -0
  55. data/vendor/assets/javascripts/kindeditor/plugins/clearhtml/clearhtml.js +29 -0
  56. data/vendor/assets/javascripts/kindeditor/plugins/code/code.js +62 -0
  57. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.css +13 -0
  58. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.js +28 -0
  59. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/emoticons.js +129 -0
  60. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/0.gif +0 -0
  61. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/1.gif +0 -0
  62. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/10.gif +0 -0
  63. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/100.gif +0 -0
  64. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/101.gif +0 -0
  65. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/102.gif +0 -0
  66. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/103.gif +0 -0
  67. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/104.gif +0 -0
  68. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/105.gif +0 -0
  69. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/106.gif +0 -0
  70. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/107.gif +0 -0
  71. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/108.gif +0 -0
  72. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/109.gif +0 -0
  73. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/11.gif +0 -0
  74. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/110.gif +0 -0
  75. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/111.gif +0 -0
  76. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/112.gif +0 -0
  77. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/113.gif +0 -0
  78. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/114.gif +0 -0
  79. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/115.gif +0 -0
  80. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/116.gif +0 -0
  81. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/117.gif +0 -0
  82. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/118.gif +0 -0
  83. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/119.gif +0 -0
  84. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/12.gif +0 -0
  85. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/120.gif +0 -0
  86. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/121.gif +0 -0
  87. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/122.gif +0 -0
  88. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/123.gif +0 -0
  89. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/124.gif +0 -0
  90. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/125.gif +0 -0
  91. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/126.gif +0 -0
  92. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/127.gif +0 -0
  93. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/128.gif +0 -0
  94. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/129.gif +0 -0
  95. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/13.gif +0 -0
  96. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/130.gif +0 -0
  97. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/131.gif +0 -0
  98. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/132.gif +0 -0
  99. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/133.gif +0 -0
  100. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/134.gif +0 -0
  101. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/14.gif +0 -0
  102. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/15.gif +0 -0
  103. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/16.gif +0 -0
  104. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/17.gif +0 -0
  105. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/18.gif +0 -0
  106. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/19.gif +0 -0
  107. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/2.gif +0 -0
  108. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/20.gif +0 -0
  109. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/21.gif +0 -0
  110. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/22.gif +0 -0
  111. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/23.gif +0 -0
  112. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/24.gif +0 -0
  113. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/25.gif +0 -0
  114. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/26.gif +0 -0
  115. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/27.gif +0 -0
  116. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/28.gif +0 -0
  117. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/29.gif +0 -0
  118. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/3.gif +0 -0
  119. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/30.gif +0 -0
  120. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/31.gif +0 -0
  121. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/32.gif +0 -0
  122. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/33.gif +0 -0
  123. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/34.gif +0 -0
  124. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/35.gif +0 -0
  125. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/36.gif +0 -0
  126. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/37.gif +0 -0
  127. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/38.gif +0 -0
  128. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/39.gif +0 -0
  129. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/4.gif +0 -0
  130. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/40.gif +0 -0
  131. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/41.gif +0 -0
  132. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/42.gif +0 -0
  133. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/43.gif +0 -0
  134. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/44.gif +0 -0
  135. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/45.gif +0 -0
  136. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/46.gif +0 -0
  137. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/47.gif +0 -0
  138. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/48.gif +0 -0
  139. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/49.gif +0 -0
  140. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/5.gif +0 -0
  141. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/50.gif +0 -0
  142. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/51.gif +0 -0
  143. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/52.gif +0 -0
  144. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/53.gif +0 -0
  145. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/54.gif +0 -0
  146. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/55.gif +0 -0
  147. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/56.gif +0 -0
  148. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/57.gif +0 -0
  149. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/58.gif +0 -0
  150. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/59.gif +0 -0
  151. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/6.gif +0 -0
  152. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/60.gif +0 -0
  153. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/61.gif +0 -0
  154. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/62.gif +0 -0
  155. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/63.gif +0 -0
  156. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/64.gif +0 -0
  157. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/65.gif +0 -0
  158. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/66.gif +0 -0
  159. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/67.gif +0 -0
  160. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/68.gif +0 -0
  161. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/69.gif +0 -0
  162. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/7.gif +0 -0
  163. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/70.gif +0 -0
  164. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/71.gif +0 -0
  165. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/72.gif +0 -0
  166. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/73.gif +0 -0
  167. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/74.gif +0 -0
  168. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/75.gif +0 -0
  169. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/76.gif +0 -0
  170. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/77.gif +0 -0
  171. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/78.gif +0 -0
  172. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/79.gif +0 -0
  173. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/8.gif +0 -0
  174. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/80.gif +0 -0
  175. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/81.gif +0 -0
  176. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/82.gif +0 -0
  177. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/83.gif +0 -0
  178. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/84.gif +0 -0
  179. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/85.gif +0 -0
  180. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/86.gif +0 -0
  181. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/87.gif +0 -0
  182. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/88.gif +0 -0
  183. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/89.gif +0 -0
  184. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/9.gif +0 -0
  185. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/90.gif +0 -0
  186. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/91.gif +0 -0
  187. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/92.gif +0 -0
  188. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/93.gif +0 -0
  189. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/94.gif +0 -0
  190. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/95.gif +0 -0
  191. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/96.gif +0 -0
  192. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/97.gif +0 -0
  193. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/98.gif +0 -0
  194. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/99.gif +0 -0
  195. data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/static.gif +0 -0
  196. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/filemanager.js +189 -0
  197. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/file-16.gif +0 -0
  198. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/file-64.gif +0 -0
  199. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/folder-16.gif +0 -0
  200. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/folder-64.gif +0 -0
  201. data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/go-up.gif +0 -0
  202. data/vendor/assets/javascripts/kindeditor/plugins/fixtoolbar/fixtoolbar.js +35 -0
  203. data/vendor/assets/javascripts/kindeditor/plugins/flash/flash.js +161 -0
  204. data/vendor/assets/javascripts/kindeditor/plugins/image/image.js +328 -0
  205. data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_left.gif +0 -0
  206. data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_right.gif +0 -0
  207. data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_top.gif +0 -0
  208. data/vendor/assets/javascripts/kindeditor/plugins/image/images/refresh.png +0 -0
  209. data/vendor/assets/javascripts/kindeditor/plugins/insertfile/insertfile.js +138 -0
  210. data/vendor/assets/javascripts/kindeditor/plugins/lineheight/lineheight.js +38 -0
  211. data/vendor/assets/javascripts/kindeditor/plugins/link/link.js +66 -0
  212. data/vendor/assets/javascripts/kindeditor/plugins/map/map.html +57 -0
  213. data/vendor/assets/javascripts/kindeditor/plugins/map/map.js +137 -0
  214. data/vendor/assets/javascripts/kindeditor/plugins/media/media.js +170 -0
  215. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/image.png +0 -0
  216. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/select-files-en.png +0 -0
  217. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/select-files-zh-CN.png +0 -0
  218. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/swfupload.swf +0 -0
  219. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/multiimage.js +1384 -0
  220. data/vendor/assets/javascripts/kindeditor/plugins/pagebreak/pagebreak.js +27 -0
  221. data/vendor/assets/javascripts/kindeditor/plugins/plainpaste/plainpaste.js +41 -0
  222. data/vendor/assets/javascripts/kindeditor/plugins/preview/preview.js +31 -0
  223. data/vendor/assets/javascripts/kindeditor/plugins/quickformat/quickformat.js +81 -0
  224. data/vendor/assets/javascripts/kindeditor/plugins/table/table.js +712 -0
  225. data/vendor/assets/javascripts/kindeditor/plugins/template/html/1.html +14 -0
  226. data/vendor/assets/javascripts/kindeditor/plugins/template/html/2.html +42 -0
  227. data/vendor/assets/javascripts/kindeditor/plugins/template/html/3.html +36 -0
  228. data/vendor/assets/javascripts/kindeditor/plugins/template/template.js +58 -0
  229. data/vendor/assets/javascripts/kindeditor/plugins/wordpaste/wordpaste.js +51 -0
  230. data/vendor/assets/javascripts/kindeditor/themes/common/anchor.gif +0 -0
  231. data/vendor/assets/javascripts/kindeditor/themes/common/blank.gif +0 -0
  232. data/vendor/assets/javascripts/kindeditor/themes/common/flash.gif +0 -0
  233. data/vendor/assets/javascripts/kindeditor/themes/common/loading.gif +0 -0
  234. data/vendor/assets/javascripts/kindeditor/themes/common/media.gif +0 -0
  235. data/vendor/assets/javascripts/kindeditor/themes/common/rm.gif +0 -0
  236. data/vendor/assets/javascripts/kindeditor/themes/default/background.png +0 -0
  237. data/vendor/assets/javascripts/kindeditor/themes/default/default.css +1147 -0
  238. data/vendor/assets/javascripts/kindeditor/themes/default/default.png +0 -0
  239. data/vendor/assets/javascripts/kindeditor/themes/qq/editor.gif +0 -0
  240. data/vendor/assets/javascripts/kindeditor/themes/qq/qq.css +143 -0
  241. data/vendor/assets/javascripts/kindeditor/themes/simple/simple.css +100 -0
  242. metadata +312 -0
@@ -0,0 +1,712 @@
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('table', function(K) {
11
+ var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
12
+ // 设置颜色
13
+ function _setColor(box, color) {
14
+ color = color.toUpperCase();
15
+ box.css('background-color', color);
16
+ box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
17
+ box.html(color);
18
+ }
19
+ // 初始化取色器
20
+ var pickerList = [];
21
+ function _initColorPicker(dialogDiv, colorBox) {
22
+ colorBox.bind('click,mousedown', function(e){
23
+ e.stopPropagation();
24
+ });
25
+ function removePicker() {
26
+ K.each(pickerList, function() {
27
+ this.remove();
28
+ });
29
+ pickerList = [];
30
+ K(document).unbind('click,mousedown', removePicker);
31
+ dialogDiv.unbind('click,mousedown', removePicker);
32
+ }
33
+ colorBox.click(function(e) {
34
+ removePicker();
35
+ var box = K(this),
36
+ pos = box.pos();
37
+ var picker = K.colorpicker({
38
+ x : pos.x,
39
+ y : pos.y + box.height(),
40
+ z : 811214,
41
+ selectedColor : K(this).html(),
42
+ colors : self.colorTable,
43
+ noColor : self.lang('noColor'),
44
+ shadowMode : self.shadowMode,
45
+ click : function(color) {
46
+ _setColor(box, color);
47
+ removePicker();
48
+ }
49
+ });
50
+ pickerList.push(picker);
51
+ K(document).bind('click,mousedown', removePicker);
52
+ dialogDiv.bind('click,mousedown', removePicker);
53
+ });
54
+ }
55
+ // 取得下一行cell的index
56
+ function _getCellIndex(table, row, cell) {
57
+ var rowSpanCount = 0;
58
+ for (var i = 0, len = row.cells.length; i < len; i++) {
59
+ if (row.cells[i] == cell) {
60
+ break;
61
+ }
62
+ rowSpanCount += row.cells[i].rowSpan - 1;
63
+ }
64
+ return cell.cellIndex - rowSpanCount;
65
+ }
66
+ self.plugin.table = {
67
+ //insert or modify table
68
+ prop : function(isInsert) {
69
+ var html = [
70
+ '<div style="padding:20px;">',
71
+ //rows, cols
72
+ '<div class="ke-dialog-row">',
73
+ '<label for="keRows" style="width:90px;">' + lang.cells + '</label>',
74
+ lang.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> &nbsp; ',
75
+ lang.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />',
76
+ '</div>',
77
+ //width, height
78
+ '<div class="ke-dialog-row">',
79
+ '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
80
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
81
+ '<select name="widthType">',
82
+ '<option value="%">' + lang.percent + '</option>',
83
+ '<option value="px">' + lang.px + '</option>',
84
+ '</select> &nbsp; ',
85
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
86
+ '<select name="heightType">',
87
+ '<option value="%">' + lang.percent + '</option>',
88
+ '<option value="px">' + lang.px + '</option>',
89
+ '</select>',
90
+ '</div>',
91
+ //space, padding
92
+ '<div class="ke-dialog-row">',
93
+ '<label for="kePadding" style="width:90px;">' + lang.space + '</label>',
94
+ lang.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> &nbsp; ',
95
+ lang.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />',
96
+ '</div>',
97
+ //align
98
+ '<div class="ke-dialog-row">',
99
+ '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
100
+ '<select id="keAlign" name="align">',
101
+ '<option value="">' + lang.alignDefault + '</option>',
102
+ '<option value="left">' + lang.alignLeft + '</option>',
103
+ '<option value="center">' + lang.alignCenter + '</option>',
104
+ '<option value="right">' + lang.alignRight + '</option>',
105
+ '</select>',
106
+ '</div>',
107
+ //border
108
+ '<div class="ke-dialog-row">',
109
+ '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
110
+ lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
111
+ lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
112
+ '</div>',
113
+ //background color
114
+ '<div class="ke-dialog-row">',
115
+ '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
116
+ '<span class="ke-inline-block ke-input-color"></span>',
117
+ '</div>',
118
+ '</div>'
119
+ ].join('');
120
+ var bookmark = self.cmd.range.createBookmark();
121
+ var dialog = self.createDialog({
122
+ name : name,
123
+ width : 500,
124
+ title : self.lang(name),
125
+ body : html,
126
+ beforeRemove : function() {
127
+ colorBox.unbind();
128
+ },
129
+ yesBtn : {
130
+ name : self.lang('yes'),
131
+ click : function(e) {
132
+ var rows = rowsBox.val(),
133
+ cols = colsBox.val(),
134
+ width = widthBox.val(),
135
+ height = heightBox.val(),
136
+ widthType = widthTypeBox.val(),
137
+ heightType = heightTypeBox.val(),
138
+ padding = paddingBox.val(),
139
+ spacing = spacingBox.val(),
140
+ align = alignBox.val(),
141
+ border = borderBox.val(),
142
+ borderColor = K(colorBox[0]).html() || '',
143
+ bgColor = K(colorBox[1]).html() || '';
144
+ if (rows == 0 || !/^\d+$/.test(rows)) {
145
+ alert(self.lang('invalidRows'));
146
+ rowsBox[0].focus();
147
+ return;
148
+ }
149
+ if (cols == 0 || !/^\d+$/.test(cols)) {
150
+ alert(self.lang('invalidRows'));
151
+ colsBox[0].focus();
152
+ return;
153
+ }
154
+ if (!/^\d*$/.test(width)) {
155
+ alert(self.lang('invalidWidth'));
156
+ widthBox[0].focus();
157
+ return;
158
+ }
159
+ if (!/^\d*$/.test(height)) {
160
+ alert(self.lang('invalidHeight'));
161
+ heightBox[0].focus();
162
+ return;
163
+ }
164
+ if (!/^\d*$/.test(padding)) {
165
+ alert(self.lang('invalidPadding'));
166
+ paddingBox[0].focus();
167
+ return;
168
+ }
169
+ if (!/^\d*$/.test(spacing)) {
170
+ alert(self.lang('invalidSpacing'));
171
+ spacingBox[0].focus();
172
+ return;
173
+ }
174
+ if (!/^\d*$/.test(border)) {
175
+ alert(self.lang('invalidBorder'));
176
+ borderBox[0].focus();
177
+ return;
178
+ }
179
+ //modify table
180
+ if (table) {
181
+ if (width !== '') {
182
+ table.width(width + widthType);
183
+ } else {
184
+ table.css('width', '');
185
+ }
186
+ if (table[0].width !== undefined) {
187
+ table.removeAttr('width');
188
+ }
189
+ if (height !== '') {
190
+ table.height(height + heightType);
191
+ } else {
192
+ table.css('height', '');
193
+ }
194
+ if (table[0].height !== undefined) {
195
+ table.removeAttr('height');
196
+ }
197
+ table.css('background-color', bgColor);
198
+ if (table[0].bgColor !== undefined) {
199
+ table.removeAttr('bgColor');
200
+ }
201
+ if (padding !== '') {
202
+ table[0].cellPadding = padding;
203
+ } else {
204
+ table.removeAttr('cellPadding');
205
+ }
206
+ if (spacing !== '') {
207
+ table[0].cellSpacing = spacing;
208
+ } else {
209
+ table.removeAttr('cellSpacing');
210
+ }
211
+ if (align !== '') {
212
+ table[0].align = align;
213
+ } else {
214
+ table.removeAttr('align');
215
+ }
216
+ if (border !== '') {
217
+ table.attr('border', border);
218
+ } else {
219
+ table.removeAttr('border');
220
+ }
221
+ if (border === '' || border === '0') {
222
+ table.addClass(zeroborder);
223
+ } else {
224
+ table.removeClass(zeroborder);
225
+ }
226
+ if (borderColor !== '') {
227
+ table.attr('borderColor', borderColor);
228
+ } else {
229
+ table.removeAttr('borderColor');
230
+ }
231
+ self.hideDialog().focus();
232
+ self.cmd.range.moveToBookmark(bookmark);
233
+ self.cmd.select();
234
+ self.addBookmark();
235
+ return;
236
+ }
237
+ //insert new table
238
+ var style = '';
239
+ if (width !== '') {
240
+ style += 'width:' + width + widthType + ';';
241
+ }
242
+ if (height !== '') {
243
+ style += 'height:' + height + heightType + ';';
244
+ }
245
+ if (bgColor !== '') {
246
+ style += 'background-color:' + bgColor + ';';
247
+ }
248
+ var html = '<table';
249
+ if (style !== '') {
250
+ html += ' style="' + style + '"';
251
+ }
252
+ if (padding !== '') {
253
+ html += ' cellpadding="' + padding + '"';
254
+ }
255
+ if (spacing !== '') {
256
+ html += ' cellspacing="' + spacing + '"';
257
+ }
258
+ if (align !== '') {
259
+ html += ' align="' + align + '"';
260
+ }
261
+ if (border !== '') {
262
+ html += ' border="' + border + '"';
263
+ }
264
+ if (border === '' || border === '0') {
265
+ html += ' class="' + zeroborder + '"';
266
+ }
267
+ if (borderColor !== '') {
268
+ html += ' bordercolor="' + borderColor + '"';
269
+ }
270
+ html += '>';
271
+ for (var i = 0; i < rows; i++) {
272
+ html += '<tr>';
273
+ for (var j = 0; j < cols; j++) {
274
+ html += '<td>' + (K.IE ? '&nbsp;' : '<br />') + '</td>';
275
+ }
276
+ html += '</tr>';
277
+ }
278
+ html += '</table>';
279
+ if (!K.IE) {
280
+ html += '<br />';
281
+ }
282
+ self.insertHtml(html);
283
+ self.select().hideDialog().focus();
284
+ self.addBookmark();
285
+ }
286
+ }
287
+ }),
288
+ div = dialog.div,
289
+ rowsBox = K('[name="rows"]', div).val(3),
290
+ colsBox = K('[name="cols"]', div).val(2),
291
+ widthBox = K('[name="width"]', div).val(100),
292
+ heightBox = K('[name="height"]', div),
293
+ widthTypeBox = K('[name="widthType"]', div),
294
+ heightTypeBox = K('[name="heightType"]', div),
295
+ paddingBox = K('[name="padding"]', div).val(2),
296
+ spacingBox = K('[name="spacing"]', div).val(0),
297
+ alignBox = K('[name="align"]', div),
298
+ borderBox = K('[name="border"]', div).val(1),
299
+ colorBox = K('.ke-input-color', div);
300
+ _initColorPicker(div, colorBox.eq(0));
301
+ _initColorPicker(div, colorBox.eq(1));
302
+ _setColor(colorBox.eq(0), '#000000');
303
+ _setColor(colorBox.eq(1), '');
304
+ // foucs and select
305
+ rowsBox[0].focus();
306
+ rowsBox[0].select();
307
+ var table;
308
+ if (isInsert) {
309
+ return;
310
+ }
311
+ //get selected table node
312
+ table = self.plugin.getSelectedTable();
313
+ if (table) {
314
+ rowsBox.val(table[0].rows.length);
315
+ colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
316
+ rowsBox.attr('disabled', true);
317
+ colsBox.attr('disabled', true);
318
+ var match,
319
+ tableWidth = table[0].style.width || table[0].width,
320
+ tableHeight = table[0].style.height || table[0].height;
321
+ if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
322
+ widthBox.val(match[1]);
323
+ widthTypeBox.val(match[2]);
324
+ } else {
325
+ widthBox.val('');
326
+ }
327
+ if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
328
+ heightBox.val(match[1]);
329
+ heightTypeBox.val(match[2]);
330
+ }
331
+ paddingBox.val(table[0].cellPadding || '');
332
+ spacingBox.val(table[0].cellSpacing || '');
333
+ alignBox.val(table[0].align || '');
334
+ borderBox.val(table[0].border === undefined ? '' : table[0].border);
335
+ _setColor(colorBox.eq(0), K.toHex(table.attr('borderColor') || ''));
336
+ _setColor(colorBox.eq(1), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
337
+ widthBox[0].focus();
338
+ widthBox[0].select();
339
+ }
340
+ },
341
+ //modify cell
342
+ cellprop : function() {
343
+ var html = [
344
+ '<div style="padding:20px;">',
345
+ //width, height
346
+ '<div class="ke-dialog-row">',
347
+ '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
348
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
349
+ '<select name="widthType">',
350
+ '<option value="%">' + lang.percent + '</option>',
351
+ '<option value="px">' + lang.px + '</option>',
352
+ '</select> &nbsp; ',
353
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
354
+ '<select name="heightType">',
355
+ '<option value="%">' + lang.percent + '</option>',
356
+ '<option value="px">' + lang.px + '</option>',
357
+ '</select>',
358
+ '</div>',
359
+ //align
360
+ '<div class="ke-dialog-row">',
361
+ '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
362
+ lang.textAlign + ' <select id="keAlign" name="textAlign">',
363
+ '<option value="">' + lang.alignDefault + '</option>',
364
+ '<option value="left">' + lang.alignLeft + '</option>',
365
+ '<option value="center">' + lang.alignCenter + '</option>',
366
+ '<option value="right">' + lang.alignRight + '</option>',
367
+ '</select> ',
368
+ lang.verticalAlign + ' <select name="verticalAlign">',
369
+ '<option value="">' + lang.alignDefault + '</option>',
370
+ '<option value="top">' + lang.alignTop + '</option>',
371
+ '<option value="middle">' + lang.alignMiddle + '</option>',
372
+ '<option value="bottom">' + lang.alignBottom + '</option>',
373
+ '<option value="baseline">' + lang.alignBaseline + '</option>',
374
+ '</select>',
375
+ '</div>',
376
+ //border
377
+ '<div class="ke-dialog-row">',
378
+ '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
379
+ lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
380
+ lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
381
+ '</div>',
382
+ //background color
383
+ '<div class="ke-dialog-row">',
384
+ '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
385
+ '<span class="ke-inline-block ke-input-color"></span>',
386
+ '</div>',
387
+ '</div>'
388
+ ].join('');
389
+ var bookmark = self.cmd.range.createBookmark();
390
+ var dialog = self.createDialog({
391
+ name : name,
392
+ width : 500,
393
+ title : self.lang('tablecell'),
394
+ body : html,
395
+ beforeRemove : function() {
396
+ colorBox.unbind();
397
+ },
398
+ yesBtn : {
399
+ name : self.lang('yes'),
400
+ click : function(e) {
401
+ var width = widthBox.val(),
402
+ height = heightBox.val(),
403
+ widthType = widthTypeBox.val(),
404
+ heightType = heightTypeBox.val(),
405
+ padding = paddingBox.val(),
406
+ spacing = spacingBox.val(),
407
+ textAlign = textAlignBox.val(),
408
+ verticalAlign = verticalAlignBox.val(),
409
+ border = borderBox.val(),
410
+ borderColor = K(colorBox[0]).html() || '',
411
+ bgColor = K(colorBox[1]).html() || '';
412
+ if (!/^\d*$/.test(width)) {
413
+ alert(self.lang('invalidWidth'));
414
+ widthBox[0].focus();
415
+ return;
416
+ }
417
+ if (!/^\d*$/.test(height)) {
418
+ alert(self.lang('invalidHeight'));
419
+ heightBox[0].focus();
420
+ return;
421
+ }
422
+ if (!/^\d*$/.test(border)) {
423
+ alert(self.lang('invalidBorder'));
424
+ borderBox[0].focus();
425
+ return;
426
+ }
427
+ cell.css({
428
+ width : width !== '' ? (width + widthType) : '',
429
+ height : height !== '' ? (height + heightType) : '',
430
+ 'background-color' : bgColor,
431
+ 'text-align' : textAlign,
432
+ 'vertical-align' : verticalAlign,
433
+ 'border-width' : border,
434
+ 'border-style' : border !== '' ? 'solid' : '',
435
+ 'border-color' : borderColor
436
+ });
437
+ self.hideDialog().focus();
438
+ self.cmd.range.moveToBookmark(bookmark);
439
+ self.cmd.select();
440
+ self.addBookmark();
441
+ }
442
+ }
443
+ }),
444
+ div = dialog.div,
445
+ widthBox = K('[name="width"]', div).val(100),
446
+ heightBox = K('[name="height"]', div),
447
+ widthTypeBox = K('[name="widthType"]', div),
448
+ heightTypeBox = K('[name="heightType"]', div),
449
+ paddingBox = K('[name="padding"]', div).val(2),
450
+ spacingBox = K('[name="spacing"]', div).val(0),
451
+ textAlignBox = K('[name="textAlign"]', div),
452
+ verticalAlignBox = K('[name="verticalAlign"]', div),
453
+ borderBox = K('[name="border"]', div).val(1),
454
+ colorBox = K('.ke-input-color', div);
455
+ _initColorPicker(div, colorBox.eq(0));
456
+ _initColorPicker(div, colorBox.eq(1));
457
+ _setColor(colorBox.eq(0), '#000000');
458
+ _setColor(colorBox.eq(1), '');
459
+ // foucs and select
460
+ widthBox[0].focus();
461
+ widthBox[0].select();
462
+ // get selected cell
463
+ var cell = self.plugin.getSelectedCell();
464
+ var match,
465
+ cellWidth = cell[0].style.width || cell[0].width || '',
466
+ cellHeight = cell[0].style.height || cell[0].height || '';
467
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
468
+ widthBox.val(match[1]);
469
+ widthTypeBox.val(match[2]);
470
+ } else {
471
+ widthBox.val('');
472
+ }
473
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
474
+ heightBox.val(match[1]);
475
+ heightTypeBox.val(match[2]);
476
+ }
477
+ textAlignBox.val(cell[0].style.textAlign || '');
478
+ verticalAlignBox.val(cell[0].style.verticalAlign || '');
479
+ var border = cell[0].style.borderWidth || '';
480
+ if (border) {
481
+ border = parseInt(border);
482
+ }
483
+ borderBox.val(border);
484
+ _setColor(colorBox.eq(0), K.toHex(cell[0].style.borderColor || ''));
485
+ _setColor(colorBox.eq(1), K.toHex(cell[0].style.backgroundColor || ''));
486
+ widthBox[0].focus();
487
+ widthBox[0].select();
488
+ },
489
+ insert : function() {
490
+ this.prop(true);
491
+ },
492
+ 'delete' : function() {
493
+ var table = self.plugin.getSelectedTable();
494
+ self.cmd.range.setStartBefore(table[0]).collapse(true);
495
+ self.cmd.select();
496
+ table.remove();
497
+ self.addBookmark();
498
+ },
499
+ colinsert : function(offset) {
500
+ var table = self.plugin.getSelectedTable()[0],
501
+ row = self.plugin.getSelectedRow()[0],
502
+ cell = self.plugin.getSelectedCell()[0],
503
+ index = cell.cellIndex + offset;
504
+ // 取得第一行的index
505
+ index += table.rows[0].cells.length - row.cells.length;
506
+
507
+ for (var i = 0, len = table.rows.length; i < len; i++) {
508
+ var newRow = table.rows[i],
509
+ newCell = newRow.insertCell(index);
510
+ newCell.innerHTML = K.IE ? '' : '<br />';
511
+ // 调整下一行的单元格index
512
+ index = _getCellIndex(table, newRow, newCell);
513
+ }
514
+ self.cmd.range.selectNodeContents(cell).collapse(true);
515
+ self.cmd.select();
516
+ self.addBookmark();
517
+ },
518
+ colinsertleft : function() {
519
+ this.colinsert(0);
520
+ },
521
+ colinsertright : function() {
522
+ this.colinsert(1);
523
+ },
524
+ rowinsert : function(offset) {
525
+ var table = self.plugin.getSelectedTable()[0],
526
+ row = self.plugin.getSelectedRow()[0],
527
+ cell = self.plugin.getSelectedCell()[0];
528
+ var rowIndex = row.rowIndex;
529
+ if (offset === 1) {
530
+ rowIndex = row.rowIndex + (cell.rowSpan - 1) + offset;
531
+ }
532
+ var newRow = table.insertRow(rowIndex);
533
+
534
+ for (var i = 0, len = row.cells.length; i < len; i++) {
535
+ // 调整cell个数
536
+ if (row.cells[i].rowSpan > 1) {
537
+ len -= row.cells[i].rowSpan - 1;
538
+ }
539
+ var newCell = newRow.insertCell(i);
540
+ // copy colspan
541
+ if (offset === 1 && row.cells[i].colSpan > 1) {
542
+ newCell.colSpan = row.cells[i].colSpan;
543
+ }
544
+ newCell.innerHTML = K.IE ? '' : '<br />';
545
+ }
546
+ // 调整rowspan
547
+ for (var j = rowIndex; j >= 0; j--) {
548
+ var cells = table.rows[j].cells;
549
+ if (cells.length > i) {
550
+ for (var k = cell.cellIndex; k >= 0; k--) {
551
+ if (cells[k].rowSpan > 1) {
552
+ cells[k].rowSpan += 1;
553
+ }
554
+ }
555
+ break;
556
+ }
557
+ }
558
+ self.cmd.range.selectNodeContents(cell).collapse(true);
559
+ self.cmd.select();
560
+ self.addBookmark();
561
+ },
562
+ rowinsertabove : function() {
563
+ this.rowinsert(0);
564
+ },
565
+ rowinsertbelow : function() {
566
+ this.rowinsert(1);
567
+ },
568
+ rowmerge : function() {
569
+ var table = self.plugin.getSelectedTable()[0],
570
+ row = self.plugin.getSelectedRow()[0],
571
+ cell = self.plugin.getSelectedCell()[0],
572
+ rowIndex = row.rowIndex, // 当前行的index
573
+ nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
574
+ nextRow = table.rows[nextRowIndex]; // 下一行
575
+ // 最后一行不能合并
576
+ if (table.rows.length <= nextRowIndex) {
577
+ return;
578
+ }
579
+ var cellIndex = cell.cellIndex; // 下一行单元格的index
580
+ if (nextRow.cells.length <= cellIndex) {
581
+ return;
582
+ }
583
+ var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
584
+ // 上下行的colspan不一致时不能合并
585
+ if (cell.colSpan !== nextCell.colSpan) {
586
+ return;
587
+ }
588
+ cell.rowSpan += nextCell.rowSpan;
589
+ nextRow.deleteCell(cellIndex);
590
+ self.cmd.range.selectNodeContents(cell).collapse(true);
591
+ self.cmd.select();
592
+ self.addBookmark();
593
+ },
594
+ colmerge : function() {
595
+ var table = self.plugin.getSelectedTable()[0],
596
+ row = self.plugin.getSelectedRow()[0],
597
+ cell = self.plugin.getSelectedCell()[0],
598
+ rowIndex = row.rowIndex, // 当前行的index
599
+ cellIndex = cell.cellIndex,
600
+ nextCellIndex = cellIndex + 1;
601
+ // 最后一列不能合并
602
+ if (row.cells.length <= nextCellIndex) {
603
+ return;
604
+ }
605
+ var nextCell = row.cells[nextCellIndex];
606
+ // 左右列的rowspan不一致时不能合并
607
+ if (cell.rowSpan !== nextCell.rowSpan) {
608
+ return;
609
+ }
610
+ cell.colSpan += nextCell.colSpan;
611
+ row.deleteCell(nextCellIndex);
612
+ self.cmd.range.selectNodeContents(cell).collapse(true);
613
+ self.cmd.select();
614
+ self.addBookmark();
615
+ },
616
+ rowsplit : function() {
617
+ var table = self.plugin.getSelectedTable()[0],
618
+ row = self.plugin.getSelectedRow()[0],
619
+ cell = self.plugin.getSelectedCell()[0],
620
+ rowIndex = row.rowIndex;
621
+ // 不是可分割单元格
622
+ if (cell.rowSpan === 1) {
623
+ return;
624
+ }
625
+ var cellIndex = _getCellIndex(table, row, cell);
626
+ for (var i = 1, len = cell.rowSpan; i < len; i++) {
627
+ var newRow = table.rows[rowIndex + i],
628
+ newCell = newRow.insertCell(cellIndex);
629
+ if (cell.colSpan > 1) {
630
+ newCell.colSpan = cell.colSpan;
631
+ }
632
+ newCell.innerHTML = K.IE ? '' : '<br />';
633
+ // 调整下一行的单元格index
634
+ cellIndex = _getCellIndex(table, newRow, newCell);
635
+ }
636
+ K(cell).removeAttr('rowSpan');
637
+ self.cmd.range.selectNodeContents(cell).collapse(true);
638
+ self.cmd.select();
639
+ self.addBookmark();
640
+ },
641
+ colsplit : function() {
642
+ var table = self.plugin.getSelectedTable()[0],
643
+ row = self.plugin.getSelectedRow()[0],
644
+ cell = self.plugin.getSelectedCell()[0],
645
+ cellIndex = cell.cellIndex;
646
+ // 不是可分割单元格
647
+ if (cell.colSpan === 1) {
648
+ return;
649
+ }
650
+ for (var i = 1, len = cell.colSpan; i < len; i++) {
651
+ var newCell = row.insertCell(cellIndex + i);
652
+ if (cell.rowSpan > 1) {
653
+ newCell.rowSpan = cell.rowSpan;
654
+ }
655
+ newCell.innerHTML = K.IE ? '' : '<br />';
656
+ }
657
+ K(cell).removeAttr('colSpan');
658
+ self.cmd.range.selectNodeContents(cell).collapse(true);
659
+ self.cmd.select();
660
+ self.addBookmark();
661
+ },
662
+ coldelete : function() {
663
+ var table = self.plugin.getSelectedTable()[0],
664
+ row = self.plugin.getSelectedRow()[0],
665
+ cell = self.plugin.getSelectedCell()[0],
666
+ index = cell.cellIndex;
667
+ for (var i = 0, len = table.rows.length; i < len; i++) {
668
+ var newRow = table.rows[i],
669
+ newCell = newRow.cells[index];
670
+ if (newCell.colSpan > 1) {
671
+ newCell.colSpan -= 1;
672
+ if (newCell.colSpan === 1) {
673
+ K(newCell).removeAttr('colSpan');
674
+ }
675
+ } else {
676
+ newRow.deleteCell(index);
677
+ }
678
+ // 跳过不需要删除的行
679
+ if (newCell.rowSpan > 1) {
680
+ i += newCell.rowSpan - 1;
681
+ }
682
+ }
683
+ if (row.cells.length === 0) {
684
+ self.cmd.range.setStartBefore(table).collapse(true);
685
+ self.cmd.select();
686
+ K(table).remove();
687
+ } else {
688
+ self.cmd.selection(true);
689
+ }
690
+ self.addBookmark();
691
+ },
692
+ rowdelete : function() {
693
+ var table = self.plugin.getSelectedTable()[0],
694
+ row = self.plugin.getSelectedRow()[0],
695
+ cell = self.plugin.getSelectedCell()[0],
696
+ rowIndex = row.rowIndex;
697
+ // 从下到上删除
698
+ for (var i = cell.rowSpan - 1; i >= 0; i--) {
699
+ table.deleteRow(rowIndex + i);
700
+ }
701
+ if (table.rows.length === 0) {
702
+ self.cmd.range.setStartBefore(table).collapse(true);
703
+ self.cmd.select();
704
+ K(table).remove();
705
+ } else {
706
+ self.cmd.selection(true);
707
+ }
708
+ self.addBookmark();
709
+ }
710
+ };
711
+ self.clickToolbar(name, self.plugin.table.prop);
712
+ });